BDMD995 ; IHS/CMI/LAB -IHS -CUMULATIVE REPORT ;
;;2.0;DIABETES MANAGEMENT SYSTEM;**2**;JUN 14, 2007
;
;
CUML ;EP
K BDMCUML
S BDMPD=0 F S BDMPD=$O(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD)) Q:BDMPD'=+BDMPD D CUML1
Q
;
CUML1 ;
GENDER ;
;gender BDMCUML(10)="Gender^total^females^males"
S:'$D(BDMCUML(10)) BDMCUML(10)="Gender"
S $P(BDMCUML(10),U,2)=$P(BDMCUML(10),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,20))
S P=$S($E(V)="F":3,$E(V)="M":4,1:5)
S $P(BDMCUML(10),U,P)=$P(BDMCUML(10),U,P)+1
AGE ;
S V=$$AGE^AUPNPAT(BDMPD,BDMADAT)
;BDMCUML(20)="Age^total^<15^15-44^45-64^>65^unknown"
I '$D(BDMCUML(20)) S BDMCUML(20)="Age"
S $P(BDMCUML(20),U,2)=$P(BDMCUML(20),U,2)+1
S P=$S(V<15:3,V>14&(V<45):4,V>44&(V<65):5,V>64:6,1:7)
S $P(BDMCUML(20),U,P)=$P(BDMCUML(20),U,P)+1
DURDMC ;
;BDMCUML(30)="Duration of Diabetes^total^<10^10 or more^do date of dx on problem list or cms register"
I '$D(BDMCUML(30)) S BDMCUML(30)="Duration of Diabetes"
S $P(BDMCUML(30),U,2)=$P(BDMCUML(30),U,2)+1
S V=$$DURDM^BDMD994(BDMPD,BDMDMRG,BDMADAT,"I")
S P=$S(V="":5,V<10:3,V>9:4,1:5)
S $P(BDMCUML(30),U,P)=$P(BDMCUML(30),U,P)+1
BMI ;
;BDMCUML(40)="Weight Control (BMI) - does not add up to 100%^total^total^overweight^obese^height or weight missing"
S:'$D(BDMCUML(40)) BDMCUML(40)="Weight Control (BMI) - does not add up to 100%"
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,112))
S $P(BDMCUML(40),U,2)=$P(BDMCUML(40),U,2)+1
D
.I V="" S $P(BDMCUML(40),U,5)=$P(BDMCUML(40),U,5)+1 Q
.I $$OW^BDMD994(BDMPD,V,BDMADAT) S $P(BDMCUML(40),U,3)=$P(BDMCUML(40),U,3)+1
.I $$OB^BDMD994(BDMPD,V,BDMADAT) S $P(BDMCUML(40),U,4)=$P(BDMCUML(40),U,4)+1
HGB ;
;use last hgba1c value only
;BDMCUML(50)=
S:'$D(BDMCUML(50)) BDMCUML(50)="Blood Sugar Control - uses last HGB A1C value"
S $P(BDMCUML(50),U,2)=$P(BDMCUML(50),U,2)+1
S V=$P($G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,78)),U)
S P=$S(V="":9,V<7.0:3,V>6.9&(V<8.0):4,V>7.9&(V<9.0):5,V>8.9&(V<10.0):6,V<11.0&(V>9.9):7,V>10.9:8,1:9)
S $P(BDMCUML(50),U,P)=$P(BDMCUML(50),U,P)+1
BPC ;blood pressure control
;take last 3 bp's and get mean systolic and mean diastolic
S:'$D(BDMCUML(60)) BDMCUML(60)="Blood Pressure Control - based on mean of last 3 bp's"
S $P(BDMCUML(60),U,2)=$P(BDMCUML(60),U,2)+1
S S=$$SYSMEAN(BDMPD,BDMRBD,BDMRED)
S D=$$DIAMEAN(BDMPD,BDMRBD,BDMRED)
D
.I S=""!(D="") S $P(BDMCUML(60),U,8)=$P(BDMCUML(60),U,8)+1 Q
.I S<120&(D<80) S $P(BDMCUML(60),U,3)=$P(BDMCUML(60),U,3)+1 Q
.I S<131&(D<86) S $P(BDMCUML(60),U,4)=$P(BDMCUML(60),U,4)+1 Q
.I S<141&(D<91) S $P(BDMCUML(60),U,5)=$P(BDMCUML(60),U,5)+1 Q
.I S<161&(D<96) S $P(BDMCUML(60),U,6)=$P(BDMCUML(60),U,6)+1 Q
.S $P(BDMCUML(60),U,7)=$P(BDMCUML(60),U,7)+1
TBSTAT ;
S:'$D(BDMCUML(70)) BDMCUML(70)="Tuberculosis Status"
S $P(BDMCUML(70),U,2)=$P(BDMCUML(70),U,2)+1
S V=$$TBCODE^BDMD996(BDMPD,BDMRED,BDMDMRG)
S $P(BDMCUML(70),U,(V+2))=$P(BDMCUML(70),U,(V+2))+1
TOBACCO ;
S:'$D(BDMCUML(80)) BDMCUML(80)="Tobacco use"
S $P(BDMCUML(80),U,2)=$P(BDMCUML(80),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,27))
S V1=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,28))
I +V=1 S $P(BDMCUML(80),U,3)=$P(BDMCUML(80),U,3)+1 S P=$S($E(V1)="Y":4,$E(V1)="N":5,1:5) S $P(BDMCUML(80),U,P)=$P(BDMCUML(80),U,P)+1
I +V=2 S $P(BDMCUML(80),U,6)=$P(BDMCUML(80),U,6)+1
I +V=3 S $P(BDMCUML(80),U,7)=$P(BDMCUML(80),U,7)+1
I +V=4 S $P(BDMCUML(80),U,8)=$P(BDMCUML(80),U,8)+1
DMTX ;diabetes treatment
S BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31)),BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
S:'$D(BDMCUML(90)) BDMCUML(90)="DIABETES TREATMENT"
S $P(BDMCUML(90),U,2)=$P(BDMCUML(90),U,2)+1
S V=$$THERAPY^BDMD996(BDMPD,BDM6MBD,BDMRED)
I V=1 S $P(BDMCUML(90),U,3)=$P(BDMCUML(90),U,3)+1
I $L(V)=1 S P=$S(V=2:4,V=3:5,V=4:6,V=5:7,V=6:8,1:"") S $P(BDMCUML(90),U,P)=$P(BDMCUML(90),U,P)+1
I $L(V)>1,V["2" S $P(BDMCUML(90),U,10)=$P(BDMCUML(90),U,10)+1
I $L(V)>1,V'[2 S $P(BDMCUML(90),U,9)=$P(BDMCUML(90),U,9)+1
ASPIRIN ;
S:'$D(BDMCUML(100)) BDMCUML(100)="DAILY LOW-DOSE ASPIRIN THERAPY"
S $P(BDMCUML(100),U,2)=$P(BDMCUML(100),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,62))
S P=$S($E(V)="Y":3,1:4)
S $P(BDMCUML(100),U,P)=$P(BDMCUML(100),U,P)+1
EXAMS ;
S:'$D(BDMCUML(120)) BDMCUML(120)="EXAMS - Yearly"
S $P(BDMCUML(120),U,2)=$P(BDMCUML(120),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,38))
I $E(V)="Y" S $P(BDMCUML(120),U,3)=$P(BDMCUML(120),U,3)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,40))
I $E(V)="Y" S $P(BDMCUML(120),U,4)=$P(BDMCUML(120),U,4)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,42))
I $E(V)="Y" S $P(BDMCUML(120),U,5)=$P(BDMCUML(120),U,5)+1
EDUC ;
S:'$D(BDMCUML(130)) BDMCUML(130)="DIABETES-RELATED EDUCATION - Yearly"
S $P(BDMCUML(130),U,2)=$P(BDMCUML(130),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,44))
I $E(V)'="N" S $P(BDMCUML(130),U,3)=$P(BDMCUML(130),U,3)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,46))
I $E(V)="Y" S $P(BDMCUML(130),U,4)=$P(BDMCUML(130),U,4)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,48))
I $E(V)="Y" S $P(BDMCUML(130),U,5)=$P(BDMCUML(130),U,5)+1
IMM ;
S:'$D(BDMCUML(140)) BDMCUML(140)="IMMUNIZATIONS"
S $P(BDMCUML(140),U,2)=$P(BDMCUML(140),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,64))
I $E(V)="Y" S $P(BDMCUML(140),U,3)=$P(BDMCUML(140),U,3)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,66))
I $E(V)="Y" S $P(BDMCUML(140),U,4)=$P(BDMCUML(140),U,4)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,68))
I $E(V)="Y" S $P(BDMCUML(140),U,5)=$P(BDMCUML(140),U,5)+1
EKG ;need date of last ekg
S:'$D(BDMCUML(150)) BDMCUML(150)="EKG"
S $P(BDMCUML(150),U,2)=$P(BDMCUML(150),U,2)+1
S V=$$EKG^BDMD998(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 Q
.I E<(365.25*5) S $P(BDMCUML(150),U,4)=$P(BDMCUML(150),U,4)+1 Q
.S $P(BDMCUML(150),U,5)=$P(BDMCUML(150),U,5)+1
CREAT ;
S:'$D(BDMCUML(170)) BDMCUML(170)="Creatinine obtained in the past 12 months"
S $P(BDMCUML(170),U,2)=$P(BDMCUML(170),U,2)+1
S V=$$CREAT^BDMD998(BDMPD,BDMRBD,BDMRED,"I"),V=$P(V,U)
I V="" S $P(BDMCUML(170),U,5)=$P(BDMCUML(170),U,5)+1 G TCHOL
I V'=+V S $P(BDMCUML(170),U,6)=$P(BDMCUML(170),U,6)+1 G TCHOL ;unable to determine result
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
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^BDMD998(BDMPD,BDMRBD,BDMRED,"I"),V=$P(V,U)
I V="" S $P(BDMCUML(180),U,6)=$P(BDMCUML(180),U,6)+1 G LDL
I V'=+V S $P(BDMCUML(180),U,7)=$P(BDMCUML(180),U,7)+1 G LDL ;unable to determine result
I V<200 S $P(BDMCUML(180),U,3)=$P(BDMCUML(180),U,3)+1
I V<240&(V>199) S $P(BDMCUML(180),U,4)=$P(BDMCUML(180),U,4)+1
I V>239 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^BDMD998(BDMPD,BDMRBD,BDMRED,"I"),V=$P(V,U)
I V="" S $P(BDMCUML(190),U,7)=$P(BDMCUML(190),U,7)+1 G TRIG
I V'=+V S $P(BDMCUML(190),U,8)=$P(BDMCUML(190),U,8)+1 G TRIG ;unable to determine result
I V<100 S $P(BDMCUML(190),U,3)=$P(BDMCUML(190),U,3)+1
I V<130&(V>99) S $P(BDMCUML(190),U,4)=$P(BDMCUML(190),U,4)+1
I V>129&(V<161) S $P(BDMCUML(190),U,5)=$P(BDMCUML(190),U,5)+1
I V>160 S $P(BDMCUML(190),U,6)=$P(BDMCUML(190),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^BDMD998(BDMPD,BDMRBD,BDMRED,"I"),V=$P(V,U)
I V="" S $P(BDMCUML(200),U,7)=$P(BDMCUML(200),U,7)+1 G SELF
I V'=+V S $P(BDMCUML(200),U,8)=$P(BDMCUML(200),U,8)+1 G SELF ;unable to determine result
I V<150 S $P(BDMCUML(200),U,3)=$P(BDMCUML(200),U,3)+1
I V<200&(V>149) S $P(BDMCUML(200),U,4)=$P(BDMCUML(200),U,4)+1
I V>199&(V<401) S $P(BDMCUML(200),U,5)=$P(BDMCUML(200),U,5)+1
I V>400 S $P(BDMCUML(200),U,6)=$P(BDMCUML(200),U,6)+1
SELF ;
S:'$D(BDMCUML(210)) BDMCUML(210)="Self monitoring of blood glucose documented"
S $P(BDMCUML(210),U,2)=$P(BDMCUML(210),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,98))
S P=$S($E(V)="Y":3,1:4)
S $P(BDMCUML(210),U,P)=$P(BDMCUML(210),U,P)+1
SDM ;
S:'$D(BDMCUML(220)) BDMCUML(220)="Participating in SDM"
S $P(BDMCUML(220),U,2)=$P(BDMCUML(220),U,2)+1
S V=$G(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,100))
S P=$S($E(V)="Y":3,1:4)
S $P(BDMCUML(220),U,P)=$P(BDMCUML(220),U,P)+1
Q
SYSMEAN(P,BDATE,EDATE) ;EP
NEW X S X=$$BPS^BDMD997(P,BDATE,EDATE,"I")
I X="" Q ""
NEW Y,C S C=0 F Y=1:1:3 I $P(X,";",Y)]"" S C=C+1
I C'=3 Q ""
S C=0 F Y=1:1:3 S C=$P($P(X,";",Y),"/")+C
Q C\3
Q ""
DIAMEAN(P,BDATE,EDATE) ;EP
NEW X S X=$$BPS^BDMD997(P,BDATE,EDATE,"I")
I X="" Q ""
NEW Y,C S C=0 F Y=1:1:3 I $P(X,";",Y)]"" S C=C+1
I C'=3 Q ""
S C=0 F Y=1:1:3 S C=$P($P(X,";",Y),"/",2)+C
Q C\3
BDMD995 ; IHS/CMI/LAB -IHS -CUMULATIVE REPORT ;
+1 ;;2.0;DIABETES MANAGEMENT SYSTEM;**2**;JUN 14, 2007
+2 ;
+3 ;
CUML ;EP
+1 KILL BDMCUML
+2 SET BDMPD=0
FOR
SET BDMPD=$ORDER(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD))
IF BDMPD'=+BDMPD
QUIT
DO CUML1
+3 QUIT
+4 ;
CUML1 ;
GENDER ;
+1 ;gender BDMCUML(10)="Gender^total^females^males"
+2 IF '$DATA(BDMCUML(10))
SET BDMCUML(10)="Gender"
+3 SET $PIECE(BDMCUML(10),U,2)=$PIECE(BDMCUML(10),U,2)+1
+4 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,20))
+5 SET P=$SELECT($EXTRACT(V)="F":3,$EXTRACT(V)="M":4,1:5)
+6 SET $PIECE(BDMCUML(10),U,P)=$PIECE(BDMCUML(10),U,P)+1
AGE ;
+1 SET V=$$AGE^AUPNPAT(BDMPD,BDMADAT)
+2 ;BDMCUML(20)="Age^total^<15^15-44^45-64^>65^unknown"
+3 IF '$DATA(BDMCUML(20))
SET BDMCUML(20)="Age"
+4 SET $PIECE(BDMCUML(20),U,2)=$PIECE(BDMCUML(20),U,2)+1
+5 SET P=$SELECT(V<15:3,V>14&(V<45):4,V>44&(V<65):5,V>64:6,1:7)
+6 SET $PIECE(BDMCUML(20),U,P)=$PIECE(BDMCUML(20),U,P)+1
DURDMC ;
+1 ;BDMCUML(30)="Duration of Diabetes^total^<10^10 or more^do date of dx on problem list or cms register"
+2 IF '$DATA(BDMCUML(30))
SET BDMCUML(30)="Duration of Diabetes"
+3 SET $PIECE(BDMCUML(30),U,2)=$PIECE(BDMCUML(30),U,2)+1
+4 SET V=$$DURDM^BDMD994(BDMPD,BDMDMRG,BDMADAT,"I")
+5 SET P=$SELECT(V="":5,V<10:3,V>9:4,1:5)
+6 SET $PIECE(BDMCUML(30),U,P)=$PIECE(BDMCUML(30),U,P)+1
BMI ;
+1 ;BDMCUML(40)="Weight Control (BMI) - does not add up to 100%^total^total^overweight^obese^height or weight missing"
+2 IF '$DATA(BDMCUML(40))
SET BDMCUML(40)="Weight Control (BMI) - does not add up to 100%"
+3 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,112))
+4 SET $PIECE(BDMCUML(40),U,2)=$PIECE(BDMCUML(40),U,2)+1
+5 Begin DoDot:1
+6 IF V=""
SET $PIECE(BDMCUML(40),U,5)=$PIECE(BDMCUML(40),U,5)+1
QUIT
+7 IF $$OW^BDMD994(BDMPD,V,BDMADAT)
SET $PIECE(BDMCUML(40),U,3)=$PIECE(BDMCUML(40),U,3)+1
+8 IF $$OB^BDMD994(BDMPD,V,BDMADAT)
SET $PIECE(BDMCUML(40),U,4)=$PIECE(BDMCUML(40),U,4)+1
End DoDot:1
HGB ;
+1 ;use last hgba1c value only
+2 ;BDMCUML(50)=
+3 IF '$DATA(BDMCUML(50))
SET BDMCUML(50)="Blood Sugar Control - uses last HGB A1C value"
+4 SET $PIECE(BDMCUML(50),U,2)=$PIECE(BDMCUML(50),U,2)+1
+5 SET V=$PIECE($GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,78)),U)
+6 SET P=$SELECT(V="":9,V<7.0:3,V>6.9&(V<8.0):4,V>7.9&(V<9.0):5,V>8.9&(V<10.0):6,V<11.0&(V>9.9):7,V>10.9:8,1:9)
+7 SET $PIECE(BDMCUML(50),U,P)=$PIECE(BDMCUML(50),U,P)+1
BPC ;blood pressure control
+1 ;take last 3 bp's and get mean systolic and mean diastolic
+2 IF '$DATA(BDMCUML(60))
SET BDMCUML(60)="Blood Pressure Control - based on mean of last 3 bp's"
+3 SET $PIECE(BDMCUML(60),U,2)=$PIECE(BDMCUML(60),U,2)+1
+4 SET S=$$SYSMEAN(BDMPD,BDMRBD,BDMRED)
+5 SET D=$$DIAMEAN(BDMPD,BDMRBD,BDMRED)
+6 Begin DoDot:1
+7 IF S=""!(D="")
SET $PIECE(BDMCUML(60),U,8)=$PIECE(BDMCUML(60),U,8)+1
QUIT
+8 IF S<120&(D<80)
SET $PIECE(BDMCUML(60),U,3)=$PIECE(BDMCUML(60),U,3)+1
QUIT
+9 IF S<131&(D<86)
SET $PIECE(BDMCUML(60),U,4)=$PIECE(BDMCUML(60),U,4)+1
QUIT
+10 IF S<141&(D<91)
SET $PIECE(BDMCUML(60),U,5)=$PIECE(BDMCUML(60),U,5)+1
QUIT
+11 IF S<161&(D<96)
SET $PIECE(BDMCUML(60),U,6)=$PIECE(BDMCUML(60),U,6)+1
QUIT
+12 SET $PIECE(BDMCUML(60),U,7)=$PIECE(BDMCUML(60),U,7)+1
End DoDot:1
TBSTAT ;
+1 IF '$DATA(BDMCUML(70))
SET BDMCUML(70)="Tuberculosis Status"
+2 SET $PIECE(BDMCUML(70),U,2)=$PIECE(BDMCUML(70),U,2)+1
+3 SET V=$$TBCODE^BDMD996(BDMPD,BDMRED,BDMDMRG)
+4 SET $PIECE(BDMCUML(70),U,(V+2))=$PIECE(BDMCUML(70),U,(V+2))+1
TOBACCO ;
+1 IF '$DATA(BDMCUML(80))
SET BDMCUML(80)="Tobacco use"
+2 SET $PIECE(BDMCUML(80),U,2)=$PIECE(BDMCUML(80),U,2)+1
+3 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,27))
+4 SET V1=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,28))
+5 IF +V=1
SET $PIECE(BDMCUML(80),U,3)=$PIECE(BDMCUML(80),U,3)+1
SET P=$SELECT($EXTRACT(V1)="Y":4,$EXTRACT(V1)="N":5,1:5)
SET $PIECE(BDMCUML(80),U,P)=$PIECE(BDMCUML(80),U,P)+1
+6 IF +V=2
SET $PIECE(BDMCUML(80),U,6)=$PIECE(BDMCUML(80),U,6)+1
+7 IF +V=3
SET $PIECE(BDMCUML(80),U,7)=$PIECE(BDMCUML(80),U,7)+1
+8 IF +V=4
SET $PIECE(BDMCUML(80),U,8)=$PIECE(BDMCUML(80),U,8)+1
DMTX ;diabetes treatment
+1 SET BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31))
SET BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
+2 IF '$DATA(BDMCUML(90))
SET BDMCUML(90)="DIABETES TREATMENT"
+3 SET $PIECE(BDMCUML(90),U,2)=$PIECE(BDMCUML(90),U,2)+1
+4 SET V=$$THERAPY^BDMD996(BDMPD,BDM6MBD,BDMRED)
+5 IF V=1
SET $PIECE(BDMCUML(90),U,3)=$PIECE(BDMCUML(90),U,3)+1
+6 IF $LENGTH(V)=1
SET P=$SELECT(V=2:4,V=3:5,V=4:6,V=5:7,V=6:8,1:"")
SET $PIECE(BDMCUML(90),U,P)=$PIECE(BDMCUML(90),U,P)+1
+7 IF $LENGTH(V)>1
IF V["2"
SET $PIECE(BDMCUML(90),U,10)=$PIECE(BDMCUML(90),U,10)+1
+8 IF $LENGTH(V)>1
IF V'[2
SET $PIECE(BDMCUML(90),U,9)=$PIECE(BDMCUML(90),U,9)+1
ASPIRIN ;
+1 IF '$DATA(BDMCUML(100))
SET BDMCUML(100)="DAILY LOW-DOSE ASPIRIN THERAPY"
+2 SET $PIECE(BDMCUML(100),U,2)=$PIECE(BDMCUML(100),U,2)+1
+3 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,62))
+4 SET P=$SELECT($EXTRACT(V)="Y":3,1:4)
+5 SET $PIECE(BDMCUML(100),U,P)=$PIECE(BDMCUML(100),U,P)+1
EXAMS ;
+1 IF '$DATA(BDMCUML(120))
SET BDMCUML(120)="EXAMS - Yearly"
+2 SET $PIECE(BDMCUML(120),U,2)=$PIECE(BDMCUML(120),U,2)+1
+3 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,38))
+4 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(120),U,3)=$PIECE(BDMCUML(120),U,3)+1
+5 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,40))
+6 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(120),U,4)=$PIECE(BDMCUML(120),U,4)+1
+7 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,42))
+8 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(120),U,5)=$PIECE(BDMCUML(120),U,5)+1
EDUC ;
+1 IF '$DATA(BDMCUML(130))
SET BDMCUML(130)="DIABETES-RELATED EDUCATION - Yearly"
+2 SET $PIECE(BDMCUML(130),U,2)=$PIECE(BDMCUML(130),U,2)+1
+3 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,44))
+4 IF $EXTRACT(V)'="N"
SET $PIECE(BDMCUML(130),U,3)=$PIECE(BDMCUML(130),U,3)+1
+5 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,46))
+6 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(130),U,4)=$PIECE(BDMCUML(130),U,4)+1
+7 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,48))
+8 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(130),U,5)=$PIECE(BDMCUML(130),U,5)+1
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("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,64))
+4 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(140),U,3)=$PIECE(BDMCUML(140),U,3)+1
+5 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,66))
+6 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(140),U,4)=$PIECE(BDMCUML(140),U,4)+1
+7 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,68))
+8 IF $EXTRACT(V)="Y"
SET $PIECE(BDMCUML(140),U,5)=$PIECE(BDMCUML(140),U,5)+1
EKG ;need date of last ekg
+1 IF '$DATA(BDMCUML(150))
SET BDMCUML(150)="EKG"
+2 SET $PIECE(BDMCUML(150),U,2)=$PIECE(BDMCUML(150),U,2)+1
+3 SET V=$$EKG^BDMD998(BDMPD,BDMRED,"I")
+4 IF V]""
Begin DoDot:1
+5 SET E=$$FMDIFF^XLFDT(BDMADAT,V)
+6 IF E<(365.25*3)
SET $PIECE(BDMCUML(150),U,3)=$PIECE(BDMCUML(150),U,3)+1
QUIT
+7 IF E<(365.25*5)
SET $PIECE(BDMCUML(150),U,4)=$PIECE(BDMCUML(150),U,4)+1
QUIT
+8 SET $PIECE(BDMCUML(150),U,5)=$PIECE(BDMCUML(150),U,5)+1
End DoDot:1
CREAT ;
+1 IF '$DATA(BDMCUML(170))
SET BDMCUML(170)="Creatinine obtained in the past 12 months"
+2 SET $PIECE(BDMCUML(170),U,2)=$PIECE(BDMCUML(170),U,2)+1
+3 SET V=$$CREAT^BDMD998(BDMPD,BDMRBD,BDMRED,"I")
SET V=$PIECE(V,U)
+4 IF V=""
SET $PIECE(BDMCUML(170),U,5)=$PIECE(BDMCUML(170),U,5)+1
GOTO TCHOL
+5 ;unable to determine result
IF V'=+V
SET $PIECE(BDMCUML(170),U,6)=$PIECE(BDMCUML(170),U,6)+1
GOTO TCHOL
+6 IF V>1.9
SET $PIECE(BDMCUML(170),U,3)=$PIECE(BDMCUML(170),U,3)+1
+7 IF V<2.0
SET $PIECE(BDMCUML(170),U,4)=$PIECE(BDMCUML(170),U,4)+1
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^BDMD998(BDMPD,BDMRBD,BDMRED,"I")
SET V=$PIECE(V,U)
+4 IF V=""
SET $PIECE(BDMCUML(180),U,6)=$PIECE(BDMCUML(180),U,6)+1
GOTO LDL
+5 ;unable to determine result
IF V'=+V
SET $PIECE(BDMCUML(180),U,7)=$PIECE(BDMCUML(180),U,7)+1
GOTO LDL
+6 IF V<200
SET $PIECE(BDMCUML(180),U,3)=$PIECE(BDMCUML(180),U,3)+1
+7 IF V<240&(V>199)
SET $PIECE(BDMCUML(180),U,4)=$PIECE(BDMCUML(180),U,4)+1
+8 IF V>239
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^BDMD998(BDMPD,BDMRBD,BDMRED,"I")
SET V=$PIECE(V,U)
+4 IF V=""
SET $PIECE(BDMCUML(190),U,7)=$PIECE(BDMCUML(190),U,7)+1
GOTO TRIG
+5 ;unable to determine result
IF V'=+V
SET $PIECE(BDMCUML(190),U,8)=$PIECE(BDMCUML(190),U,8)+1
GOTO TRIG
+6 IF V<100
SET $PIECE(BDMCUML(190),U,3)=$PIECE(BDMCUML(190),U,3)+1
+7 IF V<130&(V>99)
SET $PIECE(BDMCUML(190),U,4)=$PIECE(BDMCUML(190),U,4)+1
+8 IF V>129&(V<161)
SET $PIECE(BDMCUML(190),U,5)=$PIECE(BDMCUML(190),U,5)+1
+9 IF V>160
SET $PIECE(BDMCUML(190),U,6)=$PIECE(BDMCUML(190),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^BDMD998(BDMPD,BDMRBD,BDMRED,"I")
SET V=$PIECE(V,U)
+4 IF V=""
SET $PIECE(BDMCUML(200),U,7)=$PIECE(BDMCUML(200),U,7)+1
GOTO SELF
+5 ;unable to determine result
IF V'=+V
SET $PIECE(BDMCUML(200),U,8)=$PIECE(BDMCUML(200),U,8)+1
GOTO SELF
+6 IF V<150
SET $PIECE(BDMCUML(200),U,3)=$PIECE(BDMCUML(200),U,3)+1
+7 IF V<200&(V>149)
SET $PIECE(BDMCUML(200),U,4)=$PIECE(BDMCUML(200),U,4)+1
+8 IF V>199&(V<401)
SET $PIECE(BDMCUML(200),U,5)=$PIECE(BDMCUML(200),U,5)+1
+9 IF V>400
SET $PIECE(BDMCUML(200),U,6)=$PIECE(BDMCUML(200),U,6)+1
SELF ;
+1 IF '$DATA(BDMCUML(210))
SET BDMCUML(210)="Self monitoring of blood glucose documented"
+2 SET $PIECE(BDMCUML(210),U,2)=$PIECE(BDMCUML(210),U,2)+1
+3 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,98))
+4 SET P=$SELECT($EXTRACT(V)="Y":3,1:4)
+5 SET $PIECE(BDMCUML(210),U,P)=$PIECE(BDMCUML(210),U,P)+1
SDM ;
+1 IF '$DATA(BDMCUML(220))
SET BDMCUML(220)="Participating in SDM"
+2 SET $PIECE(BDMCUML(220),U,2)=$PIECE(BDMCUML(220),U,2)+1
+3 SET V=$GET(^XTMP("BDMDM99",BDMJOB,BDMBTH,"AUDIT",BDMPD,100))
+4 SET P=$SELECT($EXTRACT(V)="Y":3,1:4)
+5 SET $PIECE(BDMCUML(220),U,P)=$PIECE(BDMCUML(220),U,P)+1
+6 QUIT
SYSMEAN(P,BDATE,EDATE) ;EP
+1 NEW X
SET X=$$BPS^BDMD997(P,BDATE,EDATE,"I")
+2 IF X=""
QUIT ""
+3 NEW Y,C
SET C=0
FOR Y=1:1:3
IF $PIECE(X,";",Y)]""
SET C=C+1
+4 IF C'=3
QUIT ""
+5 SET C=0
FOR Y=1:1:3
SET C=$PIECE($PIECE(X,";",Y),"/")+C
+6 QUIT C\3
+7 QUIT ""
DIAMEAN(P,BDATE,EDATE) ;EP
+1 NEW X
SET X=$$BPS^BDMD997(P,BDATE,EDATE,"I")
+2 IF X=""
QUIT ""
+3 NEW Y,C
SET C=0
FOR Y=1:1:3
IF $PIECE(X,";",Y)]""
SET C=C+1
+4 IF C'=3
QUIT ""
+5 SET C=0
FOR Y=1:1:3
SET C=$PIECE($PIECE(X,";",Y),"/",2)+C
+6 QUIT C\3