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

BDMD010.m

Go to the documentation of this file.
BDMD010 ; IHS/CMI/LAB -IHS -GETS DATA FOR DIABETES QA REPORT ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**3**;JUN 14, 2007
 ;
 ;
EN ; - ENTRY POINT - from ^BDMASK
 K ^BDMDATA("BDMEPI",$J)
 S ^XTMP("BDMDM01",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2010"
 S BDMEPIN=0
 S BDMPD=0 F  S BDMPD=$O(^XTMP("BDMDM01",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^BDMD01 Q
 I BDMPREP=3!(BDMPREP=4) D CUML^BDMD015
 Q
S(P,I,V) ;
 S ^XTMP("BDMDM01",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^BDMD016(BDMPD,BDMDMRG,"I")
 I X>BDMADAT Q
 S BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2010 EPI REC 1",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT),BDMEPIN=BDMEPIN+1,^BDMDATA("BDMEPI",$J,BDMEPIN)=BDMEPIR
 S BDMTHER="",BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2010 EPI REC 2",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT),BDMEPIN=BDMEPIN+1,^BDMDATA("BDMEPI",$J,BDMEPIN)=BDMEPIR
 S BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2010 EPI REC 3",BDMRBD,BDMRED,BDMADAT,BDMDMRG,BDMBDAT),BDMEPIN=BDMEPIN+1,^BDMDATA("BDMEPI",$J,BDMEPIN)=BDMEPIR
 S BDMEPIR="",BDMEPIR=$$REC(BDMPD,"DM AUDIT 2010 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("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,1)=$S($G(BDMFISC)]"":BDMFISC,1:BDMRBD_" - "_BDMRED)
 ;set audit date to DT
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,2)=$$FMTE^XLFDT(DT)
 ;set area, su, facility code and name
 ;S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,4)=$P(^DIC(4,$S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U)
 ;S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,6)=$E($P(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),1,2)
 ;S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,8)=$E($P(^AUTTLOC($S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0),U,10),3,4)
 ;S ^XTMP("BDMDM01",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("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,12)=$S(BDMDMRG:$$RSTAT^BDMDM6(BDMDMRG,"A"),1:"")
 ;reviewer
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,14)=$P(^VA(200,DUZ,0),U,2)  ;reviewer initials
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,122)=$$COMM(BDMPD)
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,120)=$$TRIBE(BDMPD)  ;tribal enrollment code
 S ^XTMP("BDMDM01",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:"")  ;state of residence
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,15)=$$VAL^XBDIQ1(9000001,BDMPD,.14)  ;primary care provider
DEMO ;pat demographics
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,16)=$$HRN^AUPNPAT(BDMPD,$S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)))  ;hrn
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,18)=$$DOB^AUPNPAT(BDMPD,"E")  ;dob
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,20)=$$VAL^XBDIQ1(2,BDMPD,.02)  ;sex
DXDT ;dates of and dm dxs
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,22)=$S(BDMDMRG:$$CMSFDX^BDMD013(BDMPD,BDMDMRG,"D"),1:"")
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)=$S(BDMDMRG:$$CMSFDX^BDMD013(BDMPD,BDMDMRG,"DX"),1:"")
 S ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,23)=$$PLDMDOO^BDMD013(BDMPD)
 D S(BDMPD,25,$$PLDMDXS^BDMD013(BDMPD))
 D S(BDMPD,21,$$FRSTDMDX^BDMD013(BDMPD))
 D S(BDMPD,26,$$LASTDMDX^BDMD013(BDMPD,BDMRED))
 I $$DODX^BDMD016(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.")
 S BDMTYDM="" D TYPEDM,S(BDMPD,29,BDMTYDM)
 D S(BDMPD,27,$$TOBACCO^BDMD01T(BDMPD,$$DOB^AUPNPAT(BDMPD),BDMADAT))
 D S(BDMPD,28,$$CESS^BDMD011(BDMPD,BDMBDAT,BDMADAT))
 ;
VITAL ;
 D S(BDMPD,30,$$LASTHT^BDMD013(BDMPD,BDMRED))
 D S(BDMPD,32,$$LASTWT^BDMD013(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,112,$$BMI^BDMD018(BDMPD,BDMRBD,BDMRED))
 ;htn dx
 D S(BDMPD,34,$$HTNDX^BDMD013(BDMPD,BDMRED))
 ;last 3 BPs
 D S(BDMPD,36,$$BPS^BDMD013(BDMPD,BDMRBD,BDMRED))
EXAMS ;
 D S(BDMPD,38,$$DFE^BDMD017(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,40,$$EYE^BDMD017(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,42,$$DENTAL^BDMD017(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,44,$$DIETEDUC^BDMD017(BDMPD,BDMRBD,BDMRED))
 D S(BDMPD,46,$$EXEDUC^BDMD017(BDMPD,BDMRBD,BDMRED))
 D S(BDMPD,48,$$OTHEDUC^BDMD017(BDMPD,BDMRBD,BDMRED))
MH ;
 D S(BDMPD,200,$$DEPDX^BDMD012(BDMPD,BDMBDAT,BDMADAT))
 S BDMDEP=$E($G(^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,200)))
 D S(BDMPD,210,$S(BDMDEP="1":"",1:$$DEPSCR^BDMD012(BDMPD,BDMBDAT,BDMADAT)))
THERAPY ;
 S BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31)),BDM6MBD=$$FMTE^XLFDT(BDM6MBD)
 D S(BDMPD,52,$$INSULIN^BDMD012(BDMPD,BDM6MBD,BDMRED))
 D S(BDMPD,53,$$SULF^BDMD012(BDMPD,BDM6MBD,BDMRED))
 D S(BDMPD,98,$$SULFLIKE^BDMD012(BDMPD,BDM6MBD,BDMRED))
 D S(BDMPD,54,$$MET^BDMD012(BDMPD,BDM6MBD,BDMRED))
 D S(BDMPD,55,$$ACAR^BDMD012(BDMPD,BDM6MBD,BDMRED))
 D S(BDMPD,56,$$TROG^BDMD012(BDMPD,BDM6MBD,BDMRED))
 D S(BDMPD,58,$$INCR^BDMD012(BDMPD,BDM6MBD,BDMRED))  ;cmi/maw 12/18/2007 DM2010
 D S(BDMPD,59,$$DPP4^BDMD012(BDMPD,BDM6MBD,BDMRED))  ;cmi/maw 12/18/2010 DM2010
 D S(BDMPD,99,$$AMYLIN^BDMD012(BDMPD,BDM6MBD,BDMRED))
 S Z="" F X=52:1:56,58,59,98,99 I $E($G(^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)))="X" S Z=1  ;ANY MED AT ALL?
 S Y=$$REFMED^BDMD012(BDMPD,BDMRBD,BDMRED) S Y=$S(Z:"",Y="":"",1:"X"_U_$P(Y,U,2)) D S(BDMPD,57,Y)  ;REFUSAL OF A MED
 S Y="" F X=52:1:59,98,99 I $E($G(^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)))="X" S Y=1  ;cmi/maw 6/17/2010 per gary
 D S(BDMPD,51,$S(Y:"",1:"X"))
 D S(BDMPD,60,$$ACE^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 ;
IMM ;
 D S(BDMPD,62,$$ASPIRIN^BDMD016(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,300,$$STATIN^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 D S(BDMPD,301,$$FIBRATE^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 D S(BDMPD,302,$$NIACIN^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 D S(BDMPD,303,$$BILE^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 D S(BDMPD,304,$$EZET^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 D S(BDMPD,305,$$FISHOIL^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 D S(BDMPD,306,$$LOVAZA^BDMD016(BDMPD,BDM6MBD,BDMADAT))
 S Z=0 F X=300:1:306 I $E($G(^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,X)))="X" S Z=1  ;has one so skip refusal and none
 I Z G PPD
 S Y=$$REFMEDL^BDMD016(BDMPD,BDMBDAT,BDMRED) S Y=$S(Y="":"X",1:"X"_U_$P(Y,U,2)) D S(BDMPD,307,Y)
PPD ;
 D S(BDMPD,70,$$PPD^BDMD018(BDMPD,BDMADAT))
 D S(BDMPD,114,$$LASTNP^BDMD018(BDMPD,BDMADAT))
 D S(BDMPD,72,$$TBTX^BDMD012(BDMPD))
 D S(BDMPD,76,$$EKG^BDMD012(BDMPD,BDMADAT))
FLU ;
 D S(BDMPD,64,$$FLU^BDMD013(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,66,$$PNEU^BDMD013(BDMPD,BDMADAT))
 D S(BDMPD,68,$$TD^BDMD01B(BDMPD,BDMADAT))
LABS ;
 D S(BDMPD,78,$$HGBA1C^BDMD018(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,79,$$GFR^BDMD01C(BDMPD,BDMBDAT,BDMADAT))  ;cmi/maw 12/17/2007 DM2010
 D S(BDMPD,84,$$CREAT^BDMD018(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,86,$$CHOL^BDMD018(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,88,$$LDL^BDMD018(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,89,$$HDL^BDMD018(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,90,$$TRIG^BDMD018(BDMPD,BDMBDAT,BDMADAT))
 D S(BDMPD,92,$$URIN^BDMD018(BDMPD,BDMBDAT,BDMADAT))  ;cmi/maw 12/17/2007 DM2010
 ;
 Q
TYPEDM ;return type of DM in BDMTYDM
 NEW X
 I ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="NIDDM" S BDMTYDM="2  Type 2" Q
 I ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="TYPE II" S BDMTYDM="2  Type 2" Q
 I ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)[2 S BDMTYDM="2  Type 2" Q
 I ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)="IDDM" S BDMTYDM="1  Type 1" Q
 I ^XTMP("BDMDM01",BDMJOB,BDMBTH,"AUDIT",BDMPD,24)[1 S BDMTYDM="1  Type 1" Q
 S X=^XTMP("BDMDM01",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("BDMDM01",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("BDMDM01",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2010"
 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^BDMD01G(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^BDMD01G(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^BDMD01 Q
 I BDMPREP=3!(BDMPREP=4) D CUML^BDMD015
 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
 ;