BDMD111 ; IHS/CMI/LAB -IHS -CUMULATIVE REPORT ;
;;2.0;DIABETES MANAGEMENT SYSTEM;**4**;JUN 14, 2007
;
;
IMM ;
S:'$D(BDMCUML(140)) BDMCUML(140)="IMMUNIZATIONS"
S $P(BDMCUML(140),U,2)=$P(BDMCUML(140),U,2)+1
S V=$G(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,64))
I $E(V)="1" S $P(BDMCUML(140),U,3)=$P(BDMCUML(140),U,3)+1
I $E(V)="3" S $P(BDMCUML(140),U,6)=$P(BDMCUML(140),U,6)+1
S V=$G(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,66))
I $E(V)="1" S $P(BDMCUML(140),U,4)=$P(BDMCUML(140),U,4)+1
I $E(V)="3" S $P(BDMCUML(140),U,7)=$P(BDMCUML(140),U,7)+1
S V=$G(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,68))
I $E(V)="1" S $P(BDMCUML(140),U,5)=$P(BDMCUML(140),U,5)+1
I $E(V)="3" S $P(BDMCUML(140),U,8)=$P(BDMCUML(140),U,8)+1
;
QUAN ;
;145
;title^total pts^total YES^NO^REF^UACR^UPCR^24HR^MICRO STRIP^MICRO ONLY^DIPSTICK
K BDMOFLG
S BDMOFLG=0
S:'$D(BDMCUML(145)) BDMCUML(145)="LABORATORY EXAMS"
S $P(BDMCUML(145),U,2)=$P(BDMCUML(145),U,2) ;TOTAL # of patients
S Q=$G(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,92))
S V=$E($G(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,92))) ;test done?
S T=$P($G(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,92)),U,5) ;type of test
S R=$S($P(Q,U,6)]"":$P(Q,U,6),1:$P(Q,U,2)) ;value/result
I V=1 D
.S $P(BDMCUML(145),U,3)=$P(BDMCUML(145),U,3)+1
.S P=$S(T=1:6,T=2:7,T=3:8,T=4:9,T=5:10,T=6:11,1:"")
.S $P(BDMCUML(145),U,P)=$P(BDMCUML(145),U,P)+1
;.I T=1!(T=2)!(T=5) D
;..I T=5 D
;...S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1
;..I T=1 D
;...I R[">" S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
;...;I $$UP^XLFSTR(R)["COMMENT" S $P(BDMCUML(145),U,12)=$P(BDMCUML(145),U,12)+1 Q
;...S R=$$STV^BDMD118(R,8)
;...I R="" S $P(BDMCUML(145),U,15)=$P(BDMCUML(145),U,15)+1 Q
;...S R=+R
;...I R<30 S $P(BDMCUML(145),U,12)=$P(BDMCUML(145),U,12)+1 Q
;...I R<300.9999 S $P(BDMCUML(145),U,13)=$P(BDMCUML(145),U,13)+1 Q
;...S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1
;..I T=2 D
;...I R["-" S $P(BDMCUML(145),U,13)=$P(BDMCUML(145),U,13)+1 Q
;...I R["300" S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
;...I R[">" S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
;...S R=$$STV^BDMD118(R,5,1) I R>300 S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
;...S $P(BDMCUML(145),U,12)=$P(BDMCUML(145),U,12)+1
I V=2 S $P(BDMCUML(145),U,4)=$P(BDMCUML(145),U,4)+1 ;no urine testing
I V=3 S $P(BDMCUML(145),U,5)=$P(BDMCUML(145),U,5)+1 ;refused urine testing
EKG ;need date of last ekg
S:'$D(BDMCUML(150)) BDMCUML(150)="Electrocardiogram (Age 30 and above)"
G:$$AGE^AUPNPAT(BDMPD,BDMADAT)<30 CREAT
S $P(BDMCUML(150),U,2)=$P(BDMCUML(150),U,2)+1
S V=$$EKG^BDMD112(BDMPD,BDMRED,"I")
I V]"" D
.S E=$$FMDIFF^XLFDT(BDMADAT,V)
.I E<(365.25*3) S $P(BDMCUML(150),U,3)=$P(BDMCUML(150),U,3)+1
.I E<(365.25*5) S $P(BDMCUML(150),U,4)=$P(BDMCUML(150),U,4)+1
.S $P(BDMCUML(150),U,5)=$P(BDMCUML(150),U,5)+1
CREAT ;
S:'$D(BDMCUML(170)) BDMCUML(170)="Serum Creatinine obtained in the past 12 months"
S $P(BDMCUML(170),U,2)=$P(BDMCUML(170),U,2)+1
S V=$$CREAT^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
I V="" S $P(BDMCUML(170),U,5)=$P(BDMCUML(170),U,5)+1 G GFR
S V=$P(V,U)
S V=$$STV^BDMD118(V,5,1) I $E(V)'=+$E(V),$E(V)'="." S $P(BDMCUML(170),U,6)=$P(BDMCUML(170),U,6)+1 G GFR ;unable to determine result, not a number
I V>1.9 S $P(BDMCUML(170),U,3)=$P(BDMCUML(170),U,3)+1
I V<2.0 S $P(BDMCUML(170),U,4)=$P(BDMCUML(170),U,4)+1
;
GFR ;
G:$$AGE^AUPNPAT(BDMPD,BDMADAT)<18 TCHOL
S:'$D(BDMCUML(175)) BDMCUML(175)="Estimated GFR documented during audit period"
S $P(BDMCUML(175),U,2)=$P(BDMCUML(175),U,2)+1
S V=$E($G(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,79)))
I V=1 S $P(BDMCUML(175),U,5)=$P(BDMCUML(175),U,5)+1
;
TCHOL ;
S:'$D(BDMCUML(180)) BDMCUML(180)="Total Cholesterol obtained in past 12 months"
S $P(BDMCUML(180),U,2)=$P(BDMCUML(180),U,2)+1
S V=$$CHOL^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
I V="" S $P(BDMCUML(180),U,6)=$P(BDMCUML(180),U,6)+1 G LDL
S V=$P(V,U)
S V=$$STV^BDMD118(V,5,1)
I V="" S $P(BDMCUML(180),U,7)=$P(BDMCUML(180),U,7)+1 G LDL
I $E(V)'=+$E(V)!(+V=0) S $P(BDMCUML(180),U,7)=$P(BDMCUML(180),U,7)+1 G LDL ;unable to determine result, not a number or is blank
I V<200 S $P(BDMCUML(180),U,3)=$P(BDMCUML(180),U,3)+1 G LDL
I V<240 S $P(BDMCUML(180),U,4)=$P(BDMCUML(180),U,4)+1 G LDL
S $P(BDMCUML(180),U,5)=$P(BDMCUML(180),U,5)+1
LDL ;
S:'$D(BDMCUML(190)) BDMCUML(190)="LDL Cholesterol obtained in the past 12 months"
S $P(BDMCUML(190),U,2)=$P(BDMCUML(190),U,2)+1
S V=$$LDL^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
I V="" S $P(BDMCUML(190),U,7)=$P(BDMCUML(190),U,7)+1 G HDL
S V=$P(V,U)
;S V=$$STV^BDMD118(V,4)
S V=$$STV^BDMD118(V,5,1) I $E(V)'=+$E(V)!(+V=0) S $P(BDMCUML(190),U,8)=$P(BDMCUML(190),U,8)+1 G HDL ;unable to determine result, not a number or blank
I V<100 S $P(BDMCUML(190),U,3)=$P(BDMCUML(190),U,3)+1 G HDL
I V<130 S $P(BDMCUML(190),U,4)=$P(BDMCUML(190),U,4)+1 G HDL
I V<160.1 S $P(BDMCUML(190),U,5)=$P(BDMCUML(190),U,5)+1 G HDL
S $P(BDMCUML(190),U,6)=$P(BDMCUML(190),U,6)+1
HDL ;
S:'$D(BDMCUML(195)) BDMCUML(195)="HDL Cholesterol obtained in the past 12 months"
S $P(BDMCUML(195),U,2)=$P(BDMCUML(195),U,2)+1
S V=$$HDL^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
I V="" S $P(BDMCUML(195),U,7)=$P(BDMCUML(195),U,7)+1 G TRIG
S V=$P(V,U)
S V=$$STV^BDMD118(V,5,1) I $E(V)'=+$E(V)!(+V=0) S $P(BDMCUML(195),U,8)=$P(BDMCUML(195),U,8)+1 G TRIG ;unable to determine result, not a number
S V=$P(V,"."),V=$$STV^BDMD118(V,5,1)
I $E(V)'=+$E(V)!(+V=0)!(V="") S $P(BDMCUML(195),U,8)=$P(BDMCUML(195),U,8)+1 G TRIG ;unable to determine result, not a number
I V<35 S $P(BDMCUML(195),U,3)=$P(BDMCUML(195),U,3)+1 G TRIG
I V<46 S $P(BDMCUML(195),U,4)=$P(BDMCUML(195),U,4)+1 G TRIG
I V<55.1 S $P(BDMCUML(195),U,5)=$P(BDMCUML(195),U,5)+1 G TRIG
S $P(BDMCUML(195),U,6)=$P(BDMCUML(195),U,6)+1
TRIG ;
S:'$D(BDMCUML(200)) BDMCUML(200)="Triglycerides obtained in past 12 months"
S $P(BDMCUML(200),U,2)=$P(BDMCUML(200),U,2)+1
S V=$$TRIG^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
I V="" S $P(BDMCUML(200),U,7)=$P(BDMCUML(200),U,7)+1 G SELF
S V=$P(V,U)
S V=$$STV^BDMD118(V,5,1) I $E(V)'=+$E(V) S $P(BDMCUML(200),U,8)=$P(BDMCUML(200),U,8)+1 G SELF ;unable to determine result, not a number
I V<150 S $P(BDMCUML(200),U,3)=$P(BDMCUML(200),U,3)+1 G SELF
I V<200 S $P(BDMCUML(200),U,4)=$P(BDMCUML(200),U,4)+1 G SELF
I V<401 S $P(BDMCUML(200),U,5)=$P(BDMCUML(200),U,5)+1 G SELF
S $P(BDMCUML(200),U,6)=$P(BDMCUML(200),U,6)+1
SELF ;
Q
PED(P,BDATE,EDATE) ;EP
K BDMALED
NEW Y,B,D,T,A,G,Z,V,X
S Y="BDMALED("
S X=P_"^ALL EDUC;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,Y)
I $D(BDMALED(1)) S %="" D I %]"" Q %
.S (X,D)=0,%="",T="" F S X=$O(BDMALED(X)) Q:X'=+X!(%]"") D
..S T=$P(^AUPNVPED(+$P(BDMALED(X),U,4),0),U)
..Q:'T
..Q:'$D(^AUTTEDT(T,0))
..S T=$P(^AUTTEDT(T,0),U,2)
..I $E(T,1,4)="TO-Q" S %="1 Yes-"_T_" "_$$FMTE^XLFDT($P(BDMALED(X),U),5) Q
..I T="TO-LA" S %="1 Yes-"_T_" "_$$FMTE^XLFDT($P(BDMALED(X),U),5) Q
K ^TMP($J,"A")
S A="^TMP($J,""A"",",B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
I '$D(^TMP($J,"A",1)) Q ""
S X=0,G="" F S X=$O(^TMP($J,"A",X)) Q:X'=+X!(G]"") S V=$P(^TMP($J,"A",X),U,5) D
.Q:'$D(^AUPNVSIT(V,0))
.Q:'$P(^AUPNVSIT(V,0),U,9)
.Q:$P(^AUPNVSIT(V,0),U,11)
.S B=$$CLINIC^APCLV(V,"C")
.I B=94 S G="1 Yes-"_$$FMTE^XLFDT($P($P(^AUPNVSIT(V,0),U),"."),5)_" CL 94" Q
.S Z=0 F S Z=$O(^AUPNVDEN("AD",V,Z)) Q:Z'=+Z!(G]"") S B=$P($G(^AUPNVDEN(Z,0)),U) I B S B=$P($G(^AUTTADA(B,0)),U) I B=1320 S G="1 Yes-"_$$FMTE^XLFDT($P($P(^AUPNVSIT(V,0),U),"."),5)_" ADA 1320" Q
.Q
Q G
CESS(P,BDATE,EDATE) ;EP - find any cessation hf in 12 months before E
I '$G(P) Q ""
I $P($$TOBACCO^BDMD11T(P,$$DOB^AUPNPAT(P),EDATE),U,1)'=1 Q ""
NEW BDM,E,X,G,T,O,D,H,C
K BDM
S T=$O(^ATXAX("B","DM AUDIT CESSATION HLTH FACTOR",0))
S C=$O(^AUTTHF("B","TOBACCO",0)) ;ien of category passed
I '$G(C) Q ""
S (H,D)=0 S O=""
S H=0 F S H=$O(^AUPNVHF("AA",P,H)) Q:H'=+H!(O]"") D
.S G=0
.I $D(^ATXAX(T,21,"AA",H)) S G=1
.I $P(^AUTTHF(H,0),U,1)["CESSATION",$$VAL^XBDIQ1(9999999.64,H,.03)="TOBACCO" S G=1
.S D="" F S D=$O(^AUPNVHF("AA",P,H,D)) Q:D'=+D!(O]"") D
..Q:(9999999-D)>EDATE ;after time frame
..Q:(9999999-D)<BDATE ;before time frame
..S O="1 Yes- "_$$FMTE^XLFDT(9999999-D)_" "_$P(^AUTTHF(H,0),U)
.Q
S X=P_"^EDUC [DM AUDIT SMOKING CESS EDUC;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BDM(")
I $D(BDM(1)) Q "1 Yes-"_$$FMTE^XLFDT($P(BDM(1),U),5)_" "_$P(BDM(1),U,3)
S BDM=$$PED(P,BDATE,EDATE)
I BDM]"" Q BDM
NEW T S T=$O(^ATXAX("B","DM AUDIT SMOKING CESS EDUC",0))
;I 'T Q "No"
S (X,G)=0
I T F S X=$O(^ATXAX(T,21,X)) Q:X'=+X!(G) S G=$$REFUSAL^BDMD117(P,9999999.09,$P(^ATXAX(T,21,X,0),U),BDATE,EDATE)
I G Q "3 Refused "_$P(G,U,6)_" "_$P(G,U,4)_" "_$P(G,U,3)_" "_$P(G,U,5)
S X=0,G="" F S X=$O(^AUTTEDT("C","TO-Q",X)) Q:X'=+X!(G) D
.S Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE) I $P(Y,U,1)=1 S G="3 Refused "_$P(Y,U,6)_" "_$P(Y,U,4)_" "_$P(Y,U,3)_" "_$P(Y,U,5)
I G Q G
S X=0,G="" F S X=$O(^AUTTEDT("C","TO-QT",X)) Q:X'=+X!(G) D
.S Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE) I $P(Y,U,1)=1 S G="3 Refused "_$P(Y,U,6)_" "_$P(Y,U,4)_" "_$P(Y,U,3)_" "_$P(Y,U,5)
I G Q G
S X=0,G="" F S X=$O(^AUTTEDT("C","TO-QU",X)) Q:X'=+X!(G) D
.S Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE) I $P(Y,U,1)=1 S G="3 Refused "_$P(Y,U,6)_" "_$P(Y,U,4)_" "_$P(Y,U,3)_" "_$P(Y,U,5)
I G Q G
S X=0,G="" F S X=$O(^AUTTEDT("C","TO-LA",X)) Q:X'=+X!(G) D
.S Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE) I $P(Y,U,1)=1 S G="3 Refused "_$P(Y,U,6)_" "_$P(Y,U,4)_" "_$P(Y,U,3)_" "_$P(Y,U,5)
I G Q G
Q "2 No"
;
BDMD111 ; IHS/CMI/LAB -IHS -CUMULATIVE REPORT ;
+1 ;;2.0;DIABETES MANAGEMENT SYSTEM;**4**;JUN 14, 2007
+2 ;
+3 ;
IMM ;
+1 IF '$DATA(BDMCUML(140))
SET BDMCUML(140)="IMMUNIZATIONS"
+2 SET $PIECE(BDMCUML(140),U,2)=$PIECE(BDMCUML(140),U,2)+1
+3 SET V=$GET(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,64))
+4 IF $EXTRACT(V)="1"
SET $PIECE(BDMCUML(140),U,3)=$PIECE(BDMCUML(140),U,3)+1
+5 IF $EXTRACT(V)="3"
SET $PIECE(BDMCUML(140),U,6)=$PIECE(BDMCUML(140),U,6)+1
+6 SET V=$GET(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,66))
+7 IF $EXTRACT(V)="1"
SET $PIECE(BDMCUML(140),U,4)=$PIECE(BDMCUML(140),U,4)+1
+8 IF $EXTRACT(V)="3"
SET $PIECE(BDMCUML(140),U,7)=$PIECE(BDMCUML(140),U,7)+1
+9 SET V=$GET(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,68))
+10 IF $EXTRACT(V)="1"
SET $PIECE(BDMCUML(140),U,5)=$PIECE(BDMCUML(140),U,5)+1
+11 IF $EXTRACT(V)="3"
SET $PIECE(BDMCUML(140),U,8)=$PIECE(BDMCUML(140),U,8)+1
+12 ;
QUAN ;
+1 ;145
+2 ;title^total pts^total YES^NO^REF^UACR^UPCR^24HR^MICRO STRIP^MICRO ONLY^DIPSTICK
+3 KILL BDMOFLG
+4 SET BDMOFLG=0
+5 IF '$DATA(BDMCUML(145))
SET BDMCUML(145)="LABORATORY EXAMS"
+6 ;TOTAL # of patients
SET $PIECE(BDMCUML(145),U,2)=$PIECE(BDMCUML(145),U,2)
+7 SET Q=$GET(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,92))
+8 ;test done?
SET V=$EXTRACT($GET(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,92)))
+9 ;type of test
SET T=$PIECE($GET(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,92)),U,5)
+10 ;value/result
SET R=$SELECT($PIECE(Q,U,6)]"":$PIECE(Q,U,6),1:$PIECE(Q,U,2))
+11 IF V=1
Begin DoDot:1
+12 SET $PIECE(BDMCUML(145),U,3)=$PIECE(BDMCUML(145),U,3)+1
+13 SET P=$SELECT(T=1:6,T=2:7,T=3:8,T=4:9,T=5:10,T=6:11,1:"")
+14 SET $PIECE(BDMCUML(145),U,P)=$PIECE(BDMCUML(145),U,P)+1
End DoDot:1
+15 ;.I T=1!(T=2)!(T=5) D
+16 ;..I T=5 D
+17 ;...S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1
+18 ;..I T=1 D
+19 ;...I R[">" S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
+20 ;...;I $$UP^XLFSTR(R)["COMMENT" S $P(BDMCUML(145),U,12)=$P(BDMCUML(145),U,12)+1 Q
+21 ;...S R=$$STV^BDMD118(R,8)
+22 ;...I R="" S $P(BDMCUML(145),U,15)=$P(BDMCUML(145),U,15)+1 Q
+23 ;...S R=+R
+24 ;...I R<30 S $P(BDMCUML(145),U,12)=$P(BDMCUML(145),U,12)+1 Q
+25 ;...I R<300.9999 S $P(BDMCUML(145),U,13)=$P(BDMCUML(145),U,13)+1 Q
+26 ;...S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1
+27 ;..I T=2 D
+28 ;...I R["-" S $P(BDMCUML(145),U,13)=$P(BDMCUML(145),U,13)+1 Q
+29 ;...I R["300" S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
+30 ;...I R[">" S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
+31 ;...S R=$$STV^BDMD118(R,5,1) I R>300 S $P(BDMCUML(145),U,14)=$P(BDMCUML(145),U,14)+1 Q
+32 ;...S $P(BDMCUML(145),U,12)=$P(BDMCUML(145),U,12)+1
+33 ;no urine testing
IF V=2
SET $PIECE(BDMCUML(145),U,4)=$PIECE(BDMCUML(145),U,4)+1
+34 ;refused urine testing
IF V=3
SET $PIECE(BDMCUML(145),U,5)=$PIECE(BDMCUML(145),U,5)+1
EKG ;need date of last ekg
+1 IF '$DATA(BDMCUML(150))
SET BDMCUML(150)="Electrocardiogram (Age 30 and above)"
+2 IF $$AGE^AUPNPAT(BDMPD,BDMADAT)<30
GOTO CREAT
+3 SET $PIECE(BDMCUML(150),U,2)=$PIECE(BDMCUML(150),U,2)+1
+4 SET V=$$EKG^BDMD112(BDMPD,BDMRED,"I")
+5 IF V]""
Begin DoDot:1
+6 SET E=$$FMDIFF^XLFDT(BDMADAT,V)
+7 IF E<(365.25*3)
SET $PIECE(BDMCUML(150),U,3)=$PIECE(BDMCUML(150),U,3)+1
+8 IF E<(365.25*5)
SET $PIECE(BDMCUML(150),U,4)=$PIECE(BDMCUML(150),U,4)+1
+9 SET $PIECE(BDMCUML(150),U,5)=$PIECE(BDMCUML(150),U,5)+1
End DoDot:1
CREAT ;
+1 IF '$DATA(BDMCUML(170))
SET BDMCUML(170)="Serum Creatinine obtained in the past 12 months"
+2 SET $PIECE(BDMCUML(170),U,2)=$PIECE(BDMCUML(170),U,2)+1
+3 SET V=$$CREAT^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
+4 IF V=""
SET $PIECE(BDMCUML(170),U,5)=$PIECE(BDMCUML(170),U,5)+1
GOTO GFR
+5 SET V=$PIECE(V,U)
+6 ;unable to determine result, not a number
SET V=$$STV^BDMD118(V,5,1)
IF $EXTRACT(V)'=+$EXTRACT(V)
IF $EXTRACT(V)'="."
SET $PIECE(BDMCUML(170),U,6)=$PIECE(BDMCUML(170),U,6)+1
GOTO GFR
+7 IF V>1.9
SET $PIECE(BDMCUML(170),U,3)=$PIECE(BDMCUML(170),U,3)+1
+8 IF V<2.0
SET $PIECE(BDMCUML(170),U,4)=$PIECE(BDMCUML(170),U,4)+1
+9 ;
GFR ;
+1 IF $$AGE^AUPNPAT(BDMPD,BDMADAT)<18
GOTO TCHOL
+2 IF '$DATA(BDMCUML(175))
SET BDMCUML(175)="Estimated GFR documented during audit period"
+3 SET $PIECE(BDMCUML(175),U,2)=$PIECE(BDMCUML(175),U,2)+1
+4 SET V=$EXTRACT($GET(^XTMP("BDMDM11",BDMJOB,BDMBTH,"AUDIT",BDMPD,79)))
+5 IF V=1
SET $PIECE(BDMCUML(175),U,5)=$PIECE(BDMCUML(175),U,5)+1
+6 ;
TCHOL ;
+1 IF '$DATA(BDMCUML(180))
SET BDMCUML(180)="Total Cholesterol obtained in past 12 months"
+2 SET $PIECE(BDMCUML(180),U,2)=$PIECE(BDMCUML(180),U,2)+1
+3 SET V=$$CHOL^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
+4 IF V=""
SET $PIECE(BDMCUML(180),U,6)=$PIECE(BDMCUML(180),U,6)+1
GOTO LDL
+5 SET V=$PIECE(V,U)
+6 SET V=$$STV^BDMD118(V,5,1)
+7 IF V=""
SET $PIECE(BDMCUML(180),U,7)=$PIECE(BDMCUML(180),U,7)+1
GOTO LDL
+8 ;unable to determine result, not a number or is blank
IF $EXTRACT(V)'=+$EXTRACT(V)!(+V=0)
SET $PIECE(BDMCUML(180),U,7)=$PIECE(BDMCUML(180),U,7)+1
GOTO LDL
+9 IF V<200
SET $PIECE(BDMCUML(180),U,3)=$PIECE(BDMCUML(180),U,3)+1
GOTO LDL
+10 IF V<240
SET $PIECE(BDMCUML(180),U,4)=$PIECE(BDMCUML(180),U,4)+1
GOTO LDL
+11 SET $PIECE(BDMCUML(180),U,5)=$PIECE(BDMCUML(180),U,5)+1
LDL ;
+1 IF '$DATA(BDMCUML(190))
SET BDMCUML(190)="LDL Cholesterol obtained in the past 12 months"
+2 SET $PIECE(BDMCUML(190),U,2)=$PIECE(BDMCUML(190),U,2)+1
+3 SET V=$$LDL^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
+4 IF V=""
SET $PIECE(BDMCUML(190),U,7)=$PIECE(BDMCUML(190),U,7)+1
GOTO HDL
+5 SET V=$PIECE(V,U)
+6 ;S V=$$STV^BDMD118(V,4)
+7 ;unable to determine result, not a number or blank
SET V=$$STV^BDMD118(V,5,1)
IF $EXTRACT(V)'=+$EXTRACT(V)!(+V=0)
SET $PIECE(BDMCUML(190),U,8)=$PIECE(BDMCUML(190),U,8)+1
GOTO HDL
+8 IF V<100
SET $PIECE(BDMCUML(190),U,3)=$PIECE(BDMCUML(190),U,3)+1
GOTO HDL
+9 IF V<130
SET $PIECE(BDMCUML(190),U,4)=$PIECE(BDMCUML(190),U,4)+1
GOTO HDL
+10 IF V<160.1
SET $PIECE(BDMCUML(190),U,5)=$PIECE(BDMCUML(190),U,5)+1
GOTO HDL
+11 SET $PIECE(BDMCUML(190),U,6)=$PIECE(BDMCUML(190),U,6)+1
HDL ;
+1 IF '$DATA(BDMCUML(195))
SET BDMCUML(195)="HDL Cholesterol obtained in the past 12 months"
+2 SET $PIECE(BDMCUML(195),U,2)=$PIECE(BDMCUML(195),U,2)+1
+3 SET V=$$HDL^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
+4 IF V=""
SET $PIECE(BDMCUML(195),U,7)=$PIECE(BDMCUML(195),U,7)+1
GOTO TRIG
+5 SET V=$PIECE(V,U)
+6 ;unable to determine result, not a number
SET V=$$STV^BDMD118(V,5,1)
IF $EXTRACT(V)'=+$EXTRACT(V)!(+V=0)
SET $PIECE(BDMCUML(195),U,8)=$PIECE(BDMCUML(195),U,8)+1
GOTO TRIG
+7 SET V=$PIECE(V,".")
SET V=$$STV^BDMD118(V,5,1)
+8 ;unable to determine result, not a number
IF $EXTRACT(V)'=+$EXTRACT(V)!(+V=0)!(V="")
SET $PIECE(BDMCUML(195),U,8)=$PIECE(BDMCUML(195),U,8)+1
GOTO TRIG
+9 IF V<35
SET $PIECE(BDMCUML(195),U,3)=$PIECE(BDMCUML(195),U,3)+1
GOTO TRIG
+10 IF V<46
SET $PIECE(BDMCUML(195),U,4)=$PIECE(BDMCUML(195),U,4)+1
GOTO TRIG
+11 IF V<55.1
SET $PIECE(BDMCUML(195),U,5)=$PIECE(BDMCUML(195),U,5)+1
GOTO TRIG
+12 SET $PIECE(BDMCUML(195),U,6)=$PIECE(BDMCUML(195),U,6)+1
TRIG ;
+1 IF '$DATA(BDMCUML(200))
SET BDMCUML(200)="Triglycerides obtained in past 12 months"
+2 SET $PIECE(BDMCUML(200),U,2)=$PIECE(BDMCUML(200),U,2)+1
+3 SET V=$$TRIG^BDMD118(BDMPD,BDMBDAT,BDMADAT,"I")
+4 IF V=""
SET $PIECE(BDMCUML(200),U,7)=$PIECE(BDMCUML(200),U,7)+1
GOTO SELF
+5 SET V=$PIECE(V,U)
+6 ;unable to determine result, not a number
SET V=$$STV^BDMD118(V,5,1)
IF $EXTRACT(V)'=+$EXTRACT(V)
SET $PIECE(BDMCUML(200),U,8)=$PIECE(BDMCUML(200),U,8)+1
GOTO SELF
+7 IF V<150
SET $PIECE(BDMCUML(200),U,3)=$PIECE(BDMCUML(200),U,3)+1
GOTO SELF
+8 IF V<200
SET $PIECE(BDMCUML(200),U,4)=$PIECE(BDMCUML(200),U,4)+1
GOTO SELF
+9 IF V<401
SET $PIECE(BDMCUML(200),U,5)=$PIECE(BDMCUML(200),U,5)+1
GOTO SELF
+10 SET $PIECE(BDMCUML(200),U,6)=$PIECE(BDMCUML(200),U,6)+1
SELF ;
+1 QUIT
PED(P,BDATE,EDATE) ;EP
+1 KILL BDMALED
+2 NEW Y,B,D,T,A,G,Z,V,X
+3 SET Y="BDMALED("
+4 SET X=P_"^ALL EDUC;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(X,Y)
+5 IF $DATA(BDMALED(1))
SET %=""
Begin DoDot:1
+6 SET (X,D)=0
SET %=""
SET T=""
FOR
SET X=$ORDER(BDMALED(X))
IF X'=+X!(%]"")
QUIT
Begin DoDot:2
+7 SET T=$PIECE(^AUPNVPED(+$PIECE(BDMALED(X),U,4),0),U)
+8 IF 'T
QUIT
+9 IF '$DATA(^AUTTEDT(T,0))
QUIT
+10 SET T=$PIECE(^AUTTEDT(T,0),U,2)
+11 IF $EXTRACT(T,1,4)="TO-Q"
SET %="1 Yes-"_T_" "_$$FMTE^XLFDT($PIECE(BDMALED(X),U),5)
QUIT
+12 IF T="TO-LA"
SET %="1 Yes-"_T_" "_$$FMTE^XLFDT($PIECE(BDMALED(X),U),5)
QUIT
End DoDot:2
End DoDot:1
IF %]""
QUIT %
+13 KILL ^TMP($JOB,"A")
+14 SET A="^TMP($J,""A"","
SET B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(B,A)
+15 IF '$DATA(^TMP($JOB,"A",1))
QUIT ""
+16 SET X=0
SET G=""
FOR
SET X=$ORDER(^TMP($JOB,"A",X))
IF X'=+X!(G]"")
QUIT
SET V=$PIECE(^TMP($JOB,"A",X),U,5)
Begin DoDot:1
+17 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+18 IF '$PIECE(^AUPNVSIT(V,0),U,9)
QUIT
+19 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+20 SET B=$$CLINIC^APCLV(V,"C")
+21 IF B=94
SET G="1 Yes-"_$$FMTE^XLFDT($PIECE($PIECE(^AUPNVSIT(V,0),U),"."),5)_" CL 94"
QUIT
+22 SET Z=0
FOR
SET Z=$ORDER(^AUPNVDEN("AD",V,Z))
IF Z'=+Z!(G]"")
QUIT
SET B=$PIECE($GET(^AUPNVDEN(Z,0)),U)
IF B
SET B=$PIECE($GET(^AUTTADA(B,0)),U)
IF B=1320
SET G="1 Yes-"_$$FMTE^XLFDT($PIECE($PIECE(^AUPNVSIT(V,0),U),"."),5)_" ADA 1320"
QUIT
+23 QUIT
End DoDot:1
+24 QUIT G
CESS(P,BDATE,EDATE) ;EP - find any cessation hf in 12 months before E
+1 IF '$GET(P)
QUIT ""
+2 IF $PIECE($$TOBACCO^BDMD11T(P,$$DOB^AUPNPAT(P),EDATE),U,1)'=1
QUIT ""
+3 NEW BDM,E,X,G,T,O,D,H,C
+4 KILL BDM
+5 SET T=$ORDER(^ATXAX("B","DM AUDIT CESSATION HLTH FACTOR",0))
+6 ;ien of category passed
SET C=$ORDER(^AUTTHF("B","TOBACCO",0))
+7 IF '$GET(C)
QUIT ""
+8 SET (H,D)=0
SET O=""
+9 SET H=0
FOR
SET H=$ORDER(^AUPNVHF("AA",P,H))
IF H'=+H!(O]"")
QUIT
Begin DoDot:1
+10 SET G=0
+11 IF $DATA(^ATXAX(T,21,"AA",H))
SET G=1
+12 IF $PIECE(^AUTTHF(H,0),U,1)["CESSATION"
IF $$VAL^XBDIQ1(9999999.64,H,.03)="TOBACCO"
SET G=1
+13 SET D=""
FOR
SET D=$ORDER(^AUPNVHF("AA",P,H,D))
IF D'=+D!(O]"")
QUIT
Begin DoDot:2
+14 ;after time frame
IF (9999999-D)>EDATE
QUIT
+15 ;before time frame
IF (9999999-D)<BDATE
QUIT
+16 SET O="1 Yes- "_$$FMTE^XLFDT(9999999-D)_" "_$PIECE(^AUTTHF(H,0),U)
End DoDot:2
+17 QUIT
End DoDot:1
+18 SET X=P_"^EDUC [DM AUDIT SMOKING CESS EDUC;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(X,"BDM(")
+19 IF $DATA(BDM(1))
QUIT "1 Yes-"_$$FMTE^XLFDT($PIECE(BDM(1),U),5)_" "_$PIECE(BDM(1),U,3)
+20 SET BDM=$$PED(P,BDATE,EDATE)
+21 IF BDM]""
QUIT BDM
+22 NEW T
SET T=$ORDER(^ATXAX("B","DM AUDIT SMOKING CESS EDUC",0))
+23 ;I 'T Q "No"
+24 SET (X,G)=0
+25 IF T
FOR
SET X=$ORDER(^ATXAX(T,21,X))
IF X'=+X!(G)
QUIT
SET G=$$REFUSAL^BDMD117(P,9999999.09,$PIECE(^ATXAX(T,21,X,0),U),BDATE,EDATE)
+26 IF G
QUIT "3 Refused "_$PIECE(G,U,6)_" "_$PIECE(G,U,4)_" "_$PIECE(G,U,3)_" "_$PIECE(G,U,5)
+27 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUTTEDT("C","TO-Q",X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+28 SET Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE)
IF $PIECE(Y,U,1)=1
SET G="3 Refused "_$PIECE(Y,U,6)_" "_$PIECE(Y,U,4)_" "_$PIECE(Y,U,3)_" "_$PIECE(Y,U,5)
End DoDot:1
+29 IF G
QUIT G
+30 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUTTEDT("C","TO-QT",X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+31 SET Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE)
IF $PIECE(Y,U,1)=1
SET G="3 Refused "_$PIECE(Y,U,6)_" "_$PIECE(Y,U,4)_" "_$PIECE(Y,U,3)_" "_$PIECE(Y,U,5)
End DoDot:1
+32 IF G
QUIT G
+33 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUTTEDT("C","TO-QU",X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+34 SET Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE)
IF $PIECE(Y,U,1)=1
SET G="3 Refused "_$PIECE(Y,U,6)_" "_$PIECE(Y,U,4)_" "_$PIECE(Y,U,3)_" "_$PIECE(Y,U,5)
End DoDot:1
+35 IF G
QUIT G
+36 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUTTEDT("C","TO-LA",X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+37 SET Y=$$REFUSAL^BDMD117(P,9999999.09,X,BDATE,EDATE)
IF $PIECE(Y,U,1)=1
SET G="3 Refused "_$PIECE(Y,U,6)_" "_$PIECE(Y,U,4)_" "_$PIECE(Y,U,3)_" "_$PIECE(Y,U,5)
End DoDot:1
+38 IF G
QUIT G
+39 QUIT "2 No"
+40 ;