Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BGPMUD06

BGPMUD06.m

Go to the documentation of this file.
  1. BGPMUD06 ; IHS/MSC/SAT - MU measure NQF0018 ;16-JUN-2011 15:43;DU
  1. ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
  1. ;code to collect meaningful use report Control High Blood Pressure NQF 0018
  1. ENTRY ;EP
  1. ; expects:
  1. ; DFN = patient code from VA PATIENT file
  1. ; BGPBDATE = begin date of report
  1. ; BGPEDATE = end date of report
  1. ; BGPPROV = provider code from NEW PERSON file
  1. ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
  1. ; Print Routine: P18ENT^BGPMUDP3
  1. ; Delimited Routine: D18ENT^BGPMUDD3
  1. N BGP6,BGPAGEE,BGPBP,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPDEN,BGPHYPDX,BGPNUM,BGPDT,BGPOP,BGPVIEN
  1. N BGPBPS,BGPESRD,BGPPREG
  1. N END,FIRST,IEN,START,VIEN
  1. S BGPDEN=0
  1. S BGPNUM=0
  1. S BGPNSTR=""
  1. S BGPDSTR=""
  1. S (BGPBP,BGPBPS,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPESRD,BGPHYPDX,BGPOP,BGPPREG,BGPVIEN)=""
  1. ;patient needs to reach the an age between 18 and 85 by the end of the measurement period
  1. S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
  1. Q:BGPAGEE<18
  1. Q:BGPAGEE>85
  1. ;getting here means the patient is in the initial population
  1. ;
  1. ;look for hypertension during the measurement period
  1. S BGPHYP=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU CTRL HIGH BP HYP DX")
  1. S:'+BGPHYP BGPHYP=$$PLTAX^BGPMUUT1(DFN,"BGPMU CTRL HIGH BP HYP DX")
  1. Q:'BGPHYP
  1. S BGPICD="ICD"_" "_$$FMTE^XLFDT($P(BGPHYP,U,3),2)
  1. ;
  1. ;look for an outpatient encounter with the provider during the measurement period
  1. S START=9999999-BGPBDATE,END=9999999-BGPEDATE
  1. S FIRST=END-0.1 F S FIRST=$O(^AUPNVSIT("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>START) D Q:BGPOP
  1. .S VIEN=0 F S VIEN=$O(^AUPNVSIT("AA",DFN,FIRST,VIEN)) Q:'+VIEN D Q:BGPOP
  1. ..S BGPDT=$P($P($G(^AUPNVSIT(VIEN,0)),U,1),".",1)
  1. ..;Check provider
  1. ..I $$PRV^BGPMUUT1(VIEN,BGPPROV) D
  1. ...S X=$$VSTCPT^BGPMUUT1(DFN,VIEN,"BGPMU CTRL HIGH BP EM") ;look for outpatient EM
  1. ...S:'+X X=$$VSTPOV^BGPMUUT3(DFN,VIEN,"BGPMU COLON ENC DX")
  1. ...S:+X BGPOP=VIEN_U_$G(BGPDT)
  1. Q:'BGPOP
  1. ;
  1. ;look for pregnancy
  1. S BGPPREG=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU PREGNANCY ALL ICD")
  1. Q:BGPPREG
  1. ;look for procedures & diagnosis indicating ESRD
  1. S BGPESRD=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD DX")
  1. Q:BGPESRD
  1. S BGPESRD=$$PLTAX^BGPMUUT1(DFN,"BGPMU ESRD DX","C")
  1. Q:BGPESRD
  1. S BGPESRD=$$CPT^BGPMUUT1(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD CPT")
  1. Q:BGPESRD
  1. S BGPESRD=$$CPT^BGPMUUT1(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD HCPCS")
  1. Q:BGPESRD
  1. S BGPESRD=$$LASTPRC^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD PX")
  1. Q:BGPESRD
  1. ;getting here means the patient is in the denominator
  1. S BGPDEN=1
  1. ;
  1. ;check blood pressure reading of most recent outpatient encounter
  1. D BPC
  1. D TOTAL(DFN)
  1. ;
  1. ;there are no exclusions
  1. ;
  1. ;cleanup
  1. K BGP6,BGPAGEE,BGPBP,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPDEN,BGPHYPDX,BGPNUM,BGPDT,BGPOP,BGPVIEN
  1. K END,FIRST,IEN,START,VIEN
  1. Q
  1. ;
  1. TOTAL(DFN) ;See where this patient ends up
  1. ; BGPDSTR = ???
  1. ; BGPNSTR = ???
  1. N BGPDT,PTCNT,DENCT,NUMCT,NOTCT,TOTALS,PT1
  1. S TOTALS=$G(^TMP("BGPMU0018",$J,BGPMUTF,"TOT"))
  1. S NUMCT=+$G(^TMP("BGPMU0018",$J,BGPMUTF,"NUM",1))
  1. S NOTCT=+$G(^TMP("BGPMU0018",$J,BGPMUTF,"NOT",1))
  1. S DENCT=+$G(^TMP("BGPMU0018",$J,BGPMUTF,"DEN",1))
  1. S PTCNT=$P(TOTALS,U,1),PT1=$P(TOTALS,U,2)
  1. S PTCNT=PTCNT+1
  1. S PT1=PT1+1
  1. I BGPDEN D
  1. .S DENCT=DENCT+1 S ^TMP("BGPMU0018",$J,BGPMUTF,"DEN",1)=DENCT
  1. .S ^TMP("BGPMU0018",$J,"PAT",BGPMUTF,"DEN",1,DENCT)=DFN
  1. .I BGPNUM D
  1. ..S NUMCT=NUMCT+1
  1. ..S ^TMP("BGPMU0018",$J,BGPMUTF,"NUM",1)=NUMCT
  1. ..S ^TMP("BGPMU0018",$J,"PAT",BGPMUTF,"NUM",1,PT1)=DFN_U_BGPICD_";"_"EN "_$$FMTE^XLFDT($P(BGPOP,U,2),2)_";"_BGPBPS
  1. .I 'BGPNUM D
  1. ..S NOTCT=NOTCT+1
  1. ..S ^TMP("BGPMU0018",$J,BGPMUTF,"NOT",1)=NOTCT
  1. ..S ^TMP("BGPMU0018",$J,"PAT",BGPMUTF,"NOT",1,PT1)=DFN_U_BGPICD_";"_"EN "_$$FMTE^XLFDT($P(BGPOP,U,2),2)_";"_BGPBPS
  1. S ^TMP("BGPMU0018",$J,BGPMUTF,"TOT")=PTCNT_U_PT1
  1. ;Setup iCare array for patient
  1. S BGPICARE("MU.EP.0018.1",BGPMUTF)=BGPDEN_U_BGPNUM_U_""_U_BGPICD_";"_BGPBPS
  1. Q
  1. ;
  1. BPC ;check blood pressure reading of most recent outpatient encounter
  1. N LDIA,LSYS
  1. S (LDIA,LSYS)=""
  1. D BP(DFN,$P(BGPOP,U,1),.BGPBP)
  1. S BGPCNT=0
  1. I BGPBP="" S BGPBPS="NM:" Q
  1. ;loop to find lowest BP readings
  1. F BGPI=1:1:$L(BGPBP,";") D
  1. .S X=$P($P(BGPBP,";",BGPI),":",2) S %DT="T" D ^%DT S BGPBPDT=Y
  1. .S BGPBPSYS=$P($P($P(BGPBP,";",BGPI),":",1),"/",1)
  1. .S BGPBPDIA=$P($P($P(BGPBP,";",BGPI),":",1),"/",2)
  1. .S:(LSYS="")!($P(LSYS,U,2)>BGPBPSYS) LSYS=BGPI_U_BGPBPSYS_U_BGPBPDIA
  1. .S:(LDIA="")!($P(LDIA,U,3)>BGPBPDIA) LDIA=BGPI_U_BGPBPSYS_U_BGPBPDIA
  1. Q:(LSYS="")&(LDIA="") ;shouldn't happen, but just in case
  1. I (LSYS=LDIA) D ;if lowest BP's are in the same reading create only one MET row
  1. .I ($P(LSYS,U,2)<140)&($P(LDIA,U,3)<90) D
  1. ..S BGPNUM=1
  1. ..S BGPCNT=BGPCNT+1
  1. ..S BGPBPS="M:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
  1. .I '(($P(LSYS,U,2)<140)&($P(LDIA,U,3)<90)) D
  1. ..;one BP, but NOT MET
  1. ..S BGPBPS="NM:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
  1. Q:BGPBPS'=""
  1. ;if we get here, pt has lowest BP readings on two different measurements
  1. I ($P(LSYS,U,2)<140)&($P(LDIA,U,3)<90) D
  1. .;create two MET
  1. .S BGPNUM=1
  1. .S BGPCNT=BGPCNT+1
  1. .S BGPBPS="M:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
  1. .S BGPBPS=BGPBPS_"*"_" "_$P(LDIA,U,2)_"/"_$P(LDIA,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
  1. Q:BGPBPS'=""
  1. ;if we get here pt has high BP
  1. ;create two NOT MET rows
  1. S BGPBPS="NM:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
  1. S BGPBPS=BGPBPS_"*"_" "_$P(LDIA,U,2)_"/"_$P(LDIA,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
  1. Q
  1. ;
  1. BP(DFN,VIEN,NUM) ;Find is pt has a BP on the chosen visits
  1. N IEN,MSR,MTYP,BP,BPCNT,SAVE,ARRAY,VST,VCNT
  1. S BP="",BPCNT=0,VCNT=0
  1. S MTYP="" S MTYP=$O(^AUTTMSR("B","BP",MTYP))
  1. Q:MTYP="" 0
  1. S IEN=VIEN,SAVE=0
  1. S MSR="" F S MSR=$O(^AUPNVMSR("AD",VIEN,MSR)) Q:MSR="" D
  1. .I $P($G(^AUPNVMSR(MSR,0)),U,1)=MTYP D
  1. ..S BPCNT=BPCNT+1
  1. ..S ARRAY(IEN)=""
  1. ..I BPCNT=1 S BP=$P($G(^AUPNVMSR(MSR,0)),U,4)_":"_$$DATE^BGPMUUTL($P($G(^AUPNVMSR(MSR,12)),U,1))
  1. ..I BPCNT>1 S BP=BP_";"_$P($G(^AUPNVMSR(MSR,0)),U,4)_":"_$$DATE^BGPMUUTL($P($G(^AUPNVMSR(MSR,12)),U,1))
  1. ;
  1. I BPCNT>0 S NUM=BP
  1. Q
  1. ;
  1. TEST ; debug target
  1. S U="^"
  1. S DT=$$DT^XLFDT()
  1. S DFN=184 ; DFN = patient code from VA PATIENT file
  1. S BGPBDATE=3110401 ; BGPBDATE = begin date of report
  1. S BGPEDATE=3110701 ; BGPEDATE = end date of report
  1. S BGPPROV=2 ; BGPPROV = provider code from NEW PERSON file
  1. S BGPMUTF="C" ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
  1. D ENTRY
  1. Q