Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BDMDE15

BDMDE15.m

Go to the documentation of this file.
BDMDE15 ; IHS/CMI/LAB -IHS -CUMULATIVE REPORT 03 Feb 2014 5:38 PM ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**10,11**;JUN 14, 2007;Build 30
 ;
 ;
CUML ;EP
 K BDMCUML
 S BDMCUML(10)="Gender"
 S BDMCUML(20)="Age"
 S BDMCUML(25)="Diabetes Type"
 S BDMCUML(30)="Duration of Diabetes"
 S BDMCUML(40)="BMI Category"
 S BDMCUML(50)="Blood Sugar Control"
 S BDMCUML(70)="Tuberculosis Status"
 S BDMCUML(60)="Blood Pressure (BP) - Based on one value or mean of two or three values"
 S BDMCUML(65)="Tobacco use screening during Audit period:"
 S BDMCUML(69)=""
 S BDMCUML(80)="Tobacco use status:"
 S BDMCUML(90)="Diabetes Treatment"
 S BDMCUML(100)="Aspirin or Other Antiplatelet/Anticoagulant Therapy Prescribed"
 S BDMCUML(110)="ACE Inhibitor or ARB Prescribed"
 S BDMCUML(115)="Statin Prescribed"
 S BDMCUML(300)="Depression as an Active Problem"
 S BDMCUML(301)="Depression Screening?"
 S BDMCUML(120)="Exams"
 S BDMCUML(130)="Diabetes-Related Education"
 S BDMCUML(140)="Immunizations"
 S BDMCUML(145)="Laboratory Exams"
 S BDMCUML(150)="Electrocardiogram (Age 30 and above)"
 S BDMCUML(170)="Creatinine obtained during audit period"
 S BDMCUML(175)="Estimated GFR documented during audit period"
 S BDMCUML(180)="Total Cholesterol obtained in past 12 months"
 S BDMCUML(190)="LDL Cholesterol obtained during audit period"
 S BDMCUML(195)="HDL Cholesterol obtained during audit period"
 S BDMCUML(200)="Triglycerides obtained during audit period"
 S BDMCUML(400)="Comorbidities"
 ;
PROCESS ;
 S BDMNOGO=0
 S BDMPD=0 F  S BDMPD=$O(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD)) Q:BDMPD'=+BDMPD  D CUML1
 Q
 ;
CUML1 ;
 S BDMCOMOR=0  ;VARIABLE FOR # OF COMORBIDITIES
 S BDMSEVOB=0  ;SEVERELY OBESE
 S BDMBP140=0  ;COMORBIDITY SECTION
 S BDMCKD=0  ;CKD?
 S BDMEGFRU=0  ;BOTH EGFR AND UACR
 S BDMEGFRV=""  ;EGFR VALUE
 S BDMUACRV=""  ;UACR VALUE
GENDER ;
 I $$DODX^BDMDE16(BDMPD,BDMDMRG,"I")>BDMADAT S BDMNOGO=BDMNOGO+1 Q
 ;gender BDMCUML(10)="Gender^total^females^males"
 S $P(BDMCUML(10),U,2)=$P(BDMCUML(10),U,2)+1
 S V=$G(^XTMP("BDMDM17",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"
 S $P(BDMCUML(20),U,2)=$P(BDMCUML(20),U,2)+1
 S P=$S(V<20:3,V>19&(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
TYPE ;
 ;BDMCUML(25)="Total^Type 1^Type 2"
 S X=$$TYPE^BDMDE16(BDMPD,BDMDMRG,BDMADAT)
 S $P(BDMCUML(25),U,2)=$P(BDMCUML(25),U,2)+1
 S P=$S(X="":4,X=1:3,X=2:4,1:4)
 S $P(BDMCUML(25),U,P)=$P(BDMCUML(25),U,P)+1
DURDMC ;
 ;BDMCUML(30)="Duration of Diabetes^total^<10^10 or more^no date of dx on problem list or cms register^less than 1 year"
 S $P(BDMCUML(30),U,2)=$P(BDMCUML(30),U,2)+1
 ;
 S V=$$DURDM^BDMDE16(BDMPD,BDMDMRG,BDMADAT)
 S P=$S(V="":5,V<10:3,1:4)
 S $P(BDMCUML(30),U,P)=$P(BDMCUML(30),U,P)+1
 I V]"",V<1 S $P(BDMCUML(30),U,6)=$P(BDMCUML(30),U,6)+1
BMI ;
 ;BDMCUML(40)="Weight Control (BMI) - does not add up to 100%^total^total^overweight^obese^height or weight missing"
 ;S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,112))
 S H=$$LASTHT^BDMDE13(BDMPD,BDMRED,"I") S:H]"" H=$$STRIP^XLFSTR($J(H,5,2)," ")
 S W=+$$LASTWT^BDMDE13(BDMPD,BDMBDAT,BDMRED),W=$S(W=0:"",1:W) I W]"" S W=W\1
 S V=$$BMIEPI^BDMDE19(H,W)
 S $P(BDMCUML(40),U,2)=$P(BDMCUML(40),U,2)+1
 D
 .I V=""!(H="")!(W="") S $P(BDMCUML(40),U,5)=$P(BDMCUML(40),U,5)+1 Q
 .I V<25 S $P(BDMCUML(40),U,6)=$P(BDMCUML(40),U,6)+1 Q
 .I $$OW^BDMDE14(BDMPD,V,BDMADAT) S $P(BDMCUML(40),U,3)=$P(BDMCUML(40),U,3)+1 Q
 .I $$OB^BDMDE14(BDMPD,V,BDMADAT) S $P(BDMCUML(40),U,4)=$P(BDMCUML(40),U,4)+1
 .I $$SOB^BDMDE14(BDMPD,V,BDMADAT) S $P(BDMCUML(40),U,7)=$P(BDMCUML(40),U,7)+1,BDMSEVOB=1 Q
HGB ;
 ;use last hgba1c value only
 ;BDMCUML(50)=
 S $P(BDMCUML(50),U,2)=$P(BDMCUML(50),U,2)+1
 S V=$P($G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,78)),U,2)
 S P=""
 I V=""!(V="?") S P=9 G HGBS
 I V["<" S P=3
 I V[">" S P=8
 I P G HGBS
 S V=$$STV^BDMDE18(V,5)
 I V="" S P=9 G HGBS
 S V=+V
 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)
HGBS ;
 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 $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<70) S $P(BDMCUML(60),U,3)=$P(BDMCUML(60),U,3)+1,BDMBP140=1 Q
 .;I S<130&(D<80) S $P(BDMCUML(60),U,4)=$P(BDMCUML(60),U,4)+1,BDMBP140=1 Q
 .I S<140&(D<90) S $P(BDMCUML(60),U,5)=$P(BDMCUML(60),U,5)+1,BDMBP140=1 Q
 .I S<160&(D<95) 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 $P(BDMCUML(70),U,2)=$P(BDMCUML(70),U,2)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,70))
 I $E(V)=1!($E(V)=2) S $P(BDMCUML(70),U,3)=$P(BDMCUML(70),U,3)+1
 I $E(V)=1 S $P(BDMCUML(70),U,4)=$P(BDMCUML(70),U,4)+1
 I $E(V)=2 S $P(BDMCUML(70),U,5)=$P(BDMCUML(70),U,5)+1
 I $E($P(V,"||",2))=1 S $P(BDMCUML(70),U,6)=$P(BDMCUML(70),U,6)+1
 I $E($P(V,"||",2))=1,$E($G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,72)))=1 S $P(BDMCUML(70),U,7)=$P(BDMCUML(70),U,7)+1
 I $E($P(V,"||",2))=2 D
 .S $P(BDMCUML(70),U,9)=$P(BDMCUML(70),U,9)+1
 .S X=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,114))
 .I $$DODX^BDMDE16(BDMPD,BDMDMRG,"I")="" Q
 .S D=$$DODX^BDMDE16(BDMPD,BDMDMRG,"I"),E=X I D>E Q
 .S $P(BDMCUML(70),U,8)=$P(BDMCUML(70),U,8)+1
TOBACCO ;
 S $P(BDMCUML(80),U,2)=$P(BDMCUML(80),U,2)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,27))
 S V1=$G(^XTMP("BDMDM17",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)="1":4,$E(V1)="2":5,1:6) S $P(BDMCUML(80),U,P)=$P(BDMCUML(80),U,P)+1
 I +V=2 S $P(BDMCUML(80),U,7)=$P(BDMCUML(80),U,7)+1
 I +V=3 S $P(BDMCUML(80),U,8)=$P(BDMCUML(80),U,8)+1
TOBSCR ;
 S $P(BDMCUML(65),U,2)=$P(BDMCUML(65),U,2)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,215))
 I +V=1!(+V=2) S $P(BDMCUML(65),U,3)=$P(BDMCUML(65),U,3)+1
 I +V=3 S $P(BDMCUML(65),U,4)=$P(BDMCUML(65),U,4)+1
ENDS ;
 S $P(BDMCUML(69),U,2)=$P(BDMCUML(69),U,2)+1  ;denominator
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,31))
 I +V=1 S $P(BDMCUML(69),U,3)=$P(BDMCUML(69),U,3)+1  ;screened
 I +V=2 S $P(BDMCUML(69),U,4)=$P(BDMCUML(69),U,4)+1  ;not screened
 I $P(V,U,2)=1 S $P(BDMCUML(69),U,5)=$P(BDMCUML(69),U,5)+1  ;USER
 I $P(V,U,2)=2 S $P(BDMCUML(69),U,6)=$P(BDMCUML(69),U,6)+1  ;not USER
 I $P(V,U,2)=3 S $P(BDMCUML(69),U,7)=$P(BDMCUML(69),U,7)+1  ;not USER
 S T=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,27))  ;TOBACCO USER
 I $P(V,U,2)=1,+T=1 S $P(BDMCUML(69),U,8)=$P(BDMCUML(69),U,8)+1
DMTX ;diabetes treatment
 S BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31)),BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
 S $P(BDMCUML(90),U,2)=$P(BDMCUML(90),U,2)+1
 S V=$$THERAPY^BDMDE16(BDMPD,BDM6MBD,BDMRED)  ;^ pieced with each item  or =1 for diet alone or =14 for refused
 I V=1 S $P(BDMCUML(90),U,3)=$P(BDMCUML(90),U,3)+1 G ASPIRIN  ;DIET ALONE
 F I=1:1 S Q=$P(V,U,I) Q:Q=""!(Q["|")  D
 . S P=$S(Q=2:4,Q=3:5,Q=4:6,Q=5:7,Q=6:8,Q=7:9,Q=8:10,Q=9:11,Q=10:12,Q=11:14,Q=12:15,Q=13:16,1:"") S $P(BDMCUML(90),U,P)=$P(BDMCUML(90),U,P)+1
 S I=$P(V,"|||",2)  ;total number
 I I=1 S $P(BDMCUML(90),U,17)=$P(BDMCUML(90),U,17)+1 G ASPIRIN
 I I=2 S $P(BDMCUML(90),U,18)=$P(BDMCUML(90),U,18)+1 G ASPIRIN
 I I=3 S $P(BDMCUML(90),U,19)=$P(BDMCUML(90),U,19)+1  ;
 I I>3 S $P(BDMCUML(90),U,20)=$P(BDMCUML(90),U,20)+1
 ;
ASPIRIN ;
 ;only tally if patient is 30 and older
 ;G ACE:$$AGE^AUPNPAT(BDMPD,BDMADAT)<41  ;changed to 41 from 30 with 2010
 ;I $$SEX^AUPNPAT(BDMPD)="M",$$AGE^AUPNPAT(BDMPD,BDMADAT)<51 G ACE
 ;I $$SEX^AUPNPAT(BDMPD)="F",$$AGE^AUPNPAT(BDMPD,BDMADAT)<61 G ACE
 I $E($G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,116)))'=1 G LIPIDAG  ;not cvd
 S $P(BDMCUML(100),U,2)=$P(BDMCUML(100),U,2)+1  ;total with cvd
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,62))
 S P=$S($E(V)=1:3,$E(V)=3:5,$E(V)=2:4,1:4)
 S $P(BDMCUML(100),U,P)=$P(BDMCUML(100),U,P)+1
 ;
LIPIDAG ;lipid agents
 S BDMLPC=0,BDMREF=0
 S BDM6M=$$FMADD^XLFDT(BDMADAT,-(6*31))
 S $P(BDMCUML(115),U,2)=$P(BDMCUML(115),U,2)+1  ;total # of patients
 ;total # with CVD ;piece 16
 S V=$E($$STATIN^BDMDE16(BDMPD,BDM6M,BDMADAT))
 I V=1 S $P(BDMCUML(115),U,6)=$P(BDMCUML(115),U,6)+1  ;
 I V=3 S $P(BDMCUML(115),U,7)=$P(BDMCUML(115),U,7)+1
 I V'=3 S $P(BDMCUML(115),U,4)=$P(BDMCUML(115),U,4)+1
 S C=0
 I $E($G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,116)))=1 D
 .S C=1,$P(BDMCUML(115),U,16)=$P(BDMCUML(115),U,16)+1
 .I V'=3 S $P(BDMCUML(115),U,21)=$P(BDMCUML(115),U,21)+1
 .I V=1 S $P(BDMCUML(115),U,22)=$P(BDMCUML(115),U,22)+1
 .I V=3 S $P(BDMCUML(115),U,17)=$P(BDMCUML(115),U,17)+1
 S A=$$AGE^AUPNPAT(BDMPD,BDMADAT)
 I A>39&(A<76) D
 .S $P(BDMCUML(115),U,23)=$P(BDMCUML(115),U,23)+1
 .I V'=3 S $P(BDMCUML(115),U,8)=$P(BDMCUML(115),U,8)+1
 .I V=1 S $P(BDMCUML(115),U,19)=$P(BDMCUML(115),U,19)+1
 .I V=3 S $P(BDMCUML(115),U,20)=$P(BDMCUML(115),U,20)+1
 I C=1!(A>39&(A<76)) D
 .S $P(BDMCUML(115),U,24)=$P(BDMCUML(115),U,24)+1  ;DENOM
 .I V'=3 S $P(BDMCUML(115),U,25)=$P(BDMCUML(115),U,25)+1
 .I V=1 S $P(BDMCUML(115),U,26)=$P(BDMCUML(115),U,26)+1
 .I V=3 S $P(BDMCUML(115),U,27)=$P(BDMCUML(115),U,27)+1
 ;
LIPID ;115
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,61))
 S L=$$LDL^BDMDE18(BDMPD,BDMBDAT,BDMADAT,"I"),L=$P(L,U)
 S T=$$CHOL^BDMDE18(BDMPD,BDMBDAT,BDMADAT,"I"),T=$P(T,U)
 S T=$$STV^BDMDE18(T,5,1)
 S L=$$STV^BDMDE18(L,5,1)
DEP ;
 S $P(BDMCUML(300),U,2)=$P(BDMCUML(300),U,2)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,200))
 I $E(V)="1" S $P(BDMCUML(300),U,3)=$P(BDMCUML(300),U,3)+1
 I $E(V)'="1" S $P(BDMCUML(301),U,2)=$P(BDMCUML(301),U,2)+1 D
 .S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,210))
 .I $E(V)="1" S $P(BDMCUML(301),U,3)=$P(BDMCUML(301),U,3)+1
 .I $E(V)="2" S $P(BDMCUML(301),U,4)=$P(BDMCUML(301),U,4)+1
 .I $E(V)="3" S $P(BDMCUML(301),U,5)=$P(BDMCUML(301),U,5)+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("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,38))
 I $E(V)="1" S $P(BDMCUML(120),U,3)=$P(BDMCUML(120),U,3)+1
 I $E(V)="3" S $P(BDMCUML(120),U,6)=$P(BDMCUML(120),U,6)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,40))
 I $E(V)="1" S $P(BDMCUML(120),U,4)=$P(BDMCUML(120),U,4)+1
 I $E(V)="3" S $P(BDMCUML(120),U,7)=$P(BDMCUML(120),U,7)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,42))
 I $E(V)="1" S $P(BDMCUML(120),U,5)=$P(BDMCUML(120),U,5)+1
 I $E(V)="3" S $P(BDMCUML(120),U,8)=$P(BDMCUML(120),U,8)+1
 I $P(^DPT(BDMPD,0),U,2)="F" S $P(BDMCUML(120),U,9)=$P(BDMCUML(120),U,9)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,108))
 I $E(V)="1" S $P(BDMCUML(120),U,10)=$P(BDMCUML(120),U,10)+1
 I $E(V)="3" S $P(BDMCUML(120),U,11)=$P(BDMCUML(120),U,11)+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 G=0,V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,44))
 I $E(V)="1"!($E(V)=2)!($E(V)=3) S $P(BDMCUML(130),U,3)=$P(BDMCUML(130),U,3)+1 S G=1
 I $E(V)="5" S $P(BDMCUML(130),U,7)=$P(BDMCUML(130),U,7)+1
 I $E(V)="1" S $P(BDMCUML(130),U,10)=$P(BDMCUML(130),U,10)+1 S G=1
 I $E(V)="3" S $P(BDMCUML(130),U,10)=$P(BDMCUML(130),U,10)+1 S G=1  ;cmi/maw 1/15/08
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,46))
 I $E(V)="1" S $P(BDMCUML(130),U,4)=$P(BDMCUML(130),U,4)+1 S G=1
 I $E(V)="3" S $P(BDMCUML(130),U,8)=$P(BDMCUML(130),U,8)+1
 S V=$G(^XTMP("BDMDM17",BDMJOB,BDMBTH,"AUDIT",BDMPD,48))
 I $E(V)="3" S $P(BDMCUML(130),U,9)=$P(BDMCUML(130),U,9)+1
 I $E(V)="1" S $P(BDMCUML(130),U,5)=$P(BDMCUML(130),U,5)+1 S G=1
 I G S $P(BDMCUML(130),U,6)=$P(BDMCUML(130),U,6)+1
 D ^BDMDE11
 Q
SYSMEAN(P,BDATE,EDATE) ;EP
 NEW X,Z,C,Y
 S X=$$BPS^BDMDE13(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<1 Q ""
 S Z=C
 S C=0 F Y=1:1:Z S C=$P($P(X,";",Y),"/")+C
 Q C\Z
DIAMEAN(P,BDATE,EDATE) ;EP
 NEW X,Z,C,Y
 S X=$$BPS^BDMDE13(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<1 Q ""
 S Z=C
 S C=0 F Y=1:1:Z S C=$P($P(X,";",Y),"/",2)+C
 Q C\Z