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

BDMPE10.m

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