<cfcomponent displayname="Assessments Functions" hint="Return Assessments Information" output="false">
   <cffunction name="PCRupdateAssessment"  access="remote" output="Yes" returnformat="plain" returntype="string">   
		<cfargument name="Assmt_ID" required="yes" default="0">
		<cfargument name="PCR_ID" required="yes" default="0">
		<cfargument name="value" required="yes" default="0">
		<cfargument name="submitted_date" required="no" default="">
		<cfargument name="type"	 required="yes" default="">
		<cfquery name="getCurrentPCR" datasource="#Application.DataSrc#">
			SELECT PCR_Status, Verifed
			FROM #Request.prefix_db_agency#.PCR
			WHERE Assmt_ID = <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Assmt_ID#">
			AND PCR_ID = <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.PCR_ID#">
			AND Status = 0
		</cfquery>

		<cfif getCurrentPCR.recordcount EQ 0>
			<cfreturn 'PCR record not found.' />
		</cfif>

		<cfset normalizedCurrentStatus = lcase(trim(getCurrentPCR.PCR_Status & '')) />
		<cfset normalizedRequestedStatus = lcase(trim(arguments.value & '')) />
		<cfset normalizedSubmittedDate = trim(arguments.submitted_date & '') />

		<cfif arguments.type EQ 'verified' AND val(arguments.value) EQ 1 AND normalizedCurrentStatus NEQ 'complete'>
			<cfreturn 'Verified can only be checked when status is Complete.' />
		</cfif>

		<cfif arguments.type EQ 'pcr_status' AND (normalizedRequestedStatus EQ 'ready to send' OR normalizedRequestedStatus EQ 'submitted') AND val(getCurrentPCR.Verifed) NEQ 1>
			<cfreturn 'Verified must be checked before setting status to Ready to Send or Submitted.' />
		</cfif>

		<cfif arguments.type EQ 'pcr_status' AND normalizedRequestedStatus EQ 'submitted' AND (normalizedSubmittedDate EQ '' OR NOT isDate(normalizedSubmittedDate))>
			<cfreturn 'Submission date is required when status is Submitted.' />
		</cfif>

		<cfif arguments.type EQ 'submitted_date' AND normalizedCurrentStatus NEQ 'submitted'>
			<cfreturn 'Submission date can only be updated when status is Submitted.' />
		</cfif>

		<cfif arguments.type EQ 'submitted_date' AND NOT isDate(arguments.value)>
			<cfreturn 'Please enter a valid submission date.' />
		</cfif>
		<cfquery  name="updatePCR" datasource="#Application.DataSrc#">
		    UPDATE #Request.prefix_db_agency#.PCR SET 
		    	<cfif arguments.type  EQ 'facetoface'>
		    		Face_to_Face = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
		    	<cfelseif arguments.type  EQ 'poc'>
		    		Plan_Care = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
		    	<cfelseif arguments.type  EQ 'oasis'>
		    		OASIS = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
		    	<cfelseif arguments.type  EQ 'pt'>
		    		PT_Assessment = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
		    	<cfelseif arguments.type  EQ 'ot'>
		    		OT_Assessment = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
		    	<cfelseif arguments.type  EQ 'st'>
		    		ST_Assessment = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
		    	<cfelseif arguments.type  EQ 'visit'>
		    		Visit_completion = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
		    	<cfelseif arguments.type  EQ 'verified'>
		    		Verifed = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_INTEGER">,
	    		<cfelseif arguments.type  EQ 'pcr_status'>
		    		PCR_Status = <cfqueryparam value="#arguments.value#"  cfsqltype="CF_SQL_VARCHAR">,
	    			<cfif normalizedRequestedStatus EQ 'submitted'>
	    				submitted_date = <cfqueryparam value="#createODBCDate(normalizedSubmittedDate)#"  cfsqltype="CF_SQL_DATE">,
	    			</cfif>
	    		<cfelseif arguments.type EQ 'submitted_date'>
	    			submitted_date = <cfqueryparam value="#createODBCDate(arguments.value)#" cfsqltype="CF_SQL_DATE">,
		    	</cfif>
		    	record_timestamp = <cfqueryparam VALUE="#now()#"  cfsqltype="cf_sql_timestamp">
			WHERE Assmt_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Assmt_ID#">
			AND PCR_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.PCR_ID#">
			AND Status = 0
		</cfquery>
		<cfreturn 'success' />	     
	</cffunction>
	
	<!--- <cffunction name="UpdatePCR"  access="public" output="Yes" returnformat="plain" returntype="string">   
		<cfargument name="Assmt_ID" required="yes" default="0">
		<cfargument name="fileFacetoFace" required="yes" default="0">
		<cfargument name="careplans"	 required="yes" default="0">
		<cfargument name="oasisAss"	 required="yes" default="0">
		<cfargument name="ptAss"	 required="yes" default="0">
		<cfargument name="otAss"	 required="yes" default="0">
		<cfargument name="stAss"	 required="yes" default="0">
		<cfargument name="CompleteVisit"	 required="yes" default="0">
		<cfargument name="verifiedType"	 required="yes" default="0">
		<cfargument name="pcrstatus"	 required="yes" default="submitted">
		<cfquery  name="updatepAssessments" datasource="#Application.DataSrc#">
		   UPDATE #Request.prefix_db_agency#.pAssessments SET 
	    		F311 = <cfqueryparam value="#arguments.fileFacetoFace#"  cfsqltype="CF_SQL_INTEGER">,
	    		F312 = <cfqueryparam value="#arguments.careplans#"  cfsqltype="CF_SQL_INTEGER">,
	    		F313 = <cfqueryparam value="#arguments.oasisAss#"  cfsqltype="CF_SQL_INTEGER">,
	    		F314 = <cfqueryparam value="#arguments.ptAss#"  cfsqltype="CF_SQL_INTEGER">,
	    		F315 = <cfqueryparam value="#arguments.otAss#"  cfsqltype="CF_SQL_INTEGER">,
	    		F316 = <cfqueryparam value="#arguments.stAss#"  cfsqltype="CF_SQL_INTEGER">,
	    		F317 = <cfqueryparam value="#arguments.CompleteVisit#"  cfsqltype="CF_SQL_INTEGER">,
	    		F318 = <cfqueryparam value="#arguments.verifiedType#"  cfsqltype="CF_SQL_INTEGER">,
	    		F319 = <cfqueryparam value="#arguments.pcrstatus#"  cfsqltype="CF_SQL_VARCHAR">,
	    		record_timestamp = <cfqueryparam VALUE="#now()#"  cfsqltype="cf_sql_timestamp">,
				Record_Mod_By =  <cfqueryparam VALUE="#session.employeeid#"  cfsqltype="cf_sql_integer">
			WHERE Assmt_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Assmt_ID#">
			AND Status = 0
		</cfquery>
		<cfreturn 'success' />	     
	</cffunction> --->


	<cffunction name="UpdatePCR"  access="public" output="Yes" returnformat="plain" returntype="string">   
		<cfquery  name="updatePCRStatus" datasource="#Application.DataSrc#">
		   UPDATE #Request.prefix_db_agency#.PCR set Status = 2 WHERE Status = 0
		</cfquery>
		<cfreturn 'success' />	     
	</cffunction>

	<cffunction name="AddPCR" access="public" output="Yes" returnformat="plain" returntype="string">
		<cfargument name="Patient_ID" required="yes" default="0">
		<cfargument name="Assmt_ID" required="yes" default="0">
		<cfargument name="Certification_Start" required="yes" default="0">
		<cfargument name="Certification_End" required="yes" default="0">
		<cfargument name="Episode" required="yes" default="0">
		<cfargument name="Status" required="yes" default="0">
		<cfargument name="fileFacetoFace" required="yes" default="0">
		<cfargument name="careplans" required="yes" default="0">
		<cfargument name="oasisAss" required="yes" default="0">
		<cfargument name="ptAss" required="yes" default="0">
		<cfargument name="otAss" required="yes" default="0">
		<cfargument name="stAss" required="yes" default="0">
		<cfargument name="CompleteVisit" required="yes" default="0">
		<cfargument name="verifiedType" required="yes" default="0">
		<cfargument name="pcrstatus" required="yes" default="0">
		<cfargument name="Created_by" required="yes" default="#session.EmployeeID#">
		<cfargument name="Date_Create" required="yes" default="#now()#">
		<cfargument name="record_timestamp" required="yes" default="#now()#">
		<cftry>
				<cfquery  name="getAllPCR" datasource="#Application.DataSrc#">
					SELECT * FROM #Request.prefix_db_agency#.PCR
					WHERE Assmt_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Assmt_ID#">
					AND Patient_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Patient_ID#"> 
					AND Episode =  <cfqueryparam CFSQLType="CF_SQL_VARCHAR" value="#arguments.Episode#"> 
					AND Status =  0
					ORDER BY PCR_ID DESC
				</cfquery>
				<cfif getAllPCR.recordcount GT 1>
					<cfset UpdatedPCR_ID = getAllPCR.PCR_ID />
					<cfquery name="deactivateDuplicatePCR" datasource="#Application.DataSrc#">
						UPDATE #Request.prefix_db_agency#.PCR
						SET Status = 2,
							record_timestamp = <cfqueryparam value="#now()#" cfsqltype="cf_sql_timestamp">
						WHERE Assmt_ID = <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Assmt_ID#">
						AND Patient_ID = <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Patient_ID#">
						AND Episode = <cfqueryparam CFSQLType="CF_SQL_VARCHAR" value="#arguments.Episode#">
						AND Status = 0
						AND PCR_ID <> <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#UpdatedPCR_ID#">
					</cfquery>
					<cfquery name="getAllPCR" datasource="#Application.DataSrc#">
						SELECT * FROM #Request.prefix_db_agency#.PCR
						WHERE Assmt_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Assmt_ID#">
						AND Patient_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Patient_ID#"> 
						AND Episode =  <cfqueryparam CFSQLType="CF_SQL_VARCHAR" value="#arguments.Episode#"> 
						AND Status =  0
						ORDER BY PCR_ID DESC
					</cfquery>
				</cfif>
				<cfif getAllPCR.recordcount EQ 0>
					<cfquery  name='insertPCR' datasource='#Application.DataSrc#'>
						INSERT INTO #Request.prefix_db_agency#.PCR(
							Patient_ID,Assmt_ID,Status,Cert_Start,Cert_End,Face_to_Face,Plan_Care,OASIS,PT_Assessment,OT_Assessment,ST_Assessment,Episode,Visit_completion,Verifed,PCR_Status,Created_by,Date_Create,record_timestamp
						) VALUES(
							<cfqueryparam value = "#arguments.Patient_ID#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.Assmt_ID#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "0" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.Certification_Start#" CFSQLType ="CF_SQL_DATE">,
							<cfqueryparam value = "#arguments.Certification_End#" CFSQLType ="CF_SQL_DATE">,
							<cfqueryparam value = "#arguments.fileFacetoFace#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.careplans#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.oasisAss#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.ptAss#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.otAss#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.stAss#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.Episode#" CFSQLType ="CF_SQL_VARCHAR">,
							<cfqueryparam value = "#arguments.CompleteVisit#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.verifiedType#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.pcrstatus#" CFSQLType ="CF_SQL_VARCHAR">,
							<cfqueryparam value = "#arguments.Created_by#" CFSQLType ="CF_SQL_INTEGER">,
							<cfqueryparam value = "#arguments.Date_Create#" CFSQLType ="cf_sql_timestamp">,
							<cfqueryparam value = "#arguments.record_timestamp#" CFSQLType ="cf_sql_timestamp">
						)
					</cfquery>
				<cfelseif getAllPCR.PCR_Status  NEQ 'submitted'>
					<cfset UpdatedPCR_ID = getAllPCR.PCR_ID />
					<cfquery  name="updatePCR" datasource="#Application.DataSrc#">
					   UPDATE #Request.prefix_db_agency#.PCR SET 
				    		Face_to_Face = <cfqueryparam value="#arguments.fileFacetoFace#"  cfsqltype="CF_SQL_INTEGER">,
				    		Plan_Care = <cfqueryparam value="#arguments.careplans#"  cfsqltype="CF_SQL_INTEGER">,
				    		OASIS = <cfqueryparam value="#arguments.oasisAss#"  cfsqltype="CF_SQL_INTEGER">,
				    		PT_Assessment = <cfqueryparam value="#arguments.ptAss#"  cfsqltype="CF_SQL_INTEGER">,
				    		OT_Assessment = <cfqueryparam value="#arguments.otAss#"  cfsqltype="CF_SQL_INTEGER">,
				    		ST_Assessment = <cfqueryparam value="#arguments.stAss#"  cfsqltype="CF_SQL_INTEGER">,
				    		Visit_completion = <cfqueryparam value="#arguments.CompleteVisit#"  cfsqltype="CF_SQL_INTEGER">,
				    		Episode = <cfqueryparam value="#arguments.Episode#"  cfsqltype="CF_SQL_VARCHAR">,
				    	record_timestamp = <cfqueryparam VALUE="#now()#"  cfsqltype="cf_sql_timestamp">
						WHERE Assmt_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Assmt_ID#">
						AND PCR_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#UpdatedPCR_ID#">
						AND Patient_ID =  <cfqueryparam CFSQLType="CF_SQL_INTEGER" value="#arguments.Patient_ID#">
						AND Status = 0
					</cfquery>
				</cfif>
			<cfcatch><cfdump var="#cfcatch#"><cfabort></cfcatch>
		</cftry>
		<cfreturn 'success' />
	</cffunction>

	<cffunction name="getAllDocs" output="Yes" returnFormat= "plain" access="remote">
		<cfargument name="Assmt_ID" required="yes" default="0">
		<cfargument name="Patient_ID" required="yes" default="0">
		<cfargument name="Admit_ID" required="yes" default="0">

		<cfquery  name='getfiles' datasource='#Application.DataSrc#'>
			SELECT id, Title, DocumentDesc.Description AS Docdescription,FileName,Created,PatientId,CreatedBy,files.placeholder,
			files.Notes,files.faxsend_to,files.faxsent_time,
			Assessment,files.DOC_ID,files.Expires  
			FROM   #Request.prefix_db_agency#.files
			LEFT OUTER JOIN #Request.prefix_db_agency#.DocumentDesc  ON files.DOC_ID = DocumentDesc.DOC_ID
			WHERE  AgencyId = '#session.AgencyId#'
			AND    PatientId = '#arguments.Patient_ID#'
			AND Status = 0
			<cfif Session.EmpLevel eq 6>
				AND CreatedBy = '#Session.EmployeeID#'
			</cfif>
			GROUP BY files.id
			ORDER BY id
		</cfquery>

		<cfquery  name='getdocument' datasource='#Application.DataSrc#'>
			SELECT * FROM  #Request.prefix_db_agency#.DocumentDesc
			WHERE DocumentType like '%Patient%'
			AND Required = 1
			ORDER BY DOC_ID
		</cfquery> 

		<cfquery name="Get4875Orders" datasource="#Application.DataSrc#">
			SELECT pCMS4857.Order_ID, pAssessments.Patient_ID, pAssessments.F26, pCMS4857.Certification_From AS Cert_Start ,
			pCMS4857.Certification_To AS Cert_End, pCMS4857.Form_Type,pCMS4857.Form_Status,pAssessments.F176 AS Assesment_completed ,
			 pCMS4857.Date_Create, pCMS4857.Clinician_Signature,
				".." AS Addendum_Details_21, "" AS pcp_notification,
					pAssessments.F26 AS Assessment_Reason_M0100,pCMS4857.*
			FROM  #Request.prefix_db_agency#.pCMS4857,
			#Request.prefix_db_agency#.pAssessments,
			#Request.prefix_db_agency#.pPatients
			WHERE  pCMS4857.Status = 0
			And   (pCMS4857.Form_Type like '%Form%' or  pCMS4857.Form_Type like '%60-day%'
			or  pCMS4857.Form_Type like '%14-day%' or 
			pCMS4857.Form_Type like '%Discharge-Summary%')
			AND   pAssessments.Assmt_ID = pCMS4857.Assmt_ID
			AND   pPatients.Patient_ID =   pAssessments.Patient_ID
			AND   pPatients.Patient_ID = '#arguments.Patient_ID#'
			And   pAssessments.status = 0
			And   pPatients.status < 2
			And   pAssessments.Patient_ID = #arguments.Patient_ID#
			AND   pAssessments.Admit_ID = #arguments.Admit_ID#
			<cfif Session.EmpLevel eq 6 or Session.EmpLevel eq 8>
				AND
					(
						'#session.EmployeeId#'
						IN
						(
							select distinct Emp_ID from #Request.prefix_db_agency#.pSchedules
							where patient_id = pAssessments.Patient_ID and Status = 0
						)
					)
			</cfif>
			GROUP BY pCMS4857.Order_ID
			Order By Cert_Start Desc
		</cfquery>

		<cfquery  name='getpgfiles' datasource='#Application.DataSrc#'>
			SELECT pg_files.id,pg_files.DOC_ID, pg_files.Title,pg_files.FileName,pg_files.Created,pg_files.Patient_Id,pg_files.CreatedBy,
			pg_files.Notes,pg_files.faxsend_to,pg_files.faxsent_time,
			DocumentDesc.Description AS Docdescription,
			pEmployee.Emp_Last, pEmployee.Emp_First , pSchedules.* 
			FROM    #Request.prefix_db_agency#.pg_files
			LEFT OUTER JOIN #Request.prefix_db_agency#.pSchedules  ON pg_files.Schedule_ID  = pSchedules.Schedule_ID AND pSchedules.Status= 0
			LEFT OUTER JOIN #Request.prefix_db_lookup#.pEmployee  ON pg_files.CreatedBy  = pEmployee.Emp_ID
			LEFT OUTER JOIN #Request.prefix_db_agency#.DocumentDesc  ON pg_files.DOC_ID = DocumentDesc.DOC_ID
			WHERE  pg_files.Agency_Id = '#session.AgencyId#'
			AND    pg_files.Patient_Id = '#arguments.Patient_ID#'
			AND Title != 'Wounds_assessments'
			AND pg_files.Status = 0
			GROUP BY pg_files.id
			ORDER BY pg_files.id

		</cfquery> 


		<cfquery  name='getpgfiles1' datasource='#Application.DataSrc#'>
			SELECT pg_files.id,pg_files.DOC_ID, pg_files.Title,pg_files.FileName,pg_files.Created,pg_files.Patient_Id,pg_files.CreatedBy,
			pg_files.Notes,pg_files.faxsend_to,pg_files.faxsent_time,
			DocumentDesc.Description AS Docdescription,
			pEmployee.Emp_Last, pEmployee.Emp_First , pAssessments.* 
			FROM    #Request.prefix_db_agency#.pg_files
			LEFT OUTER JOIN #Request.prefix_db_agency#.pAssessments  ON pg_files.Schedule_ID  = pAssessments.Assmt_ID AND pAssessments.Status = 0
			LEFT OUTER JOIN #Request.prefix_db_lookup#.pEmployee  ON pg_files.CreatedBy  = pEmployee.Emp_ID
			LEFT OUTER JOIN #Request.prefix_db_agency#.DocumentDesc  ON pg_files.DOC_ID = DocumentDesc.DOC_ID
			WHERE  pg_files.Agency_Id = '#session.AgencyId#'
			AND    pg_files.Patient_Id = '#arguments.Patient_ID#'
			AND Title = 'Wounds_assessments'
			AND pg_files.Status = 0
			GROUP BY pg_files.id
			ORDER BY pg_files.id

		</cfquery>

		<cfquery  name='getassdocument' datasource='#Application.DataSrc#'>
			SELECT * FROM  #Request.prefix_db_agency#.DocumentDesc
			WHERE DocumentType like '%Assessment%'
			AND Required = 1
			ORDER BY DOC_ID
		</cfquery> 

		<cfquery  name="Getorders"  datasource="#Application.DataSrc#">
			SELECT * FROm #Request.prefix_db_agency#.pCMS4857
		 	JOIN #Request.prefix_db_agency#.pAssessments ON pAssessments.Assmt_ID =  pCMS4857.Assmt_ID 
		 	AND pAssessments.status = 0 
		 	AND  pCMS4857.status = 0
		 	AND pAssessments.Patient_ID =  #arguments.Patient_ID#
		 	GROUP BY Order_ID
		</cfquery>

		<cfset request.pat = CreateObject("component","components.general.patients").init() />
		<cfset  getadmit = request.pat.get_admit(#arguments.Patient_ID#,#arguments.Admit_ID#) />

		<cfquery  name="getallassessments"  datasource="#Application.DataSrc#">
		     SELECT * FROM  #Request.prefix_db_agency#.pAssessments
		     WHERE Admit_ID = '#arguments.Admit_ID#'  
		     AND status = 0 
		     AND F25 = 1
		</cfquery>

		<cfquery name="getProgressNotes" datasource="#Application.DataSrc#">
			SELECT pSchedules.Schedule_ID, pSchedules.Assmt_ID, pSchedules.Visit_Date, pSchedules.Visit_Type, pSchedules.Skill
			FROM #Request.prefix_db_agency#.pSchedules
			JOIN #Request.prefix_db_agency#.pAssessments ON pAssessments.Assmt_ID = pSchedules.Assmt_ID
				AND pAssessments.Status = 0
			WHERE pSchedules.Patient_ID = <cfqueryparam value="#arguments.Patient_ID#" cfsqltype="CF_SQL_INTEGER">
			AND pAssessments.Admit_ID = <cfqueryparam value="#arguments.Admit_ID#" cfsqltype="CF_SQL_INTEGER">
			AND pSchedules.Status = 0
			AND pSchedules.Progress_Note = 'Yes'
			AND (pSchedules.Missed = 0 OR pSchedules.Missed = 'No' OR pSchedules.Missed = '')
			ORDER BY pSchedules.Visit_Date DESC, pSchedules.Schedule_ID DESC
		</cfquery>

		<cfquery  name="GetfaxList"  datasource="#Application.DataSrc#">
			SELECT * FROm #Request.prefix_db_lookup#.Received_faxes
		 	WHERE Received_faxes.Agency_ID = #session.agencyid#
		 	AND Patient_ID =  #arguments.Patient_ID#
		 	AND status = 0
		 	ORDER BY Received_faxes.completed_timestamp  DESC 
		</cfquery>

	 	<cfset url.encpatid  =  encrypt(#arguments.Patient_ID#,#application.enckey#,"AES","Hex")  />
	 	<cfset url.encassid = encrypt(#arguments.Assmt_ID#,#application.enckey#,"AES","Hex") />

		<cfsavecontent variable = "html_Docsview">
			<h4>Face to Face</h4>
			<cfif getfiles.RecordCount gt 0>
				<table class="table table-bordered table-striped table-condensed flip-content">
					<thead class="flip-content">
						<tr>
							<th class="bold">Document Type</th>
							<th class="bold">File Name</th>
							<th class="bold">Uploaded By</th>
							<th class="bold">Upload Date</th>
							<th class="bold">Action</th>
						</tr>
					</thead>
					<tbody>
						<cfset count=1 />
						<cfoutput query="getfiles">
							<cfquery name='getfilesDetails' datasource='#Application.DataSrc#'>
								SELECT e.Emp_Last, e.Emp_First
								FROM   #Request.prefix_db_lookup#.pEmployee e
								WHERE  e.Emp_ID = '#getfiles.CreatedBy#'
							</cfquery>

							<cfif ArrayContains([1,2,3,4,5,6,7,8,9], Session.EmpLevel)>
								<tr>
									<td>
										#getfiles.Title#

									</td>
									<td> #getfiles.FileName#</td>
									<td><cfif getfiles.FileName NEQ ''>#getfilesDetails.Emp_Last#, #getfilesDetails.Emp_First#</cfif></td>
				        	
									<td><cfif getfiles.FileName NEQ ''>#DateFormat(getfiles.Created, 'mm/dd/yyyy')#</cfif></td>
									<td>
										<cfset faceToFaceLabel = lcase(trim(getfiles.Title & ' ' & getfiles.Docdescription)) />
										<cfif getfiles.FileName NEQ '' AND (faceToFaceLabel contains 'physician face-to-face' OR faceToFaceLabel contains 'physician face to face' OR faceToFaceLabel contains 'history & physical' OR faceToFaceLabel contains 'history and physical')>
											<a class="btn btn-sm grey" target="_blank" href="../patientadmin_new/S3-PDF-Viewer.cfm?id=#getfiles.id#&filetype=patientfiles"><i class="fa fa-print"></i> Print</a>
										</cfif>
 									</td>
									<cfset count=count+1 />
								</tr>
							<cfelse>
								<tr>
									
									<cfset file_id = #getfiles.id# />
									<td> 
										<!---<div class="docid_edit hide" id="docid_edit#file_id#">
										   <div class="row">
												<div class="col-md-10 editable-input" style="position: relative;">
												   <select class="form-control" id="docidtext_#file_id#" style="padding-right: 24px;" value="#getfiles.Doc_ID#">
												   		<cfloop query = "getdocument">
												   			<option value="#getdocument.DOC_ID#" <cfif #getfiles.DOC_ID#  EQ getdocument.DOC_ID >selected</cfif>>#Description#</option>
												   		</cfloop>
												   </select>
												   <span class="editable-clear-x"></span>
												</div>
												<div class="editable-buttons col-md-2 col-md-6-off">
												<button type="submit" class="btn blue editable-submit" onclick="savefiletitle(#getfiles.id#,'document_type');"><i class="fa fa-check"></i></button>
												<button type="button" class="btn default editable-cancel"  onclick='$("##docid_edit#file_id#").addClass("hide");$("##docid_span#file_id#").removeClass("hide");' ><i class="fa fa-times"></i></button>
												</div>
											</div>
										</div>
										<a href='##' id="docid_span#file_id#" class="docid_span"> <cfif getfiles.Docdescription NEQ ''>#getfiles.Docdescription#<cfelse><span style="color:red;">* required</span></cfif></a>--->
										<cfif getfiles.Docdescription NEQ ''>#getfiles.Docdescription#<cfelse><span style="color:red;">* required</span></cfif>

									</td>

									<td>
										<cfif getfiles.FileName NEQ ''>
											#getfiles.FileName#
											<a href='../patientadmin_new/Patient-File-Viewer.cfm?id=#getfiles.id#' target='pfv' class="btn btn-xs grey">Download <i class="fa fa-download" aria-hidden="true"></i></a>
											</td>
										</cfif>
									<td><cfif getfiles.FileName NEQ ''>#getfilesDetails.Emp_Last#, #getfilesDetails.Emp_First#</cfif></td>
									<td><cfif getfiles.FileName NEQ ''>#DateFormat(getfiles.Created, 'mm/dd/yyyy')#</cfif></td>
									<td>
										<cfset faceToFaceLabel = lcase(trim(getfiles.Title & ' ' & getfiles.Docdescription)) />
										<cfif getfiles.FileName NEQ '' AND (faceToFaceLabel contains 'physician face-to-face' OR faceToFaceLabel contains 'physician face to face' OR faceToFaceLabel contains 'history & physical' OR faceToFaceLabel contains 'history and physical')>
											<a class="btn btn-sm grey" target="_blank" href="/patientadmin_new/S3-PDF-Viewer.cfm?id=#getfiles.id#&filetype=patientfiles"><i class="fa fa-print"></i> Print</a>
										</cfif>
 									</td>
								</tr>
							</cfif>

						</cfoutput>
					</tbody>
				</table>
			</cfif>

			<cfif Get4875Orders.RecordCount gt 0>
				<h4>Orders</h4>
				<table class="table table-bordered table-striped table-condensed flip-content">
					<thead class="flip-content">
						<tr>
							<th>Certification</th>
			            <!---<th>Added</th>--->
							<th>Type</th>
							<th>Order</th>
							<th>Action</th>
						</tr>
					</thead>
					<tbody>
						<cfoutput query="Get4875Orders">
							<tr id="orderrow_#Order_ID#">
			                    <td>
			                    	<cfif Cert_Start EQ '' OR Cert_End EQ '' >
			                    		#DateFormat(Assesment_completed,"mm/dd/yyyy")# 
			                    	<cfelse>	
											#DateFormat(Cert_Start,"mm/dd/yyyy")#-#DateFormat(Cert_End,"mm/dd/yyyy")#
			                    	</cfif>
								</td>
								<!---<td>#DateFormat(Date_Create,"mm/dd/yyyy")#</td>--->
								  <cfset  enc_afid= encrypt(#Order_ID#,"54kczhzgHTj4a8n+SRZPyg==","AES","Hex") />					
								<cfif  Form_Type IS "60-day" >
										<td>#Form_Type#</td>
								<cfelseif  Form_Type IS "14-day" >
										<td>#Form_Type#</td>
							    <cfelseif Form_Type IS "Discharge-Summary" >
										<td>#Form_Type#</td>		
								<cfelse>
									<td>
										<cfif (session.eaorders EQ 1 OR session.IsAgencyLogin EQ 1)>
											<cfif Form_Type IS "Form 487" >
													<cfif session.eaOrders EQ 1 or Session.IsAgencyLogin eq 1>
														<cfif pcp_notification neq ''>
															#pcp_notification# Notification
														<cfelse>
															#Form_Type#
														</cfif>
													<cfelse>
														#Form_Type#
													</cfif>
											<cfelse>                              
												<cfif session.eaOrders EQ 1 or Session.IsAgencyLogin eq 1>
													#Form_Type#
												<cfelse>
													#Form_Type#
												</cfif>
											</cfif>
										<cfelse>
											#Form_Type#
										</cfif>

									</td>
								</cfif>

								<cfset thereason = Assessment_Reason_M0100 />
								<cfif LEFT(thereason,1) eq '1'>
									<cfset thereason = '1 - Start of Care' />
								<cfelseif LEFT(thereason,1) eq '4'>
									<cfset thereason = '4 - Recertification' />
								</cfif>

								<td>
									<cfif (session.eaorders EQ 1 OR session.IsAgencyLogin EQ 1)>
										<cfif Form_Type IS "Form 487">
											<cfif pcp_notification neq ''>
													#LEFT(Order_description, 60)#...
												<cfelse>
													#LEFT(Order_description, 60)#...
											</cfif>
										<cfelse>
												#LEFT(Careplan_SN, 60)#...
										</cfif>
									<cfelse>
										<cfif Form_Type IS "Form 487">	
											#LEFT(Order_description, 60)#...
										<cfelse>	
											#LEFT(Careplan_SN, 60)#...
										</cfif>
									</cfif>
								</td>
								<cfif Form_Type IS "60-day" >
									<td>
										<a class="btn btn-sm grey" href="javascript:;" onclick="window.open('../patientadmin_new/index.cfm?page=patient&cat=60day_Summarypdf&AID=#session.cs.assessment_id#&afid=#enc_afid#&Original=Print','Title','resizable=yes, width=800, height=800, top=10, left=10');"><i class="fa fa-print"></i> Print</a>
									</td>
								<cfelseif  Form_Type IS "14-day" >
									<td>
										<a class="btn btn-sm grey" href="javascript:;" onclick="window.open('../patientadmin_new/index.cfm?page=patient&cat=14day_Summarypdf&AID=#session.cs.assessment_id#&afid=#enc_afid#&Original=Print','Title','resizable=yes, width=800, height=800, top=10, left=10');"><i class="fa fa-print"></i> Print</a>
									</td>
										
						      	<cfelseif  Form_Type IS "Discharge-Summary" >
										<td>
											<a class="btn btn-sm grey" href="javascript:;" onclick="window.open('../patientadmin_new/index.cfm?page=patient&cat=discharge_Summarypdf&AID=#session.cs.assessment_id#&afid=#enc_afid#&Original=Print','Title','resizable=yes, width=800, height=800, top=10, left=10');"><i class="fa fa-print"></i> Print</a>
										</td>													
								<cfelse>
									<td>

										<cfquery name="get4857pdf"  datasource="#Application.DataSrc#">
											 SELECT * FROM #Request.prefix_db_lookup#.Received_faxes
											 WHERE  Order_ID  = <cfqueryparam value = "#Order_ID#" CFSQLType ="CF_SQL_INTEGER">
											 AND Agency_ID = <cfqueryparam value = "#session.agencyid#" CFSQLType ="CF_SQL_INTEGER">
										</cfquery>
										<cfif  get4857pdf.recordcount gt 0 >
												<a class="btn btn-sm grey" onclick="printform('../agencyadmin/getfax_file.cfm?fax_id=#get4857pdf.fax_id#')"><i class="fa fa-print"></i> Print</a>	
										<cfelse>

											<cfif Form_Type IS "Form 487">
											<a class="btn btn-sm grey" onclick="printform('../patientadmin_new/index.cfm?page=patient&cat=487_print&afid=#enc_afid#')"><i class="fa fa-print"></i> Print</a>
											<cfelse>
											    <cfif lcase(thereason) contains 'Hospice'>
											        <a class="btn btn-sm grey" href="javascript:;" onclick="printform(../patientadmin_new/index.cfm?page=patient&cat=PrintAssesmentForm_Hospice&afid=#enc_afid#&Original=Print');"><i class="fa fa-print"></i> Print</a>
											    <cfelse>
												     <a class="btn btn-sm grey" href="javascript:;" onclick="printform('../patientadmin_new/index.cfm?page=patient&cat=PrintAssesmentForm&afid=#enc_afid#&Original=Print');"><i class="fa fa-print"></i> Print </a>
											    </cfif>
											</cfif>
										</cfif>

									</td>
								</cfif>
							</tr>
						</cfoutput>
					</tbody>
				</table>
			</cfif>

			<cfif getProgressNotes.RecordCount gt 0>
				<h4>Progress Notes</h4>
				<table class="table table-bordered table-striped table-condensed flip-content">
					<thead class="flip-content">
						<tr>
							<th class="bold">Visit Date</th>
							<th class="bold">Visit Type</th>
							<th class="bold">Action</th>
						</tr>
					</thead>
					<tbody>
						<cfoutput query="getProgressNotes">
							<cfset progress_assmt_id = getProgressNotes.Assmt_ID />
							<cfif progress_assmt_id EQ '' OR progress_assmt_id EQ 0>
								<cfset progress_assmt_id = arguments.Assmt_ID />
							</cfif>
							<cfset enc_progress_assid = encrypt(#progress_assmt_id#,#application.enckey#,"AES","Hex") />
							<cfset enc_progress_sid = encrypt(#getProgressNotes.Schedule_ID#,#application.enckey#,"AES","Hex") />
							<cfset visitTypeLabel = trim(getProgressNotes.Visit_Type) />
							<cfif visitTypeLabel EQ ''>
								<cfset visitTypeLabel = getProgressNotes.Skill />
							</cfif>
							<tr>
								<td>#DateFormat(getProgressNotes.Visit_Date, 'mm/dd/yyyy')#</td>
								<td>#visitTypeLabel#</td>
								<td>
									<a class="btn btn-sm grey" target="_blank" href="../patientadmin_new/index.cfm?page=patient&ID=#url.encpatid#&cat=ProgressNoteSNPDF&restrict=1&formonly=1&AID=#enc_progress_assid#&SID=#enc_progress_sid#"><i class="fa fa-print"></i> Print</a>
								</td>
							</tr>
						</cfoutput>
					</tbody>
				</table>
			</cfif>

			<cfif getpgfiles1.RecordCount gt 0>
				<h4>Assessment</h4>
				<table class="table table-bordered table-striped table-condensed flip-content">
					<thead class="flip-content">
						<tr>
							<th class="bold">Document Type</th> 
							<th class="bold">Photo Title</th>
							<th class="bold">Assessments</th>
							<th class="bold">Employee</th>
							<th class="bold">Upload Date</th>
							<th class="bold">Fax Sent Date/Time</th>
							<th class="bold">Action</th>
						</tr>
					</thead>
					<tbody>
						<cfset count=1 />
						<cfoutput query="getpgfiles1">
								<tr>
									<cfset file_id = #getpgfiles1.id# />
									 <td> 
										<div class="assdocid_edit hide" id="assdocid_edit#file_id#">
										   <div class="row">
												<div class="col-md-10 editable-input" style="position: relative;">
												   <select class="form-control" id="assdocidtext_#file_id#" style="padding-right: 24px;" value="#getpgfiles1.Doc_ID#">
												   		<cfloop query = "#getassdocument#">
												   			<option value="#getassdocument.DOC_ID#" <cfif #getpgfiles1.DOC_ID#  EQ getassdocument.DOC_ID >selected</cfif>>#Description#</option>
												   		</cfloop>
												   </select>
												   <span class="editable-clear-x"></span>
												</div>
												<div class="editable-buttons col-md-2 col-md-6-off">
												<button type="submit" class="btn blue editable-submit" onclick="saveassessfiletitle(#getpgfiles1.id#,'document_type');"><i class="fa fa-check"></i></button>
												<button type="button" class="btn default editable-cancel"  onclick='$("##assdocid_edit#file_id#").addClass("hide");$("##assdocid_span#file_id#").removeClass("hide");' ><i class="fa fa-times"></i></button>
												</div>
											</div>
										</div>
										<cfif getpgfiles1.Docdescription NEQ ''>#getpgfiles1.Docdescription#<cfelse><span style="color:red;">* required</span></cfif>

									</td> 
									<td>#getpgfiles1.FileName# </td>
									<td> #F26#(#DateFormat(F177, 'mm/dd/yyyy')# - #DateFormat(F178, 'mm/dd/yyyy')#) </td>
									<td>#getpgfiles1.Emp_Last#, #getpgfiles1.Emp_First#</td>
	                <td>#DateFormat(getpgfiles1.Created, 'mm/dd/yyyy')#</td>
	                <td><cfif faxsend_to NEQ ''>fax sent to #faxsend_to# on #dateTimeFormat(faxsent_time, "short")#</cfif></td>
									<td>
										<a href='../patientadmin_new/Progress-File-Viewer.cfm?id=#getpgfiles1.id#' target='pfv' class="btn btn-xs grey">Download&nbsp;<i class="fa fa-download" aria-hidden="true"></i></a> 

									</td>
									<cfset count=count+1 />
								</tr>
						
						</cfoutput>
					</tbody>
				</table>
			</cfif>

	     	<cfset session.cs.ASSESSMENTID = arguments.Assmt_ID /> 
	     	<cfset session.cs.PATIENTID = arguments.Patient_ID /> 

	     	<cfif getadmit.RecordCount gt 0 AND  getadmit.status EQ 0 AND getallassessments.RecordCount gt 0>
	     		<h4>OASIS</h4>
				<table class="table table-bordered table-striped table-condensed flip-content">
					<thead class="flip-content">
						<tr>
							<th class="bold">Certification</th>
							<th class="bold">Assessment Type</th>
							<th class="bold">Action</th>
						</tr>
					</thead>
					<tbody>
						<cfoutput query="getallassessments">
							<tr>
								<td>#DateFormat(F176, 'mm/dd/yyyy')# <cfif F177 NEQ ''> - #DateFormat(F177, 'mm/dd/yyyy')#</cfif></td>
								<td> #F26#</td>
								<td>
									<cfif F26 contains '1 - Start of care' OR F26 contains '3 - Resumption' OR F26 EQ '4 - Resumption/Recertification'>
										<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=soc_print_pdf_new&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#"><i class="fa fa-print"></i> Print </a>

									<cfelseif F26 contains '4 - Recertification'>
										<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=recertification_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#"><i class="fa fa-print"></i> Print </a>

									<cfelseif F26 contains '6 - Transferred'>
										<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=6_transfer"><i class="fa fa-print"></i> Print </a>

									<cfelseif F26 contains '7 - Transferred'>
										<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=7_transfer"><i class="fa fa-print"></i> Print </a>

									<cfelseif F26 contains '9 - Discharge'>
										<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=discharge_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#"><i class="fa fa-print"></i> Print </a>

									<cfelseif F26 contains 'PT Adult'>
       								<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=PT"><i class="fa fa-print"></i> Print </a>

									<cfelseif F26 contains 'OT Adult'>
       								<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=OT"><i class="fa fa-print"></i> Print </a>

									<cfelseif F26 contains 'ST Adult' >
       								<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=ST"><i class="fa fa-print"></i> Print </a>

    								<cfelseif F26 EQ 'PT Followup'>
        								<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=PT_Followup"><i class="fa fa-print"></i> Print </a>

    								<cfelseif F26 EQ 'OT Followup'   >
        								<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=OT_Followup"><i class="fa fa-print"></i> Print </a>

    								<cfelseif F26 EQ 'SN Adult Evaluation' >
      								<a class="btn btn-sm grey" target="_blank" href="index.cfm?page=patient&cat=Eval_print_pdf&AID=#url.encassid#&patient_id=#url.encpatid#&rpt=&ATID=#url.encassid#&Evaltype=SN_Adult"><i class="fa fa-print"></i> Print </a>
									</cfif>
								</td>
							</tr>
						</cfoutput>
					</tbody>
				</table>
	     	</cfif>

			<!---<cfif GetfaxList.RecordCount gt 0 AND  Getorders.RecordCount gt 0>
				<h2>Received Faxes</h2>
				<table class="table table-striped table-bordered table-hover" id="DataTable">
	         	<thead>
	         		<tr>
	         			<th  align="center" >Action</th>
	         			<th  align="center" >Image</th>
	         			<th  align="center" >Completed Timestamp</th>
	         			<th  align="center" >From Fax number</th>
	         			<th  align="center" >To Fax</th>
	         		</tr>
	         	</thead>
	         	<tbody>
	         		<cfset i = 0 />
	         		<cfoutput query="GetfaxList">
	                  <cfset enc_fax_id  = encrypt(#fax_id#,#application.enckey#,"AES","Hex") /> 
	         			<tr style="height:30px;" class="list-hdr" id="tr#ID#">
	         				<td> <a  class="btn btn-sm green"  href="/agencyadmin/getfax_file.cfm?fax_id=#fax_id#" target="_blank">Download</a></td>
	         				<td>
	     						<div data-role="imagemagnifier" data-magnifier-mode="glass">
	     					   		 <embed  class ="zoom" src="/agencyadmin/getfax_file.cfm?fax_id=#fax_id#"  width="400" height="200">
							</div>
	     					</td>
						<td>#completed_timestamp#</td>
	         				<td>#originating_fax_number#</td>
	         				<td>#originating_fax_tsid#</td>
	         			</tr>
	         		</cfoutput>
	         	</tbody>
	     		</table>
	     	</cfif> --->

			<script>
				function printform(locurl)
				{
					 window.open(locurl,'Title','resizable=yes, width=800, height=800, top=10, left=10');
				}
			</script>
		</cfsavecontent>
		<cfreturn html_Docsview />
	</cffunction>

	<cffunction name="UpdatePendingPCR"  access="remote" output="Yes" returnformat="plain" returntype="string">
		<cfargument name="Assmt_ID" required="yes" default="0">
		<cfargument name="PCR_ID" required="yes" default="0">
		<cfargument name="value" required="yes" default="0">
		<cfargument name="type" required="yes" default="0">
		<cftry>
			<cfquery  name="getPendingPCR" datasource="#Application.DataSrc#">
				SELECT * FROM #Request.prefix_db_agency#.PCR 
				WHERE PCR_ID = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.PCR_ID#"  > 
				AND Assmt_ID = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.Assmt_ID#"  > 
				AND Status = 0
			</cfquery>
			<cfset episodeType = getPendingPCR.Episode />

			<cfif arguments.type EQ 'UTN'>
				<cfquery  name="updatePCRStatus" datasource="#Application.DataSrc#">
				   UPDATE #Request.prefix_db_agency#.PCR 
			   	SET UTN = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.value#"  >
				   WHERE Status = 0
				   AND Assmt_ID = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.Assmt_ID#"  > 
				   AND PCR_ID = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.PCR_ID#"  > 
				</cfquery>

				<cfquery  name="updateAssessment" datasource="#Application.DataSrc#">
				   UPDATE #Request.prefix_db_agency#.pAssessments SET 
				   	<cfif episodeType EQ '1st 30' >
				   		F290 = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.value#"  >
				   	<cfelse>
				   		F291 = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.value#"  >
					   </cfif>
					   WHERE Status = 0
					   AND Assmt_ID = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.Assmt_ID#"  >
					</cfquery>
			</cfif>
			<cfif arguments.type EQ 'PCR_Status'>
				<cfquery  name="updatePCRStatus" datasource="#Application.DataSrc#">
				   UPDATE #Request.prefix_db_agency#.PCR 
			   	SET PCR_Status = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.value#"  >
				   WHERE Status = 0
				   AND Assmt_ID = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.Assmt_ID#"  > 
				   AND PCR_ID = <cfqueryparam CFSQLType="cf_sql_varchar" value="#arguments.PCR_ID#"  > 
				</cfquery>
			</cfif>
			<cfcatch><cfdump var="#cfcatch#"><cfabort></cfcatch>
		</cftry>
		<cfreturn 'success' />	
	</cffunction>
</cfcomponent>