<!---
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.2 $
$Id: graphdetails.cfm,v 1.2 2009/06/02 19:44:21 arlen Exp $
$Date: 2009/06/02 19:44:21 $
--->

<!--- This code makes sure that the user has logged in, if not it will not allow them to access this page --->
<cflock scope="Session" type="ReadOnly" timeout="10" throwontimeout="no">
  <cfset MM_Username=Iif(IsDefined("Session.EmployeeID"),"Session.EmployeeID",DE("")) />
  <cfset MM_UserAuthorization=Iif(IsDefined("Session.MM_UserAuthorization"),"Session.MM_UserAuthorization",DE("")) />
</cflock>
<cfif MM_Username EQ "">
  <cfset MM_referer=CGI.SCRIPT_NAME />
  <cfif CGI.QUERY_STRING NEQ "">
    <cfset MM_referer=MM_referer & "?" & CGI.QUERY_STRING />
  </cfif>
  <cfset MM_failureURL="../login_denied.cfm?accessdenied=" & URLEncodedFormat(MM_referer) />
  <cflocation url="#MM_failureURL#" addtoken="no">
</cfif>
<cfparam name="url.display" default = "">
<cfset statuscolor=ArrayNew(1) />
<cfset statuscolor[1]='green' />
<cfset statuscolor[2]='yellow' />
<cfset statuscolor[3]='orange' />
<cfset statuscolor[4]='red' />
<cfset statuscolor[5]='purple' />

<cfif url.display eq 'diagnosis'>

    <cfset thedate=#ParseDateTime(url.d)# />
    <cfset thedate=#dateformat(thedate,'YYYY-MM-DD')# />
    <cfoutput>
    <cfquery name="GetPVD" datasource="#Application.DataSrc#">
      SELECT pvd.* ,'' AS Reading1, '' Reading2,IFNULL(pvd.severity,0) AS Sev
      FROM #Request.prefix_db_agency#.pProgress pvd
       LEFT OUTER JOIN #Request.prefix_db_agency#.pSchedules si ON pvd.Schedule_ID = si.Schedule_ID
      WHERE -- pvd.Schedule_ID = #url.p#  
       AND pvd.Description = '#url.t#' 
      AND pvd.status = 0
      AND si.Visit_Date = '#thedate#'
      GROUP BY pvd.Schedule_ID 
    </cfquery>
    </cfoutput>

    <cfoutput query="GetPVD">
    <cfset s=#Sev# + 1 />
    <div style="color:#statuscolor[s]#">
    <b><u>#ucase(Description)#</u></b><br>
    <Table width=300>
    <tr><td nowrap>Date:</td><td nowrap>#url.d#</tr>
    <tr><td nowrap>Severity:</td><td nowrap>#Sev#</tr>
    <tr><td valign=top>Notes:</td><td width=200>#Notes#</tr>
    </table>
    </div>
    </cfoutput>

<cfelse>
<cfset thedate=#ParseDateTime(url.d)# />
<cfset thedate=#dateformat(thedate,'YYYY-MM-DD')# />
<cfoutput>
<cfquery name="GetPVD" datasource="#Application.DataSrc#">
  SELECT pvd.* ,'' AS Reading1, '' Reading2,IFNULL(pvd.severity,0) AS Sev
  FROM #Request.prefix_db_agency#.pProgress pvd
   LEFT OUTER JOIN #Request.prefix_db_agency#.pSchedules si ON pvd.Schedule_ID = si.Schedule_ID
  WHERE pvd.Assmt_ID = #url.p#
  AND (pvd.Description = '#url.t#' OR pvd.Description = '###url.t#')
  AND pvd.status = 0
  AND si.Visit_Date = '#thedate#'
</cfquery>
</cfoutput>

<cfoutput query="GetPVD">
<cfset s= #Sev# + 1 />
<div style="color:#statuscolor[s]#">
<b><u>#ucase(Description)#</u></b><br>
<Table width=300>
<tr><td nowrap>Date:</td><td nowrap>#url.d#</tr>
<tr><td nowrap>Value_1:</td><td nowrap>#Value_1#</tr>
<tr><td nowrap>Reading 1:</td><td nowrap>#Reading1#</tr>
<tr><td nowrap>Reading 2:</td><td nowrap>#Reading2#</tr>
<tr><td valign=top>Notes:</td><td width=200>#Notes#</tr>
</table>
</div>
</cfoutput>

</cfif>
