<!---
This file is Copyright © 1998-2009 by Home Care Business Services. This work may not be reproduced, in whole or in part, 
using any medium, including, but not limited to, electronic transmission, CD-ROM or published in print, without the express 
permission of Home Care Business Services.

$Revision: 1.1 $
$Id: employee_info_missing.cfm,v 1.1 2010/07/09 13:32:36 melissa Exp $
$Date: 2010/07/09 13:32:36 $
--->

	<cfquery  name="GetVisits" datasource="#Application.DataSrc#">
		SELECT COUNT(si.Schedule_ID) as TotalVisits
		       ,si.PtPayer_ID AS PAYID, si.Visit_Date, '' AS SOUT
		       ,an.Assmt_ID
		       ,a.Wage_Index
		       ,py.Pay_ID AS PPAYID, py.Pay_Name, py.Output AS POUT
		 FROM  #Request.prefix_db_agency#.pSchedules si 
		 JOIN  #Request.prefix_db_agency#.pAssessments an on  an.Assmt_ID = si.Assmt_ID
		 JOIN  #Request.prefix_db_agency#.pPatients p on p.Patient_ID = si.Patient_ID 
		 JOIN  #Request.prefix_db_lookup#.Agency a on a.Agency_ID = p.Loc_ID
		 JOIN #Request.prefix_db_agency#.pPtPayer pt on si.PtPayer_ID =  pt.PtPayer_ID
		 JOIN #Request.prefix_db_agency#.pPayer py on  pt.Payer_ID =  py.Pay_ID 
		 WHERE  p.Status < 2 
		 AND  si.Visit_Date < Now()
		 AND  si.status = 0 
		 AND  si.Nonbillable = 0
		 AND  si.Missed <> 1
		 AND  si.Invoice_ID = 0
		 AND  an.status < 2 
		 GROUP BY pt.Payer_ID
		 ORDER BY py.Pay_Name
</cfquery>






<!-- BEGIN RESPONSIVE TABLE PORTLET-->
<div class="portlet box red">
	<div class="portlet-title">
		<div class="caption"><i class="fa fa-gear"></i> Visits Ready to Bill</div>
        <div class="tools"><a href="javascript:;" class="collapse"></a></div>
        <div class="actions"> <a href="javascript:;" class="btn btn-default btn-sm" onclick="history.back();"> <i class="fa fa-arrow-circle-left"></i> Back </a></div>
	</div>
	<div class="portlet-body flip-scroll">
		<cfif GetVisits.Wage_Index eq ''>
			<p>
				<font color="##CC66FF">Wage Index has not been set in the Agency Form. You will not be able to process RAPs.</font>
			</p>
		</cfif>

		<table class="table table-bordered table-striped table-condensed flip-content" style="width:50%;">
			<thead class="flip-content">
					<tr><th>Pay Name</th>
	                    		<th>No. Visits</th>
				</tr>
			</thead>
			<tbody>
				<cfoutput query="GetVisits">
					<tr>
							
			                     <td>#Pay_Name#</td>
						<td>
							<!--- <cfif SOUT eq 'Medicare' or SOUT eq 'Final' and POUT eq 'Medicare'> --->
								<a href="index.cfm?aMenu=billing&page=agency&cat=#url.cat#&rpt=visit_compliance_medicare&ID=#GetVisits.PPAYID#&type=#GetVisits.SOUT#">#TotalVisits#</a>
			                        	<!--- <cfelseif PRIOR eq 1 and POUT neq 'Medicare'>
			                        		<a href="index.cfm?aMenu=billing&page=agency&cat=#url.cat#&rpt=visit_compliance_auth_yes&ID=#GetVisits.PPAYID#&type=#GetVisits.SOUT#">#TotalVisits#</a>
			                        	<cfelseif PRIOR eq 0 and POUT neq 'Medicare'>
			                        		<a href="index.cfm?aMenu=billing&page=agency&cat=#url.cat#&rpt=visit_compliance_auth_no&ID=#GetVisits.PPAYID#&type=#GetVisits.SOUT#">#TotalVisits#</a>
			                       	<cfelseif SOUT eq 'RAP' and POUT eq 'Medicare'>
			                        		<a href="index.cfm?aMenu=billing&page=agency&cat=#url.cat#&rpt=visit_compliance_RAP_new&ID=#GetVisits.PPAYID#&type=#GetVisits.SOUT#">#TotalVisits#</a>
			                      	</cfif> --->
			                     </td>
			                         
					</tr>
				</cfoutput>
			</tbody>
             
                <cfinclude template="rap_count.cfm">  
		</table>
	</div>
</div>
<!-- END RESPONSIVE TABLE PORTLET-->
    