<!---
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.18 $
$Id: patient_chart.cfm,v 1.18 2009/09/02 01:34:14 arlen Exp $
$Date: 2009/09/02 01:34:14 $
--->

<cfparam name = 'url.fstl' default = 'n' />
<cfset filepath = "/var/www/html/datafiles/" />
<cfif Application.DEV>
	<cfset filepath = "E:\wwwroot\dev-live\datafiles\" />
</cfif>

<cfparam name='url.patient_id' default='' />
 <cfif url.patient_id neq ''>
  <cfset session.cs.patientid = url.patient_id />
 </cfif>
 
 <cfif isdefined("url.ID")>
 <cfset patientid=#url.ID#>
 </cfif>

<cfquery  name="GetP" datasource="#Application.DataSrc#">
	SELECT Patient_ID, Last_Name_M0040 AS Last_Name, First_Name_M0040 AS First_Name, Middle_Initial_M0040 AS Middle
	FROM #Request.prefix_db_agency#.patient
	WHERE  Patient_ID = '#session.cs.patientid#'
	AND    Agency_ID = #session.AgencyID#
</cfquery>

<cfif isDefined("url.df")>
	<cfquery  name='delFile' datasource='#Application.DataSrc#'>
		DELETE FROM #table_files# 
		WHERE  id = '#url.df#'
		AND    AgencyId = '#session.AgencyId#'
		AND    PatientId = '#GetP.Patient_Id#'
	</cfquery>
	<cflocation url='/patientadmin_new/index.cfm?page=patient&ID=#GetP.Patient_Id#&cat=patient_chart' addtoken='no' />
</cfif>

<cfif isDefined("Form.ufTitle") and isDefined("Form.ufFile")>
	<cfparam name="cffile.serverFile" default="">
	<cffile action="upload" filefield="Form.ufFile" destination="#filepath#" nameconflict="makeunique" mode = "664" >
	<cffile action="readbinary" variable="fileContent" file="#filepath##File.ServerFile#" >
	<cfif File.FileSize gt 510000>
		<cffile action="delete" file="#filepath##File.ServerFile#">
		<cflocation url='/patientadmin_new/index.cfm?page=patient&Id=#GetP.Patient_Id#&cat=patient_chart&fstl=y' addtoken='no' />
	<cfelse>
		<cfquery  name='uFile' datasource='#Application.DataSrc#'>
			INSERT INTO #table_files# (
			AgencyId, PatientId, Title, FileName, FileType, File, CreatedBy
			<cfif isdefined('form.document_name') and form.document_name neq ''>,DOC_ID</cfif>
			) VALUES (
			'#session.AgencyId#'
			,'#GetP.Patient_Id#'
			,'#Form.ufTitle#'
			,'#File.ServerFile#'
			,'#File.ContentType#/#File.ContentSubType#'
			<!--- ,'#toBase64(fileContent)#' --->
			,<cfqueryparam value="#fileContent#" cfsqltype="cf_sql_blob" />
			,'#session.EmployeeId#'
		<cfif isdefined('form.document_name') and form.document_name neq ''>,#form.document_name#</cfif>

			)
		</cfquery>
	</cfif>
	<cffile action="delete" file="#filepath##File.ServerFile#">
	<cflocation url='/patientadmin_new/index.cfm?page=patient&ID=#GetP.Patient_Id#&cat=patient_chart' addtoken='no' />
</cfif>

<cfquery  name='getFiles' datasource='#Application.DataSrc#'>
	SELECT f.*, e.Last_Name, e.First_Name
	FROM   #table_files# f,#Request.prefix_db_lookup#.Employee e
	WHERE  f.AgencyId = '#session.AgencyId#'
	AND    f.PatientId = '#GetP.Patient_Id#'
	AND    e.Employee_Id = f.CreatedBy
	<cfif Session.EmpLevel eq 6 or Session.EmpLevel eq 8>
		AND e.Employee_Id = '#Session.EmployeeID#'
	</cfif>
	ORDER BY f.id
</cfquery>

<!--- Get Communication --->
<cfquery  name="GetComm" datasource="#Application.DataSrc#">
	SELECT Communication.Comm_ID, Communication.CommSub_ID, Communication.Comm_Date, Communication.Resolved
	      ,CommunicationSubjects.CommSub_ID, CommunicationSubjects.Subject 
	FROM   #Request.prefix_db_agency#.Communication, #Request.prefix_db_agency#.CommunicationSubjects
	WHERE  Communication.Patient_ID = #session.cs.patientid#
	AND    CommunicationSubjects.CommSub_ID = Communication.CommSub_ID
	AND    Communication.Agency_ID = #session.AgencyID# 
	<cfif Session.EmpLevel eq 6 or Session.EmpLevel eq 8>
		
	</cfif>
	 Order by Comm_Date Desc
</cfquery>

<!--- Page specific code, such as queries and variable settings should go here --->
<cfquery  name="GetEvent" datasource="#Application.DataSrc#">
SELECT Event.Event_ID, Event.EventSub_ID, Event.Event_Date, 
patient.Last_Name_M0040, Employee.Employee_ID, Employee.Last_Name, EventSubjects.EventSub_ID, EventSubjects.Subject,Event.Resolved
FROM #Request.prefix_db_agency#.Event,#Request.prefix_db_lookup#.Employee, #Request.prefix_db_agency#.patient, #Request.prefix_db_agency#.EventSubjects
WHERE Event.Agency_ID = #session.AgencyID#
And Event.Employee_ID = Employee.Employee_ID
And Event.Patient_ID = patient.Patient_ID
And Event.EventSub_ID = EventSubjects.EventSub_ID
And Event.Patient_ID = '#session.cs.patientid#'
	<cfif Session.EmpLevel eq 6 or Session.EmpLevel eq 8>
		AND   
			(
				patient.Employee_ID = '
				#Session.EmployeeID#'
				OR
				'#session.EmployeeId#' 
				IN 
				(
					select distinct employee_id from #Request.prefix_db_agency#.ScheduleItems where patient_id = patient.Patient_Id and deleted <> 1
				)
			)
	</cfif>			
ORDER BY Event_Date DESC
</cfquery>



<!--- End page specific code --->
  

<script type="text/javascript" src="../Scripts/jquery-latest.js"></script>
<cfinclude template="PatientMenu.cfc">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 <tr>
 <td valign="middle" style="padding-left:7px;font-family:Tahoma; font-size:12px;color:ffffff; font-weight:bold; height:25px; background-color:999498">
 <cfoutput>#getP.Last_Name#, #getP.First_Name# #getP.Middle# - Chart Review</cfoutput>
 </td>
 </tr> 
 <tr>
 <td height="15px">
 </td>
 </tr>
 <tr>
 <td valign="bottom" align="left">
 <cfscript>
  pm = CreateObject("Component", "PatientMenu");
  pm.getPatientMenu(#getP.Patient_Id#);
 </cfscript>
 </td>
 </tr> 
 <tr>
 <td height="15px">
 </td>
 </tr>  
 </table> 
 
 <cfif url.fstl eq 'y'>
 <div style='width:500px; background:#ff0; margin:15px 0px 15px 0px; padding:10px; letter-spacing:1px;'>
  The file you uploaded exceeded the 500k (500,000 byte) file size limit.
   <br/>
  Please reduce the size of the file and try uploading again.
 </div>
</cfif>

<script type="text/javascript" language="javascript">
 function tuf() {
  if(document.getElementById('tuf1Div').style.display == 'none') {
   document.getElementById('tuf1Div').style.display = '';
   document.getElementById('tuf2Div').style.display = '';
  } else {
   document.getElementById('tuf1Div').style.display = 'none';
   document.getElementById('tuf2Div').style.display = 'none';
  }
 }
 function cfu() {
  document.getElementById('tdSubmit').style.display = 'none';
  if(document.uf.ufFile.value == '') {
   bootbox.alert('Please select a Patient File to Upload');
   document.uf.ufFile.focus();
   document.getElementById('tdSubmit').style.display = '';
   return false;
  }
  if(document.uf.ufFile.value.indexOf("'") > -1) {
    bootbox.alert("The File Name cannot contain an apostrophe (')\nPlease Rename the file - removing the apostrophe (')");
    document.getElementById('tdSubmit').style.display = '';
    return false;
  }
  var f = document.uf.ufFile.value.toLowerCase();
  if( f.indexOf(".cfm") > -1 
	 || f.indexOf(".htm") > -1 
   || f.indexOf(".php") > -1 
	 || f.indexOf(".cgi") > -1
	 || f.indexOf(".pl") > -1
	 || f.indexOf(".asp") > -1 
	 || f.indexOf(".bat") > -1 
	 || f.indexOf(".exe") > -1
  ) {
    bootbox.alert('The file type you are trying to upload is not allowed');
    document.getElementById('tdSubmit').style.display = '';
    return false;
  }
  if(document.uf.ufTitle.value == '') {
   bootbox.alert('Please enter a Title for the Patient File');
   document.uf.ufTitle.focus();
   document.getElementById('tdSubmit').style.display = '';
   return false;
  }
  if(document.uf.ufFile.value.lastIndexOf(".") > -1) {
    document.uf.fileExt.value = 
	   document.uf.ufFile.value.substring(
	     document.uf.ufFile.value.lastIndexOf(".")
	    ,document.uf.ufFile.value.length
	   );
  }
  if(document.uf.ufFile.value.lastIndexOf("/") > -1) {
    document.uf.fileName.value = 
	   document.uf.ufFile.value.substring(
	     document.uf.ufFile.value.lastIndexOf("/") + 1
	    ,document.uf.ufFile.value.length
	   );
  } else if(document.uf.ufFile.value.lastIndexOf("\\") > -1) {
    document.uf.fileName.value = 
	   document.uf.ufFile.value.substring(
	     document.uf.ufFile.value.lastIndexOf("\\") + 1
	    ,document.uf.ufFile.value.length
	   );
  }
 }
</script>
<div id='tuf1Div' style='display:none; width:500px; padding:4px 10px 4px 10px; background:#77c; color:#fff; font-size:12px; font-weight:bold; letter-spacing:1px;'>
 Patient Document Upload...
</div>
<div id='tuf2Div' style='display:none; width:500px; padding:10px; background:#fbfbfb;'>
 <cfif session.PatientFileManagerInUse eq 0>
  <div style='letter-spacing:1px;'>
   Your Agency is not currently using the Patient Document Management feature.
   <div style='margin-top:10px;'>
    This feature allows you to Upload documents related to the Patient's care including any 
    .doc, .pdf, .xls, etc... files you would like to associate with this Patient's record.
   </div>
   <div style='margin-top:10px;'>
    If you would like to begin using this feature, please <a href='mailto:info@MyHomecareBiz.com?subject=Patient Document Management Feature...'>Contact Us</a> to have this feature Enabled for your Agency.
   </div>
  </div>
 <cfelse>
  <cfquery  name='Document' datasource='#Application.DataSrc#'>
	SELECT *
	FROM   #Request.prefix_db_agency#.DocumentDesc
	WHERE DocumentType like '%Patient%'
	ORDER BY DOC_ID
</cfquery> 
  <form name='uf' enctype='multipart/form-data' action='/patientadmin_new/index.cfm?page=patient&ID=<cfoutput>#GetP.Patient_Id#</cfoutput>&cat=patient_chart' method='post' onsubmit='return cfu();'>
   <input type='hidden' name='fileName' value='' />
   <input type='hidden' name='fileExt' value='' />
  <table style='letter-spacing:1px;'>
   <tr>
    <td><b>File to Upload :</b></td>
    <td>
	   <input name='ufFile' type='file' style='width:200px;' />
	  </td>
   </tr>
   <tr>
    <td><b>Title for File :</b></td>
    <td>
	   <input name='ufTitle' type='text' style='width:200px;' />
	  </td>
   </tr>
    <tr>
    <td><b>Document Name</b></td>
    <td>
	   <select name="document_name" id="document_name"  >
			<option value='' selected>--Select Document_Name--</option>
			<cfoutput query=Document>
				<option value="#DOC_ID#">#Description#</option>
			</cfoutput>
			</select>
	  </td>
   </tr>
   <tr>
    <td></td>
    <td id='tdSubmit'>
     <input type='submit' value='Upload File' /> &nbsp; <a href='#' onclick='javascript:tuf();'>Cancel</a>
    </td>
   </tr>
  </table>
 </form>
 </cfif>
</div>





<!--*********************************************************************************************************************************-->
<!--****************************************Employee Login**************************************************-->
<!--*********************************************************************************************************************************-->
  <cfif Session.EmpLevel eq 1 or Session.EmpLevel eq 2 or Session.EmpLevel eq 3 or Session.EmpLevel eq 4 or Session.EmpLevel eq 5 or Session.EmpLevel eq 6 or Session.EmpLevel eq 7 or Session.EmpLevel eq 8 or Session.EmpLevel eq 9 >
  
  <cfquery  name="PatientLevel3" datasource="#Application.DataSrc#">
			SELECT MenuLevel3Id,MenuNames,DefaultPageUrl FROM #Request.prefix_db_lookup#.homecare_menulevel3 where parentid = 12
			<cfif session.EmpLevel eq 1>
			and Level1Access=1
			<cfelseif session.EmpLevel eq 2>
			and Level2Access=1
			<cfelseif session.EmpLevel eq 3>
			and Level3Access=1
			<cfelseif session.EmpLevel eq 4>
			and Level4Access=1
			<cfelseif session.EmpLevel eq 5>
			and Level5Access=1
			<cfelseif session.EmpLevel eq 6>
			and Level6Access=1
			<cfelseif session.EmpLevel eq 7>
			and Level7Access=1
			<cfelseif session.EmpLevel eq 8>
			and Level8Access=1
			<cfelseif session.EmpLevel eq 9>
			and Level9Access=1
			</cfif>
	</cfquery>
		
		<cfset Upload="0">
		<cfset Communication="0">
		<cfset Assessment="0">
		<cfset Inidence="0">
		
		
		<cfloop query="PatientLevel3">
			<cfif  PatientLevel3.MenuNames EQ "Uploaded Documents">
				<cfset Upload="1">
			</cfif>
			<cfif  PatientLevel3.MenuNames EQ "Communications">
				<cfset Communication="1">
			</cfif>
			<cfif  PatientLevel3.MenuNames EQ "Incidences">
				<cfset Inidence="1">
			</cfif>
			<cfif  PatientLevel3.MenuNames EQ "Assessments">
				<cfset Assessment="1">
			</cfif>
		</cfloop>
  

	  
  
  
<cfif  Upload EQ 1>  

<div onclick="NonAnchorTag('patientspanid','patientfileid','','')" style="margin: 10px 10px; padding: 4px 0px 4px 10px; font-size: 14px; font-weight: bold;text-align: left; cursor: pointer; background-color:#e7e7e9; height:15px">
	<div style="float:left;width:55%; font-size: 14px; font-weight: bold;">
		<span id="patientspanid">+</span>&nbsp;&nbsp;Patient Files
	</div>
</div>
<table align="center" width="100%" style="display: none;" id='patientfileid'>

<tr>
	<td valign='top' style='padding-right:10px;' align="right">
	<cfif session.eaClientEdit eq 1>	
	 <span class='raquo'>&raquo;</span> <a href='/patientadmin_new/index.cfm?page=patient&ID=<cfoutput>#getFiles.PatientId#</cfoutput>&cat=patient_upload' >Upload a Patient File</a>
	 </cfif>
	</td>
 </tr>

<tr>
	<td>
<table cellpadding="0" cellspacing="0" width="98%" align="center" style="border:solid 1px green;">
 <tr style="height:30px; background-image:url(../../images/grid_tab.gif)" >
	<td style="font:Arial; font-size:12px; padding-left:5px" align="left"><b>Title</b></td>
	<td style="font:Arial; font-size:12px;" align="left"><b>File Name</b></td>
	<td style="font:Arial; font-size:12px;" align="left"><b>Uploaded By</b></td>
	<td style="font:Arial; font-size:12px;" align="left"><b>Upload Date</b></td>
	<td style="font:Arial; font-size:12px;" align="left"><b>Action</b></td>
 </tr>
 <cfif getFiles.RecordCount lt 1>
  <tr>
   <td colspan='4' style="padding-left:5px">No Files have been Uploaded</td>
  </tr>
 </cfif>
 <cfoutput query="getFiles">
 <cfset RowBG = IIF(GetComm.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''")>
 <tr style="height:25px" <cfif GetComm.CurrentRow MOD 2 EQ 0> bgcolor="##FFFFFF" <cfelse>bgcolor="##e7e7e9"</cfif> >
  <td style="font:Arial; font-size:12px; padding-left:5px" ><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.Title#</a></td>
  <td style="font:Arial; font-size:12px;"><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.FileName#</a></td>
  <td style="font:Arial; font-size:12px;">#getFiles.Last_Name#, #getFiles.First_Name#</td>
  <td style='font:Arial; font-size:12px;'>#DateFormat(getFiles.Created, 'mm/dd/yyyy')#</td>
  <td style='font:Arial; font-size:12px;'>
  <cfif session.eaClientEdit eq 1>	
	 <a href='##' onclick="javascript:if(confirm('Are you sure you want to DELETE this file?')) { window.location.replace('/patientadmin_new/index.cfm?page=patient&ID=#getFiles.PatientId#&cat=patient_chart&df=#getFiles.id#'); }">Delete</a>
	 </cfif>
	</td>
 </tr>
 </cfoutput>
</table>
	</td>
</tr>
</table>
</cfif>

<cfif  Communication EQ 1>  

<div onclick="NonAnchorTag('communicationspanid','communicationid','','')" style="margin: 10px 10px; padding: 4px 0px 4px 10px; font-size: 14px; font-weight: bold;text-align: left; cursor: pointer; background-color:#e7e7e9; height:15px">
	<div style="float:left;width:55%; font-size: 14px; font-weight: bold;">
		<span id="communicationspanid">+</span>&nbsp;&nbsp;Communication
	</div>
</div>
<table align="center" width="100%" style="display: none;" id='communicationid'>

<tr>
	<td valign='top' style="padding-right:10px" align="right">
	<cfif session.eaClientEdit eq 1>	
	 <span class='raquo'>&raquo;</span> <a href='/agencyadmin/index.cfm?page=agency&cat=Communication&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>&rpt=New_Commwizard&ID=0'>New Communication</a>
	</cfif>
<!--- To Do: add ability to Un-Archive Comms...
	  &nbsp;&nbsp;
	 <span class='raquo'>&raquo;</span> <a href='/patientadmin_new/index.cfm?page=patient&cat=patient_chart&archived=y'>Archived Communications</a>
--->
	 <span class='raquo'>&raquo;</span>&nbsp;<img src="../../images/printer.gif" style="vertical-align:middle" />&nbsp;
	 <a href="javascript:void(0);" onclick="javascript:clickwin=window.open('/patientadmin_new/index.cfm?page=patient&cat=printcommunicationhistory&patient_id=<cfif #patientid#eq ''><cfoutput>#session.cs.patientid#</cfoutput><cfelse><cfoutput>#patientid#</cfoutput></cfif>')">Print Communication Report</a>
	 </td>
 </tr>
 
 <tr>
 	<td>
	
<table cellpadding="0" cellspacing="0" class="list-border" width="98%" align="center" style="border:solid 1px green;">
 <tr style="height:30px; background-image:url(../../images/grid_tab.gif)" >
	<td style="font:Arial; font-size:12px; padding-left:5px" align="left"><b>Date</b></td>
	<td style="font:Arial; font-size:12px;" align="left"><b>Subject</b></td>
	<td style="font:Arial; font-size:12px;" align="left"><b>Resolved</b></td>
	<td style="font:Arial; font-size:12px;" align="left"><b>Action</b></td>
 </tr>
 <cfif GetComm.RecordCount lt 1>
  <tr>
   <td colspan='4' style="padding-left:5px">No Communications were found</td>
  </tr>
 </cfif>
 <cfoutput query="GetComm">
 <cfset RowBG = IIF(GetComm.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''")>
 
 <tr style="height:25px" <cfif GetComm.CurrentRow MOD 2 EQ 0> bgcolor="##FFFFFF" <cfelse>bgcolor="##e7e7e9"</cfif> id='commTR#GetComm.Comm_ID#' class="#RowBG#">
	<td nowrap style="font:Arial; font-size:12px; padding-left:5px">#DateFormat(Comm_Date,"mm/dd/yyyy")#</td>
	<td style="font:Arial; font-size:12px;">#Subject#</td>
	<td style='font:Arial; font-size:12px;'>
	<cfif session.eaClientEdit eq 1>	
   <a href='../agencyadmin/index.cfm?page=agency&cat=Communication&rpt=communication_view&ID=#GetComm.Comm_ID#&res=No&patient_id=#GetP.Patient_ID#'>#Resolved#</a>
   <cfelse>
		#Resolved#   
   </cfif>
	</td>
	<td style='font:Arial; font-size:12px;'>
	 <a href='index.cfm?page=patient&cat=communication_print&ID=#GetComm.Comm_ID#' target='p'>Print</a>
	  |
	 <a href='javascript:void(0);' onclick="javascript: delComm('#GetComm.Comm_Id#', 'commTR#GetComm.Comm_Id#');">Archive</a>
  </td>
 </tr>
 </cfoutput>
</table>

	</td>
</tr>


</table>

 <script>
  function delComm(id, trId) {
   if(confirm('Are you sure you want to Archive this Communication?')) {
	var msg = ajaxURL('/patientadmin_new/ajax-patient-functions.cfm?p=ArchiveComm&id='+id);
    if(document.all) {
	 document.getElementById(trId).style.display = 'none';
	} else {
	 document.getElementById(trId).innerHTML = "<td colspan='4' align='center' style='background:#fafafa; color:#f00;'>This Communication has been Archived</td>";
	}
   }
  }
  

 </script>
 
 </cfif>
 
 
<cfif Inidence EQ 1>
<div onclick="NonAnchorTag('IncidenceSpanid','Incidenceid','','')" style="margin: 10px 10px; padding: 4px 0px 4px 10px; font-size: 14px; font-weight: bold;text-align: left; cursor: pointer; background-color:#e7e7e9; height:15px">
	<div style="float:left;width:55%; font-size: 14px; font-weight: bold;">
		<span id="IncidenceSpanid">+</span>&nbsp;&nbsp;Incidences
	</div>
</div>
<table align="center" width="100%" style="display: none;" id='Incidenceid'>
<tr>
	<td valign='top' style='padding-right:10px;' align="right">
	<cfif session.eaClientEdit eq 1>	
	 <span class='raquo'>&raquo;</span> 

	 <a href='/agencyadmin/index.cfm?page=agency&cat=Event&rpt=patient_NewIncidenceWizard&ID=0&res=No&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>'>New Incidences</a>&nbsp;
	 </cfif>
	 <span class='raquo' style='padding-left:25px;'>&raquo;</span> 
	 &nbsp;<img src="../../images/printer.gif" style="vertical-align:middle" />&nbsp;
    <a target="_blank" href="patient/Event_form_Print?ID=0&res=No&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>&patientname=<cfoutput>#getP.First_Name# #getP.Last_Name#</cfoutput>">Print Incidences Report</a>
	</td>
 </tr>
<tr>
	<td>
<table cellpadding="0" cellspacing="0" class="list-border" align="center" style="border:solid 1px green;" width="98%">
 <tr style="height:30px; background-image:url(../../images/grid_tab.gif)" class='list-hdr' >
			<td style="font:Arial; font-size:12px; padding-left:5px" align="left"><b>Date</b></td>
			<td style="font:Arial; font-size:12px;" align="left"><b>Patient</b></td>
			<td style="font:Arial; font-size:12px;" align="left"><b>Employee</b></td>
			<td style="font:Arial; font-size:12px;" align="left"><b>Subject</b></td>
	  </tr>
		<cfif getEvent.RecordCount lt 1>
  <tr>
   <td colspan='4' style="padding-left:5px">No Incidences were found</td>
  </tr>
 </cfif>
<cfoutput query="getEvent" >
			<tr style="height:25px" <cfif getEvent.CurrentRow MOD 2 EQ 0> bgcolor="##FFFFFF" <cfelse>bgcolor="##e7e7e9"</cfif> class="trhighlight" >
				<td style="font:Arial; font-size:12px; padding-left:5px" >#DateFormat(GetEvent.Event_Date,"mm/dd/yyyy")#</td>
				<td  nowrap style="font:Arial; font-size:12px;">#GetEvent.Last_Name_M0040#</td>
				<td nowrap style="font:Arial; font-size:12px;">#GetEvent.Last_Name#</td>
				<td style="font:Arial; font-size:12px;">#Subject#</td>
			</tr>
</cfoutput>
</table>
	</td>
</tr>
</table>
</cfif>

</cfif>









<!--*********************************************************************************************************************************-->
<!--****************************************Agency Login**************************************************-->
<!--*********************************************************************************************************************************-->
<script language="javascript" type="text/javascript">
function NonAnchorTag(sid,tid,linkid,reid)
{   
  if(document.getElementById(tid).style.display == '') 
     { 
	  document.getElementById(sid).innerHTML = '+'; 
	  document.getElementById(tid).style.display = 'none';		  
	  if(linkid !='')
	  {   
	  document.getElementById(linkid).style.display = 'none';	
	  document.getElementById(reid).style.display = 'none';    
	  }
	  	
	 } 
  else 
     { 
	  document.getElementById(sid).innerHTML = '-'; 
	  document.getElementById(tid).style.display = '';	  
	  if(linkid!='')
	  {  
	  document.getElementById(linkid).style.display = ''; 
	  document.getElementById(reid).style.display = '';	 	  
	  }
	  
	 }	 
}
</script>

  <cfif Session.EmpLevel neq 1 and Session.EmpLevel neq 2 and Session.EmpLevel neq 3 and Session.EmpLevel neq 4 and Session.EmpLevel neq 5 and Session.EmpLevel neq 6 and Session.EmpLevel neq 7 and Session.EmpLevel neq 8 and Session.EmpLevel neq 9 >
  
<div onclick="NonAnchorTag('patientspanid','patientfileid','','')" style="margin: 10px 10px; padding: 4px 0px 4px 10px; font-size: 14px; font-weight: bold;text-align: left; cursor: pointer; background-color:#e7e7e9; height:15px">
	<div style="float:left;width:55%; font-size: 14px; font-weight: bold;">
		<span id="patientspanid">+</span>&nbsp;&nbsp;Patient Files
	</div>
</div>
<table align="center" width="100%" style="display: none;" id='patientfileid'>

<tr>
 	<td valign='top' style='padding-right:10px;;' align="right">
	 <span class='raquo'>&raquo;</span> <a href='/patientadmin_new/index.cfm?page=patient&ID=<cfoutput>#getFiles.PatientId#</cfoutput>&cat=patient_upload' >Upload a Patient File</a>
	</td>
 </tr>

<tr>
	<td>
<table cellpadding="0" cellspacing="0" class="list-border" width="98%" align="center" style="border:solid 1px green;">
 <tr style="height:30px; background-image:url(../../images/grid_tab.gif)" class='list-hdr' >
 
	<td  align="left" style="padding-left:5px; font:Arial; font-size:12px;"><b>Title</b></td>
	<td align="left" style="font:Arial; font-size:12px;"><b>File Name</b></td>
	<td align="left" style="font:Arial; font-size:12px;"><b>Uploaded By</b></td>
	<td align="left" style="font:Arial; font-size:12px;"><b>Upload Date</b></td>
	<td align="left" style="font:Arial; font-size:12px;"><b>Action</b></td>
 </tr>
 <cfif getFiles.RecordCount lt 1>
  <tr>
   <td colspan='4' style="padding-left:5px">No Files have been Uploaded</td>
  </tr>
 </cfif>
 <cfoutput query="getFiles">
 <cfset RowBG = IIF(GetComm.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''")>
 <tr style="height:25px" <cfif getFiles.CurrentRow MOD 2 EQ 0> bgcolor="##FFFFFF" <cfelse>bgcolor="##e7e7e9"</cfif> class="#RowBG#">
  <td style="padding-left:5px; font:Arial; font-size:12px;"><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.Title#</a></td>
  <td style="font:Arial; font-size:12px;"><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.FileName#</a></td>
  <td style="font:Arial; font-size:12px;">#getFiles.Last_Name#, #getFiles.First_Name#</td>
  <td style='font:Arial; font-size:12px;'>#DateFormat(getFiles.Created, 'mm/dd/yyyy')#</td>
  <td style='font:Arial; font-size:12px;'>
	 <a href='##' onclick="javascript:if(confirm('Are you sure you want to DELETE this file?')) { window.location.replace('/patientadmin_new/index.cfm?page=patient&ID=#getFiles.PatientId#&cat=patient_chart&df=#getFiles.id#'); }">Delete</a>
	</td>
 </tr>
 </cfoutput>
</table>
    </td>
</tr>
</table>

<div onclick="NonAnchorTag('communicationspanid','communicationid','','')" style="margin: 10px 10px; padding: 4px 0px 4px 10px; font-size: 14px; font-weight: bold;text-align: left; cursor: pointer; background-color:#e7e7e9; height:15px">
	<div style="float:left;width:55%; font-size: 14px; font-weight: bold;">
		<span id="communicationspanid">+</span>&nbsp;&nbsp;Communication
	</div>
</div>
<table align="center" width="100%" style="display: none;" id='communicationid'>

	<tr>
	<td align="right" width="98%" style="padding-right:10px;">
	 <span class='raquo'>&raquo;</span> <a href='/agencyadmin/index.cfm?page=agency&cat=Communication&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>&rpt=New_Commwizard&ID=0'>New Communication</a>

<!--- To Do: add ability to Un-Archive Comms...
	  &nbsp;&nbsp;
	 <span class='raquo'>&raquo;</span> <a href='/patientadmin_new/index.cfm?page=patient&cat=patient_chart&archived=y'>Archived Communications</a>
--->
	 <span class='raquo'>&raquo;</span>&nbsp;<img src="../../images/printer.gif" style="vertical-align:middle" />&nbsp;<a href="javascript:void(0);" onclick="javascript:clickwin=window.open('/patientadmin_new/index.cfm?page=patient&cat=printcommunicationhistory&patient_id=<cfif #patientid#eq ''><cfoutput>#session.cs.patientid#</cfoutput><cfelse><cfoutput>#patientid#</cfoutput></cfif>')">Print Communication Report</a>
	 </td>
 </tr>

<tr>
	<td>

<table cellpadding="0" cellspacing="0" class="list-border" width="98%" align="center" style="border:solid 1px green;">
 <tr style="height:30px; background-image:url(../../images/grid_tab.gif)" class='list-hdr' >
	<td align="left" style="padding-left:5px; font:Arial; font-size:12px;">Date</td>
	<td align="left" style="font:Arial; font-size:12px;">Subject</td>
	<td align="left" style="font:Arial; font-size:12px;" >Resolved</td>
	<td align="left" style="font:Arial; font-size:12px;" >Action</td>
 </tr>
 <cfif GetComm.RecordCount lt 1>
  <tr>
   <td colspan='4' style="padding-left:5px">No Communications were found</td>
  </tr>
 </cfif>
 <cfoutput query="GetComm">
 <cfset RowBG = IIF(GetComm.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''")>
 <tr style="height:25px" <cfif GetComm.CurrentRow MOD 2 EQ 0> bgcolor="##FFFFFF" <cfelse>bgcolor="##e7e7e9"</cfif> id='commTR#GetComm.Comm_ID#' class="#RowBG#">
	<td nowrap style="padding-left:5px; font:Arial; font-size:12px;">#DateFormat(Comm_Date,"mm/dd/yyyy")#</td>
	<td style="font:Arial; font-size:12px;">#Subject#</td>
	<td style='font:Arial; font-size:12px;'>
   <a href='../agencyadmin/index.cfm?page=agency&cat=Communication&rpt=communication_view&ID=#GetComm.Comm_ID#&res=No&patient_id=#GetP.Patient_ID#'>#Resolved#</a>
	</td>
	<td style='font:Arial; font-size:12px;'>
	 <a href='index.cfm?page=patient&cat=communication_print&ID=#GetComm.Comm_ID#' target='p'>Print</a>
	  |
	 <a href='javascript:void(0);' onclick="javascript: delComm('#GetComm.Comm_Id#', 'commTR#GetComm.Comm_Id#');">Archive</a>
  </td>
 </tr>
 </cfoutput>
</table>

	</td>
</tr>
</table>

 <script>
  function delComm(id, trId) {
   if(confirm('Are you sure you want to Archive this Communication?')) {
	var msg = ajaxURL('/patientadmin_new/ajax-patient-functions.cfm?p=ArchiveComm&id='+id);
    if(document.all) {
	 document.getElementById(trId).style.display = 'none';
	} else {
	 document.getElementById(trId).innerHTML = "<td colspan='4' align='center' style='background:#fafafa; color:#f00;'>This Communication has been Archived</td>";
	}
   }
  }
 </script>
 

<div onclick="NonAnchorTag('IncidenceSpanid','Incidenceid','','')" style="margin: 10px 10px; padding: 4px 0px 4px 10px; font-size: 14px; font-weight: bold;text-align: left; cursor: pointer; background-color:#e7e7e9; height:15px">
	<div style="float:left;width:55%; font-size: 14px; font-weight: bold;">
		<span id="IncidenceSpanid">+</span>&nbsp;&nbsp;Incidences
	</div>
</div>
<table align="center" width="100%" style="display: none;" id='Incidenceid'>
  <tr>
	<td align="right" width="98%" style="padding-right:10px;">
	 <span class='raquo'>&raquo;</span> 
<!---	 <a href='/agencyadmin/index.cfm?page=agency&cat=AgencyManagement&rpt=event_log&res=No'>New Incidences</a>--->
	 <a href='/agencyadmin/index.cfm?page=agency&cat=Event&rpt=patient_NewIncidenceWizard&ID=0&res=No&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>'>New Incidences</a>
	
	 <span class='raquo' style='padding-left:25px;'>&raquo;</span> 
	 &nbsp;<img src="../../images/printer.gif" style="vertical-align:middle" />&nbsp;
    <a target="_blank" href="patient/Event_form_Print.cfm?ID=0&res=No&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>&patientname=<cfoutput>#getP.First_Name# #getP.Last_Name#</cfoutput>">Print Incidences Report</a>
	</td>
 </tr>
<tr>
	<td>

<table cellpadding="0" cellspacing="0" width="98%" align="center" style="border:solid 1px green;">
 <tr style="height:30px; background-image:url(../../images/grid_tab.gif)" class='list-hdr' >
			<td align="left" style="padding-left:5px; font:Arial; font-size:12px;"><b>Date</b></td>
			<td align="left" style="font:Arial; font-size:12px;"><b>Patient</b></td>
			<td align="left" style="font:Arial; font-size:12px;"><b>Employee</b></td>
			<td align="left" style="font:Arial; font-size:12px;"><b>Subject</b></td>
	</tr>
		<cfif getEvent.RecordCount lt 1>
		  <tr>
		   <td colspan='4' style="padding-left:5px">No Incidences were found</td>
		  </tr>
    </cfif>
<cfoutput query="getEvent" >
		<tr style="height:25px" <cfif getEvent.CurrentRow MOD 2 EQ 0> bgcolor="##FFFFFF" <cfelse>bgcolor="##e7e7e9"</cfif> class="trhighlight" >
			<td style="padding-left:5px; font:Arial; font-size:12px;">#DateFormat(GetEvent.Event_Date,"mm/dd/yyyy")#</td>
			<td style="font:Arial; font-size:12px;"  nowrap>#GetEvent.Last_Name_M0040#</td>
			<td style="font:Arial; font-size:12px;"  nowrap>#GetEvent.Last_Name#</td>
			<td style="font:Arial; font-size:12px;">#Subject#</td>
		</tr>
</cfoutput>
</table>

	</td>
</tr>
</table>

</cfif>

