<cfparam name="url.rtn" default="assessment_form" />
<cfparam name='url.na' default='' />
 <cfif isdefined('url.na') and url.na eq 'y'>
  <cfset session.cs.AssessmentId = 0 />
 </cfif>
 <cfif isdefined('url.AID') and url.AID neq ''>
<cfset session.cs.AssessmentId   = decrypt(#url.AID#,"54kczhzgHTj4a8n+SRZPyg==","AES","Hex") />
</cfif>


<cfquery name="Form" datasource="#Application.DataSrc#">
 SELECT 
    patient.Last_Name_M0040 AS Last_Name, patient.First_Name_M0040 AS First_Name, patient.Middle_Initial_M0040 AS Middle,
 Assessment_Completed_M0090,
 Assessment_New.Psy_Nursing_M0630,
Assessment_New.Emergent_Care_Reason_M0840,
Assessment_New.Grooming_M0640,
Assessment_New.Grooming_M0640p,
Assessment_New.Urinary_INcont_M0520,
Assessment_New.Patient_Behav_freq_M0620,
Assessment_New.Home_Safety_Assess,
Assessment_New.Urinary_INcont_when_M0530,
Assessment_New.M0420_Assess,
 Assessment_New.Record_Created_By
FROM #Request.prefix_db_agency#.Assessment_New
  INNER JOIN #Request.prefix_db_agency#.patient ON (Assessment_New.Patient_ID=patient.Patient_ID)   
WHERE Assessment_New.Assessment_ID='#session.cs.AssessmentId#'
</cfquery>

<cfset M0230='#session.cs.AssessmentId#'&' M0230' />
<cfquery name="M0230diagnasis" datasource="#Application.DataSrc#">
select Diagnosis_ID,Diagnosis,Short_Diagnosis,Text_ICD,Severity,CONVERT(Diagnosis.Dx_Order, CHAR(10)) as Dx_Order,Primary_Diagnosis,Secondary_Diagnosis,DG_Type from #Request.prefix_db_agency#.Diagnosis where Assessment_ID='#session.cs.AssessmentId#' and M0230_Link like '%M0230%' and M0230_Link is not null order by Dx_Order asc
</cfquery>

<cfdocument format="pdf" orientation = "portrait" overwrite = "yes">

<cfdocumentsection margintop="1" >

<cfdocumentitem type="header" evalprint="true">
    <table border="0" width="100%" height="70%" cellpadding="0" cellspacing="0" align="center">
		<tr>
			<td height="5px" colspan="2" >
			</td>
		</tr>
    	<tr>
			<td style="font-family: Arial; font-size: 16px; font-weight: 600; font-style: italic; padding-left:5px">
				<cfoutput>#session.agencyname#</cfoutput> 
			</td>
			<td style="font-family: Arial; font-size: 16px;font-weight: 600;" width="35%">
				Date Completed <cfoutput>#DateFormat(Form.Assessment_Completed_M0090,"mm/dd/yyyy")#</cfoutput>
			</td>
		</tr>
		<tr>
			<td height="3px" colspan="2" >
			</td>
		</tr>
		<tr>
			<td style="font-family: Arial; font-size: 16px; font-weight:600; padding-left:5px">
				Medical Social Worker Evaluation
			</td>
			<td style="font-family: Arial; font-size: 16px; font-weight: 600;" >
				By <cfoutput>#Form.Record_Created_By#</cfoutput>
			</td>
	    </tr>
		<tr>
			<td height="3px" colspan="2" >
			</td>
		</tr>
      	<tr>
			<td style="font-family: Arial; font-size: 16px; font-weight:600; padding-left:5px">
				<cfoutput>#Form.First_Name#</cfoutput> <cfoutput> #Form.Last_Name#</cfoutput></strong> 
			</td>
      	</tr>
		<tr>
			<td height="3px" colspan="2" >
			</td>
		</tr>
      	<tr>
			<td height="1px" colspan="2" style="background-color:#000000">
			</td>
      	</tr>
  </table>
</cfdocumentitem>

<table border="0" width="100%" cellpadding="0" cellspacing="0">
                        <tr valign="top">
                            <td align="left" style="font-family: Arial; font-size: 14px; font-weight:bold;">
							         Reason for social worker referral
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                <cfoutput>#Form.Emergent_Care_Reason_M0840#</cfoutput>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 5px">
                            </td>
                        </tr>
						
						
                        <tr>
                            <td style="height: 5px">
                            </td>
                        </tr>
						<tr>
                           <td style="font-family: Arial; font-size: 14px; font-weight: bold;">
						   Pain Assessment	
                            </td>
						</tr>
						
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 14px; padding-top: 5px; padding-left: 60px;">         Pain Level
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                <cfoutput>#Form.Psy_Nursing_M0630#</cfoutput>
                            </td>
                        </tr>
						
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 14px;  padding-top: 5px; padding-left: 60px;">         Pain Characteristics
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                              <cfif Form.Grooming_M0640 contains ','>
								<cfoutput>#replace('#Form.Grooming_M0640#',',','<br />',"ALL")#</cfoutput>
								<cfelse>
								<cfoutput>#replace('#Form.Grooming_M0640#','!','<br />',"ALL")#</cfoutput>
								</cfif>
                            </td>
                        </tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 14px;  padding-top: 5px; padding-left: 60px;">         Pain Threshold
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                <cfoutput>#Form.Grooming_M0640p#</cfoutput>
                            </td>
                        </tr>
						 <tr>
                            <td style="height: 5px">
                            </td>
                        </tr>
						
						<tr>
                            <td style="font-family: Arial; font-size: 14px; font-weight:bold;"> 
							 Living Situation
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                 <cfif Form.Urinary_INcont_M0520 contains ','>
								<cfoutput>#replace('#Form.Urinary_INcont_M0520#',',','<br />',"ALL")#</cfoutput>
								<cfelse>
								<cfoutput>#replace('#Form.Urinary_INcont_M0520#','!','<br />',"ALL")#</cfoutput>
								</cfif>
                            </td>
                        </tr>
						 <tr>
						 
						 <tr>
                            <td align="left" style="font-family: Arial; font-size: 14px; font-weight:bold; ">   
							    Mental Status
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                 <cfif Form.Patient_Behav_freq_M0620 contains ','>
								<cfoutput>#replace('#Form.Patient_Behav_freq_M0620#',',','<br />',"ALL")#</cfoutput>
								<cfelse>
								<cfoutput>#replace('#Form.Patient_Behav_freq_M0620#','!','<br />',"ALL")#</cfoutput>
								</cfif>
                            </td>
                        </tr>
						 <tr>
						 
						  <tr>
                            <td align="left" style="font-family: Arial; font-size: 14px; font-weight:bold; ">
							       Home safety Issues Mark all that apply
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                <cfoutput>#Form.Home_Safety_Assess#</cfoutput>
                            </td>
                        </tr>
						 <tr>
						 
						  <tr>
                            <td align="left" style="font-family: Arial; font-size: 14px; font-weight:bold;  ">
							       Financial
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                <cfoutput>#Form.Urinary_INcont_when_M0530#</cfoutput>
                            </td>
                        </tr>
						 <tr>
						 
						  <tr>
                            <td align="left" style="font-family: Arial; font-size: 14px; font-weight:bold; ">
							       Physical Assessment
                            </td>
						</tr>
						<tr>
                            <td align="left" style="font-family: Arial; font-size: 12px; padding-top: 5px; padding-left: 80px;">
                                <cfoutput>#Form.M0420_Assess#</cfoutput>
                            </td>
                        </tr>
						 <cfif #session.AgencyId# eq '613'>
							 <tr>
								   <td style="height: 5px">
									</td>
							  </tr>
							 <tr>
								<td style="font-family: Arial; font-size: 12px; padding-top: 5px; width: 50%; padding-left: 20px;">
							<!---Physician Name: <cfoutput><b>#Form.LastName# ,#Form.FirstName#</b></cfoutput>--->       Physician Signature: ____________________________________________________
								</td>
							 </tr>
						 </cfif>
						 
						 <tr>
                            <td style="height: 5px">
                            </td>
                        </tr>
				</table>		
						
						
						
						
						
		 <cfdocumentitem type="footer">
		<!---<cfoutput>Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</cfoutput>--->
		<table width="100%" cellpadding="0" cellpadding="0" border="0" align="center">
		<tr>
		<td align="center" style="font-family: Arial; font-size: 13px;">
		<cfoutput>Page #cfdocument.currentpagenumber#  Medical Social Worker Evaluation for <cfoutput>#Form.First_Name# #Form.Last_Name#</cfoutput></cfoutput>
		</td>
		</tr>
		</table>
		
	</cfdocumentitem>
	</cfdocumentsection>
</cfdocument>				 
						 
						
						
						
						
						

