<cfif Not isDefined('session.AgencyId') or session.AgencyId eq ''>
  <div style='margin:20px;'> Your session has Timed Out. <br/>
    <br/>
    Please <a href='/'>Sign In</a> again to continue. </div>
  <cfexit>
</cfif>



<cfparam name="url.download" default="0">
<cfset Request.prefix_db_lookup = 'hhapowerpath' />

<cfset Assessment_ID = #url.AID#  />
<cfquery name="new" datasource="#Application.DataSrc#">
     SELECT Assessment_Completed_M0090 FROM #Request.prefix_db_agency#.Assessment_New where Assessment_ID = '#Assessment_ID#'
</cfquery>
<cfquery name="Assessment_Details" datasource="#Application.DataSrc#">
SELECT *  	FROM #Request.prefix_db_agency#.Assessment_New
JOIN #Request.prefix_db_agency#.patient on patient.Patient_ID = Assessment_New.Patient_ID
WHERE Assessment_ID='#Assessment_ID#'
</cfquery>
<cfquery name="Rec_Vis" datasource="#Application.DataSrc#">
 SELECT * from #Request.prefix_db_agency#.Coding_Scrub c
 WHERE c.Assessment_ID = '#Assessment_ID#'
  AND  c.Patient_ID = '#ID#'
  and c.Message_ID = 120
 </cfquery>
 <cfquery name="Rec_Old_Vis" datasource="#Application.DataSrc#">
 SELECT * from #Request.prefix_db_agency#.Coding_Scrub c
 WHERE c.Assessment_ID = '#Assessment_ID#'
  AND  c.Patient_ID = '#ID#'
  and c.Message_ID = 121
 </cfquery>

<cfquery name="Nursing" datasource="#Application.DataSrc#">
 SELECT * from #Request.prefix_db_agency#.Coding_Scrub c
 WHERE c.Assessment_ID = '#Assessment_ID#'
  AND  c.Patient_ID = '#ID#'
  and c.Message_ID = 145
 </cfquery>
<cfquery name="Report_dtails" datasource="#Application.DataSrc#">
 SELECT Coding_Results.* from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
 <!---and Message_ID < 14--->
  AND  Coding_Results.Patient_ID = '#ID#'
 and Message_ID in (13, 15, 20) 
 order by Message_ID, M0_Item_Medication, Order_ID ASC
 </cfquery>
<cfquery name="Report_dtails2" datasource="#Application.DataSrc#">
 SELECT Coding_Results.* from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
 <!---and Message_ID < 14--->
  AND  Coding_Results.Patient_ID = '#ID#'
 and Message_ID in (1,2,3,4,5,6,7,8,9,10,11,12,16) 
 order by Message_ID, Order_ID ASC
 </cfquery>
 <cfquery name="Report_Scrub" datasource="#Application.DataSrc#">
 SELECT Coding_Scrub.* from #Request.prefix_db_agency#.Coding_Scrub
 WHERE Coding_Scrub.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Scrub.Patient_ID = '#ID#'
  and Message_ID NOT IN ('120', '130', '135', '140', '145')
  order by Scrub_ID ASC
 </cfquery>
<cfquery name="mistakes" datasource="#Application.DataSrc#">
 SELECT Message_ID, count(*) AS count 
 from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and Message_ID in (20)
 and Order_ID !=''
 </cfquery>
<cfquery name="inconsistent1" datasource="#Application.DataSrc#">
 SELECT Message_ID, count(*) AS count 
 from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and Message_ID in (15)
 and Order_ID !=''
  </cfquery>
<cfquery name="inconsistent2" datasource="#Application.DataSrc#">
 SELECT Message_ID, count(*) AS count 
 from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and Message_ID in (14)
 and M0_Item_Medication like '%(M1%'
 and Order_ID !=''
  </cfquery>
<cfquery name="missed" datasource="#Application.DataSrc#">
 SELECT *
 from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and Message_ID < 13
 and (M0_Item_Medication = 'medication' or M0_Item_Medication = 'OASIS' or M0_Item_Medication = 'scrub')
 and (OASIS like '%unstable%' or '%OASIS YES%')
 order by Message_ID ASC
  </cfquery>
<cfquery name="Get_14" datasource="#Application.DataSrc#">
 SELECT Message_ID, OASIS, count(*) AS count 
 from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and Message_ID in (35,36,37,38,39)
 </cfquery>
<cfquery name="coding_score" datasource="#Application.DataSrc#">
 SELECT Coding_Results.* from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and (Message_ID = 0)
 </cfquery>
<cfquery name="CM_score" datasource="#Application.DataSrc#">
 SELECT Coding_Results.* from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and (Message_ID = 21)
 </cfquery>
<cfquery name="Get_wizard" datasource="#Application.DataSrc#">
 SELECT Coding_Results.* from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
 AND  Coding_Results.Patient_ID = '#ID#'
 and Deficits like ('%move to%')
 order by Deficits ASC
 </cfquery>
<cfquery name="Get_orig" datasource="#Application.DataSrc#">
 SELECT Coding_Results.* from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and M0_Item_Medication like '%(M1%'
 order by DX_Order ASC
 </cfquery>
 <cfquery name="Get_Not" datasource="#Application.DataSrc#">
 SELECT Coding_Results.* from #Request.prefix_db_agency#.Coding_Results
 WHERE Coding_Results.Assessment_ID = '#Assessment_ID#'
  AND  Coding_Results.Patient_ID = '#ID#'
 and Created_By like '%not%'
 </cfquery>

<cfset coding_score = coding_score.OASIS>
<cfset HIPPS = #Rec_Vis.Field_2#>
<cfset Level = #Rec_Vis.Answer_2#>

<cfif Get_Not.Created_By contains 'not'>
<cfset problem = 'yes'>
<cfelse>
<cfset problem = 'no'>
</cfif>
<cfset money = CM_score.Casemix>
<cfset Rec_Reason = #Rec_Vis.Answer_1#>
<cfset Rec_Therapy = #Rec_Vis.Field_5#>
<cfset Cur_Therapy = #Rec_Old_Vis.Answer_2#>
<cfset CaseMix = #Rec_Vis.Subject#>
<cfset Reimburse = #Rec_Vis.Field_8#>
<cfset Profit = #Rec_Vis.Field_10#>
<cfset userCM = CM_score.OASIS>
<cfset wizardCM = CM_score.Medications>
<cfset mistakes = mistakes.count>
<cfset inconsistent = inconsistent1.count + inconsistent2.count>
<cfif Get_14.count gte 1>
  <cfset therapy_message = Get_14.OASIS>
</cfif>
<cfset Assessment_Reason_M0100 = Assessment_Details.Assessment_Reason_M0100 />
<cfset Admission_Status = Assessment_Details.Admission_Status />
<cfset thereason = Assessment_Reason_M0100 />
<cfif LEFT(thereason,1) eq '1'>
  <cfset thereason = 'Start of Care' />
  <cfelseif LEFT(thereason,1) eq '3'>
  <cfset thereason = 'Resumption of Care' />
  <cfelseif LEFT(thereason,1) eq '4'>
  <cfset thereason = 'Recertification' />
  <cfelseif LEFT(thereason,1) eq '5'>
  <cfset thereason = 'Other Follow Up' />
</cfif>
<cfset thereason=#rereplacenocase(thereason,"recertification","Recertification","ALL")# />

<cfif url.download eq 1>
<CFSET Patient_LName = #replacenocase(Assessment_Details.Last_Name_M0040,",","","all")#>
<cfset agency_name = rereplace(Session.AgencyName,"[^A-Za-z0-9]","","all") />
<cfset coding_reports= #agency_name#&"_"&#Trim(Patient_LName)#&"_"&#DateFormat(now(),'yyyymmdd')#&"_coding_report.pdf" />

<cfheader name="Content-Disposition" value="attachment;filename=#coding_reports#">
<cfcontent  <!---file="#teachplan#"--->  type="application/pdf"> 
</cfif>


<!---<cfif CGI.REMOTE_ADDR eq '103.66.78.232'>
<cfabort>
</cfif>--->




<cfdocument format="pdf" orientation="portrait" overwrite="yes">
<cfdocumentsection>
  <cfdocumentitem type="header"  evalatprint="true">
  <cfif (cfdocument.currentpagenumber neq 1) is 0>
    <cfelse>
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
      <tr>
        <td height="30px"></td>
      </tr>
      <tr>
        <td style="padding-left:10px; font-family: Arial; font-size: 18px; font-weight: bold;font-style: italic;"><cfoutput>#Assessment_Details.First_Name_M0040# #Assessment_Details.Last_Name_M0040#</cfoutput>
      <tr>
        <td height="30px"></td>
      </tr>
      </td>
      
      </tr>
      
    </table>
  </cfif>
  </cfdocumentitem>
  <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td valign="top" style="padding-top:10px;height:80px;"><table cellpadding="0" cellspacing="0" border="0" width="100%">
          <tr>
            <td align="left" width="50%"><table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                  <td style="padding-left:10px; font-family: Arial; font-size: 23px; font-weight: bold;font-style: italic;"><cfoutput>#Assessment_Details.First_Name_M0040# #Assessment_Details.Last_Name_M0040#</cfoutput></td>
                </tr>
                <tr>
                  <td height="5px"></td>
                </tr>
                <tr>
                  <td style="padding-left:60px; font-family: Arial; font-size: 23px; font-weight: bold;font-style: italic;"> Coding Wizard </td>
                </tr>
              </table></td>
            <td align="right" width="50%"><table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                  <td align="right" style="font-family: Arial;font-size: 12px; font-weight: bold; font-style: italic;"> Assessment </td>
                  <td style="font-family: Verdana;font-size: 12px;"><cfoutput>#Assessment_Details.Assessment_Reason_M0100#</cfoutput></td>
                </tr>
                <tr>
                  <td height="3px"></td>
                </tr>
                <tr>
                  <td align="right" style="font-family: Arial;font-size: 12px; font-weight: bold; font-style: italic;"> SOC Date </td>
                  <td style="font-family: Verdana;font-size: 12px;"><cfoutput>#DateFormat(Assessment_Details.Start_of_Care_M0030, "mm/dd/yyyy")#</cfoutput></td>
                </tr>
                <tr>
                  <td height="3px"></td>
                </tr>
                <tr>
                  <td align="right" style="font-family: Arial; font-size: 12px;font-weight: bold; font-style: italic"> Certification </td>
                  <td style="font-family: Verdana; font-size: 12px;"><cfoutput>#DateFormat(Assessment_Details.Certification_Start, "mm/dd/yyyy")#</cfoutput> <b><i><font  style="font-family: Arial; font-size: 12px;font-weight: bold; font-style: italic">to</font></i></b> <cfoutput>#DateFormat(Assessment_Details.Certification_End, "mm/dd/yyyy")#</cfoutput></td>
                </tr>
              </table></td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td height="10px"></td>
    </tr>
    <tr>
      <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
          <tr>
            <td height="1px"></td>
          </tr>
          <cfif Get_orig.Recordcount gt 0>
            <tr>
              <td valign="top" style="color:red; font-weight:bold;" >USER-ENTERED ICD/WIZARD H&amp;P REVIEW</td>
            </tr>
                       <tr>
            <td height="5px"></td>
          </tr>

            <cfoutput query="Get_orig">
              <tr>
                <td valign="top" ><b>
                  <cfif M0_Item_Medication contains 'M1021'>
                    (M1021)
                    <cfelse>
                    (M1023)
                  </cfif>
                  </b>&nbsp;#Diagnosis#</td>
                <td ><b>
                  <cfif Created_by contains 'NOT'>
                    <font color="##FF0000">problem**</font>
                    <cfelse>
                    <font color="##0000FF">Verified!</font>
                  </cfif>
                  </b></td>
              </tr>
            </cfoutput><cfif problem eq 'yes'>
                                  <tr>
            <td height="7px"></td>
          </tr>

            <tr>
              <td><i>**See INCONSISTENCIES below.</i></td>
            </tr>
            <cfelse>&nbsp;</cfif>
            <cfelse>
            <tr>
              <td valign="top"> No coding results are available.</td>
            </tr>
          </cfif>
          <tr> 
                        <td>&nbsp;<!---<cfif Get_orig.Created_by contains 'not'><i>*Diagnosis unsupported by treatment orders and/or OASIS assessment. See below.</i></cfif>---></td>

          <!---<td valign="top" style="height:10px;"></td>--->
        </table>
    </tr>
  </table>
 <tr>
    <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
        <tr>
          <td height="2px"></td>
        </tr>
        <tr>
          <td valign="top" style="color:red; font-weight:bold;" >OASIS-D THERAPY ANALYSIS</td>
        </tr>
                               <tr>
            <td height="5px"></td>
          </tr>
        <cfoutput>
          <tr>
              <td>  Current Therapy Ordered:&nbsp;<font color="##0000FF"><b>#Cur_Therapy#&nbsp;visits</b></font> <br />              
               Recommended Therapy:&nbsp;<font color="##0000FF"><b>#Rec_Therapy#&nbsp;visits</b></font>.&nbsp;#Rec_Reason#&nbsp;<cfif Rec_Reason contains 'maintenance'>Maintenance is recommended because current function is the SAME as prior function. See CMS Guidelines at 42 CFR 409.44 for maintenance therapy.</cfif><i>&nbsp;*See full analysis starting on Page 4-5.</i>
              </td>
          </tr>
         
        </cfoutput>
        <!--- </cfif>--->
      </table></td>
  </tr>
  </table>
  <tr>
    <!---<td valign="top" style="height:300px;"></td>--->
  </tr>
  <tr>
    <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
        <tr>
          <td height="20px"></td>
        </tr>
        <cfif Get_wizard.Recordcount gt 0>
          <tr>
            <td valign="top" style="color:red; font-weight:bold;" >RECOMMENDED CODING BASED ON TREATMENT ORDERS</td>
          </tr>
                                 <tr>
            <td height="5px"></td>
          </tr>
          <!--- <tr><td valign="top">&nbsp;</td></tr>--->
          <cfoutput query="Get_wizard">
            <tr>
              <td valign="top" ><b>
                <cfif Deficits contains 'No. 1'>
                  (M1021)
                  <cfelse>
                  (M1023)
                </cfif>
                </b>&nbsp;#Diagnosis#
                <cfif Casemix neq ''>
                  &nbsp;<font color="##0000FF"><b>(#Casemix#)</b></font>
                </cfif>
                <br /></td>
            </tr>
          </cfoutput>
        <tr>
            <td><i>&nbsp;</i></td>
          </tr>
          <tr>
            <td><i>----------------------------------------------------Rationale----------------------------------------------------</i></td>
          </tr>
          <cfoutput query="Get_wizard">
            <!--- <cfoutput group="Message_ID"> <tr><td valign="top" >#Message_ID#</td></tr></cfoutput>--->
            <tr>
              <td valign="top" ><i>
                <li>#ICD# - #Memo#</li>
                </i></td>
            </tr>
          </cfoutput>
          <cfelse>
          <tr>
            <td valign="top"> No coding results are available.</td>
          </tr>
        </cfif>
        <!---<cfoutput>#session.cs.deficits#</cfoutput>--->
        <tr>
          <td valign="top" style="height:10px;"></td>
        </tr>
      </table></td>
  </tr>
  </table>
    <tr>
    <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
        <tr>
          <td height="2px"></td>
        </tr>
        <tr>
          <td valign="top" style="color:red; font-weight:bold;" >WIZARD FINDINGS</td>
        </tr>
                               <tr>
            <td height="5px"></td>
          </tr>
        <cfoutput>
          <tr>
            <td>Errors:&nbsp;<font color="##FF0000"><b>#mistakes#</b></font>&nbsp;&nbsp;&nbsp;Inconsistencies:&nbsp;<font color="##FF0000"><b>#inconsistent#</b></font>&nbsp;&nbsp;&nbsp;User Coding Score:&nbsp;<font color="##FF0000"><b>#coding_score#%</b></font>&nbsp;(see below)</td>
          </tr>
          <tr>
            <td>User Casemix Count:&nbsp;<font color="##FF0000"><b>#wizardCM#</b></font>&nbsp;&nbsp;&nbsp;Wizard Casemix Count:&nbsp;<font color="##FF0000"><b>#userCM#</b></font></cfoutput><cfif money eq 2 or money eq 3><br /><b>Reimbursement Increase:&nbsp;$33</b><cfelseif money gte 4><br /><b>Reimbursement Increase:&nbsp;$190</b></cfif></td></tr>
						<tr>
                         
          <td valign="top" style="color:red; font-weight:bold;" >WIZARD RECOMMENDATIONS</td>
        </tr>
                               <tr>
            <td height="5px"></td>
          </tr>
						<cfoutput query="Rec_Vis">
          <tr>
                <td>Reimbursement:&nbsp;<strong>#LSCurrencyFormat(Field_8, "local")#</strong>
		  &nbsp;&nbsp;&nbsp;&nbsp;
                Net:&nbsp;<strong><cfif Message contains '-'>#LSCurrencyFormat(Field_10, "local")#<cfelse>#LSCurrencyFormat(Field_10, "local")#</cfif></strong>
                &nbsp;&nbsp;&nbsp;&nbsp;
                 HIPPS:&nbsp;<strong>#Field_2#</strong>
                <br />
               Therapy:&nbsp;<strong>#Field_5#&nbsp;visits<cfif Field_5 does not contain '0'>:&nbsp;#Message#</cfif></strong>&nbsp;               
               Nursing:&nbsp;<strong>#Field_4#&nbsp;visits<cfif Field_4 does not contain '0'>:&nbsp;#Desired#</cfif></strong>&nbsp;
              
               Aide:&nbsp;<strong>#Field_6#&nbsp;visits<cfif Field_6 does not contain '0' and Field_6 neq ''>:&nbsp;#Short#</cfif></strong>
               
              </td>
          </tr>
              </td>
          </tr>
         
        </cfoutput>
        <!--- </cfif>--->
      </table></td>
  </tr>
  </table>
  <tr>
    <!---<td valign="top" style="height:300px;"></td>--->
  </tr>

  <cfif Rec_Vis.Recordcount gt 0>
   <cfdocumentitem type="pagebreak" />
    <tr>
      <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
          <tr>
            <td height="10px"></td>
          </tr>
          <tr>
            <td valign="top" style="color:red; font-weight:bold;">WIZARD UTILIZATION RECOMMENDATIONS</td>
          </tr>
           <tr>
            <td height="5px"></td>
          </tr>
          <!--- <tr><td valign="top">&nbsp;</td></tr>---> 
          
          <cfoutput query="Rec_Vis">
            <tr>
              <td valign="top">CERTIFICATION PERIOD: <b>#Field_11# Weeks</b><br /><br />
              THERAPY:<b><cfif Field_5 gt 0>&nbsp;#Field_5#&nbsp;visits, #Message#.<cfelse>&nbsp;0 Visits.</cfif></b>&nbsp;&nbsp;<font color="##0000FF">#Answer_1#
                <cfif Answer_1 contains 'NOT indicated'> <br /> <br />
                  If this is inconsistent with the clinician recommendation, update M18XX to indicate lower current functioning and update GG0100 to indicate higher prior functioning.
                </cfif></font>
                <br />
                <br />
               NURSING:<b><cfif Field_4 gt 0>&nbsp;#Field_4#&nbsp;visits, #Desired#.<cfelse>&nbsp;0 Visits.</cfif></b>&nbsp;&nbsp;<font color="##0000FF">#Field_12#</font>
                <br />
                <br />
                HOME HEALTH AIDE:<b><cfif Field_6 gt 0>&nbsp;#Field_6#&nbsp;visits, #Short#.<cfelse>&nbsp;0 Visits.</cfif></b>&nbsp;&nbsp;<font color="##0000FF">#GG_1#</font>
                                <br />
                <br />
                 RISK FACTORS:&nbsp;<font color="##0000FF">#GG_2##M0_Item#<cfif GG_2 contains 'significant' or M0_Item contains 'severe'>INCREASED UTILIZATION IS INDICATED.<cfelse>Increased utilization is NOT indicated.</cfif></font>
            </tr>
          </cfoutput> 
          <!---<cfoutput>#session.cs.deficits#</cfoutput>--->
          <tr>
            <td valign="top" style="height:5px;"></td>
          </tr>
        </table></td>
    </tr>
    </table>
  </cfif>
  <tr>
    <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
        <tr> 
          <!---<td height="2px"></td>---> 
        </tr>
        <cfset Message = ''>
        <cfif Report_dtails.Recordcount gt 0>
          <cfoutput query="Report_dtails">
            <tr>
              <td valign="top" >&nbsp;</td>
            </tr>
            <cfif Message contains Message_ID>
              <cfelse>
              <cfset Message = Message&','&Message_ID />
              <tr>
                <td valign="top" style="color:red; font-weight:bold;" >
              <tr>
                <td valign="top" style="color:red; font-weight:bold;" ><cfif Message_ID eq 1>
                    risk for asphyxiation without constant monitoring<br />
                    <br />
                    <cfelseif Message_ID eq 2>
                    wounds at high risk for infection<br />
                    <br />
                    <cfelseif Message_ID eq 3>
                    infections requiring monitoring<br />
                    <br />
                    <cfelseif Message_ID eq 4>
                    conditions causing severe dyspnea<br />
                    <br />
                    <cfelseif Message_ID eq 5>
                    conditions affecting mobility and safety<br />
                    <br />
                    <cfelseif Message_ID eq 6>
                    high risk safety issues because of unknown/unlikely supervision/advocacy<br />
                    <br />
                    <cfelseif Message_ID eq 7>
                    high risk chronic conditions requiring intervention, teaching and close monitoring<br />
                    <br />
                    <cfelseif Message_ID eq 8>
                    chronic conditions requiring intervention, teaching and close monitoring <br />
                    <br />
                    <cfelseif Message_ID eq 9>
                    stable conditions that may be affected by changes in careplan<br />
                    <br />
                    <cfelseif Message_ID eq 10 or Message_ID eq 11 or Message_ID eq ''>
                    additional chronic conditions requiring teaching<br />
                    <br />
                    <cfelseif Message_ID eq 13>
                    CONDITION IS STABLE: DO NOT CODE<br />
                    <br />
                    <cfelseif Message_ID eq 15>
                    INCONSISTENCIES<br />
                    <br />
                    <cfelseif Message_ID eq 20>
                    ERRORS - FIX BEFORE TRANSMISSION<br />
                    <br />
                    <cfelseif Message_ID eq 0>
                    &nbsp;
                    <cfelse>
                    needs a home
                  </cfif></td>
              </tr>
              <tr>
                <td height="10px"></td>
              </tr>
            </cfif>
            <!--- <cfoutput group="Message_ID"> <tr><td valign="top" >#Message_ID#</td></tr></cfoutput>--->
            
            <tr>
              <td valign="top" ><b>
                <cfif M0_Item_Medication contains 'M1'>
                  #M0_Item_Medication#
                  <cfelse>
                  (WZRD)
                </cfif>
                </b>&nbsp;#Diagnosis#<!---<cfif Casemix neq ''>&nbsp;<font>(#Casemix#)</font></cfif>---> 
                <font color="##0000FF">
                <cfif OASIS neq ''>
                  <br />
                  #OASIS#
                </cfif>
                <br />
                <i>#Medications#</i></font></td>
            </tr>
          </cfoutput>
          <cfelse>
        </cfif>
        <!---<cfoutput>#session.cs.deficits#</cfoutput>--->
        
        <tr>
          <td height="20px"></td>
        </tr>
        <tr>
          <td valign="top" ></td>
        </tr>
      </table></td>
  </tr>
  </table>
  <tr>
    <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
        <tr> 
          <!---<td height="2px"></td>---> 
        </tr>
        <tr>
          <td valign="top" style="color:black; font-weight:bold;" >FULL PROBLEM LIST ACCORDING TO OASIS AND MEDICATION PROFILE</td>
        </tr>
        <cfset Message = ''>
        <cfif Report_dtails2.Recordcount gt 0>
          <cfoutput query="Report_dtails2">
            <tr>
              <td valign="top" >&nbsp;</td>
            </tr>
            <cfif Message contains Message_ID>
              <cfelse>
              <cfset Message = Message&','&Message_ID />
              <tr>
                <td valign="top" style="color:red; font-weight:bold;" >
              <tr>
                <td valign="top" style="color:black; font-weight:bold;" ><cfif Message_ID eq 1>
                    <font color="##FF0000"><b>UNSTABLE risk for asphyxiation without constant monitoring</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 2>
                    <font color="##FF0000"><b>UNSTABLE wounds at high risk for infection</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 3>
                    <font color="##FF0000"><b>UNSTABLE infections requiring monitoring</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 4>
                    <font color="##FF0000"><b>UNSTABLE conditions causing severe dyspnea</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 5>
                    <font color="##FF0000"><b>UNSTABLE conditions affecting mobility and safety</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 6>
                    <font color="##FF0000"><b>UNSTABLE high risk safety issues because of unknown/unlikely supervision/advocacy</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 7>
                    <font color="##FF0000"><b>UNSTABLE high risk chronic conditions requiring intervention, teaching and close monitoring</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 8>
                    <font color="##FF0000"><b>UNSTABLE chronic conditions requiring intervention, teaching and close monitoring</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 10 or Message_ID eq 11 or Message_ID eq 16 or Message_ID eq ''>
                    <b>additional chronic conditions requiring teaching</b><br />
                    <br />
                    <cfelseif Message_ID eq 9>
                    <font color="##0000FF"><b>STABLE conditions that may be affected by changes in careplan</b></font><br />
                    <br />
                    <cfelseif Message_ID eq 12>
                    <font color="##0000FF"><b> conditions that are stable as evidenced by OASIS</b></font><br />
                    <br />
                    <cfelse>
                    needs a home
                  </cfif></td>
              </tr>
            </cfif>
            <!--- <cfoutput group="Message_ID"> <tr><td valign="top" >#Message_ID#</td></tr></cfoutput>--->
            
            <tr>
              <td valign="top" ><cfif M0_Item_Medication contains 'M1'>
                  #M0_Item_Medication#
                  <cfelse>
                  (WZRD)
                </cfif>
                &nbsp;#Diagnosis#<!---<cfif Casemix neq ''>&nbsp;<font>(#Casemix#)</font></cfif>--->
                
                <cfif OASIS neq ''>
                  <br />
                  #OASIS#
                </cfif>
                <br />
                <i>#Medications#</i></td>
            </tr>
          </cfoutput>
          <cfelse>
          <tr>
            <td valign="top"> No coding results are available.</td>
          </tr>
        </cfif>
        <tr>
          <td height="40px"></td>
        </tr>
        <tr>
          <td valign="top" ></td>
        </tr>
      </table></td>
  </tr>
  </table>  <cfdocumentitem type="pagebreak" /><tr>
      <td height="20px"></td>
    </tr>
    <tr>
     <td valign="top"><table cellpadding="0" style="font-family: Verdana; font-size: 14px;" align="center" cellspacing="0" border="0" width="90%">
          <cfif Report_Scrub.Recordcount gt 0>
            <tr>
              <td valign="top" style="color:red; font-weight:bold;" >OASIS-D THERAPY ANALYSIS AND RECOMMENDED ANSWERS TO GG0130 and GG0170</td>
            </tr>
            <tr>
              <td height="10px"></td>
            </tr>
            <cfoutput query="Report_Scrub">
              <tr>
                <td style="width:50%">#M0_Item#</td>
                <td style="width:50%">#Answer_1#</td>
              </tr>
              <tr>
                <td height="5px"></td>
              </tr>
              <tr>
                <td style="width:50%">#Answer_2#</td>
                <td style="width:50%"><cfif Message does not contain 'NOT'>
                    <b>#UCASE(Message)#</b>
                    <cfelse>
                    #Message#
                  </cfif></td>
              </tr>
              <tr>
                <td height="5px"></td>
              </tr>
              <tr>
                <td style="width:50%">&nbsp;</td>
                <td style="width:50%"><font color="##0000FF">#GG_1#</font></td>
              </tr>
              <tr>
                <td height="5px"></td>
              </tr>
              <tr>
                <td style="width:50%">&nbsp;</td>
                <td style="width:50%"><font color="##0000FF">#GG_2#</font></td>
              </tr>
              <tr>
              <tr>
                <td height="20px"></td>
              </tr>
            </cfoutput>
          </cfif>
        </table></td>
    </tr>
  </table>
  <cfdocumentitem type="footer" >
  <table cellpadding="0" align="center" style="border-top:: solid 1px black;" cellspacing="0" border="0" height="150px" width="100%">
    <tr>
      <td><table align="center" cellpadding="0" cellspacing="0" border="0" width="40%" 
	  style="font-family: Verdana; font-size: 18px; ">
          <tr>
            <td height="8px"></td>
          </tr>
          <tr>
            <td align="center" style="font-family: Verdana;font-size: 40pt;"> Assessment Inconsistencies </td>
          </tr>
          <tr>
            <td height="3px"></td>
          </tr>
          <tr>
            <td align="center" style="font-family: Verdana;font-size: 40pt;"> Home Care Business Services </td>
          </tr>
          <tr>
            <td height="3px"></td>
          </tr>
          <tr>
            <td align="center" style="font-family: Verdana;font-size: 40pt;"> page <cfoutput>#cfdocument.currentpagenumber#</cfoutput></td>
          </tr>
          <tr>
            <td height="25px"></td>
          </tr>
        </table></td>
    </tr>
  </table>
  </cfdocumentitem>
</cfdocumentsection>
</cfdocument>
