<!---cron_coding_SCRUB.cfm--->
<!---<cfset Request.prefix_db_agency = 'agency_631' />--->
<cfset session.cs.patientid = #url.ID# />
<cfset Patient_ID = #url.ID# />
<cfset Assessment_ID = #url.AID# />
<cfset Request.prefix_db_lookup = 'hhapowerpath' />
<cfset Diagnosis = '' />
<cfset OASIS = '' />
<cfset CM_Count = 0 />
<cfset dx_count = 0 />
<cfset user_CM_count = '' />
<cfset wiz_CM_count = '' />
<cfif getTimeZone.Coding_wizard eq 1>
  <cfset coding = 'yes' />
  <cfelse>
  <cfset coding = 'no' />
</cfif>
<cfquery  name="Get_Primary" datasource="#Application.DataSrc#">
SELECT Safety_Hazards_M0320, Structural_Barriers_M0310, Current_Residence_M0300
From #Request.prefix_db_agency#.patient
where Patient_ID = #url.ID#
</cfquery>
<cfif Get_Primary.Safety_Hazards_M0320 eq '1'>
  <!---Get_Wound_with no problems--->
  <cfquery  name="Get_Wound_1" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'WOUND'
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_Wound_1.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_Wound_1.Diagnosis#', Textfield_8 = '#Get_Wound_1.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'WOUND'
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Wound_with problems--->
  <cfquery  name="Get_Wound_2" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'WOUND'
     and Dx_Order = 1
    and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_Wound_2.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care however the wound is either healed or not recorded on OASIS. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_Wound_2.Diagnosis#', Textfield_8 = '#Get_Wound_2.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'WOUND'
    and Dx_Order = 1
      and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Wound no Case Mix--->
  <cfquery  name="Get_Wound_3" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_Wound_3.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Wound_3.Diagnosis#', Textfield_8 = '#Get_Wound_3.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = ''
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
    </cfquery>
  </cfif>
  <!---Get_Wound no Case Mix and problems--->
  <cfquery  name="Get_Wound_4" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
   and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_Wound_4.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care however the wound is either healed or not recorded on OASIS. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Wound_4.Diagnosis#', Textfield_8 = '#Get_Wound_4.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
       and Dx_Order = 1
        and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Wound teaching no Case Mix--->
  <cfquery  name="Get_Wound_5" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and TextField_3 = ''
    and Dx_Order = 1
    </cfquery>
  <cfif Get_Wound_5.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care however the wound is either healed or not recorded on OASIS. Either change the primary reason for home health or correct the OASIS.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Wound_5.Diagnosis#', Textfield_8 = '#Get_Wound_5.Textfield_2#'
      where Assessment_ID = #url.AID#
        and Patient_ID = #url.ID#
        and Message_ID = 99
        and Dx_Order = 1
        and TextField_3 = ''
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Wound_Teaching with no problems--->
  <cfquery  name="Get_Wound_6" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'WOUND'
    and Dx_Order = 1
  and Message_ID = 99
  </cfquery>
  <cfif Get_Wound_6.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
    Update #Request.prefix_db_agency#.Coding_Results
    set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_Wound_6.Diagnosis#', Textfield_8 = '#Get_Wound_6.Textfield_2#'
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'WOUND'
    and Dx_Order = 1
    and Message_ID = 99
    LIMIT 1
  </cfquery>
  </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq 'NEURO_REHAB'>
  <!---Get_Neuro_with no problems--->
  <cfquery  name="Get_Neuro_1" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'NEURO_REHAB'
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_Neuro_1.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is rehabilitation for a neurological condition. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_Neuro_1.Diagnosis#', Textfield_8 = '#Get_Neuro_1.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'NEURO_REHAB'
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Neuro_with problems--->
  <cfquery  name="Get_Neuro_2" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'NEURO_REHAB'
    and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_Neuro_2.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is rehabilitation for a neurological condition however the condition is stable or not recorded on OASIS. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_Neuro_2.Diagnosis#', Textfield_8 = '#Get_Neuro_2.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'NEURO_REHAB'
    and Dx_Order = 1
      and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Neuro no Case Mix--->
  <cfquery  name="Get_Neuro_3" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_Neuro_3.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is rehabilitation for a neurological condition however the user-entered diagnosis is not a PDGM casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Neuro_3.Diagnosis#', Textfield_8 = '#Get_Neuro_3.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
     and Dx_Order = 1
        Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Neuro no Case Mix and problems--->
  <cfquery  name="Get_Neuro_4" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
   and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_Neuro_4.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care however the wound is either healed or not recorded on OASIS. Either change the primary reason for home health or correct the OASIS.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Neuro_4.Diagnosis#', Textfield_8 = '#Get_Neuro_4.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
       and Dx_Order = 1
        and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Neuro teaching no Case Mix--->
  <cfquery  name="Get_Neuro_5" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and TextField_3 = ''
    and Dx_Order = 1
    </cfquery>
  <cfif Get_Neuro_5.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care however the wound is either healed or not recorded on OASIS. Either change the primary reason for home health or correct the OASIS.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Neuro_5.Diagnosis#', Textfield_8 = '#Get_Neuro_5.Textfield_2#'
      where Assessment_ID = #url.AID#
        and Patient_ID = #url.ID#
        and Message_ID = 99
        and Dx_Order = 1
        and TextField_3 = ''
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Neuro_Teaching with no problems--->
  <cfquery  name="Get_Neuro_6" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'NEURO_REHAB'
    and Dx_Order = 1
  and Message_ID = 99
  </cfquery>
  <cfif Get_Neuro_6.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
    Update #Request.prefix_db_agency#.Coding_Results
    set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is wound care. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_Neuro_6.Diagnosis#', Textfield_8 = '#Get_Neuro_6.Textfield_2#'
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'NEURO_REHAB'
    and Dx_Order = 1
    and Message_ID = 99
    LIMIT 1
  </cfquery>
  </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '3'>
  <!---Get_Endo_with no problems--->
  <cfquery  name="Get_Endo_1" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_ENDO'
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_Endo_1.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor diabetes. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_Endo_1.Diagnosis#', Textfield_8 = '#Get_Endo_1.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_ENDO'
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Endo_with problems--->
  <cfquery  name="Get_Endo_2" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_ENDO'
    and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_Endo_2.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor diabetes however the condition has no medical treatment. Either change the primary reason for home health or add medications. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_Endo_2.Diagnosis#', Textfield_8 = '#Get_Endo_2.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_ENDO'
    and Dx_Order = 1
      and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Endo no Case Mix--->
  <cfquery  name="Get_Endo_3" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_Endo_3.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor diabetes however the user-entered diagnosis is not a PDGM casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Endo_3.Diagnosis#', Textfield_8 = '#Get_Endo_3.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
     and Dx_Order = 1
        and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Endo no Case Mix and problems--->
  <cfquery  name="Get_Endo_4" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
   and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_Endo_4.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor diabetes.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Endo_4.Diagnosis#', Textfield_8 = '#Get_Endo_4.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
       and Dx_Order = 1
        and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Endo teaching no Case Mix--->
  <cfquery  name="Get_Endo_5" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and TextField_3 = ''
    and Dx_Order = 1
    </cfquery>
  <cfif Get_Endo_5.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor diabetes however the condition has no medical treatment. Either change the primary reason for home health or add medications.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_Endo_5.Diagnosis#', Textfield_8 = '#Get_Endo_5.Textfield_2#'
      where Assessment_ID = #url.AID#
        and Patient_ID = #url.ID#
        and Message_ID = 99
        and Dx_Order = 1
        and TextField_3 = ''
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_Endo_Teaching with no problems--->
  <cfquery  name="Get_Endo_6" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_ENDO'
    and Dx_Order = 1
  and Message_ID = 99
  </cfquery>
  <cfif Get_Endo_6.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
    Update #Request.prefix_db_agency#.Coding_Results
    set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor diabetes. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_Endo_6.Diagnosis#', Textfield_8 = '#Get_Endo_6.Textfield_2#'
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_ENDO'
    and Dx_Order = 1
    and Message_ID = 99
    LIMIT 1
  </cfquery>
  </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '6'>
  <!---Get_DX_with no problems--->
  <cfquery  name="Get_DX_1" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_CARDIAC'
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_1.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a cardiac condition. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_CARDIAC'
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_with problems--->
  <cfquery  name="Get_DX_2" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_CARDIAC'
     and Dx_Order = 1
    and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_2.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a cardiac condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_CARDIAC'
    and Dx_Order = 1
      and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix--->
  <cfquery  name="Get_DX_3" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_3.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a cardiac condition however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = ''
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix and problems--->
  <cfquery  name="Get_DX_4" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
   and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_4.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a cardiac condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
       and Dx_Order = 1
        and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX teaching no Case Mix--->
  <cfquery  name="Get_DX_5" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and TextField_3 = ''
    and Dx_Order = 1
    </cfquery>
  <cfif Get_DX_5.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a cardiac condition.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
      where Assessment_ID = #url.AID#
        and Patient_ID = #url.ID#
        and Message_ID = 99
        and Dx_Order = 1
        and TextField_3 = ''
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_Teaching with no problems--->
  <cfquery  name="Get_DX_6" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_CARDIAC'
    and Dx_Order = 1
  and Message_ID = 99
  </cfquery>
  <cfif Get_DX_6.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
    Update #Request.prefix_db_agency#.Coding_Results
    set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a cardiac condition. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_CARDIAC'
    and Dx_Order = 1
    and Message_ID = 99
    LIMIT 1
  </cfquery>
  </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '7'>
  <!---Get_DX_with no problems--->
  <cfquery  name="Get_DX_1" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_INFECT'
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_1.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor the potential for infection or an active infection. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_INFECT'
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_with problems--->
  <cfquery  name="Get_DX_2" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_INFECT'
     and Dx_Order = 1
    and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_2.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor the potential for infection or an active infection however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_INFECT'
    and Dx_Order = 1
      and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix--->
  <cfquery  name="Get_DX_3" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_3.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor the potential for infection or an active infection however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = ''
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix and problems--->
  <cfquery  name="Get_DX_4" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
   and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_4.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor the potential for infection or an active infection however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
       and Dx_Order = 1
        and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX teaching no Case Mix--->
  <cfquery  name="Get_DX_5" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and TextField_3 = ''
    and Dx_Order = 1
    </cfquery>
  <cfif Get_DX_5.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor the potential for infection or an active infection.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
      where Assessment_ID = #url.AID#
        and Patient_ID = #url.ID#
        and Message_ID = 99
        and Dx_Order = 1
        and TextField_3 = ''
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_Teaching with no problems--->
  <cfquery  name="Get_DX_6" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_INFECT'
    and Dx_Order = 1
  and Message_ID = 99
  </cfquery>
  <cfif Get_DX_6.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
    Update #Request.prefix_db_agency#.Coding_Results
    set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor the potential for infection or an active infection. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_INFECT'
    and Dx_Order = 1
    and Message_ID = 99
    LIMIT 1
  </cfquery>
  </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '9'>
  <!---Get_DX_with no problems--->
  <cfquery  name="Get_DX_1" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_RESP'
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_1.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a respiratory condition. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_RESP'
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_with problems--->
  <cfquery  name="Get_DX_2" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_RESP'
     and Dx_Order = 1
    and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_2.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a respiratory condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'MMTA_RESP'
    and Dx_Order = 1
      and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix--->
  <cfquery  name="Get_DX_3" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_3.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a respiratory condition however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = ''
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix and problems--->
  <cfquery  name="Get_DX_4" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
   and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_4.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a respiratory condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
       and Dx_Order = 1
        and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX teaching no Case Mix--->
  <cfquery  name="Get_DX_5" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and TextField_3 = ''
    and Dx_Order = 1
    </cfquery>
  <cfif Get_DX_5.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a respiratory condition.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
      where Assessment_ID = #url.AID#
        and Patient_ID = #url.ID#
        and Message_ID = 99
        and Dx_Order = 1
        and TextField_3 = ''
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_Teaching with no problems--->
  <cfquery  name="Get_DX_6" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_RESP'
    and Dx_Order = 1
  and Message_ID = 99
  </cfquery>
  <cfif Get_DX_6.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
    Update #Request.prefix_db_agency#.Coding_Results
    set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a respiratory condition. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'MMTA_RESP'
    and Dx_Order = 1
    and Message_ID = 99
    LIMIT 1
  </cfquery>
  </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '10'>
  <!---Get_DX_with no problems--->
  <cfquery  name="Get_DX_1" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'COMPLEX'
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_1.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to teach/monitor a skilled procedure. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'COMPLEX'
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_with problems--->
  <cfquery  name="Get_DX_2" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'COMPLEX'
     and Dx_Order = 1
    and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_2.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to teach/monitor a skilled procedure however the condition is not recorded on OASIS. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = 'COMPLEX'
    and Dx_Order = 1
      and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix--->
  <cfquery  name="Get_DX_3" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID NOT IN (13,15)
    </cfquery>
  <cfif Get_DX_3.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to teach/monitor a skilled procedure however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
      and TextField_3 = ''
      and Dx_Order = 1
      and Message_ID NOT IN (13,15)
    </cfquery>
  </cfif>
  <!---Get_DX no Case Mix and problems--->
  <cfquery  name="Get_DX_4" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
   and Message_ID IN (13,15)
    </cfquery>
  <cfif Get_DX_4.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to teach/monitor a skilled procedure however the condition is not recorded on OASIS. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
      where Assessment_ID = #url.AID#
      and Patient_ID = #url.ID#
       and TextField_3 = ''
       and Dx_Order = 1
        and Message_ID IN (13,15)
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX teaching no Case Mix--->
  <cfquery  name="Get_DX_5" datasource="#Application.DataSrc#">
    SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
    From #Request.prefix_db_agency#.Coding_Results
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and TextField_3 = ''
    and Dx_Order = 1
    </cfquery>
  <cfif Get_DX_5.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
      Update #Request.prefix_db_agency#.Coding_Results
      set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to teach/monitor a skilled procedure.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement.  We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
      where Assessment_ID = #url.AID#
        and Patient_ID = #url.ID#
        and Message_ID = 99
        and Dx_Order = 1
        and TextField_3 = ''
      LIMIT 1
    </cfquery>
  </cfif>
  <!---Get_DX_Teaching with no problems--->
  <cfquery  name="Get_DX_6" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'COMPLEX'
    and Dx_Order = 1
  and Message_ID = 99
  </cfquery>
  <cfif Get_DX_6.count gte 1>
    <cfset dx_count =  dx_count + 1 />
    <cfquery  name="update" datasource="#Application.DataSrc#">
    Update #Request.prefix_db_agency#.Coding_Results
    set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to teach/monitor a skilled procedure. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
    where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and TextField_3 = 'COMPLEX'
    and Dx_Order = 1
    and Message_ID = 99
    LIMIT 1
  </cfquery>
  </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '11'>
 <!---Get_DX_with no problems--->
 <cfquery name="Get_DX_1" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_GI_GU'
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_1.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a GI or GU condition. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'MMTA_GI_GU'
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_with problems--->
 <cfquery name="Get_DX_2" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_GI_GU'
   and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_2.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a GI or GU condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'MMTA_GI_GU'
  and Dx_Order = 1
   and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix--->
 <cfquery name="Get_DX_3" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_3.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a GI or GU condition however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = ''
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix and problems--->
 <cfquery name="Get_DX_4" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_4.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a GI or GU condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX teaching no Case Mix--->
 <cfquery name="Get_DX_5" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and Message_ID = 99
  and TextField_3 = ''
  and Dx_Order = 1
  </cfquery>
 <cfif Get_DX_5.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a GI or GU condition.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
   where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and Dx_Order = 1
    and TextField_3 = ''
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_Teaching with no problems--->
 <cfquery name="Get_DX_6" datasource="#Application.DataSrc#">
 SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
 From #Request.prefix_db_agency#.Coding_Results
 where Assessment_ID = #url.AID#
 and Patient_ID = #url.ID#
 and TextField_3 = 'MMTA_GI_GU'
  and Dx_Order = 1
 and Message_ID = 99
 </cfquery>
 <cfif Get_DX_6.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
  Update #Request.prefix_db_agency#.Coding_Results
  set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a GI or GU condition. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_GI_GU'
  and Dx_Order = 1
  and Message_ID = 99
  LIMIT 1
 </cfquery>
 </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '12'>
 <!---Get_DX_with no problems--->
 <cfquery name="Get_DX_1" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'BEHAVE_HEALTH'
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_1.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a behavioral/psychiatric condition. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'BEHAVE_HEALTH'
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_with problems--->
 <cfquery name="Get_DX_2" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'BEHAVE_HEALTH'
   and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_2.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a behavioral/psychiatric condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'BEHAVE_HEALTH'
  and Dx_Order = 1
   and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix--->
 <cfquery name="Get_DX_3" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_3.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a behavioral/psychiatric condition however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = ''
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix and problems--->
 <cfquery name="Get_DX_4" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_4.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a behavioral/psychiatric condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX teaching no Case Mix--->
 <cfquery name="Get_DX_5" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and Message_ID = 99
  and TextField_3 = ''
  and Dx_Order = 1
  </cfquery>
 <cfif Get_DX_5.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a behavioral/psychiatric condition.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
   where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and Dx_Order = 1
    and TextField_3 = ''
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_Teaching with no problems--->
 <cfquery name="Get_DX_6" datasource="#Application.DataSrc#">
 SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
 From #Request.prefix_db_agency#.Coding_Results
 where Assessment_ID = #url.AID#
 and Patient_ID = #url.ID#
 and TextField_3 = 'BEHAVE_HEALTH'
  and Dx_Order = 1
 and Message_ID = 99
 </cfquery>
 <cfif Get_DX_6.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
  Update #Request.prefix_db_agency#.Coding_Results
  set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a behavioral/psychiatric condition. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'BEHAVE_HEALTH'
  and Dx_Order = 1
  and Message_ID = 99
  LIMIT 1
 </cfquery>
 </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 eq '8'>
 <!---Get_DX_with no problems--->
 <cfquery name="Get_DX_1" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_AFTER'
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_1.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to surgical aftercare. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'MMTA_AFTER'
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_with problems--->
 <cfquery name="Get_DX_2" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_AFTER'
   and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_2.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to surgical aftercare however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'MMTA_AFTER'
  and Dx_Order = 1
   and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix--->
 <cfquery name="Get_DX_3" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_3.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to surgical aftercare however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = ''
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix and problems--->
 <cfquery name="Get_DX_4" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_4.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to surgical aftercare however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX teaching no Case Mix--->
 <cfquery name="Get_DX_5" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and Message_ID = 99
  and TextField_3 = ''
  and Dx_Order = 1
  </cfquery>
 <cfif Get_DX_5.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to surgical aftercare.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
   where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and Dx_Order = 1
    and TextField_3 = ''
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_Teaching with no problems--->
 <cfquery name="Get_DX_6" datasource="#Application.DataSrc#">
 SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
 From #Request.prefix_db_agency#.Coding_Results
 where Assessment_ID = #url.AID#
 and Patient_ID = #url.ID#
 and TextField_3 = 'MMTA_AFTER'
  and Dx_Order = 1
 and Message_ID = 99
 </cfquery>
 <cfif Get_DX_6.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
  Update #Request.prefix_db_agency#.Coding_Results
  set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to surgical aftercare. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_AFTER'
  and Dx_Order = 1
  and Message_ID = 99
  LIMIT 1
 </cfquery>
 </cfif>
</cfif>
<cfif Get_Primary.Safety_Hazards_M0320 contains '5'>
 <!---Get_DX_with no problems--->
 <cfquery name="Get_DX_1" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_OTHER'
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_1.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a specific condition. The user-entered diagnosis is a PDGM wound casemix and optimizes reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_1.Diagnosis#', Textfield_8 = '#Get_DX_1.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'MMTA_OTHER'
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_with problems--->
 <cfquery name="Get_DX_2" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_OTHER'
   and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_2.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a specific condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', casemix = '0', Textfield_7 = '#Get_DX_2.Diagnosis#', Textfield_8 = '#Get_DX_2.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = 'MMTA_OTHER'
  and Dx_Order = 1
   and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix--->
 <cfquery name="Get_DX_3" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID NOT IN (13,15)
  </cfquery>
 <cfif Get_DX_3.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a specific condition however the user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_3.Diagnosis#', Textfield_8 = '#Get_DX_3.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
   and TextField_3 = ''
   and Dx_Order = 1
   and Message_ID NOT IN (13,15)
  </cfquery>
 </cfif>
 <!---Get_DX no Case Mix and problems--->
 <cfquery name="Get_DX_4" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = ''
  and Dx_Order = 1
  and Message_ID IN (13,15)
  </cfquery>
 <cfif Get_DX_4.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a specific condition however the condition is stable or has no medical treatment. Either change the primary reason for home health or correct the OASIS.<br><br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_4.Diagnosis#', Textfield_8 = '#Get_DX_4.Textfield_2#'
   where Assessment_ID = #url.AID#
   and Patient_ID = #url.ID#
    and TextField_3 = ''
    and Dx_Order = 1
    and Message_ID IN (13,15)
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX teaching no Case Mix--->
 <cfquery name="Get_DX_5" datasource="#Application.DataSrc#">
  SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
  From #Request.prefix_db_agency#.Coding_Results
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and Message_ID = 99
  and TextField_3 = ''
  and Dx_Order = 1
  </cfquery>
 <cfif Get_DX_5.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
   Update #Request.prefix_db_agency#.Coding_Results
   set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a specific condition.<br>The user-entered diagnosis is not a PDGM wound casemix and will not optimize reimbursement. We recommend using the Coding Wizard-recommend casemix diagnosis replacement that will increase reimbursement by $407.38.', casemix = '407.38', Textfield_7 = '#Get_DX_5.Diagnosis#', Textfield_8 = '#Get_DX_5.Textfield_2#'
   where Assessment_ID = #url.AID#
    and Patient_ID = #url.ID#
    and Message_ID = 99
    and Dx_Order = 1
    and TextField_3 = ''
   LIMIT 1
  </cfquery>
 </cfif>
 <!---Get_DX_Teaching with no problems--->
 <cfquery name="Get_DX_6" datasource="#Application.DataSrc#">
 SELECT Assessment_ID, Order_ID, Diagnosis,Textfield_1, Textfield_2, count(*) AS count
 From #Request.prefix_db_agency#.Coding_Results
 where Assessment_ID = #url.AID#
 and Patient_ID = #url.ID#
 and TextField_3 = 'MMTA_OTHER'
  and Dx_Order = 1
 and Message_ID = 99
 </cfquery>
 <cfif Get_DX_6.count gte 1>
  <cfset dx_count = dx_count + 1 />
  <cfquery name="update" datasource="#Application.DataSrc#">
  Update #Request.prefix_db_agency#.Coding_Results
  set deficits = concat('move to No. ', #dx_count#), Memo = 'The primary reason for home health is to monitor a specific condition. The user-entered diagnosis is a PDGM wound casemix and will optimize reimbursement.', Textfield_7 = '#Get_DX_6.Diagnosis#', Textfield_8 = '#Get_DX_6.Textfield_2#'
  where Assessment_ID = #url.AID#
  and Patient_ID = #url.ID#
  and TextField_3 = 'MMTA_OTHER'
  and Dx_Order = 1
  and Message_ID = 99
  LIMIT 1
 </cfquery>
 </cfif>
</cfif>

