<!---
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/datafiles/" />
 
<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
   ) 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#'
   )
  </cfquery>
 </cfif>
 <cffile action="delete" file="#filepath##File.ServerFile#">
 <cflocation url='/patientadmin_new/index.cfm?page=patient&ID=#GetP.Patient_Id#&cat=Patient&view=month' 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>


<!--- Get Assessments --->
<cfquery  name="GetA" datasource="#Application.DataSrc#">
	SELECT Assessment_Id, Start_of_Care_M0030, Admission_Status, Transmission_Status, Assessment_Reason_M0100
	      ,Assessment_Completed_M0090, Certification_Start, Certification_End, Assessment_Tracker_Id,Assessment_Number
	FROM   #Request.prefix_db_agency#.Assessment_New
	WHERE  Patient_ID = '#session.cs.patientid#'
	AND    Deleted <> 1
    AND    Archive <> 1
	<cfif Session.EmpLevel eq 6 or Session.EmpLevel eq 8>
			AND   
			(
				
				'#session.EmployeeId#' 
				IN 
				(
					select distinct employee_id from #Request.prefix_db_agency#.ScheduleItems where patient_id = Assessment_New.Patient_Id and deleted <> 1
				)
			)
	</cfif>

	Order By Start_of_Care_M0030 Desc, Assessment_Completed_M0090 Desc, Assessment_Reason_M0100 ASC
</cfquery>

<!--- Get Forms --->
<cfquery  name="GetF" datasource="#Application.DataSrc#">
	SELECT Assessment_Forms.Assessment_Forms_ID, Assessment_Forms.Patient_ID, Assessment_Forms.Cert_start_Item_3a AS Cert_Start
	      ,Assessment_Forms.Cert_End_Item_3b AS Cert_End, Assessment_Forms.Form_Type, Assessment_Forms.Form_Status, Assessment_Forms.Record_Modified_by 
	      ,Assessment_Forms.Record_Creation_Date, Assessment_Forms.Digital_Signature, Assessment_Forms.Addendum_Details_21, Assessment_New.Assessment_Reason_M0100
	FROM  #Request.prefix_db_agency#.Assessment_Forms, #Request.prefix_db_agency#.Assessment_New
	WHERE Assessment_Forms.Patient_Id = #session.cs.patientid#
	And   Assessment_Forms.Form_Status <> 'Delete'
	And   Assessment_Forms.Form_Type like '%Form%'
	And   Assessment_New.Assessment_Tracker_Id = Assessment_Forms.Assessment_Tracker_Id
	And   Assessment_New.Deleted <> 1
	And   Assessment_New.Archive <> 1
	<cfif Session.EmpLevel eq 6 or Session.EmpLevel eq 8>
		AND   
			(
				
				'#session.EmployeeId#' 
				IN 
				(
					select distinct employee_id from #Request.prefix_db_agency#.ScheduleItems where patient_id = Assessment_New.Patient_Id and deleted <> 1
				)
			)
	</cfif>

	Order By Cert_Start Desc
</cfquery>


<!--- Get Visits --->
<cfquery  name="GetV" datasource="#Application.DataSrc#">
	SELECT ScheduleItems.Visit_Date, ScheduleItems.Visit_Type, ScheduleItems.Progress_Note, ScheduleItems.EClaimed, 
	       ScheduleItems.QB_Export, ScheduleItems.ScheduleItems_ID, ScheduleItems.Total_Units, ScheduleItems.Patient_ID,
	       Assessment_New.Assessment_Id, Assessment_New.Assessment_Reason_M0100, Assessment_New.Certification_Start, Assessment_New.Certification_End
	FROM #Request.prefix_db_agency#.ScheduleItems, #Request.prefix_db_agency#.Assessment_New
	WHERE  ScheduleItems.Patient_ID = '#session.cs.patientid#'
	AND    ScheduleItems.Deleted <> 1
	AND    ScheduleItems.Agency_ID = #session.AgencyID#
	AND    Assessment_New.Assessment_Tracker_ID = ScheduleItems.Assessment_Tracker_ID
	AND    Assessment_New.Deleted <> 1
	AND    Assessment_New.Archive <> 1
	<cfif Session.EmpLevel eq 6 or Session.EmpLevel eq 8>
		AND   
			(
				
				'#session.EmployeeId#' 
				IN 
				(
					select distinct employee_id from #Request.prefix_db_agency#.ScheduleItems where patient_id = Assessment_New.Patient_Id and deleted <> 1
				)
			)
	</cfif>

	Order By Visit_Date DESC, ScheduleItems.ScheduleItems_Id DESC, Assessment_Reason_M0100
</cfquery>

 <!---Account History--->




<!--- End page specific code --->


<cfinclude template="PatientMenu.cfc">

<table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
        <td valign="bottom" align="left">
            <cfscript>
            pm = CreateObject("Component", "PatientMenu");
            pm.getPatientMenu(#getP.Patient_Id#);
            </cfscript>
        </td>
    </tr> 
</table> 
 

<div class="portlet box blue">
	<div class="portlet-title">
		<div class="caption">
			<i class="fa fa-gear"></i> <cfoutput>#getP.Last_Name#, #getP.First_Name# #getP.Middle# - Chart Review</cfoutput>
		</div>
		<div class="actions">
			<a title="" data-original-title="" href="javascript:;" class="btn btn-icon-only btn-default btn-sm fullscreen">
			</a>
		</div>
	</div>
    <div class="portlet-body">
        
    <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' class="portlet box blue" style='display:none;'>
        <div class="portlet-title">
            <div class="caption">
                <i class="fa fa-gear"></i> Patient Document Upload...
            </div>
            <div class="tools">
                <a href="javascript:;" class="collapse">
                </a>
            </div>
        </div>
        <div id='tuf2Div' class="portlet-body form" style='display:none;'>
			<cfif session.PatientFileManagerInUse eq 0>
                <div class="form-body">
                    <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>
                </div>
            <cfelse>
            	<form class="form-horizontal form-bordered" 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='' />
                    <div class="form-body">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">File to Upload :</label>
                            <div class="col-sm-4">
                                <div class="input-group">
                                	<input name='ufFile' type='file' />
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">Title for File :</label>
                            <div class="col-sm-4">
                                <div class="input-group"><input name='ufTitle' type='text' class="form-control tt-input" /></div>
                            </div>
                        </div>
                    </div>
                    <div id='tdSubmit' class="form-actions">
                    	<div class="row">
                        	<div class="col-md-offset-3 col-md-9">
                                <input type='submit' class="btn blue" value='Upload File' />
                                <a class="btn default" href='#' onclick='javascript:tuf();'>Cancel</a>
                        	</div>
                        </div>
                    </div>
                </form>
            </cfif>
        </div>
    </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 class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i> Patient Files
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions margin-right-10">
                        <cfif session.eaClientEdit eq 1>	
                            <a class="btn btn-default btn-sm" href='#' onclick='javascript:tuf();'><i class="fa fa-plus"></i> Upload a Patient File</a>
                        </cfif>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll"> 
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Title</th>
                                <th>File Name</th>
                                <th>Uploaded By</th>
                                <th>Upload Date</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <cfif getFiles.RecordCount lt 1>
                                <tr>
                                    <td colspan='5' 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>
                                    <td><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.Title#</a></td>
                                    <td><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.FileName#</a></td>
                                    <td>#getFiles.Last_Name#, #getFiles.First_Name#</td>
                                    <td>#DateFormat(getFiles.Created, 'mm/dd/yyyy')#</td>
                                    <td>
                                        <cfif session.eaClientEdit eq 1>	
                                            <a class="btn btn-sm red" 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#'); }"><i class="fa fa-trash-o"></i> Delete</a>
                                        </cfif>
                                    </td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>
                </div>
            </div>        
        </cfif>
    
		<cfif  Communication EQ 1>
         	<div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Communication
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <cfif session.eaClientEdit eq 1>	
                        	<a class="btn btn-default btn-sm margin-right-10" href='/agencyadmin/index.cfm?page=agency&cat=Communication&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>&rpt=communication_form&ID=0'><i class="fa fa-plus"></i> New Communication</a>
                        </cfif>
                        <a class="btn btn-default btn-sm margin-right-10" 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>')"><i class="fa fa-print"></i> Print Communication Report</a>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">                    
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                    	<thead class="flip-content">
                            <tr>
                                <th>Date</th>
                                <th>Subject</th>
                                <th>Resolved</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
							<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 id='commTR#GetComm.Comm_ID#'>
                                    <td>#DateFormat(Comm_Date,"mm/dd/yyyy")#</td>
                                    <td>#Subject#</td>
                                    <td>
										<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>
                                        <a class="btn btn-sm blue btn-sm margin-right-10" href='index.cfm?page=patient&cat=communication_print&ID=#GetComm.Comm_ID#' target='p'><i class="fa fa-print"></i> Print</a>
                                        <a class="btn btn-sm green" href='javascript:void(0);' onclick="javascript: delComm('#GetComm.Comm_Id#', 'commTR#GetComm.Comm_Id#');"><i class="fa fa-file-archive-o"></i> Archive</a>
                                    </td>
                                </tr>
                            </cfoutput>
                    	</tbody>
                    </table>
				</div>
            </div>                    
            <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 class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Incidences
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <cfif session.eaClientEdit eq 1>	
                            <a class="btn btn-default btn-sm margin-right-10" href='/agencyadmin/index.cfm?page=agency&cat=Event&rpt=Event_form&ID=0&res=No&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>'><i class="fa fa-plus"></i> New Incidences</a>
                        </cfif>
                        <a class="btn btn-default btn-sm margin-right-10" 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>"><i class="fa fa-print"></i> Print Incidences Report</a>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                    	<thead class="flip-content">
                            <tr>
                                <th>Date</th>
                                <th>Patient</th>
                                <th>Employee</th>
                                <th>Subject</th>
                            </tr>
                        </thead>
                        <tbody>
							<cfif getEvent.RecordCount lt 1>
                                <tr>
                                    <td colspan='4' style="padding-left:5px">No Incidences were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="getEvent" >
                                <tr>
                                    <td>#DateFormat(GetEvent.Event_Date,"mm/dd/yyyy")#</td>
                                    <td>#GetEvent.Last_Name_M0040#</td>
                                    <td>#GetEvent.Last_Name#</td>
                                    <td>#Subject#</td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>
				</div>
        	</div>
        </cfif>
    
		<cfif  Assessment EQ 1>  
        	<div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Assessments
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions margin-right-10">
                        <cfif session.eaClientEdit eq 1>	
                            <a class="btn btn-default btn-sm" href='/patientadmin_new/index.cfm?a=1&page=patient&cat=assessment_form&na=y'><i class="fa fa-plus"></i> New Assessment</a>
                        </cfif>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Start of Care</th>
                                <th>Completed</th>
                                <th>Reason</th>
                                <th>Cert Start</th>
                                <th>Cert End</th>
                                <th>Status</th>
                                <th>Transmitted</th>
                                <th>Careplan</th>
                            </tr>
                        </thead>
                        <tbody>
							<cfif GetA.RecordCount lt 1>
                                <tr>
                                	<td colspan='7' style="padding-left:5px">No Assessments were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="GetA">
								<cfset RowBG = IIF(GetA.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''") />
                                <cfset thereason = Assessment_Reason_M0100 />
                                <cfif LEFT(thereason,1) eq '1'>
                                	<cfset thereason = '1 - Start of Care' />
                                <cfelseif LEFT(thereason,1) eq '3'>
                                	<cfset thereason = '3 - Resumption of Care' />
                                <cfelseif LEFT(thereason,1) eq '4'>
                                	<cfset thereason = '4 - Recertification' />
                                <cfelseif LEFT(thereason,1) eq '5'>
                                	<cfset thereason = '5 - Other Follow Up' />
                                <cfelseif LEFT(thereason,1) eq '6'>
                                	<cfset thereason = '6 - Transferred to Inpatient Facility' />
                                <cfelseif LEFT(thereason,1) eq '7'>
                                	<cfset thereason = '7 - Transfer with Discharge' />
                                <cfelseif LEFT(thereason,1) eq '8'>
                                	<cfset thereason = '8 - Death' />
                                <cfelseif LEFT(thereason,1) eq '9'>
                                	<cfset thereason = '9 - Discharge' />
                                </cfif>
                                <cfset thereason=#rereplacenocase(thereason,"recertification","Recertification","ALL")# />
                                <tr>
                                    <td>#DateFormat(Start_of_Care_M0030,"mm/dd/yyyy")#</td>
                                    <td>#DateFormat(Assessment_Completed_M0090,"mm/dd/yyyy")#</td>
                                    <td>
										<cfif session.eaClientEdit eq 1>	
                                        	<a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=assessment_form&AID=#assessment_id#&ATID=#assessment_tracker_ID#&rtn=#url.cat#&type=#thereason#')">
                                        	#thereason#</a>
                                        <cfelse>
                                        	#thereason#	
                                        </cfif>                                    
                                    </td>
                                    <td>#DateFormat(Certification_Start,"mm/dd/yyyy")#</td>
                                    <td>#DateFormat(Certification_End,"mm/dd/yyyy")#</td>
                                    <td><cfif Admission_Status IS "complete"><font color="##009900">Complete</font> <cfelse><font color="##FF0000">#admission_status#</font></cfif></b></td>
                                    <td>#Transmission_Status#</td>
                                    <td>
                                        <a class="btn btn-sm blue" href='javascript:void(0);' onclick="javascript: secureHREF('index.cfm?page=patient&cat=careplan&AID=#assessment_id#&ATID=#assessment_tracker_ID#&AN=#URLEncodedFormat(Assessment_Number)#&PID=#session.cs.patientid#');">
											<cfif session.eaClientEdit eq 1>	
                                            	<i class="fa fa-pencil"></i> Edit
                                            <cfelse>
                                            	<i class="fa fa-eye"></i> View
                                            </cfif>
                                        </a>
                                    </td>
                                </tr>
                            </cfoutput>
                    	</tbody>
                    </table>
				</div>
        	</div>                    
  		</cfif>
    
    
        <cfquery name="PatientLevel4" datasource="#Application.DataSrc#">
            SELECT MenuLevel4Id,MenuNames,DefaultPageUrl FROM #Request.prefix_db_lookup#.homecare_menulevel4 where parentid = 15
            <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 Orders = "0" />
        <cfset Careplan = "0" />
        <cfset Visits = "0" />
        <cfset Datasets = "0" />
    
        <cfloop query="PatientLevel4">        
			<cfif  PatientLevel4.MenuNames EQ "Orders">
	            <cfset Orders="1" />
            </cfif>
            <cfif  PatientLevel4.MenuNames EQ "Careplan">
    	        <cfset Careplan="1" />
            </cfif>
            <cfif  PatientLevel4.MenuNames EQ "Visits">
        	    <cfset Visits="1" />
            </cfif>
            <cfif  PatientLevel4.MenuNames EQ "Datasets">
            	<cfset Datasets="1" />
            </cfif>        
        </cfloop> 
    
		<cfif Orders EQ 1>
			<div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Physician Orders
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions margin-right-10">
                        <cfif session.eaClientEdit eq 1>	
                        	<a class="btn btn-default btn-sm"  href='/patientadmin_new/index.cfm?page=patient&cat=add_487_patient'><i class="fa fa-plus"></i> New Order</a>
                        </cfif>
                        <cfif session.eaClientEdit eq 1>	
                        	<a class="btn btn-default btn-sm"  href='/patientadmin_new/index.cfm?page=patient&cat=add_485_patient'><i class="fa fa-plus"></i> New Form 485</a>
                        </cfif>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Added</th>
                                <th>Type</th>
                                <th>Assessment</th>
                                <th>Cert Start</th>
                                <th>Cert End</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
							<cfif GetF.RecordCount lt 1>
                                <tr>
                                    <td colspan='8' style="padding-left:5px">No Physician Orders were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="GetF">
                            	<cfset RowBG = IIF(GetF.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''") />
                                <tr>
                                    <td>
                                    	#DateFormat(Record_Creation_Date,"mm/dd/yyyy")#
                                    </td>
                                    <td>
										<cfif Form_Type IS "Form 487" >
											<cfif session.eaClientEdit eq 1>
                                                <a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=487_update&afid=#assessment_forms_id#')">
                                                	#Form_Type#
                                                </a>
                                            <cfelse>
                                            	#Form_Type#
                                            </cfif>                                        
                                        <cfelse>
											<cfif session.eaClientEdit eq 1>
                                                <a href="javascript:void(0);" onclick=
                                                "javascript:secureHREF('index.cfm?page=patient&cat=485_update&afid=#assessment_forms_id#&PID=#session.cs.patientid#')">
                                                	#Form_Type#
                                                </a>
                                                <cfelse>
                                                	#Form_Type#
                                            </cfif>	
                                        </cfif>
                                    </td>
                                    <cfset thereason = Assessment_Reason_M0100 />
                                    <cfif LEFT(thereason,1) eq '1'>
                                    	<cfset thereason = '1 - Start of Care' />
                                    <cfelseif LEFT(thereason,1) eq '4'>
                                    	<cfset thereason = '4 - Recertification' />
                                    </cfif>
                                    <td>#thereason#</td>
                                    <td>
                                    	#DateFormat(Cert_Start,"mm/dd/yy")#
                                    </td>
                                    <td>
                                    	#DateFormat(Cert_End,"mm/dd/yy")#
                                    </td>
                                    <td>
										<cfif Form_Type IS "Form 487">
                                            <a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=487_update&afid=#assessment_forms_id#')">
                                            	#Form_Status#
                                            </a> - #LEFT(Addendum_Details_21, 30)#...
                                        <cfelse>
                                        	<a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=485_update&afid=#assessment_forms_id#&PID=#session.cs.patientid#')">#Form_Status#</a>
                                        </cfif>
                                        <cfif Digital_Signature IS NOT ""><font size="1"><em><font color="##FF0000">digitally signed</font></em></font></cfif>
                                    </td>
                                    <td>
                                    	<cfif Form_Type IS "Form 487">
                                        	<a class="btn btn-sm blue" href='index.cfm?page=patient&cat=487_print&ID=#Assessment_Forms_ID#' target='p'><i class="fa fa-print"></i> Print</a>
                                        <cfelse>
                                        	<font size="1"><em>download to print</em></font>
                                        </cfif>
                                    </td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>        
				</div>
        	</div>
        </cfif>
    
		<cfif Visits EQ 1>
			<div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Visits
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <cfif session.eaClientEdit eq 1>
                        	<a class="btn btn-default btn-sm margin-right-10" href='/schedules/index.cfm?page=schedules&cat=&rpt=add_visit&pid=<cfoutput>#session.cs.patientid#</cfoutput>'><i class="fa fa-plus"></i> New Visit</a>
                            <a class="btn btn-default btn-sm margin-right-10" href="../../schedules/index.cfm?page=schedules&cat=&rpt=add_schedule_Step2&ID=<cfoutput>#GetP.Patient_Id#</cfoutput>"><i class="fa fa-plus"></i> Add schedule</a>
                        </cfif>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">
                    <a name='VisitsAnchor'></a>
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Visit Date</th>
                                <th>Visit Type</th>
                                <th>Assessment</th>
                                <th>Cert Period</th>
                                <th>Billed?</th>
                                <th>Units</th>
                                <th>QB Export?</th>
                                <th>Note?</th>
                            </tr>
                        </thead>
                        <tbody>
							<cfif GetV.RecordCount lt 1>
                                <tr>
                                	<td colspan='8' style="padding-left:5px">No Visits were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="GetV">
								<cfset RowBG = IIF(GetV.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''") />
                                <tr>
									<cfset thereason=#rereplacenocase(Assessment_Reason_M0100,"start of care","SOC","ALL")# />
                                    <cfset thereason=#rereplacenocase(thereason,"recertification","Recert","ALL")# />
                                    <cfset thevisit=#rereplacenocase(Visit_type,"start of care","SOC","ALL")# />
                                    <cfset thevisit=#rereplacenocase(thevisit,"recertification","Recert","ALL")# />
                                    <td>
										<cfif session.eaClientEdit eq 1>
                                            <a href="index.cfm?page=patient&cat=patient_editVisit&id=#GetV.Patient_ID#&restrict=0&formonly=1&assid=#GetV.Assessment_Id#&sid=#GetV.scheduleitems_id#">
                                            	#DateFormat(Visit_Date,"mm/dd/yyyy")#
                                            </a>
                                        <cfelse>
                                        	#DateFormat(Visit_Date,"mm/dd/yyyy")#
                                        </cfif>
                                        <div id='edit_scheduleitems_#GetV.scheduleitems_id#_id' style="margin-left:30px; position:absolute; visibility:hidden; overflow:auto; border:2px solid black; background-color:##fdfdfd; border:1px solid black; padding:5px;"></div> 
                                    </td>
                                    <td>#thevisit#</td>
                                    <td>
                                    	#thereason#
                                    </td>
                                    <td>
                                    	#DateFormat(Certification_Start,"mm/dd/yy")# - #DateFormat(Certification_End,"mm/dd/yy")#
                                    </td>
                                    <td><cfif EClaimed IS '1' ><font color="##009900">yes</font><cfelse><font color="##FF0000">no</font></cfif></b></td>
                                    <td><cfif Total_Units IS '' ><font color="##FF0000">0</font><cfelse><font color="##009900">#Total_Units#</font></cfif></b></td>
                                    <td><cfif QB_Export gte 1 ><font color="##009900">yes</font><cfelse><font color="##FF0000">no</font></cfif></b></td>
                                    <td>
										<cfif 0>
                                        <cfif Progress_Note IS "yes"><cf_button v="notes"  root=#Navroot# l='index.cfm?page=reports&cat=schedules&rpt=progress_form_printer&scheduleitems_id=#getv.scheduleitems_id#' w=new><cfelse><font color="##FF0000">no</font></cfif></b>
                                        <cfelse>
                                        <cfif Progress_Note IS "yes"><cf_button v="notes"  root=".." l='index.cfm?page=patient&cat=ProgressNoteSNPDF&sid=#getv.scheduleitems_id#&assid=#GetV.Assessment_Id#' w=new><cfelse><font color="##FF0000">no</font></cfif></b>
                                        </cfif>
                                    </td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>                    
                </div>
			</div>
        </cfif>    
    </cfif>



<!--*********************************************************************************************************************************-->
<!--****************************************Agency Login**************************************************-->
<!--*********************************************************************************************************************************-->
		<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 class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Patient Files
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions margin-right-10">
                        <a class="btn btn-default btn-sm" href='#' onclick='javascript:tuf();'><i class="fa fa-cloud-upload"></i> Upload a Patient File</a>
                    </div>        
                </div> 
                <div class="portlet-body flip-scroll">
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Title</th>
                                <th>File Name</th>
                                <th>Uploaded By</th>
                                <th>Upload Date</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <cfif getFiles.RecordCount lt 1>
                                <tr>
                                    <td colspan='5' 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>
                                    <td><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.Title#</a></td>
                                    <td><a href='Patient-File-Viewer.cfm?id=#getFiles.id#' target='pfv'>#getFiles.FileName#</a></td>
                                    <td>#getFiles.Last_Name#, #getFiles.First_Name#</td>
                                    <td>#DateFormat(getFiles.Created, 'mm/dd/yyyy')#</td>
                                    <td>
                                        <a class="btn btn-sm red" 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#'); }"><i class="fa fa-trash-o"></i> Delete</a>
                                    </td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>
                </div>
            </div>
        
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Communication
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <a class="btn btn-default btn-sm margin-right-10" href='/agencyadmin/index.cfm?page=agency&cat=Communication&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>&rpt=communication_form&ID=0'><i class="fa fa-plus"></i> New Communication</a>
                        <a class="btn btn-default btn-sm margin-right-10" 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>')"><i class="fa fa-print"></i> Print Communication Report</a>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">        
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Date</th>
                                <th>Subject</th>
                                <th>Resolved</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <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 id='commTR#GetComm.Comm_ID#'>
                                    <td>#DateFormat(Comm_Date,"mm/dd/yyyy")#</td>
                                    <td>#Subject#</td>
                                    <td>
                                        <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>
                                        <a class="btn btn-sm blue" href='index.cfm?page=patient&cat=communication_print&ID=#GetComm.Comm_ID#' target='p'><i class="fa fa-print"></i> Print</a>
                                        <a class="btn btn-sm green" href='javascript:void(0);' onclick="javascript: delComm('#GetComm.Comm_Id#', 'commTR#GetComm.Comm_Id#');"><i class="fa fa-file-archive-o"></i> Archive</a>
                                    </td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>		
                </div>
            </div>
        
            <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 class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Incidences
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <a class="btn btn-default btn-sm margin-right-10" href='/agencyadmin/index.cfm?page=agency&cat=Event&rpt=Event_form&ID=0&res=No&patient_id=<cfoutput>#getP.Patient_Id#</cfoutput>'><i class="fa fa-plus"></i> New Incidences</a>
                        <a class="btn btn-default btn-sm margin-right-10" 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>"><i class="fa fa-print"></i> Print Incidences Report</a>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Date</th>
                                <th>Patient</th>
                                <th>Employee</th>
                                <th>Subject</th>
                            </tr>
                        </thead>
                        <tbody>
                            <cfif getEvent.RecordCount lt 1>
                                <tr>
                                    <td colspan='4' style="padding-left:5px">No Incidences were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="getEvent" >
                                <tr>
                                    <td>#DateFormat(GetEvent.Event_Date,"mm/dd/yyyy")#</td>
                                    <td>#GetEvent.Last_Name_M0040#</td>
                                    <td>#GetEvent.Last_Name#</td>
                                    <td>#Subject#</td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>
                </div>
            </div>
            
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Assessments
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions margin-right-10">
                        <a class="btn btn-default btn-sm" href='/patientadmin_new/index.cfm?a=1&page=patient&cat=assessment_form&na=y'><i class="fa fa-plus"></i> New Assessment</a>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Start of Care</th>
                                <th>Completed</th>
                                <th>Reason</th>
                                <th>Cert Start</th>
                                <th>Cert End</th>
                                <th>Status</th>
                                <th>Transmitted</th>
                            </tr>
                        </thead>
                        <tbody>
                            <cfif GetA.RecordCount lt 1>
                                <tr>
                                    <td colspan='6'>No Assessments were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="GetA">
                                <cfset RowBG = IIF(GetA.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''") />
                                <cfset thereason = Assessment_Reason_M0100 />
                                <cfif LEFT(thereason,1) eq '1'>
                                    <cfset thereason = '1 - Start of Care' />
                                <cfelseif LEFT(thereason,1) eq '3'>
                                    <cfset thereason = '3 - Resumption of Care' />
                                <cfelseif LEFT(thereason,1) eq '4'>
                                    <cfset thereason = '4 - Recertification' />
                                <cfelseif LEFT(thereason,1) eq '5'>
                                    <cfset thereason = '5 - Other Follow Up' />
                                <cfelseif LEFT(thereason,1) eq '6'>
                                    <cfset thereason = '6 - Transferred to Inpatient Facility' />
                                <cfelseif LEFT(thereason,1) eq '7'>
                                    <cfset thereason = '7 - Transfer with Discharge' />
                                <cfelseif LEFT(thereason,1) eq '8'>
                                    <cfset thereason = '8 - Death' />
                                <cfelseif LEFT(thereason,1) eq '9'>
                                    <cfset thereason = '9 - Discharge' />
                                </cfif>
                                <cfset thereason=#rereplacenocase(thereason,"recertification","Recertification","ALL")# />
                                <tr>
                                    <td>#DateFormat(Start_of_Care_M0030,"mm/dd/yyyy")#</td>
                                    <td>#DateFormat(Assessment_Completed_M0090,"mm/dd/yyyy")#</td>
                                    <td><a href="javascript:void(0);" onclick=	
                                    "javascript:secureHREF('index.cfm?page=patient&cat=assessment_form&AID=#assessment_id#&ATID=#assessment_tracker_ID#&rtn=#url.cat#&type=#thereason#')">
                                    #thereason#</a></td>
                                    <td>#DateFormat(Certification_Start,"mm/dd/yyyy")#</td>
                                    <td>#DateFormat(Certification_End,"mm/dd/yyyy")#</td>
                                    <td>
                                        <cfif Admission_Status IS "complete">
                                            <font color="##009900">Complete</font> <cfelse><font color="##FF0000">#admission_status#</font>
                                        </cfif></b></td>
                                    <td>#Transmission_Status#</td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>
                </div>
            </div>
            
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Physician Orders
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions">
                        <a class="btn btn-default btn-sm margin-right-10" href='/patientadmin_new/index.cfm?page=patient&cat=add_487_patient'><i class="fa fa-plus"></i> New Order</a>
                        <a class="btn btn-default btn-sm margin-right-10" href='/patientadmin_new/index.cfm?page=patient&cat=add_485_patient'><i class="fa fa-plus"></i> New Form 485</a>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Added</th>
                                <th>Type</th>
                                <th>Assessment</th>
                                <th>Cert Start</th>
                                <th>Cert End</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <cfif GetF.RecordCount lt 1>
                                <tr>
                                    <td colspan='8' style="font:Arial; font-size:12px; padding-left:5px">No Physician Orders were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="GetF">
                                <cfset RowBG = IIF(GetF.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''") />
                                <tr>
                                    <td>
                                        #DateFormat(Record_Creation_Date,"mm/dd/yyyy")#
                                    </td>
                                    <td>
                                        <cfif Form_Type IS "Form 487">
                                            <a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=487_update&afid=#assessment_forms_id#')">
                                                #Form_Type#
                                            </a>
                                        <cfelse>
                                            <a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=485_update&afid=#assessment_forms_id#&PID=#session.cs.patientid#')">
                                                #Form_Type#
                                            </a>
                                        </cfif>
                                    </td>
                                    <cfset thereason = Assessment_Reason_M0100 />
                                    <cfif LEFT(thereason,1) eq '1'>
                                        <cfset thereason = '1 - Start of Care' />
                                    <cfelseif LEFT(thereason,1) eq '4'>
                                        <cfset thereason = '4 - Recertification' />
                                    </cfif>
                                    <td>#thereason#</td>
                                    <td>
                                        #DateFormat(Cert_Start,"mm/dd/yy")#
                                    </td>
                                    <td>
                                        #DateFormat(Cert_End,"mm/dd/yy")#
                                    </td>
                                    <td>
                                        <cfif Form_Type IS "Form 487">
                                            <a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=487_update&afid=#assessment_forms_id#')">
                                            #Form_Status#
                                            </a> - #LEFT(Addendum_Details_21, 30)#...
                                        <cfelse>
                                            <a href="javascript:void(0);" onclick="javascript:secureHREF('index.cfm?page=patient&cat=485_update&afid=#assessment_forms_id#&PID=#session.cs.patientid#')">#Form_Status#</a>
                                        </cfif>
                                        <cfif Digital_Signature IS NOT ""><font size="1"><em><font color="##FF0000">digitally signed</font></em></font></cfif>
                                    </td>
                                    <td>
                                        <cfif Form_Type IS "Form 487">
                                        	<a class="btn btn-sm blue" href='index.cfm?page=patient&cat=487_print&ID=#Assessment_Forms_ID#' target='p'><i class="fa fa-print"></i> Print</a>
                                        <cfelse>
                                            <font size="1"><em>download to print</em></font>
                                        </cfif>
                                    </td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>
                </div>
            </div>
              
            <div class="portlet box blue">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gear"></i>Visits
                    </div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                    <div class="actions margin-right-10">
                        <a class="btn btn-default btn-sm" href="../../schedules/index.cfm?page=schedules&cat=&rpt=add_schedule_Step2&ID=<cfoutput>#GetP.Patient_Id#</cfoutput>"><i class="fa fa-plus"></i> Add Schedule</a>
                        <a class="btn btn-default btn-sm" href='/schedules/index.cfm?page=schedules&cat=&rpt=add_visit&pid=<cfoutput>#session.cs.patientid#</cfoutput>'><i class="fa fa-plus"></i> New Visit</a>
                    </div>        
                </div>
                <div class="portlet-body flip-scroll">    
                    <table class="table table-bordered table-striped table-condensed flip-content margin-top-15">
                        <thead class="flip-content">
                            <tr>
                                <th>Visit Date</th>
                                <th>Visit Type</b></th>
                                <th>Assessment</b></th>
                                <th>Cert Period</b></th>
                                <th>Billed?</b></th>
                                <th>Units</b></th>
                                <th>QB Export?</b></th>
                                <th>Note?</b></th>
                            </tr>
                        </thead>
                        <tbody>
                            <cfif GetV.RecordCount lt 1>
                                <tr>
                                    <td colspan='8'>No Visits were found</td>
                                </tr>
                            </cfif>
                            <cfoutput query="GetV">
                                <cfset RowBG = IIF(GetV.CurrentRow MOD 2 EQ 0, "'list-altrow'", "''") />
                                <tr>
                                    <cfset thereason=#rereplacenocase(Assessment_Reason_M0100,"start of care","SOC","ALL")# />
                                    <cfset thereason=#rereplacenocase(thereason,"recertification","Recert","ALL")# />
                                    <cfset thevisit=#rereplacenocase(Visit_type,"start of care","SOC","ALL")# />
                                    <cfset thevisit=#rereplacenocase(thevisit,"recertification","Recert","ALL")# />
                                    <td>                            
                                        <a href="index.cfm?page=patient&cat=patient_editVisit&id=#GetV.Patient_ID#&restrict=1&formonly=1&assid=#GetV.Assessment_Id#&sid=#GetV.scheduleitems_id#">
                                        #DateFormat(Visit_Date,"mm/dd/yyyy")#
                                        </a>
                                    <div id='edit_scheduleitems_#GetV.scheduleitems_id#_id' style="margin-left:30px; position:absolute; visibility:hidden; overflow:auto; border:2px solid black; background-color:##fdfdfd; border:1px solid black; padding:5px;"></div> 
                                    </td>
                                    <td>#thevisit#</td>
                                    <td>
                                        #thereason#
                                    </td>
                                    <td>
                                        #DateFormat(Certification_Start,"mm/dd/yy")# - #DateFormat(Certification_End,"mm/dd/yy")#
                                    </td>
                                    <td><cfif EClaimed IS '1' ><font color="##009900">yes</font><cfelse><font color="##FF0000">no</font></cfif></b></td>
                                    <td><cfif Total_Units IS '' ><font color="##FF0000">0</font><cfelse><font color="##009900">#Total_Units#</font></cfif></b></td>
                                    <td><cfif QB_Export gte 1 ><font color="##009900">yes</font><cfelse><font color="##FF0000">no</font></cfif></b></td>
                                    <td>
                                        <cfif 0>
                                        	<cfif Progress_Note IS "yes">
                                            	<cf_button v="notes"  root=#Navroot# l='index.cfm?page=reports&cat=schedules&rpt=progress_form_printer&scheduleitems_id=#getv.scheduleitems_id#' w=new>
                                            <cfelse>
                                            	<font color="##FF0000">no</font>
                                            </cfif>
                                        <cfelse>
                                        	<cfif Progress_Note IS "yes">
                                            	<cf_button v="notes"  root=".." l='index.cfm?page=patient&cat=ProgressNoteSNPDF&sid=#getv.scheduleitems_id#&assid=#GetV.Assessment_Id#' w=new>
                                            <cfelse>
                                            	<font color="##FF0000">no</font>
                                            </cfif>
                                        </cfif>
                                    </td>
                                </tr>
                            </cfoutput>
                        </tbody>
                    </table>	
                </div>
            </div>    
       
        </cfif>
	
    </div>
</div>