APCM25E1 ; IHS/CMI/LAB - IHS MU 24 Feb 2015 10:32 AM ; 28 Jul 2016 11:39 AM
;;1.0;MU PERFORMANCE REPORTS;**7,8**;MAR 26, 2012;Build 22
;
BQI(BQIGREF,APCMPRV) ;PEP-Call from iCare
; input
; BQIGREF - Global reference
; APCMPRV - Array of providers
;
PROC ;EP
S APCMBT=$H
;D JRNL^APCM1UTL
S APCMJ=$J,APCMH=$H
S APCMSEME=0 ;FOR SEM ERROR -1 FROM PHR
S APCMVDTE=0 ;FOR VDT ERROR -1 FROM PHR CALL
D XTMP^APCM1UTL("APCM1D","MU Patient List")
;process each patient
;first gather up provider exclusions
I APCMRPTT=2 D G PROC1 ;hospital report doesn't need this stuff for exclusions
.K APCMOFFV
.K APCM25ON
.K APCMIMME
.K APCMN565
.K APCMHO65
.K APCMNOEC
.S X=APCMFAC S APCMX=$$VSTH(APCMFAC,APCMBD,APCMED,APCMMETH) D
..I '$P(APCMX,U,3) S APCM25ON(X,1)=""
..I '$P(APCMX,U,1) S APCMOFFV(X,1)=""
..I '$P(APCMX,U,5) S APCMIMME(X,1)=""
..I '$P(APCMX,U,6) S APCMN565(X,1)=""
..I '$P(APCMX,U,7) S APCMHO65(X,1)=""
..I '$P(APCMX,U,9) S APCMNOEC(X,1)=""
.;
K APCM100R
S X=0 F S X=$O(APCMPRV(X)) Q:X'=+X I '$$H100(X,APCMBD,APCMED) S APCM100R(X,1)=""
K APCM25ON
K APCMIMME
K APCMOFFV
S X=0 F S X=$O(APCMPRV(X)) Q:X'=+X S APCMX=$$VST(X,APCMBD,APCMED) D
.I '$P(APCMX,U,3) S APCM25ON(X,1)="" ;smk status excl
.I '$P(APCMX,U,1) S APCMOFFV(X,1)="" ;
.I '$P(APCMX,U,5) S APCMIMME(X,1)="" ;imm reg excl
N1 ;
;NOW GO THROUGH ALL PROVIDER'S VISIT IN 24 MONTHS BEFORE EHR REPORTING PERIOD, SEE IF ANY VISITS
K APCM25BR
S X=0 F S X=$O(APCMPRV(X)) Q:X'=+X D
.S APCMX=$$VST24(X,$$FMADD^XLFDT(APCMBD,-(24*30.5)),$$FMADD^XLFDT(APCMBD,-1))
.I 'APCMX S APCM25BR(X)="" ;EXCL FROM PAT REMINDERS
;
PROC1 ;
S DFN=0 F S DFN=$O(^AUPNPAT(DFN)) Q:DFN'=+DFN D
.Q:'$D(^DPT(DFN,0))
.;I DUZ=2793 Q:'$D(^DIBT(4723,1,DFN))
.;I DUZ=2793 Q:DFN'=2972
.Q:$$DEMO^APCLUTL(DFN,$G(APCMDEMO))
.D PROCCY
N ;
;NOW DO ATTESTATION MEASURES
D PROCACY
S APCMET=$H
Q
;
PROCCY ;EP - current time period
K ^TMP($J)
Q:'$D(^DPT(DFN,0))
Q:$P(^DPT(DFN,0),U,2)=""
S APCMEDAT=APCMED,APCMTIME=1,APCMBDAT=APCMBD,APCMGBL="^APCMM25C(",APCMFILN=9001304.0311
S APCMAGEB=$$AGE^AUPNPAT(DFN,APCMBDAT)
S APCMAGEE=$$AGE^AUPNPAT(DFN,APCMEDAT)
S APCMSEX=$P(^DPT(DFN,0),U,2)
;had visit to each provider?
D CALCIND
K ^TMP($J,"A")
Q
CALCIND ;
D CALCIND^APCM25CI
Q
PROCACY ;EP - current time period
S APCMEDAT=APCMED,APCMTIME=1,APCMBDAT=APCMBD,APCMGBL="^APCMM25C(",APCMFILN=9001304.0311
D CALCINDA^APCM25CI
Q
S(RPT,IND,VALUE,PROV,RT,T,F,NT) ;EP - set counter
NEW N,P,Y,J,I,ID
I VALUE="" Q ;no value to add
I RT=1 S I=PROV_";VA(200,"
I RT=2 S I=PROV_";AUTTLOC("
I T=1 D Q
.I $G(BQIGREF)'="" D Q
..NEW ID
..S ID=$P(^APCM25OB(IND,0),U,1)
..I $P(^APCM25OB(IND,0),U,8)=F S $P(@BQIGREF@(PROV,ID,"CURR"),U,1)=$P($G(@BQIGREF@(PROV,ID,"CURR")),U,1)+VALUE
..I $P(^APCM25OB(IND,0),U,9)=F S $P(@BQIGREF@(PROV,ID,"CURR"),U,2)=$P($G(@BQIGREF@(PROV,ID,"CURR")),U,2)+VALUE
..I $P(^APCM25OB(IND,0),U,11)=F S $P(@BQIGREF@(PROV,ID,"CURR"),U,3)=VALUE
..S $P(@BQIGREF@(PROV,ID,"CURR"),U,4)=$G(APCMVALU)
.S Y=$P(^DD(9001304.0311,F,0),U,4)
.S N=$P(Y,";")
.S P=$P(Y,";",2)
.S J=$O(^APCMM25C(RPT,11,"B",I,0))
.I 'J W APCMBOMB Q
.I VALUE?.N S $P(^APCMM25C(RPT,11,J,N),U,P)=$P($G(^APCMM25C(RPT,11,J,N)),U,P)+VALUE
.I VALUE'?.N S $P(^APCMM25C(RPT,11,J,N),U,P)=VALUE
.Q
Q
SETLIST ;EP
NEW P,APCMX,APCMO
Q:APCMTIME'=1
Q:'$D(APCMINDL(APCMIC)) ;not a selected topic
S APCMX=0 F S APCMX=$O(APCMINDL(APCMIC,APCMX)) Q:APCMX'=+APCMX D
.X ^APCMM25L(APCMX,12) Q:'$T
.S APCMINDL(APCMIC,APCMX,APCMP)=$G(APCMINDL(APCMIC,APCMX,APCMP))+1
.S APCMO=$S(APCMRPTT=2:$P(^APCMM25L(APCMX,0),U,6),1:$P(^APCMM25L(APCMX,0),U,5))
.S P=$S(APCMRPTT=2:$P(^DIC(4,APCMP,0),U),1:$P(^VA(200,APCMP,0),U))
.S ^XTMP("APCM1D",APCMJ,APCMH,"LIST",$P(^APCM25OB(APCMIC,0),U,4),APCMIC,APCMO,APCMX,P,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),$$AGE^AUPNPAT(DFN,APCMBDAT),DFN)=$G(APCMVALU)
Q
H100(R,BD,ED) ;
NEW ID,C,Y,X,VMED,V
S C=0
S ID=$$FMADD^XLFDT(BD,-1)
F S ID=$O(^PSRX("AC",ID)) Q:ID'=+ID!(C>100)!(ID>ED) D
.S X=0 F S X=$O(^PSRX("AC",ID,X)) Q:X'=+X!(C>100) D
..Q:$P($G(^PSRX(X,0)),U,4)'=R
..Q:$P($G(^PSRX(X,"STA")),"^")=13
..;SKIP ER CLINIC OR H VISIT, GET VISIT FROM V MED
..S VMED=$P($G(^PSRX(X,999999911)),U,1)
..Q:'VMED
..S V=$P($G(^AUPNVMED(VMED,0)),U,3)
..Q:'V
..Q:'$D(^AUPNVSIT(V,0))
..Q:$P(^AUPNVSIT(V,0),U,7)="H"
..Q:$$CLINIC^APCLV(V,"C")=30
..S C=C+1
Q $S(C>100:1,1:"")
VST(R,BD,ED) ;did this provider see anyone over 2
NEW SD,A,B,C,G,V,T
S SD=$$FMADD^XLFDT(BD,-1)
S SD=SD_".9999"
S G=""
F S SD=$O(^AUPNVSIT("B",SD)) Q:SD'=+SD!($P(SD,".")>ED)!($$GOTALL(G)) D
.S V=0 F S V=$O(^AUPNVSIT("B",SD,V)) Q:V'=+V!($$GOTALL(G)) D
..S B=0,C=0 F S B=$O(^AUPNVPRV("AD",V,B)) Q:B'=+B D
...Q:'$D(^AUPNVPRV(B,0))
...Q:$P(^AUPNVPRV(B,0),U,1)'=R
...Q:$P(^AUPNVPRV(B,0),U,4)'="P"
...S C=1
..Q:'C ;not to this provider
..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 $P(G,U,1)=1 ;has an office visit ;clinic summary excl
..I $$AGE^AUPNPAT($P(^AUPNVSIT(V,0),U,5),$P(BD,"."))>12 S $P(G,U,3)=1
..I $D(^AUPNVIMM("AD",V)) S $P(G,U,5)=1 ;not an exclusion for imm reg
Q G
;
GOTALL(%) ;EP
NEW Y
S Y=$P(%,U,1)+$P(%,U,3)+$P(%,U,5)
I Y=3 Q 1
Q 0
VST24(R,BD,ED) ;did this provider see anyone over 2
NEW SD,A,B,C,G,V,T
S SD=$$FMADD^XLFDT(BD,-1)
S SD=SD_".9999"
S G=""
F S SD=$O(^AUPNVSIT("B",SD)) Q:SD'=+SD!($P(SD,".")>ED)!(G) D
.S V=0 F S V=$O(^AUPNVSIT("B",SD,V)) Q:V'=+V!(G) D
..S B=0,C=0 F S B=$O(^AUPNVPRV("AD",V,B)) Q:B'=+B!(C) D
...Q:'$D(^AUPNVPRV(B,0))
...Q:$P(^AUPNVPRV(B,0),U,1)'=R
...Q:$P(^AUPNVPRV(B,0),U,4)'="P"
...S C=1
..Q:'C ;not to this provider
..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 ;has an office visit ;clinic summary excl
Q G
VSTH(R,BD,ED,APCMMETH) ;did this HOSPITAL HAVE THESE VISITS
NEW SD,A,B,C,G,V,T,O,P,Q,E,J,S
S T=$O(^APCMMUCN("B","MODIFIED STAGE 2 2015",0))
S SD=$$FMADD^XLFDT(BD,-1)
S SD=SD_".9999"
S G=""
F S SD=$O(^AUPNVSIT("B",SD)) Q:SD'=+SD!($P(SD,".")>ED)!($$GOTALLH(G)) D
.S V=0 F S V=$O(^AUPNVSIT("B",SD,V)) Q:V'=+V!($$GOTALLH(G)) D
..Q:$P(^AUPNVSIT(V,0),U,6)'=R
..I APCMMETH="E" Q:'$$HOSER^APCM25E6(V,R)
..I APCMMETH="O" Q:"OH"'[$P(^AUPNVSIT(V,0),U,7)
..S $P(G,U,1)=1
..S A=$$AGE^AUPNPAT($P(^AUPNVSIT(V,0),U,5),$P(BD,".")) I A>2 S $P(G,U,2)=1
..I A>12 S $P(G,U,3)=1
..S $P(G,U,4)=1
..I $D(^AUPNVIMM("AD",V)) S $P(G,U,5)=1 ;not an exclusion for imm reg
..;check age
..I A<6!(A>64) S $P(G,U,6)=1
..I $P(^AUPNVSIT(V,0),U,7)="H" S A=$$AGE^AUPNPAT($P(^AUPNVSIT(V,0),U,5),$$VD^APCLV(V)) I A>64 S $P(G,U,7)=1
Q G
GOTALLH(%) ;EP
NEW Y
S Y=$P(%,U,1)+$P(%,U,2)+$P(%,U,3)+$P(%,U,4)+$P(%,U,5)+$P(%,U,6)+$P(%,U,7)+$P(%,U,8)+$P(%,U,9)
I Y=9 Q 1
Q 0
APCM25E1 ; IHS/CMI/LAB - IHS MU 24 Feb 2015 10:32 AM ; 28 Jul 2016 11:39 AM
+1 ;;1.0;MU PERFORMANCE REPORTS;**7,8**;MAR 26, 2012;Build 22
+2 ;
BQI(BQIGREF,APCMPRV) ;PEP-Call from iCare
+1 ; input
+2 ; BQIGREF - Global reference
+3 ; APCMPRV - Array of providers
+4 ;
PROC ;EP
+1 SET APCMBT=$HOROLOG
+2 ;D JRNL^APCM1UTL
+3 SET APCMJ=$JOB
SET APCMH=$HOROLOG
+4 ;FOR SEM ERROR -1 FROM PHR
SET APCMSEME=0
+5 ;FOR VDT ERROR -1 FROM PHR CALL
SET APCMVDTE=0
+6 DO XTMP^APCM1UTL("APCM1D","MU Patient List")
+7 ;process each patient
+8 ;first gather up provider exclusions
+9 ;hospital report doesn't need this stuff for exclusions
IF APCMRPTT=2
Begin DoDot:1
+10 KILL APCMOFFV
+11 KILL APCM25ON
+12 KILL APCMIMME
+13 KILL APCMN565
+14 KILL APCMHO65
+15 KILL APCMNOEC
+16 SET X=APCMFAC
SET APCMX=$$VSTH(APCMFAC,APCMBD,APCMED,APCMMETH)
Begin DoDot:2
+17 IF '$PIECE(APCMX,U,3)
SET APCM25ON(X,1)=""
+18 IF '$PIECE(APCMX,U,1)
SET APCMOFFV(X,1)=""
+19 IF '$PIECE(APCMX,U,5)
SET APCMIMME(X,1)=""
+20 IF '$PIECE(APCMX,U,6)
SET APCMN565(X,1)=""
+21 IF '$PIECE(APCMX,U,7)
SET APCMHO65(X,1)=""
+22 IF '$PIECE(APCMX,U,9)
SET APCMNOEC(X,1)=""
End DoDot:2
+23 ;
End DoDot:1
GOTO PROC1
+24 KILL APCM100R
+25 SET X=0
FOR
SET X=$ORDER(APCMPRV(X))
IF X'=+X
QUIT
IF '$$H100(X,APCMBD,APCMED)
SET APCM100R(X,1)=""
+26 KILL APCM25ON
+27 KILL APCMIMME
+28 KILL APCMOFFV
+29 SET X=0
FOR
SET X=$ORDER(APCMPRV(X))
IF X'=+X
QUIT
SET APCMX=$$VST(X,APCMBD,APCMED)
Begin DoDot:1
+30 ;smk status excl
IF '$PIECE(APCMX,U,3)
SET APCM25ON(X,1)=""
+31 ;
IF '$PIECE(APCMX,U,1)
SET APCMOFFV(X,1)=""
+32 ;imm reg excl
IF '$PIECE(APCMX,U,5)
SET APCMIMME(X,1)=""
End DoDot:1
N1 ;
+1 ;NOW GO THROUGH ALL PROVIDER'S VISIT IN 24 MONTHS BEFORE EHR REPORTING PERIOD, SEE IF ANY VISITS
+2 KILL APCM25BR
+3 SET X=0
FOR
SET X=$ORDER(APCMPRV(X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCMX=$$VST24(X,$$FMADD^XLFDT(APCMBD,-(24*30.5)),$$FMADD^XLFDT(APCMBD,-1))
+5 ;EXCL FROM PAT REMINDERS
IF 'APCMX
SET APCM25BR(X)=""
End DoDot:1
+6 ;
PROC1 ;
+1 SET DFN=0
FOR
SET DFN=$ORDER(^AUPNPAT(DFN))
IF DFN'=+DFN
QUIT
Begin DoDot:1
+2 IF '$DATA(^DPT(DFN,0))
QUIT
+3 ;I DUZ=2793 Q:'$D(^DIBT(4723,1,DFN))
+4 ;I DUZ=2793 Q:DFN'=2972
+5 IF $$DEMO^APCLUTL(DFN,$GET(APCMDEMO))
QUIT
+6 DO PROCCY
End DoDot:1
N ;
+1 ;NOW DO ATTESTATION MEASURES
+2 DO PROCACY
+3 SET APCMET=$HOROLOG
+4 QUIT
+5 ;
PROCCY ;EP - current time period
+1 KILL ^TMP($JOB)
+2 IF '$DATA(^DPT(DFN,0))
QUIT
+3 IF $PIECE(^DPT(DFN,0),U,2)=""
QUIT
+4 SET APCMEDAT=APCMED
SET APCMTIME=1
SET APCMBDAT=APCMBD
SET APCMGBL="^APCMM25C("
SET APCMFILN=9001304.0311
+5 SET APCMAGEB=$$AGE^AUPNPAT(DFN,APCMBDAT)
+6 SET APCMAGEE=$$AGE^AUPNPAT(DFN,APCMEDAT)
+7 SET APCMSEX=$PIECE(^DPT(DFN,0),U,2)
+8 ;had visit to each provider?
+9 DO CALCIND
+10 KILL ^TMP($JOB,"A")
+11 QUIT
CALCIND ;
+1 DO CALCIND^APCM25CI
+2 QUIT
PROCACY ;EP - current time period
+1 SET APCMEDAT=APCMED
SET APCMTIME=1
SET APCMBDAT=APCMBD
SET APCMGBL="^APCMM25C("
SET APCMFILN=9001304.0311
+2 DO CALCINDA^APCM25CI
+3 QUIT
S(RPT,IND,VALUE,PROV,RT,T,F,NT) ;EP - set counter
+1 NEW N,P,Y,J,I,ID
+2 ;no value to add
IF VALUE=""
QUIT
+3 IF RT=1
SET I=PROV_";VA(200,"
+4 IF RT=2
SET I=PROV_";AUTTLOC("
+5 IF T=1
Begin DoDot:1
+6 IF $GET(BQIGREF)'=""
Begin DoDot:2
+7 NEW ID
+8 SET ID=$PIECE(^APCM25OB(IND,0),U,1)
+9 IF $PIECE(^APCM25OB(IND,0),U,8)=F
SET $PIECE(@BQIGREF@(PROV,ID,"CURR"),U,1)=$PIECE($GET(@BQIGREF@(PROV,ID,"CURR")),U,1)+VALUE
+10 IF $PIECE(^APCM25OB(IND,0),U,9)=F
SET $PIECE(@BQIGREF@(PROV,ID,"CURR"),U,2)=$PIECE($GET(@BQIGREF@(PROV,ID,"CURR")),U,2)+VALUE
+11 IF $PIECE(^APCM25OB(IND,0),U,11)=F
SET $PIECE(@BQIGREF@(PROV,ID,"CURR"),U,3)=VALUE
+12 SET $PIECE(@BQIGREF@(PROV,ID,"CURR"),U,4)=$GET(APCMVALU)
End DoDot:2
QUIT
+13 SET Y=$PIECE(^DD(9001304.0311,F,0),U,4)
+14 SET N=$PIECE(Y,";")
+15 SET P=$PIECE(Y,";",2)
+16 SET J=$ORDER(^APCMM25C(RPT,11,"B",I,0))
+17 IF 'J
WRITE APCMBOMB
QUIT
+18 IF VALUE?.N
SET $PIECE(^APCMM25C(RPT,11,J,N),U,P)=$PIECE($GET(^APCMM25C(RPT,11,J,N)),U,P)+VALUE
+19 IF VALUE'?.N
SET $PIECE(^APCMM25C(RPT,11,J,N),U,P)=VALUE
+20 QUIT
End DoDot:1
QUIT
+21 QUIT
SETLIST ;EP
+1 NEW P,APCMX,APCMO
+2 IF APCMTIME'=1
QUIT
+3 ;not a selected topic
IF '$DATA(APCMINDL(APCMIC))
QUIT
+4 SET APCMX=0
FOR
SET APCMX=$ORDER(APCMINDL(APCMIC,APCMX))
IF APCMX'=+APCMX
QUIT
Begin DoDot:1
+5 XECUTE ^APCMM25L(APCMX,12)
IF '$TEST
QUIT
+6 SET APCMINDL(APCMIC,APCMX,APCMP)=$GET(APCMINDL(APCMIC,APCMX,APCMP))+1
+7 SET APCMO=$SELECT(APCMRPTT=2:$PIECE(^APCMM25L(APCMX,0),U,6),1:$PIECE(^APCMM25L(APCMX,0),U,5))
+8 SET P=$SELECT(APCMRPTT=2:$PIECE(^DIC(4,APCMP,0),U),1:$PIECE(^VA(200,APCMP,0),U))
+9 SET ^XTMP("APCM1D",APCMJ,APCMH,"LIST",$PIECE(^APCM25OB(APCMIC,0),U,4),APCMIC,APCMO,APCMX,P,$SELECT($PIECE($GET(^AUPNPAT(DFN,11)),U,18)]"":$PIECE(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$PIECE(^DPT(DFN,0),U,2),$$AGE^AUPNPAT(DFN,APCMBDAT),DFN)
=...
... $GET(APCMVALU)
End DoDot:1
+10 QUIT
H100(R,BD,ED) ;
+1 NEW ID,C,Y,X,VMED,V
+2 SET C=0
+3 SET ID=$$FMADD^XLFDT(BD,-1)
+4 FOR
SET ID=$ORDER(^PSRX("AC",ID))
IF ID'=+ID!(C>100)!(ID>ED)
QUIT
Begin DoDot:1
+5 SET X=0
FOR
SET X=$ORDER(^PSRX("AC",ID,X))
IF X'=+X!(C>100)
QUIT
Begin DoDot:2
+6 IF $PIECE($GET(^PSRX(X,0)),U,4)'=R
QUIT
+7 IF $PIECE($GET(^PSRX(X,"STA")),"^")=13
QUIT
+8 ;SKIP ER CLINIC OR H VISIT, GET VISIT FROM V MED
+9 SET VMED=$PIECE($GET(^PSRX(X,999999911)),U,1)
+10 IF 'VMED
QUIT
+11 SET V=$PIECE($GET(^AUPNVMED(VMED,0)),U,3)
+12 IF 'V
QUIT
+13 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+14 IF $PIECE(^AUPNVSIT(V,0),U,7)="H"
QUIT
+15 IF $$CLINIC^APCLV(V,"C")=30
QUIT
+16 SET C=C+1
End DoDot:2
End DoDot:1
+17 QUIT $SELECT(C>100:1,1:"")
VST(R,BD,ED) ;did this provider see anyone over 2
+1 NEW SD,A,B,C,G,V,T
+2 SET SD=$$FMADD^XLFDT(BD,-1)
+3 SET SD=SD_".9999"
+4 SET G=""
+5 FOR
SET SD=$ORDER(^AUPNVSIT("B",SD))
IF SD'=+SD!($PIECE(SD,".")>ED)!($$GOTALL(G))
QUIT
Begin DoDot:1
+6 SET V=0
FOR
SET V=$ORDER(^AUPNVSIT("B",SD,V))
IF V'=+V!($$GOTALL(G))
QUIT
Begin DoDot:2
+7 SET B=0
SET C=0
FOR
SET B=$ORDER(^AUPNVPRV("AD",V,B))
IF B'=+B
QUIT
Begin DoDot:3
+8 IF '$DATA(^AUPNVPRV(B,0))
QUIT
+9 IF $PIECE(^AUPNVPRV(B,0),U,1)'=R
QUIT
+10 IF $PIECE(^AUPNVPRV(B,0),U,4)'="P"
QUIT
+11 SET C=1
End DoDot:3
+12 ;not to this provider
IF 'C
QUIT
+13 SET C=$$CLINIC^APCLV(V,"C")
+14 ;no ER per Carmen patch 1
IF C=30
QUIT
+15 ;no case management clinic 77 per Chris
IF C=77
QUIT
+16 ;no lab
IF C=76
QUIT
+17 ;no radiology
IF C=63
QUIT
+18 ;no pharmacy
IF C=39
QUIT
+19 ;has an office visit ;clinic summary excl
SET $PIECE(G,U,1)=1
+20 IF $$AGE^AUPNPAT($PIECE(^AUPNVSIT(V,0),U,5),$PIECE(BD,"."))>12
SET $PIECE(G,U,3)=1
+21 ;not an exclusion for imm reg
IF $DATA(^AUPNVIMM("AD",V))
SET $PIECE(G,U,5)=1
End DoDot:2
End DoDot:1
+22 QUIT G
+23 ;
GOTALL(%) ;EP
+1 NEW Y
+2 SET Y=$PIECE(%,U,1)+$PIECE(%,U,3)+$PIECE(%,U,5)
+3 IF Y=3
QUIT 1
+4 QUIT 0
VST24(R,BD,ED) ;did this provider see anyone over 2
+1 NEW SD,A,B,C,G,V,T
+2 SET SD=$$FMADD^XLFDT(BD,-1)
+3 SET SD=SD_".9999"
+4 SET G=""
+5 FOR
SET SD=$ORDER(^AUPNVSIT("B",SD))
IF SD'=+SD!($PIECE(SD,".")>ED)!(G)
QUIT
Begin DoDot:1
+6 SET V=0
FOR
SET V=$ORDER(^AUPNVSIT("B",SD,V))
IF V'=+V!(G)
QUIT
Begin DoDot:2
+7 SET B=0
SET C=0
FOR
SET B=$ORDER(^AUPNVPRV("AD",V,B))
IF B'=+B!(C)
QUIT
Begin DoDot:3
+8 IF '$DATA(^AUPNVPRV(B,0))
QUIT
+9 IF $PIECE(^AUPNVPRV(B,0),U,1)'=R
QUIT
+10 IF $PIECE(^AUPNVPRV(B,0),U,4)'="P"
QUIT
+11 SET C=1
End DoDot:3
+12 ;not to this provider
IF 'C
QUIT
+13 SET C=$$CLINIC^APCLV(V,"C")
+14 ;no ER per Carmen patch 1
IF C=30
QUIT
+15 ;no case management clinic 77 per Chris
IF C=77
QUIT
+16 ;no lab
IF C=76
QUIT
+17 ;no radiology
IF C=63
QUIT
+18 ;no pharmacy
IF C=39
QUIT
+19 ;has an office visit ;clinic summary excl
SET G=1
End DoDot:2
End DoDot:1
+20 QUIT G
VSTH(R,BD,ED,APCMMETH) ;did this HOSPITAL HAVE THESE VISITS
+1 NEW SD,A,B,C,G,V,T,O,P,Q,E,J,S
+2 SET T=$ORDER(^APCMMUCN("B","MODIFIED STAGE 2 2015",0))
+3 SET SD=$$FMADD^XLFDT(BD,-1)
+4 SET SD=SD_".9999"
+5 SET G=""
+6 FOR
SET SD=$ORDER(^AUPNVSIT("B",SD))
IF SD'=+SD!($PIECE(SD,".")>ED)!($$GOTALLH(G))
QUIT
Begin DoDot:1
+7 SET V=0
FOR
SET V=$ORDER(^AUPNVSIT("B",SD,V))
IF V'=+V!($$GOTALLH(G))
QUIT
Begin DoDot:2
+8 IF $PIECE(^AUPNVSIT(V,0),U,6)'=R
QUIT
+9 IF APCMMETH="E"
IF '$$HOSER^APCM25E6(V,R)
QUIT
+10 IF APCMMETH="O"
IF "OH"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+11 SET $PIECE(G,U,1)=1
+12 SET A=$$AGE^AUPNPAT($PIECE(^AUPNVSIT(V,0),U,5),$PIECE(BD,"."))
IF A>2
SET $PIECE(G,U,2)=1
+13 IF A>12
SET $PIECE(G,U,3)=1
+14 SET $PIECE(G,U,4)=1
+15 ;not an exclusion for imm reg
IF $DATA(^AUPNVIMM("AD",V))
SET $PIECE(G,U,5)=1
+16 ;check age
+17 IF A<6!(A>64)
SET $PIECE(G,U,6)=1
+18 IF $PIECE(^AUPNVSIT(V,0),U,7)="H"
SET A=$$AGE^AUPNPAT($PIECE(^AUPNVSIT(V,0),U,5),$$VD^APCLV(V))
IF A>64
SET $PIECE(G,U,7)=1
End DoDot:2
End DoDot:1
+19 QUIT G
GOTALLH(%) ;EP
+1 NEW Y
+2 SET Y=$PIECE(%,U,1)+$PIECE(%,U,2)+$PIECE(%,U,3)+$PIECE(%,U,4)+$PIECE(%,U,5)+$PIECE(%,U,6)+$PIECE(%,U,7)+$PIECE(%,U,8)+$PIECE(%,U,9)
+3 IF Y=9
QUIT 1
+4 QUIT 0