<cfquery  name="GetRev" datasource="#Application.DataSrc#">
	SELECT rc.Rev_CodeID,  rc.Visit_Type, rc.Description,  rc.Rev_Code,  rc.HCPCS, rc.Payer_ID,rc.RevenueCodeStatus, rc.EClaim_Price, rc.Measure, p.PayName
	FROM #Request.prefix_db_agency#.Revenue_Code rc, #Request.prefix_db_agency#.Payer p
	WHERE rc.Payer_ID = p.Payer_ID
	AND rc.Agency_ID = #session.AgencyID# and rc.RevenueCodeStatus = 'active'
	GROUP BY rc.Rev_CodeID
	ORDER BY rc.RevenueCodeStatus,p.PayName ASC, rc.Visit_Type ASC
</cfquery>
<cfquery  name="GetIRev" datasource="#Application.DataSrc#">
	SELECT rc.Rev_CodeID,  rc.Visit_Type, rc.Description,  rc.Rev_Code,  rc.HCPCS, rc.Payer_ID,rc.RevenueCodeStatus, rc.EClaim_Price, rc.Measure, p.PayName
	FROM #Request.prefix_db_agency#.Revenue_Code rc, #Request.prefix_db_agency#.Payer p
	WHERE rc.Payer_ID = p.Payer_ID
	AND rc.Agency_ID = #session.AgencyID# 
	and (rc.RevenueCodeStatus = 'deleted' or rc.RevenueCodeStatus = 'inactive')
	GROUP BY rc.Rev_CodeID
	ORDER BY rc.RevenueCodeStatus,p.PayName ASC, rc.Visit_Type ASC
</cfquery>
<cfquery  name="GetRevTotals" datasource="#Application.DataSrc#">
	SELECT DISTINCT(s.Rev_CodeID)
	FROM #Request.prefix_db_agency#.ScheduleItems s
	WHERE s.Agency_ID = #session.AgencyID#
	ORDER BY s.Rev_CodeID
</cfquery>

<cfset usedlist="" />
<cfoutput query=GetRevTotals>
	<cfset usedlist=ListAppend(usedlist,Rev_CodeID) />
</cfoutput>

<cfdocument format="PDF" > 

<!---<cfdocumentitem type="header"><font size="16">Revenue Code List</font></cfdocumentitem> --->
<h2>Active Revenue Codes</h2>
		<table border="2" cellpadding="2" cellspacing="2">
			<thead>
				<tr style="padding-left:1px;">
					<th>Payer</th>
					<th>Visit Type</th>
					<th>Description</th>
					<th>Rev Code</th>
					<th>HCPCS</th>
					<th>Unit Charge</th>
				</tr>
			</thead>
			<tbody>
				<cfoutput query="GetRev">
					<tr style="padding-left:1px;">
						<cfset Encrypted_Rev_CodeID ="" />
						<cfif Rev_CodeID neq ''>
							<cfscript>Encrypted_Rev_CodeID=encrypt(#Rev_CodeID#,"54kczhzgHTj4a8n+SRZPyg==","AES","Hex");</cfscript>
						</cfif>
						<td>#PayName#</td>
						<td>#Visit_Type#</td>
						<td>#Description#</td>
						<td>#Rev_Code#</td>
						<td>#HCPCS#</td>
						<td>#EClaim_Price#&nbsp;by&nbsp;<cfif Measure eq '1'><span style="color:green; font-weight:bold;">hour</span>
						<cfelseif Measure eq '.25'><span style="color:red;font-weight:bold;">1/4 hr</span>
						<cfelse><span style="color:blue; font-weight:bold;">visit</span></cfif></td>
					</tr>
				</cfoutput>
			</tbody>
		</table>
		<h2>Inactive Revenue Codes</h2>
		<table border="2" cellpadding="2" cellspacing="2">
			<thead>
				<tr>
					<th>Payer</th>
					<th>Visit Type</th>
					<th>Description</th>
					<th>Rev Code</th>
					<th>HCPCS</th>
					<th>Unit Charge</th>
				</tr>
			</thead>
			<tbody>
				<cfoutput query="GetIRev">				
					<tr>
						<td>#PayName#</td>
						<td>#Visit_Type#</td>
						<td>#Description#</td>
						<td>#Rev_Code#</td>
						<td>#HCPCS#</td>
						<td>#EClaim_Price#&nbsp;by&nbsp;<cfif Measure eq '1'><span style="color:green; font-weight:bold;">hour</span>
						<cfelseif Measure eq '.25'><span style="color:red;font-weight:bold;">1/4 hr</span>
						<cfelse><span style="color:blue; font-weight:bold;">visit</span></cfif></td>
				  </tr>
				</cfoutput>
			</tbody>
		</table>
		</cfdocument>