- BGPMUD06 ; IHS/MSC/SAT - MU measure NQF0018 ;16-JUN-2011 15:43;DU
- ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
- ;code to collect meaningful use report Control High Blood Pressure NQF 0018
- ENTRY ;EP
- ; expects:
- ; DFN = patient code from VA PATIENT file
- ; BGPBDATE = begin date of report
- ; BGPEDATE = end date of report
- ; BGPPROV = provider code from NEW PERSON file
- ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
- ; Print Routine: P18ENT^BGPMUDP3
- ; Delimited Routine: D18ENT^BGPMUDD3
- N BGP6,BGPAGEE,BGPBP,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPDEN,BGPHYPDX,BGPNUM,BGPDT,BGPOP,BGPVIEN
- N BGPBPS,BGPESRD,BGPPREG
- N END,FIRST,IEN,START,VIEN
- S BGPDEN=0
- S BGPNUM=0
- S BGPNSTR=""
- S BGPDSTR=""
- S (BGPBP,BGPBPS,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPESRD,BGPHYPDX,BGPOP,BGPPREG,BGPVIEN)=""
- ;patient needs to reach the an age between 18 and 85 by the end of the measurement period
- S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
- Q:BGPAGEE<18
- Q:BGPAGEE>85
- ;getting here means the patient is in the initial population
- ;
- ;look for hypertension during the measurement period
- S BGPHYP=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU CTRL HIGH BP HYP DX")
- S:'+BGPHYP BGPHYP=$$PLTAX^BGPMUUT1(DFN,"BGPMU CTRL HIGH BP HYP DX")
- Q:'BGPHYP
- S BGPICD="ICD"_" "_$$FMTE^XLFDT($P(BGPHYP,U,3),2)
- ;
- ;look for an outpatient encounter with the provider during the measurement period
- S START=9999999-BGPBDATE,END=9999999-BGPEDATE
- S FIRST=END-0.1 F S FIRST=$O(^AUPNVSIT("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>START) D Q:BGPOP
- .S VIEN=0 F S VIEN=$O(^AUPNVSIT("AA",DFN,FIRST,VIEN)) Q:'+VIEN D Q:BGPOP
- ..S BGPDT=$P($P($G(^AUPNVSIT(VIEN,0)),U,1),".",1)
- ..;Check provider
- ..I $$PRV^BGPMUUT1(VIEN,BGPPROV) D
- ...S X=$$VSTCPT^BGPMUUT1(DFN,VIEN,"BGPMU CTRL HIGH BP EM") ;look for outpatient EM
- ...S:'+X X=$$VSTPOV^BGPMUUT3(DFN,VIEN,"BGPMU COLON ENC DX")
- ...S:+X BGPOP=VIEN_U_$G(BGPDT)
- Q:'BGPOP
- ;
- ;look for pregnancy
- S BGPPREG=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU PREGNANCY ALL ICD")
- Q:BGPPREG
- ;look for procedures & diagnosis indicating ESRD
- S BGPESRD=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD DX")
- Q:BGPESRD
- S BGPESRD=$$PLTAX^BGPMUUT1(DFN,"BGPMU ESRD DX","C")
- Q:BGPESRD
- S BGPESRD=$$CPT^BGPMUUT1(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD CPT")
- Q:BGPESRD
- S BGPESRD=$$CPT^BGPMUUT1(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD HCPCS")
- Q:BGPESRD
- S BGPESRD=$$LASTPRC^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD PX")
- Q:BGPESRD
- ;getting here means the patient is in the denominator
- S BGPDEN=1
- ;
- ;check blood pressure reading of most recent outpatient encounter
- D BPC
- D TOTAL(DFN)
- ;
- ;there are no exclusions
- ;
- ;cleanup
- K BGP6,BGPAGEE,BGPBP,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPDEN,BGPHYPDX,BGPNUM,BGPDT,BGPOP,BGPVIEN
- K END,FIRST,IEN,START,VIEN
- Q
- ;
- TOTAL(DFN) ;See where this patient ends up
- ; BGPDSTR = ???
- ; BGPNSTR = ???
- N BGPDT,PTCNT,DENCT,NUMCT,NOTCT,TOTALS,PT1
- S TOTALS=$G(^TMP("BGPMU0018",$J,BGPMUTF,"TOT"))
- S NUMCT=+$G(^TMP("BGPMU0018",$J,BGPMUTF,"NUM",1))
- S NOTCT=+$G(^TMP("BGPMU0018",$J,BGPMUTF,"NOT",1))
- S DENCT=+$G(^TMP("BGPMU0018",$J,BGPMUTF,"DEN",1))
- S PTCNT=$P(TOTALS,U,1),PT1=$P(TOTALS,U,2)
- S PTCNT=PTCNT+1
- S PT1=PT1+1
- I BGPDEN D
- .S DENCT=DENCT+1 S ^TMP("BGPMU0018",$J,BGPMUTF,"DEN",1)=DENCT
- .S ^TMP("BGPMU0018",$J,"PAT",BGPMUTF,"DEN",1,DENCT)=DFN
- .I BGPNUM D
- ..S NUMCT=NUMCT+1
- ..S ^TMP("BGPMU0018",$J,BGPMUTF,"NUM",1)=NUMCT
- ..S ^TMP("BGPMU0018",$J,"PAT",BGPMUTF,"NUM",1,PT1)=DFN_U_BGPICD_";"_"EN "_$$FMTE^XLFDT($P(BGPOP,U,2),2)_";"_BGPBPS
- .I 'BGPNUM D
- ..S NOTCT=NOTCT+1
- ..S ^TMP("BGPMU0018",$J,BGPMUTF,"NOT",1)=NOTCT
- ..S ^TMP("BGPMU0018",$J,"PAT",BGPMUTF,"NOT",1,PT1)=DFN_U_BGPICD_";"_"EN "_$$FMTE^XLFDT($P(BGPOP,U,2),2)_";"_BGPBPS
- S ^TMP("BGPMU0018",$J,BGPMUTF,"TOT")=PTCNT_U_PT1
- ;Setup iCare array for patient
- S BGPICARE("MU.EP.0018.1",BGPMUTF)=BGPDEN_U_BGPNUM_U_""_U_BGPICD_";"_BGPBPS
- Q
- ;
- BPC ;check blood pressure reading of most recent outpatient encounter
- N LDIA,LSYS
- S (LDIA,LSYS)=""
- D BP(DFN,$P(BGPOP,U,1),.BGPBP)
- S BGPCNT=0
- I BGPBP="" S BGPBPS="NM:" Q
- ;loop to find lowest BP readings
- F BGPI=1:1:$L(BGPBP,";") D
- .S X=$P($P(BGPBP,";",BGPI),":",2) S %DT="T" D ^%DT S BGPBPDT=Y
- .S BGPBPSYS=$P($P($P(BGPBP,";",BGPI),":",1),"/",1)
- .S BGPBPDIA=$P($P($P(BGPBP,";",BGPI),":",1),"/",2)
- .S:(LSYS="")!($P(LSYS,U,2)>BGPBPSYS) LSYS=BGPI_U_BGPBPSYS_U_BGPBPDIA
- .S:(LDIA="")!($P(LDIA,U,3)>BGPBPDIA) LDIA=BGPI_U_BGPBPSYS_U_BGPBPDIA
- Q:(LSYS="")&(LDIA="") ;shouldn't happen, but just in case
- I (LSYS=LDIA) D ;if lowest BP's are in the same reading create only one MET row
- .I ($P(LSYS,U,2)<140)&($P(LDIA,U,3)<90) D
- ..S BGPNUM=1
- ..S BGPCNT=BGPCNT+1
- ..S BGPBPS="M:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
- .I '(($P(LSYS,U,2)<140)&($P(LDIA,U,3)<90)) D
- ..;one BP, but NOT MET
- ..S BGPBPS="NM:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
- Q:BGPBPS'=""
- ;if we get here, pt has lowest BP readings on two different measurements
- I ($P(LSYS,U,2)<140)&($P(LDIA,U,3)<90) D
- .;create two MET
- .S BGPNUM=1
- .S BGPCNT=BGPCNT+1
- .S BGPBPS="M:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
- .S BGPBPS=BGPBPS_"*"_" "_$P(LDIA,U,2)_"/"_$P(LDIA,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
- Q:BGPBPS'=""
- ;if we get here pt has high BP
- ;create two NOT MET rows
- S BGPBPS="NM:"_$P(LSYS,U,2)_"/"_$P(LSYS,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
- S BGPBPS=BGPBPS_"*"_" "_$P(LDIA,U,2)_"/"_$P(LDIA,U,3)_" "_$$FMTE^XLFDT($P(BGPOP,U,2),2)
- Q
- ;
- BP(DFN,VIEN,NUM) ;Find is pt has a BP on the chosen visits
- N IEN,MSR,MTYP,BP,BPCNT,SAVE,ARRAY,VST,VCNT
- S BP="",BPCNT=0,VCNT=0
- S MTYP="" S MTYP=$O(^AUTTMSR("B","BP",MTYP))
- Q:MTYP="" 0
- S IEN=VIEN,SAVE=0
- S MSR="" F S MSR=$O(^AUPNVMSR("AD",VIEN,MSR)) Q:MSR="" D
- .I $P($G(^AUPNVMSR(MSR,0)),U,1)=MTYP D
- ..S BPCNT=BPCNT+1
- ..S ARRAY(IEN)=""
- ..I BPCNT=1 S BP=$P($G(^AUPNVMSR(MSR,0)),U,4)_":"_$$DATE^BGPMUUTL($P($G(^AUPNVMSR(MSR,12)),U,1))
- ..I BPCNT>1 S BP=BP_";"_$P($G(^AUPNVMSR(MSR,0)),U,4)_":"_$$DATE^BGPMUUTL($P($G(^AUPNVMSR(MSR,12)),U,1))
- ;
- I BPCNT>0 S NUM=BP
- Q
- ;
- TEST ; debug target
- S U="^"
- S DT=$$DT^XLFDT()
- S DFN=184 ; DFN = patient code from VA PATIENT file
- S BGPBDATE=3110401 ; BGPBDATE = begin date of report
- S BGPEDATE=3110701 ; BGPEDATE = end date of report
- S BGPPROV=2 ; BGPPROV = provider code from NEW PERSON file
- S BGPMUTF="C" ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
- D ENTRY
- Q
- 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
- +2 ;code to collect meaningful use report Control High Blood Pressure NQF 0018
- ENTRY ;EP
- +1 ; expects:
- +2 ; DFN = patient code from VA PATIENT file
- +3 ; BGPBDATE = begin date of report
- +4 ; BGPEDATE = end date of report
- +5 ; BGPPROV = provider code from NEW PERSON file
- +6 ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
- +7 ; Print Routine: P18ENT^BGPMUDP3
- +8 ; Delimited Routine: D18ENT^BGPMUDD3
- +9 NEW BGP6,BGPAGEE,BGPBP,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPDEN,BGPHYPDX,BGPNUM,BGPDT,BGPOP,BGPVIEN
- +10 NEW BGPBPS,BGPESRD,BGPPREG
- +11 NEW END,FIRST,IEN,START,VIEN
- +12 SET BGPDEN=0
- +13 SET BGPNUM=0
- +14 SET BGPNSTR=""
- +15 SET BGPDSTR=""
- +16 SET (BGPBP,BGPBPS,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPESRD,BGPHYPDX,BGPOP,BGPPREG,BGPVIEN)=""
- +17 ;patient needs to reach the an age between 18 and 85 by the end of the measurement period
- +18 SET BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
- +19 IF BGPAGEE<18
- QUIT
- +20 IF BGPAGEE>85
- QUIT
- +21 ;getting here means the patient is in the initial population
- +22 ;
- +23 ;look for hypertension during the measurement period
- +24 SET BGPHYP=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU CTRL HIGH BP HYP DX")
- +25 IF '+BGPHYP
- SET BGPHYP=$$PLTAX^BGPMUUT1(DFN,"BGPMU CTRL HIGH BP HYP DX")
- +26 IF 'BGPHYP
- QUIT
- +27 SET BGPICD="ICD"_" "_$$FMTE^XLFDT($PIECE(BGPHYP,U,3),2)
- +28 ;
- +29 ;look for an outpatient encounter with the provider during the measurement period
- +30 SET START=9999999-BGPBDATE
- SET END=9999999-BGPEDATE
- +31 SET FIRST=END-0.1
- FOR
- SET FIRST=$ORDER(^AUPNVSIT("AA",DFN,FIRST))
- IF FIRST=""!($PIECE(FIRST,".",1)>START)
- QUIT
- Begin DoDot:1
- +32 SET VIEN=0
- FOR
- SET VIEN=$ORDER(^AUPNVSIT("AA",DFN,FIRST,VIEN))
- IF '+VIEN
- QUIT
- Begin DoDot:2
- +33 SET BGPDT=$PIECE($PIECE($GET(^AUPNVSIT(VIEN,0)),U,1),".",1)
- +34 ;Check provider
- +35 IF $$PRV^BGPMUUT1(VIEN,BGPPROV)
- Begin DoDot:3
- +36 ;look for outpatient EM
- SET X=$$VSTCPT^BGPMUUT1(DFN,VIEN,"BGPMU CTRL HIGH BP EM")
- +37 IF '+X
- SET X=$$VSTPOV^BGPMUUT3(DFN,VIEN,"BGPMU COLON ENC DX")
- +38 IF +X
- SET BGPOP=VIEN_U_$GET(BGPDT)
- End DoDot:3
- End DoDot:2
- IF BGPOP
- QUIT
- End DoDot:1
- IF BGPOP
- QUIT
- +39 IF 'BGPOP
- QUIT
- +40 ;
- +41 ;look for pregnancy
- +42 SET BGPPREG=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU PREGNANCY ALL ICD")
- +43 IF BGPPREG
- QUIT
- +44 ;look for procedures & diagnosis indicating ESRD
- +45 SET BGPESRD=$$LASTDX^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD DX")
- +46 IF BGPESRD
- QUIT
- +47 SET BGPESRD=$$PLTAX^BGPMUUT1(DFN,"BGPMU ESRD DX","C")
- +48 IF BGPESRD
- QUIT
- +49 SET BGPESRD=$$CPT^BGPMUUT1(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD CPT")
- +50 IF BGPESRD
- QUIT
- +51 SET BGPESRD=$$CPT^BGPMUUT1(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD HCPCS")
- +52 IF BGPESRD
- QUIT
- +53 SET BGPESRD=$$LASTPRC^BGPMUUT2(DFN,BGPBDATE,BGPEDATE,"BGPMU ESRD PX")
- +54 IF BGPESRD
- QUIT
- +55 ;getting here means the patient is in the denominator
- +56 SET BGPDEN=1
- +57 ;
- +58 ;check blood pressure reading of most recent outpatient encounter
- +59 DO BPC
- +60 DO TOTAL(DFN)
- +61 ;
- +62 ;there are no exclusions
- +63 ;
- +64 ;cleanup
- +65 KILL BGP6,BGPAGEE,BGPBP,BGPBPDIA,BGPBPDT,BGPBPSYS,BGPDEN,BGPHYPDX,BGPNUM,BGPDT,BGPOP,BGPVIEN
- +66 KILL END,FIRST,IEN,START,VIEN
- +67 QUIT
- +68 ;
- TOTAL(DFN) ;See where this patient ends up
- +1 ; BGPDSTR = ???
- +2 ; BGPNSTR = ???
- +3 NEW BGPDT,PTCNT,DENCT,NUMCT,NOTCT,TOTALS,PT1
- +4 SET TOTALS=$GET(^TMP("BGPMU0018",$JOB,BGPMUTF,"TOT"))
- +5 SET NUMCT=+$GET(^TMP("BGPMU0018",$JOB,BGPMUTF,"NUM",1))
- +6 SET NOTCT=+$GET(^TMP("BGPMU0018",$JOB,BGPMUTF,"NOT",1))
- +7 SET DENCT=+$GET(^TMP("BGPMU0018",$JOB,BGPMUTF,"DEN",1))
- +8 SET PTCNT=$PIECE(TOTALS,U,1)
- SET PT1=$PIECE(TOTALS,U,2)
- +9 SET PTCNT=PTCNT+1
- +10 SET PT1=PT1+1
- +11 IF BGPDEN
- Begin DoDot:1
- +12 SET DENCT=DENCT+1
- SET ^TMP("BGPMU0018",$JOB,BGPMUTF,"DEN",1)=DENCT
- +13 SET ^TMP("BGPMU0018",$JOB,"PAT",BGPMUTF,"DEN",1,DENCT)=DFN
- +14 IF BGPNUM
- Begin DoDot:2
- +15 SET NUMCT=NUMCT+1
- +16 SET ^TMP("BGPMU0018",$JOB,BGPMUTF,"NUM",1)=NUMCT
- +17 SET ^TMP("BGPMU0018",$JOB,"PAT",BGPMUTF,"NUM",1,PT1)=DFN_U_BGPICD_";"_"EN "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)_";"_BGPBPS
- End DoDot:2
- +18 IF 'BGPNUM
- Begin DoDot:2
- +19 SET NOTCT=NOTCT+1
- +20 SET ^TMP("BGPMU0018",$JOB,BGPMUTF,"NOT",1)=NOTCT
- +21 SET ^TMP("BGPMU0018",$JOB,"PAT",BGPMUTF,"NOT",1,PT1)=DFN_U_BGPICD_";"_"EN "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)_";"_BGPBPS
- End DoDot:2
- End DoDot:1
- +22 SET ^TMP("BGPMU0018",$JOB,BGPMUTF,"TOT")=PTCNT_U_PT1
- +23 ;Setup iCare array for patient
- +24 SET BGPICARE("MU.EP.0018.1",BGPMUTF)=BGPDEN_U_BGPNUM_U_""_U_BGPICD_";"_BGPBPS
- +25 QUIT
- +26 ;
- BPC ;check blood pressure reading of most recent outpatient encounter
- +1 NEW LDIA,LSYS
- +2 SET (LDIA,LSYS)=""
- +3 DO BP(DFN,$PIECE(BGPOP,U,1),.BGPBP)
- +4 SET BGPCNT=0
- +5 IF BGPBP=""
- SET BGPBPS="NM:"
- QUIT
- +6 ;loop to find lowest BP readings
- +7 FOR BGPI=1:1:$LENGTH(BGPBP,";")
- Begin DoDot:1
- +8 SET X=$PIECE($PIECE(BGPBP,";",BGPI),":",2)
- SET %DT="T"
- DO ^%DT
- SET BGPBPDT=Y
- +9 SET BGPBPSYS=$PIECE($PIECE($PIECE(BGPBP,";",BGPI),":",1),"/",1)
- +10 SET BGPBPDIA=$PIECE($PIECE($PIECE(BGPBP,";",BGPI),":",1),"/",2)
- +11 IF (LSYS="")!($PIECE(LSYS,U,2)>BGPBPSYS)
- SET LSYS=BGPI_U_BGPBPSYS_U_BGPBPDIA
- +12 IF (LDIA="")!($PIECE(LDIA,U,3)>BGPBPDIA)
- SET LDIA=BGPI_U_BGPBPSYS_U_BGPBPDIA
- End DoDot:1
- +13 ;shouldn't happen, but just in case
- IF (LSYS="")&(LDIA="")
- QUIT
- +14 ;if lowest BP's are in the same reading create only one MET row
- IF (LSYS=LDIA)
- Begin DoDot:1
- +15 IF ($PIECE(LSYS,U,2)<140)&($PIECE(LDIA,U,3)<90)
- Begin DoDot:2
- +16 SET BGPNUM=1
- +17 SET BGPCNT=BGPCNT+1
- +18 SET BGPBPS="M:"_$PIECE(LSYS,U,2)_"/"_$PIECE(LSYS,U,3)_" "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)
- End DoDot:2
- +19 IF '(($PIECE(LSYS,U,2)<140)&($PIECE(LDIA,U,3)<90))
- Begin DoDot:2
- +20 ;one BP, but NOT MET
- +21 SET BGPBPS="NM:"_$PIECE(LSYS,U,2)_"/"_$PIECE(LSYS,U,3)_" "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)
- End DoDot:2
- End DoDot:1
- +22 IF BGPBPS'=""
- QUIT
- +23 ;if we get here, pt has lowest BP readings on two different measurements
- +24 IF ($PIECE(LSYS,U,2)<140)&($PIECE(LDIA,U,3)<90)
- Begin DoDot:1
- +25 ;create two MET
- +26 SET BGPNUM=1
- +27 SET BGPCNT=BGPCNT+1
- +28 SET BGPBPS="M:"_$PIECE(LSYS,U,2)_"/"_$PIECE(LSYS,U,3)_" "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)
- +29 SET BGPBPS=BGPBPS_"*"_" "_$PIECE(LDIA,U,2)_"/"_$PIECE(LDIA,U,3)_" "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)
- End DoDot:1
- +30 IF BGPBPS'=""
- QUIT
- +31 ;if we get here pt has high BP
- +32 ;create two NOT MET rows
- +33 SET BGPBPS="NM:"_$PIECE(LSYS,U,2)_"/"_$PIECE(LSYS,U,3)_" "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)
- +34 SET BGPBPS=BGPBPS_"*"_" "_$PIECE(LDIA,U,2)_"/"_$PIECE(LDIA,U,3)_" "_$$FMTE^XLFDT($PIECE(BGPOP,U,2),2)
- +35 QUIT
- +36 ;
- BP(DFN,VIEN,NUM) ;Find is pt has a BP on the chosen visits
- +1 NEW IEN,MSR,MTYP,BP,BPCNT,SAVE,ARRAY,VST,VCNT
- +2 SET BP=""
- SET BPCNT=0
- SET VCNT=0
- +3 SET MTYP=""
- SET MTYP=$ORDER(^AUTTMSR("B","BP",MTYP))
- +4 IF MTYP=""
- QUIT 0
- +5 SET IEN=VIEN
- SET SAVE=0
- +6 SET MSR=""
- FOR
- SET MSR=$ORDER(^AUPNVMSR("AD",VIEN,MSR))
- IF MSR=""
- QUIT
- Begin DoDot:1
- +7 IF $PIECE($GET(^AUPNVMSR(MSR,0)),U,1)=MTYP
- Begin DoDot:2
- +8 SET BPCNT=BPCNT+1
- +9 SET ARRAY(IEN)=""
- +10 IF BPCNT=1
- SET BP=$PIECE($GET(^AUPNVMSR(MSR,0)),U,4)_":"_$$DATE^BGPMUUTL($PIECE($GET(^AUPNVMSR(MSR,12)),U,1))
- +11 IF BPCNT>1
- SET BP=BP_";"_$PIECE($GET(^AUPNVMSR(MSR,0)),U,4)_":"_$$DATE^BGPMUUTL($PIECE($GET(^AUPNVMSR(MSR,12)),U,1))
- End DoDot:2
- End DoDot:1
- +12 ;
- +13 IF BPCNT>0
- SET NUM=BP
- +14 QUIT
- +15 ;
- TEST ; debug target
- +1 SET U="^"
- +2 SET DT=$$DT^XLFDT()
- +3 ; DFN = patient code from VA PATIENT file
- SET DFN=184
- +4 ; BGPBDATE = begin date of report
- SET BGPBDATE=3110401
- +5 ; BGPEDATE = end date of report
- SET BGPEDATE=3110701
- +6 ; BGPPROV = provider code from NEW PERSON file
- SET BGPPROV=2
- +7 ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
- SET BGPMUTF="C"
- +8 DO ENTRY
- +9 QUIT