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