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

BDMDF1J.m

Go to the documentation of this file.
BDMDF1J ; IHS/CMI/LAB -IHS -CUMULATIVE REPORT 10 Oct 2014 9:50 AM ; 
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**11**;JUN 14, 2007;Build 30
 ;
CUML ;EP
 ;
COMORBID ;USE 400
 S:'$D(BDMCUML(400)) BDMCUML(400)="Comorbidities"
 S $P(BDMCUML(400),U,2)=$P(BDMCUML(400),U,2)+1  ;TOTAL # of patients
 ;active depression piece 3
 S V=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,200))
 I $E(V)="1" S $P(BDMCUML(400),U,3)=$P(BDMCUML(400),U,3)+1,BDMCOMOR=BDMCOMOR+1
 ;tobacco use piece 4
 S V=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,27))
 I +V=1 S $P(BDMCUML(400),U,4)=$P(BDMCUML(400),U,4)+1,BDMCOMOR=BDMCOMOR+1
 ;SEVERELY OBESE PIECE 5
 I BDMSEVOB S $P(BDMCUML(400),U,5)=$P(BDMCUML(400),U,5)+1,BDMCOMOR=BDMCOMOR+1
 ;HYPERTENSION DIAGNOSED PIECE 6
 S H=$E($G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,34)))
 I $E(H)=1 S $P(BDMCUML(400),U,6)=$P(BDMCUML(400),U,6)+1,BDMCOMOR=BDMCOMOR+1
 ;HTN AND MEAN BP <140/<90 PIECE 7
 I $E(H)=1,BDMBP140 S $P(BDMCUML(400),U,7)=$P(BDMCUML(400),U,7)+1
 ;cvd piece 8
 S V=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,116))
 I $E(V)=1 S $P(BDMCUML(400),U,8)=$P(BDMCUML(400),U,8)+1,BDMCOMOR=BDMCOMOR+1
 ;
 ;CVD & BP <140/<90 PIECE 9
 I $E(V)=1,BDMBP140 S $P(BDMCUML(400),U,9)=$P(BDMCUML(400),U,9)+1
 ;CVD AND NOT A TOBACCO USER PIECE 10
 S T=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,27))
 I $E(T)=2,$E(V)=1 S $P(BDMCUML(400),U,10)=$P(BDMCUML(400),U,10)+1
 ;CVD AND STATIN PRESCRIBED PIECE 11
 S T=+$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,300))
 I $E(V)=1,T=1 S $P(BDMCUML(400),U,11)=$P(BDMCUML(400),U,11)+1
 I $E(V)=1,T'=3 S $P(BDMCUML(400),U,34)=$P(BDMCUML(400),U,34)+1 ;DENOM W/O ALLERGY
 ;CVD AND ASPIRIN PIECE 12
 S T=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,62))
 I $E(V)=1,$E(T)=1 S $P(BDMCUML(400),U,12)=$P(BDMCUML(400),U,12)+1
 ;
 ;CKD PIECE 13 & 14
 ;CKD IS EGFR <60 OR UACR >=30
 I $$AGE^AUPNPAT(BDMPD,BDMADAT)<18 G N
 S $P(BDMCUML(400),U,13)=$P(BDMCUML(400),U,13)+1  ;over 18 denom
 I BDMCKD S $P(BDMCUML(400),U,14)=$P(BDMCUML(400),U,14)+1,BDMCOMOR=BDMCOMOR+1  ;HAS CKD
 ;CKD AND BP <140/<90 PIECE 15
 I BDMCKD,BDMBP140 S $P(BDMCUML(400),U,15)=$P(BDMCUML(400),U,15)+1
 ;CKD AND ACE PIECE 16
 S A=$E($G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,60)))
 I A=1,BDMCKD S $P(BDMCUML(400),U,16)=$P(BDMCUML(400),U,16)+1
 ;EGFR AND UACR DONE PIECE 17
 S G=0
 I BDMEGFRU S $P(BDMCUML(400),U,17)=$P(BDMCUML(400),U,17)+1 D  I G G N
 .;NORMAL PIECE 18
 .I BDMEGFRV>59,BDMUACRV="<30" S $P(BDMCUML(400),U,18)=$P(BDMCUML(400),U,18)+1 S G=1
 .;STAGE 1/2 EGFR =>60, UACR =>30
 .I BDMEGFRV>59,BDMUACRV=">30" S $P(BDMCUML(400),U,19)=$P(BDMCUML(400),U,19)+1 S G=1
 ;STAGE 3 EGFR 30-59
 I BDMEGFRV]"",BDMEGFRV'<30,BDMEGFRV<60 S $P(BDMCUML(400),U,20)=$P(BDMCUML(400),U,20)+1 G N
 ;STAGE 4 EGFR 15-20 PIECE 21
 I BDMEGFRV]"",BDMEGFRV'<15,BDMEGFRV'>29 S $P(BDMCUML(400),U,21)=$P(BDMCUML(400),U,21)+1 G N
 ;STAGE 5 EGFR <15
 I BDMEGFRV]"",BDMEGFRV<15 S $P(BDMCUML(400),U,22)=$P(BDMCUML(400),U,22)+1 G N
 ;UACR AND EGFR NOT DONE
 S $P(BDMCUML(400),U,23)=$P(BDMCUML(400),U,23)+1
N ;p12 HEP C AND RETINOPATHY
 S V=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,222))
 I $E(V)="1" S $P(BDMCUML(400),U,35)=$P(BDMCUML(400),U,35)+1,BDMCOMOR=BDMCOMOR+1 G R
 ;
 S V=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,223))
 I $E(V)="1" S $P(BDMCUML(400),U,37)=$P(BDMCUML(400),U,37)+1
 I $E(V)'=3 S $P(BDMCUML(400),U,36)=$P(BDMCUML(400),U,36)+1 ;hep c screen denom
R ;RETINOPATHY
 S V=$G(^XTMP("BDMDM18",BDMJOB,BDMBTH,"AUDIT",BDMPD,224))
 I $E(V)="1" S $P(BDMCUML(400),U,38)=$P(BDMCUML(400),U,38)+1,BDMCOMOR=BDMCOMOR+1
V ;NONE PIECE 25
 I BDMCOMOR=0 S $P(BDMCUML(400),U,25)=$P(BDMCUML(400),U,25)+1
 I BDMCOMOR=1 S $P(BDMCUML(400),U,26)=$P(BDMCUML(400),U,26)+1
 I BDMCOMOR=2 S $P(BDMCUML(400),U,27)=$P(BDMCUML(400),U,27)+1
 I BDMCOMOR=3 S $P(BDMCUML(400),U,28)=$P(BDMCUML(400),U,28)+1
 I BDMCOMOR=4 S $P(BDMCUML(400),U,29)=$P(BDMCUML(400),U,29)+1
 I BDMCOMOR>4 S $P(BDMCUML(400),U,30)=$P(BDMCUML(400),U,30)+1  ;P11
 ;I BDMCOMOR=6 S $P(BDMCUML(400),U,31)=$P(BDMCUML(400),U,31)+1  ;P11
 Q
REC(DFN,BDMRTYP,BDMRBD,BDMRED,BDMED,BDMDMRG,BDMBDAT) ;EP - called to send back a visit record as
 NEW BDMX,BDMREC,BDMEPIX,BDMTTT,X,Y,Z
 S BDMREC=""
 S BDMRTYP("IEN")=$O(^BDMRECD("B",BDMRTYP,0))
 I 'BDMRTYP("IEN") Q BDMREC
PROC ;
 S BDMEPIX=0
 F  S BDMEPIX=$O(^BDMRECD(BDMRTYP("IEN"),11,"AC",BDMEPIX)) Q:BDMEPIX'=+BDMEPIX!(BDMREC=-1)  S BDMTTT=$O(^BDMRECD(BDMRTYP("IEN"),11,"AC",BDMEPIX,0))  D
 .S X="" X:$D(^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,11)) ^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,11)
 .;I X="" S X=" "
 .S $P(BDMREC,U,$P(^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,0),U,2))=X
 Q BDMREC
EPICHK ;create epi info record in ^BDMDATA("BDMEPI",$J,n)
 ;skip this patient if dodx is greater than the audit date
 S X=$$DODX^BDMDF16(BDMPD,BDMDMRG,"I")
 I X>BDMADAT Q
 ;I DUZ=2881,BDMPD'=8932 Q
 NEW BDMECNT,BDMEPIR,BDMTHER
 S BDMEPIR="",BDMTHER="",BDMECNT=0
 S BDMEPIR=$$REC(BDMPD,"DM AUDIT 2018 EXPORT RECORD",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT)
 ;CHECK ERRORS ON BDMEPIR
 S BDMRTYP("IEN")=$O(^BDMRECD("B","DM AUDIT 2018 EXPORT RECORD",0))
 S Z=0 F  S Z=$O(^BDMRECD(BDMRTYP("IEN"),21,Z)) Q:Z'=+Z  D
 .X:$D(^BDMRECD(BDMRTYP("IEN"),21,Z,1)) ^BDMRECD(BDMRTYP("IEN"),21,Z,1)
 .Q:'$T
 .S S=""
 .I BDMQSRT="P" S S=$P(^DPT(BDMPD,0),U,1)
 .I BDMQSRT="E" S S=$P(^BDMRECD(BDMRTYP("IEN"),21,Z,0),U,1)
 .S BDMECNT=BDMECNT+1
 .S $P(^XTMP("BDMDM18 ERRORS",BDMJOB,BDMBTH,"PATS",S,BDMPD,BDMECNT),U,1)=$P(^BDMRECD(BDMRTYP("IEN"),21,Z,0),U,1)
 .S J=$P(^BDMRECD(BDMRTYP("IEN"),21,Z,0),U,2)
 .S $P(^XTMP("BDMDM18 ERRORS",BDMJOB,BDMBTH,"PATS",S,BDMPD,BDMECNT),U,2)=$S(J="P":"POTENTIAL",J="D":"DEFINITE",1:"")
 .S $P(^XTMP("BDMDM18 ERRORS",BDMJOB,BDMBTH,"PATS",S,BDMPD,BDMECNT),U,3)=$P($G(^BDMRECD(BDMRTYP("IEN"),21,Z,11)),U,1)
 .S P=$P(^BDMRECD(BDMRTYP("IEN"),21,Z,0),U,4)
 .S A=""
 .I P="" D
 ..I $P(^BDMRECD(BDMRTYP("IEN"),21,Z,0),U,1)["BMI" S A=$$BMI^BDMDF18(BDMPD,BDMRBD,BDMRED)
 ..I $P(^BDMRECD(BDMRTYP("IEN"),21,Z,0),U,1)["HEIGHT TOTAL" S A="" I $P(BDMEPIR,U,18)]"" S A=$P(BDMEPIR,U,18)*12,A=A+$P(BDMEPIR,U,19)
 ..I $P(^BDMRECD(BDMRTYP("IEN"),21,Z,0),U,1)["DURATION" S A=$$DURDM^BDMDF16(BDMPD,BDMDMRG,BDMADAT)
 .I P S A=$P(BDMEPIR,U,P)
 .S $P(^XTMP("BDMDM18 ERRORS",BDMJOB,BDMBTH,"PATS",S,BDMPD,BDMECNT),U,4)=A
 Q
QUALCHK ;EP - addl questions for data quality report
 ;get sort value
 S BDMQSRT=""
 S DIR(0)="S^P:PATIENT NAME;E:ERROR FIELD NAME",DIR("A")="How should the report be sorted",DIR("B")="P" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) S BDMSTP=1 Q
 S BDMQSRT=Y
 Q