BGPMUAD1 ; IHS/MSC/MGH - Print MI measure NQF0421 and NQF0013 ;22-Mar-2011 09:53;DU
;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
;Delimeted outptu
BMI(CNT) ;EP
D P1
K ^TMP("BGPMU0421",$J)
Q
P1 ;Write individual measure
N X,Y,Z,LIST1,LIST2,LIST3
N DEN1,NUM1,DEN2,NUM2,PC1,PC2,EXC1,EXC2,STRING1,STRING2,STRING3
N PRD1,PRD2,PRD3,PRD4,PRD5,PRD6,PRD7,PRD8,PRN1,PRN2,PRN3,PRN4,PRN5,PRN6,PRN7,PRN8
S STRING1=$$421("C")
S STRING2=$$421("P")
S STRING3=$$421("B")
D SUMMARY1^BGPMUAP1(STRING1,STRING2,STRING3)
;First population
S PRD1=$P(STRING1,U,5)-$P(STRING2,U,5) I PRD1>0 S PRD1="+"_PRD1
S PRD2=$P(STRING1,U,6)-$P(STRING2,U,6) I PRD2>0 S PRD2="+"_PRD2
S PRD3=$P(STRING1,U,7)-$P(STRING2,U,7) I PRD3>0 S PRD3="+"_PRD3
S PRD7=$P(STRING1,U,16)-$P(STRING2,U,16) I PRD7>0 S PRD7="+"_PRD7
S PRN1=$P(STRING1,U,5)-$P(STRING3,U,5) I PRN1>0 S PRN1="+"_PRN1
S PRN2=$P(STRING1,U,6)-$P(STRING3,U,6) I PRN2>0 S PRN2="+"_PRN2
S PRN3=$P(STRING1,U,7)-$P(STRING3,U,7) I PRN3>0 S PRN3="+"_PRN3
S PRN7=$P(STRING1,U,16)-$P(STRING3,U,16) I PRN7>0 S PRN7="+"_PRN7
;second population
S PRD4=$P(STRING1,U,12)-$P(STRING2,U,12) I PRD4>0 S PRD4="+"_PRD4
S PRD5=$P(STRING1,U,13)-$P(STRING2,U,13) I PRD5>0 S PRD5="+"_PRD5
S PRD6=$P(STRING1,U,14)-$P(STRING2,U,14) I PRD6>0 S PRD6="+"_PRD6
S PRD8=$P(STRING1,U,18)-$P(STRING2,U,18) I PRD8>0 S PRD8="+"_PRD8
S PRN4=$P(STRING1,U,12)-$P(STRING3,U,12) I PRN4>0 S PRN4="+"_PRN4
S PRN5=$P(STRING1,U,13)-$P(STRING3,U,13) I PRN5>0 S PRN5="+"_PRN5
S PRN6=$P(STRING1,U,14)-$P(STRING3,U,14) I PRN6>0 S PRN6="+"_PRN6
S PRN8=$P(STRING1,U,18)-$P(STRING3,U,18) I PRN8>0 S PRN8="+"_PRN8
S X=U_"REPORT PERIOD"_U_"%"_U_"PREV YR PERIOD"_U_"%"_U_"CHG FROM PREV YR"_U_"BASE YEAR"_U_"%"_U_"CHG FROM BASE"
D S^BGPMUDEL(X,2,1)
S X="Denominator 1" D S^BGPMUDEL(X,2,1)
S X="Pts 65+"_U_$P(STRING1,U,1)_U_U_$P(STRING2,U,1)_U_U_U_$P(STRING3,U,1) D S^BGPMUDEL(X,1,1)
S X="# Excluded (Exc)"_U_$P(STRING1,U,4)_U_U_$P(STRING2,U,4)_U_U_U_$P(STRING3,U,4)
D S^BGPMUDEL(X,1,1)
S X="Pts 65+ - Exc"_U_$P(STRING1,U,3)_U_U_$P(STRING2,U,3)_U_U_U_$P(STRING3,U,3)
D S^BGPMUDEL(X,1,1)
S X="# w/normal BMI/followup"_U_$P(STRING1,U,2)_U_$P(STRING1,U,5)_U_$P(STRING2,U,2)_U_$P(STRING2,U,5)_U_PRD1_U_$P(STRING3,U,2)_U_$P(STRING3,U,5)_U_PRN1
D S^BGPMUDEL(X,2,1)
S X="# No BMI/followup"_U_$P(STRING1,U,15)_U_$P(STRING1,U,16)_U_$P(STRING2,U,15)_U_$P(STRING2,U,16)_U_PRD7_U_$P(STRING3,U,15)_U_$P(STRING3,U,16)_U_PRN7
D S^BGPMUDEL(X,2,1)
S X="Denominator 2" D S^BGPMUDEL(X,2,1)
S X="Pts 18-64"_U_$P(STRING1,U,8)_U_U_$P(STRING2,U,8)_U_U_U_$P(STRING3,U,8) D S^BGPMUDEL(X,1,1)
S X="# with exclusions:"_U_$P(STRING1,U,11)_U_U_$P(STRING2,U,11)_U_U_U_$P(STRING3,U,11)
D S^BGPMUDEL(X,1,1)
S X="Pts 65+ - Exc"_U_$P(STRING1,U,10)_U_U_$P(STRING2,U,10)_U_U_U_$P(STRING3,U,10)
D S^BGPMUDEL(X,1,1)
S X="# w/normal BMI/followup"_U_$P(STRING1,U,9)_U_$P(STRING1,U,12)_U_$P(STRING2,U,9)_U_$P(STRING2,U,12)_U_PRD4_U_$P(STRING3,U,9)_U_$P(STRING3,U,12)_U_PRN4
D S^BGPMUDEL(X,2,1)
S X="# No BMI/followup"_U_$P(STRING1,U,17)_U_$P(STRING1,U,18)_U_$P(STRING2,U,17)_U_$P(STRING2,U,18)_U_PRD8_U_$P(STRING3,U,17)_U_$P(STRING3,U,18)_U_PRN8
D S^BGPMUDEL(X,2,1)
I $D(BGPLIST(BGPIC)) D P2
Q
421(TF) ;Get the numbers for this measure
N ARRAY,DEN1,NUM1,EXC1,DEN2,NUM2,EXC2,NOT1,NOT2,PC1,PC11,PC2,PC14,PC24,PC21,PC13,PC23,NNUM1,NNUM2
S DEN1=+$G(^TMP("BGPMU0421",$J,TF,"DEN",1))
S NUM1=+$G(^TMP("BGPMU0421",$J,TF,"NUM",1))
S NOT1=+$G(^TMP("BGPMU0421",$J,TF,"NOT",1))
S EXC1=+$G(^TMP("BGPMU0421",$J,TF,"EXC",1))
S DEN2=+$G(^TMP("BGPMU0421",$J,TF,"DEN",2))
S NUM2=+$G(^TMP("BGPMU0421",$J,TF,"NUM",2))
S EXC2=+$G(^TMP("BGPMU0421",$J,TF,"EXC",2))
S NOT2=+$G(^TMP("BGPMU0421",$J,TF,"NOT",2))
S NNUM1=DEN1-EXC1
S NNUM2=DEN2-EXC2
I DEN1=0 S (PC1,PC11,PC13,PC14)=0
I DEN1>0 D
.S PC1=$$ROUND^BGPMUA01((NUM1/NNUM1),3)*100
.S PC11=$$ROUND^BGPMUA01((NNUM1/DEN1),3)*100
.S PC13=$$ROUND^BGPMUA01((EXC1/DEN1),3)*100
.S PC14=$$ROUND^BGPMUA01((NOT1/NNUM1),3)*100
I DEN2=0 S (PC2,PC21,PC23,PC24)=0
I DEN2>0 D
.S PC2=$$ROUND^BGPMUA01((NUM2/NNUM2),3)*100
.S PC21=$$ROUND^BGPMUA01((NNUM2/DEN2),3)*100
.S PC23=$$ROUND^BGPMUA01((EXC2/DEN2),3)*100
.S PC24=$$ROUND^BGPMUA01((NOT2/NNUM2),3)*100
S ARRAY=DEN1_U_NUM1_U_NNUM1_U_EXC1_U_PC1_U_PC11_U_PC13_U_DEN2_U_NUM2_U_NNUM2_U_EXC2_U_PC2_U_PC21_U_PC23
S ARRAY=ARRAY_U_NOT1_U_PC14_U_NOT2_U_PC24
Q ARRAY
P2 ;Do the Details
N PT,NODE,NAME,VST,BMI,FOL,X,PTCT
S PTCT=0
S X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT ****" D S^BGPMUDEL(X,2,1)
S X="Patients 18+ with at least 1 encounter with the EP during the reporting period." D S^BGPMUDEL(X,1,1)
S X="with documented BMI and follow-up, if any." D S^BGPMUDEL(X,1,1)
S X="Patients who do not meet the numerator criteria are listed first (NM:)," D S^BGPMUDEL(X,2,1)
S X="by patients who do meet the numerator criteria (M:)." D S^BGPMUDEL(X,1,1)
S X="The following are the abbreviations used in the denominator column" D S^BGPMUDEL(X,2,1)
S X="EN=Encounter" D S^BGPMUDEL(X,1,1)
S X="Patients 65+" D S^BGPMUDEL(X,2,1)
S X="PATIENT NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR" D S^BGPMUDEL(X,2,1)
I BGPLIST="D"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",1,""NOT"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA(NODE)
I BGPLIST="N"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",1,""NUM"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA(NODE)
I BGPLIST="A" D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",1,""EXC"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA(NODE)
S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
S X="Patients 18-64" D S^BGPMUDEL(X,2,1)
S X="PATIENT NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR" D S^BGPMUDEL(X,2,1)
S PTCT=0
I BGPLIST="D"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",2,""NOT"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA(NODE)
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",2,""NUM"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA(NODE)
I BGPLIST="A" D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",2,""EXC"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA(NODE)
S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
Q
DATA(NODE) ;GET DATA
N NAME,HRN,DEN,NUM,AGE,DFN,SEX,COMM
S DFN=$P(NODE,U,1)
S NAME=$E($$GET1^DIQ(2,$P(NODE,U,1),.01),1,30)
S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
S AGE=$$AGE^AUPNPAT(DFN,BGPED)
S COMM=$$GET1^DIQ(9000001,DFN,1118)
S SEX=$P(^DPT(DFN,0),U,2)
S DEN=$P(NODE,U,2),NUM=$P(NODE,U,4)
S X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_DEN_U_NUM D S^BGPMUDEL(X,1,1)
Q
DATA2(NODE) ;GET DATA
N NAME,HRN,DEN,AGE,DFN,SEX,COMM
S DFN=$P(NODE,U,1)
S NAME=$E($$GET1^DIQ(2,$P(NODE,U,1),.01),1,30)
S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
S AGE=$$AGE^AUPNPAT(DFN,BGPED)
S COMM=$$GET1^DIQ(9000001,DFN,1118)
S SEX=$P(^DPT(DFN,0),U,2)
S DEN=$P(NODE,U,2),NUM=$P(NODE,U,3)
S X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_DEN_U_NUM D S^BGPMUDEL(X,1,1)
Q
;Get printout for BP measure
BLOODP ;EP
D BP1
K ^TMP("BGPMU0013",$J)
Q
BP1 ;Write individual measure
N X,Y,Z,DEN,NUM,PC,STRING1,STRING2,PRD,PRN,PRD1,PRN1
S STRING1=$$0013("C")
S STRING2=$$0013("P")
S STRING3=$$0013("B")
D SUMMARY2^BGPMUAP1(STRING1,STRING2,STRING3)
S PRD=$P(STRING1,U,4)-$P(STRING2,U,4) I PRD>0 S PRD="+"_PRD
S PRD1=$P(STRING1,U,5)-$P(STRING2,U,5) I PRD1>0 S PRD1="+"_PRD1
S PRN=$P(STRING1,U,4)-$P(STRING3,U,4) I PRN>0 S PRN="+"_PRN
S PRN1=$P(STRING1,U,5)-$P(STRING3,U,5) I PRN1>0 S PRN="+"_PRN1
S X=U_"REPORT PERIOD"_U_"%"_U_"PREV YR PERIOD"_U_"%"_U_"CHG FROM PREV YR"_U_"BASE YEAR"_U_"%"_U_"CHG FROM BASE"
D S^BGPMUDEL(X,2,1)
S X="Pts 18+ w/HTN"_U_$P(STRING1,U,1)_U_U_$P(STRING2,U,1)_U_U_U_$P(STRING3,U,1) D S^BGPMUDEL(X,2,1)
S X="# w/=>2 BP recorded"_U_$P(STRING1,U,2)_U_$P(STRING1,U,4)_U_$P(STRING2,U,2)_U_$P(STRING2,U,4)_U_PRD_U_$P(STRING3,U,2)_U_$P(STRING3,U,4)_U_PRN
D S^BGPMUDEL(X,2,1)
S X="# w/o=> 2 BP recorded"_U_$P(STRING1,U,3)_U_$P(STRING1,U,5)_U_$P(STRING2,U,3)_U_$P(STRING2,U,5)_U_PRD1_U_$P(STRING3,U,3)_U_$P(STRING3,U,5)_U_PRN1
D S^BGPMUDEL(X,1,1)
I $D(BGPLIST(BGPIC)) D BP2
Q
0013(TF) ;Get the numbers for this measure
N ARRAY,DEN,NUM,PC1,PC2,NOT
S DEN=+$G(^TMP("BGPMU0013",$J,TF,"DEN"))
S NUM=+$G(^TMP("BGPMU0013",$J,TF,"NUM"))
S NOT=+$G(^TMP("BGPMU0013",$J,TF,"NOT"))
I DEN=0 S (PC1,PC2)=0
I DEN>0 D
.S PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
.S PC2=$$ROUND^BGPMUA01((NOT/DEN),3)*100
S ARRAY=DEN_U_NUM_U_NOT_U_PC1_U_PC2
Q ARRAY
BP2 ;Do the Details
N PT,NODE,NAME,BP,PTCT
S X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT ****" D S^BGPMUDEL(X,2,1)
S X="Hypertensive patients 18+ with at least 2 encounters with the EP during the" D S^BGPMUDEL(X,1,1)
S X="reporting period, with => 2 documented BPs during the encounters, if any." D S^BGPMUDEL(X,1,1)
S X="Patients who do not meet the numerator criteria are listed first (NM:)," D S^BGPMUDEL(X,2,1)
S X="followed by patients who do meet the numerator criteria (M:)." D S^BGPMUDEL(X,1,1)
S X="The following are the abbreviations used in the denominator and numerator" D S^BGPMUDEL(X,2,1)
S X="columns: " D S^BGPMUDEL(X,1,1)
S X="EN=Encounter" D S^BGPMUDEL(X,1,1)
S PTCT=0
S X="Details for pts in numerator Age > 18" D S^BGPMUDEL(X,2,1)
S X="NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR" D S^BGPMUDEL(X,2,1)
I BGPLIST="D"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0013"","_$J_",""PAT"",""C"",""NOT"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA2(NODE)
I BGPLIST="N"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0013"","_$J_",""PAT"",""C"",""NUM"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA2(NODE)
S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
Q
XML0421 ;XML output for adi;t BMI measure
; BGPXML(i)=Population Number^Numerator Number^Denominator Count
N STRING,TOTN,TOTD,TOTE
S STRING=$$421("C")
S TOTD=$P(STRING,U,1)+$P(STRING,U,8)
S TOTN=$P(STRING,U,2)+$P(STRING,U,9)
S TOTE=$P(STRING,U,4)+$P(STRING,U,11)
S BGPXML(1)="128"_U_U_+TOTD_U_TOTN_U_TOTE
K ^TMP("BGPMU0421",$J)
Q
XML0013 ;XML output for hypertension measure
; BGPXML(i)=Population Number^Numerator Number^Denominator Count
N STRING
S STRING=$$0013("C")
S BGPXML(1)="237"_U_U_+$P(STRING,U,1)_U_+$P(STRING,U,2)
K ^TMP("BGPMU0013",$J)
Q
BGPMUAD1 ; IHS/MSC/MGH - Print MI measure NQF0421 and NQF0013 ;22-Mar-2011 09:53;DU
+1 ;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
+2 ;Delimeted outptu
BMI(CNT) ;EP
+1 DO P1
+2 KILL ^TMP("BGPMU0421",$JOB)
+3 QUIT
P1 ;Write individual measure
+1 NEW X,Y,Z,LIST1,LIST2,LIST3
+2 NEW DEN1,NUM1,DEN2,NUM2,PC1,PC2,EXC1,EXC2,STRING1,STRING2,STRING3
+3 NEW PRD1,PRD2,PRD3,PRD4,PRD5,PRD6,PRD7,PRD8,PRN1,PRN2,PRN3,PRN4,PRN5,PRN6,PRN7,PRN8
+4 SET STRING1=$$421("C")
+5 SET STRING2=$$421("P")
+6 SET STRING3=$$421("B")
+7 DO SUMMARY1^BGPMUAP1(STRING1,STRING2,STRING3)
+8 ;First population
+9 SET PRD1=$PIECE(STRING1,U,5)-$PIECE(STRING2,U,5)
IF PRD1>0
SET PRD1="+"_PRD1
+10 SET PRD2=$PIECE(STRING1,U,6)-$PIECE(STRING2,U,6)
IF PRD2>0
SET PRD2="+"_PRD2
+11 SET PRD3=$PIECE(STRING1,U,7)-$PIECE(STRING2,U,7)
IF PRD3>0
SET PRD3="+"_PRD3
+12 SET PRD7=$PIECE(STRING1,U,16)-$PIECE(STRING2,U,16)
IF PRD7>0
SET PRD7="+"_PRD7
+13 SET PRN1=$PIECE(STRING1,U,5)-$PIECE(STRING3,U,5)
IF PRN1>0
SET PRN1="+"_PRN1
+14 SET PRN2=$PIECE(STRING1,U,6)-$PIECE(STRING3,U,6)
IF PRN2>0
SET PRN2="+"_PRN2
+15 SET PRN3=$PIECE(STRING1,U,7)-$PIECE(STRING3,U,7)
IF PRN3>0
SET PRN3="+"_PRN3
+16 SET PRN7=$PIECE(STRING1,U,16)-$PIECE(STRING3,U,16)
IF PRN7>0
SET PRN7="+"_PRN7
+17 ;second population
+18 SET PRD4=$PIECE(STRING1,U,12)-$PIECE(STRING2,U,12)
IF PRD4>0
SET PRD4="+"_PRD4
+19 SET PRD5=$PIECE(STRING1,U,13)-$PIECE(STRING2,U,13)
IF PRD5>0
SET PRD5="+"_PRD5
+20 SET PRD6=$PIECE(STRING1,U,14)-$PIECE(STRING2,U,14)
IF PRD6>0
SET PRD6="+"_PRD6
+21 SET PRD8=$PIECE(STRING1,U,18)-$PIECE(STRING2,U,18)
IF PRD8>0
SET PRD8="+"_PRD8
+22 SET PRN4=$PIECE(STRING1,U,12)-$PIECE(STRING3,U,12)
IF PRN4>0
SET PRN4="+"_PRN4
+23 SET PRN5=$PIECE(STRING1,U,13)-$PIECE(STRING3,U,13)
IF PRN5>0
SET PRN5="+"_PRN5
+24 SET PRN6=$PIECE(STRING1,U,14)-$PIECE(STRING3,U,14)
IF PRN6>0
SET PRN6="+"_PRN6
+25 SET PRN8=$PIECE(STRING1,U,18)-$PIECE(STRING3,U,18)
IF PRN8>0
SET PRN8="+"_PRN8
+26 SET X=U_"REPORT PERIOD"_U_"%"_U_"PREV YR PERIOD"_U_"%"_U_"CHG FROM PREV YR"_U_"BASE YEAR"_U_"%"_U_"CHG FROM BASE"
+27 DO S^BGPMUDEL(X,2,1)
+28 SET X="Denominator 1"
DO S^BGPMUDEL(X,2,1)
+29 SET X="Pts 65+"_U_$PIECE(STRING1,U,1)_U_U_$PIECE(STRING2,U,1)_U_U_U_$PIECE(STRING3,U,1)
DO S^BGPMUDEL(X,1,1)
+30 SET X="# Excluded (Exc)"_U_$PIECE(STRING1,U,4)_U_U_$PIECE(STRING2,U,4)_U_U_U_$PIECE(STRING3,U,4)
+31 DO S^BGPMUDEL(X,1,1)
+32 SET X="Pts 65+ - Exc"_U_$PIECE(STRING1,U,3)_U_U_$PIECE(STRING2,U,3)_U_U_U_$PIECE(STRING3,U,3)
+33 DO S^BGPMUDEL(X,1,1)
+34 SET X="# w/normal BMI/followup"_U_$PIECE(STRING1,U,2)_U_$PIECE(STRING1,U,5)_U_$PIECE(STRING2,U,2)_U_$PIECE(STRING2,U,5)_U_PRD1_U_$PIECE(STRING3,U,2)_U_$PIECE(STRING3,U,5)_U_PRN1
+35 DO S^BGPMUDEL(X,2,1)
+36 SET X="# No BMI/followup"_U_$PIECE(STRING1,U,15)_U_$PIECE(STRING1,U,16)_U_$PIECE(STRING2,U,15)_U_$PIECE(STRING2,U,16)_U_PRD7_U_$PIECE(STRING3,U,15)_U_$PIECE(STRING3,U,16)_U_PRN7
+37 DO S^BGPMUDEL(X,2,1)
+38 SET X="Denominator 2"
DO S^BGPMUDEL(X,2,1)
+39 SET X="Pts 18-64"_U_$PIECE(STRING1,U,8)_U_U_$PIECE(STRING2,U,8)_U_U_U_$PIECE(STRING3,U,8)
DO S^BGPMUDEL(X,1,1)
+40 SET X="# with exclusions:"_U_$PIECE(STRING1,U,11)_U_U_$PIECE(STRING2,U,11)_U_U_U_$PIECE(STRING3,U,11)
+41 DO S^BGPMUDEL(X,1,1)
+42 SET X="Pts 65+ - Exc"_U_$PIECE(STRING1,U,10)_U_U_$PIECE(STRING2,U,10)_U_U_U_$PIECE(STRING3,U,10)
+43 DO S^BGPMUDEL(X,1,1)
+44 SET X="# w/normal BMI/followup"_U_$PIECE(STRING1,U,9)_U_$PIECE(STRING1,U,12)_U_$PIECE(STRING2,U,9)_U_$PIECE(STRING2,U,12)_U_PRD4_U_$PIECE(STRING3,U,9)_U_$PIECE(STRING3,U,12)_U_PRN4
+45 DO S^BGPMUDEL(X,2,1)
+46 SET X="# No BMI/followup"_U_$PIECE(STRING1,U,17)_U_$PIECE(STRING1,U,18)_U_$PIECE(STRING2,U,17)_U_$PIECE(STRING2,U,18)_U_PRD8_U_$PIECE(STRING3,U,17)_U_$PIECE(STRING3,U,18)_U_PRN8
+47 DO S^BGPMUDEL(X,2,1)
+48 IF $DATA(BGPLIST(BGPIC))
DO P2
+49 QUIT
421(TF) ;Get the numbers for this measure
+1 NEW ARRAY,DEN1,NUM1,EXC1,DEN2,NUM2,EXC2,NOT1,NOT2,PC1,PC11,PC2,PC14,PC24,PC21,PC13,PC23,NNUM1,NNUM2
+2 SET DEN1=+$GET(^TMP("BGPMU0421",$JOB,TF,"DEN",1))
+3 SET NUM1=+$GET(^TMP("BGPMU0421",$JOB,TF,"NUM",1))
+4 SET NOT1=+$GET(^TMP("BGPMU0421",$JOB,TF,"NOT",1))
+5 SET EXC1=+$GET(^TMP("BGPMU0421",$JOB,TF,"EXC",1))
+6 SET DEN2=+$GET(^TMP("BGPMU0421",$JOB,TF,"DEN",2))
+7 SET NUM2=+$GET(^TMP("BGPMU0421",$JOB,TF,"NUM",2))
+8 SET EXC2=+$GET(^TMP("BGPMU0421",$JOB,TF,"EXC",2))
+9 SET NOT2=+$GET(^TMP("BGPMU0421",$JOB,TF,"NOT",2))
+10 SET NNUM1=DEN1-EXC1
+11 SET NNUM2=DEN2-EXC2
+12 IF DEN1=0
SET (PC1,PC11,PC13,PC14)=0
+13 IF DEN1>0
Begin DoDot:1
+14 SET PC1=$$ROUND^BGPMUA01((NUM1/NNUM1),3)*100
+15 SET PC11=$$ROUND^BGPMUA01((NNUM1/DEN1),3)*100
+16 SET PC13=$$ROUND^BGPMUA01((EXC1/DEN1),3)*100
+17 SET PC14=$$ROUND^BGPMUA01((NOT1/NNUM1),3)*100
End DoDot:1
+18 IF DEN2=0
SET (PC2,PC21,PC23,PC24)=0
+19 IF DEN2>0
Begin DoDot:1
+20 SET PC2=$$ROUND^BGPMUA01((NUM2/NNUM2),3)*100
+21 SET PC21=$$ROUND^BGPMUA01((NNUM2/DEN2),3)*100
+22 SET PC23=$$ROUND^BGPMUA01((EXC2/DEN2),3)*100
+23 SET PC24=$$ROUND^BGPMUA01((NOT2/NNUM2),3)*100
End DoDot:1
+24 SET ARRAY=DEN1_U_NUM1_U_NNUM1_U_EXC1_U_PC1_U_PC11_U_PC13_U_DEN2_U_NUM2_U_NNUM2_U_EXC2_U_PC2_U_PC21_U_PC23
+25 SET ARRAY=ARRAY_U_NOT1_U_PC14_U_NOT2_U_PC24
+26 QUIT ARRAY
P2 ;Do the Details
+1 NEW PT,NODE,NAME,VST,BMI,FOL,X,PTCT
+2 SET PTCT=0
+3 SET X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT ****"
DO S^BGPMUDEL(X,2,1)
+4 SET X="Patients 18+ with at least 1 encounter with the EP during the reporting period."
DO S^BGPMUDEL(X,1,1)
+5 SET X="with documented BMI and follow-up, if any."
DO S^BGPMUDEL(X,1,1)
+6 SET X="Patients who do not meet the numerator criteria are listed first (NM:),"
DO S^BGPMUDEL(X,2,1)
+7 SET X="by patients who do meet the numerator criteria (M:)."
DO S^BGPMUDEL(X,1,1)
+8 SET X="The following are the abbreviations used in the denominator column"
DO S^BGPMUDEL(X,2,1)
+9 SET X="EN=Encounter"
DO S^BGPMUDEL(X,1,1)
+10 SET X="Patients 65+"
DO S^BGPMUDEL(X,2,1)
+11 SET X="PATIENT NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR"
DO S^BGPMUDEL(X,2,1)
+12 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+13 KILL BGPARR
+14 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$JOB_",""PAT"",""C"",1,""NOT"")")
+15 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+16 SET PTCT=PTCT+1
+17 SET NODE=$GET(BGPARR(PT))
+18 DO DATA(NODE)
End DoDot:2
End DoDot:1
+19 IF BGPLIST="N"!(BGPLIST="A")
Begin DoDot:1
+20 KILL BGPARR
+21 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$JOB_",""PAT"",""C"",1,""NUM"")")
+22 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+23 SET PTCT=PTCT+1
+24 SET NODE=$GET(BGPARR(PT))
+25 DO DATA(NODE)
End DoDot:2
End DoDot:1
+26 IF BGPLIST="A"
Begin DoDot:1
+27 KILL BGPARR
+28 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$JOB_",""PAT"",""C"",1,""EXC"")")
+29 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+30 SET PTCT=PTCT+1
+31 SET NODE=$GET(BGPARR(PT))
+32 DO DATA(NODE)
End DoDot:2
End DoDot:1
+33 SET X="Total # of patients on list: "_PTCT
DO S^BGPMUDEL(X,2,1)
+34 SET X="Patients 18-64"
DO S^BGPMUDEL(X,2,1)
+35 SET X="PATIENT NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR"
DO S^BGPMUDEL(X,2,1)
+36 SET PTCT=0
+37 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+38 KILL BGPARR
+39 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$JOB_",""PAT"",""C"",2,""NOT"")")
+40 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+41 SET PTCT=PTCT+1
+42 SET NODE=$GET(BGPARR(PT))
+43 DO DATA(NODE)
End DoDot:2
+44 KILL BGPARR
+45 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$JOB_",""PAT"",""C"",2,""NUM"")")
+46 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+47 SET PTCT=PTCT+1
+48 SET NODE=$GET(BGPARR(PT))
+49 DO DATA(NODE)
End DoDot:2
End DoDot:1
+50 IF BGPLIST="A"
Begin DoDot:1
+51 KILL BGPARR
+52 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$JOB_",""PAT"",""C"",2,""EXC"")")
+53 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+54 SET PTCT=PTCT+1
+55 SET NODE=$GET(BGPARR(PT))
+56 DO DATA(NODE)
End DoDot:2
End DoDot:1
+57 SET X="Total # of patients on list: "_PTCT
DO S^BGPMUDEL(X,2,1)
+58 QUIT
DATA(NODE) ;GET DATA
+1 NEW NAME,HRN,DEN,NUM,AGE,DFN,SEX,COMM
+2 SET DFN=$PIECE(NODE,U,1)
+3 SET NAME=$EXTRACT($$GET1^DIQ(2,$PIECE(NODE,U,1),.01),1,30)
+4 SET HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
+5 SET AGE=$$AGE^AUPNPAT(DFN,BGPED)
+6 SET COMM=$$GET1^DIQ(9000001,DFN,1118)
+7 SET SEX=$PIECE(^DPT(DFN,0),U,2)
+8 SET DEN=$PIECE(NODE,U,2)
SET NUM=$PIECE(NODE,U,4)
+9 SET X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_DEN_U_NUM
DO S^BGPMUDEL(X,1,1)
+10 QUIT
DATA2(NODE) ;GET DATA
+1 NEW NAME,HRN,DEN,AGE,DFN,SEX,COMM
+2 SET DFN=$PIECE(NODE,U,1)
+3 SET NAME=$EXTRACT($$GET1^DIQ(2,$PIECE(NODE,U,1),.01),1,30)
+4 SET HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
+5 SET AGE=$$AGE^AUPNPAT(DFN,BGPED)
+6 SET COMM=$$GET1^DIQ(9000001,DFN,1118)
+7 SET SEX=$PIECE(^DPT(DFN,0),U,2)
+8 SET DEN=$PIECE(NODE,U,2)
SET NUM=$PIECE(NODE,U,3)
+9 SET X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_DEN_U_NUM
DO S^BGPMUDEL(X,1,1)
+10 QUIT
+11 ;Get printout for BP measure
BLOODP ;EP
+1 DO BP1
+2 KILL ^TMP("BGPMU0013",$JOB)
+3 QUIT
BP1 ;Write individual measure
+1 NEW X,Y,Z,DEN,NUM,PC,STRING1,STRING2,PRD,PRN,PRD1,PRN1
+2 SET STRING1=$$0013("C")
+3 SET STRING2=$$0013("P")
+4 SET STRING3=$$0013("B")
+5 DO SUMMARY2^BGPMUAP1(STRING1,STRING2,STRING3)
+6 SET PRD=$PIECE(STRING1,U,4)-$PIECE(STRING2,U,4)
IF PRD>0
SET PRD="+"_PRD
+7 SET PRD1=$PIECE(STRING1,U,5)-$PIECE(STRING2,U,5)
IF PRD1>0
SET PRD1="+"_PRD1
+8 SET PRN=$PIECE(STRING1,U,4)-$PIECE(STRING3,U,4)
IF PRN>0
SET PRN="+"_PRN
+9 SET PRN1=$PIECE(STRING1,U,5)-$PIECE(STRING3,U,5)
IF PRN1>0
SET PRN="+"_PRN1
+10 SET X=U_"REPORT PERIOD"_U_"%"_U_"PREV YR PERIOD"_U_"%"_U_"CHG FROM PREV YR"_U_"BASE YEAR"_U_"%"_U_"CHG FROM BASE"
+11 DO S^BGPMUDEL(X,2,1)
+12 SET X="Pts 18+ w/HTN"_U_$PIECE(STRING1,U,1)_U_U_$PIECE(STRING2,U,1)_U_U_U_$PIECE(STRING3,U,1)
DO S^BGPMUDEL(X,2,1)
+13 SET X="# w/=>2 BP recorded"_U_$PIECE(STRING1,U,2)_U_$PIECE(STRING1,U,4)_U_$PIECE(STRING2,U,2)_U_$PIECE(STRING2,U,4)_U_PRD_U_$PIECE(STRING3,U,2)_U_$PIECE(STRING3,U,4)_U_PRN
+14 DO S^BGPMUDEL(X,2,1)
+15 SET X="# w/o=> 2 BP recorded"_U_$PIECE(STRING1,U,3)_U_$PIECE(STRING1,U,5)_U_$PIECE(STRING2,U,3)_U_$PIECE(STRING2,U,5)_U_PRD1_U_$PIECE(STRING3,U,3)_U_$PIECE(STRING3,U,5)_U_PRN1
+16 DO S^BGPMUDEL(X,1,1)
+17 IF $DATA(BGPLIST(BGPIC))
DO BP2
+18 QUIT
0013(TF) ;Get the numbers for this measure
+1 NEW ARRAY,DEN,NUM,PC1,PC2,NOT
+2 SET DEN=+$GET(^TMP("BGPMU0013",$JOB,TF,"DEN"))
+3 SET NUM=+$GET(^TMP("BGPMU0013",$JOB,TF,"NUM"))
+4 SET NOT=+$GET(^TMP("BGPMU0013",$JOB,TF,"NOT"))
+5 IF DEN=0
SET (PC1,PC2)=0
+6 IF DEN>0
Begin DoDot:1
+7 SET PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
+8 SET PC2=$$ROUND^BGPMUA01((NOT/DEN),3)*100
End DoDot:1
+9 SET ARRAY=DEN_U_NUM_U_NOT_U_PC1_U_PC2
+10 QUIT ARRAY
BP2 ;Do the Details
+1 NEW PT,NODE,NAME,BP,PTCT
+2 SET X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT ****"
DO S^BGPMUDEL(X,2,1)
+3 SET X="Hypertensive patients 18+ with at least 2 encounters with the EP during the"
DO S^BGPMUDEL(X,1,1)
+4 SET X="reporting period, with => 2 documented BPs during the encounters, if any."
DO S^BGPMUDEL(X,1,1)
+5 SET X="Patients who do not meet the numerator criteria are listed first (NM:),"
DO S^BGPMUDEL(X,2,1)
+6 SET X="followed by patients who do meet the numerator criteria (M:)."
DO S^BGPMUDEL(X,1,1)
+7 SET X="The following are the abbreviations used in the denominator and numerator"
DO S^BGPMUDEL(X,2,1)
+8 SET X="columns: "
DO S^BGPMUDEL(X,1,1)
+9 SET X="EN=Encounter"
DO S^BGPMUDEL(X,1,1)
+10 SET PTCT=0
+11 SET X="Details for pts in numerator Age > 18"
DO S^BGPMUDEL(X,2,1)
+12 SET X="NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR"
DO S^BGPMUDEL(X,2,1)
+13 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+14 KILL BGPARR
+15 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0013"","_$JOB_",""PAT"",""C"",""NOT"")")
+16 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+17 SET PTCT=PTCT+1
+18 SET NODE=$GET(BGPARR(PT))
+19 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+20 IF BGPLIST="N"!(BGPLIST="A")
Begin DoDot:1
+21 KILL BGPARR
+22 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0013"","_$JOB_",""PAT"",""C"",""NUM"")")
+23 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+24 SET PTCT=PTCT+1
+25 SET NODE=$GET(BGPARR(PT))
+26 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+27 SET X="Total # of patients on list: "_PTCT
DO S^BGPMUDEL(X,2,1)
+28 QUIT
XML0421 ;XML output for adi;t BMI measure
+1 ; BGPXML(i)=Population Number^Numerator Number^Denominator Count
+2 NEW STRING,TOTN,TOTD,TOTE
+3 SET STRING=$$421("C")
+4 SET TOTD=$PIECE(STRING,U,1)+$PIECE(STRING,U,8)
+5 SET TOTN=$PIECE(STRING,U,2)+$PIECE(STRING,U,9)
+6 SET TOTE=$PIECE(STRING,U,4)+$PIECE(STRING,U,11)
+7 SET BGPXML(1)="128"_U_U_+TOTD_U_TOTN_U_TOTE
+8 KILL ^TMP("BGPMU0421",$JOB)
+9 QUIT
XML0013 ;XML output for hypertension measure
+1 ; BGPXML(i)=Population Number^Numerator Number^Denominator Count
+2 NEW STRING
+3 SET STRING=$$0013("C")
+4 SET BGPXML(1)="237"_U_U_+$PIECE(STRING,U,1)_U_+$PIECE(STRING,U,2)
+5 KILL ^TMP("BGPMU0013",$JOB)
+6 QUIT