BGPMUEPD ; IHS/MSC/MMT - EP Report Driver;02-Mar-2011 11:36;DU
;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
;
PROC ;EP
D BQIKILL
S BGPBT=$H
D JRNL^BGPMUUTL
S BGPJ=$J,BGPH=$H
S BGPCHWC=0
K ^XTMP("BGPMUEP",BGPJ,BGPH) ; not sure if I need this Timestamp stuff or if it should be Provider Specific
D XTMP^BGPMUUTL("BGPMUEP","Meaningful Use EP Report")
;calculate 3 years before end of each time frame
S BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
S BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
;process each patient
S DFN=0 F S DFN=$O(^AUPNPAT(DFN)) Q:DFN'=+DFN D
.I $G(BGPDESGP) S P=$$DP(DFN) I P'=BGPDESGP Q
.Q:'$D(^DPT(DFN,0))
.Q:$P($G(^DPT(DFN,0)),U)["DEMO,PATIENT"
.I $P($G(^BGPSITE(DUZ(2),0)),U,12) Q:$D(^DIBT($P(^BGPSITE(DUZ(2),0),U,12),1,DFN))
.D PROCCY,PROCPY,PROCBY
N ;
S BGPET=$H
Q
;
PROCCY ;EP - current time period
Q:'$D(^DPT(DFN,0))
Q:$P(^DPT(DFN,0),U,2)=""
Q:"FM"'[$P(^DPT(DFN,0),U,2)
S BGPBDATE=BGPBD,BGPEDATE=BGPED,BGPTIME=1
S BGP365=BGPBDATE
S BGPACTUP=$$ACTUPAP(DFN,BGP3YE,BGPEDATE,BGPBEN)
I 'BGPACTUP,'$G(BGPXPXPX),'$G(BGPIISO) Q
S BGPACTCL=$$ACTCL(DFN,BGP3YE,BGPEDATE) ;active clinical
S BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
S BGPSEX=$P(^DPT(DFN,0),U,2)
I $G(BGPIISO)=1 S BGPACTUP=1,BGPACTCL=1 ;if in scheduling option, everyone is user pop/active clinical
S BGPMUTF="C"
D CALCMEAS
Q
PROCPY ;
Q:'$D(^DPT(DFN,0))
Q:$P(^DPT(DFN,0),U,2)=""
Q:"FM"'[$P(^DPT(DFN,0),U,2)
S BGPBDATE=BGPPBD,BGPEDATE=BGPPED,BGPTIME=2
S BGP365=BGPBDATE
S BGPACTUP=$$ACTUPAP(DFN,BGPB3YE,BGPEDATE,BGPBEN)
I 'BGPACTUP Q ;if not in user pop, don't use patient
S BGPACTCL=$$ACTCL(DFN,BGPB3YE,BGPEDATE) ;active clinical
S BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
S BGPSEX=$P(^DPT(DFN,0),U,2)
S BGPMUTF="P"
D CALCMEAS
Q
PROCBY ;
Q:'$D(^DPT(DFN,0))
Q:$P(^DPT(DFN,0),U,2)=""
Q:"FM"'[$P(^DPT(DFN,0),U,2)
S BGPBDATE=BGPBBD,BGPEDATE=BGPBED,BGPTIME=3
S BGP365=BGPBDATE
S BGPACTUP=$$ACTUPAP(DFN,BGPB3YE,BGPEDATE,BGPBEN)
I 'BGPACTUP Q ;if not in user pop, don't use patient
S BGPACTCL=$$ACTCL(DFN,BGPB3YE,BGPEDATE) ;active clinical
S BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
S BGPSEX=$P(^DPT(DFN,0),U,2)
S BGPMUTF="B"
D CALCMEAS
Q
CALCMEAS ;
D CALCMEAS^BGPMUDCI
Q
V2(P,BDATE,EDATE) ;EP
N A,B,X,G,V
I '$D(^AUPNVSIT("AC",P)) Q ""
K ^TMP($J,"A")
S A="^TMP($J,""A"",",B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
I '$D(^TMP($J,"A",1)) Q ""
S (X,G)=0 F S X=$O(^TMP($J,"A",X)) Q:X'=+X!(G>2) S V=$P(^TMP($J,"A",X),U,5) D
.Q:'$D(^AUPNVSIT(V,0))
.Q:'$P(^AUPNVSIT(V,0),U,9)
.Q:$P(^AUPNVSIT(V,0),U,11)
.Q:"SAHO"'[$P(^AUPNVSIT(V,0),U,7)
.Q:"V"[$P(^AUPNVSIT(V,0),U,3)
.Q:$P(^AUPNVSIT(V,0),U,6)=""
.S G=G+1
.Q
Q $S(G<2:"",1:1)
;
ACTUPAP(P,BDATE,EDATE,B) ;EP - is this patient in user pop?
I B=1,$$BEN^AUPNPAT(P,"C")'="01" Q 0 ;must be Indian/Alaskan Native
I B=2,$$BEN^AUPNPAT(P,"C")="01" Q 0 ;must not be I/A
S DOD=$$DOD^AUPNPAT(P) I DOD]"",DOD<EDATE Q 0
Q 1
;
ACTCL(P,BDATE,EDATE) ;EP - clinical user
N X,G,F,S,V,B
S (X,G,F,S)=0 F S X=$O(^TMP($J,"A",X)) Q:X'=+X!(F) S V=$P(^TMP($J,"A",X),U,5) D
.Q:'$D(^AUPNVSIT(V,0))
.Q:'$P(^AUPNVSIT(V,0),U,9)
.Q:$P(^AUPNVSIT(V,0),U,11)
.Q:'$D(^AUPNVPRV("AD",V))
.Q:"SAHO"'[$P(^AUPNVSIT(V,0),U,7)
.Q:"V"[$P(^AUPNVSIT(V,0),U,3)
.Q:$P(^AUPNVSIT(V,0),U,6)=""
.S B=$$CLINIC^APCLV(V,"C")
.Q:B=""
.I G,S S F=1
.Q
Q $S(F:1,1:0)
;
LASTVD(P,BDATE,EDATE) ;
N A,B,V,X,G
I '$D(^AUPNVSIT("AC",P)) Q ""
K ^TMP($J,"A")
S A="^TMP($J,""A"",",B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
I '$D(^TMP($J,"A",1)) Q ""
S (X,G)=0 F S X=$O(^TMP($J,"A",X)) Q:X'=+X!(G) S V=$P(^TMP($J,"A",X),U,5) D
.Q:'$D(^AUPNVSIT(V,0))
.Q:'$P(^AUPNVSIT(V,0),U,9)
.Q:$P(^AUPNVSIT(V,0),U,11)
.Q:'$D(^AUPNVPRV("AD",V))
.Q:"SAHO"'[$P(^AUPNVSIT(V,0),U,7)
.Q:"V"[$P(^AUPNVSIT(V,0),U,3)
.Q:$P(^AUPNVSIT(V,0),U,6)=""
.S G=1
.Q
Q G
;
LOINC(A,B) ;
NEW %
S %=$P($G(^LAB(95.3,A,9999999)),U,2)
I %]"",$D(^ATXAX(B,21,"B",%)) Q 1
S %=$P($G(^LAB(95.3,A,0)),U)_"-"_$P($G(^LAB(95.3,A,0)),U,15)
I $D(^ATXAX(B,21,"B",%)) Q 1
Q ""
DP(P) ;
I $P(^AUPNPAT(P,0),U,14) Q $P(^AUPNPAT(P,0),U,14)
I $T(ALLDP^BDPAPI)="" Q ""
NEW X
D ALLDP^BDPAPI(P,"DESIGNATED PRIMARY PROVIDER",.X)
Q $P($G(X("DESIGNATED PRIMARY PROVIDER")),U,2)
;
BQI(BQIGREF,BGPPROV) ;PEP - iCARE
; Input parameters
; BQIGREF = Global reference to store data
; BGPPROV = Provider IEN
Q:BQIGREF=""
N BGPICARE,BGPIMEAS,BGPUMTF,BGPIIEN,BGPIDATA
S BGPBT=$H
D JRNL^BGPMUUTL
S BGPJ=$J,BGPH=$H
S BGPCHWC=0
K ^XTMP("BGPMUEP",BGPJ,BGPH) ; not sure if I need this Timestamp stuff or if it should be Provider Specific
D XTMP^BGPMUUTL("BGPMUEP","Meaningful Use EP Report")
;calculate 3 years before end of each time frame
S BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
S BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
;process each patient
S DFN=0 F S DFN=$O(^AUPNPAT(DFN)) Q:DFN'=+DFN D
.Q:'$D(^DPT(DFN,0))
.Q:$P($G(^DPT(DFN,0)),U)["DEMO,PATIENT"
.I $P($G(^BGPSITE(DUZ(2),0)),U,12) Q:$D(^DIBT($P(^BGPSITE(DUZ(2),0),U,12),1,DFN))
.K BGPICARE
.D PROCCY
.I $G(BGPPBD)'="" D PROCPY
.;Move patient data for all requested measures from array to the passed in global reference
.; BGPICARE(INDICATOR_ID,Timeframe)=Denom Flag ^ Num Flag ^ Excl Flag ^ Denom disp ; Num disp ^ Excl disp
.S BGPIMEAS=""
.F S BGPIMEAS=$O(BGPICARE(BGPIMEAS)) Q:BGPIMEAS="" D
..S BGPMUTF=""
..F S BGPMUTF=$O(BGPICARE(BGPIMEAS,BGPMUTF)) Q:BGPMUTF="" D
...S BGPIDATA=$G(BGPICARE(BGPIMEAS,BGPMUTF))
...;Lookup indicator ID
...S BGPIIEN=$O(^BGPMUIND(90596.11,"C",BGPIMEAS,0))
...;Store into global - ONLY if measure ID exists
...I BGPIIEN'="" S @BQIGREF@(BGPPROV,DFN,BGPMUTF,BGPIIEN)=BGPIDATA
D BQIKILL
K BGPICARE,BGPIMEAS,BGPUMTF,BGPIIEN,BGPIDATA
Q
BQIKILL ; TEMPORARY Subroutine to kill off ^TMP globals created by running measure evals without printing
;This routine should be removed once a better system for killing off ^TMP globals has been implemented
K ^TMP("BGPMU0001",$J)
K ^TMP("BGPMU0002",$J)
K ^TMP("BGPMU0004",$J)
K ^TMP("BGPMU0012",$J)
K ^TMP("BGPMU0013",$J)
K ^TMP("BGPMU0014",$J)
K ^TMP("BGPMU0018",$J)
K ^TMP("BGPMU0024",$J)
K ^TMP("BGPMU0027",$J)
K ^TMP("BGPMU0028A",$J)
K ^TMP("BGPMU0028B",$J)
K ^TMP("BGPMU0031",$J)
K ^TMP("BGPMU0032",$J)
K ^TMP("BGPMU0033",$J)
K ^TMP("BGPMU0034",$J)
K ^TMP("BGPMU0036",$J)
K ^TMP("BGPMU0038",$J)
K ^TMP("BGPMU0041",$J)
K ^TMP("BGPMU0043",$J)
K ^TMP("BGPMU0047",$J)
K ^TMP("BGPMU0052",$J)
K ^TMP("BGPMU0055",$J)
K ^TMP("BGPMU0056",$J)
K ^TMP("BGPMU0059",$J)
K ^TMP("BGPMU0061",$J)
K ^TMP("BGPMU0062",$J)
K ^TMP("BGPMU0064",$J)
K ^TMP("BGPMU0067",$J)
K ^TMP("BGPMU0068",$J)
K ^TMP("BGPMU0070",$J)
K ^TMP("BGPMU0073",$J)
K ^TMP("BGPMU0074",$J)
K ^TMP("BGPMU0075",$J)
K ^TMP("BGPMU0081",$J)
K ^TMP("BGPMU0083",$J)
K ^TMP("BGPMU0084",$J)
K ^TMP("BGPMU0086",$J)
K ^TMP("BGPMU0088",$J)
K ^TMP("BGPMU0089",$J)
K ^TMP("BGPMU0105",$J)
K ^TMP("BGPMU0385",$J)
K ^TMP("BGPMU0387",$J)
K ^TMP("BGPMU0389",$J)
K ^TMP("BGPMU0421",$J)
K ^TMP("BGPMU0575",$J)
Q
BGPMUEPD ; IHS/MSC/MMT - EP Report Driver;02-Mar-2011 11:36;DU
+1 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
+2 ;
PROC ;EP
+1 DO BQIKILL
+2 SET BGPBT=$HOROLOG
+3 DO JRNL^BGPMUUTL
+4 SET BGPJ=$JOB
SET BGPH=$HOROLOG
+5 SET BGPCHWC=0
+6 ; not sure if I need this Timestamp stuff or if it should be Provider Specific
KILL ^XTMP("BGPMUEP",BGPJ,BGPH)
+7 DO XTMP^BGPMUUTL("BGPMUEP","Meaningful Use EP Report")
+8 ;calculate 3 years before end of each time frame
+9 SET BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
+10 SET BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
+11 ;process each patient
+12 SET DFN=0
FOR
SET DFN=$ORDER(^AUPNPAT(DFN))
IF DFN'=+DFN
QUIT
Begin DoDot:1
+13 IF $GET(BGPDESGP)
SET P=$$DP(DFN)
IF P'=BGPDESGP
QUIT
+14 IF '$DATA(^DPT(DFN,0))
QUIT
+15 IF $PIECE($GET(^DPT(DFN,0)),U)["DEMO,PATIENT"
QUIT
+16 IF $PIECE($GET(^BGPSITE(DUZ(2),0)),U,12)
IF $DATA(^DIBT($PIECE(^BGPSITE(DUZ(2),0),U,12),1,DFN))
QUIT
+17 DO PROCCY
DO PROCPY
DO PROCBY
End DoDot:1
N ;
+1 SET BGPET=$HOROLOG
+2 QUIT
+3 ;
PROCCY ;EP - current time period
+1 IF '$DATA(^DPT(DFN,0))
QUIT
+2 IF $PIECE(^DPT(DFN,0),U,2)=""
QUIT
+3 IF "FM"'[$PIECE(^DPT(DFN,0),U,2)
QUIT
+4 SET BGPBDATE=BGPBD
SET BGPEDATE=BGPED
SET BGPTIME=1
+5 SET BGP365=BGPBDATE
+6 SET BGPACTUP=$$ACTUPAP(DFN,BGP3YE,BGPEDATE,BGPBEN)
+7 IF 'BGPACTUP
IF '$GET(BGPXPXPX)
IF '$GET(BGPIISO)
QUIT
+8 ;active clinical
SET BGPACTCL=$$ACTCL(DFN,BGP3YE,BGPEDATE)
+9 SET BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
+10 SET BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
+11 SET BGPSEX=$PIECE(^DPT(DFN,0),U,2)
+12 ;if in scheduling option, everyone is user pop/active clinical
IF $GET(BGPIISO)=1
SET BGPACTUP=1
SET BGPACTCL=1
+13 SET BGPMUTF="C"
+14 DO CALCMEAS
+15 QUIT
PROCPY ;
+1 IF '$DATA(^DPT(DFN,0))
QUIT
+2 IF $PIECE(^DPT(DFN,0),U,2)=""
QUIT
+3 IF "FM"'[$PIECE(^DPT(DFN,0),U,2)
QUIT
+4 SET BGPBDATE=BGPPBD
SET BGPEDATE=BGPPED
SET BGPTIME=2
+5 SET BGP365=BGPBDATE
+6 SET BGPACTUP=$$ACTUPAP(DFN,BGPB3YE,BGPEDATE,BGPBEN)
+7 ;if not in user pop, don't use patient
IF 'BGPACTUP
QUIT
+8 ;active clinical
SET BGPACTCL=$$ACTCL(DFN,BGPB3YE,BGPEDATE)
+9 SET BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
+10 SET BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
+11 SET BGPSEX=$PIECE(^DPT(DFN,0),U,2)
+12 SET BGPMUTF="P"
+13 DO CALCMEAS
+14 QUIT
PROCBY ;
+1 IF '$DATA(^DPT(DFN,0))
QUIT
+2 IF $PIECE(^DPT(DFN,0),U,2)=""
QUIT
+3 IF "FM"'[$PIECE(^DPT(DFN,0),U,2)
QUIT
+4 SET BGPBDATE=BGPBBD
SET BGPEDATE=BGPBED
SET BGPTIME=3
+5 SET BGP365=BGPBDATE
+6 SET BGPACTUP=$$ACTUPAP(DFN,BGPB3YE,BGPEDATE,BGPBEN)
+7 ;if not in user pop, don't use patient
IF 'BGPACTUP
QUIT
+8 ;active clinical
SET BGPACTCL=$$ACTCL(DFN,BGPB3YE,BGPEDATE)
+9 SET BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
+10 SET BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
+11 SET BGPSEX=$PIECE(^DPT(DFN,0),U,2)
+12 SET BGPMUTF="B"
+13 DO CALCMEAS
+14 QUIT
CALCMEAS ;
+1 DO CALCMEAS^BGPMUDCI
+2 QUIT
V2(P,BDATE,EDATE) ;EP
+1 NEW A,B,X,G,V
+2 IF '$DATA(^AUPNVSIT("AC",P))
QUIT ""
+3 KILL ^TMP($JOB,"A")
+4 SET A="^TMP($J,""A"","
SET B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(B,A)
+5 IF '$DATA(^TMP($JOB,"A",1))
QUIT ""
+6 SET (X,G)=0
FOR
SET X=$ORDER(^TMP($JOB,"A",X))
IF X'=+X!(G>2)
QUIT
SET V=$PIECE(^TMP($JOB,"A",X),U,5)
Begin DoDot:1
+7 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+8 IF '$PIECE(^AUPNVSIT(V,0),U,9)
QUIT
+9 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+10 IF "SAHO"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+11 IF "V"[$PIECE(^AUPNVSIT(V,0),U,3)
QUIT
+12 IF $PIECE(^AUPNVSIT(V,0),U,6)=""
QUIT
+13 SET G=G+1
+14 QUIT
End DoDot:1
+15 QUIT $SELECT(G<2:"",1:1)
+16 ;
ACTUPAP(P,BDATE,EDATE,B) ;EP - is this patient in user pop?
+1 ;must be Indian/Alaskan Native
IF B=1
IF $$BEN^AUPNPAT(P,"C")'="01"
QUIT 0
+2 ;must not be I/A
IF B=2
IF $$BEN^AUPNPAT(P,"C")="01"
QUIT 0
+3 SET DOD=$$DOD^AUPNPAT(P)
IF DOD]""
IF DOD<EDATE
QUIT 0
+4 QUIT 1
+5 ;
ACTCL(P,BDATE,EDATE) ;EP - clinical user
+1 NEW X,G,F,S,V,B
+2 SET (X,G,F,S)=0
FOR
SET X=$ORDER(^TMP($JOB,"A",X))
IF X'=+X!(F)
QUIT
SET V=$PIECE(^TMP($JOB,"A",X),U,5)
Begin DoDot:1
+3 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+4 IF '$PIECE(^AUPNVSIT(V,0),U,9)
QUIT
+5 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+6 IF '$DATA(^AUPNVPRV("AD",V))
QUIT
+7 IF "SAHO"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+8 IF "V"[$PIECE(^AUPNVSIT(V,0),U,3)
QUIT
+9 IF $PIECE(^AUPNVSIT(V,0),U,6)=""
QUIT
+10 SET B=$$CLINIC^APCLV(V,"C")
+11 IF B=""
QUIT
+12 IF G
IF S
SET F=1
+13 QUIT
End DoDot:1
+14 QUIT $SELECT(F:1,1:0)
+15 ;
LASTVD(P,BDATE,EDATE) ;
+1 NEW A,B,V,X,G
+2 IF '$DATA(^AUPNVSIT("AC",P))
QUIT ""
+3 KILL ^TMP($JOB,"A")
+4 SET A="^TMP($J,""A"","
SET B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(B,A)
+5 IF '$DATA(^TMP($JOB,"A",1))
QUIT ""
+6 SET (X,G)=0
FOR
SET X=$ORDER(^TMP($JOB,"A",X))
IF X'=+X!(G)
QUIT
SET V=$PIECE(^TMP($JOB,"A",X),U,5)
Begin DoDot:1
+7 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+8 IF '$PIECE(^AUPNVSIT(V,0),U,9)
QUIT
+9 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+10 IF '$DATA(^AUPNVPRV("AD",V))
QUIT
+11 IF "SAHO"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+12 IF "V"[$PIECE(^AUPNVSIT(V,0),U,3)
QUIT
+13 IF $PIECE(^AUPNVSIT(V,0),U,6)=""
QUIT
+14 SET G=1
+15 QUIT
End DoDot:1
+16 QUIT G
+17 ;
LOINC(A,B) ;
+1 NEW %
+2 SET %=$PIECE($GET(^LAB(95.3,A,9999999)),U,2)
+3 IF %]""
IF $DATA(^ATXAX(B,21,"B",%))
QUIT 1
+4 SET %=$PIECE($GET(^LAB(95.3,A,0)),U)_"-"_$PIECE($GET(^LAB(95.3,A,0)),U,15)
+5 IF $DATA(^ATXAX(B,21,"B",%))
QUIT 1
+6 QUIT ""
DP(P) ;
+1 IF $PIECE(^AUPNPAT(P,0),U,14)
QUIT $PIECE(^AUPNPAT(P,0),U,14)
+2 IF $TEXT(ALLDP^BDPAPI)=""
QUIT ""
+3 NEW X
+4 DO ALLDP^BDPAPI(P,"DESIGNATED PRIMARY PROVIDER",.X)
+5 QUIT $PIECE($GET(X("DESIGNATED PRIMARY PROVIDER")),U,2)
+6 ;
BQI(BQIGREF,BGPPROV) ;PEP - iCARE
+1 ; Input parameters
+2 ; BQIGREF = Global reference to store data
+3 ; BGPPROV = Provider IEN
+4 IF BQIGREF=""
QUIT
+5 NEW BGPICARE,BGPIMEAS,BGPUMTF,BGPIIEN,BGPIDATA
+6 SET BGPBT=$HOROLOG
+7 DO JRNL^BGPMUUTL
+8 SET BGPJ=$JOB
SET BGPH=$HOROLOG
+9 SET BGPCHWC=0
+10 ; not sure if I need this Timestamp stuff or if it should be Provider Specific
KILL ^XTMP("BGPMUEP",BGPJ,BGPH)
+11 DO XTMP^BGPMUUTL("BGPMUEP","Meaningful Use EP Report")
+12 ;calculate 3 years before end of each time frame
+13 SET BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
+14 SET BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
+15 ;process each patient
+16 SET DFN=0
FOR
SET DFN=$ORDER(^AUPNPAT(DFN))
IF DFN'=+DFN
QUIT
Begin DoDot:1
+17 IF '$DATA(^DPT(DFN,0))
QUIT
+18 IF $PIECE($GET(^DPT(DFN,0)),U)["DEMO,PATIENT"
QUIT
+19 IF $PIECE($GET(^BGPSITE(DUZ(2),0)),U,12)
IF $DATA(^DIBT($PIECE(^BGPSITE(DUZ(2),0),U,12),1,DFN))
QUIT
+20 KILL BGPICARE
+21 DO PROCCY
+22 IF $GET(BGPPBD)'=""
DO PROCPY
+23 ;Move patient data for all requested measures from array to the passed in global reference
+24 ; BGPICARE(INDICATOR_ID,Timeframe)=Denom Flag ^ Num Flag ^ Excl Flag ^ Denom disp ; Num disp ^ Excl disp
+25 SET BGPIMEAS=""
+26 FOR
SET BGPIMEAS=$ORDER(BGPICARE(BGPIMEAS))
IF BGPIMEAS=""
QUIT
Begin DoDot:2
+27 SET BGPMUTF=""
+28 FOR
SET BGPMUTF=$ORDER(BGPICARE(BGPIMEAS,BGPMUTF))
IF BGPMUTF=""
QUIT
Begin DoDot:3
+29 SET BGPIDATA=$GET(BGPICARE(BGPIMEAS,BGPMUTF))
+30 ;Lookup indicator ID
+31 SET BGPIIEN=$ORDER(^BGPMUIND(90596.11,"C",BGPIMEAS,0))
+32 ;Store into global - ONLY if measure ID exists
+33 IF BGPIIEN'=""
SET @BQIGREF@(BGPPROV,DFN,BGPMUTF,BGPIIEN)=BGPIDATA
End DoDot:3
End DoDot:2
End DoDot:1
+34 DO BQIKILL
+35 KILL BGPICARE,BGPIMEAS,BGPUMTF,BGPIIEN,BGPIDATA
+36 QUIT
BQIKILL ; TEMPORARY Subroutine to kill off ^TMP globals created by running measure evals without printing
+1 ;This routine should be removed once a better system for killing off ^TMP globals has been implemented
+2 KILL ^TMP("BGPMU0001",$JOB)
+3 KILL ^TMP("BGPMU0002",$JOB)
+4 KILL ^TMP("BGPMU0004",$JOB)
+5 KILL ^TMP("BGPMU0012",$JOB)
+6 KILL ^TMP("BGPMU0013",$JOB)
+7 KILL ^TMP("BGPMU0014",$JOB)
+8 KILL ^TMP("BGPMU0018",$JOB)
+9 KILL ^TMP("BGPMU0024",$JOB)
+10 KILL ^TMP("BGPMU0027",$JOB)
+11 KILL ^TMP("BGPMU0028A",$JOB)
+12 KILL ^TMP("BGPMU0028B",$JOB)
+13 KILL ^TMP("BGPMU0031",$JOB)
+14 KILL ^TMP("BGPMU0032",$JOB)
+15 KILL ^TMP("BGPMU0033",$JOB)
+16 KILL ^TMP("BGPMU0034",$JOB)
+17 KILL ^TMP("BGPMU0036",$JOB)
+18 KILL ^TMP("BGPMU0038",$JOB)
+19 KILL ^TMP("BGPMU0041",$JOB)
+20 KILL ^TMP("BGPMU0043",$JOB)
+21 KILL ^TMP("BGPMU0047",$JOB)
+22 KILL ^TMP("BGPMU0052",$JOB)
+23 KILL ^TMP("BGPMU0055",$JOB)
+24 KILL ^TMP("BGPMU0056",$JOB)
+25 KILL ^TMP("BGPMU0059",$JOB)
+26 KILL ^TMP("BGPMU0061",$JOB)
+27 KILL ^TMP("BGPMU0062",$JOB)
+28 KILL ^TMP("BGPMU0064",$JOB)
+29 KILL ^TMP("BGPMU0067",$JOB)
+30 KILL ^TMP("BGPMU0068",$JOB)
+31 KILL ^TMP("BGPMU0070",$JOB)
+32 KILL ^TMP("BGPMU0073",$JOB)
+33 KILL ^TMP("BGPMU0074",$JOB)
+34 KILL ^TMP("BGPMU0075",$JOB)
+35 KILL ^TMP("BGPMU0081",$JOB)
+36 KILL ^TMP("BGPMU0083",$JOB)
+37 KILL ^TMP("BGPMU0084",$JOB)
+38 KILL ^TMP("BGPMU0086",$JOB)
+39 KILL ^TMP("BGPMU0088",$JOB)
+40 KILL ^TMP("BGPMU0089",$JOB)
+41 KILL ^TMP("BGPMU0105",$JOB)
+42 KILL ^TMP("BGPMU0385",$JOB)
+43 KILL ^TMP("BGPMU0387",$JOB)
+44 KILL ^TMP("BGPMU0389",$JOB)
+45 KILL ^TMP("BGPMU0421",$JOB)
+46 KILL ^TMP("BGPMU0575",$JOB)
+47 QUIT