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

APCLD710.m

Go to the documentation of this file.
APCLD710 ; IHS/CMI/LAB -IHS -GETS DATA FOR DIABETES QA REPORT ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
 ;
EN ; - ENTRY POINT - from ^APCLASK
 K ^APCLDATA("APCLEPI",$J)
 S ^XTMP("APCLDM71",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2007"
 S APCLEPIN=0
 S APCLPD=0 F  S APCLPD=$O(^XTMP("APCLDM71",APCLJOB,APCLBTH,"PATS",APCLPD)) Q:'APCLPD  D
 .I APCLTYPE'="P",APCLTYPE'="S" Q:$$DEMO^APCLUTL(APCLPD,$G(APCLDEMO))
 .I APCLPREP=2 D EPIREC Q
 .D GATHER
 I APCLPREP=2 D WRITEF^APCLD71 Q
 I APCLPREP=3!(APCLPREP=4) D CUML^APCLD715
 Q
S(P,I,V) ;
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",P,I)=V
 Q
REC(DFN,APCLRTYP,APCLRBD,APCLRED,APCLED,APCLDMRG,APCLBDAT) ;EP - called to send back a visit record as
 NEW APCLX,APCLREC
 S APCLREC=""
 S APCLRTYP("IEN")=$O(^APCLRECD("B",APCLRTYP,0))
 I 'APCLRTYP("IEN") Q APCLREC
PROC ;
 S APCLEPIX=0
 F  S APCLEPIX=$O(^APCLRECD(APCLRTYP("IEN"),11,"AC",APCLEPIX)) Q:APCLEPIX'=+APCLEPIX!(APCLREC=-1)  S APCLTTT=$O(^APCLRECD(APCLRTYP("IEN"),11,"AC",APCLEPIX,0))  D
 .S X="" X:$D(^APCLRECD(APCLRTYP("IEN"),11,APCLTTT,11)) ^APCLRECD(APCLRTYP("IEN"),11,APCLTTT,11)
 .S $E(APCLREC,$P(^APCLRECD(APCLRTYP("IEN"),11,APCLTTT,0),U,2))=X   ;W !,APCLTTT,?5,$P(^APCLRECD(APCLRTYP("IEN"),11,APCLTTT,0),U),?40,X
 Q APCLREC
EPIREC ;create epi info record in ^APCLDATA("APCLEPI",$J,n)
 S APCLEPIR="",APCLEPIR=$$REC(APCLPD,"DM AUDIT 2007 EPI REC 1",APCLRBD,APCLRED,APCLADAT,APCLDMRG,APCLBDAT),APCLEPIN=APCLEPIN+1,^APCLDATA("APCLEPI",$J,APCLEPIN)=APCLEPIR
 S APCLTHER="",APCLEPIR="",APCLEPIR=$$REC(APCLPD,"DM AUDIT 2007 EPI REC 2",APCLRBD,APCLRED,APCLADAT,APCLDMRG,APCLBDAT),APCLEPIN=APCLEPIN+1,^APCLDATA("APCLEPI",$J,APCLEPIN)=APCLEPIR
 S APCLEPIR="",APCLEPIR=$$REC(APCLPD,"DM AUDIT 2007 EPI REC 3",APCLRBD,APCLRED,APCLADAT,APCLDMRG,APCLBDAT),APCLEPIN=APCLEPIN+1,^APCLDATA("APCLEPI",$J,APCLEPIN)=APCLEPIR
 ;S APCLEPIR="",APCLEPIR=$$REC(APCLPD,"DM AUDIT 2007 EPI REC 4",APCLRBD,APCLRED,APCLADAT,APCLDMRG,APCLBDAT),APCLEPIN=APCLEPIN+1,^APCLDATA("APCLEPI",$J,APCLEPIN)=APCLEPIR
 Q
GATHER ;gather data for 1 patient
 S APCLER=0
 ;set report dates
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,1)=$S($G(APCLFISC)]"":APCLFISC,1:APCLRBD_" - "_APCLRED)
 ;set audit date to DT
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,2)=$$FMTE^XLFDT(DT)
 ;set area, su, facility code and name
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,4)=$P(^DIC(4,DUZ(2),0),U)
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,6)=$E($P(^AUTTLOC(DUZ(2),0),U,10),1,2)
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,8)=$E($P(^AUTTLOC(DUZ(2),0),U,10),3,4)
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,10)=$E($P(^AUTTLOC(DUZ(2),0),U,10),5,6)
 ;# pats in register
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,12)=$S(APCLDMRG:$$RSTAT^APCLDM6(APCLDMRG,"A"),1:"")
 ;reviewer
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,14)=$P(^VA(200,DUZ,0),U,2)
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,15)=$$VAL^XBDIQ1(9000001,APCLPD,.14)
DEMO ;pat demographics
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,16)=$$HRN^AUPNPAT(APCLPD,DUZ(2))
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,18)=$$DOB^AUPNPAT(APCLPD,"E")
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,20)=$$VAL^XBDIQ1(2,APCLPD,.02)
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,120)=$$TRIBE(APCLPD)
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,121)=$$COMM(APCLPD)
DXDT ;dates of and dm dxs
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,22)=$S(APCLDMRG:$$CMSFDX^APCLD713(APCLPD,APCLDMRG,"D"),1:"")
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,24)=$S(APCLDMRG:$$CMSFDX^APCLD713(APCLPD,APCLDMRG,"DX"),1:"")
 S ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,23)=$$PLDMDOO^APCLD713(APCLPD)
 D S(APCLPD,25,$$PLDMDXS^APCLD713(APCLPD))
 D S(APCLPD,21,$$FRSTDMDX^APCLD713(APCLPD))
 D S(APCLPD,26,$$LASTDMDX^APCLD713(APCLPD,APCLRED))
 D S(APCLPD,27,$$TOBACCO^APCLD716(APCLPD,APCLRED))
 S APCLTYDM="" D TYPEDM,S(APCLPD,29,APCLTYDM)
 D S(APCLPD,28,$$CESS^APCLD711(APCLPD,APCLRBD,APCLRED))
VITAL ;
 D S(APCLPD,30,$$LASTHT^APCLD713(APCLPD,APCLRED))
 D S(APCLPD,32,$$LASTWT^APCLD713(APCLPD,APCLRED))
 ;htn dx
 D S(APCLPD,34,$$HTNDX^APCLD713(APCLPD,APCLRED))
 ;last 3 BPs
 D S(APCLPD,36,$$BPS^APCLD713(APCLPD,APCLRBD,APCLRED))
EXAMS ;
 D S(APCLPD,38,$$DFE^APCLD717(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,40,$$EYE^APCLD717(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,42,$$DENTAL^APCLD717(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,44,$$DIETEDUC^APCLD717(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,46,$$EXEDUC^APCLD717(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,48,$$OTHEDUC^APCLD717(APCLPD,APCLRBD,APCLRED))
THERAPY ;
 S APCL6MBD=$$FMADD^XLFDT(APCLADAT,-(6*31)),APCL6MBD=$$FMTE^XLFDT(APCL6MBD)
 D S(APCLPD,52,$$INSULIN^APCLD712(APCLPD,APCL6MBD,APCLRED))
 D S(APCLPD,53,$$SULF^APCLD712(APCLPD,APCL6MBD,APCLRED))
 D S(APCLPD,54,$$MET^APCLD712(APCLPD,APCL6MBD,APCLRED))
 D S(APCLPD,55,$$ACAR^APCLD712(APCLPD,APCL6MBD,APCLRED))
 D S(APCLPD,56,$$TROG^APCLD712(APCLPD,APCL6MBD,APCLRED))
 S Y=$$REFMED^APCLD712(APCLPD,APCLRBD,APCLRED) S Y=$S(Y="":"",1:"X"_U_$P(Y,U,2)) D S(APCLPD,57,Y)
 S Y=0 F X=52:1:57 I $E(^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,X))="X" S Y=1
 D S(APCLPD,51,$S(Y:"",1:"X"))
 D S(APCLPD,60,$$ACE^APCLD716(APCLPD,APCL6MBD,APCLRED))
IMM ;
 D S(APCLPD,62,$$ASPIRIN^APCLD716(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,61,$$LIPID^APCLD716(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,64,$$FLU^APCLD713(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,66,$$PNEU^APCLD713(APCLPD,APCLRED))
 D S(APCLPD,68,$$TD^APCLD71B(APCLPD,APCLRED))
PPD ;
 D S(APCLPD,70,$$PPD^APCLD718(APCLPD,APCLRED))
 D S(APCLPD,114,$$LASTNP^APCLD718(APCLPD,APCLRED))
 D S(APCLPD,72,$$TBTX^APCLD712(APCLPD))
 D S(APCLPD,76,$$EKG^APCLD712(APCLPD,APCLRED))
LABS ;
 D S(APCLPD,78,$$HGBA1C^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 ;D S(APCLPD,82,$$BS^APCLD718(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,84,$$CREAT^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 D S(APCLPD,86,$$CHOL^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 D S(APCLPD,88,$$LDL^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 D S(APCLPD,89,$$HDL^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 D S(APCLPD,90,$$TRIG^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 D S(APCLPD,92,$$URIN^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 D S(APCLPD,94,$$PROTEIN^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 D S(APCLPD,96,$$MICRO^APCLD718(APCLPD,APCLBDAT,APCLADAT))
 ;D S(APCLPD,98,$$SELF^APCLD716(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,112,$$BMI^APCLD718(APCLPD,APCLRBD,APCLRED))
 D S(APCLPD,200,$$DEPDX^APCLD712(APCLPD,APCLBDAT,APCLADAT))
 S APCLDEP=$E($G(^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,200)))
 D S(APCLPD,210,$S(APCLDEP="Y":"",1:$$DEPSCR^APCLD712(APCLPD,APCLBDAT,APCLADAT)))
 ;
 Q
TYPEDM ;return type of DM in APCLTYDM
 NEW X
 I ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,24)="NIDDM" S APCLTYDM="2  Type 2" Q
 I ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,24)="TYPE II" S APCLTYDM="2  Type 2" Q
 I ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,24)[2 S APCLTYDM="2  Type 2" Q
 I ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,24)="IDDM" S APCLTYDM="1  Type 1" Q
 I ^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,24)[1 S APCLTYDM="1  Type 1" Q
 S X=^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,25) ;get problem list dxs
 F I=1:1 S C=$P(X,";",I) Q:C=""!(APCLTYDM]"")  I $E(C,6)=0!($E(C,6)=2) S APCLTYDM="2  Type 2"
 Q:APCLTYDM]""
 F I=1:1 S C=$P(X,";",I) Q:C=""!(APCLTYDM]"")  I $E(C,6)=1!($E(C,6)=3) S APCLTYDM="1  Type 1"
 Q:APCLTYDM]""
 S X=^XTMP("APCLDM71",APCLJOB,APCLBTH,"AUDIT",APCLPD,26) ;get pov list dxs
 I X[2 S APCLTYDM="2  Type 2" Q
 I X[1 S APCLTYDM="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,"C")_"^"_$$COMMRES^AUPNPAT(P,"E")
EAUDIT ;EP
 K ^APCLDATA("APCLEPI",$J)
 S ^XTMP("APCLDM71",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^DM AUDIT 2007"
 S APCLEPIN=0
 S APCLBEGD=$$FMADD^XLFDT(APCLADAT,-365)
 S APCL3YE=$$FMADD^XLFDT(APCLADAT,-1096)
 I APCLACTI=1 D
 .S APCLEAUT=0 F  S APCLEAUT=$O(^ACM(41,"B",APCLDMRG,APCLEAUT)) Q:APCLEAUT'=+APCLEAUT  D
 ..I $P($G(^ACM(41,APCLEAUT,"DT")),U,1)'="A" Q
 ..S APCLPD=$P(^ACM(41,APCLEAUT,0),U,2)
 ..Q:$$DEMO^APCLUTL(APCLPD,$G(APCLDEMO))
 ..S APCLX=$$ACTDMPT^APCLD71G(APCLPD,APCLBEGD,APCLADAT,APCLTAXI,APCLBEN,APCL3YE)
 ..I 'APCLX Q  ;not active diabetic
 ..I APCLPREP=2 D EPIREC Q
 ..D GATHER
 .Q
 I APCLACTI=0 S APCLPD=0 F  S APCLPD=$O(^AUPNPAT(APCLPD)) Q:'APCLPD  D
 .S APCLX=$$ACTDMPT^APCLD71G(APCLPD,APCLBEGD,APCLADAT,APCLTAXI,APCLBEN,APCL3YE)
 .I 'APCLX Q  ;not active diabetic
 .I APCLACTI,'$$ACTONREG(APCLPD,APCLDMRG) Q
 .I APCLPREP=2 D EPIREC Q
 .D GATHER
 I APCLPREP=2 D WRITEF^APCLD71 Q
 I APCLPREP=3!(APCLPREP=4) D CUML^APCLD715
 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