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

BDMPG10.m

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