APCM13E9 ;IHS/CMI/LAB - IHS MU;
;;1.0;IHS MU PERFORMANCE REPORTS;**2,4,5,6**;MAR 26, 2012;Build 65
;;;;;;Build 3
;IHS/CMI/LAB - PATCH 4 REMOVED CPOE KEY LOGIC
CPOE ;EP - CALCULATE EPRESCRIBING
;for each provider or for the facility count all prescriptions that meet criteria and if it is not written it meets numerator
K ^TMP($J,"PATSRX")
K APCMRXS
D TOTRX
K ^TMP($J,"ORDERSPROCESSED")
NEW APCMP,N,F
S (APCMD1,APCMN1)=0
I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
.I $P($G(APCMRXS(APCMP)),U,1)<100 S F=$P(^APCM13OB(APCMIC,0),U,11) D G D
..D S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had < 100 medication orders during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
D .;set denominator value into field
.S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
.S N=$P($G(APCMRXS(APCMP)),U,1) ;returns # of prescriptions^# not written by nature of order
.D S^APCM13E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
.;now set patient list for this provider
.S P=0 F S P=$O(^TMP($J,"PATSRX",APCMP,P)) Q:P'=+P D
..S D=$P(^TMP($J,"PATSRX",APCMP,P),U,1),N=$P(^TMP($J,"PATSRX",APCMP,P),U,2) S APCMVALU="# Orders: "_D_"|||"_"# CPOE: "_N_" # NOT CPOE: "_(D-N)
..S DFN=P D SETLIST^APCM13E1
.;numerator?
.S F=$P(^APCM13OB(APCMIC,0),U,9)
.S N=$P($G(APCMRXS(APCMP)),U,2)
.D S^APCM13E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
I APCMRPTT=2 D
.S APCMP=APCMFAC
.S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
.S N=$P($G(APCMRXS(APCMFAC)),U,1) ;returns # of prescriptions^# not written by nature of order
.D S^APCM13E1(APCMRPT,APCMIC,N,APCMFAC,APCMRPTT,APCMTIME,F)
.;now set patient list for this FACILITY
.S P=0 F S P=$O(^TMP($J,"PATSRX",APCMFAC,P)) Q:P'=+P D
..S D=$P(^TMP($J,"PATSRX",APCMFAC,P),U,1),N=$P(^TMP($J,"PATSRX",APCMFAC,P),U,2) S APCMVALU="# Orders: "_D_"|||"_"# CPOE: "_N_" # NOT CPOE: "_(D-N)
..S DFN=P D SETLIST^APCM13E1
.;numerator?
.S F=$P(^APCM13OB(APCMIC,0),U,9)
.S N=$P($G(APCMRXS(APCMFAC)),U,2)
.D S^APCM13E1(APCMRPT,APCMIC,N,APCMFAC,APCMRPTT,APCMTIME,F)
K ^TMP($J,"PATSRX")
Q
TOTRX ;EP - did patient have a RX in file 52 with an issue date
;between BD and ED
;SET ARRAY APCMRXS to APCMRXS(prov ien)=denom^numer
K ^TMP($J,"ORDERSPROCESSED")
NEW ID,C,Y,X,D,S,N,A,B,R,PAT,G,ORIEN,ORPFILE,ORPTST,ORNS,PATLOC,ORACT0,ORORD,ORDEB
S ID=$$FMADD^XLFDT(APCMBDAT,-1),ID=ID_".9999"
F S ID=$O(^OR(100,"AF",ID)) Q:ID'=+ID!($P(ID,".")>APCMEDAT) D
.S ORIEN=0 F S ORIEN=$O(^OR(100,"AF",ID,ORIEN)) Q:ORIEN'=+ORIEN D
..Q:$D(^TMP($J,"ORDERSPROCESSED",ORIEN))
..S ^TMP($J,"ORDERSPROCESSED",ORIEN)=""
..S ORPFILE=$P($G(^OR(100,ORIEN,0)),"^",2) Q:ORPFILE="" ;Quit if no object of order
..Q:$P(ORPFILE,";",2)'["DPT" ;only patient orders
..S PAT=+$P($G(^OR(100,ORIEN,0)),U,2) ;GET Patient DFN
..Q:$$DEMO^APCLUTL(PAT,APCMDEMO) ;Quit if demo patient
..Q:+$P($G(^OR(100,ORIEN,3)),"^",11)'=0 ;190 quit if order type not standard
..S ORPTST=$P($G(^OR(100,ORIEN,0)),"^",12) ;patient status (in/out)
..S ORNS=$$NMSP($P($G(^OR(100,ORIEN,0)),"^",14)) ;get package namespace
..I ORNS'="PS" Q ;if not getting all types of orders then quit if order is not from pharmacy
..S ORACT0=$G(^OR(100,ORIEN,8,1,0))
..Q:$P(ORACT0,U,1)'=ID
..S ORORD=$P(ORACT0,"^",12) ;ORORD holds nature of order ien
..Q:ORORD=4 ;skip service corrections
..S ORPVID=$P(ORACT0,"^",3)
..;I ORPTST="O",ORNS="PS",$G(^OR(100,ORIEN,4))=+$G(^OR(100,ORIEN,4)),$L($T(EN^PSOTPCUL)) Q:$$EN^PSOTPCUL($G(^OR(100,ORIEN,4))) ;196 Don't count if outpatient pharm order is a transitional pharmacy benefit order
..S G=0
..I APCMRPTT=1 D
...Q:ORPTST'="O" ;Quit if patient status is not outpatient and in EP report
...S ORPVID=$P(ORACT0,"^",3) Q:'$D(APCMPRV(ORPVID)) ;quit if ordering provider doesn't match user selected provider
...S PATLOC=+$P($G(^OR(100,ORIEN,0)),U,10)
...S C="" I PATLOC,$D(^SC(PATLOC,0)) S C=$P(^SC(PATLOC,0),U,7) I C Q:$P($G(^DIC(40.7,C,0)),U,2)=30 ;IF ER IN HOSP LOC Q
...S G=1
..I APCMRPTT=2 D
...I ORPTST="I" S G=1 Q
...S PATLOC=+$P($G(^OR(100,ORIEN,0)),U,10)
...Q:'PATLOC
...S C="" I PATLOC,$D(^SC(PATLOC,0)) S C=$P(^SC(PATLOC,0),U,7) I C Q:$P($G(^DIC(40.7,C,0)),U,2)'=30 ;IF NOT ER IN HOSP LOC Q
...I PATLOC,$D(^SC(PATLOC,0)) S C=$P(^SC(PATLOC,0),U,4) I C,C'=APCMFAC Q
...S G=1
..Q:'G
..S ORORD=$P(ORACT0,"^",12) ;ORORD holds nature of order ien
..;S ORPVNM=$P($G(^VA(200,ORPVID,0)),"^") ;get provider name
..;Q:'$D(^XUSEC("ORES",ORPVID)) ;quit if ordering provider doesn't have ORES key DBIA # 10076 allows direct read of XUSEC =====> PM
..;Q:"^1^2^3^5^8^"'[("^"_ORORD_"^") ;quit if NATUS O=$O(^OR(100,"AF" ====> PM REPORT BUT NOT IN IHS MU LOGIC
..;SET DENOM COUNT FOR THIS EP = INCREMENT BY 1
..;I DUZ=2793 W !,"PAT: ",$P(^DPT(PAT,0),U,1),"DATE: ",$$FMTE^XLFDT(ID)," ORDER: ",ORIEN," NATURE: ",ORORD
..I APCMRPTT=1 S $P(APCMRXS(ORPVID),U,1)=$P($G(APCMRXS(ORPVID)),U,1)+1,$P(^TMP($J,"PATSRX",ORPVID,PAT),U,1)=$P($G(^TMP($J,"PATSRX",ORPVID,PAT)),U,1)+1
..I APCMRPTT=2 S $P(APCMRXS(APCMFAC),U,1)=$P($G(APCMRXS(APCMFAC)),U,1)+1,$P(^TMP($J,"PATSRX",APCMFAC,PAT),U,1)=$P($G(^TMP($J,"PATSRX",APCMFAC,PAT)),U,1)+1
..;
..;now check to see if it has a nature of order IS equal to 1-written if so, quit and don't set numerator
..I ORORD=1 Q ;this is a written order so do not put in numerator
..S ORDEB=$P(^OR(100,ORIEN,8,1,0),"^",13) ;this is the person who entered the order (ENTERED BY)
..;Q:'$$ORES(ORDEB,$P(ID,".",1)) ;quit if this person does not have ORES or ORESLE on date of order so don't count in numerator
..; DUZ=2793 W " NUMER"
..I APCMRPTT=1 S $P(APCMRXS(ORPVID),U,2)=$P(APCMRXS(ORPVID),U,2)+1,$P(^TMP($J,"PATSRX",ORPVID,PAT),U,2)=$P($G(^TMP($J,"PATSRX",ORPVID,PAT)),U,2)+1
..I APCMRPTT=2 S $P(APCMRXS(APCMFAC),U,2)=$P($G(APCMRXS(APCMFAC)),U,2)+1,$P(^TMP($J,"PATSRX",APCMFAC,PAT),U,2)=$P($G(^TMP($J,"PATSRX",APCMFAC,PAT)),U,2)+1
Q
NMSP(PKG) ; -- Returns package namespace from pointer
N Y S Y=$$GET1^DIQ(9.4,+PKG_",",1)
S:$E(Y,1,2)="PS" Y="PS" S:Y="GMRV" Y="OR"
Q Y
;
ORES(R,D) ;EP - DID PROVIDER HAVE ORES OR ORESLE ON DATE D
I '$G(R) Q ""
I '$D(^VA(200,R,0)) Q ""
NEW K,J
S K=$O(^DIC(19.1,"B","ORES",0))
S J=$O(^DIC(19.1,"B","ORELSE",0))
I $D(^VA(200,R,51,K,0)),$P(^VA(200,R,51,K,0),U,3)'>D Q 1
I $D(^VA(200,R,51,J,0)),$P(^VA(200,R,51,J,0),U,3)'>D Q 1
Q ""
APCM13E9 ;IHS/CMI/LAB - IHS MU;
+1 ;;1.0;IHS MU PERFORMANCE REPORTS;**2,4,5,6**;MAR 26, 2012;Build 65
+2 ;;;;;;Build 3
+3 ;IHS/CMI/LAB - PATCH 4 REMOVED CPOE KEY LOGIC
CPOE ;EP - CALCULATE EPRESCRIBING
+1 ;for each provider or for the facility count all prescriptions that meet criteria and if it is not written it meets numerator
+2 KILL ^TMP($JOB,"PATSRX")
+3 KILL APCMRXS
+4 DO TOTRX
+5 KILL ^TMP($JOB,"ORDERSPROCESSED")
+6 NEW APCMP,N,F
+7 SET (APCMD1,APCMN1)=0
+8 IF APCMRPTT=1
SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:1
+9 IF $PIECE($GET(APCMRXS(APCMP)),U,1)<100
SET F=$PIECE(^APCM13OB(APCMIC,0),U,11)
Begin DoDot:2
+10 DO S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had < 100 medication orders during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
End DoDot:2
GOTO D
D ;set denominator value into field
+1 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+2 ;returns # of prescriptions^# not written by nature of order
SET N=$PIECE($GET(APCMRXS(APCMP)),U,1)
+3 DO S^APCM13E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
+4 ;now set patient list for this provider
+5 SET P=0
FOR
SET P=$ORDER(^TMP($JOB,"PATSRX",APCMP,P))
IF P'=+P
QUIT
Begin DoDot:2
+6 SET D=$PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,1)
SET N=$PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,2)
SET APCMVALU="# Orders: "_D_"|||"_"# CPOE: "_N_" # NOT CPOE: "_(D-N)
+7 SET DFN=P
DO SETLIST^APCM13E1
End DoDot:2
+8 ;numerator?
+9 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+10 SET N=$PIECE($GET(APCMRXS(APCMP)),U,2)
+11 DO S^APCM13E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
End DoDot:1
+12 IF APCMRPTT=2
Begin DoDot:1
+13 SET APCMP=APCMFAC
+14 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+15 ;returns # of prescriptions^# not written by nature of order
SET N=$PIECE($GET(APCMRXS(APCMFAC)),U,1)
+16 DO S^APCM13E1(APCMRPT,APCMIC,N,APCMFAC,APCMRPTT,APCMTIME,F)
+17 ;now set patient list for this FACILITY
+18 SET P=0
FOR
SET P=$ORDER(^TMP($JOB,"PATSRX",APCMFAC,P))
IF P'=+P
QUIT
Begin DoDot:2
+19 SET D=$PIECE(^TMP($JOB,"PATSRX",APCMFAC,P),U,1)
SET N=$PIECE(^TMP($JOB,"PATSRX",APCMFAC,P),U,2)
SET APCMVALU="# Orders: "_D_"|||"_"# CPOE: "_N_" # NOT CPOE: "_(D-N)
+20 SET DFN=P
DO SETLIST^APCM13E1
End DoDot:2
+21 ;numerator?
+22 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+23 SET N=$PIECE($GET(APCMRXS(APCMFAC)),U,2)
+24 DO S^APCM13E1(APCMRPT,APCMIC,N,APCMFAC,APCMRPTT,APCMTIME,F)
End DoDot:1
+25 KILL ^TMP($JOB,"PATSRX")
+26 QUIT
TOTRX ;EP - did patient have a RX in file 52 with an issue date
+1 ;between BD and ED
+2 ;SET ARRAY APCMRXS to APCMRXS(prov ien)=denom^numer
+3 KILL ^TMP($JOB,"ORDERSPROCESSED")
+4 NEW ID,C,Y,X,D,S,N,A,B,R,PAT,G,ORIEN,ORPFILE,ORPTST,ORNS,PATLOC,ORACT0,ORORD,ORDEB
+5 SET ID=$$FMADD^XLFDT(APCMBDAT,-1)
SET ID=ID_".9999"
+6 FOR
SET ID=$ORDER(^OR(100,"AF",ID))
IF ID'=+ID!($PIECE(ID,".")>APCMEDAT)
QUIT
Begin DoDot:1
+7 SET ORIEN=0
FOR
SET ORIEN=$ORDER(^OR(100,"AF",ID,ORIEN))
IF ORIEN'=+ORIEN
QUIT
Begin DoDot:2
+8 IF $DATA(^TMP($JOB,"ORDERSPROCESSED",ORIEN))
QUIT
+9 SET ^TMP($JOB,"ORDERSPROCESSED",ORIEN)=""
+10 ;Quit if no object of order
SET ORPFILE=$PIECE($GET(^OR(100,ORIEN,0)),"^",2)
IF ORPFILE=""
QUIT
+11 ;only patient orders
IF $PIECE(ORPFILE,";",2)'["DPT"
QUIT
+12 ;GET Patient DFN
SET PAT=+$PIECE($GET(^OR(100,ORIEN,0)),U,2)
+13 ;Quit if demo patient
IF $$DEMO^APCLUTL(PAT,APCMDEMO)
QUIT
+14 ;190 quit if order type not standard
IF +$PIECE($GET(^OR(100,ORIEN,3)),"^",11)'=0
QUIT
+15 ;patient status (in/out)
SET ORPTST=$PIECE($GET(^OR(100,ORIEN,0)),"^",12)
+16 ;get package namespace
SET ORNS=$$NMSP($PIECE($GET(^OR(100,ORIEN,0)),"^",14))
+17 ;if not getting all types of orders then quit if order is not from pharmacy
IF ORNS'="PS"
QUIT
+18 SET ORACT0=$GET(^OR(100,ORIEN,8,1,0))
+19 IF $PIECE(ORACT0,U,1)'=ID
QUIT
+20 ;ORORD holds nature of order ien
SET ORORD=$PIECE(ORACT0,"^",12)
+21 ;skip service corrections
IF ORORD=4
QUIT
+22 SET ORPVID=$PIECE(ORACT0,"^",3)
+23 ;I ORPTST="O",ORNS="PS",$G(^OR(100,ORIEN,4))=+$G(^OR(100,ORIEN,4)),$L($T(EN^PSOTPCUL)) Q:$$EN^PSOTPCUL($G(^OR(100,ORIEN,4))) ;196 Don't count if outpatient pharm order is a transitional pharmacy benefit order
+24 SET G=0
+25 IF APCMRPTT=1
Begin DoDot:3
+26 ;Quit if patient status is not outpatient and in EP report
IF ORPTST'="O"
QUIT
+27 ;quit if ordering provider doesn't match user selected provider
SET ORPVID=$PIECE(ORACT0,"^",3)
IF '$DATA(APCMPRV(ORPVID))
QUIT
+28 SET PATLOC=+$PIECE($GET(^OR(100,ORIEN,0)),U,10)
+29 ;IF ER IN HOSP LOC Q
SET C=""
IF PATLOC
IF $DATA(^SC(PATLOC,0))
SET C=$PIECE(^SC(PATLOC,0),U,7)
IF C
IF $PIECE($GET(^DIC(40.7,C,0)),U,2)=30
QUIT
+30 SET G=1
End DoDot:3
+31 IF APCMRPTT=2
Begin DoDot:3
+32 IF ORPTST="I"
SET G=1
QUIT
+33 SET PATLOC=+$PIECE($GET(^OR(100,ORIEN,0)),U,10)
+34 IF 'PATLOC
QUIT
+35 ;IF NOT ER IN HOSP LOC Q
SET C=""
IF PATLOC
IF $DATA(^SC(PATLOC,0))
SET C=$PIECE(^SC(PATLOC,0),U,7)
IF C
IF $PIECE($GET(^DIC(40.7,C,0)),U,2)'=30
QUIT
+36 IF PATLOC
IF $DATA(^SC(PATLOC,0))
SET C=$PIECE(^SC(PATLOC,0),U,4)
IF C
IF C'=APCMFAC
QUIT
+37 SET G=1
End DoDot:3
+38 IF 'G
QUIT
+39 ;ORORD holds nature of order ien
SET ORORD=$PIECE(ORACT0,"^",12)
+40 ;S ORPVNM=$P($G(^VA(200,ORPVID,0)),"^") ;get provider name
+41 ;Q:'$D(^XUSEC("ORES",ORPVID)) ;quit if ordering provider doesn't have ORES key DBIA # 10076 allows direct read of XUSEC =====> PM
+42 ;Q:"^1^2^3^5^8^"'[("^"_ORORD_"^") ;quit if NATUS O=$O(^OR(100,"AF" ====> PM REPORT BUT NOT IN IHS MU LOGIC
+43 ;SET DENOM COUNT FOR THIS EP = INCREMENT BY 1
+44 ;I DUZ=2793 W !,"PAT: ",$P(^DPT(PAT,0),U,1),"DATE: ",$$FMTE^XLFDT(ID)," ORDER: ",ORIEN," NATURE: ",ORORD
+45 IF APCMRPTT=1
SET $PIECE(APCMRXS(ORPVID),U,1)=$PIECE($GET(APCMRXS(ORPVID)),U,1)+1
SET $PIECE(^TMP($JOB,"PATSRX",ORPVID,PAT),U,1)=$PIECE($GET(^TMP($JOB,"PATSRX",ORPVID,PAT)),U,1)+1
+46 IF APCMRPTT=2
SET $PIECE(APCMRXS(APCMFAC),U,1)=$PIECE($GET(APCMRXS(APCMFAC)),U,1)+1
SET $PIECE(^TMP($JOB,"PATSRX",APCMFAC,PAT),U,1)=$PIECE($GET(^TMP($JOB,"PATSRX",APCMFAC,PAT)),U,1)+1
+47 ;
+48 ;now check to see if it has a nature of order IS equal to 1-written if so, quit and don't set numerator
+49 ;this is a written order so do not put in numerator
IF ORORD=1
QUIT
+50 ;this is the person who entered the order (ENTERED BY)
SET ORDEB=$PIECE(^OR(100,ORIEN,8,1,0),"^",13)
+51 ;Q:'$$ORES(ORDEB,$P(ID,".",1)) ;quit if this person does not have ORES or ORESLE on date of order so don't count in numerator
+52 ; DUZ=2793 W " NUMER"
+53 IF APCMRPTT=1
SET $PIECE(APCMRXS(ORPVID),U,2)=$PIECE(APCMRXS(ORPVID),U,2)+1
SET $PIECE(^TMP($JOB,"PATSRX",ORPVID,PAT),U,2)=$PIECE($GET(^TMP($JOB,"PATSRX",ORPVID,PAT)),U,2)+1
+54 IF APCMRPTT=2
SET $PIECE(APCMRXS(APCMFAC),U,2)=$PIECE($GET(APCMRXS(APCMFAC)),U,2)+1
SET $PIECE(^TMP($JOB,"PATSRX",APCMFAC,PAT),U,2)=$PIECE($GET(^TMP($JOB,"PATSRX",APCMFAC,PAT)),U,2)+1
End DoDot:2
End DoDot:1
+55 QUIT
NMSP(PKG) ; -- Returns package namespace from pointer
+1 NEW Y
SET Y=$$GET1^DIQ(9.4,+PKG_",",1)
+2 IF $EXTRACT(Y,1,2)="PS"
SET Y="PS"
IF Y="GMRV"
SET Y="OR"
+3 QUIT Y
+4 ;
ORES(R,D) ;EP - DID PROVIDER HAVE ORES OR ORESLE ON DATE D
+1 IF '$GET(R)
QUIT ""
+2 IF '$DATA(^VA(200,R,0))
QUIT ""
+3 NEW K,J
+4 SET K=$ORDER(^DIC(19.1,"B","ORES",0))
+5 SET J=$ORDER(^DIC(19.1,"B","ORELSE",0))
+6 IF $DATA(^VA(200,R,51,K,0))
IF $PIECE(^VA(200,R,51,K,0),U,3)'>D
QUIT 1
+7 IF $DATA(^VA(200,R,51,J,0))
IF $PIECE(^VA(200,R,51,J,0),U,3)'>D
QUIT 1
+8 QUIT ""