<!---
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.3 $
$Id: supply_add_action.cfm,v 1.3 2009/02/16 20:15:08 arlen Exp $
$Date: 2009/02/16 20:15:08 $
--->
<cfquery name="GetSupply" datasource="#Application.DataSrc#">
SELECT Supply_ID, Price, HCPCS, Revenue_Code
FROM #Request.prefix_db_agency#.Supply
WHERE Supply_ID = '#form.Supply_ID#'
AND Agency_ID = #session.AgencyID#
</cfquery>

<cfset Total_Price = #GetSupply.Price# * #form.Total_Units# />
<cfset Rev = #GetSupply.Revenue_Code# />
<cfset HCPCS = #GetSupply.HCPCS# />

<cfif form.Supply_Sched_ID EQ 0>

<cfquery name="PC" datasource="#Application.DataSrc#">
	INSERT INTO #Request.prefix_db_lookup#.Supply_Sched (
		Supply_ID, 
		ScheduleItems_ID,
		Patient_ID,
		Assessment_Tracker_ID,
		Total_Units,
		Total_Price,
		Revenue_Code,
		HCPCS,
		Payer_ID
	)
	VALUES (
		'#form.Supply_ID#',
		#form.ScheduleItems_ID#,
		#form.Patient_ID#,
		#form.Assessment_Tracker_ID#,
		#form.Total_Units#,
		#Total_Price#,
		'#Rev#',
		'#HCPCS#',
		#form.Payer_ID#
	)
</cfquery>
<cfelse>
<cfquery name="PC" datasource="#Application.DataSrc#">
	UPDATE #Request.prefix_db_lookup#.Supply_Sched SET
		Total_Units = #form.Total_Units#,
		Total_Price = #Total_Price#,
		Revenue_Code = '#Rev#',	
		HCPCS = '#HCPCS#'					
	WHERE Supply_Sched_ID = #form.Supply_Sched_ID#
</cfquery>
</cfif>

<cflocation url="index.cfm?page=patient&cat=supply_visit_list&ID=#form.Patient_ID#&SID=#form.ScheduleItems_ID#" addtoken="no">

