BGPMUAP9 ; IHS/MSC/MGH - MU EP measure NQF0064 ;25-Jul-2011 10:34;DU
;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
;Get printout for Lipid control
LIPID ;EP
D LDL
K ^TMP("BGPMU0064",$J)
Q
LDL ;Write individual measure
N X,Y,Z,DEN,NUM,PC,STRING1,STRING2,PRD,PRD2,PRN,PRN1,PRN2,PRD1,PRD3,PRN3,PRN4,PRN5,PRD4,PRD5
S STRING1=$$NUM64("C")
S STRING2=$$NUM64("P")
S STRING3=$$NUM64("B")
D SUMMARY2(STRING1,STRING2,STRING3)
S PRD=$P(STRING1,U,4)-$P(STRING2,U,4)
S PRD1=$P(STRING1,U,5)-$P(STRING2,U,5)
S PRD2=$P(STRING1,U,7)-$P(STRING2,U,7)
S PRD3=$P(STRING1,U,9)-$P(STRING2,U,9)
S PRD4=$P(STRING1,U,11)-$P(STRING2,U,11)
S PRD5=$P(STRING1,U,13)-$P(STRING2,U,13)
S PRN=$P(STRING1,U,4)-$P(STRING3,U,4)
S PRN1=$P(STRING1,U,5)-$P(STRING3,U,5)
S PRN2=$P(STRING1,U,7)-$P(STRING3,U,7)
S PRN3=$P(STRING1,U,9)-$P(STRING3,U,9)
S PRN4=$P(STRING1,U,11)-$P(STRING3,U,11)
S PRN5=$P(STRING1,U,13)-$P(STRING3,U,13)
D HEADER^BGPMUPH Q:BGPQUIT
D HDRBLK^BGPMUPH
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !,"Pts 18-75 w/diabetes",?33,$P(STRING1,U,1),?44,$P(STRING2,U,1),?64,$P(STRING3,U,1)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !,"# Excluded (Exc)",?33,$P(STRING1,U,4),?44,$P(STRING2,U,4),?64,$P(STRING3,U,4)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !,"Pts 18-75 w/diabetes less Exc ",?33,$P(STRING1,U,3),?44,$P(STRING2,U,3),?64,$P(STRING3,U,3)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !!,"Numerator 1"
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !,"# w/LDL test result",?33,$P(STRING1,U,2),?38,$J($P(STRING1,U,5),5,1),?44,$P(STRING2,U,2),?49,$J($P(STRING2,U,5),5,1),?56,$J($FN(PRD1,",+",1),6),?64,$P(STRING3,U,2),?68,$J($P(STRING3,U,5),5,1),?74,$J($FN(PRN1,",+",1),6)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !,"# w/o LDL test result",?33,$P(STRING1,U,8),?38,$J($P(STRING1,U,9),5,1),?44,$P(STRING2,U,8),?49,$J($P(STRING2,U,9),5,1),?56,$J($FN(PRD3,",+",1),6),?64,$P(STRING3,U,8),?68,$J($P(STRING3,U,9),5,1),?74,$J($FN(PRN3,",+",1),6)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !!,"Numerator 2"
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !,"# w/LDL < 100mg/dL",?33,$P(STRING1,U,10),?38,$J($P(STRING1,U,11),5,1),?44,$P(STRING2,U,10),?49,$J($P(STRING2,U,11),5,1),?56,$J($FN(PRD4,",+"),6),?64,$P(STRING3,U,2),?68,$J($P(STRING3,U,5),5,1),?74,$J($FN(PRN4,",+",1),6)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH,HDRBLK^BGPMUPH Q:BGPQUIT
W !,"# w/o LDL or LDL => 100mg/dL",?33,$P(STRING1,U,12),?38,$J($P(STRING1,U,13),5,1),?44,$P(STRING2,U,12),?49,$J($P(STRING2,U,13),5,1),?56,$J($FN(PRD5,",+",1),6),?64,$P(STRING3,U,12),?68,$J($P(STRING3,U,13),5,1),?74,$J($FN(PRN5,",+",1),6)
I $D(BGPLIST(BGPIC)) D LDL2
Q
NUM64(TF) ;Get the numbers for this measure
N ARRAY,DEN1,NUM1,PC1,PC2,NOT,NNUM1,EXC,PC3,PC4,NUM2,NOT1,NOT2,PC5,PC6
S DEN=+$G(^TMP("BGPMU0064",$J,TF,"DEN"))
S NUM1=+$G(^TMP("BGPMU0064",$J,TF,"NUM1"))
S NOT1=+$G(^TMP("BGPMU0064",$J,TF,"NOT1"))
S EXC=+$G(^TMP("BGPMU0064",$J,TF,"EXC"))
S NUM2=+$G(^TMP("BGPMU0064",$J,TF,"NUM2"))
S NOT2=+$G(^TMP("BGPMU0064",$J,TF,"NOT2"))
S NNUM=DEN-EXC
I DEN=0 S (PC1,PC2,PC3,PC4,PC5,PC6)=0
I DEN>0&(NNUM=0) D
.S (PC4,PC6)=0
.S PC3=$$ROUND^BGPMUA01((EXC/DEN),3)*100
.S PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
.S PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
.S PC5=$$ROUND^BGPMUA01((NUM2/DEN),3)*100
I DEN>0 D
.S PC1=$$ROUND^BGPMUA01((NUM1/DEN),3)*100
.S PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
.S PC3=$$ROUND^BGPMUA01((EXC/DEN),3)*100
.S PC4=$$ROUND^BGPMUA01((NOT1/NNUM),3)*100
.S PC5=$$ROUND^BGPMUA01((NUM2/DEN),3)*100
.S PC6=$$ROUND^BGPMUA01((NOT2/NNUM),3)*100
S ARRAY=DEN_U_NUM1_U_NNUM_U_EXC_U_PC1_U_PC2_U_PC3_U_NOT1_U_PC4_U_NUM2_U_PC5_U_NOT2_U_PC6
Q ARRAY
LDL2 ;Do the Details
N PT,NODE,NAME,BP,PTCT,BGPARR,LINE
D HEADERL^BGPMUPH
S X="Diabetic patients 18-75 years of age with at least 1 or 2 encounters with the EP" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="during the reporting period, who had LDL-C < 100mg/dL, if any." D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="Patients who do not meet the numerator criteria are listed first (NM:), followed" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="by patients who do meet the numerator criteria (M:). Excluded patients" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="are listed last." D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="The following are the abbreviations used in the denominator and numerator " D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="columns:" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="ICD=Diabetes Diagnosis" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="MED=Medication Indicative of Diabetes" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="EN=Encounter" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="" D W^BGPMUPP(X,0,1,BGPPTYPE)
S PTCT=0
I $Y>(BGPIOSL-6) D HEADERL^BGPMUPH Q:BGPQUIT
W !,"Numerator 1: Patients with LDL-C Test"
W !!,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?65,"NUMERATOR"
S LINE="",$P(LINE,"-",81)="" W !,LINE
I BGPLIST="D"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$J_",""PAT"",""C"",""NOT1"")")
.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(""BGPMU0064"","_$J_",""PAT"",""C"",""NUM1"")")
.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="A" D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$J_",""PAT"",""C"",""EXC"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA2(NODE)
W !!,"Total # of patients on list: "_PTCT
I $Y>(BGPIOSL-5) D HEADERL^BGPMUPH Q:BGPQUIT
W !!,"Numerator 2: Patients with LDL-C Test Result < 100mg/dL"
W !!,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?65,"NUMERATOR"
S PTCT=0
S LINE="",$P(LINE,"-",81)="" W !,LINE
I BGPLIST="D"!(BGPLIST="A") D
.K BGPARR
.S PTCT=0
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$J_",""PAT"",""C"",""NOT2"")")
.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(""BGPMU0064"","_$J_",""PAT"",""C"",""NUM2"")")
.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="A" D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$J_",""PAT"",""C"",""EXC"")")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA2(NODE)
W !!,"Total # of patients on list: "_PTCT
Q
DATA2(NODE) ;GET DATA
N NAME,HRN,DEN,SEX,COMM,DEN1,DEN2,DEN3,NUM1,NUM2,LINE
S DFN=$P(NODE,U,1)
S NAME=$E($$GET1^DIQ(2,$P(NODE,U,1),.01),1,18)
S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
S AGE=$$AGE^AUPNPAT(DFN,BGPED)
S SEX=$P(^DPT(DFN,0),U,2)
S COMM=$E($$GET1^DIQ(9000001,DFN,1118),1,11)
S DEN=$P(NODE,U,2)
S DEN1=$P(DEN,";",1),DEN2=$P(DEN,";",2),DEN3=$P(DEN,";",3)
S NUM=$P(NODE,U,3)
S NUM1=$P(NUM,";",1),NUM2=$$DATE($P($P(NUM,";",2),".",1))
I $Y>(BGPIOSL-2) D
.D HEADERL^BGPMUPH Q:BGPQUIT
.W !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?65,"NUMERATOR"
.S LINE="",$P(LINE,"-",81)="" W !,LINE
W !,NAME,?23,HRN,?30,COMM,?43,SEX,?46,AGE,?50,DEN1,?65,NUM1
I DEN2'="" D
.W !,?50,DEN2,?65,NUM2
I DEN3'="" D
.W !,?50,DEN3
Q
SUMMARY2(STRING1,STRING2,STRING3) ;Summary setup
N DESC
K ^TMP("BGPMU SUMMARY",$J,BGPIC)
S ^TMP("BGPMU SUMMARY",$J,BGPIC)="0064^2"
S DESC="18-75 # w/LDL test result"
S LINE="MU.EP.0064.1"_U_DESC_U_$P(STRING1,U,4)_U_$P(STRING1,U,1)_U_$P(STRING1,U,2)_U_$P(STRING1,U,5)_U_U_U_U_U
S LINE=LINE_$P(STRING2,U,4)_U_$P(STRING2,U,1)_U_$P(STRING2,U,2)_U_$P(STRING2,U,5)_U_$P(STRING3,U,4)_U_$P(STRING3,U,1)_U_$P(STRING3,U,2)_U_$P(STRING3,U,5)
S ^TMP("BGPMU SUMMARY",$J,BGPIC,1)=LINE
S DESC="18-75 # w/LDL < 100mg/dl"
S LINE="MU.EP.0064.1"_U_DESC_U_$P(STRING1,U,4)_U_$P(STRING1,U,1)_U_$P(STRING1,U,10)_U_$P(STRING1,U,11)_U_U_U_U_U
S LINE=LINE_$P(STRING2,U,4)_U_$P(STRING2,U,1)_U_$P(STRING2,U,10)_U_$P(STRING2,U,11)_U_$P(STRING3,U,4)_U_$P(STRING3,U,1)_U_$P(STRING3,U,10)_U_$P(STRING3,U,11)
S ^TMP("BGPMU SUMMARY",$J,BGPIC,2)=LINE
Q
DATE(D) ;EP
I D="" Q ""
Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_$E(D,2,3)
BGPMUAP9 ; IHS/MSC/MGH - MU EP measure NQF0064 ;25-Jul-2011 10:34;DU
+1 ;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
+2 ;Get printout for Lipid control
LIPID ;EP
+1 DO LDL
+2 KILL ^TMP("BGPMU0064",$JOB)
+3 QUIT
LDL ;Write individual measure
+1 NEW X,Y,Z,DEN,NUM,PC,STRING1,STRING2,PRD,PRD2,PRN,PRN1,PRN2,PRD1,PRD3,PRN3,PRN4,PRN5,PRD4,PRD5
+2 SET STRING1=$$NUM64("C")
+3 SET STRING2=$$NUM64("P")
+4 SET STRING3=$$NUM64("B")
+5 DO SUMMARY2(STRING1,STRING2,STRING3)
+6 SET PRD=$PIECE(STRING1,U,4)-$PIECE(STRING2,U,4)
+7 SET PRD1=$PIECE(STRING1,U,5)-$PIECE(STRING2,U,5)
+8 SET PRD2=$PIECE(STRING1,U,7)-$PIECE(STRING2,U,7)
+9 SET PRD3=$PIECE(STRING1,U,9)-$PIECE(STRING2,U,9)
+10 SET PRD4=$PIECE(STRING1,U,11)-$PIECE(STRING2,U,11)
+11 SET PRD5=$PIECE(STRING1,U,13)-$PIECE(STRING2,U,13)
+12 SET PRN=$PIECE(STRING1,U,4)-$PIECE(STRING3,U,4)
+13 SET PRN1=$PIECE(STRING1,U,5)-$PIECE(STRING3,U,5)
+14 SET PRN2=$PIECE(STRING1,U,7)-$PIECE(STRING3,U,7)
+15 SET PRN3=$PIECE(STRING1,U,9)-$PIECE(STRING3,U,9)
+16 SET PRN4=$PIECE(STRING1,U,11)-$PIECE(STRING3,U,11)
+17 SET PRN5=$PIECE(STRING1,U,13)-$PIECE(STRING3,U,13)
+18 DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+19 DO HDRBLK^BGPMUPH
+20 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+21 WRITE !,"Pts 18-75 w/diabetes",?33,$PIECE(STRING1,U,1),?44,$PIECE(STRING2,U,1),?64,$PIECE(STRING3,U,1)
+22 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+23 WRITE !,"# Excluded (Exc)",?33,$PIECE(STRING1,U,4),?44,$PIECE(STRING2,U,4),?64,$PIECE(STRING3,U,4)
+24 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+25 WRITE !,"Pts 18-75 w/diabetes less Exc ",?33,$PIECE(STRING1,U,3),?44,$PIECE(STRING2,U,3),?64,$PIECE(STRING3,U,3)
+26 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+27 WRITE !!,"Numerator 1"
+28 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+29 WRITE !,"# w/LDL test result",?33,$PIECE(STRING1,U,2),?38,$JUSTIFY($PIECE(STRING1,U,5),5,1),?44,$PIECE(STRING2,U,2),?49,$JUSTIFY($PIECE(STRING2,U,5),5,1),?56,...
... $JUSTIFY($FNUMBER(PRD1,",+",1),6),?64,$PIECE(STRING3,U,2),?68,$JUSTIFY($PIECE(STRING3,U,5),5,1),?74,$JUSTIFY($FNUMBER(PRN1,",+",1),6)
+30 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+31 WRITE !,"# w/o LDL test result",?33,$PIECE(STRING1,U,8),?38,$JUSTIFY($PIECE(STRING1,U,9),5,1),?44,$PIECE(STRING2,U,8),?49,$JUSTIFY(...
... $PIECE(STRING2,U,9),5,1),?56,$JUSTIFY($FNUMBER(PRD3,",+",1),6),?64,$PIECE(STRING3,U,8),?68,$JUSTIFY($PIECE(STRING3,U,9),5,1),?74,$JUSTIFY($FNUMBER(PRN3,",+",1),6)
+32 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+33 WRITE !!,"Numerator 2"
+34 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+35 WRITE !,"# w/LDL < 100mg/dL",?33,$PIECE(STRING1,U,10),?38,$JUSTIFY($PIECE(STRING1,U,11),5,1),?44,$PIECE(STRING2,U,10),?49,$JUSTIFY(...
... $PIECE(STRING2,U,11),5,1),?56,$JUSTIFY($FNUMBER(PRD4,",+"),6),?64,$PIECE(STRING3,U,2),?68,$JUSTIFY($PIECE(STRING3,U,5),5,1),?74,$JUSTIFY($FNUMBER(PRN4,",+",1),6)
+36 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
DO HDRBLK^BGPMUPH
IF BGPQUIT
QUIT
+37 WRITE !,"# w/o LDL or LDL => 100mg/dL",?33,$PIECE(STRING1,U,12),?38,$JUSTIFY(...
... $PIECE(STRING1,U,13),5,1),?44,$PIECE(STRING2,U,12),?49,$JUSTIFY($PIECE(STRING2,U,13),5,1),?56,$JUSTIFY($FNUMBER(PRD5,",+",1),6),?64,$PIECE(STRING3,U,12),?68,$JUSTIFY($PIECE(STRING3,U,13),5,1),?74,$JUSTIFY($FNUMBER(PRN5,",+",1),6)
+38 IF $DATA(BGPLIST(BGPIC))
DO LDL2
+39 QUIT
NUM64(TF) ;Get the numbers for this measure
+1 NEW ARRAY,DEN1,NUM1,PC1,PC2,NOT,NNUM1,EXC,PC3,PC4,NUM2,NOT1,NOT2,PC5,PC6
+2 SET DEN=+$GET(^TMP("BGPMU0064",$JOB,TF,"DEN"))
+3 SET NUM1=+$GET(^TMP("BGPMU0064",$JOB,TF,"NUM1"))
+4 SET NOT1=+$GET(^TMP("BGPMU0064",$JOB,TF,"NOT1"))
+5 SET EXC=+$GET(^TMP("BGPMU0064",$JOB,TF,"EXC"))
+6 SET NUM2=+$GET(^TMP("BGPMU0064",$JOB,TF,"NUM2"))
+7 SET NOT2=+$GET(^TMP("BGPMU0064",$JOB,TF,"NOT2"))
+8 SET NNUM=DEN-EXC
+9 IF DEN=0
SET (PC1,PC2,PC3,PC4,PC5,PC6)=0
+10 IF DEN>0&(NNUM=0)
Begin DoDot:1
+11 SET (PC4,PC6)=0
+12 SET PC3=$$ROUND^BGPMUA01((EXC/DEN),3)*100
+13 SET PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
+14 SET PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
+15 SET PC5=$$ROUND^BGPMUA01((NUM2/DEN),3)*100
End DoDot:1
+16 IF DEN>0
Begin DoDot:1
+17 SET PC1=$$ROUND^BGPMUA01((NUM1/DEN),3)*100
+18 SET PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
+19 SET PC3=$$ROUND^BGPMUA01((EXC/DEN),3)*100
+20 SET PC4=$$ROUND^BGPMUA01((NOT1/NNUM),3)*100
+21 SET PC5=$$ROUND^BGPMUA01((NUM2/DEN),3)*100
+22 SET PC6=$$ROUND^BGPMUA01((NOT2/NNUM),3)*100
End DoDot:1
+23 SET ARRAY=DEN_U_NUM1_U_NNUM_U_EXC_U_PC1_U_PC2_U_PC3_U_NOT1_U_PC4_U_NUM2_U_PC5_U_NOT2_U_PC6
+24 QUIT ARRAY
LDL2 ;Do the Details
+1 NEW PT,NODE,NAME,BP,PTCT,BGPARR,LINE
+2 DO HEADERL^BGPMUPH
+3 SET X="Diabetic patients 18-75 years of age with at least 1 or 2 encounters with the EP"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+4 SET X="during the reporting period, who had LDL-C < 100mg/dL, if any."
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+5 SET X=""
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+6 SET X="Patients who do not meet the numerator criteria are listed first (NM:), followed"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+7 SET X="by patients who do meet the numerator criteria (M:). Excluded patients"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+8 SET X="are listed last."
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+9 SET X=""
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+10 SET X="The following are the abbreviations used in the denominator and numerator "
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+11 SET X="columns:"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+12 SET X="ICD=Diabetes Diagnosis"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+13 SET X="MED=Medication Indicative of Diabetes"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+14 SET X="EN=Encounter"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+15 SET X=""
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+16 SET PTCT=0
+17 IF $Y>(BGPIOSL-6)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+18 WRITE !,"Numerator 1: Patients with LDL-C Test"
+19 WRITE !!,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?65,"NUMERATOR"
+20 SET LINE=""
SET $PIECE(LINE,"-",81)=""
WRITE !,LINE
+21 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+22 KILL BGPARR
+23 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$JOB_",""PAT"",""C"",""NOT1"")")
+24 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+25 SET PTCT=PTCT+1
+26 SET NODE=$GET(BGPARR(PT))
+27 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+28 IF BGPLIST="N"!(BGPLIST="A")
Begin DoDot:1
+29 KILL BGPARR
+30 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$JOB_",""PAT"",""C"",""NUM1"")")
+31 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+32 SET PTCT=PTCT+1
+33 SET NODE=$GET(BGPARR(PT))
+34 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+35 IF BGPLIST="A"
Begin DoDot:1
+36 KILL BGPARR
+37 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$JOB_",""PAT"",""C"",""EXC"")")
+38 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+39 SET PTCT=PTCT+1
+40 SET NODE=$GET(BGPARR(PT))
+41 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+42 WRITE !!,"Total # of patients on list: "_PTCT
+43 IF $Y>(BGPIOSL-5)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+44 WRITE !!,"Numerator 2: Patients with LDL-C Test Result < 100mg/dL"
+45 WRITE !!,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?65,"NUMERATOR"
+46 SET PTCT=0
+47 SET LINE=""
SET $PIECE(LINE,"-",81)=""
WRITE !,LINE
+48 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+49 KILL BGPARR
+50 SET PTCT=0
+51 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$JOB_",""PAT"",""C"",""NOT2"")")
+52 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+53 SET PTCT=PTCT+1
+54 SET NODE=$GET(BGPARR(PT))
+55 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+56 IF BGPLIST="N"!(BGPLIST="A")
Begin DoDot:1
+57 KILL BGPARR
+58 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$JOB_",""PAT"",""C"",""NUM2"")")
+59 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+60 SET PTCT=PTCT+1
+61 SET NODE=$GET(BGPARR(PT))
+62 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+63 IF BGPLIST="A"
Begin DoDot:1
+64 KILL BGPARR
+65 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0064"","_$JOB_",""PAT"",""C"",""EXC"")")
+66 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+67 SET PTCT=PTCT+1
+68 SET NODE=$GET(BGPARR(PT))
+69 DO DATA2(NODE)
End DoDot:2
End DoDot:1
+70 WRITE !!,"Total # of patients on list: "_PTCT
+71 QUIT
DATA2(NODE) ;GET DATA
+1 NEW NAME,HRN,DEN,SEX,COMM,DEN1,DEN2,DEN3,NUM1,NUM2,LINE
+2 SET DFN=$PIECE(NODE,U,1)
+3 SET NAME=$EXTRACT($$GET1^DIQ(2,$PIECE(NODE,U,1),.01),1,18)
+4 SET HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
+5 SET AGE=$$AGE^AUPNPAT(DFN,BGPED)
+6 SET SEX=$PIECE(^DPT(DFN,0),U,2)
+7 SET COMM=$EXTRACT($$GET1^DIQ(9000001,DFN,1118),1,11)
+8 SET DEN=$PIECE(NODE,U,2)
+9 SET DEN1=$PIECE(DEN,";",1)
SET DEN2=$PIECE(DEN,";",2)
SET DEN3=$PIECE(DEN,";",3)
+10 SET NUM=$PIECE(NODE,U,3)
+11 SET NUM1=$PIECE(NUM,";",1)
SET NUM2=$$DATE($PIECE($PIECE(NUM,";",2),".",1))
+12 IF $Y>(BGPIOSL-2)
Begin DoDot:1
+13 DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+14 WRITE !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?65,"NUMERATOR"
+15 SET LINE=""
SET $PIECE(LINE,"-",81)=""
WRITE !,LINE
End DoDot:1
+16 WRITE !,NAME,?23,HRN,?30,COMM,?43,SEX,?46,AGE,?50,DEN1,?65,NUM1
+17 IF DEN2'=""
Begin DoDot:1
+18 WRITE !,?50,DEN2,?65,NUM2
End DoDot:1
+19 IF DEN3'=""
Begin DoDot:1
+20 WRITE !,?50,DEN3
End DoDot:1
+21 QUIT
SUMMARY2(STRING1,STRING2,STRING3) ;Summary setup
+1 NEW DESC
+2 KILL ^TMP("BGPMU SUMMARY",$JOB,BGPIC)
+3 SET ^TMP("BGPMU SUMMARY",$JOB,BGPIC)="0064^2"
+4 SET DESC="18-75 # w/LDL test result"
+5 SET LINE="MU.EP.0064.1"_U_DESC_U_$PIECE(STRING1,U,4)_U_$PIECE(STRING1,U,1)_U_$PIECE(STRING1,U,2)_U_$PIECE(STRING1,U,5)_U_U_U_U_U
+6 SET LINE=LINE_$PIECE(STRING2,U,4)_U_$PIECE(STRING2,U,1)_U_$PIECE(STRING2,U,2)_U_$PIECE(STRING2,U,5)_U_$PIECE(STRING3,U,4)_U_$PIECE(STRING3,U,1)_U_$PIECE(STRING3,U,2)_U_$PIECE(STRING3,U,5)
+7 SET ^TMP("BGPMU SUMMARY",$JOB,BGPIC,1)=LINE
+8 SET DESC="18-75 # w/LDL < 100mg/dl"
+9 SET LINE="MU.EP.0064.1"_U_DESC_U_$PIECE(STRING1,U,4)_U_$PIECE(STRING1,U,1)_U_$PIECE(STRING1,U,10)_U_$PIECE(STRING1,U,11)_U_U_U_U_U
+10 SET LINE=LINE_$PIECE(STRING2,U,4)_U_$PIECE(STRING2,U,1)_U_$PIECE(STRING2,U,10)_U_$PIECE(STRING2,U,11)_U_$PIECE(STRING3,U,4)_U_$PIECE(STRING3,U,1)_U_$PIECE(STRING3,U,10)_U_$PIECE(STRING3,U,11)
+11 SET ^TMP("BGPMU SUMMARY",$JOB,BGPIC,2)=LINE
+12 QUIT
DATE(D) ;EP
+1 IF D=""
QUIT ""
+2 QUIT $EXTRACT(D,4,5)_"/"_$EXTRACT(D,6,7)_"/"_$EXTRACT(D,2,3)