BDMD910 ; IHS/CMI/LAB -IHS -GETS DATA FOR DIABETES QA REPORT ;
;;2.0;DIABETES MANAGEMENT SYSTEM;**2,3**;JUN 14, 2007
;
;
EN ; - ENTRY POINT - from ^BDMASK
K ^BDMDATA("BDMEPI",$J)
S ^XTMP("BDMDM91",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2009"
S BDMEPIN=0
S BDMPD=0 F S BDMPD=$O(^XTMP("BDMDM91",BDMJOB,BDMBTH,"PATS",BDMPD)) Q:'BDMPD D
.I BDMTYPE'="P",BDMTYPE'="S" Q:$$DEMO^BDMUTL(BDMPD,$G(BDMDEMO))
.I BDMPREP=2 D EPIREC Q
.D GATHER
I BDMPREP=2 D WRITEF^BDMD91 Q
I BDMPREP=3!(BDMPREP=4) D CUML^BDMD915
Q
S(P,I,V) ;
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",P,I)=V
Q
REC(DFN,BDMRTYP,BDMRBD,BDMRED,BDMED,BDMDMRG,BDMBDAT) ;EP - called to send back a visit record as
NEW BDMX,BDMREC
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)
.S $E(BDMREC,$P(^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,0),U,2))=X ;W !,BDMTTT,?5,$P(^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,0),U),?40,X
Q BDMREC
EPIREC ;create epi info record in ^BDMDATA("BDMEPI",$J,n)
;skip this patient if dodx is greater than the audit date
S X=$$DODX^BDMD916(BDMPD,BDMDMRG,"I")
I X>BDMADAT Q
S BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 1",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT),BDMEPIN=BDMEPIN+1,^BDMDATA("BDMEPI",$J,BDMEPIN)=BDMEPIR
S BDMTHER="",BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 2",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT),BDMEPIN=BDMEPIN+1,^BDMDATA("BDMEPI",$J,BDMEPIN)=BDMEPIR
S BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 3",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT),BDMEPIN=BDMEPIN+1,^BDMDATA("BDMEPI",$J,BDMEPIN)=BDMEPIR
S BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 4",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT),BDMEPIN=BDMEPIN+1,^BDMDATA("BDMEPI",$J,BDMEPIN)=BDMEPIR
Q
GATHER ;gather data for 1 patient
S BDMER=0
;set report dates
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,1)=$S($G(BDMFISC)]"":BDMFISC,1:BDMRBD_" - "_BDMRED)
;set audit date to DT
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,2)=$$FMTE^XLFDT(DT)
;set area, su, facility code and name
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,4)=$P(^DIC(4,$S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U)
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,6)=$E($P(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),1,2)
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,8)=$E($P(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),3,4)
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,10)=$E($P(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),5,6)
;# pats in register
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,12)=$S(BDMDMRG:$$RSTAT^BDMDM6(BDMDMRG,"A"),1:"")
;reviewer
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,14)=$P(^VA(200,DUZ,0),U,2)
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,15)=$$VAL^XBDIQ1(9000001,BDMPD,.14)
DEMO ;pat demographics
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,16)=$$HRN^AUPNPAT(BDMPD,$S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)))
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,18)=$$DOB^AUPNPAT(BDMPD,"E")
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,20)=$$VAL^XBDIQ1(2,BDMPD,.02)
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,120)=$$TRIBE(BDMPD)
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,121)=$S($P($G(^DPT(BDMPD,.11)),U,5):$P($G(^DIC(5,$P(^DPT(BDMPD,.11),U,5),0)),U,2),1:"") ;cmi/maw 12/17/2007 state of residence DM2009
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,122)=$$COMM(BDMPD)
DXDT ;dates of and dm dxs
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,22)=$S(BDMDMRG:$$CMSFDX^BDMD913(BDMPD,BDMDMRG,"D"),1:"")
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)=$S(BDMDMRG:$$CMSFDX^BDMD913(BDMPD,BDMDMRG,"DX"),1:"")
S ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,23)=$$PLDMDOO^BDMD913(BDMPD)
D S(BDMPD,25,$$PLDMDXS^BDMD913(BDMPD))
D S(BDMPD,21,$$FRSTDMDX^BDMD913(BDMPD))
D S(BDMPD,26,$$LASTDMDX^BDMD913(BDMPD,BDMRED))
I $$DODX^BDMD916(BDMPD,BDMDMRG,"I")>BDMADAT D S(BDMPD,26.5,"*** Patient's Date of Onset is after the audit date.") D
.D S(BDMPD,26.6,"**** This patient will not be included in the cumulative audit.")
D S(BDMPD,27,$$TOBACCO^BDMD91T(BDMPD,BDMBDAT,BDMADAT))
S BDMTYDM="" D TYPEDM,S(BDMPD,29,BDMTYDM)
D S(BDMPD,28,$$CESS^BDMD911(BDMPD,BDMBDAT,BDMADAT))
;
VITAL ;
D S(BDMPD,30,$$LASTHT^BDMD913(BDMPD,BDMRED))
D S(BDMPD,32,$$LASTWT^BDMD913(BDMPD,BDMRED))
;htn dx
D S(BDMPD,34,$$HTNDX^BDMD913(BDMPD,BDMRED))
;last 3 BPs
D S(BDMPD,36,$$BPS^BDMD913(BDMPD,BDMRBD,BDMRED))
EXAMS ;
D S(BDMPD,38,$$DFE^BDMD917(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,40,$$EYE^BDMD917(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,42,$$DENTAL^BDMD917(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,44,$$DIETEDUC^BDMD917(BDMPD,BDMRBD,BDMRED))
D S(BDMPD,46,$$EXEDUC^BDMD917(BDMPD,BDMRBD,BDMRED))
D S(BDMPD,48,$$OTHEDUC^BDMD917(BDMPD,BDMRBD,BDMRED))
THERAPY ;
S BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31)),BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
D S(BDMPD,52,$$INSULIN^BDMD912(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,53,$$SULF^BDMD912(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,54,$$MET^BDMD912(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,55,$$ACAR^BDMD912(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,56,$$TROG^BDMD912(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,58,$$INCR^BDMD912(BDMPD,BDM6MBD,BDMRED)) ;cmi/maw 12/18/2007 DM2009
D S(BDMPD,59,$$DPP4^BDMD912(BDMPD,BDM6MBD,BDMRED)) ;cmi/maw 12/18/2009 DM2009
D S(BDMPD,99,$$AMYLIN^BDMD912(BDMPD,BDM6MBD,BDMRED))
S Z=0 F X=52:1:59,99 I $E($G(^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)))="X" S Z=1
S Y=$$REFMED^BDMD912(BDMPD,BDMRBD,BDMRED) S Y=$S(Z:"",Y="":"",1:"X"_U_$P(Y,U,2)) D S(BDMPD,57,Y)
S Y=0 F X=52:1:59,99 I $E($G(^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)))="X" S Y=1 ;cmi/maw 6/17/2009 per gary
D S(BDMPD,51,$S(Y:"",1:"X"))
D S(BDMPD,60,$$ACE^BDMD916(BDMPD,BDM6MBD,BDMADAT))
IMM ;
D S(BDMPD,62,$$ASPIRIN^BDMD916(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,61,$$LIPID^BDMD916(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,64,$$FLU^BDMD913(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,66,$$PNEU^BDMD913(BDMPD,BDMADAT))
D S(BDMPD,68,$$TD^BDMD91B(BDMPD,BDMADAT))
PPD ;
D S(BDMPD,70,$$PPD^BDMD918(BDMPD,BDMADAT))
D S(BDMPD,114,$$LASTNP^BDMD918(BDMPD,BDMADAT))
D S(BDMPD,72,$$TBTX^BDMD912(BDMPD))
D S(BDMPD,76,$$EKG^BDMD912(BDMPD,BDMADAT))
LABS ;
D S(BDMPD,78,$$HGBA1C^BDMD918(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,79,$$GFR^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
D S(BDMPD,84,$$CREAT^BDMD918(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,86,$$CHOL^BDMD918(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,88,$$LDL^BDMD918(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,89,$$HDL^BDMD918(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,90,$$TRIG^BDMD918(BDMPD,BDMBDAT,BDMADAT))
;D S(BDMPD,91,$$UACR^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
;D S(BDMPD,82,$$SEMI^BDMD91C(BDMPD,BDMBDAT,BDMADAT))
;D S(BDMPD,93,$$UPCR^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
;D S(BDMPD,95,$$QUAN^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
D S(BDMPD,92,$$URIN^BDMD918(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
;D S(BDMPD,94,$$PROTEIN^BDMD918(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
;D S(BDMPD,96,$$MICRO^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
;D S(BDMPD,98,$$SELF^BDMD916(BDMPD,BDMRBD,BDMRED))
D S(BDMPD,112,$$BMI^BDMD918(BDMPD,BDMRBD,BDMRED))
D S(BDMPD,200,$$DEPDX^BDMD912(BDMPD,BDMBDAT,BDMADAT))
S BDMDEP=$E($G(^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,200)))
D S(BDMPD,210,$S(BDMDEP="1":"",1:$$DEPSCR^BDMD912(BDMPD,BDMBDAT,BDMADAT)))
;
Q
TYPEDM ;return type of DM in BDMTYDM
NEW X
I ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="NIDDM" S BDMTYDM="2 Type 2" Q
I ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="TYPE II" S BDMTYDM="2 Type 2" Q
I ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)[2 S BDMTYDM="2 Type 2" Q
I ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="IDDM" S BDMTYDM="1 Type 1" Q
I ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)[1 S BDMTYDM="1 Type 1" Q
S X=^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,25) ;get problem list dxs
F I=1:1 S C=$P(X,";",I) Q:C=""!(BDMTYDM]"") I $E(C,6)=0!($E(C,6)=2) S BDMTYDM="2 Type 2"
Q:BDMTYDM]""
F I=1:1 S C=$P(X,";",I) Q:C=""!(BDMTYDM]"") I $E(C,6)=1!($E(C,6)=3) S BDMTYDM="1 Type 1"
Q:BDMTYDM]""
S X=^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,26) ;get pov list dxs
I X[2 S BDMTYDM="2 Type 2" Q
I X[1 S BDMTYDM="1 Type 1" Q
Q
DATE(D) ;EP
I $G(D)="" Q ""
Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_(1700+($E(D,1,3)))
TRIBE(P) ;EP
I '$G(P) Q ""
I '$D(^AUPNPAT(P,11)) Q ""
Q $$TRIBE^AUPNPAT(P,"C")_"^"_$$TRIBE^AUPNPAT(P,"E")
COMM(P) ;EP
I '$G(P) Q ""
I '$D(^AUPNPAT(P,11)) Q ""
Q $$COMMRES^AUPNPAT(P,"E")
EAUDIT ;EP
K ^BDMDATA("BDMEPI",$J)
S ^XTMP("BDMDM91",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2009"
S BDMEPIN=0
S BDMBEGD=$$FMADD^XLFDT(BDMADAT,-365)
S BDM3YE=$$FMADD^XLFDT(BDMADAT,-1096)
I BDMACTI=1 D
.S BDMEAUT=0 F S BDMEAUT=$O(^ACM(41,"B",BDMDMRG,BDMEAUT)) Q:BDMEAUT'=+BDMEAUT D
..I $P($G(^ACM(41,BDMEAUT,"DT")),U,1)'="A" Q
..S BDMPD=$P(^ACM(41,BDMEAUT,0),U,2)
..Q:$$DEMO^BDMUTL(BDMPD,$G(BDMDEMO))
..S BDMX=$$ACTDMPT^BDMD91G(BDMPD,BDMBEGD,BDMADAT,BDMTAXI,BDMBEN,BDM3YE)
..I 'BDMX Q ;not active diabetic
..I BDMPREP=2 D EPIREC Q
..D GATHER
.Q
I BDMACTI=0 S BDMPD=0 F S BDMPD=$O(^AUPNPAT(BDMPD)) Q:'BDMPD D
.S BDMX=$$ACTDMPT^BDMD91G(BDMPD,BDMBEGD,BDMADAT,BDMTAXI,BDMBEN,BDM3YE)
.I 'BDMX Q ;not active diabetic
.I BDMACTI,'$$ACTONREG(BDMPD,BDMDMRG) Q
.I BDMPREP=2 D EPIREC Q
.D GATHER
I BDMPREP=2 D WRITEF^BDMD91 Q
I BDMPREP=3!(BDMPREP=4) D CUML^BDMD915
Q
ACTONREG(P,R) ;
I '$D(^ACM(41,"AC",P,R)) Q 0
S X=^ACM(41,"AC",P,R)
I $P($G(^ACM(41,X,"DT")),U,1)'="A" Q 0
Q 1
;
BDMD910 ; IHS/CMI/LAB -IHS -GETS DATA FOR DIABETES QA REPORT ;
+1 ;;2.0;DIABETES MANAGEMENT SYSTEM;**2,3**;JUN 14, 2007
+2 ;
+3 ;
EN ; - ENTRY POINT - from ^BDMASK
+1 KILL ^BDMDATA("BDMEPI",$JOB)
+2 SET ^XTMP("BDMDM91",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2009"
+3 SET BDMEPIN=0
+4 SET BDMPD=0
FOR
SET BDMPD=$ORDER(^XTMP("BDMDM91",BDMJOB,BDMBTH,"PATS",BDMPD))
IF 'BDMPD
QUIT
Begin DoDot:1
+5 IF BDMTYPE'="P"
IF BDMTYPE'="S"
IF $$DEMO^BDMUTL(BDMPD,$GET(BDMDEMO))
QUIT
+6 IF BDMPREP=2
DO EPIREC
QUIT
+7 DO GATHER
End DoDot:1
+8 IF BDMPREP=2
DO WRITEF^BDMD91
QUIT
+9 IF BDMPREP=3!(BDMPREP=4)
DO CUML^BDMD915
+10 QUIT
S(P,I,V) ;
+1 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",P,I)=V
+2 QUIT
REC(DFN,BDMRTYP,BDMRBD,BDMRED,BDMED,BDMDMRG,BDMBDAT) ;EP - called to send back a visit record as
+1 NEW BDMX,BDMREC
+2 SET BDMREC=""
+3 SET BDMRTYP("IEN")=$ORDER(^BDMRECD("B",BDMRTYP,0))
+4 IF 'BDMRTYP("IEN")
QUIT BDMREC
PROC ;
+1 SET BDMEPIX=0
+2 FOR
SET BDMEPIX=$ORDER(^BDMRECD(BDMRTYP("IEN"),11,"AC",BDMEPIX))
IF BDMEPIX'=+BDMEPIX!(BDMREC=-1)
QUIT
SET BDMTTT=$ORDER(^BDMRECD(BDMRTYP("IEN"),11,"AC",BDMEPIX,0))
Begin DoDot:1
+3 SET X=""
IF $DATA(^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,11))
XECUTE ^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,11)
+4 ;W !,BDMTTT,?5,$P(^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,0),U),?40,X
SET $EXTRACT(BDMREC,$PIECE(^BDMRECD(BDMRTYP("IEN"),11,BDMTTT,0),U,2))=X
End DoDot:1
+5 QUIT BDMREC
EPIREC ;create epi info record in ^BDMDATA("BDMEPI",$J,n)
+1 ;skip this patient if dodx is greater than the audit date
+2 SET X=$$DODX^BDMD916(BDMPD,BDMDMRG,"I")
+3 IF X>BDMADAT
QUIT
+4 SET BDMEPIR=""
SET BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 1",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT)
SET BDMEPIN=BDMEPIN+1
SET ^BDMDATA("BDMEPI",$JOB,BDMEPIN)=BDMEPIR
+5 SET BDMTHER=""
SET BDMEPIR=""
SET BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 2",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT)
SET BDMEPIN=BDMEPIN+1
SET ^BDMDATA("BDMEPI",$JOB,BDMEPIN)=BDMEPIR
+6 SET BDMEPIR=""
SET BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 3",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT)
SET BDMEPIN=BDMEPIN+1
SET ^BDMDATA("BDMEPI",$JOB,BDMEPIN)=BDMEPIR
+7 SET BDMEPIR=""
SET BDMEPIR=$$REC(BDMPD,"DM AUDIT 2009 EPI REC 4",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT)
SET BDMEPIN=BDMEPIN+1
SET ^BDMDATA("BDMEPI",$JOB,BDMEPIN)=BDMEPIR
+8 QUIT
GATHER ;gather data for 1 patient
+1 SET BDMER=0
+1 ;set report dates
+2 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,1)=$SELECT($GET(BDMFISC)]"":BDMFISC,1:BDMRBD_" - "_BDMRED)
+3 ;set audit date to DT
+4 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,2)=$$FMTE^XLFDT(DT)
+5 ;set area, su, facility code and name
+6 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,4)=$PIECE(^DIC(4,$SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U)
+7 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,6)=$EXTRACT($PIECE(^AUTTLOC($SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),1,2)
+8 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,8)=$EXTRACT($PIECE(^AUTTLOC($SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),3,4)
+9 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,10)=$EXTRACT($PIECE(^AUTTLOC($SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),5,6)
+10 ;# pats in register
+11 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,12)=$SELECT(BDMDMRG:$$RSTAT^BDMDM6(BDMDMRG,"A"),1:"")
+12 ;reviewer
+13 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,14)=$PIECE(^VA(200,DUZ,0),U,2)
+14 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,15)=$$VAL^XBDIQ1(9000001,BDMPD,.14)
DEMO ;pat demographics
+1 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,16)=$$HRN^AUPNPAT(BDMPD,$SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)))
+2 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,18)=$$DOB^AUPNPAT(BDMPD,"E")
+3 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,20)=$$VAL^XBDIQ1(2,BDMPD,.02)
+4 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,120)=$$TRIBE(BDMPD)
+5 ;cmi/maw 12/17/2007 state of residence DM2009
SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,121)=$SELECT($PIECE($GET(^DPT(BDMPD,.11)),U,5):$PIECE($GET(^DIC(5,$PIECE(^DPT(BDMPD,.11),U,5),0)),U,2),1:"")
+6 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,122)=$$COMM(BDMPD)
DXDT ;dates of and dm dxs
+1 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,22)=$SELECT(BDMDMRG:$$CMSFDX^BDMD913(BDMPD,BDMDMRG,"D"),1:"")
+2 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)=$SELECT(BDMDMRG:$$CMSFDX^BDMD913(BDMPD,BDMDMRG,"DX"),1:"")
+3 SET ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,23)=$$PLDMDOO^BDMD913(BDMPD)
+4 DO S(BDMPD,25,$$PLDMDXS^BDMD913(BDMPD))
+5 DO S(BDMPD,21,$$FRSTDMDX^BDMD913(BDMPD))
+6 DO S(BDMPD,26,$$LASTDMDX^BDMD913(BDMPD,BDMRED))
+7 IF $$DODX^BDMD916(BDMPD,BDMDMRG,"I")>BDMADAT
DO S(BDMPD,26.5,"*** Patient's Date of Onset is after the audit date.")
Begin DoDot:1
+8 DO S(BDMPD,26.6,"**** This patient will not be included in the cumulative audit.")
End DoDot:1
+9 DO S(BDMPD,27,$$TOBACCO^BDMD91T(BDMPD,BDMBDAT,BDMADAT))
+10 SET BDMTYDM=""
DO TYPEDM
DO S(BDMPD,29,BDMTYDM)
+11 DO S(BDMPD,28,$$CESS^BDMD911(BDMPD,BDMBDAT,BDMADAT))
+12 ;
VITAL ;
+1 DO S(BDMPD,30,$$LASTHT^BDMD913(BDMPD,BDMRED))
+2 DO S(BDMPD,32,$$LASTWT^BDMD913(BDMPD,BDMRED))
+3 ;htn dx
+4 DO S(BDMPD,34,$$HTNDX^BDMD913(BDMPD,BDMRED))
+5 ;last 3 BPs
+6 DO S(BDMPD,36,$$BPS^BDMD913(BDMPD,BDMRBD,BDMRED))
EXAMS ;
+1 DO S(BDMPD,38,$$DFE^BDMD917(BDMPD,BDMBDAT,BDMADAT))
+2 DO S(BDMPD,40,$$EYE^BDMD917(BDMPD,BDMBDAT,BDMADAT))
+3 DO S(BDMPD,42,$$DENTAL^BDMD917(BDMPD,BDMBDAT,BDMADAT))
+4 DO S(BDMPD,44,$$DIETEDUC^BDMD917(BDMPD,BDMRBD,BDMRED))
+5 DO S(BDMPD,46,$$EXEDUC^BDMD917(BDMPD,BDMRBD,BDMRED))
+6 DO S(BDMPD,48,$$OTHEDUC^BDMD917(BDMPD,BDMRBD,BDMRED))
THERAPY ;
+1 SET BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31))
SET BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
+2 DO S(BDMPD,52,$$INSULIN^BDMD912(BDMPD,BDM6MBD,BDMRED))
+3 DO S(BDMPD,53,$$SULF^BDMD912(BDMPD,BDM6MBD,BDMRED))
+4 DO S(BDMPD,54,$$MET^BDMD912(BDMPD,BDM6MBD,BDMRED))
+5 DO S(BDMPD,55,$$ACAR^BDMD912(BDMPD,BDM6MBD,BDMRED))
+6 DO S(BDMPD,56,$$TROG^BDMD912(BDMPD,BDM6MBD,BDMRED))
+7 ;cmi/maw 12/18/2007 DM2009
DO S(BDMPD,58,$$INCR^BDMD912(BDMPD,BDM6MBD,BDMRED))
+8 ;cmi/maw 12/18/2009 DM2009
DO S(BDMPD,59,$$DPP4^BDMD912(BDMPD,BDM6MBD,BDMRED))
+9 DO S(BDMPD,99,$$AMYLIN^BDMD912(BDMPD,BDM6MBD,BDMRED))
+10 SET Z=0
FOR X=52:1:59,99
IF $EXTRACT($GET(^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)))="X"
SET Z=1
+11 SET Y=$$REFMED^BDMD912(BDMPD,BDMRBD,BDMRED)
SET Y=$SELECT(Z:"",Y="":"",1:"X"_U_$PIECE(Y,U,2))
DO S(BDMPD,57,Y)
+12 ;cmi/maw 6/17/2009 per gary
SET Y=0
FOR X=52:1:59,99
IF $EXTRACT($GET(^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)))="X"
SET Y=1
+13 DO S(BDMPD,51,$SELECT(Y:"",1:"X"))
+14 DO S(BDMPD,60,$$ACE^BDMD916(BDMPD,BDM6MBD,BDMADAT))
IMM ;
+1 DO S(BDMPD,62,$$ASPIRIN^BDMD916(BDMPD,BDMBDAT,BDMADAT))
+2 DO S(BDMPD,61,$$LIPID^BDMD916(BDMPD,BDMBDAT,BDMADAT))
+3 DO S(BDMPD,64,$$FLU^BDMD913(BDMPD,BDMBDAT,BDMADAT))
+4 DO S(BDMPD,66,$$PNEU^BDMD913(BDMPD,BDMADAT))
+5 DO S(BDMPD,68,$$TD^BDMD91B(BDMPD,BDMADAT))
PPD ;
+1 DO S(BDMPD,70,$$PPD^BDMD918(BDMPD,BDMADAT))
+2 DO S(BDMPD,114,$$LASTNP^BDMD918(BDMPD,BDMADAT))
+3 DO S(BDMPD,72,$$TBTX^BDMD912(BDMPD))
+4 DO S(BDMPD,76,$$EKG^BDMD912(BDMPD,BDMADAT))
LABS ;
+1 DO S(BDMPD,78,$$HGBA1C^BDMD918(BDMPD,BDMBDAT,BDMADAT))
+2 ;cmi/maw 12/17/2007 DM2009
DO S(BDMPD,79,$$GFR^BDMD91C(BDMPD,BDMBDAT,BDMADAT))
+3 DO S(BDMPD,84,$$CREAT^BDMD918(BDMPD,BDMBDAT,BDMADAT))
+4 DO S(BDMPD,86,$$CHOL^BDMD918(BDMPD,BDMBDAT,BDMADAT))
+5 DO S(BDMPD,88,$$LDL^BDMD918(BDMPD,BDMBDAT,BDMADAT))
+6 DO S(BDMPD,89,$$HDL^BDMD918(BDMPD,BDMBDAT,BDMADAT))
+7 DO S(BDMPD,90,$$TRIG^BDMD918(BDMPD,BDMBDAT,BDMADAT))
+8 ;D S(BDMPD,91,$$UACR^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
+9 ;D S(BDMPD,82,$$SEMI^BDMD91C(BDMPD,BDMBDAT,BDMADAT))
+10 ;D S(BDMPD,93,$$UPCR^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
+11 ;D S(BDMPD,95,$$QUAN^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
+12 ;cmi/maw 12/17/2007 DM2009
DO S(BDMPD,92,$$URIN^BDMD918(BDMPD,BDMBDAT,BDMADAT))
+13 ;D S(BDMPD,94,$$PROTEIN^BDMD918(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
+14 ;D S(BDMPD,96,$$MICRO^BDMD91C(BDMPD,BDMBDAT,BDMADAT)) ;cmi/maw 12/17/2007 DM2009
+15 ;D S(BDMPD,98,$$SELF^BDMD916(BDMPD,BDMRBD,BDMRED))
+16 DO S(BDMPD,112,$$BMI^BDMD918(BDMPD,BDMRBD,BDMRED))
+17 DO S(BDMPD,200,$$DEPDX^BDMD912(BDMPD,BDMBDAT,BDMADAT))
+18 SET BDMDEP=$EXTRACT($GET(^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,200)))
+19 DO S(BDMPD,210,$SELECT(BDMDEP="1":"",1:$$DEPSCR^BDMD912(BDMPD,BDMBDAT,BDMADAT)))
+20 ;
+21 QUIT
TYPEDM ;return type of DM in BDMTYDM
+1 NEW X
+2 IF ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="NIDDM"
SET BDMTYDM="2 Type 2"
QUIT
+3 IF ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="TYPE II"
SET BDMTYDM="2 Type 2"
QUIT
+4 IF ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)[2
SET BDMTYDM="2 Type 2"
QUIT
+5 IF ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="IDDM"
SET BDMTYDM="1 Type 1"
QUIT
+6 IF ^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)[1
SET BDMTYDM="1 Type 1"
QUIT
+7 ;get problem list dxs
SET X=^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,25)
+8 FOR I=1:1
SET C=$PIECE(X,";",I)
IF C=""!(BDMTYDM]"")
QUIT
IF $EXTRACT(C,6)=0!($EXTRACT(C,6)=2)
SET BDMTYDM="2 Type 2"
+9 IF BDMTYDM]""
QUIT
+10 FOR I=1:1
SET C=$PIECE(X,";",I)
IF C=""!(BDMTYDM]"")
QUIT
IF $EXTRACT(C,6)=1!($EXTRACT(C,6)=3)
SET BDMTYDM="1 Type 1"
+11 IF BDMTYDM]""
QUIT
+12 ;get pov list dxs
SET X=^XTMP("BDMDM91",BDMJOB,BDMBTH,"AUDIT",BDMPD,26)
+13 IF X[2
SET BDMTYDM="2 Type 2"
QUIT
+14 IF X[1
SET BDMTYDM="1 Type 1"
QUIT
+15 QUIT
DATE(D) ;EP
+1 IF $GET(D)=""
QUIT ""
+2 QUIT $EXTRACT(D,4,5)_"/"_$EXTRACT(D,6,7)_"/"_(1700+($EXTRACT(D,1,3)))
TRIBE(P) ;EP
+1 IF '$GET(P)
QUIT ""
+2 IF '$DATA(^AUPNPAT(P,11))
QUIT ""
+3 QUIT $$TRIBE^AUPNPAT(P,"C")_"^"_$$TRIBE^AUPNPAT(P,"E")
COMM(P) ;EP
+1 IF '$GET(P)
QUIT ""
+2 IF '$DATA(^AUPNPAT(P,11))
QUIT ""
+3 QUIT $$COMMRES^AUPNPAT(P,"E")
EAUDIT ;EP
+1 KILL ^BDMDATA("BDMEPI",$JOB)
+2 SET ^XTMP("BDMDM91",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2009"
+3 SET BDMEPIN=0
+4 SET BDMBEGD=$$FMADD^XLFDT(BDMADAT,-365)
+5 SET BDM3YE=$$FMADD^XLFDT(BDMADAT,-1096)
+6 IF BDMACTI=1
Begin DoDot:1
+7 SET BDMEAUT=0
FOR
SET BDMEAUT=$ORDER(^ACM(41,"B",BDMDMRG,BDMEAUT))
IF BDMEAUT'=+BDMEAUT
QUIT
Begin DoDot:2
+8 IF $PIECE($GET(^ACM(41,BDMEAUT,"DT")),U,1)'="A"
QUIT
+9 SET BDMPD=$PIECE(^ACM(41,BDMEAUT,0),U,2)
+10 IF $$DEMO^BDMUTL(BDMPD,$GET(BDMDEMO))
QUIT
+11 SET BDMX=$$ACTDMPT^BDMD91G(BDMPD,BDMBEGD,BDMADAT,BDMTAXI,BDMBEN,BDM3YE)
+12 ;not active diabetic
IF 'BDMX
QUIT
+13 IF BDMPREP=2
DO EPIREC
QUIT
+14 DO GATHER
End DoDot:2
+15 QUIT
End DoDot:1
+16 IF BDMACTI=0
SET BDMPD=0
FOR
SET BDMPD=$ORDER(^AUPNPAT(BDMPD))
IF 'BDMPD
QUIT
Begin DoDot:1
+17 SET BDMX=$$ACTDMPT^BDMD91G(BDMPD,BDMBEGD,BDMADAT,BDMTAXI,BDMBEN,BDM3YE)
+18 ;not active diabetic
IF 'BDMX
QUIT
+19 IF BDMACTI
IF '$$ACTONREG(BDMPD,BDMDMRG)
QUIT
+20 IF BDMPREP=2
DO EPIREC
QUIT
+21 DO GATHER
End DoDot:1
+22 IF BDMPREP=2
DO WRITEF^BDMD91
QUIT
+23 IF BDMPREP=3!(BDMPREP=4)
DO CUML^BDMD915
+24 QUIT
ACTONREG(P,R) ;
+1 IF '$DATA(^ACM(41,"AC",P,R))
QUIT 0
+2 SET X=^ACM(41,"AC",P,R)
+3 IF $PIECE($GET(^ACM(41,X,"DT")),U,1)'="A"
QUIT 0
+4 QUIT 1
+5 ;