<!---
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.13 $
$Id: progress_form_printer.cfm,v 1.13 2010/03/22 22:03:45 arlen Exp $
$Date: 2010/03/22 22:03:45 $
--->

<cfinclude template='/__Security-Block.cfm' />

<cfparam name='url.id' default='' />
<cfparam name='url.ScheduleItems_Id' default='' />
 <cfif url.id neq ''>
  <cfset url.ScheduleItems_Id = url.id />
 </cfif>

<cfquery  name='Check4Telephony1' datasource='#Application.DataSrc#'>
 SELECT si.ScheduleItems_Id, si.Assessment_Tracker_Id, si.Employee_Id, ti.Call_TelephonyId
 FROM   #Request.prefix_db_agency#.ScheduleItems si, #Request.prefix_db_agency#.telephony_input ti
 WHERE  si.ScheduleItems_Id = '#url.ScheduleItems_Id#'
 AND    si.Agency_Id = '#session.AgencyId#'
 AND    ti.Call_TelephonyId = si.Telephony_Id
</cfquery>

<cfquery  name='Check4Telephony2' datasource='#Application.DataSrc#'>
 SELECT si.ScheduleItems_Id, si.Assessment_Tracker_Id, si.Employee_Id
 FROM   #Request.prefix_db_agency#.ScheduleItems si
 WHERE  si.ScheduleItems_Id = '#url.ScheduleItems_Id#'
 AND    si.Agency_Id = '#session.AgencyId#'
 AND    si.Telephony_Yes = 1
</cfquery>

<cfif Check4Telephony1.RecordCount gt 0>
 <cfoutput query = 'Check4Telephony1'>
  <cfset gURL = "/managementreports/telephony_log.cfm?ScheduleItems_Id=" & Check4Telephony1.ScheduleItems_Id & "&empId=" & Check4Telephony1.Employee_Id & "&callId=" & Check4Telephony1.Call_TelephonyId & "&atid=" & Check4Telephony1.Assessment_Tracker_Id />
 </cfoutput>
 <cflocation url = '#gURL#' addToken = 'no' />
<cfelseif Check4Telephony2.RecordCount gt 0>
 <cfoutput query = 'Check4Telephony2'>
  <cfset gURL = "/managementreports/telephony_log.cfm?ScheduleItems_Id=" & Check4Telephony2.ScheduleItems_Id & "&empId=" & Check4Telephony2.Employee_Id & "&atid=" & Check4Telephony2.Assessment_Tracker_Id />
 </cfoutput>
 <cflocation url = '#gURL#' addToken = 'no' />
</cfif>


<!--- Page specific code, such as queries and variable settings should go here --->

<cfquery  name="GetSchedule" datasource="#Application.DataSrc#">
 SELECT Employee.Employee_Id, Employee.Last_Name, Employee.First_Name,
        patient.Patient_Id, patient.Last_Name_M0040, patient.First_Name_M0040, patient.Agency_Assigned_Id,
        ScheduleItems.ScheduleItems_Id, ScheduleItems.Visit_Date, ScheduleItems.Visit_Type, ScheduleItems.StartTime,
        ScheduleItems.EndTime, ScheduleItems.Mileage, ScheduleItems.Visit_Notes
 FROM  #Request.prefix_db_lookup#.Employee, #Request.prefix_db_agency#.patient, #Request.prefix_db_agency#.ScheduleItems
 WHERE ScheduleItems.ScheduleItems_Id = '#url.ScheduleItems_Id#'
 And   patient.Patient_Id = ScheduleItems.Patient_Id
 And   ScheduleItems.Employee_Id = Employee.Employee_Id
 AND   Employee.EmployeeType != 'Physician'
</cfquery>

<cfquery  name="GetDetails" datasource="#Application.DataSrc#">
 SELECT DISTINCT pvd.Type, pvd.Description, pvd.Notes, pvd.general_assessment
 FROM   #Request.prefix_db_agency#.ScheduleItems si, #Request.prefix_db_agency#.PatientVisitDetails pvd
 WHERE  si.ScheduleItems_Id = '#url.ScheduleItems_Id#'
<!--- AND  (PatientVisitDetails.ScheduleItems_Id = ScheduleItems.ScheduleItems_Id OR PatientVisitDetails.Assessment_Tracker_Id = ScheduleItems.Assessment_Tracker_Id) --->
 AND    pvd.ScheduleItems_Id = si.ScheduleItems_Id
 ORDER BY pvd.Type Desc, pvd.Description Asc, pvd.Notes Desc
</cfquery>
 <cfdocument format="pdf" orientation = "portrait"   overwrite = "yes">
<!---<cfif 0>--->
 <!--- End page specific code --->
 <!---<cfdocument   format = "PDF"   orientation = "portrait"   overwrite = "yes">

  <cfdocumentitem type="header">
	<cfoutput query="getSchedule">
	<table border="0" cellpadding="2" width="100%">
	  <tr><td>
	<h3><div style="font-size:14px;">#First_Name_M0040# #Last_Name_M0040# <cfif Agency_Assigned_ID neq ''> (#Agency_Assigned_ID#)</cfif> #Visit_Type#</font></h3>
	<div style="font-size:14px;">#DateFormat(Visit_Date,"mm/dd/yyyy")#, #StartTime# - #EndTime#, #First_Name# #Last_Name#<br><br></font>
	</td></tr></table></cfoutput>
	</cfdocumentitem>
   <cfdocumentitem type="footer">
   	<div style="font-size:10px;"><cfinclude template="../_footer.cfm"></div>
   </cfdocumentitem>  --->
<!---<cfelse>--->
 <!---<form><input type="button" value=" Print " onclick="window.print();javascript:ScrollWin.scroll('1');return false;" /> &nbsp;<input type="button" onclick="history.back();" value="Back" name="Cancel"></form> <br>--->

	<!---<cfoutput query="getSchedule">
	<table border="0" cellpadding="2" width="100%">
	  <tr><td>
	<h3><div style="font-size:14px;">#First_Name_M0040# #Last_Name_M0040# <cfif Agency_Assigned_ID neq ''> (#Agency_Assigned_ID#)</cfif> #Visit_Type#</font></h3></div>
	<div style="font-size:14px;">#DateFormat(Visit_Date,"mm/dd/yyyy")#, #StartTime# - #EndTime#, #First_Name# #Last_Name#<br><br></font></div>
	</td></tr></table></cfoutput>
</cfif>

<br><Br>

<cfoutput query="getSchedule">
	<table border="0" cellpadding="2" width="100%">
	  <tr>
	  <td nowrap valign=top><i><div style="font-size:14px;">Visit Notes:</div>  </i></td>
	  <td><div style="font-size:12px;">#HTMLEditFormat(Visit_Notes)#</div></td>
	  </tr>
	</table>	
</cfoutput>

<br>

<cfset t = '' />
<cfset d = '' />
<cfset n = '' />

<cfoutput query="GetDetails" group="Type">
					<tr>
						<td valign="top" colspan="2">
						<table border="0" cellpadding="2" width="100%">
						<cfif Type neq 'Intervention'>
______________________________________________________________________________________________________________________________ <br>
							<tr>
								<td align="left" valign="top" width="30%"><b><div style="font-size:12px;">#Type#</div></b></td>
								<td align="left" colspan="4" valign="top"><div style="font-size:12px;">Notes</div></td>
								<cfif #Type# eq 'Symptom'>
								<td width="30%"><div style="font-size:12px;">General Assessment</div></td></cfif>
							</tr>
						<cfelse>
______________________________________________________________________________________________________________________________ <br>
							<tr>
								<td align="left" valign="top" width="30%"><b><div style="font-size:12px;">Intervention</b></div></td>
								<td align="left" colspan="4" valign="top"><div style="font-size:12px;">Notes</div></td>								
							</tr>
						</cfif>
						</table>
						</td>
					</tr>
					<tr>
						<td valign="top" colspan="2">
						<table cellpadding="2" border="0" class="trhighlight"  width="100%" class="form-border">
							<cfoutput>
  <cfif d neq Description>
								<cfset RowBG = IIF(GetDetails.CurrentRow MOD 2 EQ 0, "'white'", "''")>
								<tr bgcolor="#RowBG#">
									<td align="left" valign="top" width="30%"><i><div style="font-size:11px;">
									 #Description#&nbsp;
									 </div></i></td>
									<td align="left" colspan="4" valign="top"><div style="font-size:11px;">#Notes#&nbsp;</div></td>
									<cfif #Type# eq 'Symptom'>
									<td align="left" width="30%"><div style="font-size:11px;"><cfif #general_assessment# eq ''>--nil--<cfelse>#general_assessment#</cfif>&nbsp;</div></td></cfif>
								</tr>
  </cfif>
  <cfset t = Type />
  <cfset d = Description />
  <cfset n = Notes />
							</cfoutput>
						
						</td>
					</tr>
					</table>
</cfoutput>
 <p></p>
<cfif 0>
  
<cfelse>
   	<div style="font-size:10px;"><cfinclude template="../_footer.cfm"></div>

</cfif>--->

<cfif isdefined('url.ScheduleItems_ID') and url.ScheduleItems_ID neq '' and isdefined('url.assid') and url.assid neq ''>
<cfset linklist = "SN:Skilled Nursing,PT:Physical Therapy,OT:Occupational Therapy,ST:Speech 

Therapy,MSW:Medical Social Worker,HHA:Home Health Aide,PCA I:Personal Care Attendant I,PCA 

II:Personal Care Attendant II,PCA III:Personal Care Attendant 

III,HMKR:Homemaker,COMP:Companion,HHH:Hospice,VOL:Volunteer,HSN: Skilled Nursing Hospice,HMS: Medical 

Social Work Hospice,BRV: Bereavement Hospice,SPR: Spiritual Hospice">

<cfset wlist="Bite,Contusion,Aborsion,Burn,Diabetic Ulcer,Graft,Gunshot,Laceration,Nodule,Pressure 
								Ulcer,Puncture,Skin Tear,Stab,Statis Ulcer,Surgical Wound,Welt,Other">

<cfquery  name="GetAgencyDetails" datasource="#Application.DataSrc#">
Select Agency_Name,Agency_Address1,Agency_City,Agency_State,Agency_Zip,Agency_Contact_Phone,Agency_Fax,Natl_Provider_ID 
from #Request.prefix_db_lookup#.Agency 
Where Agency_ID=#Session.AgencyID#
</cfquery>



<cfquery  name="GetSchedule" datasource="#Application.DataSrc#">
 SELECT Employee.Employee_Id, Employee.Last_Name, Employee.First_Name,
        patient.Patient_Id, patient.Last_Name_M0040, patient.First_Name_M0040, patient.Agency_Assigned_Id,patient.Location,
        ScheduleItems.ScheduleItems_Id, ScheduleItems.Visit_Date, ScheduleItems.Visit_Type, ScheduleItems.StartTime,
        ScheduleItems.EndTime, ScheduleItems.Mileage, ScheduleItems.Visit_Notes
 FROM  #Request.prefix_db_lookup#.Employee, #Request.prefix_db_agency#.patient, #Request.prefix_db_agency#.ScheduleItems
 WHERE ScheduleItems.ScheduleItems_Id = '#url.ScheduleItems_ID#'
 And   patient.Patient_Id = ScheduleItems.Patient_Id
 And   ScheduleItems.Employee_Id = Employee.Employee_Id
 AND   Employee.EmployeeType != 'Physician'
</cfquery>


<cfquery  name="Get_location" datasource="#Application.DataSrc#">
	SELECT * FROM #Request.prefix_db_agency#.Locations 
	WHERE Location_ID  = '#GetSchedule.Location#'
</cfquery>

<cfset url.code = '' />
<cfoutput>
<cfloop list="#linklist#" index=i>
 <cfset code = GetToken(i, 1, ':')>
 <cfset desc = GetToken(i , 2, ':')>
 <cfif #GetSchedule.Visit_Type# eq desc>
  <cfset url.code = code>
 </cfif>
</cfloop>
</cfoutput>
<cfif url.code eq 'PCA I' OR url.code eq 'PCA II' OR url.code eq 'PCA III' OR url.code eq 'HMKR' OR 

url.code eq 'COMP'>
 <cfset categorylist="Interventions:Intervention:id_intervention">
<cfelse>
 <cfset categorylist="Vital Signs:Vital 

Sign:id_vitalsign,Laboratory:laboratory:id_laboratory,Wounds:Wound:id_wound,Symptoms:Symptom:id_sympt

on,Interventions:Intervention:id_intervention,Goals:Goal:id_goal">
</cfif>

 <cfset categorylist = "Symptoms:Symptom, Interventions:Intervention, Goals:Goal" />

<cfquery  name="GetDetails" datasource="#Application.DataSrc#">
 SELECT DISTINCT pvd.Type, pvd.Description, pvd.Notes, pvd.general_assessment
 FROM   #Request.prefix_db_agency#.ScheduleItems si, #Request.prefix_db_agency#.PatientVisitDetails pvd
 WHERE  si.ScheduleItems_Id = '#url.ScheduleItems_ID#'
 AND    pvd.ScheduleItems_Id = si.ScheduleItems_Id
 ORDER BY pvd.Type Desc, pvd.Description Asc, pvd.Notes Desc
</cfquery>

  <cfquery  name="GetVital" datasource="#Application.DataSrc#">
select pd.Pathway_Details_Id,pvd.Progress_Details_Id,pvd.Description,pvd.Performed,pvd.Reading1,pvd.Severity,pvd.Notes,pd.Resolved_Date  from #Request.prefix_db_agency#.PatientVisitDetails pvd  
Inner Join #Request.prefix_db_agency#.Pathway_Details pd on pvd.Pathway_Details_Id=pd.Pathway_Details_Id
where pvd.Type like '%vital%'
and pvd.ScheduleItems_ID='#url.ScheduleItems_ID#'
</cfquery>

<cfquery  name="GetLab" datasource="#Application.DataSrc#">
select pd.Pathway_Details_Id,pvd.Progress_Details_Id,pvd.Description,pvd.Performed,pvd.Reading1,pvd.Severity,pvd.Notes,pd.Resolved_Date  from #Request.prefix_db_agency#.PatientVisitDetails pvd  
Inner Join #Request.prefix_db_agency#.Pathway_Details pd on pvd.Pathway_Details_Id=pd.Pathway_Details_Id
where pvd.Type like '%lab%'
and pvd.ScheduleItems_ID='#url.ScheduleItems_ID#'
</cfquery>

 <cfset nt0 = ArrayNew(1) />
 <cfset nt1 = ArrayNew(1) />
 <cfset nt2 = ArrayNew(1) />

 <cfif url.code eq 'SN'>
  <cfset nt0[1] = 'Cardio' />
  <cfset nt1[1] = 'Cardio / Respiratory / Hematology' />
  <cfset nt2[1] = '12, 14, 27, 40' />

  <cfset nt0[2] = 'Neuro' />
  <cfset nt1[2] = 'Neuro / Emotional / Behavioral' />
  <cfset nt2[2] = '2, 3, 18, 22' />

  <cfset nt0[3] = 'ADL' />
  <cfset nt1[3] = 'ADL Management Homebound Status' />
  <cfset nt2[3] = '4, 13, 21, 24, 26, 33' />

  <cfset nt0[4] = 'Endocrine' />
  <cfset nt1[4] = 'Endocrine' />
  <cfset nt2[4] = '9' />

  <cfset nt0[5] = 'Nutrition' />
  <cfset nt1[5] = 'Nutrition' />
  <cfset nt2[5] = '11, 23, 35, 36, 37' />

  <cfset nt0[6] = 'Gastrointestinal' />
  <cfset nt1[6] = 'Gastrointestinal' />
  <cfset nt2[6] = '10' />

  <cfset nt0[7] = 'Genitourinary' />
  <cfset nt1[7] = 'Genitourinary' />
  <cfset nt2[7] = '19' />

  <cfset nt0[8] = 'Integumentary' />
  <cfset nt1[8] = 'Integumentary' />
  <cfset nt2[8] = '25, 34, 35, 38, 39' />

 <cfelseif url.code eq 'PT'>
  <cfset nt0[1] = 'ADL' />
  <cfset nt1[1] = 'ADL Management Homebound Status' />
<!---
  <cfset nt2[1] = '29' />
--->

 <cfelseif url.code eq 'OT'>
  <cfset nt0[1] = 'ADL' />
  <cfset nt1[1] = 'ADL Management Homebound Status' />
<!---
  <cfset nt2[1] = '28' />
--->

 <cfelseif url.code eq 'ST'>
  <cfset nt0[1] = 'Neuro' />
  <cfset nt1[1] = 'Neuro / Emotional / Behavioral' />
<!---
  <cfset nt2[1] = '6, 7, 8' />
--->

 <cfelseif url.code eq 'MSW'>
  <cfset nt0[1] = 'ADL' />
  <cfset nt1[1] = 'ADL Management Homebound Status' />
<!---
  <cfset nt2[1] = '5, 32' />
--->

 <cfelseif url.code eq 'BRV'>
  <cfset nt0[1] = 'ADL' />
  <cfset nt1[1] = 'ADL Management Homebound Status' />
  
 <cfelseif url.code eq 'SPR'>
  <cfset nt0[1] = 'ADL' />
  <cfset nt1[1] = 'ADL Management Homebound Status' />

 <cfelseif url.code eq 'HHA'>
  <cfset nt0[1] = 'ADL' />
  <cfset nt1[1] = 'ADL Management Homebound Status' />
<!---
  <cfset nt2[1] = '30' />
--->

 <cfelseif url.code eq 'HSN'>
  <cfset nt0[1] = 'Cardio' />
  <cfset nt1[1] = 'Cardio / Respiratory / Hematology' />
  <cfset nt2[1] = '12, 14, 27, 40' />
  <cfset nt0[2] = 'Neuro' />
  <cfset nt1[2] = 'Neuro / Emotional / Behavioral' />
  <cfset nt2[2] = '2, 3, 18, 22' />
  <cfset nt0[3] = 'ADL' />
  <cfset nt1[3] = 'ADL Management Homebound Status' />
  <cfset nt2[3] = '4, 13, 21, 24, 26, 33' />
  <cfset nt0[4] = 'Endocrine' />
  <cfset nt1[4] = 'Endocrine' />
  <cfset nt2[4] = '9' />
  <cfset nt0[5] = 'Nutrition' />
  <cfset nt1[5] = 'Nutrition' />
  <cfset nt2[5] = '11, 23, 35, 36, 37' />
  <cfset nt0[6] = 'Gastrointestinal' />
  <cfset nt1[6] = 'Gastrointestinal' />
  <cfset nt2[6] = '10' />
  <cfset nt0[7] = 'Genitourinary' />
  <cfset nt1[7] = 'Genitourinary' />
  <cfset nt2[7] = '19' />
  <cfset nt0[8] = 'Integumentary' />
  <cfset nt1[8] = 'Integumentary' />
  <cfset nt2[8] = '25, 34, 35, 38, 39' />

 <cfelseif url.code eq 'HMS'>
  <cfset nt0[1] = 'ADL' />
  <cfset nt1[1] = 'ADL Management Homebound Status' />
<!---
  <cfset nt2[1] = '5, 32' />
--->

 </cfif>


	<table border="0" cellpadding="0" cellspacing="0" width="100%">
		<tr>
					<cfif Get_location.RecordCount gt 0 >
						  <cfoutput query="Get_location">
							   <td colspan="2" style="font-family:'Courier New',Courier,monospace;font-size:12px;line-height:15px;padding-left:10px"align="left">#Trim(Agency_Name)#<br>
								#Trim(Agency_Address1)#<br>
								#Trim(Agency_City)#, #Trim(Agency_State)# #Trim(Agency_Zip)#<br />
								phone: #Trim(Agency_Contact_Phone)# fax: #Trim(Agency_Fax)#<br>
								NPI: #Trim(Natl_Provider_ID)#</td>
							 </cfoutput>
						  <cfelse>
						  <cfoutput query="GetAgencyDetails">
							   <td colspan="2" style="font-family:'Courier New';font-size:12px;line-height:20px;padding-left:10px">
										#Agency_Name#<br>
										#Agency_Address1#<br>
										#Agency_City#,#Agency_State# #Agency_Zip# #Agency_Contact_Phone# #Agency_Fax#<br>
										#Natl_Provider_ID#
								</td>
							 </cfoutput>
						</cfif>
	 
		</tr>
		<tr>
			<td colspan="2" height="10px">
			</td>
		</tr>
		<tr>
			<td style="font-family:Arial;font-size:14px;padding-left:10px;"><b><cfoutput>#session.Display#</cfoutput>&nbsp;(<cfoutput>#session.AgencyLogin#</cfoutput>)</b></td>
			<!---<cfif #GetSchedule.Visit_Type# contains 'Skilled Nursing'>
				<cfset type = 'SN'> 
			<cfelse>
				<cfset type = #GetSchedule.Visit_Type#> 
			</cfif>--->
			<td style="font-family:Arial;font-size:14px;padding-right:10px" align="right">
			<cfoutput><b>#url.code# Progress Note: #DateFormat(GetSchedule.Visit_Date,"mm/dd/yyyy")#</b></cfoutput>
			</td>
		</tr>		
		<tr>
			<td colspan="2" style="background-color:black;padding-left:5px;font-weight:bold">
			</td>
		</tr>
		<tr>
			<td colspan="2" align="left" valign="top" style="font-size:12px;font-family:'Courier New';line-height:20px;padding-left:10px;padding-top:10px">
				Time In : <cfoutput>#GetSchedule.StartTime#</cfoutput>  Time Out :  <cfoutput>#GetSchedule.EndTime#</cfoutput> <br>
				General Notes :<cfoutput> #HTMLEditFormat(GetSchedule.Visit_Notes)#</cfoutput>
			</td>
		</tr>
		<tr>
			<td colspan="2">	
				<table border="0" cellpadding="2" width="100%">						
						<tr>
							<td colspan="2" style="font-family:Arial;font-size:12px;font-weight:bold">VITAL SIGNS
							</td>
						</tr>
						<tr>
							<td colspan="2" style="background-color:black">
							</td>
						</tr>
						<cfoutput>
						<cfif #GetVital.recordcount# GT 0>
						<cfloop query="GetVital">						
							<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>
									#UCASE(GetVital.Description)#
								</td>
								<td>
									#GetVital.Notes#
								</td>
							</tr>							
						</cfloop>
						<cfelse>
							<tr style="font-size:12px;font-family:'Courier New';line-height:20px"> 
								<td align="left" colspan="2">
									No Vital Sign Records were Found
								</td>
							</tr>							
						</cfif>
						</cfoutput>
						<tr>
							<td colspan="2" width="100%" style="font-family:Arial;font-size:12px;font-weight:bold">LABORATORY
							</td>
						</tr>
						<tr>
							<td colspan="2" style="background-color:black">	
							</td>
						</tr>					
						<cfoutput>
						<cfif #GetLab.recordcount# GT 0>	
						<cfloop query="GetLab">						
							<tr valign="top" style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>
									#UCASE(GetLab.Description)#
								</td>
								<td>
									#GetLab.Notes#
								</td>
							</tr>							
						</cfloop>
						<cfelse>
							<tr style="font-size:12px;font-family:'Courier New';line-height:20px"> 
								<td align="left" colspan="2">
									No Lab Work Records were Found
								</td>
							</tr>	
						</cfif>						
							</cfoutput>
						<!---<tr>
							<td colspan="2" width="100%" style="font-family:Arial;font-size:14px;font-weight:bold">Cardio/Respiratory/Hematology<br />	___________________________________________________________________________________________________________________________________ <br>
							</td>
						</tr>--->
						<cfset count=0>
						<cfloop from = "1" to = "#ArrayLen(nt1)#" index = "i">
							<cfquery  name = 'GetPath' datasource = '#Application.DataSrc#'>
								SELECT pd.Assessment_Id, pd.Skill, pd.Description, pd.Created_By, pd.Record_Creation_Date,pd.Type as pd_type
									  ,pd.Pathway_Details_Id, pd.Assessment_Tracker_Id, pd.M0_Answer as Diagnosis,pd.Care_Pathway, pd.Resolved_Date
									  ,pvd.Description as pvd_description, pvd.Performed, pvd.Severity,pvd.general_assessment, pvd.Notes, pvd.Reading1,
									   pvd.Type as pvd_type,pvd.Reading2, pvd.Progress_Details_Id,pvd.Record_creation_date as pvdtest,si.Visit_Date
									  ,e.Last_Name,pl.Item_Id AS PathwayListItemId, pl.CopyIntoProgressNote,pvd.generalassnotes
								FROM   #Request.prefix_db_agency#.Pathway_Details pd
								LEFT OUTER JOIN #Request.prefix_db_lookup#.Employee e on pd.Created_By = e.Employee_Id
								LEFT OUTER JOIN #Request.prefix_db_agency#.PatientVisitDetails pvd on pd.Pathway_Details_Id = pvd.Pathway_Details_Id
								LEFT OUTER JOIN #Request.prefix_db_agency#.ScheduleItems si on pvd.ScheduleItems_Id = si.ScheduleItems_Id
								LEFT OUTER JOIN #Request.prefix_db_lookup#.pathway_list pl ON pl.Pathway_Id = pd.Care_Pathway
								WHERE  pd.Assessment_Id = '#url.assid#' 
								and    pvd.ScheduleItems_ID = '#url.ScheduleItems_ID#'
								and si.Visit_Date='#dateformat(GetSchedule.Visit_Date,'yyyy-mm-dd')#'	
								AND    pd.Skill = '#url.code#'
								<cfif ArrayLen(nt2) gt 0>
								AND    pd.Care_Pathway IN (#nt2[i]#)
								</cfif>
								AND    pd.Type IN ('Goal', 'Intervention', 'Symptom')
								GROUP BY pd.Description
								ORDER BY pd.Type DESC, pd.Record_Creation_Date, pd.Description
							 </cfquery>
							 <cfif GetPath.RecordCount gt 0> 
							  <cfset z = 0 />
							  <cfset gotSymptomsGeneralAssessment = 0 />
							  <cfset Scount=0>
							  <cfloop list="#categorylist#" index=item>
								  <cfset Scount=Scount+1>
								  								
								  <cfset item1 = #GetToken(item, 1, ':')# />
								  <cfset item2 = #GetToken(item, 2, ':')# />
								  <cfset item3 = #GetToken(item, 3, ':')# />
								
								  <cfquery  name="GetPathDetails" dbtype="query">
									SELECT * FROM GetPath WHERE UPPER(pd_type) ='#UCASE(item2)#'
								   </cfquery>
								   <cfif z eq 0>
									<tr  style="font-family:Arial;font-size:12px;font-weight:bold;">
										<td colspan="2">
											<cfoutput>#UCASE(nt1[i])# </cfoutput>
										</td>
									</tr>
									<tr>
										<td colspan="2" style="background-color:black">	
										</td>
									</tr>
									</cfif>
									<cfif z eq 0>
							<cfoutput>
							<cfquery  name="SelectGeneralAssessment" datasource="#Application.DataSrc#">	 
							SELECT Generalassessment_ID,genaralassessment,generalassessmentnotes FROM 
							#Request.prefix_db_agency#.patient_generalassessment where
							ScheduleItems_ID='#url.ScheduleItems_ID#' and Skill='#url.code#' and category='#nt0[i]#'
							</cfquery>
							</cfoutput>
									
							<cfif isdefined('SelectGeneralAssessment.recordcount') and SelectGeneralAssessment.recordcount gt 0>
									<cfif SelectGeneralAssessment.RecordCount gt 0>
										<cfoutput>
										<tr style="font-size:12px;font-family:'Courier New';line-height:10px">
											  <td colspan="2" align="left">												   
												#nt0[i]# General Assessment
											  </td>
										</tr>
											<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
											
											  <td align="left">												   
												#SelectGeneralAssessment.genaralassessment#
											  </td>
											  <td valign="top">
												#SelectGeneralAssessment.generalassessmentnotes#
											  </td>
											</tr>										
										</cfoutput>  
									</cfif>
								</cfif>
								    </cfif>
								   <!---<cfif #item1# neq 'Symptoms'>--->
								   	<tr>
										<td colspan="2"  style="font-family:'Courier New';font-size:12px;font-weight:bold;color:red;">
											<cfoutput>#UCASE(item1)#</cfoutput>
										</td>
									</tr>
								   <!---</cfif>--->
								    <cfset x = 0 >
								    <cfif GetPathDetails.RecordCount lt 1>		
										<tr>
										  <td colspan='2' align="left" style="padding: 3px 10px;font-size:12px;font-family:'Courier New';line-height:20px">
											No <cfoutput>#item2#</cfoutput> records were found
										  </td>
										 </tr>
									 <cfelse>
									     <cfoutput query = 'GetPathDetails'>
										 	<tr valign="top" style="font-size:12px;font-family:'Courier New';line-height:20px"> 
											   <td>
											   		#Description#
											    </td>
												<td>
													#Notes#
												</td>
											</tr>
										 </cfoutput>
									</cfif>
									<cfset z = z + 1 />	
									
								<cfif i neq 'other' and #nt1[i]# eq 'Integumentary' and #item2# eq 'Goal'>
								<tr>
									<td colspan="2" height="15px">	
									</td>
								</tr>	
								<tr  style="font-family:Arial;font-size:12px;font-weight:bold;">
									<td colspan="2">
										WOUNDS
									</td>
								</tr>
								<tr>
									<td colspan="2" style="background-color:black">	
									</td>
								</tr>
								
								<cfoutput>	
								<cfset Wcount=0>						
								<cfloop list ="#wlist#" index=i>
								<cfquery  datasource="#Application.DataSrc#" name="woundlist">
								select pd.Pathway_Details_Id,pd.Resolved_Date,pvd.Progress_Details_Id,pvd.Patient_ID,
								pvd.Description,pvd.Wnd_Type,pd.Skill from #Request.prefix_db_agency#.PatientVisitDetails pvd left outer join 
								#Request.prefix_db_agency#.Pathway_Details pd on pvd.Pathway_Details_Id=pd.Pathway_Details_Id
								WHERE  pd.Assessment_Id ='#url.assid#' and pd.Skill='SSN' and Wnd_Type like '%#i#%' and pvd.Type 
								like '%wound%' and Care_PathWay in(25,34,35,38,39) group by Wnd_Type
								</cfquery>								
								<cfif isdefined('woundlist') and woundlist.recordcount gt 0>
								<cfset Wcount=Wcount+1>
								<cfquery  datasource="#Application.DataSrc#" name="GetWounds">
								Select  
								Progress_Details_ID,
								Agency_ID,
								Patient_ID,
								Assessment_ID,
								Assessment_Tracker_ID,
								Reading2,
								Wnd_Type,
								Wnd_Stage,
								Wnd_Status,
								Wnd_Location,
								Record_Creation_Date,
								Record_Created_By,
								Wnd_Len_1,
								Wnd_Len_2,
								Wnd_Wid_1,
								Wnd_Wid_2,
								Wnd_Dep_1,
								Wnd_Dep_2,
								Wnd_Chara,
								Notes,
								Wnd_Surr_Tiss
								from #Request.prefix_db_agency#.PatientVisitDetails where Progress_Details_ID='#woundlist.Progress_Details_Id#'
								</cfquery>
								<cfset Progress_Details_ID="#GetWounds.Progress_Details_ID#">
								<cfset Wnd_Type="#GetWounds.Wnd_Type#">
								<cfset Wnd_Stage="#GetWounds.Wnd_Stage#">
								<cfset Wnd_Status="#GetWounds.Wnd_Status#">
								<cfset Wnd_Location="#GetWounds.Wnd_Location#">
								<cfset Wnd_Len_1="#GetWounds.Wnd_Len_1#">
								<cfset Wnd_Len_2="#GetWounds.Wnd_Len_2#">
								<cfset Wnd_Wid_1="#GetWounds.Wnd_Wid_1#">
								<cfset Wnd_Wid_2="#GetWounds.Wnd_Wid_2#">
								<cfset Wnd_Dep_1="#GetWounds.Wnd_Dep_1#">
								<cfset Wnd_Dep_2="#GetWounds.Wnd_Dep_2#">
								<cfset Wnd_Chara="#GetWounds.Wnd_Chara#">
								<cfset Notes="#GetWounds.Notes#">
								<cfset Wnd_Surr_Tiss="#GetWounds.Wnd_Surr_Tiss#">
								
								
								<tr style="font-family:'Courier New';font-size:12px;font-weight:bold;color:red;">
								<td colspan="2" align="left">												  
								#UCASE(i)#
								</td>
								</tr>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Length
								</td>
								<td>
								#Wnd_Len_1# - #Wnd_Len_2# cm
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Width
								</td>
								<td>
								#Wnd_Wid_1# - #Wnd_Wid_2# cm
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Depth
								</td>
								<td>
								#Wnd_Dep_1# - #Wnd_Dep_2# cm
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Surrounding Tissue
								</td>
								<td>
								#Wnd_Surr_Tiss#
								</td>
								</tr>		
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Characteristics
								</td>
								<td>
								#Wnd_Chara#
								</td>
								</tr>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Notes
								</td>
								<td>
								#Trim(GetWounds.Notes)#
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Resolve?(Remove from future Notes)
								</td>
								<td>
								<cfif #woundlist.Resolved_Date# neq ''>Yes<cfelse>No</cfif>
								</td>
								</tr>	
								</cfif>
								</cfloop>
								</cfoutput>	
								<cfif Wcount eq 0>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								  <td align="left" colspan='2'>
									No Wounds records were found
								  </td>
								</tr>	
								</cfif>
								</cfif>
								
														
								</cfloop>
							<cfelse>  							
							   							
								<cfoutput>
								<cfquery  name="SelectGeneralAssessment" datasource="#Application.DataSrc#">	 
								SELECT Generalassessment_ID,genaralassessment,generalassessmentnotes FROM  #Request.prefix_db_agency#.patient_generalassessment where
								ScheduleItems_ID='#url.ScheduleItems_ID#' and Skill='#url.code#' and category='#nt0[i]#'
								</cfquery>
								</cfoutput>
								<tr  style="font-family:Arial;font-size:12px;font-weight:bold;">
									<td colspan="2">
										<cfoutput>#UCASE(nt1[i])# </cfoutput>
									</td>
								</tr>
								<tr>
									<td colspan="2" style="background-color:black">	
									</td>
								</tr>
							<cfif isdefined('SelectGeneralAssessment.recordcount') and SelectGeneralAssessment.recordcount gt 0>
								<cfif SelectGeneralAssessment.RecordCount gt 0>
									<cfoutput>
										<tr style="font-size:12px;font-family:'Courier New';line-height:10px">
											 <td colspan="2" align="left">												  
												#nt0[i]# General Assessment
											  </td>
										</tr>
											<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
											  <td align="left">												  
												#SelectGeneralAssessment.genaralassessment#
											  </td>
											  <td valign="top">
												 #SelectGeneralAssessment.generalassessmentnotes#
											  </td>
											</tr>										
										</cfoutput>  
									</cfif>
								</cfif>
								<tr style="font-family:'Courier New';font-size:12px;font-weight:bold;color:red;">
									<td align="left" colspan="2">
									  SYMPTOMS
									 </td>
								</tr>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
									 <td align="left" colspan="2">
									  No Symptoms records were found
									 </td>
								</tr> 
								<tr style="font-family:'Courier New';font-size:12px;font-weight:bold;color:red;">
									<td align="left" colspan="2">
									  INTERVENTIONS
									 </td>
								</tr>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								  <td align="left" colspan='2'>
									No Interventions records were found
								  </td>
								</tr>	
								<tr style="font-family:'Courier New';font-size:12px;font-weight:bold;color:red;">
								  <td align="left" colspan="2">
									GOALS
								  </td>
								</tr>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								  <td align="left" colspan='2'>
									No Goals records were found
								  </td>
								</tr>	
								
								<cfif i neq 'other' and nt1[i] eq 'Integumentary'>
								<tr>
									<td colspan="2" height="15px">	
									</td>
								</tr>	
								<tr  style="font-family:Arial;font-size:12px;font-weight:bold;">
									<td colspan="2">
										WOUNDS
									</td>
								</tr>
								<tr>
									<td colspan="2" style="background-color:black">	
									</td>
								</tr>
								<cfoutput>	
								<cfset Wcount=0>						
								<cfloop list ="#wlist#" index=i>
								<cfquery  datasource="#Application.DataSrc#" name="woundlist">
								select pd.Pathway_Details_Id,pd.Resolved_Date,pvd.Progress_Details_Id,pvd.Patient_ID,
								pvd.Description,pvd.Wnd_Type,pd.Skill from #Request.prefix_db_agency#.PatientVisitDetails pvd left outer join 
								#Request.prefix_db_agency#.Pathway_Details pd on pvd.Pathway_Details_Id=pd.Pathway_Details_Id
								WHERE  pd.Assessment_Id ='#url.assid#' and pd.Skill='SSN' and Wnd_Type like '%#i#%' and pvd.Type 
								like '%wound%' and Care_PathWay in(25,34,35,38,39) group by Wnd_Type
								</cfquery>								
								<cfif isdefined('woundlist') and woundlist.recordcount gt 0>
								<cfset Wcount=Wcount+1>
								<cfquery  datasource="#Application.DataSrc#" name="GetWounds">
								Select  
								Progress_Details_ID,
								Agency_ID,
								Patient_ID,
								Assessment_ID,
								Assessment_Tracker_ID,
								Reading2,
								Wnd_Type,
								Wnd_Stage,
								Wnd_Status,
								Wnd_Location,
								Record_Creation_Date,
								Record_Created_By,
								Wnd_Len_1,
								Wnd_Len_2,
								Wnd_Wid_1,
								Wnd_Wid_2,
								Wnd_Dep_1,
								Wnd_Dep_2,
								Wnd_Chara,
								Notes,
								Wnd_Surr_Tiss
								from #Request.prefix_db_agency#.PatientVisitDetails where Progress_Details_ID='#woundlist.Progress_Details_Id#'
								</cfquery>
								<cfset Progress_Details_ID="#GetWounds.Progress_Details_ID#">
								<cfset Wnd_Type="#GetWounds.Wnd_Type#">
								<cfset Wnd_Stage="#GetWounds.Wnd_Stage#">
								<cfset Wnd_Status="#GetWounds.Wnd_Status#">
								<cfset Wnd_Location="#GetWounds.Wnd_Location#">
								<cfset Wnd_Len_1="#GetWounds.Wnd_Len_1#">
								<cfset Wnd_Len_2="#GetWounds.Wnd_Len_2#">
								<cfset Wnd_Wid_1="#GetWounds.Wnd_Wid_1#">
								<cfset Wnd_Wid_2="#GetWounds.Wnd_Wid_2#">
								<cfset Wnd_Dep_1="#GetWounds.Wnd_Dep_1#">
								<cfset Wnd_Dep_2="#GetWounds.Wnd_Dep_2#">
								<cfset Wnd_Chara="#GetWounds.Wnd_Chara#">
								<cfset Notes="#GetWounds.Notes#">
								<cfset Wnd_Surr_Tiss="#GetWounds.Wnd_Surr_Tiss#">
								
								
								<tr style="font-family:'Courier New';font-size:12px;font-weight:bold;color:red;">
								<td colspan="2" align="left">												  
								#UCASE(i)#
								</td>
								</tr>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Length
								</td>
								<td>
								#Wnd_Len_1# - #Wnd_Len_2# cm
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Width
								</td>
								<td>
								#Wnd_Wid_1# - #Wnd_Wid_2# cm
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Depth
								</td>
								<td>
								#Wnd_Dep_1# - #Wnd_Dep_2# cm
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Surrounding Tissue
								</td>
								<td>
								#Wnd_Surr_Tiss#
								</td>
								</tr>		
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Characteristics
								</td>
								<td>
								#Wnd_Chara#
								</td>
								</tr>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Notes
								</td>
								<td>
								#Trim(GetWounds.Notes)#
								</td>
								</tr>	
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								<td>												  
								Resolve?(Remove from future Notes)
								</td>
								<td>
								<cfif #woundlist.Resolved_Date# neq ''>Yes<cfelse>No</cfif>
								</td>
								</tr>	
								</cfif>
								</cfloop>
								</cfoutput>	
								<cfif Wcount eq 0>
								<tr style="font-size:12px;font-family:'Courier New';line-height:20px">
								  <td align="left" colspan='2'>
									No Wounds records were found
								  </td>
								</tr>	
								</cfif>
								</cfif>
								
									
							</cfif>
						</cfloop>
				</table>
			</td>
		</tr>
	</table>
<cfelse>
No Record(s) Found
</cfif>
</cfdocument>
