BGPMUAD2 ; IHS/MSC/MGH - Print MU measure NQF0031,NQF0032,NQF0034 ;01-Mar-2011 15:41;MGH
;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
;Delimeted output for these measures
COLON ;EP
D P1
;I BGPMUDET="D" D P2
K ^TMP("BGPMU0034",$J)
Q
P1 ;Write individual measure
N X,Y,Z,DEN,NUM,PC1,STRING1,STRING2,STRING3,PRD,PRN,PRD1,PRD2,PRN1,PRN2
S STRING1=$$0034("C")
S STRING2=$$0034("P")
S STRING3=$$0034("B")
D SUM34^BGPMUAP2
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 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 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 50-70"_U_($P(STRING1,U,1)+$P(STRING1,U,6))_U_U_($P(STRING2,U,1)+$P(STRING2,U,6))_U_U_U_($P(STRING3,U,1)+$P(STRING3,U,6)) D S^BGPMUDEL(X,2,1)
S X="# Excluded (Exc)"_U_$P(STRING1,U,6)_U_U_$P(STRING2,U,6)_U_U_U_$P(STRING3,U,6) D S^BGPMUDEL(X,1,1)
S X="Pts 50-74 less Exc"_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="# w/colon screen"_U_$P(STRING1,U,2)_U_$P(STRING1,U,4)_U_$P(STRING2,U,2)_U_$P(STRING2,U,4)_U_$FN(PRD,",+",1)_U_$P(STRING3,U,2)_U_$P(STRING3,U,4)_U_$FN(PRN,",+",1)
D S^BGPMUDEL(X,2,1)
S X="# w/o colon screen"_U_$P(STRING1,U,3)_U_$P(STRING1,U,5)_U_$P(STRING2,U,3)_U_$P(STRING2,U,5)_U_$FN(PRD1,",+",1)_U_$P(STRING3,U,3)_U_$P(STRING3,U,5)_U_$FN(PRN1,",+",1)
D S^BGPMUDEL(X,1,1)
I $D(BGPLIST(BGPIC)) D P2
Q
0034(TF) ;Get the numbers for this measure
N ARRAY,DEN,NUM,PC1,PC2,PC3,EXC
S (ARRAY,PC1,PC2,PC3)=""
S DEN=+$G(^TMP("BGPMU0034",$J,TF,"DEN"))
S NUM=+$G(^TMP("BGPMU0034",$J,TF,"NUM"))
S EXC=+$G(^TMP("BGPMU0034",$J,TF,"EXC"))
S NOT=+$G(^TMP("BGPMU0034",$J,TF,"NOT"))
I DEN=0 S (PC1,PC2,PC3)=0
I DEN>0 D
.S PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
.S PC2=$$ROUND^BGPMUA01((NOT/DEN),3)*100
.S PC3=$$ROUND^BGPMUA01((EXC/DEN),3)*100
S ARRAY=DEN_U_NUM_U_NOT_U_PC1_U_PC2_U_EXC_U_PC3
Q ARRAY
P2 ;Do the Details
N PT,NODE,NAME,VST,COLON,FOL,PTCT
S X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT *****" D S^BGPMUDEL(X,2,1)
S X="Patients 50-74 with at least 1 encounter with the EP within the last 2 years" D S^BGPMUDEL(X,2,1)
S X="who have never had a total colectomy, with documented colorectal cancer screening," D S^BGPMUDEL(X,1,1)
S X="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 X="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(""BGPMU0034"","_$J_",""PAT"",""C"",""DEN"")")
.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(""BGPMU0034"","_$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 DATA(NODE)
I BGPLIST="A" D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0034"","_$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 DATA(NODE)
S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
Q
;Print results of breast cancer screen
BREAST ;EP
D B1
;I BGPMUDET="D" D B2
K ^TMP("BGPMU0031",$J)
Q
B1 ;Write individual measure
N X,Y,Z,DEN,NUM,PC,STRING1,STRING2,STRING3,PRD,PRN,PRD1,PRN1
S STRING1=$$0031("C")
S STRING2=$$0031("P")
S STRING3=$$0031("B")
D SUM31^BGPMUAP2
S PRD=$P(STRING1,U,4)-$P(STRING2,U,4)
S PRD1=$P(STRING1,U,5)-$P(STRING2,U,5)
S PRN=$P(STRING1,U,4)-$P(STRING3,U,4)
S PRN1=$P(STRING1,U,5)-$P(STRING3,U,5)
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 41-68"_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/mammogram"_U_$P(STRING1,U,2)_U_$P(STRING1,U,4)_U_$P(STRING2,U,2)_U_$P(STRING2,U,4)_U_$FN(PRD,"+,",1)_U_$P(STRING3,U,2)_U_$P(STRING3,U,4)_U_$FN(PRN,"+,",1)
D S^BGPMUDEL(X,2,1)
S X="# w/o mammogram"_U_$P(STRING1,U,3)_U_$P(STRING1,U,5)_U_$P(STRING2,U,3)_U_$P(STRING2,U,5)_U_$FN(PRD1,"+,",1)_U_$P(STRING3,U,3)_U_$P(STRING3,U,5)_U_$FN(PRN1,"+,",1)
D S^BGPMUDEL(X,1,1)
I $D(BGPLIST(BGPIC)) D B2
Q
0031(TF) ;Get the numbers for this measure
N ARRAY,DEN,NUM,NNUM,PC1,PC2
S DEN=+$G(^TMP("BGPMU0031",$J,TF,"DEN"))
S NUM=+$G(^TMP("BGPMU0031",$J,TF,"NUM"))
S NOT=+$G(^TMP("BGPMU0031",$J,TF,"NOT"))
S NNUM=DEN-NUM
I DEN=0 S (PC1,PC2)=0
I DEN>0 D
.S PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
.S PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
S ARRAY=DEN_U_NUM_U_NNUM_U_PC1_U_PC2
Q ARRAY
B2 ;Do the Details
N PT,NODE,NAME,VST,BREAST,PTCT
S X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT *****"
D S^BGPMUDEL(X,2,1)
S X="Female patients 41-68 with at least 1 encounter with the EP within 2 years of"
D S^BGPMUDEL(X,2,1)
S X="the reporting period end date and who have never had a bilateral mastectomy or 2"
D S^BGPMUDEL(X,1,1)
S X="unilateral mastectomies, with documented mammogram, if any."
D S^BGPMUDEL(X,1,1)
S X="Patients who do not meet the numerator criteria are listed first (NM:), followed"
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="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(""BGPMU0031"","_$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 DATA(NODE)
I BGPLIST="N"!(BGPLIST="A") D
.K BGPARR
.D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0031"","_$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 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,DEN1,DEN2
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 DEN=$P(NODE,U,4)
S NUM=$P(NODE,U,5)
S COMM=$$GET1^DIQ(9000001,DFN,1118)
S SEX=$P(^DPT(DFN,0),U,2)
S X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_"EN:"_$P($$FMTE^XLFDT(DEN,2),".",1)_U_$S(NUM="":"NM: ",1:"M: "_$P(NUM,";",1)_" "_$P($$FMTE^XLFDT($P(NUM,";",2),2),".",1))
D S^BGPMUDEL(X,1,1)
Q
;Get results of cervical cancer screen
PAP ;EP
D C1
;I BGPMUDET="D" D C2
K ^TMP("BGPMU0032",$J)
Q
C1 ;Write individual measure
N X,Y,Z,DEN,NUM,PC,STRING1,STRING2,STRING3,PRD,PRN,PRN1,PRD1
S STRING1=$$0032("C")
S STRING2=$$0032("P")
S STRING3=$$0032("B")
D SUM32^BGPMUAP2
S PRD=$P(STRING1,U,4)-$P(STRING2,U,4)
S PRD1=$P(STRING1,U,5)-$P(STRING2,U,5)
S PRN=$P(STRING1,U,4)-$P(STRING3,U,4)
S PRN1=$P(STRING1,U,5)-$P(STRING3,U,5)
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 23-63:"_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/pap test"_U_$P(STRING1,U,2)_U_$P(STRING1,U,4)_U_$P(STRING2,U,2)_U_$P(STRING2,U,4)_U_$FN(PRD,",+",1)_U_$P(STRING3,U,2)_U_$P(STRING3,U,4)_U_$FN(PRN,",+",1)
D S^BGPMUDEL(X,2,1)
S X="# w/o pap test"_U_$P(STRING1,U,3)_U_$P(STRING1,U,5)_U_$P(STRING2,U,3)_U_$P(STRING2,U,5)_U_$FN(PRD1,",+",1)_U_$P(STRING3,U,3)_U_$P(STRING3,U,5)_U_$FN(PRN1,",+",1)
D S^BGPMUDEL(X,1,1)
I $D(BGPLIST(BGPIC)) D C2
Q
0032(TF) ;Get the numbers for this measure
N ARRAY,DEN,NUM,PC1,PC2,NNUM
S DEN=+$G(^TMP("BGPMU0032",$J,TF,"DEN"))
S NUM=+$G(^TMP("BGPMU0032",$J,TF,"NUM"))
S NNUM=DEN-NUM
I DEN=0 S (PC1,PC2)=0
I DEN>0 D
.S PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
.S PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
S ARRAY=DEN_U_NUM_U_NNUM_U_PC1_U_PC2
Q ARRAY
C2 ;Do the Details
N PT,NODE,NAME,VST,CERV,PTCT
S X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT *****" D S^BGPMUDEL(X,2,1)
S X="Female patients 23-63 with at least 1 encounter with the EP within the last" D S^BGPMUDEL(X,2,1)
S X="2 years who have never had a hysterectomy, with documented pap test, 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 X="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(""BGPMU0032"","_$J_",""PAT"",""C"",""DEN"")")
.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(""BGPMU0032"","_$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 DATA(NODE)
S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
Q
XML0032 ;Ouptut the XML for the PAP smear logic
; BGPXML(i)=Population Number^Numerator Number^Denominator Count^Numerator Count
N STRING
S STRING=$$0032("C")
S BGPXML(1)="NQF_0032"_U_U_+$P(STRING,U,1)_U_+$P(STRING,U,2)
K ^TMP("BGPMU0032",$J)
Q
XML0031 ;Output the XML for the Mammogram logic
; BGPXML(i)=Population Number^Numerator Number^Denominator Count
N STRING
S STRING=$$0031("C")
S BGPXML(1)="112"_U_U_+$P(STRING,U,1)_U_+$P(STRING,U,2)
K ^TMP("BGPMU0031",$J)
Q
XML0034 ;Output the XML for the Colon Cancer logic
; BGPXML(i)=Population Number^Numerator Number^Denominator Count^Numerator Count^Exception
N STRING
S STRING=$$0034("C")
S BGPXML(1)="113"_U_U_+$P(STRING,U,1)_U_+$P(STRING,U,2)_U_+$P(STRING,U,6) Q
K ^TMP("BGPMU0034",$J)
Q
BGPMUAD2 ; IHS/MSC/MGH - Print MU measure NQF0031,NQF0032,NQF0034 ;01-Mar-2011 15:41;MGH
+1 ;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
+2 ;Delimeted output for these measures
COLON ;EP
+1 DO P1
+2 ;I BGPMUDET="D" D P2
+3 KILL ^TMP("BGPMU0034",$JOB)
+4 QUIT
P1 ;Write individual measure
+1 NEW X,Y,Z,DEN,NUM,PC1,STRING1,STRING2,STRING3,PRD,PRN,PRD1,PRD2,PRN1,PRN2
+2 SET STRING1=$$0034("C")
+3 SET STRING2=$$0034("P")
+4 SET STRING3=$$0034("B")
+5 DO SUM34^BGPMUAP2
+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 PRN=$PIECE(STRING1,U,4)-$PIECE(STRING3,U,4)
+10 SET PRN1=$PIECE(STRING1,U,5)-$PIECE(STRING3,U,5)
+11 SET PRN2=$PIECE(STRING1,U,7)-$PIECE(STRING3,U,7)
+12 SET X=U_"REPORT PERIOD"_U_"%"_U_"PREV YR PERIOD"_U_"%"_U_"CHG FROM PREV YR"_U_"BASE YEAR"_U_"%"_U_"CHG FROM BASE"
+13 DO S^BGPMUDEL(X,2,1)
+14 SET X="Pts 50-70"_U_($PIECE(STRING1,U,1)+$PIECE(STRING1,U,6))_U_U_($PIECE(STRING2,U,1)+$PIECE(STRING2,U,6))_U_U_U_($PIECE(STRING3,U,1)+$PIECE(STRING3,U,6))
DO S^BGPMUDEL(X,2,1)
+15 SET X="# Excluded (Exc)"_U_$PIECE(STRING1,U,6)_U_U_$PIECE(STRING2,U,6)_U_U_U_$PIECE(STRING3,U,6)
DO S^BGPMUDEL(X,1,1)
+16 SET X="Pts 50-74 less Exc"_U_$PIECE(STRING1,U,1)_U_U_$PIECE(STRING2,U,1)_U_U_U_$PIECE(STRING3,U,1)
DO S^BGPMUDEL(X,1,1)
+17 SET X="# w/colon screen"_U_$PIECE(STRING1,U,2)_U_$PIECE(STRING1,U,4)_U_$PIECE(STRING2,U,2)_U_$PIECE(STRING2,U,4)_U_$FNUMBER(PRD,",+",1)_U_$PIECE(STRING3,U,2)_U_$PIECE(STRING3,U,4)_U_$FNUMBER(PRN,",+",1)
+18 DO S^BGPMUDEL(X,2,1)
+19 SET X="# w/o colon screen"_U_$PIECE(STRING1,U,3)_U_$PIECE(STRING1,U,5)_U_$PIECE(STRING2,U,3)_U_$PIECE(STRING2,U,5)_U_$FNUMBER(PRD1,",+",1)_U_$PIECE(STRING3,U,3)_U_$PIECE(STRING3,U,5)_U_$FNUMBER(PRN1,",+",1)
+20 DO S^BGPMUDEL(X,1,1)
+21 IF $DATA(BGPLIST(BGPIC))
DO P2
+22 QUIT
0034(TF) ;Get the numbers for this measure
+1 NEW ARRAY,DEN,NUM,PC1,PC2,PC3,EXC
+2 SET (ARRAY,PC1,PC2,PC3)=""
+3 SET DEN=+$GET(^TMP("BGPMU0034",$JOB,TF,"DEN"))
+4 SET NUM=+$GET(^TMP("BGPMU0034",$JOB,TF,"NUM"))
+5 SET EXC=+$GET(^TMP("BGPMU0034",$JOB,TF,"EXC"))
+6 SET NOT=+$GET(^TMP("BGPMU0034",$JOB,TF,"NOT"))
+7 IF DEN=0
SET (PC1,PC2,PC3)=0
+8 IF DEN>0
Begin DoDot:1
+9 SET PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
+10 SET PC2=$$ROUND^BGPMUA01((NOT/DEN),3)*100
+11 SET PC3=$$ROUND^BGPMUA01((EXC/DEN),3)*100
End DoDot:1
+12 SET ARRAY=DEN_U_NUM_U_NOT_U_PC1_U_PC2_U_EXC_U_PC3
+13 QUIT ARRAY
P2 ;Do the Details
+1 NEW PT,NODE,NAME,VST,COLON,FOL,PTCT
+2 SET X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT *****"
DO S^BGPMUDEL(X,2,1)
+3 SET X="Patients 50-74 with at least 1 encounter with the EP within the last 2 years"
DO S^BGPMUDEL(X,2,1)
+4 SET X="who have never had a total colectomy, with documented colorectal cancer screening,"
DO S^BGPMUDEL(X,1,1)
+5 SET X="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="followed 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 and numerator"
DO S^BGPMUDEL(X,2,1)
+9 SET X="columns: "
DO S^BGPMUDEL(X,1,1)
+10 SET X="EN=Encounter"
DO S^BGPMUDEL(X,1,1)
+11 SET X="NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR"
DO S^BGPMUDEL(X,2,1)
+12 SET PTCT=0
+13 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+14 KILL BGPARR
+15 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0034"","_$JOB_",""PAT"",""C"",""DEN"")")
+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 DATA(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(""BGPMU0034"","_$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 DATA(NODE)
End DoDot:2
End DoDot:1
+27 IF BGPLIST="A"
Begin DoDot:1
+28 KILL BGPARR
+29 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0034"","_$JOB_",""PAT"",""C"",""EXC"")")
+30 SET PT=0
FOR
SET PT=$ORDER(BGPARR(PT))
IF PT=""
QUIT
Begin DoDot:2
+31 SET PTCT=PTCT+1
+32 SET NODE=$GET(BGPARR(PT))
+33 DO DATA(NODE)
End DoDot:2
End DoDot:1
+34 SET X="Total # of patients on list: "_PTCT
DO S^BGPMUDEL(X,2,1)
+35 QUIT
+36 ;Print results of breast cancer screen
BREAST ;EP
+1 DO B1
+2 ;I BGPMUDET="D" D B2
+3 KILL ^TMP("BGPMU0031",$JOB)
+4 QUIT
B1 ;Write individual measure
+1 NEW X,Y,Z,DEN,NUM,PC,STRING1,STRING2,STRING3,PRD,PRN,PRD1,PRN1
+2 SET STRING1=$$0031("C")
+3 SET STRING2=$$0031("P")
+4 SET STRING3=$$0031("B")
+5 DO SUM31^BGPMUAP2
+6 SET PRD=$PIECE(STRING1,U,4)-$PIECE(STRING2,U,4)
+7 SET PRD1=$PIECE(STRING1,U,5)-$PIECE(STRING2,U,5)
+8 SET PRN=$PIECE(STRING1,U,4)-$PIECE(STRING3,U,4)
+9 SET PRN1=$PIECE(STRING1,U,5)-$PIECE(STRING3,U,5)
+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 41-68"_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/mammogram"_U_$PIECE(STRING1,U,2)_U_$PIECE(STRING1,U,4)_U_$PIECE(STRING2,U,2)_U_$PIECE(STRING2,U,4)_U_$FNUMBER(PRD,"+,",1)_U_$PIECE(STRING3,U,2)_U_$PIECE(STRING3,U,4)_U_$FNUMBER(PRN,"+,",1)
+14 DO S^BGPMUDEL(X,2,1)
+15 SET X="# w/o mammogram"_U_$PIECE(STRING1,U,3)_U_$PIECE(STRING1,U,5)_U_$PIECE(STRING2,U,3)_U_$PIECE(STRING2,U,5)_U_$FNUMBER(PRD1,"+,",1)_U_$PIECE(STRING3,U,3)_U_$PIECE(STRING3,U,5)_U_$FNUMBER(PRN1,"+,",1)
+16 DO S^BGPMUDEL(X,1,1)
+17 IF $DATA(BGPLIST(BGPIC))
DO B2
+18 QUIT
0031(TF) ;Get the numbers for this measure
+1 NEW ARRAY,DEN,NUM,NNUM,PC1,PC2
+2 SET DEN=+$GET(^TMP("BGPMU0031",$JOB,TF,"DEN"))
+3 SET NUM=+$GET(^TMP("BGPMU0031",$JOB,TF,"NUM"))
+4 SET NOT=+$GET(^TMP("BGPMU0031",$JOB,TF,"NOT"))
+5 SET NNUM=DEN-NUM
+6 IF DEN=0
SET (PC1,PC2)=0
+7 IF DEN>0
Begin DoDot:1
+8 SET PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
+9 SET PC2=$$ROUND^BGPMUA01((NNUM/DEN),3)*100
End DoDot:1
+10 SET ARRAY=DEN_U_NUM_U_NNUM_U_PC1_U_PC2
+11 QUIT ARRAY
B2 ;Do the Details
+1 NEW PT,NODE,NAME,VST,BREAST,PTCT
+2 SET X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT *****"
+3 DO S^BGPMUDEL(X,2,1)
+4 SET X="Female patients 41-68 with at least 1 encounter with the EP within 2 years of"
+5 DO S^BGPMUDEL(X,2,1)
+6 SET X="the reporting period end date and who have never had a bilateral mastectomy or 2"
+7 DO S^BGPMUDEL(X,1,1)
+8 SET X="unilateral mastectomies, with documented mammogram, if any."
+9 DO S^BGPMUDEL(X,1,1)
+10 SET X="Patients who do not meet the numerator criteria are listed first (NM:), followed"
+11 DO S^BGPMUDEL(X,2,1)
+12 SET X="by patients who do meet the numerator criteria (M:)."
+13 DO S^BGPMUDEL(X,1,1)
+14 SET X="The following are the abbreviations used in the denominator column:"
+15 DO S^BGPMUDEL(X,2,1)
+16 SET X="EN=Encounter"
+17 DO S^BGPMUDEL(X,1,1)
+18 SET X="PATIENT NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR"
+19 DO S^BGPMUDEL(X,2,1)
+20 SET PTCT=0
+21 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+22 KILL BGPARR
+23 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0031"","_$JOB_",""PAT"",""C"",""NOT"")")
+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 DATA(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(""BGPMU0031"","_$JOB_",""PAT"",""C"",""NUM"")")
+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 DATA(NODE)
End DoDot:2
End DoDot:1
+35 SET X="Total # of patients on list: "_PTCT
DO S^BGPMUDEL(X,2,1)
+36 QUIT
+37 ;
DATA(NODE) ;GET DATA
+1 NEW NAME,HRN,DEN,NUM,AGE,DFN,SEX,COMM,DEN1,DEN2
+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 DEN=$PIECE(NODE,U,4)
+7 SET NUM=$PIECE(NODE,U,5)
+8 SET COMM=$$GET1^DIQ(9000001,DFN,1118)
+9 SET SEX=$PIECE(^DPT(DFN,0),U,2)
+10 SET X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_"EN:"_$PIECE($$FMTE^XLFDT(DEN,2),".",1)_U_$SELECT(NUM="":"NM: ",1:"M: "_$PIECE(NUM,";",1)_" "_$PIECE($$FMTE^XLFDT($PIECE(NUM,";",2),2),".",1))
+11 DO S^BGPMUDEL(X,1,1)
+12 QUIT
+13 ;Get results of cervical cancer screen
PAP ;EP
+1 DO C1
+2 ;I BGPMUDET="D" D C2
+3 KILL ^TMP("BGPMU0032",$JOB)
+4 QUIT
C1 ;Write individual measure
+1 NEW X,Y,Z,DEN,NUM,PC,STRING1,STRING2,STRING3,PRD,PRN,PRN1,PRD1
+2 SET STRING1=$$0032("C")
+3 SET STRING2=$$0032("P")
+4 SET STRING3=$$0032("B")
+5 DO SUM32^BGPMUAP2
+6 SET PRD=$PIECE(STRING1,U,4)-$PIECE(STRING2,U,4)
+7 SET PRD1=$PIECE(STRING1,U,5)-$PIECE(STRING2,U,5)
+8 SET PRN=$PIECE(STRING1,U,4)-$PIECE(STRING3,U,4)
+9 SET PRN1=$PIECE(STRING1,U,5)-$PIECE(STRING3,U,5)
+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 23-63:"_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/pap test"_U_$PIECE(STRING1,U,2)_U_$PIECE(STRING1,U,4)_U_$PIECE(STRING2,U,2)_U_$PIECE(STRING2,U,4)_U_$FNUMBER(PRD,",+",1)_U_$PIECE(STRING3,U,2)_U_$PIECE(STRING3,U,4)_U_$FNUMBER(PRN,",+",1)
+14 DO S^BGPMUDEL(X,2,1)
+15 SET X="# w/o pap test"_U_$PIECE(STRING1,U,3)_U_$PIECE(STRING1,U,5)_U_$PIECE(STRING2,U,3)_U_$PIECE(STRING2,U,5)_U_$FNUMBER(PRD1,",+",1)_U_$PIECE(STRING3,U,3)_U_$PIECE(STRING3,U,5)_U_$FNUMBER(PRN1,",+",1)
+16 DO S^BGPMUDEL(X,1,1)
+17 IF $DATA(BGPLIST(BGPIC))
DO C2
+18 QUIT
0032(TF) ;Get the numbers for this measure
+1 NEW ARRAY,DEN,NUM,PC1,PC2,NNUM
+2 SET DEN=+$GET(^TMP("BGPMU0032",$JOB,TF,"DEN"))
+3 SET NUM=+$GET(^TMP("BGPMU0032",$JOB,TF,"NUM"))
+4 SET NNUM=DEN-NUM
+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((NNUM/DEN),3)*100
End DoDot:1
+9 SET ARRAY=DEN_U_NUM_U_NNUM_U_PC1_U_PC2
+10 QUIT ARRAY
C2 ;Do the Details
+1 NEW PT,NODE,NAME,VST,CERV,PTCT
+2 SET X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT *****"
DO S^BGPMUDEL(X,2,1)
+3 SET X="Female patients 23-63 with at least 1 encounter with the EP within the last"
DO S^BGPMUDEL(X,2,1)
+4 SET X="2 years who have never had a hysterectomy, with documented pap test, 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 X="NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR"
DO S^BGPMUDEL(X,2,1)
+11 SET PTCT=0
+12 IF BGPLIST="D"!(BGPLIST="A")
Begin DoDot:1
+13 KILL BGPARR
+14 DO PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0032"","_$JOB_",""PAT"",""C"",""DEN"")")
+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(""BGPMU0032"","_$JOB_",""PAT"",""C"",""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 SET X="Total # of patients on list: "_PTCT
DO S^BGPMUDEL(X,2,1)
+27 QUIT
XML0032 ;Ouptut the XML for the PAP smear logic
+1 ; BGPXML(i)=Population Number^Numerator Number^Denominator Count^Numerator Count
+2 NEW STRING
+3 SET STRING=$$0032("C")
+4 SET BGPXML(1)="NQF_0032"_U_U_+$PIECE(STRING,U,1)_U_+$PIECE(STRING,U,2)
+5 KILL ^TMP("BGPMU0032",$JOB)
+6 QUIT
XML0031 ;Output the XML for the Mammogram logic
+1 ; BGPXML(i)=Population Number^Numerator Number^Denominator Count
+2 NEW STRING
+3 SET STRING=$$0031("C")
+4 SET BGPXML(1)="112"_U_U_+$PIECE(STRING,U,1)_U_+$PIECE(STRING,U,2)
+5 KILL ^TMP("BGPMU0031",$JOB)
+6 QUIT
XML0034 ;Output the XML for the Colon Cancer logic
+1 ; BGPXML(i)=Population Number^Numerator Number^Denominator Count^Numerator Count^Exception
+2 NEW STRING
+3 SET STRING=$$0034("C")
+4 SET BGPXML(1)="113"_U_U_+$PIECE(STRING,U,1)_U_+$PIECE(STRING,U,2)_U_+$PIECE(STRING,U,6)
QUIT
+5 KILL ^TMP("BGPMU0034",$JOB)
+6 QUIT