BDMDE17 ; IHS/CMI/LAB - 2017 DIABETES AUDIT 03 Nov 2015 9:29 AM ;
;;2.0;DIABETES MANAGEMENT SYSTEM;**10**;JUN 14, 2007;Build 12
DIETEDUC(P,BDATE,EDATE) ;EP
NEW D,BD,ED,X,Y,%DT,D,G,BDMVRD,V,BDM,RD,NRD,BDMV
S (RD,NRD,BDMV)=""
S X=BDATE,%DT="P" D ^%DT S BD=Y
S X=EDATE,%DT="P" D ^%DT S ED=Y
S D=9999999-ED,(RD,NRD)=""
F S D=$O(^AUPNVSIT("AA",P,D)) Q:D=""!(D>(9999999-BD)) D
.S V=0 F S V=$O(^AUPNVSIT("AA",P,D,V)) Q:V'=+V D
..Q:'$D(^AUPNVSIT(V,0))
..Q:$P(^AUPNVSIT(V,0),U,11)
..Q:'$P(^AUPNVSIT(V,0),U,9)
..Q:$$DNKA(V)
..Q:$P(^AUPNVSIT(V,0),U,7)="C"
..Q:$$CLINIC^APCLV(V,"C")=52
..I $$PRIMPROV^APCLV(V,"D")=29 S BDMVRD(V)="",BDMV=BDMV_" RD: "_$P(^DIC(7,$O(^DIC(7,"D",29,0)),0),U)_" Visit: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " Q
..I $$PRIMPROV^APCLV(V,"D")="07" S BDMVRD(V)="",BDMV=BDMV_" RD: "_$P(^DIC(7,$O(^DIC(7,"D","07",0)),0),U)_" Visit: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " Q
..I $$PRIMPROV^APCLV(V,"D")="34" S BDMVRD(V)="",BDMV=BDMV_" RD: "_$P(^DIC(7,$O(^DIC(7,"D",34,0)),0),U)_" Visit: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " Q
..;now check povs for V65.3 and label as non-rd
..;change this to check to see if in BGP DIETARY SURVEILLANCE DXS TAXONOMY calls are $$ICD^ATXCH(code)
..;S X=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X I $$VAL^XBDIQ1(9000010.07,X,.01)="V65.3" S NRD=1,BDMV=BDMV_"NRD: V65.3 Dx: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
..N TAX
..S TAX=$O(^ATXAX("B","BGP DIETARY SURVEILLANCE DXS",0))
..;S X=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X I $$ICD^ATXCHK($$VALI^XBDIQ1(9000010.07,X,.01),TAX,9) S NRD=1,BDMV=BDMV_"NRD: "_$$VAL^XBDIQ1(9000010.07,X,.01)_" Dx: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " ;p8 ICD-10
..S X=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X I $$ICD^BDMUTL($$VALI^XBDIQ1(9000010.07,X,.01),$P(^ATXAX(TAX,0),U),9) S NRD=1,BDMV=BDMV_"NRD: "_$$VAL^XBDIQ1(9000010.07,X,.01)_" Dx: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " ;p8 ICD-10
..S X=0 F S X=$O(^AUPNVCPT("AD",V,X)) Q:X'=+X S Z=$$VAL^XBDIQ1(9000010.18,X,.01) I Z=97802!(Z=97803)!(Z=97804) S RD=1,BDMV=BDMV_"RD: CPT "_Z_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
..;now check for education topics
..S T=$O(^ATXAX("B","DM AUDIT DIET EDUC TOPICS",0))
..S X=0 F S X=$O(^AUPNVPED("AD",V,X)) Q:X'=+X S Y=$P($G(^AUPNVPED(X,0)),U) D
...Q:'Y
...Q:'$D(^AUTTEDT(Y,0))
...I T,$D(^ATXAX(T,21,"B",Y)) S Z=$$PC(X) D Q
....I Z="07"!(Z=29)!(Z=34) S RD=1,BDMV=BDMV_"RD: "_$P(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " Q
....S NRD=1,BDMV=BDMV_"NRD: "_$P(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
...S J=$P(^AUTTEDT(Y,0),U,2) I $P(J,"-",2)="N"!($P(J,"-",2)="DT")!($P(J,"-")="MNT")!($P(J,"-",2)="MNT")!($P(J,"-")="DMCN") S Z=$$PC(X) D Q
....I Z="07"!(Z=29)!(Z=34) S RD=1,BDMV=BDMV_"RD: "_$P(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " Q
....S NRD=1,BDMV=BDMV_"NRD: "_$P(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
..Q
.Q
I $D(BDMVRD) S RD=1 ;a RD visit so a hit
S G=0
I RD!(NRD) Q $S(RD+NRD=2:"3 Yes (RD & Non RD - Other) "_U_BDMV,RD:"1 Yes (RD) "_BDMV,1:"2 Yes (Non RD) "_BDMV)
Q "4 None" ;_$S(G:" - Not Medically Indicated",1:"")
PC(V) ;return provider discipline of educ provider
I 'V Q ""
NEW X S X=$P(^AUPNVPED(V,0),U,5)
I 'X Q ""
I $P(^DD(9000010.16,.05,0),U,2)[200 Q $$PROVCLSC^XBFUNC1(X)
NEW A S A=$P(^DIC(6,X,0),U,4)
I 'A Q ""
Q $P($G(^DIC(7,A,9999999)),U)
EXEDUC(P,BDATE,EDATE) ;EP
NEW BDM,X,E,%,G
S X=P_"^LAST EDUC [DM AUDIT EXERCISE EDUC TOPICS;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BDM(")
I $D(BDM(1)) Q "1 Yes "_$P(BDM(1),U,3)_" "_$$DATE^BDMS9B1($P(BDM(1),U,1))
K BDM
S X=P_"^ALL EDUC;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BDM(")
S X=0,G=0 F S X=$O(BDM(X)) Q:X'=+X!(G) S I=+$P(BDM(X),U,4),E=$P($G(^AUPNVPED(I,0)),U),T=$P($G(^AUTTEDT(E,0)),U,2) I $P(T,"-",2)="EX" S G=1
I G Q "1 Yes "_T_" "_$$VD^APCLV($P(^AUPNVPED(I,0),U,3),"E")
K BDM
S X=P_"^LAST DX [BGP EXERCISE COUNSELING DXS;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BDM(") ;p8 ICD-10
I $D(BDM(1)) Q "1 Yes POV: "_$P(BDM(1),U,3)_" "_$$DATE^BDMS9B1($P(BDM(1),U))
Q "2 No"
OTHEDUC(P,BDATE,EDATE) ;EP
NEW BDM,X,E,%,T,TX
S TX=$O(^ATXAX("B","DM AUDIT OTHER EDUC TOPICS",0))
K BDM
S X=P_"^ALL EDUC;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BDM(")
S X=0,G=0 F S X=$O(BDM(X)) Q:X'=+X!(G) D
.S I=+$P(BDM(X),U,4)
.S J=$P($G(^AUPNVPED(I,0)),U)
.Q:'J
.S T=$P($G(^AUTTEDT(J,0)),U,2)
.I $P(T,"-",2)="EX" Q
.I $P(T,"-",2)="N" Q
.I $P(T,"-",2)="MNT" Q
.I $P(T,"-",1)="MNT" Q
.I $P(T,"-",2)="DT" Q
.I $P(T,"-",1)="DMCN" Q
.I TX,$D(^ATXAX(TX,21,"AA",J)) S G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($P(^AUPNVPED(I,0),U,3),"I"))
.I $P(T,"-",1)="DM"!($P(T,"-",1)="DMC") S G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($P(^AUPNVPED(I,0),U,3),"I")) Q
.N CODE
.S CODE=$P($$CODEN^BDMUTL($P(T,"-",1),80),"~")
.I CODE>0 D Q
..N TAX
..S TAX=$O(^ATXAX("B","SURVEILLANCE DIABETES",0))
..I $$ICD^BDMUTL(CODE,$P(^ATXAX(TAX,0),U),9) S G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($P(^AUPNVPED(I,0),U,3),"I"))
.I $P(T,"-",1)]"",$$SNOMED^BDMUTL(2017,"DIABETES DIAGNOSES",$P(T,"-",1)) S G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($P(^AUPNVPED(I,0),U,3),"I"))
I G Q G
Q "2 No" ;_$S(G:" - Not Medically Indicated",1:"")
;
DFE(P,BDATE,EDATE,F,R) ;EP - FOOT EXAM
I $G(BDATE)="" S BDATE=$$DOB^AUPNPAT(P)
I $G(EDATE)="" S EDATE=DT
I $G(F)="" S F="E"
NEW BDMY,BDMV,%,LASTI,A,D,V,G,PROV,E,T,PROVI,G
S LASTI=""
S BDMY(1)=$$LASTDFE^APCLAPI2(P,BDATE,EDATE,"D")
I BDMY(1) S LASTI=$P(BDMY(1),U)_U_"1 Yes "_$$DATE^BDMS9B1($P(BDMY(1),U))_" Diabetic Foot Exam"
S G=$$LASTCPTT^BDMAPIU(P,BDATE,EDATE,"DM AUDIT CPT FOOT EXAM","E")
I G,$P(BDMY(1),U)<$P(G,U,1) S LASTI=$P(G,U,1)_U_"1 Yes "_$$DATE^BDMS9B1($P(G,U,1))_" "_$P(G,U,2)
I LASTI]"",F="H" Q $P(LASTI,U,2) ;in supplement
I F="E",LASTI]"" Q $P(LASTI,U,2) ; if in audit and has exam display it
;now check any clinic 65 or prov 33/25
;
K T
S T="T"
D ALLV^BDMAPIU(P,BDATE,EDATE,.T)
;reorder by date of visit/reverse order
S %=0 F S %=$O(T(%)) Q:%'=+% S BDMY((9999999-$P(T(%),U)),$P(T(%),U,5))=T(%)
N PROV,D,V,G
S (D,V)=0,G=""
F S D=$O(BDMY(D)) Q:D'=+D!(G) S V=0 F S V=$O(BDMY(D,V)) Q:V'=+V!(G) D
.Q:$$DNKA(V)
.Q:$P(^AUPNVSIT(V,0),U,7)="C"
.Q:$$CLINIC^APCLV(V,"C")=52
.S PROV=$$PRIMPROV^APCLV(V,"D"),PROVI=$$PRIMPROV^APCLV(V,"F") I (PROV=33!(PROV=25)!(PROV=84)) S G=9999999-D
I G]"" D
.Q:$P(LASTI,U)>G
.S LASTI=G_U_"1 "_$S(F="H":"Maybe ",1:"Yes ")_$$DATE^BDMS9B1($P(G,U))_" "_$P(^DIC(7,PROVI,0),U,1)_" visit"
S (D,V)=0,G=""
F S D=$O(BDMY(D)) Q:D'=+D!(G) S V=0 F S V=$O(BDMY(D,V)) Q:V'=+V!(G) D
.Q:$$DNKA(V)
.Q:$P(^AUPNVSIT(V,0),U,7)="C"
.Q:$$CLINIC^APCLV(V,"C")=52
.S PROV=$$CLINIC^APCLV(V,"C"),PROVI=$$CLINIC^APCLV(V,"I") I PROV=65!(PROV="B7") S G=9999999-D
I G]"" D
.Q:$P(LASTI,U)>G
.S LASTI=G_U_"1 "_$S(F="H":"Maybe ",1:"Yes ")_$$DATE^BDMS9B1($P(G,U))_" "_$P(^DIC(40.7,PROVI,0),U,1)_" clinic visit"
;
I $G(R) K T Q $S(F="D":$P(LASTI,U),1:$P(LASTI,U,2)) ;no refusals
;
I LASTI]"" K T Q $S(F="D":$P(LASTI,U),1:$P(LASTI,U,2))
;
NEW G S G=$$REFUSAL(P,9999999.15,$O(^AUTTEXAM("B","DIABETIC FOOT EXAM, COMPLETE",0)),BDATE,EDATE,"N")
Q "2 No"_$S(G:" - Not Medically Indicated",1:"")
;
ADA(V) ;any ada other than 9991
I '$G(V) Q ""
NEW X,Y,Z,G
S G="",X=0 F S X=$O(^AUPNVDEN("AD",V,X)) Q:X'=+X!(G) S Y=$P($G(^AUPNVDEN(X,0)),U) I Y,$D(^AUTTADA(Y,0)),$P(^AUTTADA(Y,0),U)'=9991 S G=1
Q G
DNKA(V) ;EP - is this a DNKA visit?
I '$G(V) Q ""
NEW D,N S D=$$PRIMPOV^APCLV(V,"C")
I D=".0860" Q 1
S N=$$PRIMPOV^APCLV(V,"N")
I $E(D)="V",N["DNKA" Q 1
I $E(D)="V",N["DID NOT KEEP APPOINTMENT" Q 1
I $E(D)="V",N["DID NOT KEEP APPT" Q 1
Q 0
REFR(V) ;
I '$G(V) Q ""
NEW D,N S D=$$PRIMPOV^APCLV(V,"I")
I D="" Q 0
;change this to look at the DM AUDIT REFRACTION taxonomy
N TAX
S TAX=$O(^ATXAX("B","DM AUDIT REFRACTION DXS",0))
;I $$ICD^ATXCHK(D,TAX,9) Q 1
I $$ICD^BDMUTL(D,$P(^ATXAX(TAX,0),U),9) Q 1 ;cmi/maw 05/15/2014 p8
;I D="367.89"!(D="367.9")!($E(D,1,5)=372.0)!($E(D,1,5)=372.1) Q 1
Q 0
;
REFUSAL(P,F,I,B,E,T) ;EP
I '$G(P) Q ""
I '$G(F) Q ""
I '$G(I) Q ""
I $G(B)="" Q ""
I $G(E)="" Q ""
NEW G,X,Y,%DT,R S X=B,%DT="P" D ^%DT S B=Y
S X=E,%DT="P" D ^%DT S E=Y
S (X,G)=0 F S X=$O(^AUPNPREF("AA",P,F,I,X)) Q:X'=+X!(G) S Y=0 F S Y=$O(^AUPNPREF("AA",P,F,I,X,Y)) Q:Y'=+Y S D=$P(^AUPNPREF(Y,0),U,3) I D'<B&(D'>E) D
.I $G(T)]"",T'=$P(^AUPNPREF(Y,0),U,7) Q
.S G=1_"^"_$P(^AUPNPREF(Y,0),U,7)_U_$$DATE^BDMS9B1($P(^AUPNPREF(Y,0),U,3))_U_$$VAL^XBDIQ1(9000022,Y,.04)_U_$$VAL^XBDIQ1(9000022,Y,.07)_U_$$VAL^XBDIQ1(9000022,Y,.01)_U_$P(^AUPNPREF(Y,0),U,3)
Q G
;
EYE(P,BDATE,EDATE,F,R) ;EP
I $G(BDATE)="" S BDATE=$$DOB^AUPNPAT(P)
I $G(EDATE)="" S EDATE=DT
I $G(F)="" S F="E"
NEW BDMY,BDMV,%,LASTI,BD,ED,T,D,%,Y,X,G,V,PROV,T,PROVI
S LASTI=$$LASTITEM^APCLAPIU(P,"03","EXAM",BDATE,EDATE,"D")
I LASTI]"" S $P(LASTI,U,2)="1 Yes "_$$DATE^BDMS9B1($P(LASTI,U))_" Diabetic Eye Exam" ; I F="H"!(F="D") Q LASTI
I F="E",LASTI]"" Q $P(LASTI,U,2) ; if in audit and has exam display it
;
S X=$$LASTCPTT^BDMAPIU(P,BDATE,EDATE,"DM AUDIT EYE EXAM CPTS","E")
I $P(X,U)>$P(LASTI,U) S LASTI=$P(X,U)_U_"1 Yes "_$$DATE^BDMS9B1($P(X,U))_" "_$P(X,U,2) ;I F="H"!(F="D") Q LASTI
K BDMV,BDMY
I F="E",LASTI]"" Q $P(LASTI,U,2)
;
S X=$$LASTPRCT^BDMAPIU(P,BDATE,EDATE,"DM AUDIT EYE EXAM PROCS","A")
I $P(X,U)>$P(LASTI,U) S LASTI=$P(X,U)_U_"1 Yes "_$$DATE^BDMS9B1($P(X,U,1))_" "_$P(X,U,2)
I F="D" Q $P(LASTI,U)
I LASTI,F="H" Q $P(LASTI,U,2)
I LASTI,F="E" Q $P(LASTI,U,2)
S T="T"
D ALLV^BDMAPIU(P,BDATE,EDATE,.T)
;reorder by date of visit/reverse order
S %=0 F S %=$O(T(%)) Q:%'=+% S BDMY((9999999-$P(T(%),U)),$P(T(%),U,5))=T(%)
N PROV,D,V,G
S (D,V)=0,G=""
F S D=$O(BDMY(D)) Q:D'=+D!(G) S V=0 F S V=$O(BDMY(D,V)) Q:V'=+V!(G) D
.Q:$$DNKA(V)
.Q:$P(^AUPNVSIT(V,0),U,7)="C"
.Q:$$CLINIC^APCLV(V,"C")=52
.S PROV=$$PRIMPROV^APCLV(V,"D"),PROVI=$$PRIMPROV^APCLV(V,"F") I (PROV=24!(PROV=79)!(PROV="08")),'$$REFR(V) S G=9999999-D
I G]"" D
.Q:$P(LASTI,U)>G
.S LASTI=G_U_"1 "_$S(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($P(G,U))_" "_$P(^DIC(7,PROVI,0),U,1)_" Visit "
S (D,V)=0,G=""
F S D=$O(BDMY(D)) Q:D'=+D!(G) S V=0 F S V=$O(BDMY(D,V)) Q:V'=+V!(G) D
.Q:$$DNKA(V)
.Q:$P(^AUPNVSIT(V,0),U,7)="C"
.Q:$$CLINIC^APCLV(V,"C")=52
.S PROV=$$CLINIC^APCLV(V,"C"),PROVI=$$CLINIC^APCLV(V,"I") I PROV=17!(PROV=18)!(PROV="A2"),'$$REFR(V) S G=9999999-D
I G]"" D
.Q:$P(LASTI,U)>G
.S LASTI=G_U_"1 "_$S(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($P(G,U))_" "_$P(^DIC(40.7,PROVI,0),U,1)_" Clinic Visit "
;
I $G(R) Q $S(F="D":$P(LASTI,U),1:$P(LASTI,U,2)) ;no refusals
;
I LASTI]"" Q $S(F="D":$P(LASTI,U),1:$P(LASTI,U,2))
;
NEW G S G=$$REFUSAL(P,9999999.15,$O(^AUTTEXAM("B","DIABETIC EYE EXAM",0)),BDATE,EDATE,"N")
Q "2 No"_$S(G:" - Not Medically Indicated",1:"")
;
DENTAL(P,BDATE,EDATE,F,R) ;EP
NEW BDMY,BDMV,%,LASTI,BD,ED,T,D,%,Y,X,G,V,PROV
I $G(BDATE)="" S BDATE=$$DOB^AUPNPAT(P)
I $G(EDATE)="" S EDATE=DT
I $G(F)="" S F="E"
S LASTI=$$LASTDENT^APCLAPI2(P,BDATE,EDATE,"D")
I LASTI]"" S $P(LASTI,U,2)="1 Yes "_$$DATE^BDMS9B1($P(LASTI,U))_" Dental Exam" I F="H" Q LASTI
I F="E",LASTI]"" Q $P(LASTI,U,2) ; if in audit and has exam display it
;
K BDMV,BDMY
;
K T
S T="T"
D ALLV^BDMAPIU(P,BDATE,EDATE,.T)
;reorder by date of visit/reverse order
S %=0 F S %=$O(T(%)) Q:%'=+% S BDMY((9999999-$P(T(%),U)),$P(T(%),U,5))=T(%)
N PROV,D,V,G
S (D,V)=0,G=""
F S D=$O(BDMY(D)) Q:D'=+D!(G) S V=0 F S V=$O(BDMY(D,V)) Q:V'=+V!(G) D
.Q:$$DNKA(V)
.Q:$P(^AUPNVSIT(V,0),U,7)="C"
.Q:$$CLINIC^APCLV(V,"C")=52
.S PROV=$$PRIMPROV^APCLV(V,"D") I PROV=52,$$ADA(V) S G=9999999-D
I G]"" D
.Q:$P(LASTI,U)>G
.S LASTI=G_U_"1 "_$S(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($P(G,U))_" Dentist Visit "
S (D,V)=0,G=""
F S D=$O(BDMY(D)) Q:D'=+D!(G) S V=0 F S V=$O(BDMY(D,V)) Q:V'=+V!(G) S PROV=$$CLINIC^APCLV(V,"C") I PROV=56,$$ADA(V),$O(^AUPNVDEN("AD",V,0)),'$$DNKA(V) S G=9999999-D
I G]"" D
.Q:$P(LASTI,U)>G
.S LASTI=G_U_"1 "_$S(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($P(G,U))_" Dental Clinic Visit "
;
S (D,V)=0,G=""
F S D=$O(BDMY(D)) Q:D'=+D!(G) S V=0 F S V=$O(BDMY(D,V)) Q:V'=+V!(G) I $$DCPT(V) S G=9999999-D
I G]"" D
.Q:$P(LASTI,U)>G
.S LASTI=G_U_"1 Yes"_" "_$$DATE^BDMS9B1($P(G,U))_" Dental CPT "
;
I $G(R) Q $S(F="D":$P(LASTI,U),1:$P(LASTI,U,2)) ;no refusals
;
I LASTI]"" Q $S(F="D":$P(LASTI,U),1:$P(LASTI,U,2))
;
NEW G S G=$$REFUSAL(P,9999999.15,$O(^AUTTEXAM("B","DENTAL EXAM",0)),BDATE,EDATE,"N")
Q "2 No"_$S(G:" - Not Medically Indicated",1:"")
DCPT(V) ;
NEW A,B,C
S B=""
S A=0 F S A=$O(^AUPNVCPT("AD",V,A)) Q:A'=+A!(B) D
.I $$ICD^BDMUTL($P($G(^AUPNVCPT(A,0)),U,1),"DM AUDIT DENTAL EXAM CPTS",1) S B=1
Q B
BDMDE17 ; IHS/CMI/LAB - 2017 DIABETES AUDIT 03 Nov 2015 9:29 AM ;
+1 ;;2.0;DIABETES MANAGEMENT SYSTEM;**10**;JUN 14, 2007;Build 12
DIETEDUC(P,BDATE,EDATE) ;EP
+1 NEW D,BD,ED,X,Y,%DT,D,G,BDMVRD,V,BDM,RD,NRD,BDMV
+2 SET (RD,NRD,BDMV)=""
+3 SET X=BDATE
SET %DT="P"
DO ^%DT
SET BD=Y
+4 SET X=EDATE
SET %DT="P"
DO ^%DT
SET ED=Y
+5 SET D=9999999-ED
SET (RD,NRD)=""
+6 FOR
SET D=$ORDER(^AUPNVSIT("AA",P,D))
IF D=""!(D>(9999999-BD))
QUIT
Begin DoDot:1
+7 SET V=0
FOR
SET V=$ORDER(^AUPNVSIT("AA",P,D,V))
IF V'=+V
QUIT
Begin DoDot:2
+8 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+9 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+10 IF '$PIECE(^AUPNVSIT(V,0),U,9)
QUIT
+11 IF $$DNKA(V)
QUIT
+12 IF $PIECE(^AUPNVSIT(V,0),U,7)="C"
QUIT
+13 IF $$CLINIC^APCLV(V,"C")=52
QUIT
+14 IF $$PRIMPROV^APCLV(V,"D")=29
SET BDMVRD(V)=""
SET BDMV=BDMV_" RD: "_$PIECE(^DIC(7,$ORDER(^DIC(7,"D",29,0)),0),U)_" Visit: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
QUIT
+15 IF $$PRIMPROV^APCLV(V,"D")="07"
SET BDMVRD(V)=""
SET BDMV=BDMV_" RD: "_$PIECE(^DIC(7,$ORDER(^DIC(7,"D","07",0)),0),U)_" Visit: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
QUIT
+16 IF $$PRIMPROV^APCLV(V,"D")="34"
SET BDMVRD(V)=""
SET BDMV=BDMV_" RD: "_$PIECE(^DIC(7,$ORDER(^DIC(7,"D",34,0)),0),U)_" Visit: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
QUIT
+17 ;now check povs for V65.3 and label as non-rd
+18 ;change this to check to see if in BGP DIETARY SURVEILLANCE DXS TAXONOMY calls are $$ICD^ATXCH(code)
+19 ;S X=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X I $$VAL^XBDIQ1(9000010.07,X,.01)="V65.3" S NRD=1,BDMV=BDMV_"NRD: V65.3 Dx: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
+20 NEW TAX
+21 SET TAX=$ORDER(^ATXAX("B","BGP DIETARY SURVEILLANCE DXS",0))
+22 ;S X=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X I $$ICD^ATXCHK($$VALI^XBDIQ1(9000010.07,X,.01),TAX,9) S NRD=1,BDMV=BDMV_"NRD: "_$$VAL^XBDIQ1(9000010.07,X,.01)_" Dx: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" " ;p8 ICD-10
+23 ;p8 ICD-10
SET X=0
FOR
SET X=$ORDER(^AUPNVPOV("AD",V,X))
IF X'=+X
QUIT
IF $$ICD^BDMUTL($$VALI^XBDIQ1(9000010.07,X,.01),$PIECE(^ATXAX(TAX,0),U),9)
SET NRD=1
SET BDMV=BDMV_"NRD: "_$$VAL^XBDIQ1(9000010.07,X,.01)_" Dx: "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
+24 SET X=0
FOR
SET X=$ORDER(^AUPNVCPT("AD",V,X))
IF X'=+X
QUIT
SET Z=$$VAL^XBDIQ1(9000010.18,X,.01)
IF Z=97802!(Z=97803)!(Z=97804)
SET RD=1
SET BDMV=BDMV_"RD: CPT "_Z_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
+25 ;now check for education topics
+26 SET T=$ORDER(^ATXAX("B","DM AUDIT DIET EDUC TOPICS",0))
+27 SET X=0
FOR
SET X=$ORDER(^AUPNVPED("AD",V,X))
IF X'=+X
QUIT
SET Y=$PIECE($GET(^AUPNVPED(X,0)),U)
Begin DoDot:3
+28 IF 'Y
QUIT
+29 IF '$DATA(^AUTTEDT(Y,0))
QUIT
+30 IF T
IF $DATA(^ATXAX(T,21,"B",Y))
SET Z=$$PC(X)
Begin DoDot:4
+31 IF Z="07"!(Z=29)!(Z=34)
SET RD=1
SET BDMV=BDMV_"RD: "_$PIECE(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
QUIT
+32 SET NRD=1
SET BDMV=BDMV_"NRD: "_$PIECE(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
End DoDot:4
QUIT
+33 SET J=$PIECE(^AUTTEDT(Y,0),U,2)
IF $PIECE(J,"-",2)="N"!($PIECE(J,"-",2)="DT")!($PIECE(J,"-")="MNT")!($PIECE(J,"-",2)="MNT")!($PIECE(J,"-")="DMCN")
SET Z=$$PC(X)
Begin DoDot:4
+34 IF Z="07"!(Z=29)!(Z=34)
SET RD=1
SET BDMV=BDMV_"RD: "_$PIECE(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
QUIT
+35 SET NRD=1
SET BDMV=BDMV_"NRD: "_$PIECE(^AUTTEDT(Y,0),U,2)_" "_$$DATE^BDMS9B1($$VD^APCLV(V))_" "
End DoDot:4
QUIT
End DoDot:3
+36 QUIT
End DoDot:2
+37 QUIT
End DoDot:1
+38 ;a RD visit so a hit
IF $DATA(BDMVRD)
SET RD=1
+39 SET G=0
+40 IF RD!(NRD)
QUIT $SELECT(RD+NRD=2:"3 Yes (RD & Non RD - Other) "_U_BDMV,RD:"1 Yes (RD) "_BDMV,1:"2 Yes (Non RD) "_BDMV)
+41 ;_$S(G:" - Not Medically Indicated",1:"")
QUIT "4 None"
PC(V) ;return provider discipline of educ provider
+1 IF 'V
QUIT ""
+2 NEW X
SET X=$PIECE(^AUPNVPED(V,0),U,5)
+3 IF 'X
QUIT ""
+4 IF $PIECE(^DD(9000010.16,.05,0),U,2)[200
QUIT $$PROVCLSC^XBFUNC1(X)
+5 NEW A
SET A=$PIECE(^DIC(6,X,0),U,4)
+6 IF 'A
QUIT ""
+7 QUIT $PIECE($GET(^DIC(7,A,9999999)),U)
EXEDUC(P,BDATE,EDATE) ;EP
+1 NEW BDM,X,E,%,G
+2 SET X=P_"^LAST EDUC [DM AUDIT EXERCISE EDUC TOPICS;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(X,"BDM(")
+3 IF $DATA(BDM(1))
QUIT "1 Yes "_$PIECE(BDM(1),U,3)_" "_$$DATE^BDMS9B1($PIECE(BDM(1),U,1))
+4 KILL BDM
+5 SET X=P_"^ALL EDUC;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(X,"BDM(")
+6 SET X=0
SET G=0
FOR
SET X=$ORDER(BDM(X))
IF X'=+X!(G)
QUIT
SET I=+$PIECE(BDM(X),U,4)
SET E=$PIECE($GET(^AUPNVPED(I,0)),U)
SET T=$PIECE($GET(^AUTTEDT(E,0)),U,2)
IF $PIECE(T,"-",2)="EX"
SET G=1
+7 IF G
QUIT "1 Yes "_T_" "_$$VD^APCLV($PIECE(^AUPNVPED(I,0),U,3),"E")
+8 KILL BDM
+9 ;p8 ICD-10
SET X=P_"^LAST DX [BGP EXERCISE COUNSELING DXS;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(X,"BDM(")
+10 IF $DATA(BDM(1))
QUIT "1 Yes POV: "_$PIECE(BDM(1),U,3)_" "_$$DATE^BDMS9B1($PIECE(BDM(1),U))
+11 QUIT "2 No"
OTHEDUC(P,BDATE,EDATE) ;EP
+1 NEW BDM,X,E,%,T,TX
+2 SET TX=$ORDER(^ATXAX("B","DM AUDIT OTHER EDUC TOPICS",0))
+3 KILL BDM
+4 SET X=P_"^ALL EDUC;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(X,"BDM(")
+5 SET X=0
SET G=0
FOR
SET X=$ORDER(BDM(X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+6 SET I=+$PIECE(BDM(X),U,4)
+7 SET J=$PIECE($GET(^AUPNVPED(I,0)),U)
+8 IF 'J
QUIT
+9 SET T=$PIECE($GET(^AUTTEDT(J,0)),U,2)
+10 IF $PIECE(T,"-",2)="EX"
QUIT
+11 IF $PIECE(T,"-",2)="N"
QUIT
+12 IF $PIECE(T,"-",2)="MNT"
QUIT
+13 IF $PIECE(T,"-",1)="MNT"
QUIT
+14 IF $PIECE(T,"-",2)="DT"
QUIT
+15 IF $PIECE(T,"-",1)="DMCN"
QUIT
+16 IF TX
IF $DATA(^ATXAX(TX,21,"AA",J))
SET G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($PIECE(^AUPNVPED(I,0),U,3),"I"))
+17 IF $PIECE(T,"-",1)="DM"!($PIECE(T,"-",1)="DMC")
SET G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($PIECE(^AUPNVPED(I,0),U,3),"I"))
QUIT
+18 NEW CODE
+19 SET CODE=$PIECE($$CODEN^BDMUTL($PIECE(T,"-",1),80),"~")
+20 IF CODE>0
Begin DoDot:2
+21 NEW TAX
+22 SET TAX=$ORDER(^ATXAX("B","SURVEILLANCE DIABETES",0))
+23 IF $$ICD^BDMUTL(CODE,$PIECE(^ATXAX(TAX,0),U),9)
SET G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($PIECE(^AUPNVPED(I,0),U,3),"I"))
End DoDot:2
QUIT
+24 IF $PIECE(T,"-",1)]""
IF $$SNOMED^BDMUTL(2017,"DIABETES DIAGNOSES",$PIECE(T,"-",1))
SET G="1 Yes "_T_" "_$$DATE^BDMS9B1($$VD^APCLV($PIECE(^AUPNVPED(I,0),U,3),"I"))
End DoDot:1
+25 IF G
QUIT G
+26 ;_$S(G:" - Not Medically Indicated",1:"")
QUIT "2 No"
+27 ;
DFE(P,BDATE,EDATE,F,R) ;EP - FOOT EXAM
+1 IF $GET(BDATE)=""
SET BDATE=$$DOB^AUPNPAT(P)
+2 IF $GET(EDATE)=""
SET EDATE=DT
+3 IF $GET(F)=""
SET F="E"
+4 NEW BDMY,BDMV,%,LASTI,A,D,V,G,PROV,E,T,PROVI,G
+5 SET LASTI=""
+6 SET BDMY(1)=$$LASTDFE^APCLAPI2(P,BDATE,EDATE,"D")
+7 IF BDMY(1)
SET LASTI=$PIECE(BDMY(1),U)_U_"1 Yes "_$$DATE^BDMS9B1($PIECE(BDMY(1),U))_" Diabetic Foot Exam"
+8 SET G=$$LASTCPTT^BDMAPIU(P,BDATE,EDATE,"DM AUDIT CPT FOOT EXAM","E")
+9 IF G
IF $PIECE(BDMY(1),U)<$PIECE(G,U,1)
SET LASTI=$PIECE(G,U,1)_U_"1 Yes "_$$DATE^BDMS9B1($PIECE(G,U,1))_" "_$PIECE(G,U,2)
+10 ;in supplement
IF LASTI]""
IF F="H"
QUIT $PIECE(LASTI,U,2)
+11 ; if in audit and has exam display it
IF F="E"
IF LASTI]""
QUIT $PIECE(LASTI,U,2)
+12 ;now check any clinic 65 or prov 33/25
+13 ;
+14 KILL T
+15 SET T="T"
+16 DO ALLV^BDMAPIU(P,BDATE,EDATE,.T)
+17 ;reorder by date of visit/reverse order
+18 SET %=0
FOR
SET %=$ORDER(T(%))
IF %'=+%
QUIT
SET BDMY((9999999-$PIECE(T(%),U)),$PIECE(T(%),U,5))=T(%)
+19 NEW PROV,D,V,G
+20 SET (D,V)=0
SET G=""
+21 FOR
SET D=$ORDER(BDMY(D))
IF D'=+D!(G)
QUIT
SET V=0
FOR
SET V=$ORDER(BDMY(D,V))
IF V'=+V!(G)
QUIT
Begin DoDot:1
+22 IF $$DNKA(V)
QUIT
+23 IF $PIECE(^AUPNVSIT(V,0),U,7)="C"
QUIT
+24 IF $$CLINIC^APCLV(V,"C")=52
QUIT
+25 SET PROV=$$PRIMPROV^APCLV(V,"D")
SET PROVI=$$PRIMPROV^APCLV(V,"F")
IF (PROV=33!(PROV=25)!(PROV=84))
SET G=9999999-D
End DoDot:1
+26 IF G]""
Begin DoDot:1
+27 IF $PIECE(LASTI,U)>G
QUIT
+28 SET LASTI=G_U_"1 "_$SELECT(F="H":"Maybe ",1:"Yes ")_$$DATE^BDMS9B1($PIECE(G,U))_" "_$PIECE(^DIC(7,PROVI,0),U,1)_" visit"
End DoDot:1
+29 SET (D,V)=0
SET G=""
+30 FOR
SET D=$ORDER(BDMY(D))
IF D'=+D!(G)
QUIT
SET V=0
FOR
SET V=$ORDER(BDMY(D,V))
IF V'=+V!(G)
QUIT
Begin DoDot:1
+31 IF $$DNKA(V)
QUIT
+32 IF $PIECE(^AUPNVSIT(V,0),U,7)="C"
QUIT
+33 IF $$CLINIC^APCLV(V,"C")=52
QUIT
+34 SET PROV=$$CLINIC^APCLV(V,"C")
SET PROVI=$$CLINIC^APCLV(V,"I")
IF PROV=65!(PROV="B7")
SET G=9999999-D
End DoDot:1
+35 IF G]""
Begin DoDot:1
+36 IF $PIECE(LASTI,U)>G
QUIT
+37 SET LASTI=G_U_"1 "_$SELECT(F="H":"Maybe ",1:"Yes ")_$$DATE^BDMS9B1($PIECE(G,U))_" "_$PIECE(^DIC(40.7,PROVI,0),U,1)_" clinic visit"
End DoDot:1
+38 ;
+39 ;no refusals
IF $GET(R)
KILL T
QUIT $SELECT(F="D":$PIECE(LASTI,U),1:$PIECE(LASTI,U,2))
+40 ;
+41 IF LASTI]""
KILL T
QUIT $SELECT(F="D":$PIECE(LASTI,U),1:$PIECE(LASTI,U,2))
+42 ;
+43 NEW G
SET G=$$REFUSAL(P,9999999.15,$ORDER(^AUTTEXAM("B","DIABETIC FOOT EXAM, COMPLETE",0)),BDATE,EDATE,"N")
+44 QUIT "2 No"_$SELECT(G:" - Not Medically Indicated",1:"")
+45 ;
ADA(V) ;any ada other than 9991
+1 IF '$GET(V)
QUIT ""
+2 NEW X,Y,Z,G
+3 SET G=""
SET X=0
FOR
SET X=$ORDER(^AUPNVDEN("AD",V,X))
IF X'=+X!(G)
QUIT
SET Y=$PIECE($GET(^AUPNVDEN(X,0)),U)
IF Y
IF $DATA(^AUTTADA(Y,0))
IF $PIECE(^AUTTADA(Y,0),U)'=9991
SET G=1
+4 QUIT G
DNKA(V) ;EP - is this a DNKA visit?
+1 IF '$GET(V)
QUIT ""
+2 NEW D,N
SET D=$$PRIMPOV^APCLV(V,"C")
+3 IF D=".0860"
QUIT 1
+4 SET N=$$PRIMPOV^APCLV(V,"N")
+5 IF $EXTRACT(D)="V"
IF N["DNKA"
QUIT 1
+6 IF $EXTRACT(D)="V"
IF N["DID NOT KEEP APPOINTMENT"
QUIT 1
+7 IF $EXTRACT(D)="V"
IF N["DID NOT KEEP APPT"
QUIT 1
+8 QUIT 0
REFR(V) ;
+1 IF '$GET(V)
QUIT ""
+2 NEW D,N
SET D=$$PRIMPOV^APCLV(V,"I")
+3 IF D=""
QUIT 0
+4 ;change this to look at the DM AUDIT REFRACTION taxonomy
+5 NEW TAX
+6 SET TAX=$ORDER(^ATXAX("B","DM AUDIT REFRACTION DXS",0))
+7 ;I $$ICD^ATXCHK(D,TAX,9) Q 1
+8 ;cmi/maw 05/15/2014 p8
IF $$ICD^BDMUTL(D,$PIECE(^ATXAX(TAX,0),U),9)
QUIT 1
+9 ;I D="367.89"!(D="367.9")!($E(D,1,5)=372.0)!($E(D,1,5)=372.1) Q 1
+10 QUIT 0
+11 ;
REFUSAL(P,F,I,B,E,T) ;EP
+1 IF '$GET(P)
QUIT ""
+2 IF '$GET(F)
QUIT ""
+3 IF '$GET(I)
QUIT ""
+4 IF $GET(B)=""
QUIT ""
+5 IF $GET(E)=""
QUIT ""
+6 NEW G,X,Y,%DT,R
SET X=B
SET %DT="P"
DO ^%DT
SET B=Y
+7 SET X=E
SET %DT="P"
DO ^%DT
SET E=Y
+8 SET (X,G)=0
FOR
SET X=$ORDER(^AUPNPREF("AA",P,F,I,X))
IF X'=+X!(G)
QUIT
SET Y=0
FOR
SET Y=$ORDER(^AUPNPREF("AA",P,F,I,X,Y))
IF Y'=+Y
QUIT
SET D=$PIECE(^AUPNPREF(Y,0),U,3)
IF D'<B&(D'>E)
Begin DoDot:1
+9 IF $GET(T)]""
IF T'=$PIECE(^AUPNPREF(Y,0),U,7)
QUIT
+10 SET G=1_"^"_$PIECE(^AUPNPREF(Y,0),U,7)_U_$$DATE^BDMS9B1($PIECE(^AUPNPREF(Y,0),U,3))_U_$$VAL^XBDIQ1(9000022,Y,.04)_U_$$VAL^XBDIQ1(9000022,Y,.07)_U_$$VAL^XBDIQ1(9000022,Y,.01)_U_$PIECE(^AUPNPREF(Y,0),U,3)
End DoDot:1
+11 QUIT G
+12 ;
EYE(P,BDATE,EDATE,F,R) ;EP
+1 IF $GET(BDATE)=""
SET BDATE=$$DOB^AUPNPAT(P)
+2 IF $GET(EDATE)=""
SET EDATE=DT
+3 IF $GET(F)=""
SET F="E"
+4 NEW BDMY,BDMV,%,LASTI,BD,ED,T,D,%,Y,X,G,V,PROV,T,PROVI
+5 SET LASTI=$$LASTITEM^APCLAPIU(P,"03","EXAM",BDATE,EDATE,"D")
+6 ; I F="H"!(F="D") Q LASTI
IF LASTI]""
SET $PIECE(LASTI,U,2)="1 Yes "_$$DATE^BDMS9B1($PIECE(LASTI,U))_" Diabetic Eye Exam"
+7 ; if in audit and has exam display it
IF F="E"
IF LASTI]""
QUIT $PIECE(LASTI,U,2)
+8 ;
+9 SET X=$$LASTCPTT^BDMAPIU(P,BDATE,EDATE,"DM AUDIT EYE EXAM CPTS","E")
+10 ;I F="H"!(F="D") Q LASTI
IF $PIECE(X,U)>$PIECE(LASTI,U)
SET LASTI=$PIECE(X,U)_U_"1 Yes "_$$DATE^BDMS9B1($PIECE(X,U))_" "_$PIECE(X,U,2)
+11 KILL BDMV,BDMY
+12 IF F="E"
IF LASTI]""
QUIT $PIECE(LASTI,U,2)
+13 ;
+14 SET X=$$LASTPRCT^BDMAPIU(P,BDATE,EDATE,"DM AUDIT EYE EXAM PROCS","A")
+15 IF $PIECE(X,U)>$PIECE(LASTI,U)
SET LASTI=$PIECE(X,U)_U_"1 Yes "_$$DATE^BDMS9B1($PIECE(X,U,1))_" "_$PIECE(X,U,2)
+16 IF F="D"
QUIT $PIECE(LASTI,U)
+17 IF LASTI
IF F="H"
QUIT $PIECE(LASTI,U,2)
+18 IF LASTI
IF F="E"
QUIT $PIECE(LASTI,U,2)
+19 SET T="T"
+20 DO ALLV^BDMAPIU(P,BDATE,EDATE,.T)
+21 ;reorder by date of visit/reverse order
+22 SET %=0
FOR
SET %=$ORDER(T(%))
IF %'=+%
QUIT
SET BDMY((9999999-$PIECE(T(%),U)),$PIECE(T(%),U,5))=T(%)
+23 NEW PROV,D,V,G
+24 SET (D,V)=0
SET G=""
+25 FOR
SET D=$ORDER(BDMY(D))
IF D'=+D!(G)
QUIT
SET V=0
FOR
SET V=$ORDER(BDMY(D,V))
IF V'=+V!(G)
QUIT
Begin DoDot:1
+26 IF $$DNKA(V)
QUIT
+27 IF $PIECE(^AUPNVSIT(V,0),U,7)="C"
QUIT
+28 IF $$CLINIC^APCLV(V,"C")=52
QUIT
+29 SET PROV=$$PRIMPROV^APCLV(V,"D")
SET PROVI=$$PRIMPROV^APCLV(V,"F")
IF (PROV=24!(PROV=79)!(PROV="08"))
IF '$$REFR(V)
SET G=9999999-D
End DoDot:1
+30 IF G]""
Begin DoDot:1
+31 IF $PIECE(LASTI,U)>G
QUIT
+32 SET LASTI=G_U_"1 "_$SELECT(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($PIECE(G,U))_" "_$PIECE(^DIC(7,PROVI,0),U,1)_" Visit "
End DoDot:1
+33 SET (D,V)=0
SET G=""
+34 FOR
SET D=$ORDER(BDMY(D))
IF D'=+D!(G)
QUIT
SET V=0
FOR
SET V=$ORDER(BDMY(D,V))
IF V'=+V!(G)
QUIT
Begin DoDot:1
+35 IF $$DNKA(V)
QUIT
+36 IF $PIECE(^AUPNVSIT(V,0),U,7)="C"
QUIT
+37 IF $$CLINIC^APCLV(V,"C")=52
QUIT
+38 SET PROV=$$CLINIC^APCLV(V,"C")
SET PROVI=$$CLINIC^APCLV(V,"I")
IF PROV=17!(PROV=18)!(PROV="A2")
IF '$$REFR(V)
SET G=9999999-D
End DoDot:1
+39 IF G]""
Begin DoDot:1
+40 IF $PIECE(LASTI,U)>G
QUIT
+41 SET LASTI=G_U_"1 "_$SELECT(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($PIECE(G,U))_" "_$PIECE(^DIC(40.7,PROVI,0),U,1)_" Clinic Visit "
End DoDot:1
+42 ;
+43 ;no refusals
IF $GET(R)
QUIT $SELECT(F="D":$PIECE(LASTI,U),1:$PIECE(LASTI,U,2))
+44 ;
+45 IF LASTI]""
QUIT $SELECT(F="D":$PIECE(LASTI,U),1:$PIECE(LASTI,U,2))
+46 ;
+47 NEW G
SET G=$$REFUSAL(P,9999999.15,$ORDER(^AUTTEXAM("B","DIABETIC EYE EXAM",0)),BDATE,EDATE,"N")
+48 QUIT "2 No"_$SELECT(G:" - Not Medically Indicated",1:"")
+49 ;
DENTAL(P,BDATE,EDATE,F,R) ;EP
+1 NEW BDMY,BDMV,%,LASTI,BD,ED,T,D,%,Y,X,G,V,PROV
+2 IF $GET(BDATE)=""
SET BDATE=$$DOB^AUPNPAT(P)
+3 IF $GET(EDATE)=""
SET EDATE=DT
+4 IF $GET(F)=""
SET F="E"
+5 SET LASTI=$$LASTDENT^APCLAPI2(P,BDATE,EDATE,"D")
+6 IF LASTI]""
SET $PIECE(LASTI,U,2)="1 Yes "_$$DATE^BDMS9B1($PIECE(LASTI,U))_" Dental Exam"
IF F="H"
QUIT LASTI
+7 ; if in audit and has exam display it
IF F="E"
IF LASTI]""
QUIT $PIECE(LASTI,U,2)
+8 ;
+9 KILL BDMV,BDMY
+10 ;
+11 KILL T
+12 SET T="T"
+13 DO ALLV^BDMAPIU(P,BDATE,EDATE,.T)
+14 ;reorder by date of visit/reverse order
+15 SET %=0
FOR
SET %=$ORDER(T(%))
IF %'=+%
QUIT
SET BDMY((9999999-$PIECE(T(%),U)),$PIECE(T(%),U,5))=T(%)
+16 NEW PROV,D,V,G
+17 SET (D,V)=0
SET G=""
+18 FOR
SET D=$ORDER(BDMY(D))
IF D'=+D!(G)
QUIT
SET V=0
FOR
SET V=$ORDER(BDMY(D,V))
IF V'=+V!(G)
QUIT
Begin DoDot:1
+19 IF $$DNKA(V)
QUIT
+20 IF $PIECE(^AUPNVSIT(V,0),U,7)="C"
QUIT
+21 IF $$CLINIC^APCLV(V,"C")=52
QUIT
+22 SET PROV=$$PRIMPROV^APCLV(V,"D")
IF PROV=52
IF $$ADA(V)
SET G=9999999-D
End DoDot:1
+23 IF G]""
Begin DoDot:1
+24 IF $PIECE(LASTI,U)>G
QUIT
+25 SET LASTI=G_U_"1 "_$SELECT(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($PIECE(G,U))_" Dentist Visit "
End DoDot:1
+26 SET (D,V)=0
SET G=""
+27 FOR
SET D=$ORDER(BDMY(D))
IF D'=+D!(G)
QUIT
SET V=0
FOR
SET V=$ORDER(BDMY(D,V))
IF V'=+V!(G)
QUIT
SET PROV=$$CLINIC^APCLV(V,"C")
IF PROV=56
IF $$ADA(V)
IF $ORDER(^AUPNVDEN("AD",V,0))
IF '$$DNKA(V)
SET G=9999999-D
+28 IF G]""
Begin DoDot:1
+29 IF $PIECE(LASTI,U)>G
QUIT
+30 SET LASTI=G_U_"1 "_$SELECT(F="H":"Maybe",1:"Yes")_" "_$$DATE^BDMS9B1($PIECE(G,U))_" Dental Clinic Visit "
End DoDot:1
+31 ;
+32 SET (D,V)=0
SET G=""
+33 FOR
SET D=$ORDER(BDMY(D))
IF D'=+D!(G)
QUIT
SET V=0
FOR
SET V=$ORDER(BDMY(D,V))
IF V'=+V!(G)
QUIT
IF $$DCPT(V)
SET G=9999999-D
+34 IF G]""
Begin DoDot:1
+35 IF $PIECE(LASTI,U)>G
QUIT
+36 SET LASTI=G_U_"1 Yes"_" "_$$DATE^BDMS9B1($PIECE(G,U))_" Dental CPT "
End DoDot:1
+37 ;
+38 ;no refusals
IF $GET(R)
QUIT $SELECT(F="D":$PIECE(LASTI,U),1:$PIECE(LASTI,U,2))
+39 ;
+40 IF LASTI]""
QUIT $SELECT(F="D":$PIECE(LASTI,U),1:$PIECE(LASTI,U,2))
+41 ;
+42 NEW G
SET G=$$REFUSAL(P,9999999.15,$ORDER(^AUTTEXAM("B","DENTAL EXAM",0)),BDATE,EDATE,"N")
+43 QUIT "2 No"_$SELECT(G:" - Not Medically Indicated",1:"")
DCPT(V) ;
+1 NEW A,B,C
+2 SET B=""
+3 SET A=0
FOR
SET A=$ORDER(^AUPNVCPT("AD",V,A))
IF A'=+A!(B)
QUIT
Begin DoDot:1
+4 IF $$ICD^BDMUTL($PIECE($GET(^AUPNVCPT(A,0)),U,1),"DM AUDIT DENTAL EXAM CPTS",1)
SET B=1
End DoDot:1
+5 QUIT B