BGPMUEHD ; IHS/MSC/MMT - EH Report Driver;02-Mar-2011 16:33;MGH
;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
;Eligible Hospital CQM evaluation driver
PROC ;EP
S BGPBT=$H
D JRNL^BGPMUUTL
S BGPJ=$J,BGPH=$H
S BGPCHWC=0
K ^XTMP("BGPMUHOS",BGPJ,BGPH) ; not sure if I need this Timestamp stuff or if it should be Provider Specific
D XTMP^BGPMUUTL("BGPMUHOS","Meaningful Use Hospital CQM Report")
;calculate 3 years before end of each time frame
S BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
S BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
D PROCCY,PROCPY,PROCBY
N ;
S BGPET=$H
Q
;
PROCCY ;EP - current time period
S BGPBDATE=BGPBD,BGPEDATE=BGPED,BGPTIME=1
S BGP365=BGPBDATE
S BGPMUTF="C"
D CALCMEAS
Q
PROCPY ;
S BGPBDATE=BGPPBD,BGPEDATE=BGPPED,BGPTIME=2
S BGP365=BGPBDATE
S BGPMUTF="P"
D CALCMEAS
Q
PROCBY ;
S BGPBDATE=BGPBBD,BGPEDATE=BGPBED,BGPTIME=3
S BGP365=BGPBDATE
S BGPMUTF="B"
D CALCMEAS
Q
CALCMEAS ;
D CALCMEAS^BGPMUDCI
Q
ACTUPAP(P,BDATE,EDATE,B) ;EP - is this patient in user pop? - NO EXPIRED CHECKS
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
Q 1
V2(P,BDATE,EDATE) ;EP
N A,B,V,X,G,E
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)
;
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 ""
BQI(BQIGREF) ;PEP - iCARE
; Input parameters
; BQIGREF = Global reference to store data
Q:BQIGREF=""
N BGPICARE,BGPIMEAS,BGPUMTF,BGPIIEN,BGPIDATA
S BGPBT=$H
D JRNL^BGPMUUTL
S BGPJ=$J,BGPH=$H
S BGPCHWC=0
K ^XTMP("BGPMUHOS",BGPJ,BGPH) ; not sure if I need this Timestamp stuff or if it should be Provider Specific
D XTMP^BGPMUUTL("BGPMUHOS","Meaningful Use Hospital CQM Report")
;calculate 3 years before end of each time frame
S BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
S BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
K BGPICARE
D PROCCY,PROCPY
;Move patient data for all requested measures from array to the passed in global reference
S BGPIMEAS=""
F S BGPIMEAS=$O(BGPICARE(BGPIMEAS)) Q:BGPIMEAS="" D
.S BGPMUTF=""
.F S BGPMUTF=$O(BGPICARE(BGPIMEAS,BGPMUTF)) Q:BGPMUTF="" D
..S DFN=""
..F S DFN=$O(BGPICARE(BGPIMEAS,BGPMUTF,DFN)) Q:DFN="" D
...S BGPIDATA=$G(BGPICARE(BGPIMEAS,BGPMUTF,DFN))
...;Lookup indicator ID
...S BGPIIEN=$O(^BGPMUIND(90596.11,"C",BGPIMEAS,0))
...;Store into global
...S @BQIGREF@(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("BGPMU0495",$J)
K ^TMP("BGPMU0497",$J)
K ^TMP("BGPMU0435",$J)
K ^TMP("BGPMU0436",$J)
K ^TMP("BGPMU0437",$J)
K ^TMP("BGPMU0438",$J)
K ^TMP("BGPMU0439",$J)
K ^TMP("BGPMU0440",$J)
K ^TMP("BGPMU0441",$J)
K ^TMP("BGPMU0371",$J)
K ^TMP("BGPMU0372",$J)
K ^TMP("BGPMU0373",$J)
K ^TMP("BGPMU0374",$J)
K ^TMP("BGPMU0375",$J)
K ^TMP("BGPMU0376",$J)
Q
BGPMUEHD ; IHS/MSC/MMT - EH Report Driver;02-Mar-2011 16:33;MGH
+1 ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
+2 ;Eligible Hospital CQM evaluation driver
PROC ;EP
+1 SET BGPBT=$HOROLOG
+2 DO JRNL^BGPMUUTL
+3 SET BGPJ=$JOB
SET BGPH=$HOROLOG
+4 SET BGPCHWC=0
+5 ; not sure if I need this Timestamp stuff or if it should be Provider Specific
KILL ^XTMP("BGPMUHOS",BGPJ,BGPH)
+6 DO XTMP^BGPMUUTL("BGPMUHOS","Meaningful Use Hospital CQM Report")
+7 ;calculate 3 years before end of each time frame
+8 SET BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
+9 SET BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
+10 DO PROCCY
DO PROCPY
DO PROCBY
N ;
+1 SET BGPET=$HOROLOG
+2 QUIT
+3 ;
PROCCY ;EP - current time period
+1 SET BGPBDATE=BGPBD
SET BGPEDATE=BGPED
SET BGPTIME=1
+2 SET BGP365=BGPBDATE
+3 SET BGPMUTF="C"
+4 DO CALCMEAS
+5 QUIT
PROCPY ;
+1 SET BGPBDATE=BGPPBD
SET BGPEDATE=BGPPED
SET BGPTIME=2
+2 SET BGP365=BGPBDATE
+3 SET BGPMUTF="P"
+4 DO CALCMEAS
+5 QUIT
PROCBY ;
+1 SET BGPBDATE=BGPBBD
SET BGPEDATE=BGPBED
SET BGPTIME=3
+2 SET BGP365=BGPBDATE
+3 SET BGPMUTF="B"
+4 DO CALCMEAS
+5 QUIT
CALCMEAS ;
+1 DO CALCMEAS^BGPMUDCI
+2 QUIT
ACTUPAP(P,BDATE,EDATE,B) ;EP - is this patient in user pop? - NO EXPIRED CHECKS
+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 QUIT 1
V2(P,BDATE,EDATE) ;EP
+1 NEW A,B,V,X,G,E
+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 ;
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 ""
BQI(BQIGREF) ;PEP - iCARE
+1 ; Input parameters
+2 ; BQIGREF = Global reference to store data
+3 IF BQIGREF=""
QUIT
+4 NEW BGPICARE,BGPIMEAS,BGPUMTF,BGPIIEN,BGPIDATA
+5 SET BGPBT=$HOROLOG
+6 DO JRNL^BGPMUUTL
+7 SET BGPJ=$JOB
SET BGPH=$HOROLOG
+8 SET BGPCHWC=0
+9 ; not sure if I need this Timestamp stuff or if it should be Provider Specific
KILL ^XTMP("BGPMUHOS",BGPJ,BGPH)
+10 DO XTMP^BGPMUUTL("BGPMUHOS","Meaningful Use Hospital CQM Report")
+11 ;calculate 3 years before end of each time frame
+12 SET BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
+13 SET BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
+14 KILL BGPICARE
+15 DO PROCCY
DO PROCPY
+16 ;Move patient data for all requested measures from array to the passed in global reference
+17 SET BGPIMEAS=""
+18 FOR
SET BGPIMEAS=$ORDER(BGPICARE(BGPIMEAS))
IF BGPIMEAS=""
QUIT
Begin DoDot:1
+19 SET BGPMUTF=""
+20 FOR
SET BGPMUTF=$ORDER(BGPICARE(BGPIMEAS,BGPMUTF))
IF BGPMUTF=""
QUIT
Begin DoDot:2
+21 SET DFN=""
+22 FOR
SET DFN=$ORDER(BGPICARE(BGPIMEAS,BGPMUTF,DFN))
IF DFN=""
QUIT
Begin DoDot:3
+23 SET BGPIDATA=$GET(BGPICARE(BGPIMEAS,BGPMUTF,DFN))
+24 ;Lookup indicator ID
+25 SET BGPIIEN=$ORDER(^BGPMUIND(90596.11,"C",BGPIMEAS,0))
+26 ;Store into global
+27 SET @BQIGREF@(DFN,BGPMUTF,BGPIIEN)=BGPIDATA
End DoDot:3
End DoDot:2
End DoDot:1
+28 DO BQIKILL
+29 KILL BGPICARE,BGPIMEAS,BGPUMTF,BGPIIEN,BGPIDATA
+30 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("BGPMU0495",$JOB)
+3 KILL ^TMP("BGPMU0497",$JOB)
+4 KILL ^TMP("BGPMU0435",$JOB)
+5 KILL ^TMP("BGPMU0436",$JOB)
+6 KILL ^TMP("BGPMU0437",$JOB)
+7 KILL ^TMP("BGPMU0438",$JOB)
+8 KILL ^TMP("BGPMU0439",$JOB)
+9 KILL ^TMP("BGPMU0440",$JOB)
+10 KILL ^TMP("BGPMU0441",$JOB)
+11 KILL ^TMP("BGPMU0371",$JOB)
+12 KILL ^TMP("BGPMU0372",$JOB)
+13 KILL ^TMP("BGPMU0373",$JOB)
+14 KILL ^TMP("BGPMU0374",$JOB)
+15 KILL ^TMP("BGPMU0375",$JOB)
+16 KILL ^TMP("BGPMU0376",$JOB)
+17 QUIT