Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BGPMUF01

BGPMUF01.m

Go to the documentation of this file.
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 +BGPNUM1 D
 .S NUM1CT=NUM1CT+1
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","INCL",1,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM1,U,2)
 I 'BGPEXC1 S DEN1CT=DEN1CT+1
 I +BGPEXC1 D
 .S EXC1CT=EXC1CT+1
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","EXCL",1,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_"Excluded"
 I 'BGPNUM1,'BGPEXC1 D
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","NOT",1,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM1,U,2)
 I +BGPNUM2 D
 .S NUM2CT=NUM2CT+1
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","INCL",2,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM2,U,2)
 I 'BGPEXC2 S DEN2CT=DEN2CT+1
 I +BGPEXC2 D
 .S EXC2CT=EXC2CT+1
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","EXCL",2,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_"Excluded"
 I 'BGPNUM2,'BGPEXC2 D
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","NOT",2,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM2,U,2)
 I 'BGPEXC3 S DEN3CT=DEN3CT+1
 I +BGPNUM3 D
 .S NUM3CT=NUM3CT+1
 .S ^TMP("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)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM8,U,2)
 I +BGPNUM9 D
 .S NUM9CT=NUM9CT+1
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","INCL",9,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_$P(BGPNUM9,U,2)
 I 'BGPEXC9 S DEN9CT=DEN9CT+1
 I +BGPEXC9 D
 .S EXC9CT=EXC9CT+1
 .S ^TMP("BGPMU0038",$J,BGPMUTF,"PAT","EXCL",9,DFN)=DFN_U_$P(BGPDEN1,U,2)_U_"Excluded"
 I 'BGPNUM9,'BGPEXC9 D
 .S ^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