APCM13E5 ;IHS/CMI/LAB - IHS MU;
;;1.0;IHS MU PERFORMANCE REPORTS;**2,4,5,6**;MAR 26, 2012;Build 65
;;;;;;Build 3
PATEDUC ;EP - CALCULATE PAT ED
;for each provider or for the facility find out if this
;patient had a visit of A, O, R, S to this provider or facility
;if so, then check to see if they have PAT ED LITERATURE documented anytime before end of report period
NEW APCMP
S (APCMD1,APCMN1)=0
I APCMRPTT=1 D Q
.S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
..Q:'$D(APCMHVTP(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
..D PATEDUC1
..Q
I APCMRPTT=2 D
.S APCMP=APCMFAC
.Q:'$D(APCMHVTP(APCMP))
.D PATEDUC1
.Q
Q
PATEDUC1 ;
;set denominator value into field
S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
D S^APCM13E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
;numerator?
S APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
S APCMEP=$$HASED(DFN,APCMBDAT,APCMEDAT)
;I APCMRPTT=2 S APCMEP=$$HASEDH(DFN,APCMBDAT,APCMEDAT,APCMFAC,.APCMVSTS)
S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
S F=$P(^APCM13OB(APCMIC,0),U,9)
D S^APCM13E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
;S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
D SETLIST^APCM13E1
Q
HASEDH(P,BD,ED,R,VSTS) ;does patient have a visit/patient ed
;
NEW A,B,C,D,E,X,Y,V,PED,T,W,Z,Q,EDUC
;LOOP THROUGH ALL VISITS AND COUNT VISIT AND educ
S PED=""
S X=0 F S X=$O(VSTS(X)) Q:X'=+X D
.S G=0
.S V=$P(VSTS(X),U,5)
.I '$D(^AUPNVSIT(V,0)) Q
.I $P(^AUPNVSIT(V,0),U,11) Q
.I '$$HOSER^APCM13E6(V,R) Q ;not correct service category, clinic, facility
.;was there a PAT ED -L between admission an discharge?
.S Y="EDUC("
.S Z=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT($$VD^APCLV(V))_"-"_$$FMTE^XLFDT($$DSCHDATE^APCM13E6(V)) S E=$$START1^APCLDF(Z,Y)
.I '$D(EDUC(1)) Q
.S (Z,B,D)=0,%="",T="" F S Z=$O(EDUC(Z)) Q:Z'=+Z!(B) D
..S A=$P(^AUPNVPED(+$P(EDUC(Z),U,4),0),U)
..Q:'A
..Q:'$D(^AUTTEDT(A,0))
..S T=$P(^AUTTEDT(A,0),U,2)
..I $P(T,"-",2)'="L" Q
..S PED=1_U_"Visit/Adm: "_$$DATE^APCM1UTL($$VD^APCLV(V))_";"_T_" on "_$$DATE^APCM1UTL($P(EDUC(X),U)) Q
Q PED
HASED(P,BD,ED) ;does patient have Patient Ed -L
;
NEW A,B,C,D,E,PED,Y,EDUC,X,T
S C=0
S PED=""
S Y="EDUC("
S X=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT(BD)_"-"_$$FMTE^XLFDT(ED) S E=$$START1^APCLDF(X,Y)
I '$D(EDUC(1)) Q ""
S (X,D)=0,%="",T="" F S X=$O(EDUC(X)) Q:X'=+X!(PED]"") D
.S T=$P(^AUPNVPED(+$P(EDUC(X),U,4),0),U)
.Q:'T
.Q:'$D(^AUTTEDT(T,0))
.S T=$P(^AUTTEDT(T,0),U,2)
.I $P(T,"-",2)="L" S PED=1_U_T_" on "_$$DATE^APCM1UTL($P(EDUC(X),U)) Q
Q PED
TIMELY ;EP - TIMELY - THIS IS THE PHR MEASURE
NEW APCMP
S (APCMD1,APCMN1)=0
I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
.Q:'$D(APCMHVTP(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
.;set denominator value into field
.S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
.D S^APCM13E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
.S APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
.;numerator?
.S APCMEP=$S(APCMATTE("S1.020.EP",APCMP)="Yes":1,1:0)
.S F=$P(^APCM13OB(APCMIC,0),U,9)
.D S^APCM13E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
.S APCMVALU=APCMVALU_"|||"_APCMATTE("S1.020.EP",APCMP)
.D SETLIST^APCM13E1
Q
;
MR ;EP - med reconciliation
;;then check to see if they have m-mr on the day of the visit
NEW APCMP
S (APCMD1,APCMN1)=0
I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
.I $D(APCMTRAE(APCMP,APCMTIME)) S F=$P(^APCM13OB(APCMIC,0),U,11) D Q
..D S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not have any transitions of care clinic visits.",APCMP,APCMRPTT,APCMTIME,F,1) Q
.Q:'$D(APCMHVTP(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
.;numerator?
.S APCMEP=$$HASMMR(DFN,APCMBDAT,APCMEDAT,APCMP,.APCMVSTS) ;return # of visits^# w/M-MR
.;set denominator value into field
.S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
.D S^APCM13E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
.;numerator?
.S APCMVALU="# of visits: "_$P(APCMEP,U,1)_" - # w/ M-MR: "_+$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,3)_"|||"_$S($P(APCMEP,U,1)=$P(APCMEP,U,2):1,1:0)
.S F=$P(^APCM13OB(APCMIC,0),U,9)
.D S^APCM13E1(APCMRPT,APCMIC,$P(APCMEP,U,2),APCMP,APCMRPTT,APCMTIME,F)
.Q:$P(APCMEP,U,1)=0
.D SETLIST^APCM13E1
Q
HASMMR(P,BD,ED,R,VSTS) ;does patient have a m-mr on visits
;
NEW A,B,C,D,E,X,Y,V,PWH,T,W,Z,Q,PED,EDUC,J
S J=$O(^APCMMUCN("B","INTERIM STAGE 1 2013",0))
;LOOP THROUGH ALL VISITS AND COUNT VISIT AND PWH'S
S PWH="0^0"
S X=0 F S X=$O(VSTS(X)) Q:X'=+X D
.S G=0
.S V=$P(VSTS(X),U,5)
.I '$D(^AUPNVSIT(V,0)) Q
.I $P(^AUPNVSIT(V,0),U,11) Q ;deleted
.I "AOSM"'[$P(^AUPNVSIT(V,0),U,7) Q ;not correct service category/OFFICE VISIT
.S Y=0 F S Y=$O(^AUPNVPRV("AD",V,Y)) Q:Y'=+Y!(G) D
..I $P($G(^AUPNVPRV(Y,0)),U)'=R Q
..Q:$P(^AUPNVPRV(Y,0),U,4)'="P"
..S G=1
.Q:'G ;not a visit to this provider
.S C=$$CLINIC^APCLV(V,"C")
.Q:C=30
.I C]"",J,$D(^APCMMUCN(J,14,"B",C)) Q ;don't count these clinics
.S $P(PWH,U,1)=$P(PWH,U,1)+1
.;was there a PAT ED M-MR on the date of the visit
.S B=""
.K EDUC
.S Y="EDUC("
.S Z=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT($$VD^APCLV(V))_"-"_$$FMTE^XLFDT($$VD^APCLV(V)) S E=$$START1^APCLDF(Z,Y)
.;I '$D(EDUC(1)) Q
.S (Z,D)=0,%="",T="" F S Z=$O(EDUC(Z)) Q:Z'=+Z!(B) D
..S T=$P(^AUPNVPED(+$P(EDUC(Z),U,4),0),U)
..Q:'T
..Q:'$D(^AUTTEDT(T,0))
..S Y=$P(^AUTTEDT(T,0),U,2)
..Q:Y'="M-MR"
..S B=1 S $P(PWH,U,2)=$P(PWH,U,2)+1
.S $P(PWH,U,3)=$P(PWH,U,3)_$$DATE^APCM1UTL($$VD^APCLV(V))_":"_$S(B:"M-MR",1:"NO M-MR")_";"
.Q
Q PWH
HASPWH(P,BD,ED,R,VSTS) ;
;
NEW A,B,C,D,E,X,Y,V,PWH,T,W,Z,Q
S T=$O(^APCMMUCN("B","INTERIM STAGE 1 2013",0))
;LOOP THROUGH ALL VISITS AND COUNT VISIT AND PWH'S
S PWH="0^0"
S X=0 F S X=$O(VSTS(X)) Q:X'=+X D
.S G=0
.S V=$P(VSTS(X),U,5)
.I '$D(^AUPNVSIT(V,0)) Q
.I $P(^AUPNVSIT(V,0),U,11) Q
.I "AOSM"'[$P(^AUPNVSIT(V,0),U,7) Q ;not correct service category/OFFICE VISIT
.S Y=0 F S Y=$O(^AUPNVPRV("AD",V,Y)) Q:Y'=+Y!(G) D
..I $P($G(^AUPNVPRV(Y,0)),U)'=R Q
..I $P($G(^AUPNVPRV(Y,0)),U,4)'="P" Q
..S G=1
.Q:'G ;not a visit to this provider
.S C=$$CLINIC^APCLV(V,"C")
.I C]"",T,$D(^APCMMUCN(T,14,"B",C)) Q ;don't count these clinics
.S $P(PWH,U,1)=$P(PWH,U,1)+1
.;was there a pwh on the date of the visit
.S D=$P(^AUPNVSIT(V,0),U),D=D-.000001 ;date of visit
.S E=$P(D,".")
.S A=D,B=0 F S A=$O(^APCHPWHL("AA",P,A)) Q:A'=+A!($P(A,".")>E) D
..;MUST HAVE MEDICATONS AS A COMPONENT
..S Z=0 F S Z=$O(^APCHPWHL("AA",P,A,Z)) Q:Z'=+Z D
...S W=$P(^APCHPWHL(Z,0),U,2)
...Q:'W
...S Q=0 F S Q=$O(^APCHPWHT(Z,1,Q)) Q:Q'=+Q!(B) D
....S R=$P($G(^APCHPWHT(Z,1,Q,0)),U,2)
....Q:'R
....S R=$P($G(^APCHPWHC(R,0)),U,1)
....Q:R'["MEDICATIONS"
....S B=1
.I B S $P(PWH,U,2)=$P(PWH,U,2)+1
.Q
Q PWH
PR ;EP - patient reminders
;for each provider or for the facility find out if this
;if patient is <=5 or >=65 count them
;exclude deceased, and inactive charts
;if so, then check to see if they have PWH WITH 4 COMPONENTs documented any time before end of report period
NEW APCMP
S (APCMD1,APCMN1)=0
I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
.I APCMN565(APCMTIME) S F=$P(^APCM13OB(APCMIC,0),U,11) D Q
..D S^APCM13E1(APCMRPT,APCMIC,"Facility is excluded from this measure as they did not see any patients <=5 or >=65 years old.",APCMP,APCMRPTT,APCMTIME,F,1) Q
.;set denominator value into field
.S G=0
.I APCMAGEB<5 G PR1
.I APCMAGEB<65 Q
.Q:$$DOB^AUPNPAT(DFN)>APCMBDAT ;born after time period begin date
PR1 .;IS CHART ACTIVE OR DECEASED
.S X=$$DOD^AUPNPAT(DFN)
.I X,X'>APCMEDAT Q
.Q:'$O(^AUPNPAT(DFN,41,0)) ;no charts
.S X=$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,3)
.I X,X'>APCMEDAT Q
.;did they have a visit ever to the EP?
.;I DUZ=2793 W !,DFN," ",$$NOW^XLFDT
.;K APCMPRVT
.;D ALLV^APCLAPIU(DFN,$$DOB^AUPNPAT(DFN),APCMEDAT,"APCMPRVT")
.I '$$HADV(DFN,APCMP,$$DOB^AUPNPAT(DFN),APCMEDAT) Q
.;I DUZ=2793 W !,DFN W " YES"
.S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
.D S^APCM13E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
.S APCMVALU=""
.;numerator?
.S APCMEP=$$HASPWHR(DFN,APCMBDAT,APCMEDAT,APCMP,.APCMVSTS) ;return # of visits^# w/pwh
.S APCMVALU="Patient age: "_$$AGE^AUPNPAT(DFN,APCMBDAT)_"|||"_"PWH: "_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
.S F=$P(^APCM13OB(APCMIC,0),U,9)
.D S^APCM13E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
.D SETLIST^APCM13E1
Q
HADV(P,PROV,BD,ED) ;EP
NEW X,Y,G,V
S X=0,G="" F S X=$O(^AUPNVPRV("B",PROV,X)) Q:X'=+X!(G) D
.Q:'$D(^AUPNVPRV(X,0))
.Q:$P(^AUPNVPRV(X,0),U,2)'=P
.Q:$P(^AUPNVPRV(X,0),U,4)'="P"
.S V=$P(^AUPNVPRV(X,0),U,3)
.Q:'$D(^AUPNVSIT(V,0))
.I "AOSM"'[$P(^AUPNVSIT(V,0),U,7) Q ;not correct service category
.S C=$$CLINIC^APCLV(V,"C")
.I C=30 Q ;no ER per Carmen patch 1
.I C=77 Q ;no case management clinic 77 per Chris
.I C=76 Q ;no lab
.I C=63 Q ;no radiology
.I C=39 Q ;no pharmacy
.S G=1
.Q
Q G
HASPWHR(P,BD,ED,R,VSTS) ;
;
NEW A,B,C,D,E,X,Y,V,PWH,T,W,Z,Q
S PWH=""
S D=$$FMADD^XLFDT(BD,-1)
S A=D,B=0 F S A=$O(^APCHPWHL("AA",P,A)) Q:A'=+A!($P(A,".")>ED)!(PWH) D
.S Z=0,C=0 F S Z=$O(^APCHPWHL("AA",P,A,Z)) Q:Z'=+Z!(PWH) D
..S W=$P(^APCHPWHL(Z,0),U,2)
..Q:'W
..;REMOVED CHECK ON TYPE OF PWH
..S PWH=1_U_$$DATE^APCM1UTL(A)_" "_$P(^APCHPWHT(W,0),U)
Q PWH
SC ;EP - REFERRAL, SUMMARY OF CARE
NEW APCMP
S (APCMD1,APCMN1)=0
I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
.I $D(APCMRCIS(APCMP,APCMTIME)) S F=$P(^APCM13OB(APCMIC,0),U,11) D Q
..D S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not make any referrals for patients they saw during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1) Q
.;Q:'$D(APCMHVTP(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
.;set denominator value into field
.S APCMEP=$$HASC32(DFN,APCMBDAT,$$FMADD^XLFDT(APCMEDAT,-14),APCMP) ;# referrals^# w/c32 documentation
.Q:$P(APCMEP,U,1)=0
.S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
.D S^APCM13E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
.;S APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
.;numerator?
.S APCMVALU="# of refs: "_$P(APCMEP,U,1)_" # w/C32 w/in 14 days: "_+$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,3)_"|||"_$S('+$P(APCMEP,U,1):0,+$P(APCMEP,U,1)=+$P(APCMEP,U,2):1,1:0)
.S F=$P(^APCM13OB(APCMIC,0),U,9)
.D S^APCM13E1(APCMRPT,APCMIC,$P(APCMEP,U,2),APCMP,APCMRPTT,APCMTIME,F)
.D SETLIST^APCM13E1
Q
HASC32(P,BD,ED,R) ;does patient have a referral with c32
;
NEW A,B,C,D,E,ROI,X,ROII,S,G
S ROI="0^0" ;set to 1 if had a good request
S ROII="" ;set to date of reques
S D=$$FMADD^XLFDT(BD,-1)
F S D=$O(^BMCREF("AA",P,D)) Q:D'=+D!(D>ED) D
.S X=0 F S X=$O(^BMCREF("AA",P,D,X)) Q:X'=+X D
..;check to see if it is for this provider, is an A or CL and is not an in-house
..S S=$P(^BMCREF(X,0),U,6)
..Q:S'=R ;not the requesting provider we want
..S S=$P(^BMCREF(X,0),U,15)
..I S'="A",S'="C1" Q ;not a A or C1
..Q:$P(^BMCREF(X,0),U,4)="N"
..;was it 1 day before through 1 day after discharge
..;OR was it on the date of an 30/80 visit or the day after
..S $P(ROI,U,1)=$P(ROI,U,1)+1
..;now check to see if a c32 was printed
..I '$O(^BMCREF(X,6,"B",0)) S $P(ROI,U,2)=0,ROII=" Ref: "_$$DATE^APCM1UTL(D)_":C32 None;" Q
..S Y=0,G=0 F S Y=$O(^BMCREF(X,6,"B",Y)) Q:Y'=+Y!(G) D
...I $P(Y,".")'<D,$P(Y,".")'>$$FMADD^XLFDT(D,14) S G=1,$P(ROI,U,2)=$P(ROI,U,2)+1,ROII=ROII_"Ref: "_$$DATE^APCM1UTL(D)_":C32 "_$$DATE^APCM1UTL(Y)_";" Q
...S ROII=ROII_" Ref: "_$$DATE^APCM1UTL(D)_":C32 "_$$DATE^APCM1UTL(Y)_";"
Q ROI_U_ROII
;
LAB ;EP - CALCULATE LAB
;for each provider count each lab in the time period, loop through patients for visits in time period
K ^TMP($J,"PATSRX")
K APCMLABS
D TOTLAB
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(APCMLABS(APCMP)),U,1) D Q
..S F=$P(^APCM13OB(APCMIC,0),U,11) D S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not order any lab tests with results during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1) Q
.;set denominator value into field
.S F=$P(^APCM13OB(APCMIC,0),U,8) ;denom field for this measure
.S N=$P($G(APCMLABS(APCMP)),U,1) ;returns # of LABS^# not Structured data
.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
..;Q:'$P(^TMP($J,"PATSRX",APCMP,P),U,1)
..I $P(^TMP($J,"PATSRX",APCMP,P),U,1)=$P(^TMP($J,"PATSRX",APCMP,P),U,2) S APCMVALU="# Labs: "_$P(^TMP($J,"PATSRX",APCMP,P),U,1)_"|||"_" # w/structured result: "_+$P(^TMP($J,"PATSRX",APCMP,P),U,2)_"|||1" D Q
...S DFN=P D SETLIST^APCM13E1 Q
..S S="",APCMVALU="No Structured Result: "
..F S S=$O(^TMP($J,"PATSRX",APCMP,P,"SCRIPTS",S)) Q:S="" D
...I '$D(^TMP($J,"PATSRX",APCMP,P,"ELEC",S)) D
....S APCMVALU=APCMVALU_S_";"
..S DFN=P,APCMVALU="# of Labs: "_$P(^TMP($J,"PATSRX",APCMP,P),U,1)_" # w/structured results: "_+$P(^TMP($J,"PATSRX",APCMP,P),U,2)_"|||"_APCMVALU,$P(APCMVALU,"|||",3)=0 D SETLIST^APCM13E1
.;numerator?
.S F=$P(^APCM13OB(APCMIC,0),U,9)
.S N=$P($G(APCMLABS(APCMP)),U,2)
.D S^APCM13E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
K ^TMP($J,"PATSRX")
Q
TOTLAB ;EP -
D TOTLAB^APCM13E8
Q
APCM13E5 ;IHS/CMI/LAB - IHS MU;
+1 ;;1.0;IHS MU PERFORMANCE REPORTS;**2,4,5,6**;MAR 26, 2012;Build 65
+2 ;;;;;;Build 3
PATEDUC ;EP - CALCULATE PAT ED
+1 ;for each provider or for the facility find out if this
+2 ;patient had a visit of A, O, R, S to this provider or facility
+3 ;if so, then check to see if they have PAT ED LITERATURE documented anytime before end of report period
+4 NEW APCMP
+5 SET (APCMD1,APCMN1)=0
+6 IF APCMRPTT=1
Begin DoDot:1
+7 SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:2
+8 ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
IF '$DATA(APCMHVTP(APCMP))
QUIT
+9 DO PATEDUC1
+10 QUIT
End DoDot:2
End DoDot:1
QUIT
+11 IF APCMRPTT=2
Begin DoDot:1
+12 SET APCMP=APCMFAC
+13 IF '$DATA(APCMHVTP(APCMP))
QUIT
+14 DO PATEDUC1
+15 QUIT
End DoDot:1
+16 QUIT
PATEDUC1 ;
+1 ;set denominator value into field
+2 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+3 DO S^APCM13E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
+4 ;numerator?
+5 SET APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
+6 SET APCMEP=$$HASED(DFN,APCMBDAT,APCMEDAT)
+7 ;I APCMRPTT=2 S APCMEP=$$HASEDH(DFN,APCMBDAT,APCMEDAT,APCMFAC,.APCMVSTS)
+8 SET APCMVALU=APCMVALU_"|||"_$PIECE(APCMEP,U,2)_"|||"_$PIECE(APCMEP,U,1)
+9 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+10 DO S^APCM13E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
+11 ;S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
+12 DO SETLIST^APCM13E1
+13 QUIT
HASEDH(P,BD,ED,R,VSTS) ;does patient have a visit/patient ed
+1 ;
+2 NEW A,B,C,D,E,X,Y,V,PED,T,W,Z,Q,EDUC
+3 ;LOOP THROUGH ALL VISITS AND COUNT VISIT AND educ
+4 SET PED=""
+5 SET X=0
FOR
SET X=$ORDER(VSTS(X))
IF X'=+X
QUIT
Begin DoDot:1
+6 SET G=0
+7 SET V=$PIECE(VSTS(X),U,5)
+8 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+9 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+10 ;not correct service category, clinic, facility
IF '$$HOSER^APCM13E6(V,R)
QUIT
+11 ;was there a PAT ED -L between admission an discharge?
+12 SET Y="EDUC("
+13 SET Z=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT($$VD^APCLV(V))_"-"_$$FMTE^XLFDT($$DSCHDATE^APCM13E6(V))
SET E=$$START1^APCLDF(Z,Y)
+14 IF '$DATA(EDUC(1))
QUIT
+15 SET (Z,B,D)=0
SET %=""
SET T=""
FOR
SET Z=$ORDER(EDUC(Z))
IF Z'=+Z!(B)
QUIT
Begin DoDot:2
+16 SET A=$PIECE(^AUPNVPED(+$PIECE(EDUC(Z),U,4),0),U)
+17 IF 'A
QUIT
+18 IF '$DATA(^AUTTEDT(A,0))
QUIT
+19 SET T=$PIECE(^AUTTEDT(A,0),U,2)
+20 IF $PIECE(T,"-",2)'="L"
QUIT
+21 SET PED=1_U_"Visit/Adm: "_$$DATE^APCM1UTL($$VD^APCLV(V))_";"_T_" on "_$$DATE^APCM1UTL($PIECE(EDUC(X),U))
QUIT
End DoDot:2
End DoDot:1
+22 QUIT PED
HASED(P,BD,ED) ;does patient have Patient Ed -L
+1 ;
+2 NEW A,B,C,D,E,PED,Y,EDUC,X,T
+3 SET C=0
+4 SET PED=""
+5 SET Y="EDUC("
+6 SET X=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT(BD)_"-"_$$FMTE^XLFDT(ED)
SET E=$$START1^APCLDF(X,Y)
+7 IF '$DATA(EDUC(1))
QUIT ""
+8 SET (X,D)=0
SET %=""
SET T=""
FOR
SET X=$ORDER(EDUC(X))
IF X'=+X!(PED]"")
QUIT
Begin DoDot:1
+9 SET T=$PIECE(^AUPNVPED(+$PIECE(EDUC(X),U,4),0),U)
+10 IF 'T
QUIT
+11 IF '$DATA(^AUTTEDT(T,0))
QUIT
+12 SET T=$PIECE(^AUTTEDT(T,0),U,2)
+13 IF $PIECE(T,"-",2)="L"
SET PED=1_U_T_" on "_$$DATE^APCM1UTL($PIECE(EDUC(X),U))
QUIT
End DoDot:1
+14 QUIT PED
TIMELY ;EP - TIMELY - THIS IS THE PHR MEASURE
+1 NEW APCMP
+2 SET (APCMD1,APCMN1)=0
+3 IF APCMRPTT=1
SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:1
+4 ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
IF '$DATA(APCMHVTP(APCMP))
QUIT
+5 ;set denominator value into field
+6 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+7 DO S^APCM13E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
+8 SET APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
+9 ;numerator?
+10 SET APCMEP=$SELECT(APCMATTE("S1.020.EP",APCMP)="Yes":1,1:0)
+11 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+12 DO S^APCM13E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
+13 SET APCMVALU=APCMVALU_"|||"_APCMATTE("S1.020.EP",APCMP)
+14 DO SETLIST^APCM13E1
End DoDot:1
+15 QUIT
+16 ;
MR ;EP - med reconciliation
+1 ;;then check to see if they have m-mr on the day of the visit
+2 NEW APCMP
+3 SET (APCMD1,APCMN1)=0
+4 IF APCMRPTT=1
SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:1
+5 IF $DATA(APCMTRAE(APCMP,APCMTIME))
SET F=$PIECE(^APCM13OB(APCMIC,0),U,11)
Begin DoDot:2
+6 DO S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not have any transitions of care clinic visits.",APCMP,APCMRPTT,APCMTIME,F,1)
QUIT
End DoDot:2
QUIT
+7 ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
IF '$DATA(APCMHVTP(APCMP))
QUIT
+8 ;numerator?
+9 ;return # of visits^# w/M-MR
SET APCMEP=$$HASMMR(DFN,APCMBDAT,APCMEDAT,APCMP,.APCMVSTS)
+10 ;set denominator value into field
+11 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+12 DO S^APCM13E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
+13 ;numerator?
+14 SET APCMVALU="# of visits: "_$PIECE(APCMEP,U,1)_" - # w/ M-MR: "_+$PIECE(APCMEP,U,2)_"|||"_$PIECE(APCMEP,U,3)_"|||"_$SELECT($PIECE(APCMEP,U,1)=$PIECE(APCMEP,U,2):1,1:0)
+15 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+16 DO S^APCM13E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,2),APCMP,APCMRPTT,APCMTIME,F)
+17 IF $PIECE(APCMEP,U,1)=0
QUIT
+18 DO SETLIST^APCM13E1
End DoDot:1
+19 QUIT
HASMMR(P,BD,ED,R,VSTS) ;does patient have a m-mr on visits
+1 ;
+2 NEW A,B,C,D,E,X,Y,V,PWH,T,W,Z,Q,PED,EDUC,J
+3 SET J=$ORDER(^APCMMUCN("B","INTERIM STAGE 1 2013",0))
+4 ;LOOP THROUGH ALL VISITS AND COUNT VISIT AND PWH'S
+5 SET PWH="0^0"
+6 SET X=0
FOR
SET X=$ORDER(VSTS(X))
IF X'=+X
QUIT
Begin DoDot:1
+7 SET G=0
+8 SET V=$PIECE(VSTS(X),U,5)
+9 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+10 ;deleted
IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+11 ;not correct service category/OFFICE VISIT
IF "AOSM"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+12 SET Y=0
FOR
SET Y=$ORDER(^AUPNVPRV("AD",V,Y))
IF Y'=+Y!(G)
QUIT
Begin DoDot:2
+13 IF $PIECE($GET(^AUPNVPRV(Y,0)),U)'=R
QUIT
+14 IF $PIECE(^AUPNVPRV(Y,0),U,4)'="P"
QUIT
+15 SET G=1
End DoDot:2
+16 ;not a visit to this provider
IF 'G
QUIT
+17 SET C=$$CLINIC^APCLV(V,"C")
+18 IF C=30
QUIT
+19 ;don't count these clinics
IF C]""
IF J
IF $DATA(^APCMMUCN(J,14,"B",C))
QUIT
+20 SET $PIECE(PWH,U,1)=$PIECE(PWH,U,1)+1
+21 ;was there a PAT ED M-MR on the date of the visit
+22 SET B=""
+23 KILL EDUC
+24 SET Y="EDUC("
+25 SET Z=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT($$VD^APCLV(V))_"-"_$$FMTE^XLFDT($$VD^APCLV(V))
SET E=$$START1^APCLDF(Z,Y)
+26 ;I '$D(EDUC(1)) Q
+27 SET (Z,D)=0
SET %=""
SET T=""
FOR
SET Z=$ORDER(EDUC(Z))
IF Z'=+Z!(B)
QUIT
Begin DoDot:2
+28 SET T=$PIECE(^AUPNVPED(+$PIECE(EDUC(Z),U,4),0),U)
+29 IF 'T
QUIT
+30 IF '$DATA(^AUTTEDT(T,0))
QUIT
+31 SET Y=$PIECE(^AUTTEDT(T,0),U,2)
+32 IF Y'="M-MR"
QUIT
+33 SET B=1
SET $PIECE(PWH,U,2)=$PIECE(PWH,U,2)+1
End DoDot:2
+34 SET $PIECE(PWH,U,3)=$PIECE(PWH,U,3)_$$DATE^APCM1UTL($$VD^APCLV(V))_":"_$SELECT(B:"M-MR",1:"NO M-MR")_";"
+35 QUIT
End DoDot:1
+36 QUIT PWH
HASPWH(P,BD,ED,R,VSTS) ;
+1 ;
+2 NEW A,B,C,D,E,X,Y,V,PWH,T,W,Z,Q
+3 SET T=$ORDER(^APCMMUCN("B","INTERIM STAGE 1 2013",0))
+4 ;LOOP THROUGH ALL VISITS AND COUNT VISIT AND PWH'S
+5 SET PWH="0^0"
+6 SET X=0
FOR
SET X=$ORDER(VSTS(X))
IF X'=+X
QUIT
Begin DoDot:1
+7 SET G=0
+8 SET V=$PIECE(VSTS(X),U,5)
+9 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+10 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+11 ;not correct service category/OFFICE VISIT
IF "AOSM"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+12 SET Y=0
FOR
SET Y=$ORDER(^AUPNVPRV("AD",V,Y))
IF Y'=+Y!(G)
QUIT
Begin DoDot:2
+13 IF $PIECE($GET(^AUPNVPRV(Y,0)),U)'=R
QUIT
+14 IF $PIECE($GET(^AUPNVPRV(Y,0)),U,4)'="P"
QUIT
+15 SET G=1
End DoDot:2
+16 ;not a visit to this provider
IF 'G
QUIT
+17 SET C=$$CLINIC^APCLV(V,"C")
+18 ;don't count these clinics
IF C]""
IF T
IF $DATA(^APCMMUCN(T,14,"B",C))
QUIT
+19 SET $PIECE(PWH,U,1)=$PIECE(PWH,U,1)+1
+20 ;was there a pwh on the date of the visit
+21 ;date of visit
SET D=$PIECE(^AUPNVSIT(V,0),U)
SET D=D-.000001
+22 SET E=$PIECE(D,".")
+23 SET A=D
SET B=0
FOR
SET A=$ORDER(^APCHPWHL("AA",P,A))
IF A'=+A!($PIECE(A,".")>E)
QUIT
Begin DoDot:2
+24 ;MUST HAVE MEDICATONS AS A COMPONENT
+25 SET Z=0
FOR
SET Z=$ORDER(^APCHPWHL("AA",P,A,Z))
IF Z'=+Z
QUIT
Begin DoDot:3
+26 SET W=$PIECE(^APCHPWHL(Z,0),U,2)
+27 IF 'W
QUIT
+28 SET Q=0
FOR
SET Q=$ORDER(^APCHPWHT(Z,1,Q))
IF Q'=+Q!(B)
QUIT
Begin DoDot:4
+29 SET R=$PIECE($GET(^APCHPWHT(Z,1,Q,0)),U,2)
+30 IF 'R
QUIT
+31 SET R=$PIECE($GET(^APCHPWHC(R,0)),U,1)
+32 IF R'["MEDICATIONS"
QUIT
+33 SET B=1
End DoDot:4
End DoDot:3
End DoDot:2
+34 IF B
SET $PIECE(PWH,U,2)=$PIECE(PWH,U,2)+1
+35 QUIT
End DoDot:1
+36 QUIT PWH
PR ;EP - patient reminders
+1 ;for each provider or for the facility find out if this
+2 ;if patient is <=5 or >=65 count them
+3 ;exclude deceased, and inactive charts
+4 ;if so, then check to see if they have PWH WITH 4 COMPONENTs documented any time before end of report period
+5 NEW APCMP
+6 SET (APCMD1,APCMN1)=0
+7 IF APCMRPTT=1
SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:1
+8 IF APCMN565(APCMTIME)
SET F=$PIECE(^APCM13OB(APCMIC,0),U,11)
Begin DoDot:2
+9 DO S^APCM13E1(APCMRPT,APCMIC,"Facility is excluded from this measure as they did not see any patients <=5 or >=65 years old.",APCMP,APCMRPTT,APCMTIME,F,1)
QUIT
End DoDot:2
QUIT
+10 ;set denominator value into field
+11 SET G=0
+12 IF APCMAGEB<5
GOTO PR1
+13 IF APCMAGEB<65
QUIT
+14 ;born after time period begin date
IF $$DOB^AUPNPAT(DFN)>APCMBDAT
QUIT
PR1 ;IS CHART ACTIVE OR DECEASED
+1 SET X=$$DOD^AUPNPAT(DFN)
+2 IF X
IF X'>APCMEDAT
QUIT
+3 ;no charts
IF '$ORDER(^AUPNPAT(DFN,41,0))
QUIT
+4 SET X=$PIECE($GET(^AUPNPAT(DFN,41,DUZ(2),0)),U,3)
+5 IF X
IF X'>APCMEDAT
QUIT
+6 ;did they have a visit ever to the EP?
+7 ;I DUZ=2793 W !,DFN," ",$$NOW^XLFDT
+8 ;K APCMPRVT
+9 ;D ALLV^APCLAPIU(DFN,$$DOB^AUPNPAT(DFN),APCMEDAT,"APCMPRVT")
+10 IF '$$HADV(DFN,APCMP,$$DOB^AUPNPAT(DFN),APCMEDAT)
QUIT
+11 ;I DUZ=2793 W !,DFN W " YES"
+12 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+13 DO S^APCM13E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
+14 SET APCMVALU=""
+15 ;numerator?
+16 ;return # of visits^# w/pwh
SET APCMEP=$$HASPWHR(DFN,APCMBDAT,APCMEDAT,APCMP,.APCMVSTS)
+17 SET APCMVALU="Patient age: "_$$AGE^AUPNPAT(DFN,APCMBDAT)_"|||"_"PWH: "_$PIECE(APCMEP,U,2)_"|||"_$PIECE(APCMEP,U,1)
+18 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+19 DO S^APCM13E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
+20 DO SETLIST^APCM13E1
End DoDot:1
+21 QUIT
HADV(P,PROV,BD,ED) ;EP
+1 NEW X,Y,G,V
+2 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNVPRV("B",PROV,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+3 IF '$DATA(^AUPNVPRV(X,0))
QUIT
+4 IF $PIECE(^AUPNVPRV(X,0),U,2)'=P
QUIT
+5 IF $PIECE(^AUPNVPRV(X,0),U,4)'="P"
QUIT
+6 SET V=$PIECE(^AUPNVPRV(X,0),U,3)
+7 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+8 ;not correct service category
IF "AOSM"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+9 SET C=$$CLINIC^APCLV(V,"C")
+10 ;no ER per Carmen patch 1
IF C=30
QUIT
+11 ;no case management clinic 77 per Chris
IF C=77
QUIT
+12 ;no lab
IF C=76
QUIT
+13 ;no radiology
IF C=63
QUIT
+14 ;no pharmacy
IF C=39
QUIT
+15 SET G=1
+16 QUIT
End DoDot:1
+17 QUIT G
HASPWHR(P,BD,ED,R,VSTS) ;
+1 ;
+2 NEW A,B,C,D,E,X,Y,V,PWH,T,W,Z,Q
+3 SET PWH=""
+4 SET D=$$FMADD^XLFDT(BD,-1)
+5 SET A=D
SET B=0
FOR
SET A=$ORDER(^APCHPWHL("AA",P,A))
IF A'=+A!($PIECE(A,".")>ED)!(PWH)
QUIT
Begin DoDot:1
+6 SET Z=0
SET C=0
FOR
SET Z=$ORDER(^APCHPWHL("AA",P,A,Z))
IF Z'=+Z!(PWH)
QUIT
Begin DoDot:2
+7 SET W=$PIECE(^APCHPWHL(Z,0),U,2)
+8 IF 'W
QUIT
+9 ;REMOVED CHECK ON TYPE OF PWH
+10 SET PWH=1_U_$$DATE^APCM1UTL(A)_" "_$PIECE(^APCHPWHT(W,0),U)
End DoDot:2
End DoDot:1
+11 QUIT PWH
SC ;EP - REFERRAL, SUMMARY OF CARE
+1 NEW APCMP
+2 SET (APCMD1,APCMN1)=0
+3 IF APCMRPTT=1
SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:1
+4 IF $DATA(APCMRCIS(APCMP,APCMTIME))
SET F=$PIECE(^APCM13OB(APCMIC,0),U,11)
Begin DoDot:2
+5 DO S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not make any referrals for patients they saw during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
QUIT
End DoDot:2
QUIT
+6 ;Q:'$D(APCMHVTP(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
+7 ;set denominator value into field
+8 ;# referrals^# w/c32 documentation
SET APCMEP=$$HASC32(DFN,APCMBDAT,$$FMADD^XLFDT(APCMEDAT,-14),APCMP)
+9 IF $PIECE(APCMEP,U,1)=0
QUIT
+10 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+11 DO S^APCM13E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
+12 ;S APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
+13 ;numerator?
+14 SET APCMVALU="# of refs: "_$PIECE(APCMEP,U,1)_" # w/C32 w/in 14 days: "_+$PIECE(APCMEP,U,2)_"|||"_$PIECE(APCMEP,U,3)_"|||"_$SELECT('+$PIECE(APCMEP,U,1):0,+$PIECE(APCMEP,U,1)=+$PIECE(APCMEP,U,2):1,1:0)
+15 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+16 DO S^APCM13E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,2),APCMP,APCMRPTT,APCMTIME,F)
+17 DO SETLIST^APCM13E1
End DoDot:1
+18 QUIT
HASC32(P,BD,ED,R) ;does patient have a referral with c32
+1 ;
+2 NEW A,B,C,D,E,ROI,X,ROII,S,G
+3 ;set to 1 if had a good request
SET ROI="0^0"
+4 ;set to date of reques
SET ROII=""
+5 SET D=$$FMADD^XLFDT(BD,-1)
+6 FOR
SET D=$ORDER(^BMCREF("AA",P,D))
IF D'=+D!(D>ED)
QUIT
Begin DoDot:1
+7 SET X=0
FOR
SET X=$ORDER(^BMCREF("AA",P,D,X))
IF X'=+X
QUIT
Begin DoDot:2
+8 ;check to see if it is for this provider, is an A or CL and is not an in-house
+9 SET S=$PIECE(^BMCREF(X,0),U,6)
+10 ;not the requesting provider we want
IF S'=R
QUIT
+11 SET S=$PIECE(^BMCREF(X,0),U,15)
+12 ;not a A or C1
IF S'="A"
IF S'="C1"
QUIT
+13 IF $PIECE(^BMCREF(X,0),U,4)="N"
QUIT
+14 ;was it 1 day before through 1 day after discharge
+15 ;OR was it on the date of an 30/80 visit or the day after
+16 SET $PIECE(ROI,U,1)=$PIECE(ROI,U,1)+1
+17 ;now check to see if a c32 was printed
+18 IF '$ORDER(^BMCREF(X,6,"B",0))
SET $PIECE(ROI,U,2)=0
SET ROII=" Ref: "_$$DATE^APCM1UTL(D)_":C32 None;"
QUIT
+19 SET Y=0
SET G=0
FOR
SET Y=$ORDER(^BMCREF(X,6,"B",Y))
IF Y'=+Y!(G)
QUIT
Begin DoDot:3
+20 IF $PIECE(Y,".")'<D
IF $PIECE(Y,".")'>$$FMADD^XLFDT(D,14)
SET G=1
SET $PIECE(ROI,U,2)=$PIECE(ROI,U,2)+1
SET ROII=ROII_"Ref: "_$$DATE^APCM1UTL(D)_":C32 "_$$DATE^APCM1UTL(Y)_";"
QUIT
+21 SET ROII=ROII_" Ref: "_$$DATE^APCM1UTL(D)_":C32 "_$$DATE^APCM1UTL(Y)_";"
End DoDot:3
End DoDot:2
End DoDot:1
+22 QUIT ROI_U_ROII
+23 ;
LAB ;EP - CALCULATE LAB
+1 ;for each provider count each lab in the time period, loop through patients for visits in time period
+2 KILL ^TMP($JOB,"PATSRX")
+3 KILL APCMLABS
+4 DO TOTLAB
+5 NEW APCMP,N,F
+6 SET (APCMD1,APCMN1)=0
+7 IF APCMRPTT=1
SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:1
+8 IF '$PIECE($GET(APCMLABS(APCMP)),U,1)
Begin DoDot:2
+9 SET F=$PIECE(^APCM13OB(APCMIC,0),U,11)
DO S^APCM13E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not order any lab tests with results during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
QUIT
End DoDot:2
QUIT
+10 ;set denominator value into field
+11 ;denom field for this measure
SET F=$PIECE(^APCM13OB(APCMIC,0),U,8)
+12 ;returns # of LABS^# not Structured data
SET N=$PIECE($GET(APCMLABS(APCMP)),U,1)
+13 DO S^APCM13E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
+14 ;now set patient list for this provider
+15 SET P=0
FOR
SET P=$ORDER(^TMP($JOB,"PATSRX",APCMP,P))
IF P'=+P
QUIT
Begin DoDot:2
+16 ;Q:'$P(^TMP($J,"PATSRX",APCMP,P),U,1)
+17 IF $PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,1)=$PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,2)
SET APCMVALU="# Labs: "_$PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,1)_"|||"_" # w/structured result: "_+$PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,2)_"|||1"
Begin DoDot:3
+18 SET DFN=P
DO SETLIST^APCM13E1
QUIT
End DoDot:3
QUIT
+19 SET S=""
SET APCMVALU="No Structured Result: "
+20 FOR
SET S=$ORDER(^TMP($JOB,"PATSRX",APCMP,P,"SCRIPTS",S))
IF S=""
QUIT
Begin DoDot:3
+21 IF '$DATA(^TMP($JOB,"PATSRX",APCMP,P,"ELEC",S))
Begin DoDot:4
+22 SET APCMVALU=APCMVALU_S_";"
End DoDot:4
End DoDot:3
+23 SET DFN=P
SET APCMVALU="# of Labs: "_$PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,1)_" # w/structured results: "_+$PIECE(^TMP($JOB,"PATSRX",APCMP,P),U,2)_"|||"_APCMVALU
SET $PIECE(APCMVALU,"|||",3)=0
DO SETLIST^APCM13E1
End DoDot:2
+24 ;numerator?
+25 SET F=$PIECE(^APCM13OB(APCMIC,0),U,9)
+26 SET N=$PIECE($GET(APCMLABS(APCMP)),U,2)
+27 DO S^APCM13E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
End DoDot:1
+28 KILL ^TMP($JOB,"PATSRX")
+29 QUIT
TOTLAB ;EP -
+1 DO TOTLAB^APCM13E8
+2 QUIT