BGPMUDP1 ; IHS/MSC/SAT - Print MU EP measure NQF0028b ;02-Mar-2011 10:55;DU
;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
;This routine does the printed output of these 2 EP measures
TOB ;EP
D P1
K ^TMP("BGPMU0028B",$J)
Q
P1 ;Write individual measure
N J,X,Y,Z,LIST1,LIST2,LIST3
N BGPPTYPE,DEN1,NUM1,PC1,STRING1,STRING2,STRING3,PRD1,PRD2,PRB1,PRB2
S J=$J
S BGPPTYPE="P"
S STRING1=$$G28B("C")
S STRING2=$$G28B("P")
S STRING3=$$G28B("B")
S PRD1=$P(STRING1,U,7)-$P(STRING2,U,7)
S PRD2=$P(STRING1,U,8)-$P(STRING2,U,8)
S PRB1=$P(STRING1,U,7)-$P(STRING3,U,7)
S PRB2=$P(STRING1,U,8)-$P(STRING3,U,8)
D HEADER^BGPMUPH Q:BGPQUIT
D HDRBLK^BGPMUPH
W !,"Pts 18+/Tobacco user/24mos",?33,$P(STRING1,U,1),?44,$P(STRING2,U,1),?64,$P(STRING3,U,1)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
W !!,"# w/cess counsel/agent/24 mos",?33,$P(STRING1,U,2),?38,$J($P(STRING1,U,7),5,1),?44,$P(STRING2,U,2),?49,$J($P(STRING2,U,7),5,1),?56,$J($FN(PRD1,",+",1),6),?64,$P(STRING3,U,2),?68,$J($P(STRING3,U,7),5,1),?74,$J($FN(PRB1,",+",1),6)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
W !,"# w/o cess counsel/agent/24 mos",?33,$P(STRING1,U,3),?38,$J($P(STRING1,U,8),5,1),?44,$P(STRING2,U,3),?49,$J($P(STRING2,U,8),5,1),?56,$J($FN(PRD2,",+",1),6),?64,$P(STRING3,U,3),?68,$J($P(STRING3,U,8),5,1),?74,$J($FN(PRB2,",+",1),6)
I $D(BGPLIST(BGPIC)) D P2
D SUM28B
Q
G28B(BGPMUTF) ;Get the numbers for this measure
N ARRAY,N
S J=$J
S DEN1=+$G(^TMP("BGPMU0028B",J,BGPMUTF,"DEN",1))
S NUM1=+$G(^TMP("BGPMU0028B",J,BGPMUTF,"INCL",1))
S NONUM=+$G(^TMP("BGPMU0028B",J,BGPMUTF,"NOT",1))
I DEN1=0 S (PC1,PC2)=0
I DEN1>0 D
.S PC1=$$ROUND^BGPMUA01((NUM1/DEN1),3)*100
.S PC2=$$ROUND^BGPMUA01((NONUM/DEN1),3)*100
S ARRAY=DEN1_U_NUM1_U_NONUM_U_""_U_""_U_""_U_PC1_U_PC2
Q ARRAY
P2 ;Do the Details
N J,PT,NODE,NAME,VST,BMI,FOL,X,BGPARR
S J=$J
D HEADERL^BGPMUPH Q:BGPQUIT
S X="Patients 18+ with at least 1 or 2 encounters with the EP during the reporting" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="period and who have been identified as tobacco users within the last 24 months," D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="with documented cessation intervention, if any." 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,2,BGPPTYPE)
S X="by patients who do meet the numerator criteria (M:)." D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="The following are the abbreviations used in the denominator column:" D W^BGPMUPP(X,0,2,BGPPTYPE)
S X="EN=Encounter" D W^BGPMUPP(X,0,1,BGPPTYPE)
S X="HF=Tobacco User Health Factor" D W^BGPMUPP(X,0,1,BGPPTYPE)
W !!,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
S LINE="",$P(LINE,"-",81)="" W !,LINE
S PTCT=0
I BGPLIST="D"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0028B"","_$J_",""C"",""NOT"",""PAT"",1)")
.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(""BGPMU0028B"","_$J_",""C"",""INCL"",""PAT"",1)")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA(NODE)
W !!,"Total # of patients on list: "_PTCT
Q
DATA(NODE) ;GET DATA
N AGE,DEN,DFN,COMM,HRN,NAME,NUM,SEX
S DFN=$P(NODE,U,1)
S NAME=$E($$GET1^DIQ(2,$P(NODE,U,1),.01),1,22)
S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
S AGE=$$AGE^AUPNPAT(DFN,BGPED)
S SEX=$$SEX^AUPNPAT(DFN)
S COMM=$E($$GET1^DIQ(9000001,DFN,1118),1,11)
S DEN=$P(NODE,U,2)
S NUM=$P(NODE,U,3)
I $Y>(BGPIOSL-2) D
.D HEADER^BGPMUPH Q:BGPQUIT
.W !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
.S LINE="",$P(LINE,"-",81)="" W !,LINE
; line 1
W !,NAME,?23,HRN,?30,COMM,?42,SEX,?46,AGE
W ?50,$S($P($P(DEN,":",1),";",1)'="":"EN:"_$P($$FMTE^XLFDT($P($P(DEN,":",1),";",1),2),"@",1)_$S($L($P(DEN,":",1),";")>1:";",1:""),1:"")
W ?63,$S(NUM'="":"M:"_$P(NUM,";",1)_" "_$$FMTE^XLFDT($P(NUM,";",2),2),1:"NM:")
;line 2
S BGPTMP=$S($P($P(DEN,":",1),";",2)'="":"EN",1:"HF")
W !,?50,$S(BGPTMP="EN":"EN:"_$P($$FMTE^XLFDT($P($P(DEN,":",1),";",2),2),"@",1),1:"HF:"_$P($$FMTE^XLFDT($P(DEN,":",2),2),"@",1))
;possible line 3
I BGPTMP="EN" W !,?50,"HF:"_$P($$FMTE^XLFDT($P(DEN,":",2),2),"@",1)
Q
;
TOB2 ;Tobacco print
D P1A
K ^TMP("BGPMU0028A",$J)
Q
P1A ;Write individual measure
N BGPPTYPE,X,Y,Z,LIST1,LIST2,LIST3
N DEN1,NUM1,PC1,STRING1,STRING2,STRING3,PRD1,PRD2,PRB1,PRB2,NONUM
N LINE
S BGPPTYPE="P"
S STRING1=$$G28A("C")
S STRING2=$$G28A("P")
S STRING3=$$G28A("B")
S PRD1=$P(STRING1,U,7)-$P(STRING2,U,7)
S PRD2=$P(STRING1,U,8)-$P(STRING2,U,8)
S PRB1=$P(STRING1,U,7)-$P(STRING3,U,7)
S PRB2=$P(STRING1,U,8)-$P(STRING3,U,8)
D HEADER^BGPMUPH Q:BGPQUIT
D HDRBLK^BGPMUPH
W !,"Pts 18+",?33,$P(STRING1,U,1),?44,$P(STRING2,U,1),?64,$P(STRING3,U,1)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
W !!,"# w/tob screen-24 mos",?33,$P(STRING1,U,2),?38,$J($P(STRING1,U,7),5,1),?44,$P(STRING2,U,2),?49,$J($P(STRING2,U,7),5,1),?56,$J($FN(PRD1,",+",1),6),?64,$P(STRING3,U,2),?68,$J($P(STRING3,U,7),5,1),?74,$J($FN(PRB1,",+",1),6)
I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
W !,"# w/o tob screen-24 mos",?33,$P(STRING1,U,3),?38,$J($P(STRING1,U,8),5,1),?44,$P(STRING2,U,3),?49,$J($P(STRING2,U,8),5,1),?56,$J($FN(PRD2,",+",1),6),?64,$P(STRING3,U,3),?68,$J($P(STRING3,U,8),5,1),?74,$J($FN(PRB2,",+",1),6)
I $D(BGPLIST(BGPIC)) D P2A
D SUM28A
Q
G28A(BGPMUTF) ;Get the numbers for this measure
N ARRAY,DEN1,NONUM,NUM1,PC1
S DEN1=+$G(^TMP("BGPMU0028A",$J,BGPMUTF,"DEN",1))
S NUM1=+$G(^TMP("BGPMU0028A",$J,BGPMUTF,"INCL",1))
S NONUM=+$G(^TMP("BGPMU0028A",$J,BGPMUTF,"NOT",1))
I DEN1=0 S (PC1,PC2)=0
I DEN1>0 D
.S PC1=$$ROUND^BGPMUA01((NUM1/DEN1),3)*100
.S PC2=$$ROUND^BGPMUA01((NONUM/DEN1),3)*100
S ARRAY=DEN1_U_NUM1_U_NONUM_U_""_U_""_U_""_U_PC1_U_PC2
Q ARRAY
P2A ;Do the Details
N PT,NODE,NAME,VST,BMI,FOL,X,BGPARR,PTCT,LINE
D HEADERL^BGPMUPH Q:BGPQUIT
W !,"Patients 18+ with at least 1 or 2 encounters with the EP during the reporting "
W !,"period, with documented tobacco screening within 24 months, if any."
W !
W !,"Patients who do not meet the numerator criteria are listed first (NM:), followed"
W !,"by patients who do meet the numerator criteria (M:)."
W !
W !,"The following are the abbreviations used in the denominator column:"
W !,"EN=Encounter"
W !
W !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
S LINE="",$P(LINE,"-",81)="" W !,LINE
S PTCT=0
I BGPLIST="D"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0028A"","_$J_",""C"",""NOT"",""PAT"",1)")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA3(NODE)
I BGPLIST="N"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0028A"","_$J_",""C"",""INCL"",""PAT"",1)")
.S PT=0 F S PT=$O(BGPARR(PT)) Q:PT="" D
..S PTCT=PTCT+1
..S NODE=$G(BGPARR(PT))
..D DATA3(NODE)
W !!,"Total # of patients on list: "_PTCT
Q
DATA3(NODE) ;GET DATA
N AGE,DEN,DFN,COMM,HRN,NAME,NUM,SEX
S DFN=$P(NODE,U,1)
S NAME=$E($$GET1^DIQ(2,$P(NODE,U,1),.01),1,22)
S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
S AGE=$$AGE^AUPNPAT(DFN,BGPED)
S SEX=$$SEX^AUPNPAT(DFN)
S COMM=$E($$GET1^DIQ(9000001,DFN,1118),1,11)
S DEN=$P(NODE,U,2)
S NUM=$P(NODE,U,3)
I $Y>(BGPIOSL-2) D
.D HEADERL^BGPMUPH Q:BGPQUIT
.W !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
.S LINE="",$P(LINE,"-",81)="" W !,LINE
W !,NAME,?23,HRN,?30,COMM,?42,SEX,?46,AGE,?50,$S($P(DEN,";",1)'="":"EN:"_$P($$FMTE^XLFDT($P(DEN,";",1),2),"@",1)_$S($L(DEN,";")>1:";",1:""),1:""),?63,$S(NUM'="":"M:"_$E($P(NUM,";",1),1,15),1:"NM:")
I ($L(DEN,";")>1)!($L(NUM,";")>1) W !,?50,$S($P(DEN,";",2)'="":"EN:"_$P($$FMTE^XLFDT($P(DEN,";",2),2),"@",1),1:""),?65,$S($P(NUM,";",2)'="":$P($$FMTE^XLFDT($P(NUM,";",2),2),"@",1),1:"")
Q
;
XML28A ;Populate the BGPXML array with data for each population/numerator
; BGPXMLOUT(i)=Population Number^Numerator Number^Denominator Count^Numerator Count^Exclusion Count
S BGPXML(1)="114"_U_""_U_+$G(^TMP("BGPMU0028A",$J,"C","DEN",1))_U_+$G(^TMP("BGPMU0028A",$J,"C","INCL",1))
K ^TMP("BGPMU0028A",$J)
Q
;
XML28B ;Populate the BGPXML array with data for each population/numerator
; BGPXMLOUT(i)=Population Number^Numerator Number^Denominator Count^Numerator Count^Exclusion Count
S BGPXML(1)="115"_U_""_U_+$G(^TMP("BGPMU0028B",$J,"C","DEN",1))_U_+$G(^TMP("BGPMU0028B",$J,"C","INCL",1))
K ^TMP("BGPMU0028B",$J)
Q
;
SUM28A ;Populate "BGPMU SUMMARY" for Tobacco Assessment
;Initialize iCare/summary global
N BGPDNCNT,BGPSSTR,J,N
S BGPDNCNT=0
K ^TMP("BGPMU SUMMARY",$J,BGPIC)
S ^TMP("BGPMU SUMMARY",$J,BGPIC)="0028a"_U_"114"
S N=1 ;only 1 numerator
;Setup summary page/iCare ^TMP global
S CDEN1CT=+$G(^TMP("BGPMU0028A",$J,"C","DEN",N)) ;current
S CNUM1CT=+$G(^TMP("BGPMU0028A",$J,"C","INCL",N))
S CMP=$S(CDEN1CT>0:$$ROUND^BGPMUA01(CNUM1CT/CDEN1CT,3)*100,1:0)
S PDEN1CT=+$G(^TMP("BGPMU0028A",$J,"P","DEN",N)) ;previous
S PNUM1CT=+$G(^TMP("BGPMU0028A",$J,"P","INCL",N))
S PMP=$S(PDEN1CT>0:$$ROUND^BGPMUA01(PNUM1CT/PDEN1CT,3)*100,1:0)
S BDEN1CT=+$G(^TMP("BGPMU0028A",$J,"B","DEN",N)) ;baseline
S BNUM1CT=+$G(^TMP("BGPMU0028A",$J,"B","INCL",N))
S BMP=$S(BDEN1CT>0:$$ROUND^BGPMUA01(BNUM1CT/BDEN1CT,3)*100,1:0)
S BGPDNCNT=BGPDNCNT+1
S BGPSSTR="MU.EP.0028A."_N_U_"18+ screening w/in 24 mos"_U_0_U_CDEN1CT_U_CNUM1CT_U_CMP_U_U_U_U
; 11 12 13 14
S BGPSSTR=BGPSSTR_U_""_U_PDEN1CT_U_PNUM1CT_U_PMP
; 15 16 17 18
S BGPSSTR=BGPSSTR_U_""_U_BDEN1CT_U_BNUM1CT_U_BMP
S ^TMP("BGPMU SUMMARY",$J,BGPIC,BGPDNCNT)=BGPSSTR
Q
;
SUM28B ;Populate "BGPMU SUMMARY" for Tobacco Cessation
;Initialize iCare/summary global
N BGPDNCNT,BGPSSTR,J,N
S BGPDNCNT=0
K ^TMP("BGPMU SUMMARY",$J,BGPIC)
S ^TMP("BGPMU SUMMARY",$J,BGPIC)="0028b"_U_"115"
S N=1 ;only 1 numerator
;Setup summary page/iCare ^TMP global
S CDEN1CT=+$G(^TMP("BGPMU0028B",$J,"C","DEN",N)) ;current
S CNUM1CT=+$G(^TMP("BGPMU0028B",$J,"C","INCL",N))
S CMP=$S(CDEN1CT>0:$$ROUND^BGPMUA01(CNUM1CT/CDEN1CT,3)*100,1:0)
S PDEN1CT=+$G(^TMP("BGPMU0028B",$J,"P","DEN",N)) ;previous
S PNUM1CT=+$G(^TMP("BGPMU0028B",$J,"P","INCL",N))
S PMP=$S(PDEN1CT>0:$$ROUND^BGPMUA01(PNUM1CT/PDEN1CT,3)*100,1:0)
S BDEN1CT=+$G(^TMP("BGPMU0028B",$J,"B","DEN",N)) ;baseline
S BNUM1CT=+$G(^TMP("BGPMU0028B",$J,"B","INCL",N))
S BMP=$S(BDEN1CT>0:$$ROUND^BGPMUA01(BNUM1CT/BDEN1CT,3)*100,1:0)
S BGPDNCNT=BGPDNCNT+1
S BGPSSTR="MU.EP.0028B."_N_U_"18+ cessation counsel/agent w/in 24 mos"_U_0_U_CDEN1CT_U_CNUM1CT_U_CMP_U_U_U_U
; 11 12 13 14
S BGPSSTR=BGPSSTR_U_""_U_PDEN1CT_U_PNUM1CT_U_PMP
; 15 16 17 18
S BGPSSTR=BGPSSTR_U_""_U_BDEN1CT_U_BNUM1CT_U_BMP
S ^TMP("BGPMU SUMMARY",$J,BGPIC,BGPDNCNT)=BGPSSTR
Q
;
LARGE(N1,N2) ;large function returns the largest of the 2 values
I N1>N2 Q N1
I N2>N1 Q N2
Q N1
;
TESTB ; debug target
;S U="^"
;S DUZ=1
;S DT=3110217
;S J=7404
;S BGPIOSL=20
;S BGPGPG=1
;S DFN=184
;S DFN=158
;S BGPBDATE=3100101
;S BGPEDATE=3110401
;S BGPPROV=2
;S BGPMUTF="C"
;D TOB
Q
BGPMUDP1 ; IHS/MSC/SAT - Print MU EP measure NQF0028b ;02-Mar-2011 10:55;DU
+1 ;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
+2 ;This routine does the printed output of these 2 EP measures
TOB ;EP
+1 DO P1
+2 KILL ^TMP("BGPMU0028B",$JOB)
+3 QUIT
P1 ;Write individual measure
+1 NEW J,X,Y,Z,LIST1,LIST2,LIST3
+2 NEW BGPPTYPE,DEN1,NUM1,PC1,STRING1,STRING2,STRING3,PRD1,PRD2,PRB1,PRB2
+3 SET J=$JOB
+4 SET BGPPTYPE="P"
+5 SET STRING1=$$G28B("C")
+6 SET STRING2=$$G28B("P")
+7 SET STRING3=$$G28B("B")
+8 SET PRD1=$PIECE(STRING1,U,7)-$PIECE(STRING2,U,7)
+9 SET PRD2=$PIECE(STRING1,U,8)-$PIECE(STRING2,U,8)
+10 SET PRB1=$PIECE(STRING1,U,7)-$PIECE(STRING3,U,7)
+11 SET PRB2=$PIECE(STRING1,U,8)-$PIECE(STRING3,U,8)
+12 DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+13 DO HDRBLK^BGPMUPH
+14 WRITE !,"Pts 18+/Tobacco user/24mos",?33,$PIECE(STRING1,U,1),?44,$PIECE(STRING2,U,1),?64,$PIECE(STRING3,U,1)
+15 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+16 WRITE !!,"# w/cess counsel/agent/24 mos",?33,$PIECE(STRING1,U,2),?38,$JUSTIFY($PIECE(STRING1,U,7),5,1),?44,...
... $PIECE(STRING2,U,2),?49,$JUSTIFY($PIECE(STRING2,U,7),5,1),?56,$JUSTIFY($FNUMBER(PRD1,",+",1),6),?64,$PIECE(STRING3,U,2),?68,$JUSTIFY($PIECE(STRING3,U,7),5,1),?74,$JUSTIFY($FNUMBER(PRB1,",+",1),6)
+17 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+18 WRITE !,"# w/o cess counsel/agent/24 mos",?33,$PIECE(STRING1,U,3),?38,$JUSTIFY($PIECE(STRING1,U,8),5,1),?44,...
... $PIECE(STRING2,U,3),?49,$JUSTIFY($PIECE(STRING2,U,8),5,1),?56,$JUSTIFY($FNUMBER(PRD2,",+",1),6),?64,$PIECE(STRING3,U,3),?68,$JUSTIFY($PIECE(STRING3,U,8),5,1),?74,$JUSTIFY($FNUMBER(PRB2,",+",1),6)
+19 IF $DATA(BGPLIST(BGPIC))
DO P2
+20 DO SUM28B
+21 QUIT
G28B(BGPMUTF) ;Get the numbers for this measure
+1 NEW ARRAY,N
+2 SET J=$JOB
+3 SET DEN1=+$GET(^TMP("BGPMU0028B",J,BGPMUTF,"DEN",1))
+4 SET NUM1=+$GET(^TMP("BGPMU0028B",J,BGPMUTF,"INCL",1))
+5 SET NONUM=+$GET(^TMP("BGPMU0028B",J,BGPMUTF,"NOT",1))
+6 IF DEN1=0
SET (PC1,PC2)=0
+7 IF DEN1>0
Begin DoDot:1
+8 SET PC1=$$ROUND^BGPMUA01((NUM1/DEN1),3)*100
+9 SET PC2=$$ROUND^BGPMUA01((NONUM/DEN1),3)*100
End DoDot:1
+10 SET ARRAY=DEN1_U_NUM1_U_NONUM_U_""_U_""_U_""_U_PC1_U_PC2
+11 QUIT ARRAY
P2 ;Do the Details
+1 NEW J,PT,NODE,NAME,VST,BMI,FOL,X,BGPARR
+2 SET J=$JOB
+3 DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+4 SET X="Patients 18+ with at least 1 or 2 encounters with the EP during the reporting"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+5 SET X="period and who have been identified as tobacco users within the last 24 months,"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+6 SET X="with documented cessation intervention, if any."
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+7 SET X="Patients who do not meet the numerator criteria are listed first (NM:), followed"
DO W^BGPMUPP(X,0,2,BGPPTYPE)
+8 SET X="by patients who do meet the numerator criteria (M:)."
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+9 SET X="The following are the abbreviations used in the denominator column:"
DO W^BGPMUPP(X,0,2,BGPPTYPE)
+10 SET X="EN=Encounter"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+11 SET X="HF=Tobacco User Health Factor"
DO W^BGPMUPP(X,0,1,BGPPTYPE)
+12 WRITE !!,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
+13 SET LINE=""
SET $PIECE(LINE,"-",81)=""
WRITE !,LINE
+14 SET PTCT=0
+15 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+16 KILL BGPARR
+17 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0028B"","_$JOB_",""C"",""NOT"",""PAT"",1)")
+18 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+19 SET PTCT=PTCT+1
+20 SET NODE=$GET(BGPARR(PT))
+21 DO DATA(NODE)
End DoDot:2
End DoDot:1
+22 IF BGPLIST="N"!(BGPLIST="A")
Begin DoDot:1
+23 KILL BGPARR
+24 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0028B"","_$JOB_",""C"",""INCL"",""PAT"",1)")
+25 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+26 SET PTCT=PTCT+1
+27 SET NODE=$GET(BGPARR(PT))
+28 DO DATA(NODE)
End DoDot:2
End DoDot:1
+29 WRITE !!,"Total # of patients on list: "_PTCT
+30 QUIT
DATA(NODE) ;GET DATA
+1 NEW AGE,DEN,DFN,COMM,HRN,NAME,NUM,SEX
+2 SET DFN=$PIECE(NODE,U,1)
+3 SET NAME=$EXTRACT($$GET1^DIQ(2,$PIECE(NODE,U,1),.01),1,22)
+4 SET HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
+5 SET AGE=$$AGE^AUPNPAT(DFN,BGPED)
+6 SET SEX=$$SEX^AUPNPAT(DFN)
+7 SET COMM=$EXTRACT($$GET1^DIQ(9000001,DFN,1118),1,11)
+8 SET DEN=$PIECE(NODE,U,2)
+9 SET NUM=$PIECE(NODE,U,3)
+10 IF $Y>(BGPIOSL-2)
Begin DoDot:1
+11 DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+12 WRITE !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
+13 SET LINE=""
SET $PIECE(LINE,"-",81)=""
WRITE !,LINE
End DoDot:1
+14 ; line 1
+15 WRITE !,NAME,?23,HRN,?30,COMM,?42,SEX,?46,AGE
+16 WRITE ?50,$SELECT($PIECE($PIECE(DEN,":",1),";",1)'="":"EN:"_$PIECE($$FMTE^XLFDT($PIECE($PIECE(DEN,":",1),";",1),2),"@",1)_$SELECT($LENGTH($PIECE(DEN,":",1),";")>1:";",1:""),1:"")
+17 WRITE ?63,$SELECT(NUM'="":"M:"_$PIECE(NUM,";",1)_" "_$$FMTE^XLFDT($PIECE(NUM,";",2),2),1:"NM:")
+18 ;line 2
+19 SET BGPTMP=$SELECT($PIECE($PIECE(DEN,":",1),";",2)'="":"EN",1:"HF")
+20 WRITE !,?50,$SELECT(BGPTMP="EN":"EN:"_$PIECE($$FMTE^XLFDT($PIECE($PIECE(DEN,":",1),";",2),2),"@",1),1:"HF:"_$PIECE($$FMTE^XLFDT($PIECE(DEN,":",2),2),"@",1))
+21 ;possible line 3
+22 IF BGPTMP="EN"
WRITE !,?50,"HF:"_$PIECE($$FMTE^XLFDT($PIECE(DEN,":",2),2),"@",1)
+23 QUIT
+24 ;
TOB2 ;Tobacco print
+1 DO P1A
+2 KILL ^TMP("BGPMU0028A",$JOB)
+3 QUIT
P1A ;Write individual measure
+1 NEW BGPPTYPE,X,Y,Z,LIST1,LIST2,LIST3
+2 NEW DEN1,NUM1,PC1,STRING1,STRING2,STRING3,PRD1,PRD2,PRB1,PRB2,NONUM
+3 NEW LINE
+4 SET BGPPTYPE="P"
+5 SET STRING1=$$G28A("C")
+6 SET STRING2=$$G28A("P")
+7 SET STRING3=$$G28A("B")
+8 SET PRD1=$PIECE(STRING1,U,7)-$PIECE(STRING2,U,7)
+9 SET PRD2=$PIECE(STRING1,U,8)-$PIECE(STRING2,U,8)
+10 SET PRB1=$PIECE(STRING1,U,7)-$PIECE(STRING3,U,7)
+11 SET PRB2=$PIECE(STRING1,U,8)-$PIECE(STRING3,U,8)
+12 DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+13 DO HDRBLK^BGPMUPH
+14 WRITE !,"Pts 18+",?33,$PIECE(STRING1,U,1),?44,$PIECE(STRING2,U,1),?64,$PIECE(STRING3,U,1)
+15 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+16 WRITE !!,"# w/tob screen-24 mos",?33,$PIECE(STRING1,U,2),?38,$JUSTIFY($PIECE(STRING1,U,7),5,1),?44,$PIECE(STRING2,U,2),?49,$JUSTIFY(...
... $PIECE(STRING2,U,7),5,1),?56,$JUSTIFY($FNUMBER(PRD1,",+",1),6),?64,$PIECE(STRING3,U,2),?68,$JUSTIFY($PIECE(STRING3,U,7),5,1),?74,$JUSTIFY($FNUMBER(PRB1,",+",1),6)
+17 IF $Y>(BGPIOSL-3)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+18 WRITE !,"# w/o tob screen-24 mos",?33,$PIECE(STRING1,U,3),?38,$JUSTIFY($PIECE(STRING1,U,8),5,1),?44,$PIECE(STRING2,U,3),?49,$JUSTIFY(...
... $PIECE(STRING2,U,8),5,1),?56,$JUSTIFY($FNUMBER(PRD2,",+",1),6),?64,$PIECE(STRING3,U,3),?68,$JUSTIFY($PIECE(STRING3,U,8),5,1),?74,$JUSTIFY($FNUMBER(PRB2,",+",1),6)
+19 IF $DATA(BGPLIST(BGPIC))
DO P2A
+20 DO SUM28A
+21 QUIT
G28A(BGPMUTF) ;Get the numbers for this measure
+1 NEW ARRAY,DEN1,NONUM,NUM1,PC1
+2 SET DEN1=+$GET(^TMP("BGPMU0028A",$JOB,BGPMUTF,"DEN",1))
+3 SET NUM1=+$GET(^TMP("BGPMU0028A",$JOB,BGPMUTF,"INCL",1))
+4 SET NONUM=+$GET(^TMP("BGPMU0028A",$JOB,BGPMUTF,"NOT",1))
+5 IF DEN1=0
SET (PC1,PC2)=0
+6 IF DEN1>0
Begin DoDot:1
+7 SET PC1=$$ROUND^BGPMUA01((NUM1/DEN1),3)*100
+8 SET PC2=$$ROUND^BGPMUA01((NONUM/DEN1),3)*100
End DoDot:1
+9 SET ARRAY=DEN1_U_NUM1_U_NONUM_U_""_U_""_U_""_U_PC1_U_PC2
+10 QUIT ARRAY
P2A ;Do the Details
+1 NEW PT,NODE,NAME,VST,BMI,FOL,X,BGPARR,PTCT,LINE
+2 DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+3 WRITE !,"Patients 18+ with at least 1 or 2 encounters with the EP during the reporting "
+4 WRITE !,"period, with documented tobacco screening within 24 months, if any."
+5 WRITE !
+6 WRITE !,"Patients who do not meet the numerator criteria are listed first (NM:), followed"
+7 WRITE !,"by patients who do meet the numerator criteria (M:)."
+8 WRITE !
+9 WRITE !,"The following are the abbreviations used in the denominator column:"
+10 WRITE !,"EN=Encounter"
+11 WRITE !
+12 WRITE !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
+13 SET LINE=""
SET $PIECE(LINE,"-",81)=""
WRITE !,LINE
+14 SET PTCT=0
+15 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+16 KILL BGPARR
+17 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0028A"","_$JOB_",""C"",""NOT"",""PAT"",1)")
+18 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+19 SET PTCT=PTCT+1
+20 SET NODE=$GET(BGPARR(PT))
+21 DO DATA3(NODE)
End DoDot:2
End DoDot:1
+22 IF BGPLIST="N"!(BGPLIST="A")
Begin DoDot:1
+23 KILL BGPARR
+24 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0028A"","_$JOB_",""C"",""INCL"",""PAT"",1)")
+25 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+26 SET PTCT=PTCT+1
+27 SET NODE=$GET(BGPARR(PT))
+28 DO DATA3(NODE)
End DoDot:2
End DoDot:1
+29 WRITE !!,"Total # of patients on list: "_PTCT
+30 QUIT
DATA3(NODE) ;GET DATA
+1 NEW AGE,DEN,DFN,COMM,HRN,NAME,NUM,SEX
+2 SET DFN=$PIECE(NODE,U,1)
+3 SET NAME=$EXTRACT($$GET1^DIQ(2,$PIECE(NODE,U,1),.01),1,22)
+4 SET HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
+5 SET AGE=$$AGE^AUPNPAT(DFN,BGPED)
+6 SET SEX=$$SEX^AUPNPAT(DFN)
+7 SET COMM=$EXTRACT($$GET1^DIQ(9000001,DFN,1118),1,11)
+8 SET DEN=$PIECE(NODE,U,2)
+9 SET NUM=$PIECE(NODE,U,3)
+10 IF $Y>(BGPIOSL-2)
Begin DoDot:1
+11 DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+12 WRITE !,"PATIENT NAME",?23,"HRN",?30,"COMMUNITY",?42,"SEX",?46,"AGE",?50,"DENOMINATOR",?63,"NUMERATOR"
+13 SET LINE=""
SET $PIECE(LINE,"-",81)=""
WRITE !,LINE
End DoDot:1
+14 WRITE !,NAME,?23,HRN,?30,COMM,?42,SEX,?46,AGE,?50,$SELECT($PIECE(DEN,";",1)'="":"EN:"_$PIECE($$FMTE^XLFDT($PIECE(DEN,";",1),2),"@",1)_$SELECT($LENGTH(DEN,";")>1:";",1:""),1:""),?63,$SELECT(NUM'="":"M:"_$EXTRACT($PIECE(NUM,";",1),1,15),1:"NM:")
+15 IF ($LENGTH(DEN,";")>1)!($LENGTH(NUM,";")>1)
WRITE !,?50,$SELECT($PIECE(DEN,";",2)'="":"EN:"_$PIECE($$FMTE^XLFDT($PIECE(DEN,";",2),2),"@",1),1:""),?65,$SELECT($PIECE(NUM,";",2)'="":$PIECE($$FMTE^XLFDT($PIECE(NUM,";",2),2),"@",1),1:"")
+16 QUIT
+17 ;
XML28A ;Populate the BGPXML array with data for each population/numerator
+1 ; BGPXMLOUT(i)=Population Number^Numerator Number^Denominator Count^Numerator Count^Exclusion Count
+2 SET BGPXML(1)="114"_U_""_U_+$GET(^TMP("BGPMU0028A",$JOB,"C","DEN",1))_U_+$GET(^TMP("BGPMU0028A",$JOB,"C","INCL",1))
+3 KILL ^TMP("BGPMU0028A",$JOB)
+4 QUIT
+5 ;
XML28B ;Populate the BGPXML array with data for each population/numerator
+1 ; BGPXMLOUT(i)=Population Number^Numerator Number^Denominator Count^Numerator Count^Exclusion Count
+2 SET BGPXML(1)="115"_U_""_U_+$GET(^TMP("BGPMU0028B",$JOB,"C","DEN",1))_U_+$GET(^TMP("BGPMU0028B",$JOB,"C","INCL",1))
+3 KILL ^TMP("BGPMU0028B",$JOB)
+4 QUIT
+5 ;
SUM28A ;Populate "BGPMU SUMMARY" for Tobacco Assessment
+1 ;Initialize iCare/summary global
+2 NEW BGPDNCNT,BGPSSTR,J,N
+3 SET BGPDNCNT=0
+4 KILL ^TMP("BGPMU SUMMARY",$JOB,BGPIC)
+5 SET ^TMP("BGPMU SUMMARY",$JOB,BGPIC)="0028a"_U_"114"
+6 ;only 1 numerator
SET N=1
+7 ;Setup summary page/iCare ^TMP global
+8 ;current
SET CDEN1CT=+$GET(^TMP("BGPMU0028A",$JOB,"C","DEN",N))
+9 SET CNUM1CT=+$GET(^TMP("BGPMU0028A",$JOB,"C","INCL",N))
+10 SET CMP=$SELECT(CDEN1CT>0:$$ROUND^BGPMUA01(CNUM1CT/CDEN1CT,3)*100,1:0)
+11 ;previous
SET PDEN1CT=+$GET(^TMP("BGPMU0028A",$JOB,"P","DEN",N))
+12 SET PNUM1CT=+$GET(^TMP("BGPMU0028A",$JOB,"P","INCL",N))
+13 SET PMP=$SELECT(PDEN1CT>0:$$ROUND^BGPMUA01(PNUM1CT/PDEN1CT,3)*100,1:0)
+14 ;baseline
SET BDEN1CT=+$GET(^TMP("BGPMU0028A",$JOB,"B","DEN",N))
+15 SET BNUM1CT=+$GET(^TMP("BGPMU0028A",$JOB,"B","INCL",N))
+16 SET BMP=$SELECT(BDEN1CT>0:$$ROUND^BGPMUA01(BNUM1CT/BDEN1CT,3)*100,1:0)
+17 SET BGPDNCNT=BGPDNCNT+1
+18 SET BGPSSTR="MU.EP.0028A."_N_U_"18+ screening w/in 24 mos"_U_0_U_CDEN1CT_U_CNUM1CT_U_CMP_U_U_U_U
+19 ; 11 12 13 14
+20 SET BGPSSTR=BGPSSTR_U_""_U_PDEN1CT_U_PNUM1CT_U_PMP
+21 ; 15 16 17 18
+22 SET BGPSSTR=BGPSSTR_U_""_U_BDEN1CT_U_BNUM1CT_U_BMP
+23 SET ^TMP("BGPMU SUMMARY",$JOB,BGPIC,BGPDNCNT)=BGPSSTR
+24 QUIT
+25 ;
SUM28B ;Populate "BGPMU SUMMARY" for Tobacco Cessation
+1 ;Initialize iCare/summary global
+2 NEW BGPDNCNT,BGPSSTR,J,N
+3 SET BGPDNCNT=0
+4 KILL ^TMP("BGPMU SUMMARY",$JOB,BGPIC)
+5 SET ^TMP("BGPMU SUMMARY",$JOB,BGPIC)="0028b"_U_"115"
+6 ;only 1 numerator
SET N=1
+7 ;Setup summary page/iCare ^TMP global
+8 ;current
SET CDEN1CT=+$GET(^TMP("BGPMU0028B",$JOB,"C","DEN",N))
+9 SET CNUM1CT=+$GET(^TMP("BGPMU0028B",$JOB,"C","INCL",N))
+10 SET CMP=$SELECT(CDEN1CT>0:$$ROUND^BGPMUA01(CNUM1CT/CDEN1CT,3)*100,1:0)
+11 ;previous
SET PDEN1CT=+$GET(^TMP("BGPMU0028B",$JOB,"P","DEN",N))
+12 SET PNUM1CT=+$GET(^TMP("BGPMU0028B",$JOB,"P","INCL",N))
+13 SET PMP=$SELECT(PDEN1CT>0:$$ROUND^BGPMUA01(PNUM1CT/PDEN1CT,3)*100,1:0)
+14 ;baseline
SET BDEN1CT=+$GET(^TMP("BGPMU0028B",$JOB,"B","DEN",N))
+15 SET BNUM1CT=+$GET(^TMP("BGPMU0028B",$JOB,"B","INCL",N))
+16 SET BMP=$SELECT(BDEN1CT>0:$$ROUND^BGPMUA01(BNUM1CT/BDEN1CT,3)*100,1:0)
+17 SET BGPDNCNT=BGPDNCNT+1
+18 SET BGPSSTR="MU.EP.0028B."_N_U_"18+ cessation counsel/agent w/in 24 mos"_U_0_U_CDEN1CT_U_CNUM1CT_U_CMP_U_U_U_U
+19 ; 11 12 13 14
+20 SET BGPSSTR=BGPSSTR_U_""_U_PDEN1CT_U_PNUM1CT_U_PMP
+21 ; 15 16 17 18
+22 SET BGPSSTR=BGPSSTR_U_""_U_BDEN1CT_U_BNUM1CT_U_BMP
+23 SET ^TMP("BGPMU SUMMARY",$JOB,BGPIC,BGPDNCNT)=BGPSSTR
+24 QUIT
+25 ;
LARGE(N1,N2) ;large function returns the largest of the 2 values
+1 IF N1>N2
QUIT N1
+2 IF N2>N1
QUIT N2
+3 QUIT N1
+4 ;
TESTB ; debug target
+1 ;S U="^"
+2 ;S DUZ=1
+3 ;S DT=3110217
+4 ;S J=7404
+5 ;S BGPIOSL=20
+6 ;S BGPGPG=1
+7 ;S DFN=184
+8 ;S DFN=158
+9 ;S BGPBDATE=3100101
+10 ;S BGPEDATE=3110401
+11 ;S BGPPROV=2
+12 ;S BGPMUTF="C"
+13 ;D TOB
+14 QUIT