BDMPD10 ; IHS/CMI/LAB -IHS -GETS DATA FOR DIABETES QA REPORT ;
;;2.0;DIABETES MANAGEMENT SYSTEM;**9**;JUN 14, 2007;Build 78
;
;
EN ; - ENTRY POINT - from ^BDMASK
D UNFOLDTX^BDMUTL(2016)
K ^BDMDATA("BDMEPI",$J)
S ^XTMP("BDMPD1",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^PRE DM AUDIT 2016"
S BDMEPIN=0
S BDMPD=0 F S BDMPD=$O(^XTMP("BDMPD1",BDMJOB,BDMBTH,"PATS",BDMPD)) Q:'BDMPD D
.I BDMTYPE'="P",BDMTYPE'="S" Q:$$DEMO^BDMUTL(BDMPD,$G(BDMDEMO))
.D GATHER
I BDMPREP=2!(BDMPREP=3) D CUML^BDMPD15
Q
S(P,I,V) ;
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",P,I)=V
Q
GATHER ;gather data for 1 patient
S BDMER=0
;set report dates
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,1)=$S($G(BDMFISC)]"":BDMFISC,1:BDMRBD_" - "_BDMRED)
;set audit date to DT
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,2)=$$FMTE^XLFDT(DT)
;set area, su, facility code and name
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,4)=$P(^DIC(4,$S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,6)=$E($P(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),1,2)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,8)=$E($P(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),3,4)
S ^XTMP("BDMPD1",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("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,12)=$S(BDMDMRG:$$RSTAT^BDMDM6(BDMDMRG,"A"),1:"")
;reviewer
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,14)=$P(^VA(200,DUZ,0),U,2)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,15)=$$VAL^XBDIQ1(9000001,BDMPD,.14)
DEMO ;pat demographics
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,16)=$$HRN^AUPNPAT(BDMPD,$S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)))
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,18)=$$DOB^AUPNPAT(BDMPD,"E")
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,20)=$$VAL^XBDIQ1(2,BDMPD,.02)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,120)=$$TRIBE(BDMPD)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,121)=$$COMM(BDMPD)
DXDT ;dates of and dm dxs
K BDMDCTA D IFG^BDMPD13(BDMPD,.BDMDCTA)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,200)=$S($D(BDMDCTA):"Yes",1:"No")
S X=0 F S X=$O(BDMDCTA(X)) Q:X'=+X D
.S Y=200_"."_X
.S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
K BDMDCTA D IGT^BDMPD13(BDMPD,.BDMDCTA)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,210)=$S($D(BDMDCTA):"Yes",1:"No")
S X=0 F S X=$O(BDMDCTA(X)) Q:X'=+X D
.S Y=210_"."_X
.S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
K BDMDCTA D MS^BDMPD13(BDMPD,.BDMDCTA)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,220)=$S($D(BDMDCTA):"Yes",1:"No")
S X=0 F S X=$O(BDMDCTA(X)) Q:X'=+X D
.S Y=220_"."_X
.S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
K BDMDCTA D ABNG^BDMPD13(BDMPD,.BDMDCTA)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,230)=$S($D(BDMDCTA):"Yes",1:"No")
S X=0 F S X=$O(BDMDCTA(X)) Q:X'=+X D
.S Y=230_"."_X
.S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,22)=$S(BDMDMRG:$$CMSFDX^BDMDD13(BDMPD,BDMDMRG,"D"),1:"")
S ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)=$S(BDMDMRG:$$CMSFDX^BDMDD13(BDMPD,BDMDMRG,"DX"),1:"")
I $$PLDMDXS^BDMDD13(BDMPD)]"" D S(BDMPD,25,"PLEASE NOTE: Diabetes is on the Problem list for this patient")
S X=$$FRSTDMDX^BDMDD13(BDMPD,"E") I X]"" D S(BDMPD,26,"PLEASE NOTE: Diabetes has been used as a diagnosis in PCC: "_X)
D S(BDMPD,27,$P($$TOBACCO^BDMDD1T(BDMPD,$$DOB^AUPNPAT(BDMPD),BDMADAT),U,2))
D S(BDMPD,28,$$CESS^BDMDD11(BDMPD,BDMBDAT,BDMADAT))
VITAL ;
D S(BDMPD,30,$$LASTHT^BDMDD13(BDMPD,BDMADAT))
D S(BDMPD,32,$$LASTWT^BDMPD13(BDMPD,BDMADAT))
D S(BDMPD,33,$$LASTWC^BDMPD13(BDMPD,BDMADAT))
;htn dx
S X=$$HTNDX^BDMDD13(BDMPD,BDMADAT) D S(BDMPD,34,$S($E(X)=1:"Yes",1:"No"))
;last 3 BPs
D S(BDMPD,36,$$BPS^BDMDD13(BDMPD,BDMRBD,BDMRED))
EXAMS ;
S X=$$DIETEDUC^BDMDD17(BDMPD,BDMRBD,BDMRED),X=$P(X,U),X=$P(X," ",2) D S(BDMPD,44,X)
D S(BDMPD,46,$$EXEDUC^BDMDD17(BDMPD,BDMBDAT,BDMADAT))
THERAPY ;
S BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31)),BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
D S(BDMPD,53,$$SULF^BDMDD12(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,54,$$MET^BDMDD12(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,55,$$ACAR^BDMDD12(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,56,$$TROG^BDMDD12(BDMPD,BDM6MBD,BDMRED))
S Y="" F X=53:1:56 I ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)="X" S Y=1
D S(BDMPD,51,$S(Y:"",1:"X"))
D S(BDMPD,60,$$ACE^BDMDD16(BDMPD,BDM6MBD,BDMRED))
IMM ;
D S(BDMPD,62,$$ASPIRIN^BDMPD16(BDMPD,BDMRBD,BDMRED))
D S(BDMPD,61,$$LIPID^BDMPD16(BDMPD,BDM6MBD,BDMRED))
D S(BDMPD,76,$$EKG^BDMPD12(BDMPD,BDMRED))
LABS ;
D S(BDMPD,90,$$FGLUCOSE^BDMDD18(BDMPD,$P(^DPT(BDMPD,0),U,3),BDMADAT))
D S(BDMPD,91,$$G75^BDMDD18(BDMPD,$P(^DPT(BDMPD,0),U,3),BDMADAT))
D S(BDMPD,86,$$CHOL^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,88,$$LDL^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,89,$$HDL^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
D S(BDMPD,190,$$TRIG^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
;
D S(BDMPD,112,$$BMI^BDMDD18(BDMPD,BDMRBD,BDMRED))
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,"C")_"^"_$$COMMRES^AUPNPAT(P,"E")
BDMPD10 ; IHS/CMI/LAB -IHS -GETS DATA FOR DIABETES QA REPORT ;
+1 ;;2.0;DIABETES MANAGEMENT SYSTEM;**9**;JUN 14, 2007;Build 78
+2 ;
+3 ;
EN ; - ENTRY POINT - from ^BDMASK
+1 DO UNFOLDTX^BDMUTL(2016)
+2 KILL ^BDMDATA("BDMEPI",$JOB)
+3 SET ^XTMP("BDMPD1",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^PRE DM AUDIT 2016"
+4 SET BDMEPIN=0
+5 SET BDMPD=0
FOR
SET BDMPD=$ORDER(^XTMP("BDMPD1",BDMJOB,BDMBTH,"PATS",BDMPD))
IF 'BDMPD
QUIT
Begin DoDot:1
+6 IF BDMTYPE'="P"
IF BDMTYPE'="S"
IF $$DEMO^BDMUTL(BDMPD,$GET(BDMDEMO))
QUIT
+7 DO GATHER
End DoDot:1
+8 IF BDMPREP=2!(BDMPREP=3)
DO CUML^BDMPD15
+9 QUIT
S(P,I,V) ;
+1 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",P,I)=V
+2 QUIT
GATHER ;gather data for 1 patient
+1 SET BDMER=0
+1 ;set report dates
+2 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,1)=$SELECT($GET(BDMFISC)]"":BDMFISC,1:BDMRBD_" - "_BDMRED)
+3 ;set audit date to DT
+4 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,2)=$$FMTE^XLFDT(DT)
+5 ;set area, su, facility code and name
+6 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,4)=$PIECE(^DIC(4,$SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U)
+7 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,6)=$EXTRACT($PIECE(^AUTTLOC($SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),1,2)
+8 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,8)=$EXTRACT($PIECE(^AUTTLOC($SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),3,4)
+9 SET ^XTMP("BDMPD1",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("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,12)=$SELECT(BDMDMRG:$$RSTAT^BDMDM6(BDMDMRG,"A"),1:"")
+12 ;reviewer
+13 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,14)=$PIECE(^VA(200,DUZ,0),U,2)
+14 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,15)=$$VAL^XBDIQ1(9000001,BDMPD,.14)
DEMO ;pat demographics
+1 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,16)=$$HRN^AUPNPAT(BDMPD,$SELECT($GET(BDMDUZ2):BDMDUZ2,1:DUZ(2)))
+2 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,18)=$$DOB^AUPNPAT(BDMPD,"E")
+3 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,20)=$$VAL^XBDIQ1(2,BDMPD,.02)
+4 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,120)=$$TRIBE(BDMPD)
+5 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,121)=$$COMM(BDMPD)
DXDT ;dates of and dm dxs
+1 KILL BDMDCTA
DO IFG^BDMPD13(BDMPD,.BDMDCTA)
+2 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,200)=$SELECT($DATA(BDMDCTA):"Yes",1:"No")
+3 SET X=0
FOR
SET X=$ORDER(BDMDCTA(X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET Y=200_"."_X
+5 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
End DoDot:1
+6 KILL BDMDCTA
DO IGT^BDMPD13(BDMPD,.BDMDCTA)
+7 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,210)=$SELECT($DATA(BDMDCTA):"Yes",1:"No")
+8 SET X=0
FOR
SET X=$ORDER(BDMDCTA(X))
IF X'=+X
QUIT
Begin DoDot:1
+9 SET Y=210_"."_X
+10 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
End DoDot:1
+11 KILL BDMDCTA
DO MS^BDMPD13(BDMPD,.BDMDCTA)
+12 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,220)=$SELECT($DATA(BDMDCTA):"Yes",1:"No")
+13 SET X=0
FOR
SET X=$ORDER(BDMDCTA(X))
IF X'=+X
QUIT
Begin DoDot:1
+14 SET Y=220_"."_X
+15 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
End DoDot:1
+16 KILL BDMDCTA
DO ABNG^BDMPD13(BDMPD,.BDMDCTA)
+17 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,230)=$SELECT($DATA(BDMDCTA):"Yes",1:"No")
+18 SET X=0
FOR
SET X=$ORDER(BDMDCTA(X))
IF X'=+X
QUIT
Begin DoDot:1
+19 SET Y=230_"."_X
+20 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,Y)=BDMDCTA(X)
End DoDot:1
+21 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,22)=$SELECT(BDMDMRG:$$CMSFDX^BDMDD13(BDMPD,BDMDMRG,"D"),1:"")
+22 SET ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)=$SELECT(BDMDMRG:$$CMSFDX^BDMDD13(BDMPD,BDMDMRG,"DX"),1:"")
+23 IF $$PLDMDXS^BDMDD13(BDMPD)]""
DO S(BDMPD,25,"PLEASE NOTE: Diabetes is on the Problem list for this patient")
+24 SET X=$$FRSTDMDX^BDMDD13(BDMPD,"E")
IF X]""
DO S(BDMPD,26,"PLEASE NOTE: Diabetes has been used as a diagnosis in PCC: "_X)
+25 DO S(BDMPD,27,$PIECE($$TOBACCO^BDMDD1T(BDMPD,$$DOB^AUPNPAT(BDMPD),BDMADAT),U,2))
+26 DO S(BDMPD,28,$$CESS^BDMDD11(BDMPD,BDMBDAT,BDMADAT))
VITAL ;
+1 DO S(BDMPD,30,$$LASTHT^BDMDD13(BDMPD,BDMADAT))
+2 DO S(BDMPD,32,$$LASTWT^BDMPD13(BDMPD,BDMADAT))
+3 DO S(BDMPD,33,$$LASTWC^BDMPD13(BDMPD,BDMADAT))
+4 ;htn dx
+5 SET X=$$HTNDX^BDMDD13(BDMPD,BDMADAT)
DO S(BDMPD,34,$SELECT($EXTRACT(X)=1:"Yes",1:"No"))
+6 ;last 3 BPs
+7 DO S(BDMPD,36,$$BPS^BDMDD13(BDMPD,BDMRBD,BDMRED))
EXAMS ;
+1 SET X=$$DIETEDUC^BDMDD17(BDMPD,BDMRBD,BDMRED)
SET X=$PIECE(X,U)
SET X=$PIECE(X," ",2)
DO S(BDMPD,44,X)
+2 DO S(BDMPD,46,$$EXEDUC^BDMDD17(BDMPD,BDMBDAT,BDMADAT))
THERAPY ;
+1 SET BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31))
SET BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
+2 DO S(BDMPD,53,$$SULF^BDMDD12(BDMPD,BDM6MBD,BDMRED))
+3 DO S(BDMPD,54,$$MET^BDMDD12(BDMPD,BDM6MBD,BDMRED))
+4 DO S(BDMPD,55,$$ACAR^BDMDD12(BDMPD,BDM6MBD,BDMRED))
+5 DO S(BDMPD,56,$$TROG^BDMDD12(BDMPD,BDM6MBD,BDMRED))
+6 SET Y=""
FOR X=53:1:56
IF ^XTMP("BDMPD1",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)="X"
SET Y=1
+7 DO S(BDMPD,51,$SELECT(Y:"",1:"X"))
+8 DO S(BDMPD,60,$$ACE^BDMDD16(BDMPD,BDM6MBD,BDMRED))
IMM ;
+1 DO S(BDMPD,62,$$ASPIRIN^BDMPD16(BDMPD,BDMRBD,BDMRED))
+2 DO S(BDMPD,61,$$LIPID^BDMPD16(BDMPD,BDM6MBD,BDMRED))
+3 DO S(BDMPD,76,$$EKG^BDMPD12(BDMPD,BDMRED))
LABS ;
+1 DO S(BDMPD,90,$$FGLUCOSE^BDMDD18(BDMPD,$PIECE(^DPT(BDMPD,0),U,3),BDMADAT))
+2 DO S(BDMPD,91,$$G75^BDMDD18(BDMPD,$PIECE(^DPT(BDMPD,0),U,3),BDMADAT))
+3 DO S(BDMPD,86,$$CHOL^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
+4 DO S(BDMPD,88,$$LDL^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
+5 DO S(BDMPD,89,$$HDL^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
+6 DO S(BDMPD,190,$$TRIG^BDMDD18(BDMPD,BDMBDAT,BDMADAT))
+7 ;
+8 DO S(BDMPD,112,$$BMI^BDMDD18(BDMPD,BDMRBD,BDMRED))
+9 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,"C")_"^"_$$COMMRES^AUPNPAT(P,"E")