<cfif isdefined('session.cs.patientid')>
<cfquery name="GetP" datasource="#Application.DataSrc#">
 SELECT Patient_ID, Last_Name_M0040, First_Name_M0040, Allergies, Primary_ReferringPhys_ID_M0072 
 FROM  #Request.prefix_db_agency#.patient 
 WHERE  Patient_ID = '#session.cs.patientid#'
</cfquery>
</cfif>
<cfquery name="Cert" datasource="#Application.DataSrc#">
select Certification_Start,Certification_End from #Request.prefix_db_agency#.Assessment_New where Assessment_ID = <cfqueryparam value="#Session.AID#" cfsqltype="CF_SQL_INTEGER" null="#IIF(len(Session.AID),de('no'),de('yes'))#">
</cfquery>
<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,e.Last_Name,
	pd.Pathway_Details_ID,pd.Assessment_Tracker_ID,pd.M0_Answer as Diagnosis,si.Visit_Date,
	pvd.Description as pvd_description,pvd.Performed,pvd.Severity,pvd.Notes,pvd.Reading1,pvd.Type as pvd_type,pvd.Reading2,pvd.Progress_Details_ID,pvd.Record_creation_date as pvdtest
	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
	WHERE pd.Assessment_ID = <cfqueryparam value="#Session.AID#" cfsqltype="CF_SQL_INTEGER" null="#IIF(len(Session.AID),de('no'),de('yes'))#">
	AND   pd.Skill = '#url.code#'
	AND  (pd.Deleted IS NULL)
	AND   pd.Resolved_Date IS NULL
	Group by pd.Description
	ORDER BY pd.Record_Creation_Date, pd.Description
</cfquery>

<cfdocument   format = "PDF"   orientation = "portrait"   overwrite = "yes" margintop="0.8">
<cfdocumentitem type="header">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 <tr>
    <td colspan="2" height="55px">	
	</td>
 </tr>
<tr>
<td align="left" style="font-family:Arial;font-size:18px;">
<b><cfoutput>#GetP.Last_Name_M0040# #GetP.First_Name_M0040#</cfoutput></b>
</td>
<td align="right" style="font-family:Arial;font-size:18px;">
<b><cfoutput>#url.code# Careplan</b> #DateFormat(Cert.Certification_Start,"mm/dd/yyyy")# - #DateFormat(Cert.Certification_End,"mm/dd/yyyy")#</cfoutput>
</td>
</tr>
</table>
</cfdocumentitem>
<cfset categorylist="Vital Signs:Vital Sign:id_vitalsign,Laboratory:laboratory:id_laboratory,Wounds:Wound:id_wound,Symptoms:Symptom:id_sympton,Interventions:Intervention:id_intervention,Goals:Goal:id_goal" />

<cfloop list="#categorylist#" index=item>

<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>

<table cellpadding="2" cellspacing="0" border="0" width="100%">  
 <tr>
    <td style="font-family:Arial;border-bottom:1px solid 666666;font-size:14px;">
	<cfoutput>#item1#</cfoutput>
	</td>
 </tr>
 <tr>
    <td height="5px">	
	</td>
 </tr>
 <cfoutput query="GetPathDetails">
 <tr>   
   <td valign="top" style="padding-left:10px;font-family:Courier New;font-size:12px; ">
   #Description#<br/>  
   </td>			
    <cfif "#item1#" neq "Goals" and "#item1#" neq "Interventions">
    <td valign="top" width="20%" align="center" style="padding-left:10px;font-family:Courier New;font-size:12px;">
	#Severity#
	</td>
    </cfif>					
 </tr>
 </cfoutput>
</table>

<br><br>
</cfloop>
</cfdocument>