<!---
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.8 $
$Id: communication_print.cfm,v 1.8 2010/05/04 13:02:39 melissa Exp $
$Date: 2010/05/04 13:02:39 $
--->
<!--- Page specific code, such as queries and variable settings should go here --->


<cfquery name="GetComm" datasource="#Application.DataSrc#">
	SELECT Communication.Comm_ID, Communication.CommSub_ID, Communication.Patient_ID, Communication.Employee_ID, 
	Communication.Comm_Date, Communication.Memo, Communication.Resolved, Communication.Record_Created_By,
	Communication.Followup_Desc, Communication.Followup_Memo, 
	pEmployee.Emp_ID, pEmployee.Emp_Last, pEmployee.Emp_First, 
	CommunicationSubjects.CommSub_ID, CommunicationSubjects.Subject, 
	pPatients.Patient_ID, pPatients.Pt_Last, pPatients.Pt_First, pAdmit.Refer_Phys_ID AS Primary_ReferringPhys_ID_M0072,
	pPhysicians.Phys_ID, pEmployee.Emp_Last as LastName, pEmployee.Emp_First as FirstName, pEmployee.Emp_Street1 AS Address1, pEmployee.Emp_City AS City, 
	pEmployee.Emp_State AS State, pEmployee.Emp_Zip AS Zip, pEmployee.Emp_Telephone as Telephone1,pPhysicians.Phys_Fax as Fax, 
	Agency.Agency_ID, Agency.Agency_Name, Agency.Agency_Contact_Phone
	FROM #Request.prefix_db_agency#.Communication
		   JOIN #Request.prefix_db_agency#.CommunicationSubjects  ON  CommunicationSubjects.CommSub_Id = Communication.CommSub_Id 
		   JOIN #Request.prefix_db_agency#.pPatients  ON  pPatients.Patient_ID = Communication.Patient_ID AND pPatients.Status  < 2
		   JOIN #Request.prefix_db_agency#.pAdmit  ON    pAdmit.Patient_ID = pPatients.Patient_ID  AND pAdmit.Status = 0
	       JOIN #Request.prefix_db_lookup#.Agency   ON Agency.Agency_Id = Communication.Agency_Id
	       LEFT OUTER JOIN #Request.prefix_db_lookup#.pEmployee  ON  pEmployee.Emp_Id = Communication.Employee_Id 
	       LEFT OUTER JOIN #Request.prefix_db_lookup#.pPhysicians  ON  pPhysicians.Emp_ID = pEmployee.Emp_ID
	       WHERE Communication.Comm_ID = #url.Comm_ID#
		GROUP BY Communication.Comm_ID 
</cfquery>

<cfset CrLf = Chr(13) />

<cfif GetComm.recordcount>
	<cfquery name="GetI" datasource="#Application.DataSrc#">
	SELECT Emp_First AS FIRST, Emp_Last AS LAST 
	FROM #Request.prefix_db_lookup#.pEmployee
	WHERE Emp_ID = '#GetComm.Record_Created_By#' AND Emp_Type != 'Physician'
	</cfquery>
		<cfdocument   format = "PDF"   orientation = "portrait"   overwrite = "yes">
		<div id="printreport"  style="font-size:14px;">
		<cfoutput query="getComm">
		<h3 style="font-size:14px;">Memo regarding #Pt_First# #Pt_Last# from #Agency_Name#<br><br>
		<em style="font-size:14px;">Re: #Subject#</em></cfoutput><br></h3>
		<cfoutput query="getI"><em style="font-size:14px;">Submitted by: #FIRST# #LAST#</em></cfoutput>
		<cfoutput query="getComm">
		<table>
		<table width="100%">

		 <tr>
		    <td style="font-size:14px;"><b>Physician</b></td>
		    <td style="font-size:14px;">#FirstName# #LastName#<br>#Address1#<br>#City#, #State# #Zip#<br>#Telephone1#     Tele<br /><cfif #Fax# neq ''>#Fax#<cfelse>No</cfif>     Fax</td>
		  </tr>
	  	<tr>
		    <td> </td>
		    <td> </td>
		  </tr>
		 <tr>
		   <td style="font-size:14px;"><b>Date</b></td>
		    <td style="font-size:14px;">#DateFormat(Comm_Date,"mm/dd/yyyy")#</td>
		  </tr>
		  <tr>
		    <td style="font-size:14px;"><b>Memo</b></td>
		    <td style="font-size:14px;"><i>#Replace(Memo, CrLf, "<br>", "ALL")#</i></td>
		  </tr>
		  <tr>
		    <td style="font-size:14px;"><b>Follow-Up</b></td>
		    <td style="font-size:14px;"><i>#Followup_Desc#:  #Followup_Memo#</i></td>
		  </tr>

		    <tr>
		    <td style="font-size:14px;"> </td>
		    <td style="font-size:14px;"> </td>
		  </tr>
		  <tr>
		  <td style="font-size:14px;"><b>Agency Representative</b></td>
		    <td style="font-size:14px;">#Emp_First# #Emp_Last#<br>#Agency_Contact_Phone#</td>
		  </tr>
		</table>
		</table>

		</cfoutput>
		<p>
		</p>
		<p style="font-size:14px;">This memo is for your records.</p>
		</div>
		</cfdocument>
	
<cfelse>
	<cfoutput>Please assign an employee to the communication.</cfoutput>
</cfif>
