APCM24E5 ;IHS/CMI/LAB - IHS MU;
;;1.0;IHS MU PERFORMANCE REPORTS;**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
..I $D(APCMOFFV(APCMP,APCMTIME)) S F=$P(^APCM24OB(APCMIC,0),U,11) D Q
...D S^APCM24E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not have any office visits during the EHR Reporting Period.",APCMP,APCMRPTT,APCMTIME,F,1) Q
..Q:'$D(APCMPEVT(APCMP)) ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
..;Q:'$D(APCMHVTP(APCMP))
..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(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
D S^APCM24E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
;numerator?
S APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
;S APCMEP=$$HASED(DFN,APCMBDAT,DT)
;S APCMEP=$$HASED(DFN,$$FMADD^XLFDT(APCMBDAT,-365),DT)
;I APCMRPTT=2 S APCMEP=$$HASEDH(DFN,APCMBDAT,APCMEDAT,APCMFAC,.APCMVSTS)
NEW B
I APCMRPTT=1 S B=$E(APCMBDAT,1,3)_"0101"
I APCMRPTT=2 S B=$S(+$E(APCMBDAT,4,5)>9:$E(APCMBDAT,1,3)_"1001",1:$E(APCMBDAT,1,3)-1_"1001")
S APCMEP=$$HASED(DFN,B,APCMEDAT)
S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
S F=$P(^APCM24OB(APCMIC,0),U,9)
D S^APCM24E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
;S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
D SETLIST^APCM24E1
Q
;
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
HASMMR(V) ;does patient have a m-mr ON this visit in v updated/reviewed
;
NEW X,Y,Z
S Z=""
S X=0 F S X=$O(^AUPNVRUP("AD",V,X)) Q:X'=+X!(Z) D
.S Y=0 F S Y=$O(^AUPNVRUP(X,26,Y)) Q:Y'=+Y!(Z) D
..I $P($G(^AUPNVRUP(X,26,Y,0)),U,1)=428191000124101 S Z=1
Q Z
PR ;EP - patient reminders
;if patinet seen 2 or more times in 24 months prior to bd and still alive on last day of reporting period
;exclude deceased, and inactive charts
;if so, then check to see if they have icare notice ocumented 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 $D(APCM24BR(APCMP)) S F=$P(^APCM24OB(APCMIC,0),U,11) D Q
..D S^APCM24E1(APCMRPT,APCMIC,"Provider is excluded from this measure as the EP did not have any office visits in 24 months before report period.",APCMP,APCMRPTT,APCMTIME,F,1) Q
.;set denominator value into field
.S G=0
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
.;2 visits w/EP in 24 months before EHR reporting period?
.Q:'$$HADV(DFN,APCMP,$$FMADD^XLFDT(APCMBD,-(24*30.5)),$$FMADD^XLFDT(APCMBD,-1)) ;DIDN'T HAVE 2 VISITS
.S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
.D S^APCM24E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
.S APCMVALU=""
.;numerator?
.S APCMEP=$$HASRM(DFN,APCMBDAT,APCMEDAT)
.S APCMVALU="|||"_"NOTIFICATION: "_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
.S F=$P(^APCM24OB(APCMIC,0),U,9)
.D S^APCM24E1(APCMRPT,APCMIC,$P(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
.D SETLIST^APCM24E1
Q
HADV(P,R,BD,ED) ;EP - had visit of A, O, R, S with provider R in time frame BD-ED
;PATCH 1 excludes ER and case management clinics
;patch 1 provider must be primary only
; so, in summary, the patient must have at least 1 A,O,R,M, non-ER, non-case man visit
; where this provider is the primary provider
I '$G(P) Q ""
I '$G(R) Q ""
I '$G(BD) Q ""
I '$G(ED) Q ""
I '$D(^AUPNPAT(P,0)) Q ""
I '$D(^VA(200,R,0)) Q ""
NEW V,X,Y,G,VSTS
D ALLV^APCLAPIU(P,BD,ED,"VSTS")
S G=0
S X=0 F S X=$O(VSTS(X)) Q:X'=+X!(G>1) D
.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
.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 Y=$$PRIMPROV^APCLV(V,"I")
.I 'Y Q
.I Y'=R Q ;not this provider
.S G=G+1
I G>1 Q 1 ;2 or more?
Q 0
;
HASRM(P,BD,ED) ;
;
NEW A,B,C,NOTIF,N
S NOTIF=""
S A=0 F S A=$O(^BQI(90509.4,"B",P,A)) Q:A'=+A!(NOTIF) D
.S N=$G(^BQI(90509.4,A,0))
.I N="" Q ;BAD XREF
.S B=$P($P(N,U,4),".")
.Q:B<BD ;before time period
.Q:B>ED ;after time period
.S C=$P(N,U,2) ;preferred method
.I C="" S NOTIF=1_U_$$GET1^DIQ(90509.4,A,.09)_" "_$$FMTE^XLFDT(B) Q
.I C'=$P(N,U,3) ;preferred doesn't match notificaton type so don't count it
.S NOTIF=1_U_$$GET1^DIQ(90509.4,A,.09)_" "_$$FMTE^XLFDT(B)
Q NOTIF
SC ;EP - TRANSITION OF CARE SUMMARY
;for each provider count each Visit that HAS a v referral
K ^TMP($J,"TRANS")
NEW APCMLABS,MMR
D TOCSUMC
NEW APCMP,N,F,O,Y
S (APCMD1,APCMN1)=0
I APCMRPTT=1 S APCMP=0 F S APCMP=$O(APCMPRV(APCMP)) Q:APCMP'=+APCMP D
.I $P($G(MMR(APCMP)),U,1)<100 D
..S F=$P(^APCM24OB(APCMIC,0),U,11) D S^APCM24E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had less than 100 referrals during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
..;now get all related measures
..S O=0 F S O=$O(^APCM24OB(APCMIC,29,O)) Q:O'=+O S Y=$P(^APCM24OB(APCMIC,29,O,0),U,1),Y=$O(^APCM24OB("B",Y,0)) I Y D
...S F=$P(^APCM24OB(Y,0),U,11) D S^APCM24E1(APCMRPT,Y,"X",APCMP,APCMRPTT,APCMTIME,F,1)
.;set value for measure 3
.S Y=$O(^APCM24OB("B","S2.023.2.EP",0))
.S F=$P(^APCM24OB(Y,0),U,8) D S^APCM24E1(APCMRPT,Y,APCMATTE("S2.023.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F)
.;set denominator value into field FOR measure 1
.S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
.S N=$P($G(MMR(APCMP)),U,1) ;returns # of transS^# with mmr
.D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
.;now set patient list for this provider
.S P=0 F S P=$O(^TMP($J,"TRANS",APCMP,P)) Q:P'=+P D
..I $P(^TMP($J,"TRANS",APCMP,P),U,1)=$P(^TMP($J,"TRANS",APCMP,P),U,2) S APCMVALU="# referrals: "_$P(^TMP($J,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$P(^TMP($J,"TRANS",APCMP,P),U,2)_" "_$P(^TMP($J,"TRANS",APCMP,P),U,3)_"|||1" D Q
...S DFN=P D SETLIST^APCM24E1 Q
..S DFN=P,APCMVALU="# referrals: "_$P(^TMP($J,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$P(^TMP($J,"TRANS",APCMP,P),U,2)_" "_$P(^TMP($J,"TRANS",APCMP,P),U,3)_"|||0" D SETLIST^APCM24E1
.;numerator?
.S F=$P(^APCM24OB(APCMIC,0),U,9)
.S N=$P($G(MMR(APCMP)),U,2)
.D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
.;NOW SET VALUES FOR MEASURE 2
.S Y=$O(^APCM24OB("B","S2.023.1.EP",0))
.S F=$P(^APCM24OB(Y,0),U,8) D S^APCM24E1(APCMRPT,Y,$P($G(MMR(APCMP)),U,1),APCMP,APCMRPTT,APCMTIME,F)
.S F=$P(^APCM24OB(Y,0),U,9)
.S N=$P($G(MMR(APCMP)),U,5)
.D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
I APCMRPTT=2 S APCMP=APCMFAC D
.I '$P($G(MMR(APCMP)),U,1) D Q
..S F=$P(^APCM24OB(APCMIC,0),U,11) D S^APCM24E1(APCMRPT,APCMIC,"Facility is excluded from this measure as there were no referrals during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
..;now get all related measures
..S O=0 F S O=$O(^APCM24OB(APCMIC,29,O)) Q:O'=+O S Y=$P(^APCM24OB(APCMIC,29,O,0),U,1),Y=$O(^APCM24OB("B",Y,0)) I Y D
...S F=$P(^APCM24OB(Y,0),U,11) D S^APCM24E1(APCMRPT,Y,"X",APCMP,APCMRPTT,APCMTIME,F,1)
.;set value for measure 3
.S Y=$O(^APCM24OB("B","S2.021.2.H",0))
.S F=$P(^APCM24OB(Y,0),U,8) D S^APCM24E1(APCMRPT,Y,APCMATTE("S2.021.H",APCMP),APCMP,APCMRPTT,APCMTIME,F)
.;set denominator value into field FOR measure 1
.S F=$P(^APCM24OB(APCMIC,0),U,8) ;denom field for this measure
.S N=$P($G(MMR(APCMP)),U,1) ;returns # of transS^# with mmr
.D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
.;now set patient list for this provider
.S P=0 F S P=$O(^TMP($J,"TRANS",APCMP,P)) Q:P'=+P D
..I $P(^TMP($J,"TRANS",APCMP,P),U,1)=$P(^TMP($J,"TRANS",APCMP,P),U,2) S APCMVALU="# referrals: "_$P(^TMP($J,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$P(^TMP($J,"TRANS",APCMP,P),U,2)_" "_$P(^TMP($J,"TRANS",APCMP,P),U,3)_"|||1" D Q
...S DFN=P D SETLIST^APCM24E1 Q
..S DFN=P,APCMVALU="# referrals: "_$P(^TMP($J,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$P(^TMP($J,"TRANS",APCMP,P),U,2)_" "_$P(^TMP($J,"TRANS",APCMP,P),U,3)_"|||0" D SETLIST^APCM24E1
.;numerator?
.S F=$P(^APCM24OB(APCMIC,0),U,9)
.S N=$P($G(MMR(APCMP)),U,2)
.D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
.;NOW SET VALUES FOR MEASURE 2
.S Y=$O(^APCM24OB("B","S2.021.1.H",0))
.S F=$P(^APCM24OB(Y,0),U,8) D S^APCM24E1(APCMRPT,Y,$P($G(MMR(APCMP)),U,1),APCMP,APCMRPTT,APCMTIME,F)
.S F=$P(^APCM24OB(Y,0),U,9)
.S N=$P($G(MMR(APCMP)),U,5)
.D S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
K ^TMP($J,"TRANS")
Q
TOCSUMC ;EP - ep toc
;SET ARRAY MMR to MMR(prov ien)=denom^numer
;DENOM=# VISITS W/REFERRAL
;NUMER=# W/TOC DOCUMENT IN 600 MULTIPLE
;IF DENOM =0 THEN PROVIDER EXCLUSION
NEW T,C,PAT,N,APCMX,R,C,G,Z,S,B,E,J,K
S C=0,N=0,PAT=""
S T=$O(^APCMMUCN("B","INTERIM STAGE 2 2014",0))
;GO THROUGH EACH PATIENT WHO HAS VISITS
S PAT=0 F S PAT=$O(^AUPNVSIT("AA",PAT)) Q:PAT'=+PAT D TOCSUMC1
Q
TOCSUMC1 ;
NEW APCMLAB
S APCMLAB="APCMLAB"
D ALLV^APCLAPIU(PAT,APCMBDAT,APCMEDAT,APCMLAB) ;get all visits for this patient in time period
S APCMX=0 F S APCMX=$O(APCMLAB(APCMX)) Q:APCMX'=+APCMX D
.S V=$P(APCMLAB(APCMX),U,5) ;VISIT IEN
.Q:'$D(^AUPNVSIT(V,0)) ;NO VISIT??
.I APCMRPTT=2,APCMMETH="E" Q:'$$HOSER^APCM24E6(V,APCMFAC) S R=APCMFAC G TOCS2
.I APCMRPTT=2,APCMMETH="O" Q:"OH"'[$P(^AUPNVSIT(V,0),U,7) Q:$P(^AUPNVSIT(V,0),U,6)'=APCMFAC S R=APCMFAC G TOCS2
.S R=$$PRIMPROV^APCLV(V,"I") ;primary provider IEN
.Q:'R
.I '$D(APCMPRV(R)) Q ;not a provider of interest for this report
.Q:"AOSM"'[$P(^AUPNVSIT(V,0),U,7)
.S C=$$CLINIC^APCLV(V,"C")
.Q:C=30
.Q:C=77
.Q:C=76
.Q:C=63
.Q:C=39
TOCS2 .;IS THERE A V REFERAL THAT MEETS DENOM DEFINITION
.S Z=0 F S Z=$O(^AUPNVREF("AD",V,Z)) Q:Z'=+Z D
..Q:'$D(^AUPNVREF(Z,0)) ;??
..S S=$P(^AUPNVREF(Z,0),U,6) ;REFERRAL IEN
..Q:'S ;no referral??
..Q:'$D(^BMCREF(S,0)) ;bad pointer
..Q:$P(^BMCREF(S,0),U,4)="N" ;NO INHOUSE
..Q:$P($G(^BMCREF(S,11)),U,5)="" ;MUST HAVE AN EXPECTED BEGIN DOS
..S D=$P($G(^BMCREF(S,13)),U,5) ;approval date
..Q:D="" ;NO APPROVAL DATE
..Q:D>APCMEDAT ;AFTER TP
..Q:D<APCMBDAT ;BEFORE TP
SUMNUM ..;
..I '$D(MMR(R)) S MMR(R)=""
..S $P(MMR(R),U,1)=$P(MMR(R),U,1)+1 D
...S $P(^TMP($J,"TRANS",R,PAT),U,1)=$P($G(^TMP($J,"TRANS",R,PAT)),U,1)+1
...S $P(^TMP($J,"TRANS",R,PAT),U,3)=$P(^TMP($J,"TRANS",R,PAT),U,3)_" "_$$VD^APCLV(V,"S")_"-"_$P(^BMCREF(S,0),U,2)
..;now check numerator, FIELD 600
..S G=0,T=0
..;FIRST LOOK FOR A TX AND ACKNOWLEDGED IF FOUND, USE IT
..;NEXT LOOK FOR A TX, IF FOUND, USE IT
..;THEN LOOK FOR PRINTED.
..S B=0 F S B=$O(^BMCREF(S,6,B)) Q:B'=+B!(G) D
...S (A,E)=""
...I $P(^BMCREF(S,6,B,0),U,4)'="CT" Q
...S E=$P($P(^BMCREF(S,6,B,0),U,6),".")
...S M=$$CD(E,D,APCMEDAT)
...I 'M S E=$P($P(^BMCREF(S,6,B,0),U,1),".") S M=$$CD(E,D,APCMEDAT) Q:'M ;dates aren't good
...S A=$P($P(^BMCREF(S,6,B,0),U,3),".") ;tx acknowledged
...I A,A'<D,A'>APCMEDAT S G=1,T="CT"
...Q
..I G D SN Q
..;CHECK FOR TX BUT NO ACKNOWLEDGE
..S (G,A,T)=""
..S B=0 F S B=$O(^BMCREF(S,6,B)) Q:B'=+B!(G) D
...S (A,E)=""
...I $P(^BMCREF(S,6,B,0),U,4)'="CT" Q
...S E=$P($P(^BMCREF(S,6,B,0),U,6),".")
...S M=$$CD(E,D,APCMEDAT)
...I 'M S E=$P($P(^BMCREF(S,6,B,0),U,1),".") S M=$$CD(E,D,APCMEDAT) Q:'M ;dates aren't good
...;S A=$P($P(^BMCREF(S,6,B,0),U,3),".") ;tx acknowledged
...S G=1,A=0,T="CT"
...Q
..I G D SN Q
..;NOW PRINTED
..S (G,A,T)=""
..S B=0 F S B=$O(^BMCREF(S,6,B)) Q:B'=+B!(G) D
...S (A,E)=""
...I $P(^BMCREF(S,6,B,0),U,4)'="CP" Q
...S E=$P($P(^BMCREF(S,6,B,0),U,6),".")
...S M=$$CD(E,D,APCMEDAT)
...I 'M S E=$P($P(^BMCREF(S,6,B,0),U,1),".") S M=$$CD(E,D,APCMEDAT) Q:'M ;dates aren't good
...S G=1,A=0,T="CP"
...Q
..I G D SN Q
..;
SUMAPCC ..;CHECK APCC DOCUMENT FILE
..S J=0 F S J=$O(^APCCDPL(V,1,J)) Q:J'=+J!(G) D
...Q:$P($G(^APCCDPL(V,1,J,0)),U,4)'=2 ;TOC ONLY
...Q:$P($P(^APCCDPL(V,1,J,0),U,1),".")'=$$VD^APCLV(V) ;DATE MUST EQUAL VISIT DATE
...S G=1
...S $P(MMR(R),U,2)=$P(MMR(R),U,2)+1 D
....S $P(^TMP($J,"TRANS",R,PAT),U,2)=$P($G(^TMP($J,"TRANS",R,PAT)),U,2)+1
....S $P(^TMP($J,"TRANS",R,PAT),U,3)=$P(^TMP($J,"TRANS",R,PAT),U,3)_";YES APCC TOCS"
..I 'G S $P(^TMP($J,"TRANS",R,PAT),U,3)=$P(^TMP($J,"TRANS",R,PAT),U,3)_";NO TOCS" Q
Q
SN ;
S $P(MMR(R),U,2)=$P(MMR(R),U,2)+1 D Q
.S $P(^TMP($J,"TRANS",R,PAT),U,2)=$P($G(^TMP($J,"TRANS",R,PAT)),U,2)+1
.S $P(^TMP($J,"TRANS",R,PAT),U,3)=$P(^TMP($J,"TRANS",R,PAT),U,3)_";YES "_T I T="CT" S $P(^TMP($J,"TRANS",R,PAT),U,3)=$P(^TMP($J,"TRANS",R,PAT),U,3)_$S(A:" TX",1:"")
.I T="CT" S $P(MMR(R),U,4)=$P(MMR(R),U,4)+1 I A S $P(MMR(R),U,5)=$P(MMR(R),U,5)+1
Q
CD(E,D,APCMEDAT) ;
I E="" Q 0 ;NO DATE TRANSMITTED
I E<D Q 0 ;BEFORE APPROVAL DATE
I E>APCMEDAT Q 0 ;AFTER TIME PERIOD
Q 1
APCM24E5 ;IHS/CMI/LAB - IHS MU;
+1 ;;1.0;IHS MU PERFORMANCE REPORTS;**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 IF $DATA(APCMOFFV(APCMP,APCMTIME))
SET F=$PIECE(^APCM24OB(APCMIC,0),U,11)
Begin DoDot:3
+9 DO S^APCM24E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she did not have any office visits during the EHR Reporting Period.",APCMP,APCMRPTT,APCMTIME,F,1)
QUIT
End DoDot:3
QUIT
+10 ;no visits to this provider for this patient so don't bother, the patient is not in the denominator
IF '$DATA(APCMPEVT(APCMP))
QUIT
+11 ;Q:'$D(APCMHVTP(APCMP))
+12 DO PATEDUC1
+13 QUIT
End DoDot:2
End DoDot:1
QUIT
+14 IF APCMRPTT=2
Begin DoDot:1
+15 SET APCMP=APCMFAC
+16 IF '$DATA(APCMHVTP(APCMP))
QUIT
+17 DO PATEDUC1
+18 QUIT
End DoDot:1
+19 QUIT
PATEDUC1 ;
+1 ;set denominator value into field
+2 ;denom field for this measure
SET F=$PIECE(^APCM24OB(APCMIC,0),U,8)
+3 DO S^APCM24E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
+4 ;numerator?
+5 SET APCMVALU="VISIT: "_$$DATE^APCM1UTL(APCMHVTP(APCMP))
+6 ;S APCMEP=$$HASED(DFN,APCMBDAT,DT)
+7 ;S APCMEP=$$HASED(DFN,$$FMADD^XLFDT(APCMBDAT,-365),DT)
+8 ;I APCMRPTT=2 S APCMEP=$$HASEDH(DFN,APCMBDAT,APCMEDAT,APCMFAC,.APCMVSTS)
+9 NEW B
+10 IF APCMRPTT=1
SET B=$EXTRACT(APCMBDAT,1,3)_"0101"
+11 IF APCMRPTT=2
SET B=$SELECT(+$EXTRACT(APCMBDAT,4,5)>9:$EXTRACT(APCMBDAT,1,3)_"1001",1:$EXTRACT(APCMBDAT,1,3)-1_"1001")
+12 SET APCMEP=$$HASED(DFN,B,APCMEDAT)
+13 SET APCMVALU=APCMVALU_"|||"_$PIECE(APCMEP,U,2)_"|||"_$PIECE(APCMEP,U,1)
+14 SET F=$PIECE(^APCM24OB(APCMIC,0),U,9)
+15 DO S^APCM24E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
+16 ;S APCMVALU=APCMVALU_"|||"_$P(APCMEP,U,2)_"|||"_$P(APCMEP,U,1)
+17 DO SETLIST^APCM24E1
+18 QUIT
+19 ;
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
HASMMR(V) ;does patient have a m-mr ON this visit in v updated/reviewed
+1 ;
+2 NEW X,Y,Z
+3 SET Z=""
+4 SET X=0
FOR
SET X=$ORDER(^AUPNVRUP("AD",V,X))
IF X'=+X!(Z)
QUIT
Begin DoDot:1
+5 SET Y=0
FOR
SET Y=$ORDER(^AUPNVRUP(X,26,Y))
IF Y'=+Y!(Z)
QUIT
Begin DoDot:2
+6 IF $PIECE($GET(^AUPNVRUP(X,26,Y,0)),U,1)=428191000124101
SET Z=1
End DoDot:2
End DoDot:1
+7 QUIT Z
PR ;EP - patient reminders
+1 ;if patinet seen 2 or more times in 24 months prior to bd and still alive on last day of reporting period
+2 ;exclude deceased, and inactive charts
+3 ;if so, then check to see if they have icare notice ocumented any time before end of report period
+4 NEW APCMP
+5 SET (APCMD1,APCMN1)=0
+6 IF APCMRPTT=1
SET APCMP=0
FOR
SET APCMP=$ORDER(APCMPRV(APCMP))
IF APCMP'=+APCMP
QUIT
Begin DoDot:1
+7 IF $DATA(APCM24BR(APCMP))
SET F=$PIECE(^APCM24OB(APCMIC,0),U,11)
Begin DoDot:2
+8 DO S^APCM24E1(APCMRPT,APCMIC,"Provider is excluded from this measure as the EP did not have any office visits in 24 months before report period.",APCMP,APCMRPTT,APCMTIME,F,1)
QUIT
End DoDot:2
QUIT
+9 ;set denominator value into field
+10 SET G=0
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 ;2 visits w/EP in 24 months before EHR reporting period?
+7 ;DIDN'T HAVE 2 VISITS
IF '$$HADV(DFN,APCMP,$$FMADD^XLFDT(APCMBD,-(24*30.5)),$$FMADD^XLFDT(APCMBD,-1))
QUIT
+8 ;denom field for this measure
SET F=$PIECE(^APCM24OB(APCMIC,0),U,8)
+9 DO S^APCM24E1(APCMRPT,APCMIC,1,APCMP,APCMRPTT,APCMTIME,F)
+10 SET APCMVALU=""
+11 ;numerator?
+12 SET APCMEP=$$HASRM(DFN,APCMBDAT,APCMEDAT)
+13 SET APCMVALU="|||"_"NOTIFICATION: "_$PIECE(APCMEP,U,2)_"|||"_$PIECE(APCMEP,U,1)
+14 SET F=$PIECE(^APCM24OB(APCMIC,0),U,9)
+15 DO S^APCM24E1(APCMRPT,APCMIC,$PIECE(APCMEP,U,1),APCMP,APCMRPTT,APCMTIME,F)
+16 DO SETLIST^APCM24E1
End DoDot:1
+17 QUIT
HADV(P,R,BD,ED) ;EP - had visit of A, O, R, S with provider R in time frame BD-ED
+1 ;PATCH 1 excludes ER and case management clinics
+2 ;patch 1 provider must be primary only
+3 ; so, in summary, the patient must have at least 1 A,O,R,M, non-ER, non-case man visit
+4 ; where this provider is the primary provider
+5 IF '$GET(P)
QUIT ""
+6 IF '$GET(R)
QUIT ""
+7 IF '$GET(BD)
QUIT ""
+8 IF '$GET(ED)
QUIT ""
+9 IF '$DATA(^AUPNPAT(P,0))
QUIT ""
+10 IF '$DATA(^VA(200,R,0))
QUIT ""
+11 NEW V,X,Y,G,VSTS
+12 DO ALLV^APCLAPIU(P,BD,ED,"VSTS")
+13 SET G=0
+14 SET X=0
FOR
SET X=$ORDER(VSTS(X))
IF X'=+X!(G>1)
QUIT
Begin DoDot:1
+15 SET V=$PIECE(VSTS(X),U,5)
+16 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+17 ;deleted
IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+18 ;not correct service category
IF "AOSM"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+19 SET C=$$CLINIC^APCLV(V,"C")
+20 ;no ER per Carmen patch 1
IF C=30
QUIT
+21 ;no case management clinic 77 per Chris
IF C=77
QUIT
+22 ;no lab
IF C=76
QUIT
+23 ;no radiology
IF C=63
QUIT
+24 ;no pharmacy
IF C=39
QUIT
+25 SET Y=$$PRIMPROV^APCLV(V,"I")
+26 IF 'Y
QUIT
+27 ;not this provider
IF Y'=R
QUIT
+28 SET G=G+1
End DoDot:1
+29 ;2 or more?
IF G>1
QUIT 1
+30 QUIT 0
+31 ;
HASRM(P,BD,ED) ;
+1 ;
+2 NEW A,B,C,NOTIF,N
+3 SET NOTIF=""
+4 SET A=0
FOR
SET A=$ORDER(^BQI(90509.4,"B",P,A))
IF A'=+A!(NOTIF)
QUIT
Begin DoDot:1
+5 SET N=$GET(^BQI(90509.4,A,0))
+6 ;BAD XREF
IF N=""
QUIT
+7 SET B=$PIECE($PIECE(N,U,4),".")
+8 ;before time period
IF B<BD
QUIT
+9 ;after time period
IF B>ED
QUIT
+10 ;preferred method
SET C=$PIECE(N,U,2)
+11 IF C=""
SET NOTIF=1_U_$$GET1^DIQ(90509.4,A,.09)_" "_$$FMTE^XLFDT(B)
QUIT
+12 ;preferred doesn't match notificaton type so don't count it
IF C'=$PIECE(N,U,3)
+13 SET NOTIF=1_U_$$GET1^DIQ(90509.4,A,.09)_" "_$$FMTE^XLFDT(B)
End DoDot:1
+14 QUIT NOTIF
SC ;EP - TRANSITION OF CARE SUMMARY
+1 ;for each provider count each Visit that HAS a v referral
+2 KILL ^TMP($JOB,"TRANS")
+3 NEW APCMLABS,MMR
+4 DO TOCSUMC
+5 NEW APCMP,N,F,O,Y
+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(MMR(APCMP)),U,1)<100
Begin DoDot:2
+9 SET F=$PIECE(^APCM24OB(APCMIC,0),U,11)
DO S^APCM24E1(APCMRPT,APCMIC,"Provider is excluded from this measure as he/she had less than 100 referrals during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
+10 ;now get all related measures
+11 SET O=0
FOR
SET O=$ORDER(^APCM24OB(APCMIC,29,O))
IF O'=+O
QUIT
SET Y=$PIECE(^APCM24OB(APCMIC,29,O,0),U,1)
SET Y=$ORDER(^APCM24OB("B",Y,0))
IF Y
Begin DoDot:3
+12 SET F=$PIECE(^APCM24OB(Y,0),U,11)
DO S^APCM24E1(APCMRPT,Y,"X",APCMP,APCMRPTT,APCMTIME,F,1)
End DoDot:3
End DoDot:2
+13 ;set value for measure 3
+14 SET Y=$ORDER(^APCM24OB("B","S2.023.2.EP",0))
+15 SET F=$PIECE(^APCM24OB(Y,0),U,8)
DO S^APCM24E1(APCMRPT,Y,APCMATTE("S2.023.EP",APCMP),APCMP,APCMRPTT,APCMTIME,F)
+16 ;set denominator value into field FOR measure 1
+17 ;denom field for this measure
SET F=$PIECE(^APCM24OB(APCMIC,0),U,8)
+18 ;returns # of transS^# with mmr
SET N=$PIECE($GET(MMR(APCMP)),U,1)
+19 DO S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
+20 ;now set patient list for this provider
+21 SET P=0
FOR
SET P=$ORDER(^TMP($JOB,"TRANS",APCMP,P))
IF P'=+P
QUIT
Begin DoDot:2
+22 IF $PIECE(^TMP($JOB,"TRANS",APCMP,P),U,1)=$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,2)
SET APCMVALU="# referrals: "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,2)_" "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,3)_"|||1"
Begin DoDot:3
+23 SET DFN=P
DO SETLIST^APCM24E1
QUIT
End DoDot:3
QUIT
+24 SET DFN=P
SET APCMVALU="# referrals: "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,2)_" "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,3)_"|||0"
DO SETLIST^APCM24E1
End DoDot:2
+25 ;numerator?
+26 SET F=$PIECE(^APCM24OB(APCMIC,0),U,9)
+27 SET N=$PIECE($GET(MMR(APCMP)),U,2)
+28 DO S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
+29 ;NOW SET VALUES FOR MEASURE 2
+30 SET Y=$ORDER(^APCM24OB("B","S2.023.1.EP",0))
+31 SET F=$PIECE(^APCM24OB(Y,0),U,8)
DO S^APCM24E1(APCMRPT,Y,$PIECE($GET(MMR(APCMP)),U,1),APCMP,APCMRPTT,APCMTIME,F)
+32 SET F=$PIECE(^APCM24OB(Y,0),U,9)
+33 SET N=$PIECE($GET(MMR(APCMP)),U,5)
+34 DO S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
End DoDot:1
+35 IF APCMRPTT=2
SET APCMP=APCMFAC
Begin DoDot:1
+36 IF '$PIECE($GET(MMR(APCMP)),U,1)
Begin DoDot:2
+37 SET F=$PIECE(^APCM24OB(APCMIC,0),U,11)
DO S^APCM24E1(APCMRPT,APCMIC,"Facility is excluded from this measure as there were no referrals during the EHR reporting period.",APCMP,APCMRPTT,APCMTIME,F,1)
+38 ;now get all related measures
+39 SET O=0
FOR
SET O=$ORDER(^APCM24OB(APCMIC,29,O))
IF O'=+O
QUIT
SET Y=$PIECE(^APCM24OB(APCMIC,29,O,0),U,1)
SET Y=$ORDER(^APCM24OB("B",Y,0))
IF Y
Begin DoDot:3
+40 SET F=$PIECE(^APCM24OB(Y,0),U,11)
DO S^APCM24E1(APCMRPT,Y,"X",APCMP,APCMRPTT,APCMTIME,F,1)
End DoDot:3
End DoDot:2
QUIT
+41 ;set value for measure 3
+42 SET Y=$ORDER(^APCM24OB("B","S2.021.2.H",0))
+43 SET F=$PIECE(^APCM24OB(Y,0),U,8)
DO S^APCM24E1(APCMRPT,Y,APCMATTE("S2.021.H",APCMP),APCMP,APCMRPTT,APCMTIME,F)
+44 ;set denominator value into field FOR measure 1
+45 ;denom field for this measure
SET F=$PIECE(^APCM24OB(APCMIC,0),U,8)
+46 ;returns # of transS^# with mmr
SET N=$PIECE($GET(MMR(APCMP)),U,1)
+47 DO S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
+48 ;now set patient list for this provider
+49 SET P=0
FOR
SET P=$ORDER(^TMP($JOB,"TRANS",APCMP,P))
IF P'=+P
QUIT
Begin DoDot:2
+50 IF $PIECE(^TMP($JOB,"TRANS",APCMP,P),U,1)=$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,2)
SET APCMVALU="# referrals: "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,2)_" "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,3)_"|||1"
Begin DoDot:3
+51 SET DFN=P
DO SETLIST^APCM24E1
QUIT
End DoDot:3
QUIT
+52 SET DFN=P
SET APCMVALU="# referrals: "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,1)_"|||"_" # w/TOCS: "_+$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,2)_" "_$PIECE(^TMP($JOB,"TRANS",APCMP,P),U,3)_"|||0"
DO SETLIST^APCM24E1
End DoDot:2
+53 ;numerator?
+54 SET F=$PIECE(^APCM24OB(APCMIC,0),U,9)
+55 SET N=$PIECE($GET(MMR(APCMP)),U,2)
+56 DO S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
+57 ;NOW SET VALUES FOR MEASURE 2
+58 SET Y=$ORDER(^APCM24OB("B","S2.021.1.H",0))
+59 SET F=$PIECE(^APCM24OB(Y,0),U,8)
DO S^APCM24E1(APCMRPT,Y,$PIECE($GET(MMR(APCMP)),U,1),APCMP,APCMRPTT,APCMTIME,F)
+60 SET F=$PIECE(^APCM24OB(Y,0),U,9)
+61 SET N=$PIECE($GET(MMR(APCMP)),U,5)
+62 DO S^APCM24E1(APCMRPT,APCMIC,N,APCMP,APCMRPTT,APCMTIME,F)
End DoDot:1
+63 KILL ^TMP($JOB,"TRANS")
+64 QUIT
TOCSUMC ;EP - ep toc
+1 ;SET ARRAY MMR to MMR(prov ien)=denom^numer
+2 ;DENOM=# VISITS W/REFERRAL
+3 ;NUMER=# W/TOC DOCUMENT IN 600 MULTIPLE
+4 ;IF DENOM =0 THEN PROVIDER EXCLUSION
+5 NEW T,C,PAT,N,APCMX,R,C,G,Z,S,B,E,J,K
+6 SET C=0
SET N=0
SET PAT=""
+7 SET T=$ORDER(^APCMMUCN("B","INTERIM STAGE 2 2014",0))
+8 ;GO THROUGH EACH PATIENT WHO HAS VISITS
+9 SET PAT=0
FOR
SET PAT=$ORDER(^AUPNVSIT("AA",PAT))
IF PAT'=+PAT
QUIT
DO TOCSUMC1
+10 QUIT
TOCSUMC1 ;
+1 NEW APCMLAB
+2 SET APCMLAB="APCMLAB"
+3 ;get all visits for this patient in time period
DO ALLV^APCLAPIU(PAT,APCMBDAT,APCMEDAT,APCMLAB)
+4 SET APCMX=0
FOR
SET APCMX=$ORDER(APCMLAB(APCMX))
IF APCMX'=+APCMX
QUIT
Begin DoDot:1
+5 ;VISIT IEN
SET V=$PIECE(APCMLAB(APCMX),U,5)
+6 ;NO VISIT??
IF '$DATA(^AUPNVSIT(V,0))
QUIT
+7 IF APCMRPTT=2
IF APCMMETH="E"
IF '$$HOSER^APCM24E6(V,APCMFAC)
QUIT
SET R=APCMFAC
GOTO TOCS2
+8 IF APCMRPTT=2
IF APCMMETH="O"
IF "OH"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
IF $PIECE(^AUPNVSIT(V,0),U,6)'=APCMFAC
QUIT
SET R=APCMFAC
GOTO TOCS2
+9 ;primary provider IEN
SET R=$$PRIMPROV^APCLV(V,"I")
+10 IF 'R
QUIT
+11 ;not a provider of interest for this report
IF '$DATA(APCMPRV(R))
QUIT
+12 IF "AOSM"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+13 SET C=$$CLINIC^APCLV(V,"C")
+14 IF C=30
QUIT
+15 IF C=77
QUIT
+16 IF C=76
QUIT
+17 IF C=63
QUIT
+18 IF C=39
QUIT
TOCS2 ;IS THERE A V REFERAL THAT MEETS DENOM DEFINITION
+1 SET Z=0
FOR
SET Z=$ORDER(^AUPNVREF("AD",V,Z))
IF Z'=+Z
QUIT
Begin DoDot:2
+2 ;??
IF '$DATA(^AUPNVREF(Z,0))
QUIT
+3 ;REFERRAL IEN
SET S=$PIECE(^AUPNVREF(Z,0),U,6)
+4 ;no referral??
IF 'S
QUIT
+5 ;bad pointer
IF '$DATA(^BMCREF(S,0))
QUIT
+6 ;NO INHOUSE
IF $PIECE(^BMCREF(S,0),U,4)="N"
QUIT
+7 ;MUST HAVE AN EXPECTED BEGIN DOS
IF $PIECE($GET(^BMCREF(S,11)),U,5)=""
QUIT
+8 ;approval date
SET D=$PIECE($GET(^BMCREF(S,13)),U,5)
+9 ;NO APPROVAL DATE
IF D=""
QUIT
+10 ;AFTER TP
IF D>APCMEDAT
QUIT
+11 ;BEFORE TP
IF D<APCMBDAT
QUIT
SUMNUM ;
+1 IF '$DATA(MMR(R))
SET MMR(R)=""
+2 SET $PIECE(MMR(R),U,1)=$PIECE(MMR(R),U,1)+1
Begin DoDot:3
+3 SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,1)=$PIECE($GET(^TMP($JOB,"TRANS",R,PAT)),U,1)+1
+4 SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)=$PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)_" "_$$VD^APCLV(V,"S")_"-"_$PIECE(^BMCREF(S,0),U,2)
End DoDot:3
+5 ;now check numerator, FIELD 600
+6 SET G=0
SET T=0
+7 ;FIRST LOOK FOR A TX AND ACKNOWLEDGED IF FOUND, USE IT
+8 ;NEXT LOOK FOR A TX, IF FOUND, USE IT
+9 ;THEN LOOK FOR PRINTED.
+10 SET B=0
FOR
SET B=$ORDER(^BMCREF(S,6,B))
IF B'=+B!(G)
QUIT
Begin DoDot:3
+11 SET (A,E)=""
+12 IF $PIECE(^BMCREF(S,6,B,0),U,4)'="CT"
QUIT
+13 SET E=$PIECE($PIECE(^BMCREF(S,6,B,0),U,6),".")
+14 SET M=$$CD(E,D,APCMEDAT)
+15 ;dates aren't good
IF 'M
SET E=$PIECE($PIECE(^BMCREF(S,6,B,0),U,1),".")
SET M=$$CD(E,D,APCMEDAT)
IF 'M
QUIT
+16 ;tx acknowledged
SET A=$PIECE($PIECE(^BMCREF(S,6,B,0),U,3),".")
+17 IF A
IF A'<D
IF A'>APCMEDAT
SET G=1
SET T="CT"
+18 QUIT
End DoDot:3
+19 IF G
DO SN
QUIT
+20 ;CHECK FOR TX BUT NO ACKNOWLEDGE
+21 SET (G,A,T)=""
+22 SET B=0
FOR
SET B=$ORDER(^BMCREF(S,6,B))
IF B'=+B!(G)
QUIT
Begin DoDot:3
+23 SET (A,E)=""
+24 IF $PIECE(^BMCREF(S,6,B,0),U,4)'="CT"
QUIT
+25 SET E=$PIECE($PIECE(^BMCREF(S,6,B,0),U,6),".")
+26 SET M=$$CD(E,D,APCMEDAT)
+27 ;dates aren't good
IF 'M
SET E=$PIECE($PIECE(^BMCREF(S,6,B,0),U,1),".")
SET M=$$CD(E,D,APCMEDAT)
IF 'M
QUIT
+28 ;S A=$P($P(^BMCREF(S,6,B,0),U,3),".") ;tx acknowledged
+29 SET G=1
SET A=0
SET T="CT"
+30 QUIT
End DoDot:3
+31 IF G
DO SN
QUIT
+32 ;NOW PRINTED
+33 SET (G,A,T)=""
+34 SET B=0
FOR
SET B=$ORDER(^BMCREF(S,6,B))
IF B'=+B!(G)
QUIT
Begin DoDot:3
+35 SET (A,E)=""
+36 IF $PIECE(^BMCREF(S,6,B,0),U,4)'="CP"
QUIT
+37 SET E=$PIECE($PIECE(^BMCREF(S,6,B,0),U,6),".")
+38 SET M=$$CD(E,D,APCMEDAT)
+39 ;dates aren't good
IF 'M
SET E=$PIECE($PIECE(^BMCREF(S,6,B,0),U,1),".")
SET M=$$CD(E,D,APCMEDAT)
IF 'M
QUIT
+40 SET G=1
SET A=0
SET T="CP"
+41 QUIT
End DoDot:3
+42 IF G
DO SN
QUIT
+43 ;
SUMAPCC ;CHECK APCC DOCUMENT FILE
+1 SET J=0
FOR
SET J=$ORDER(^APCCDPL(V,1,J))
IF J'=+J!(G)
QUIT
Begin DoDot:3
+2 ;TOC ONLY
IF $PIECE($GET(^APCCDPL(V,1,J,0)),U,4)'=2
QUIT
+3 ;DATE MUST EQUAL VISIT DATE
IF $PIECE($PIECE(^APCCDPL(V,1,J,0),U,1),".")'=$$VD^APCLV(V)
QUIT
+4 SET G=1
+5 SET $PIECE(MMR(R),U,2)=$PIECE(MMR(R),U,2)+1
Begin DoDot:4
+6 SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,2)=$PIECE($GET(^TMP($JOB,"TRANS",R,PAT)),U,2)+1
+7 SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)=$PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)_";YES APCC TOCS"
End DoDot:4
End DoDot:3
+8 IF 'G
SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)=$PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)_";NO TOCS"
QUIT
End DoDot:2
End DoDot:1
+9 QUIT
SN ;
+1 SET $PIECE(MMR(R),U,2)=$PIECE(MMR(R),U,2)+1
Begin DoDot:1
+2 SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,2)=$PIECE($GET(^TMP($JOB,"TRANS",R,PAT)),U,2)+1
+3 SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)=$PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)_";YES "_T
IF T="CT"
SET $PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)=$PIECE(^TMP($JOB,"TRANS",R,PAT),U,3)_$SELECT(A:" TX",1:"")
+4 IF T="CT"
SET $PIECE(MMR(R),U,4)=$PIECE(MMR(R),U,4)+1
IF A
SET $PIECE(MMR(R),U,5)=$PIECE(MMR(R),U,5)+1
End DoDot:1
QUIT
+5 QUIT
CD(E,D,APCMEDAT) ;
+1 ;NO DATE TRANSMITTED
IF E=""
QUIT 0
+2 ;BEFORE APPROVAL DATE
IF E<D
QUIT 0
+3 ;AFTER TIME PERIOD
IF E>APCMEDAT
QUIT 0
+4 QUIT 1