BGPMUF01 ;IHS/MSC/MMT - MU Reports Measure NQF0038 ;02-Mar-2011 11:37;DU
;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
;
ENTRY ;EP
N START,END,BGPDEN1,BGPNUM1,BGPNUM2,BGPNUM3,BGPNUM4,BGPNUM5,BGPNUM6,BGPNUM7,BGPNUM8,BGPNUM9,BGPNUM10,BGPNUM11,BGPNUM12
N BGPEXC1,BGPEXC2,BGPEXC3,BGPEXC4,BGPEXC5,BGPEXC6,BGPEXC7,BGPEXC8,BGPEXC9,BGPEXC10,BGPEXC11,BGPEXC12
N IEN,INV,VISIT,WTIEN,DATA,VDATE,BGPSIX,FIRST,VIEN,EXCEPT
N BGPIVAL,BGPPTDOB,BGPPTDOB,BGPBDAY2
S (BGPDEN1,BGPNUM1,BGPNUM2,BGPNUM3,BGPNUM4,BGPNUM5,BGPNUM6,BGPNUM7,BGPNUM8,BGPNUM9,BGPNUM10,BGPNUM11,BGPNUM12)=0
S (BGPEXC1,BGPEXC2,BGPEXC3,BGPEXC4,BGPEXC5,BGPEXC6,BGPEXC7,BGPEXC8,BGPEXC9,BGPEXC10,BGPEXC11,BGPEXC12)=0
S START=9999999-BGPBDATE,END=9999999-BGPEDATE
;Pts must have turned 2 years old during the measurement period
I '(BGPAGEB=1) Q
I '(BGPAGEE=2) Q
S FIRST=END-0.1 F S FIRST=$O(^AUPNVSIT("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>START) D
.S IEN=0 F S IEN=$O(^AUPNVSIT("AA",DFN,FIRST,IEN)) Q:'+IEN D
..;Check provider, Only visits for chosen provider
..Q:'$$PRV^BGPMUUT1(IEN,BGPPROV)
..;Quit if the visit does not have a valid E&M code
..S AENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU CIMM ENCOUNTER EM")
..S BENC=$$VSTPOV^BGPMUUT3(DFN,IEN,"BGPMU BMI ENC PEDS DX") ;borrowing taxonomy from Peds BMI
..Q:(AENC=0)&(BENC=0)
..S DATA=$G(^AUPNVSIT(IEN,0))
..S VDATE=$P($G(^AUPNVSIT(IEN,0)),U,1),VIEN=IEN
..;This pt qualifies to be counted in the denominator
..S BGPDEN1=1_U_"EN:"_$$DATE^BGPMUUTL(VDATE)
..Q
;Quit if patient will not be in denominator
I 'BGPDEN1 G EXIT
;Calculate the day before the patient's 2nd birthday
S BGPPTDOB=$$DOB^AUPNPAT(DFN),BGPBDAY2=($E(BGPPTDOB,1,3)+2)_$E(BGPPTDOB,4,7),BGPBDAY2=$$FMADD^XLFDT(BGPBDAY2,-1)
;Num 1 - at least 4 DTaP
S BGPIVAL=$$DTAP^BGP0D34(DFN,BGPBDAY2) ;1 IS had immunizations, 3 is had refusal, 4 is disease or NMI or contraindication
I $P(BGPIVAL,U,1)=1 S BGPNUM1=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC1=BGPIVAL
;Num 2 - at least 3 IPV
S BGPIVAL=$$OPV^BGP0D33(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM2=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC2=BGPIVAL
;Num 3 - MMR
S BGPIVAL=$$MMR^BGP0D33(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM3=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC3=BGPIVAL
;Num 4 - at least 2 HiB
S BGPIVAL=$$HIB^BGP0D35(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM4=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC4=BGPIVAL
;Num 5 - at least 3 Hepatitis B
S BGPIVAL=$$HEP^BGP0D35(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM5=BGPIVAL_" B"
I $P(BGPIVAL,U,1)>1 S BGPEXC5=BGPIVAL
;Num 6 - VZV
S BGPIVAL=$$VAR^BGP0D35(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM6=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC6=BGPIVAL
;Num 7 - at least 4 Pneumococcal
S BGPIVAL=$$PNEUMO^BGP0D35(DFN,BGPBDAY2,4)
I $P(BGPIVAL,U,1)=1 S BGPNUM7=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC7=BGPIVAL
;Num 8 - at least 2 Hepatitis A - this routine looks for IMM's in the same manner as CRS but uses CVX/CPT codes from the NQF spec
S BGPIVAL=$$HEPA^BGPMUF02(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM8=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC8=BGPIVAL
;Num 9 - at least 2 Rotavirus - this routine looks for IMM's in the same manner as CRS but uses CVX/CPT codes from the NQF spec
S BGPIVAL=$$ROTA^BGPMUF02(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM9=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC9=BGPIVAL
;Num 10 - at least 2 Influenza - this routine looks for IMM's in the same manner as CRS but uses CVX/CPT codes from the NQF spec
S BGPIVAL=$$FLU^BGPMUF02(DFN,BGPBDAY2)
I $P(BGPIVAL,U,1)=1 S BGPNUM10=BGPIVAL
I $P(BGPIVAL,U,1)>1 S BGPEXC10=BGPIVAL
;Num 11 - pt is TRUE for 1, 2, 3, 4, 5, 6
I +BGPNUM1,+BGPNUM2,+BGPNUM3,+BGPNUM4,+BGPNUM5,+BGPNUM6 S BGPNUM11=1_U_"4:3:1:3:3:1"
I +BGPEXC1!+BGPEXC2!+BGPEXC3!+BGPEXC4!+BGPEXC5!+BGPEXC6 S BGPEXC11=1
;Num 12 - pt is TRUE for 1, 2, 3, 4, 5, 6, 7
I BGPNUM1,+BGPNUM2,+BGPNUM3,+BGPNUM4,+BGPNUM5,+BGPNUM6,+BGPNUM7 S BGPNUM12=1_U_"4:3:1:3:3:1:4"
I BGPEXC1!+BGPEXC2!+BGPEXC3!+BGPEXC4!+BGPEXC5!+BGPEXC6!+BGPEXC7 S BGPEXC12=1
EXIT I BGPDEN1 D TOTALS
K START,END,BGPDEN1,BGPNUM1,BGPNUM2,BGPNUM3,BGPNUM4,BGPNUM5,BGPNUM6,BGPNUM7,BGPNUM8,BGPNUM9,BGPNUM10,BGPNUM11,BGPNUM12
K BGPEXC1,BGPEXC2,BGPEXC3,BGPEXC4,BGPEXC5,BGPEXC6,BGPEXC7,BGPEXC8,BGPEXC9,BGPEXC10,BGPEXC11,BGPEXC12
K IEN,INV,VISIT,WTIEN,DATA,VDATE,BGPSIX,FIRST,VIEN,EXCEPT
K BGPIVAL,BGPPTDOB,BGPPTDOB
Q
TOTALS ;
;each numerator will need to maintain it's own denominator count and if the patient is in the exclusion list
; for a numerator, they should not be added to the denominator count for the numerator
N TOTALS,BGPI,BGPNVAL,BGPXVAL
N EXC1CT,EXC2CT,EXC3CT,EXC4CT,EXC5CT,EXC6CT,EXC7CT,EXC8CT,EXC9CT,EXC10CT,EXC11CT,EXC12CT
N DEN1CT,DEN2CT,DEN3CT,DEN4CT,DEN5CT,DEN6CT,DEN7CT,DEN8CT,DEN9CT,DEN10CT,DEN11CT,DEN12CT
N NUM1CT,NUM2CT,NUM3CT,NUM4CT,NUM5CT,NUM6CT,NUM7CT,NUM8CT,NUM9CT,NUM10CT,NUM11CT,NUM12CT
S EXCEPT=""
;total patients evaluated
S TOTALS=$G(^TMP("BGPMU0038",$J,BGPMUTF,"TOT"))
;exclusion counts
F BGPI=1:1:12 S @("EXC"_BGPI_"CT")=+$G(^TMP("BGPMU0038",$J,BGPMUTF,"EXC",BGPI))
;denominator counts
F BGPI=1:1:12 S @("DEN"_BGPI_"CT")=+$G(^TMP("BGPMU0038",$J,BGPMUTF,"DEN",BGPI))
;numerator counts
F BGPI=1:1:12 S @("NUM"_BGPI_"CT")=+$G(^TMP("BGPMU0038",$J,BGPMUTF,"NUM",BGPI))
;increment appropriate counters and maintain patient lists
I +BGPNU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^TMP("BGPMU0038",$J,BGPMUTF,"PAT","NOT",9,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM9,U,2)
I +BGPNUM10 D
.S NUM10CT=NUM10CT+1
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","INCL",10,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM10,U,2)
I 'BGPEXC10 S DEN10CT=DEN10CT+1
I +BGPEXC10 D
.S EXC10CT=EXC10CT+1
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","EXCL",10,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_"Excluded"
I 'BGPNUM10,'BGPEXC10 D
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","NOT",10,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM10,U,2)
I +BGPNUM11 D
.S NUM11CT=NUM11CT+1
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","INCL",11,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM11,U,2)
I 'BGPEXC11 S DEN11CT=DEN11CT+1
I +BGPEXC11 D
.S EXC11CT=EXC11CT+1
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","EXCL",11,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_"Excluded"
I 'BGPNUM11,'BGPEXC11 D
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","NOT",11,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM11,U,2)
I +BGPNUM12 D
.S NUM12CT=NUM12CT+1
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","INCL",12,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM12,U,2)
I 'BGPEXC12 S DEN12CT=DEN12CT+1
I +BGPEXC12 D
.S EXC12CT=EXC12CT+1
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","EXCL",12,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_"Excluded"
I 'BGPNUM12,'BGPEXC12 D
.S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","NOT",12,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM12,U,2)
;store counts back out to ^TMP global
;exclusion counts
F BGPI=1:1:12 S ^TMP("BGPMU0038",$J,BGPMUTF,"EXC",BGPI)=@("EXC"_BGPI_"CT")
;denominator counts
F BGPI=1:1:12 S ^TMP("BGPMU0038",$J,BGPMUTF,"DEN",BGPI)=@("DEN"_BGPI_"CT")
;numerator counts
F BGPI=1:1:12 S ^TMP("BGPMU0038",$J,BGPMUTF,"NUM",BGPI)=@("NUM"_BGPI_"CT")
;Setup iCare array for patient
F BGPI=1:1:12 S BGPNVAL=@("BGPNUM"_BGPI),BGPXVAL=@("BGPEXC"_BGPI),BGPICARE("MU.EP.0038."_(BGPI*2-1),BGPMUTF)='BGPXVAL_U_+BGPNVAL_U_+BGPXVAL_U_$P(BGPDEN1,U,2)_";"_$P(BGPNVAL,U,2)_U_$P(BGPXVAL,U,2)
K TOTALS,BGPI,BGPNVAL,BGPXVAL
K EXC1CT,EXC2CT,EXC3CT,EXC4CT,EXC5CT,EXC6CT,EXC7CT,EXC8CT,EXC9CT,EXC10CT,EXC11CT,EXC12CT
K DEN1CT,DEN2CT,DEN3CT,DEN4CT,DEN5CT,DEN6CT,DEN7CT,DEN8CT,DEN9CT,DEN10CT,DEN11CT,DEN12CT
K NUM1CT,NUM2CT,NUM3CT,NUM4CT,NUM5CT,NUM6CT,NUM7CT,NUM8CT,NUM9CT,NUM10CT,NUM11CT,NUM12CT
Q
BGPMUF01 ;IHS/MSC/MMT - MU Reports Measure NQF0038 ;02-Mar-2011 11:37;DU
+1 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
+2 ;
ENTRY ;EP
+1 NEW START,END,BGPDEN1,BGPNUM1,BGPNUM2,BGPNUM3,BGPNUM4,BGPNUM5,BGPNUM6,BGPNUM7,BGPNUM8,BGPNUM9,BGPNUM10,BGPNUM11,BGPNUM12
+2 NEW BGPEXC1,BGPEXC2,BGPEXC3,BGPEXC4,BGPEXC5,BGPEXC6,BGPEXC7,BGPEXC8,BGPEXC9,BGPEXC10,BGPEXC11,BGPEXC12
+3 NEW IEN,INV,VISIT,WTIEN,DATA,VDATE,BGPSIX,FIRST,VIEN,EXCEPT
+4 NEW BGPIVAL,BGPPTDOB,BGPPTDOB,BGPBDAY2
+5 SET (BGPDEN1,BGPNUM1,BGPNUM2,BGPNUM3,BGPNUM4,BGPNUM5,BGPNUM6,BGPNUM7,BGPNUM8,BGPNUM9,BGPNUM10,BGPNUM11,BGPNUM12)=0
+6 SET (BGPEXC1,BGPEXC2,BGPEXC3,BGPEXC4,BGPEXC5,BGPEXC6,BGPEXC7,BGPEXC8,BGPEXC9,BGPEXC10,BGPEXC11,BGPEXC12)=0
+7 SET START=9999999-BGPBDATE
SET END=9999999-BGPEDATE
+8 ;Pts must have turned 2 years old during the measurement period
+9 IF '(BGPAGEB=1)
QUIT
+10 IF '(BGPAGEE=2)
QUIT
+11 SET FIRST=END-0.1
FOR
SET FIRST=$ORDER(^AUPNVSIT("AA",DFN,FIRST))
IF FIRST=""!($PIECE(FIRST,".",1)>START)
QUIT
Begin DoDot:1
+12 SET IEN=0
FOR
SET IEN=$ORDER(^AUPNVSIT("AA",DFN,FIRST,IEN))
IF '+IEN
QUIT
Begin DoDot:2
+13 ;Check provider, Only visits for chosen provider
+14 IF '$$PRV^BGPMUUT1(IEN,BGPPROV)
QUIT
+15 ;Quit if the visit does not have a valid E&M code
+16 SET AENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU CIMM ENCOUNTER EM")
+17 ;borrowing taxonomy from Peds BMI
SET BENC=$$VSTPOV^BGPMUUT3(DFN,IEN,"BGPMU BMI ENC PEDS DX")
+18 IF (AENC=0)&(BENC=0)
QUIT
+19 SET DATA=$GET(^AUPNVSIT(IEN,0))
+20 SET VDATE=$PIECE($GET(^AUPNVSIT(IEN,0)),U,1)
SET VIEN=IEN
+21 ;This pt qualifies to be counted in the denominator
+22 SET BGPDEN1=1_U_"EN:"_$$DATE^BGPMUUTL(VDATE)
+23 QUIT
End DoDot:2
End DoDot:1
+24 ;Quit if patient will not be in denominator
+25 IF 'BGPDEN1
GOTO EXIT
+26 ;Calculate the day before the patient's 2nd birthday
+27 SET BGPPTDOB=$$DOB^AUPNPAT(DFN)
SET BGPBDAY2=($EXTRACT(BGPPTDOB,1,3)+2)_$EXTRACT(BGPPTDOB,4,7)
SET BGPBDAY2=$$FMADD^XLFDT(BGPBDAY2,-1)
+28 ;Num 1 - at least 4 DTaP
+29 ;1 IS had immunizations, 3 is had refusal, 4 is disease or NMI or contraindication
SET BGPIVAL=$$DTAP^BGP0D34(DFN,BGPBDAY2)
+30 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM1=BGPIVAL
+31 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC1=BGPIVAL
+32 ;Num 2 - at least 3 IPV
+33 SET BGPIVAL=$$OPV^BGP0D33(DFN,BGPBDAY2)
+34 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM2=BGPIVAL
+35 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC2=BGPIVAL
+36 ;Num 3 - MMR
+37 SET BGPIVAL=$$MMR^BGP0D33(DFN,BGPBDAY2)
+38 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM3=BGPIVAL
+39 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC3=BGPIVAL
+40 ;Num 4 - at least 2 HiB
+41 SET BGPIVAL=$$HIB^BGP0D35(DFN,BGPBDAY2)
+42 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM4=BGPIVAL
+43 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC4=BGPIVAL
+44 ;Num 5 - at least 3 Hepatitis B
+45 SET BGPIVAL=$$HEP^BGP0D35(DFN,BGPBDAY2)
+46 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM5=BGPIVAL_" B"
+47 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC5=BGPIVAL
+48 ;Num 6 - VZV
+49 SET BGPIVAL=$$VAR^BGP0D35(DFN,BGPBDAY2)
+50 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM6=BGPIVAL
+51 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC6=BGPIVAL
+52 ;Num 7 - at least 4 Pneumococcal
+53 SET BGPIVAL=$$PNEUMO^BGP0D35(DFN,BGPBDAY2,4)
+54 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM7=BGPIVAL
+55 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC7=BGPIVAL
+56 ;Num 8 - at least 2 Hepatitis A - this routine looks for IMM's in the same manner as CRS but uses CVX/CPT codes from the NQF spec
+57 SET BGPIVAL=$$HEPA^BGPMUF02(DFN,BGPBDAY2)
+58 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM8=BGPIVAL
+59 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC8=BGPIVAL
+60 ;Num 9 - at least 2 Rotavirus - this routine looks for IMM's in the same manner as CRS but uses CVX/CPT codes from the NQF spec
+61 SET BGPIVAL=$$ROTA^BGPMUF02(DFN,BGPBDAY2)
+62 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM9=BGPIVAL
+63 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC9=BGPIVAL
+64 ;Num 10 - at least 2 Influenza - this routine looks for IMM's in the same manner as CRS but uses CVX/CPT codes from the NQF spec
+65 SET BGPIVAL=$$FLU^BGPMUF02(DFN,BGPBDAY2)
+66 IF $PIECE(BGPIVAL,U,1)=1
SET BGPNUM10=BGPIVAL
+67 IF $PIECE(BGPIVAL,U,1)>1
SET BGPEXC10=BGPIVAL
+68 ;Num 11 - pt is TRUE for 1, 2, 3, 4, 5, 6
+69 IF +BGPNUM1
IF +BGPNUM2
IF +BGPNUM3
IF +BGPNUM4
IF +BGPNUM5
IF +BGPNUM6
SET BGPNUM11=1_U_"4:3:1:3:3:1"
+70 IF +BGPEXC1!+BGPEXC2!+BGPEXC3!+BGPEXC4!+BGPEXC5!+BGPEXC6
SET BGPEXC11=1
+71 ;Num 12 - pt is TRUE for 1, 2, 3, 4, 5, 6, 7
+72 IF BGPNUM1
IF +BGPNUM2
IF +BGPNUM3
IF +BGPNUM4
IF +BGPNUM5
IF +BGPNUM6
IF +BGPNUM7
SET BGPNUM12=1_U_"4:3:1:3:3:1:4"
+73 IF BGPEXC1!+BGPEXC2!+BGPEXC3!+BGPEXC4!+BGPEXC5!+BGPEXC6!+BGPEXC7
SET BGPEXC12=1
EXIT IF BGPDEN1
DO TOTALS
+1 KILL START,END,BGPDEN1,BGPNUM1,BGPNUM2,BGPNUM3,BGPNUM4,BGPNUM5,BGPNUM6,BGPNUM7,BGPNUM8,BGPNUM9,BGPNUM10,BGPNUM11,BGPNUM12
+2 KILL BGPEXC1,BGPEXC2,BGPEXC3,BGPEXC4,BGPEXC5,BGPEXC6,BGPEXC7,BGPEXC8,BGPEXC9,BGPEXC10,BGPEXC11,BGPEXC12
+3 KILL IEN,INV,VISIT,WTIEN,DATA,VDATE,BGPSIX,FIRST,VIEN,EXCEPT
+4 KILL BGPIVAL,BGPPTDOB,BGPPTDOB
+5 QUIT
TOTALS ;
+1 ;each numerator will need to maintain it's own denominator count and if the patient is in the exclusion list
+2 ; for a numerator, they should not be added to the denominator count for the numerator
+3 NEW TOTALS,BGPI,BGPNVAL,BGPXVAL
+4 NEW EXC1CT,EXC2CT,EXC3CT,EXC4CT,EXC5CT,EXC6CT,EXC7CT,EXC8CT,EXC9CT,EXC10CT,EXC11CT,EXC12CT
+5 NEW DEN1CT,DEN2CT,DEN3CT,DEN4CT,DEN5CT,DEN6CT,DEN7CT,DEN8CT,DEN9CT,DEN10CT,DEN11CT,DEN12CT
+6 NEW NUM1CT,NUM2CT,NUM3CT,NUM4CT,NUM5CT,NUM6CT,NUM7CT,NUM8CT,NUM9CT,NUM10CT,NUM11CT,NUM12CT
+7 SET EXCEPT=""
+8 ;total patients evaluated
+9 SET TOTALS=$GET(^TMP("BGPMU0038",$JOB,BGPMUTF,"TOT"))
+10 ;exclusion counts
+11 FOR BGPI=1:1:12
SET @("EXC"_BGPI_"CT")=+$GET(^TMP("BGPMU0038",$JOB,BGPMUTF,"EXC",BGPI))
+12 ;denominator counts
+13 FOR BGPI=1:1:12
SET @("DEN"_BGPI_"CT")=+$GET(^TMP("BGPMU0038",$JOB,BGPMUTF,"DEN",BGPI))
+14 ;numerator counts
+15 FOR BGPI=1:1:12
SET @("NUM"_BGPI_"CT")=+$GET(^TMP("BGPMU0038",$JOB,BGPMUTF,"NUM",BGPI))
+16 ;increment appropriate counters and maintain patient lists
+17 IF +BGPNUM1
Begin DoDot:1
+18 SET NUM1CT=NUM1CT+1
+19 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",1,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM1,U,2)
End DoDot:1
+20 IF 'BGPEXC1
SET DEN1CT=DEN1CT+1
+21 IF +BGPEXC1
Begin DoDot:1
+22 SET EXC1CT=EXC1CT+1
+23 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",1,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+24 IF 'BGPNUM1
IF 'BGPEXC1
Begin DoDot:1
+25 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",1,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM1,U,2)
End DoDot:1
+26 IF +BGPNUM2
Begin DoDot:1
+27 SET NUM2CT=NUM2CT+1
+28 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",2,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM2,U,2)
End DoDot:1
+29 IF 'BGPEXC2
SET DEN2CT=DEN2CT+1
+30 IF +BGPEXC2
Begin DoDot:1
+31 SET EXC2CT=EXC2CT+1
+32 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",2,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+33 IF 'BGPNUM2
IF 'BGPEXC2
Begin DoDot:1
+34 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",2,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM2,U,2)
End DoDot:1
+35 IF 'BGPEXC3
SET DEN3CT=DEN3CT+1
+36 IF +BGPNUM3
Begin DoDot:1
+37 SET NUM3CT=NUM3CT+1
+38 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",3,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM3,U,2)
End DoDot:1
+39 IF +BGPEXC3
Begin DoDot:1
+40 SET EXC3CT=EXC3CT+1
+41 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",3,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+42 IF 'BGPNUM3
IF 'BGPEXC3
Begin DoDot:1
+43 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",3,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM3,U,2)
End DoDot:1
+44 IF +BGPNUM4
Begin DoDot:1
+45 SET NUM4CT=NUM4CT+1
+46 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",4,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM4,U,2)
End DoDot:1
+47 IF 'BGPEXC4
SET DEN4CT=DEN4CT+1
+48 IF +BGPEXC4
Begin DoDot:1
+49 SET EXC4CT=EXC4CT+1
+50 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",4,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+51 IF 'BGPNUM4
IF 'BGPEXC4
Begin DoDot:1
+52 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",4,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM4,U,2)
End DoDot:1
+53 IF +BGPNUM5
Begin DoDot:1
+54 SET NUM5CT=NUM5CT+1
+55 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",5,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM5,U,2)
End DoDot:1
+56 IF 'BGPEXC5
SET DEN5CT=DEN5CT+1
+57 IF +BGPEXC5
Begin DoDot:1
+58 SET EXC5CT=EXC5CT+1
+59 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",5,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+60 IF 'BGPNUM5
IF 'BGPEXC5
Begin DoDot:1
+61 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",5,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM5,U,2)
End DoDot:1
+62 IF +BGPNUM6
Begin DoDot:1
+63 SET NUM6CT=NUM6CT+1
+64 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",6,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM6,U,2)
End DoDot:1
+65 IF 'BGPEXC6
SET DEN6CT=DEN6CT+1
+66 IF +BGPEXC6
Begin DoDot:1
+67 SET EXC6CT=EXC6CT+1
+68 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",6,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+69 IF 'BGPNUM6
IF 'BGPEXC6
Begin DoDot:1
+70 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",6,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM6,U,2)
End DoDot:1
+71 IF +BGPNUM7
Begin DoDot:1
+72 SET NUM7CT=NUM7CT+1
+73 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",7,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM7,U,2)
End DoDot:1
+74 IF 'BGPEXC7
SET DEN7CT=DEN7CT+1
+75 IF +BGPEXC7
Begin DoDot:1
+76 SET EXC7CT=EXC7CT+1
+77 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",7,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+78 IF 'BGPNUM7
IF 'BGPEXC7
Begin DoDot:1
+79 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",7,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM7,U,2)
End DoDot:1
+80 IF +BGPNUM8
Begin DoDot:1
+81 SET NUM8CT=NUM8CT+1
+82 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",8,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM8,U,2)
End DoDot:1
+83 IF 'BGPEXC8
SET DEN8CT=DEN8CT+1
+84 IF +BGPEXC8
Begin DoDot:1
+85 SET EXC8CT=EXC8CT+1
+86 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",8,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+87 IF 'BGPNUM8
IF 'BGPEXC8
Begin DoDot:1
+88 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",8,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM8,U,2)
End DoDot:1
+89 IF +BGPNUM9
Begin DoDot:1
+90 SET NUM9CT=NUM9CT+1
+91 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",9,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM9,U,2)
End DoDot:1
+92 IF 'BGPEXC9
SET DEN9CT=DEN9CT+1
+93 IF +BGPEXC9
Begin DoDot:1
+94 SET EXC9CT=EXC9CT+1
+95 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",9,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+96 IF 'BGPNUM9
IF 'BGPEXC9
Begin DoDot:1
+97 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",9,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM9,U,2)
End DoDot:1
+98 IF +BGPNUM10
Begin DoDot:1
+99 SET NUM10CT=NUM10CT+1
+100 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",10,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM10,U,2)
End DoDot:1
+101 IF 'BGPEXC10
SET DEN10CT=DEN10CT+1
+102 IF +BGPEXC10
Begin DoDot:1
+103 SET EXC10CT=EXC10CT+1
+104 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",10,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+105 IF 'BGPNUM10
IF 'BGPEXC10
Begin DoDot:1
+106 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",10,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM10,U,2)
End DoDot:1
+107 IF +BGPNUM11
Begin DoDot:1
+108 SET NUM11CT=NUM11CT+1
+109 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",11,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM11,U,2)
End DoDot:1
+110 IF 'BGPEXC11
SET DEN11CT=DEN11CT+1
+111 IF +BGPEXC11
Begin DoDot:1
+112 SET EXC11CT=EXC11CT+1
+113 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",11,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+114 IF 'BGPNUM11
IF 'BGPEXC11
Begin DoDot:1
+115 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",11,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM11,U,2)
End DoDot:1
+116 IF +BGPNUM12
Begin DoDot:1
+117 SET NUM12CT=NUM12CT+1
+118 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","INCL",12,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM12,U,2)
End DoDot:1
+119 IF 'BGPEXC12
SET DEN12CT=DEN12CT+1
+120 IF +BGPEXC12
Begin DoDot:1
+121 SET EXC12CT=EXC12CT+1
+122 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","EXCL",12,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_"Excluded"
End DoDot:1
+123 IF 'BGPNUM12
IF 'BGPEXC12
Begin DoDot:1
+124 SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"PAT","NOT",12,DFN)=DFN_U_$PIECE(BGPDEN1,U,2)_U_$PIECE(BGPNUM12,U,2)
End DoDot:1
+125 ;store counts back out to ^TMP global
+126 ;exclusion counts
+127 FOR BGPI=1:1:12
SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"EXC",BGPI)=@("EXC"_BGPI_"CT")
+128 ;denominator counts
+129 FOR BGPI=1:1:12
SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"DEN",BGPI)=@("DEN"_BGPI_"CT")
+130 ;numerator counts
+131 FOR BGPI=1:1:12
SET ^TMP("BGPMU0038",$JOB,BGPMUTF,"NUM",BGPI)=@("NUM"_BGPI_"CT")
+132 ;Setup iCare array for patient
+133 FOR BGPI=1:1:12
SET BGPNVAL=@("BGPNUM"_BGPI)
SET BGPXVAL=@("BGPEXC"_BGPI)
SET BGPICARE("MU.EP.0038."_(BGPI*2-1),BGPMUTF)='BGPXVAL_U_+BGPNVAL_U_+BGPXVAL_U_$PIECE(BGPDEN1,U,2)_";"_$PIECE(BGPNVAL,U,2)_U_$PIECE(BGPXVAL,U,2)
+134 KILL TOTALS,BGPI,BGPNVAL,BGPXVAL
+135 KILL EXC1CT,EXC2CT,EXC3CT,EXC4CT,EXC5CT,EXC6CT,EXC7CT,EXC8CT,EXC9CT,EXC10CT,EXC11CT,EXC12CT
+136 KILL DEN1CT,DEN2CT,DEN3CT,DEN4CT,DEN5CT,DEN6CT,DEN7CT,DEN8CT,DEN9CT,DEN10CT,DEN11CT,DEN12CT
+137 KILL NUM1CT,NUM2CT,NUM3CT,NUM4CT,NUM5CT,NUM6CT,NUM7CT,NUM8CT,NUM9CT,NUM10CT,NUM11CT,NUM12CT
+138 QUIT