<cfcomponent public="yes" output="false">
<cfinclude template='/__Security-Block.cfm' />
	<cffunction name="GetScheduledcount" access="remote" returntype="string">	
	   <cfargument name="Startdate" required="yes" hint="Authorization start,end date ">
	    <cfargument name="Enddate" required="yes" hint="Authorization start,end date">
		<cfargument name="revcode_id" required="yes" hint="Authorization start,end date and Units">
	    <cfargument name="patid" required="yes" hint="Authorization start,end date and Units">
		 <cfargument name="payid" required="yes" hint="Authorization start,end date and Units">
		  <cfargument name="Assid" required="yes" hint="Authorization start,end date and Units">
	   <cfquery  name="SchDate" datasource="#Application.DataSrc#">
	   Select case  r.Measure
                     When '.25' Then  Sum(s.Total_Units)
                     When 'visit' Then Count(s.ScheduleItems_ID)
                     When '1' Then  Cast(Sum(s.Total_Hours) AS UNSIGNED)
        End  as weekunits From #Request.prefix_db_agency#.ScheduleItems s, #Request.prefix_db_agency#.Revenue_Code r
		Where r.Rev_CodeID = s.Rev_CodeID
        AND s.Assessment_ID = '#Assid#'
		AND s.Patient_ID='#patid#'
		AND s.Payer_ID='#payid#'
		AND s.Rev_CodeID = '#revcode_id#'
		AND s.Visit_Date BETWEEN '#Startdate#' AND '#Enddate#'   
	   </cfquery>  	      
	   <cfif isdefined('SchDate.recordcount') and SchDate.recordcount gt 0>
	   <cfset RetValue=SchDate.weekunits>
	   <cfreturn #RetValue#>
	   <cfelse>
	   <cfreturn '0'>
	   </cfif>  
	</cffunction>
	<cffunction name="GetRevenueDetails" access="remote" returntype="string">	
	   <cfargument name="Revid" required="yes" hint="Authorization start,end date ">	
	   <cfargument name="TempPayid" required="yes" hint="Authorization start,end date ">    
	   <cfquery  name="revdetails" datasource="#Application.DataSrc#">
	   SELECT Rev_CodeID, Rev_Code, HCPCS, Visit_Type, Description FROM #Request.prefix_db_agency#.Revenue_Code WHERE Agency_ID ='#Session.AgencyID#'
       AND Payer_ID ='#TempPayid#'    
	   AND Rev_CodeID='#Revid#'
       And EClaim_Price IS NOT NULL And Quick_Books_Price IS NOT NULL Order by Visit_Type ASC   
	   </cfquery>  	      
	   <cfif isdefined('revdetails.recordcount') and revdetails.recordcount gt 0>
	   <cfset RetValue=revdetails.Rev_Code&' | '&revdetails.HCPCS&' | '&revdetails.Rev_CodeID>
	   <cfreturn #RetValue#>
	   <cfelse>
	   <cfreturn '0'>
	   </cfif>  	   
	</cffunction>
	
	<cffunction name="GetRevenueText" access="remote" returntype="string">	
	   <cfargument name="Revid" required="yes" hint="Authorization start,end date ">	
	   <cfargument name="TempPayid" required="yes" hint="Authorization start,end date ">    
	   <cfquery  name="revtext" datasource="#Application.DataSrc#">
	   SELECT Rev_CodeID, Rev_Code, HCPCS, Visit_Type, Description FROM #Request.prefix_db_agency#.Revenue_Code WHERE Agency_ID ='#Session.AgencyID#'
       AND Payer_ID ='#TempPayid#'    
	   AND Rev_CodeID='#Revid#'
       And EClaim_Price IS NOT NULL And Quick_Books_Price IS NOT NULL Order by Visit_Type ASC   
	   </cfquery>  	      
	   <cfif isdefined('revtext.recordcount') and revtext.recordcount gt 0>
	   <cfset RetValue=revtext.Visit_Type&' | '&revtext.Rev_Code&' | '&revtext.HCPCS>
	   <cfreturn #RetValue#>
	   <cfelse>
	   <cfreturn '0'>
	   </cfif>  
	   
	</cffunction>
	
	
	<cffunction name="GetRevdrp" access="remote" returntype="string">	
	   <cfargument name="Revid" required="yes" hint="Authorization start,end date ">	
	   <cfargument name="Payid" required="yes" hint="Authorization start,end date ">    
	   <cfquery  name="rev" datasource="#Application.DataSrc#">
	   SELECT Rev_CodeID, Rev_Code, HCPCS, Visit_Type, Description FROM #Request.prefix_db_agency#.Revenue_Code WHERE Agency_ID ='#Session.AgencyID#'
       AND Payer_ID = '#Payid#'    
	   and Rev_CodeID= '#Revid#'
      And EClaim_Price IS NOT NULL And Quick_Books_Price IS NOT NULL Order by Visit_Type ASC
	   </cfquery>  	      
	   <cfif isdefined('rev.recordcount') and rev.recordcount gt 0>
	   <cfset RetValue=rev.Rev_Code&' | '&rev.HCPCS&' | '&rev.Rev_CodeID &' | '&rev.Description>
	   <cfreturn #RetValue#>
	   <cfelse>
	   <cfreturn '0'>
	   </cfif>  
	   
	</cffunction>
	
	
	
	
	
	
</cfcomponent>