BHSDMPRE ;IHS/CIA/MGH - Health Summary for Pre-Diabetic Supplement ;30-Nov-2015 10:25;DU
;;1.0;HEALTH SUMMARY COMPONENTS;**1,2,4,6,8,12**;March 17, 2006;Build 3
;===================================================================
;VA version of IHS components for supplemental summaries
;Taken from APCHS9D1
; IHS/TUCSON/LAB - DIABETIC CARE SUMMARY SUPPLEMENT ; [ 05/10/04 2:03 PM ]
;;2.0;IHS RPMS/PCC Health Summary;**3,5,6,8,9,10,11,12**;JUN 24, 1997
;Patch 4 skip vitals entered in error
;Patch 8 BMI is now stored value
;Patch 12 use new API for taxonomies
;====================================================================
;
EP ;EP - called from component
N BHSPAT
S BHSPAT=DFN
Q:'$G(BHSPAT)
I $$PLTAX^BHSMU(BHSPAT,"SURVEILLANCE DIABETES") Q ;has diabetes
S X=$$LASTITEM^BHSMU(BHSPAT,"[SURVEILLANCE DIABETES","DX")
I X>$$FMADD^XLFDT(DT,-366) Q ;if date of last dm dx is w/in past year then quit
D CKP^GMTSUP Q:$D(GMTSQIT)
D EP2(BHSPAT)
W ;write out array
W:$D(IOF) @IOF
K APCHQUIT
S APCHX=0 F S APCHX=$O(^TMP("BHS",$J,"DCS",APCHX)) Q:APCHX'=+APCHX!($D(APCHQUIT)) D
.D CKP^GMTSUP Q:$D(GMTSQIT)
.W !,^TMP("BHS",$J,"DCS",APCHX)
.Q
I $D(APCHQUIT) S GMTSQIT=1
D EOJ
Q
;
EOJ ;
K APCHX,APCHQUIT,APCHY,APCHIEN,APCHHT,BHSDFN,BHSBEG,BHSTOB,BHSUPI,BHSDD,BHSINT,BHSWD,BHSED,APCHTOBN,APCHTOB,BHSTEX,BDMSDFN,BSMSBEG
K N,%,T,F,X,Y,B,C,E,F,H,L,N,P,T,W,M
Q
EP2(BHSDFN) ;PEP - PASS DFN get back array of patient care summary
;at this point you are stuck with ^TMP("BHS",$J,"DCS"
K ^TMP("BHS",$J,"DCS")
S ^TMP("BHS",$J,"DCS",0)=0
D SETARRAY
Q
SETARRAY ;set up array containing dm care summary
;CHECK TO SEE IF START1^APCLDF EXISTS
S X="APCLDF" X ^%ZOSF("TEST") I '$T Q
S X="PREDIABETES PATIENT CARE SUMMARY Report Date: "_$$FMTE^XLFDT(DT) D S(X)
S X="Patient Name: "_$P(^DPT(BHSDFN,0),U)_" HRN: "_$$HRN^AUPNPAT(BHSDFN,DUZ(2)) D S(X)
S X="Age: "_$$AGE^AUPNPAT(BHSDFN),$E(X,15)="Sex: "_$$SEX^AUPNPAT(BHSDFN)_" DOB: "_$$FMTE^XLFDT($$DOB^AUPNPAT(BHSDFN)) D S(X)
S X="Classification:" D S(X,1)
S Y=$$IFG(BHSDFN) S X="",$E(X,2)=$S($P(Y,U)=1:"Yes",1:"No"),$E(X,8)="Impaired Fasting Glucose" I $P(Y,U)=1 S X=X_": "_$P(Y,U,3)_": "_$$FMTE^XLFDT($P(Y,U,2))
D S(X)
S Y=$$IGT(BHSDFN) S X="",$E(X,2)=$S($P(Y,U)=1:"Yes",1:"No"),$E(X,8)="Impaired Glucose Tolerance" I $P(Y,U)=1 S X=X_": "_$P(Y,U,3)_": "_$$FMTE^XLFDT($P(Y,U,2))
D S(X)
S Y=$$MS(BHSDFN) S X="",$E(X,2)=$S($P(Y,U)=1:"Yes",1:"No"),$E(X,8)="Metabolic Syndrome" I $P(Y,U)=1 S X=X_": "_$P(Y,U,3)_": "_$$FMTE^XLFDT($P(Y,U,2))
D S(X)
S X=" " D S(X)
S X="Case Manager: "_$$CMSMAN(BHSDFN) D S(X) ;HOW TO FIND CASE MANAGER - LORI
S X="Primary Care Provider: "_$$VAL^XBDIQ1(9000001,BHSDFN,.14) D S(X)
S X=" " D S(X)
D GETHWB(BHSDFN,DT)
S X=" Last Height: "_APCHX(1,"HT")_$S(APCHX(1,"HT")]"":" inches",1:""),$E(X,33)=APCHX(1,"HTD") D S(X)
S X="Last 3 Weight: "_$S(APCHX(1,"WT")]"":$J(APCHX(1,"WT"),3,0),1:"")_$S(APCHX(1,"WT")]"":" lbs",1:""),$E(X,33)=APCHX(1,"WTD"),$E(X,47)="BMI: "_APCHX(1,"BMI") D S(X)
S X="",$E(X,17)=$S(APCHX(2,"WT")]"":$J(APCHX(2,"WT"),3,0),1:"")_$S(APCHX(2,"WT")]"":" lbs",1:""),$E(X,33)=APCHX(2,"WTD"),$E(X,47)="BMI: "_APCHX(2,"BMI") D S(X)
S X="",$E(X,17)=$S(APCHX(3,"WT")]"":$J(APCHX(3,"WT"),3,0),1:"")_$S(APCHX(3,"WT")]"":" lbs",1:""),$E(X,33)=APCHX(3,"WTD"),$E(X,47)="BMI: "_APCHX(3,"BMI") D S(X)
I APCHX(1,"WC")]"" S X="Last Waist Circumference: "_APCHX(1,"WC"),$E(X,33)=APCHX(1,"WCD") D S(X,1)
S B=$$BP(BHSDFN)
S X="Last 3 non-ER BP: "_$P($G(APCHX(1)),U,2)_" "_$$FMTE^XLFDT($P($G(APCHX(1)),U))
D S(X,1)
S X="" I $D(APCHX(2)) S X="",$E(X,20)=$P(APCHX(2),U,2)_" "_$$FMTE^XLFDT($P(APCHX(2),U))
D S(X)
S X="" I $D(APCHX(3)) S X="",$E(X,20)=$P(APCHX(3),U,2)_" "_$$FMTE^XLFDT($P(APCHX(3),U))
D S(X)
;Patch 6
N BDMSDFN,BDMTOBC,BDMTOBS,BDMSBEG
S BDMSDFN=BHSDFN
D TOBACCO^BDMS9B3
S X="Tobacco Use: "_$P($G(BDMTOBS),U,1) D S(X)
I $G(BDMTOBC)]"" S X=" "_$P(BDMTOBC,U,1) D S(X)
S X="Prediabetes Education Provided (in past yr):" D S(X,1)
S X=" Last Dietitian Visit: "_$$DIETV^BDMS9B3(BHSDFN) D S(X)
S (BHSBEG,BDMSBEG)=$$FMADD^XLFDT(DT,-366)
K APCHX D EDUC^BDMS9B2 I $D(APCHX) D
.S %=0 F S %=$O(APCHX(%)) Q:%'=+% S X=" "_APCHX(%) D S(X)
K APCHX,APCHY,%
D EDUCREF^BHSDM3 I $D(APCHX) S X="In the past year, the patient has refused the following Diabetes education:" D S(X,1) D
.S %="" F S %=$O(APCHX(%)) Q:%="" S X=" "_%_" "_APCHX(%) D S(X)
K APCHX,APCHY,%
S X="HTN Diagnosed: "_$$HTN(BHSDFN) D S(X,1)
S BHSBEG=$$FMADD^XLFDT(DT,-(6*30.5))
S %=$$ACE^BDMS9B5(BHSDFN,BHSBEG) ;get date of last ACE in last year
S X="",X="ON ACE Inhibitor/ARB in past 6 months: "_% D S(X)
K BHSX S BHSBEG=$$FMADD^XLFDT(DT,-365) S X="Aspirin Use (in past yr): "_$E($$ASPIRIN(BHSDFN,BHSBEG),1,32) D S(X)
S X="",X=$$ASPREF^BDMS9B5(BHSDFN) I X]"" S X=" "_X D S(X)
M12 ;
;Patch 1001, new routine to call
D MORE^BHSDMPR1
S X=$P(^DPT(BHSDFN,0),U),$E(X,35)="DOB: "_$$DOB^AUPNPAT(BHSDFN,"S"),$E(X,55)="Chart #"_$$HRN^AUPNPAT(BHSDFN,DUZ(2),2) D S(X,1)
Q
S(Y,F,C,T) ;set up array
I '$G(F) S F=0
I '$G(T) S T=0
NEW %,X
F F=1:1:F S X="" D S1
S X=Y
I $G(C) S L=$L(Y),T=(80-L)/2 D D S1 Q
.F %=1:1:(T-1) S X=" "_X
F %=1:1:T S X=" "_Y
D S1
Q
S1 ;
S %=$P(^TMP("BHS",$J,"DCS",0),U)+1,$P(^TMP("BHS",$J,"DCS",0),U)=%
S ^TMP("BHS",$J,"DCS",%)=X
Q
CMSMAN(P,F) ;EP - return date/dx of dm in register
I $G(F)="" S F="E"
I '$G(P) Q ""
NEW R,N,D,D1,Y,X,G S R=0,N="",D="" F S N=$O(^ACM(41.1,"B",N)) Q:N=""!(D]"") S R=0 F S R=$O(^ACM(41.1,"B",N,R)) Q:R'=+R!(D]"") I N["DIAB" D
.S (G,X)=0,(D,Y)="" F S X=$O(^ACM(41,"C",P,X)) Q:X'=+X!(D]"") I $P(^ACM(41,X,0),U,4)=R D
..S D=$P($G(^ACM(41,X,"DT")),U,6) I D]"" S D=$P(^VA(200,D,0),U)
Q $G(D)
;
MS(P) ;
NEW X,Y,I,APCHY,%
S X=$$PLCODE^BHSMU(P,"277.7",2) I X D Q Y
.S D=$P(^AUPNPROB(X,0),U,13) I D]"" S Y=1_U_D_U_"Date of Onset from Problem List" Q
.S D=$P(^AUPNPROB(X,0),U,8) I D]"" S Y=1_U_D_U_"Date Added to Problem List" Q
.S Y=1_U_D_U_"Problem List" Q
K APCHY S %=P_"^FIRST DX 277.7",E=$$START1^APCLDF(%,"APCHY(")
I $D(APCHY(1)) Q 1_U_$P(APCHY(1),U)_U_"Date of first DX in PCC"
Q ""
IGT(P) ;
NEW X,Y,I,APCHY,%
S X=$$PLCODE^BHSMU(P,"790.22",2) I X D Q Y
.S D=$P(^AUPNPROB(X,0),U,13) I D]"" S Y=1_U_D_U_"Date of Onset from Problem List" Q
.S D=$P(^AUPNPROB(X,0),U,8) I D]"" S Y=1_U_D_U_"Date Added to Problem List" Q
.S Y=1_U_D_U_"Problem List" Q
K APCHY S %=P_"^FIRST DX 790.22",E=$$START1^APCLDF(%,"APCHY(")
I $D(APCHY(1)) Q 1_U_$P(APCHY(1),U)_U_"Date of first DX in PCC"
Q ""
IFG(P) ;
NEW X,Y,I,APCHY,%
S X=$$PLCODE^BHSMU(P,"790.21",2) I X D Q Y
.S D=$P(^AUPNPROB(X,0),U,13) I D]"" S Y=1_U_D_U_"Date of Onset from Problem List" Q
.S D=$P(^AUPNPROB(X,0),U,8) I D]"" S Y=1_U_D_U_"Date Added to Problem List" Q
.S Y=1_U_D_U_"Problem List" Q
K APCHY S %=P_"^FIRST DX 790.21",E=$$START1^APCLDF(%,"APCHY(")
I $D(APCHY(1)) Q 1_U_$P(APCHY(1),U)_U_"Date of first DX in PCC"
Q ""
HTN(P) ;
N T
S T=$O(^ATXAX("B","SURVEILLANCE HYPERTENSION",0))
I 'T Q ""
N X,Y,I S (X,Y,I)=0 F S X=$O(^AUPNPROB("AC",P,X)) Q:X'=+X!(I) D
.;IHS/MSC/MGH New API P11
.I $D(^AUPNPROB(X,0)) S Y=$P(^AUPNPROB(X,0),U) I $$ICD^ATXAPI(Y,T,9) S I=1
I I Q "Yes"
NEW APCHX
S APCHX=""
S X=P_"^LAST 3 DX [SURVEILLANCE HYPERTENSION" S E=$$START1^APCLDF(X,"APCHX(") G:E HTNX I $D(APCHX(3)) S APCHX="Yes"
I $G(APCHX)="" S APCHX="No"
HTNX ;
Q APCHX
BP(P) ;last 3 BPs - NON ER
NEW APCHD,APCHC
K APCHX
S APCHX="",APCHD="",APCHC=0
S T=$O(^AUTTMSR("B","BP",""))
F S APCHD=$O(^AUPNVMSR("AA",P,T,APCHD)) Q:APCHD=""!(APCHC=3) D
.S M=0 F S M=$O(^AUPNVMSR("AA",P,T,APCHD,M)) Q:M'=+M!(APCHC=3) D
..S V=$P($G(^AUPNVMSR(M,0)),U,3) Q:'V
..Q:'$D(^AUPNVSIT(V,0))
..Q:$P($G(^AUPNVMSR(M,2)),U,1) ;entered in error
..Q:$$CLINIC^APCLV(V,"C")=30
..S APCHC=APCHC+1,APCHX(APCHC)=(9999999-APCHD)_U_$P(^AUPNVMSR(M,0),U,4)
..Q
.Q
I '$D(APCHX(1)) S APCHX(1)="None recorded"
BPX ;
K APCHD,APCHC
Q APCHX
GETHWB(P,EDATE) ;get last height, height date, weight, weight date and BMI for patient P, return in APCHX("HT"),APCHX("HTD"),APCHX("WT"),APCHX("WTD"),APCHX("BMI")
K APCHX
F X=1:1:3 S APCHX(X,"HT")="",APCHX(X,"HTD")="",APCHX(X,"WT")="",APCHX(X,"WTD")="",APCHX(X,"BMI")="",APCHX(X,"WC")="",APCHX(X,"WCD")="",APCHX(X,"WTI")=""
LASTHT ;
Q:'$D(^AUPNVSIT("AC",P))
Q:'$D(^AUPNVMSR("AC",P))
NEW APCHY
S %=P_"^LAST 3 MEAS HT" NEW X S E=$$START1^APCLDF(%,"APCHY(")
S APCHX(1,"HT")=$P($G(APCHY(1)),U,2),APCHX(1,"HTD")=$$FMTE^XLFDT($P($G(APCHY(1)),U))
S APCHX(1,"HT")=$S(APCHX(1,"HT")]"":$J(APCHX(1,"HT"),2,0),1:"")
S APCHX(2,"HT")=$P($G(APCHY(2)),U,2),APCHX(2,"HTD")=$$FMTE^XLFDT($P($G(APCHY(2)),U))
S APCHX(2,"HT")=$S(APCHX(2,"HT")]"":$J(APCHX(2,"HT"),2,0),1:"")
S APCHX(3,"HT")=$P($G(APCHY(3)),U,2),APCHX(3,"HTD")=$$FMTE^XLFDT($P($G(APCHY(3)),U))
S APCHX(3,"HT")=$S(APCHX(3,"HT")]"":$J(APCHX(3,"HT"),2,0),1:"")
LASTWT ;
K APCHY S %=P_"^LAST 3 MEAS WT" NEW X S E=$$START1^APCLDF(%,"APCHY(")
S APCHX(1,"WT")=$P($G(APCHY(1)),U,2),APCHX(1,"WTD")=$$FMTE^XLFDT($P($G(APCHY(1)),U)),APCHX(1,"WTI")=$P($G(APCHY(1)),U)
S APCHX(2,"WT")=$P($G(APCHY(2)),U,2),APCHX(2,"WTD")=$$FMTE^XLFDT($P($G(APCHY(2)),U)),APCHX(2,"WTI")=$P($G(APCHY(2)),U)
S APCHX(3,"WT")=$P($G(APCHY(3)),U,2),APCHX(3,"WTD")=$$FMTE^XLFDT($P($G(APCHY(3)),U)),APCHX(3,"WTI")=$P($G(APCHY(3)),U)
LASTWC ;
K APCHY S %=P_"^LAST 3 MEAS WC" NEW X S E=$$START1^APCLDF(%,"APCHY(")
S APCHX(1,"WC")=$P($G(APCHY(1)),U,2),APCHX(1,"WCD")=$$FMTE^XLFDT($P($G(APCHY(1)),U))
S APCHX(2,"WC")=$P($G(APCHY(2)),U,2),APCHX(2,"WCD")=$$FMTE^XLFDT($P($G(APCHY(2)),U))
S APCHX(3,"WC")=$P($G(APCHY(3)),U,2),APCHX(3,"WCD")=$$FMTE^XLFDT($P($G(APCHY(3)),U))
BMI ;
K APCHY S %=P_"^LAST 3 MEAS BMI" NEW X S E=$$START1^APCLDF(%,"APCHY(")
S APCHX(1,"BMI")=$P($G(APCHY(1)),U,2),APCHX(1,"BMD")=$$FMTE^XLFDT($P($G(APCHY(1)),U))
S APCHX(2,"BMI")=$P($G(APCHY(2)),U,2),APCHX(2,"BMD")=$$FMTE^XLFDT($P($G(APCHY(2)),U))
S APCHX(3,"BMI")=$P($G(APCHY(3)),U,2),APCHX(3,"BMD")=$$FMTE^XLFDT($P($G(APCHY(3)),U))
;Patch 8 added BMI
;F APCHY=1:1:3 D
;.I APCHX(APCHY,"WT")="" Q ;no weight
;.S APCHHT=""
;.I $$AGE^AUPNPAT(P)<19 D Q:APCHHT=""
;..;Get weight on that date
;..S Y=0 F S Y=$O(APCHX(Y)) Q:Y'=+Y I APCHX(Y,"HTD")=APCHX(APCHY,"WTD") S APCHHT=APCHX(Y,"HT")
;.I $$AGE^AUPNPAT(P)>18 D Q:APCHHT=""
;..S Y=0 F S Y=$O(APCHX(Y)) Q:Y'=+Y I APCHX(Y,"HTD")=APCHX(APCHY,"WTD") S APCHHT=APCHX(Y,"HT") Q
;..S APCHHT=APCHX(1,"HT")
;.S %=""
;.S W=APCHX(APCHY,"WT")*.45359,H=(APCHHT*0.0254),H=(H*H),%=(W/H),%=$J(%,4,1)
;.S APCHX(APCHY,"BMI")=%
Q
ASPIRIN(P,D) ;
I '$G(P) Q ""
I '$G(D) S D=0 ;if don't pass date look at all time
NEW V,I,%
S %=""
NEW T,T1 S T=$O(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
S T1=$O(^ATXAX("B","DM AUDIT ANTI-PLATELET DRUGS",0))
I 'T Q ""
S I=0 F S I=$O(^AUPNVMED("AA",P,I)) Q:I'=+I!(%)!(I>(9999999-D)) D
.S V=0 F S V=$O(^AUPNVMED("AA",P,I,V)) Q:V'=+V!(%) S G=$P(^AUPNVMED(V,0),U) D
..I $D(^ATXAX(T,21,"B",G)) S %=V Q
..I T1,$D(^ATXAX(T1,21,"B",G)) S %=V Q
I %]"" D Q %
.I $P(^AUPNVMED(%,0),U,8)="" S %="Yes - "_$$FMTE^XLFDT($P($P(^AUPNVSIT($P(^AUPNVMED(%,0),U,3),0),U),"."))_" "_$$VAL^XBDIQ1(9000010.14,%,.01) Q
.I $P(^AUPNVMED(%,0),U,8)]"" S %="Discontinued - "_$$FMTE^XLFDT($P($P(^AUPNVSIT($P(^AUPNVMED(%,0),U,3),0),U),"."))_" "_$$VAL^XBDIQ1(9000010.14,%,.01) Q
Q "No"
BHSDMPRE ;IHS/CIA/MGH - Health Summary for Pre-Diabetic Supplement ;30-Nov-2015 10:25;DU
+1 ;;1.0;HEALTH SUMMARY COMPONENTS;**1,2,4,6,8,12**;March 17, 2006;Build 3
+2 ;===================================================================
+3 ;VA version of IHS components for supplemental summaries
+4 ;Taken from APCHS9D1
+5 ; IHS/TUCSON/LAB - DIABETIC CARE SUMMARY SUPPLEMENT ; [ 05/10/04 2:03 PM ]
+6 ;;2.0;IHS RPMS/PCC Health Summary;**3,5,6,8,9,10,11,12**;JUN 24, 1997
+7 ;Patch 4 skip vitals entered in error
+8 ;Patch 8 BMI is now stored value
+9 ;Patch 12 use new API for taxonomies
+10 ;====================================================================
+11 ;
EP ;EP - called from component
+1 NEW BHSPAT
+2 SET BHSPAT=DFN
+3 IF '$GET(BHSPAT)
QUIT
+4 ;has diabetes
IF $$PLTAX^BHSMU(BHSPAT,"SURVEILLANCE DIABETES")
QUIT
+5 SET X=$$LASTITEM^BHSMU(BHSPAT,"[SURVEILLANCE DIABETES","DX")
+6 ;if date of last dm dx is w/in past year then quit
IF X>$$FMADD^XLFDT(DT,-366)
QUIT
+7 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
+8 DO EP2(BHSPAT)
W ;write out array
+1 IF $DATA(IOF)
WRITE @IOF
+2 KILL APCHQUIT
+3 SET APCHX=0
FOR
SET APCHX=$ORDER(^TMP("BHS",$JOB,"DCS",APCHX))
IF APCHX'=+APCHX!($DATA(APCHQUIT))
QUIT
Begin DoDot:1
+4 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
+5 WRITE !,^TMP("BHS",$JOB,"DCS",APCHX)
+6 QUIT
End DoDot:1
+7 IF $DATA(APCHQUIT)
SET GMTSQIT=1
+8 DO EOJ
+9 QUIT
+10 ;
EOJ ;
+1 KILL APCHX,APCHQUIT,APCHY,APCHIEN,APCHHT,BHSDFN,BHSBEG,BHSTOB,BHSUPI,BHSDD,BHSINT,BHSWD,BHSED,APCHTOBN,APCHTOB,BHSTEX,BDMSDFN,BSMSBEG
+2 KILL N,%,T,F,X,Y,B,C,E,F,H,L,N,P,T,W,M
+3 QUIT
EP2(BHSDFN) ;PEP - PASS DFN get back array of patient care summary
+1 ;at this point you are stuck with ^TMP("BHS",$J,"DCS"
+2 KILL ^TMP("BHS",$JOB,"DCS")
+3 SET ^TMP("BHS",$JOB,"DCS",0)=0
+4 DO SETARRAY
+5 QUIT
SETARRAY ;set up array containing dm care summary
+1 ;CHECK TO SEE IF START1^APCLDF EXISTS
+2 SET X="APCLDF"
XECUTE ^%ZOSF("TEST")
IF '$TEST
QUIT
+3 SET X="PREDIABETES PATIENT CARE SUMMARY Report Date: "_$$FMTE^XLFDT(DT)
DO S(X)
+4 SET X="Patient Name: "_$PIECE(^DPT(BHSDFN,0),U)_" HRN: "_$$HRN^AUPNPAT(BHSDFN,DUZ(2))
DO S(X)
+5 SET X="Age: "_$$AGE^AUPNPAT(BHSDFN)
SET $EXTRACT(X,15)="Sex: "_$$SEX^AUPNPAT(BHSDFN)_" DOB: "_$$FMTE^XLFDT($$DOB^AUPNPAT(BHSDFN))
DO S(X)
+6 SET X="Classification:"
DO S(X,1)
+7 SET Y=$$IFG(BHSDFN)
SET X=""
SET $EXTRACT(X,2)=$SELECT($PIECE(Y,U)=1:"Yes",1:"No")
SET $EXTRACT(X,8)="Impaired Fasting Glucose"
IF $PIECE(Y,U)=1
SET X=X_": "_$PIECE(Y,U,3)_": "_$$FMTE^XLFDT($PIECE(Y,U,2))
+8 DO S(X)
+9 SET Y=$$IGT(BHSDFN)
SET X=""
SET $EXTRACT(X,2)=$SELECT($PIECE(Y,U)=1:"Yes",1:"No")
SET $EXTRACT(X,8)="Impaired Glucose Tolerance"
IF $PIECE(Y,U)=1
SET X=X_": "_$PIECE(Y,U,3)_": "_$$FMTE^XLFDT($PIECE(Y,U,2))
+10 DO S(X)
+11 SET Y=$$MS(BHSDFN)
SET X=""
SET $EXTRACT(X,2)=$SELECT($PIECE(Y,U)=1:"Yes",1:"No")
SET $EXTRACT(X,8)="Metabolic Syndrome"
IF $PIECE(Y,U)=1
SET X=X_": "_$PIECE(Y,U,3)_": "_$$FMTE^XLFDT($PIECE(Y,U,2))
+12 DO S(X)
+13 SET X=" "
DO S(X)
+14 ;HOW TO FIND CASE MANAGER - LORI
SET X="Case Manager: "_$$CMSMAN(BHSDFN)
DO S(X)
+15 SET X="Primary Care Provider: "_$$VAL^XBDIQ1(9000001,BHSDFN,.14)
DO S(X)
+16 SET X=" "
DO S(X)
+17 DO GETHWB(BHSDFN,DT)
+18 SET X=" Last Height: "_APCHX(1,"HT")_$SELECT(APCHX(1,"HT")]"":" inches",1:"")
SET $EXTRACT(X,33)=APCHX(1,"HTD")
DO S(X)
+19 SET X="Last 3 Weight: "_$SELECT(APCHX(1,"WT")]"":$JUSTIFY(APCHX(1,"WT"),3,0),1:"")_$SELECT(APCHX(1,"WT")]"":" lbs",1:"")
SET $EXTRACT(X,33)=APCHX(1,"WTD")
SET $EXTRACT(X,47)="BMI: "_APCHX(1,"BMI")
DO S(X)
+20 SET X=""
SET $EXTRACT(X,17)=$SELECT(APCHX(2,"WT")]"":$JUSTIFY(APCHX(2,"WT"),3,0),1:"")_$SELECT(APCHX(2,"WT")]"":" lbs",1:"")
SET $EXTRACT(X,33)=APCHX(2,"WTD")
SET $EXTRACT(X,47)="BMI: "_APCHX(2,"BMI")
DO S(X)
+21 SET X=""
SET $EXTRACT(X,17)=$SELECT(APCHX(3,"WT")]"":$JUSTIFY(APCHX(3,"WT"),3,0),1:"")_$SELECT(APCHX(3,"WT")]"":" lbs",1:"")
SET $EXTRACT(X,33)=APCHX(3,"WTD")
SET $EXTRACT(X,47)="BMI: "_APCHX(3,"BMI")
DO S(X)
+22 IF APCHX(1,"WC")]""
SET X="Last Waist Circumference: "_APCHX(1,"WC")
SET $EXTRACT(X,33)=APCHX(1,"WCD")
DO S(X,1)
+23 SET B=$$BP(BHSDFN)
+24 SET X="Last 3 non-ER BP: "_$PIECE($GET(APCHX(1)),U,2)_" "_$$FMTE^XLFDT($PIECE($GET(APCHX(1)),U))
+25 DO S(X,1)
+26 SET X=""
IF $DATA(APCHX(2))
SET X=""
SET $EXTRACT(X,20)=$PIECE(APCHX(2),U,2)_" "_$$FMTE^XLFDT($PIECE(APCHX(2),U))
+27 DO S(X)
+28 SET X=""
IF $DATA(APCHX(3))
SET X=""
SET $EXTRACT(X,20)=$PIECE(APCHX(3),U,2)_" "_$$FMTE^XLFDT($PIECE(APCHX(3),U))
+29 DO S(X)
+30 ;Patch 6
+31 NEW BDMSDFN,BDMTOBC,BDMTOBS,BDMSBEG
+32 SET BDMSDFN=BHSDFN
+33 DO TOBACCO^BDMS9B3
+34 SET X="Tobacco Use: "_$PIECE($GET(BDMTOBS),U,1)
DO S(X)
+35 IF $GET(BDMTOBC)]""
SET X=" "_$PIECE(BDMTOBC,U,1)
DO S(X)
+36 SET X="Prediabetes Education Provided (in past yr):"
DO S(X,1)
+37 SET X=" Last Dietitian Visit: "_$$DIETV^BDMS9B3(BHSDFN)
DO S(X)
+38 SET (BHSBEG,BDMSBEG)=$$FMADD^XLFDT(DT,-366)
+39 KILL APCHX
DO EDUC^BDMS9B2
IF $DATA(APCHX)
Begin DoDot:1
+40 SET %=0
FOR
SET %=$ORDER(APCHX(%))
IF %'=+%
QUIT
SET X=" "_APCHX(%)
DO S(X)
End DoDot:1
+41 KILL APCHX,APCHY,%
+42 DO EDUCREF^BHSDM3
IF $DATA(APCHX)
SET X="In the past year, the patient has refused the following Diabetes education:"
DO S(X,1)
Begin DoDot:1
+43 SET %=""
FOR
SET %=$ORDER(APCHX(%))
IF %=""
QUIT
SET X=" "_%_" "_APCHX(%)
DO S(X)
End DoDot:1
+44 KILL APCHX,APCHY,%
+45 SET X="HTN Diagnosed: "_$$HTN(BHSDFN)
DO S(X,1)
+46 SET BHSBEG=$$FMADD^XLFDT(DT,-(6*30.5))
+47 ;get date of last ACE in last year
SET %=$$ACE^BDMS9B5(BHSDFN,BHSBEG)
+48 SET X=""
SET X="ON ACE Inhibitor/ARB in past 6 months: "_%
DO S(X)
+49 KILL BHSX
SET BHSBEG=$$FMADD^XLFDT(DT,-365)
SET X="Aspirin Use (in past yr): "_$EXTRACT($$ASPIRIN(BHSDFN,BHSBEG),1,32)
DO S(X)
+50 SET X=""
SET X=$$ASPREF^BDMS9B5(BHSDFN)
IF X]""
SET X=" "_X
DO S(X)
M12 ;
+1 ;Patch 1001, new routine to call
+2 DO MORE^BHSDMPR1
+3 SET X=$PIECE(^DPT(BHSDFN,0),U)
SET $EXTRACT(X,35)="DOB: "_$$DOB^AUPNPAT(BHSDFN,"S")
SET $EXTRACT(X,55)="Chart #"_$$HRN^AUPNPAT(BHSDFN,DUZ(2),2)
DO S(X,1)
+4 QUIT
S(Y,F,C,T) ;set up array
+1 IF '$GET(F)
SET F=0
+2 IF '$GET(T)
SET T=0
+3 NEW %,X
+4 FOR F=1:1:F
SET X=""
DO S1
+5 SET X=Y
+6 IF $GET(C)
SET L=$LENGTH(Y)
SET T=(80-L)/2
Begin DoDot:1
+7 FOR %=1:1:(T-1)
SET X=" "_X
End DoDot:1
DO S1
QUIT
+8 FOR %=1:1:T
SET X=" "_Y
+9 DO S1
+10 QUIT
S1 ;
+1 SET %=$PIECE(^TMP("BHS",$JOB,"DCS",0),U)+1
SET $PIECE(^TMP("BHS",$JOB,"DCS",0),U)=%
+2 SET ^TMP("BHS",$JOB,"DCS",%)=X
+3 QUIT
CMSMAN(P,F) ;EP - return date/dx of dm in register
+1 IF $GET(F)=""
SET F="E"
+2 IF '$GET(P)
QUIT ""
+3 NEW R,N,D,D1,Y,X,G
SET R=0
SET N=""
SET D=""
FOR
SET N=$ORDER(^ACM(41.1,"B",N))
IF N=""!(D]"")
QUIT
SET R=0
FOR
SET R=$ORDER(^ACM(41.1,"B",N,R))
IF R'=+R!(D]"")
QUIT
IF N["DIAB"
Begin DoDot:1
+4 SET (G,X)=0
SET (D,Y)=""
FOR
SET X=$ORDER(^ACM(41,"C",P,X))
IF X'=+X!(D]"")
QUIT
IF $PIECE(^ACM(41,X,0),U,4)=R
Begin DoDot:2
+5 SET D=$PIECE($GET(^ACM(41,X,"DT")),U,6)
IF D]""
SET D=$PIECE(^VA(200,D,0),U)
End DoDot:2
End DoDot:1
+6 QUIT $GET(D)
+7 ;
MS(P) ;
+1 NEW X,Y,I,APCHY,%
+2 SET X=$$PLCODE^BHSMU(P,"277.7",2)
IF X
Begin DoDot:1
+3 SET D=$PIECE(^AUPNPROB(X,0),U,13)
IF D]""
SET Y=1_U_D_U_"Date of Onset from Problem List"
QUIT
+4 SET D=$PIECE(^AUPNPROB(X,0),U,8)
IF D]""
SET Y=1_U_D_U_"Date Added to Problem List"
QUIT
+5 SET Y=1_U_D_U_"Problem List"
QUIT
End DoDot:1
QUIT Y
+6 KILL APCHY
SET %=P_"^FIRST DX 277.7"
SET E=$$START1^APCLDF(%,"APCHY(")
+7 IF $DATA(APCHY(1))
QUIT 1_U_$PIECE(APCHY(1),U)_U_"Date of first DX in PCC"
+8 QUIT ""
IGT(P) ;
+1 NEW X,Y,I,APCHY,%
+2 SET X=$$PLCODE^BHSMU(P,"790.22",2)
IF X
Begin DoDot:1
+3 SET D=$PIECE(^AUPNPROB(X,0),U,13)
IF D]""
SET Y=1_U_D_U_"Date of Onset from Problem List"
QUIT
+4 SET D=$PIECE(^AUPNPROB(X,0),U,8)
IF D]""
SET Y=1_U_D_U_"Date Added to Problem List"
QUIT
+5 SET Y=1_U_D_U_"Problem List"
QUIT
End DoDot:1
QUIT Y
+6 KILL APCHY
SET %=P_"^FIRST DX 790.22"
SET E=$$START1^APCLDF(%,"APCHY(")
+7 IF $DATA(APCHY(1))
QUIT 1_U_$PIECE(APCHY(1),U)_U_"Date of first DX in PCC"
+8 QUIT ""
IFG(P) ;
+1 NEW X,Y,I,APCHY,%
+2 SET X=$$PLCODE^BHSMU(P,"790.21",2)
IF X
Begin DoDot:1
+3 SET D=$PIECE(^AUPNPROB(X,0),U,13)
IF D]""
SET Y=1_U_D_U_"Date of Onset from Problem List"
QUIT
+4 SET D=$PIECE(^AUPNPROB(X,0),U,8)
IF D]""
SET Y=1_U_D_U_"Date Added to Problem List"
QUIT
+5 SET Y=1_U_D_U_"Problem List"
QUIT
End DoDot:1
QUIT Y
+6 KILL APCHY
SET %=P_"^FIRST DX 790.21"
SET E=$$START1^APCLDF(%,"APCHY(")
+7 IF $DATA(APCHY(1))
QUIT 1_U_$PIECE(APCHY(1),U)_U_"Date of first DX in PCC"
+8 QUIT ""
HTN(P) ;
+1 NEW T
+2 SET T=$ORDER(^ATXAX("B","SURVEILLANCE HYPERTENSION",0))
+3 IF 'T
QUIT ""
+4 NEW X,Y,I
SET (X,Y,I)=0
FOR
SET X=$ORDER(^AUPNPROB("AC",P,X))
IF X'=+X!(I)
QUIT
Begin DoDot:1
+5 ;IHS/MSC/MGH New API P11
+6 IF $DATA(^AUPNPROB(X,0))
SET Y=$PIECE(^AUPNPROB(X,0),U)
IF $$ICD^ATXAPI(Y,T,9)
SET I=1
End DoDot:1
+7 IF I
QUIT "Yes"
+8 NEW APCHX
+9 SET APCHX=""
+10 SET X=P_"^LAST 3 DX [SURVEILLANCE HYPERTENSION"
SET E=$$START1^APCLDF(X,"APCHX(")
IF E
GOTO HTNX
IF $DATA(APCHX(3))
SET APCHX="Yes"
+11 IF $GET(APCHX)=""
SET APCHX="No"
HTNX ;
+1 QUIT APCHX
BP(P) ;last 3 BPs - NON ER
+1 NEW APCHD,APCHC
+2 KILL APCHX
+3 SET APCHX=""
SET APCHD=""
SET APCHC=0
+4 SET T=$ORDER(^AUTTMSR("B","BP",""))
+5 FOR
SET APCHD=$ORDER(^AUPNVMSR("AA",P,T,APCHD))
IF APCHD=""!(APCHC=3)
QUIT
Begin DoDot:1
+6 SET M=0
FOR
SET M=$ORDER(^AUPNVMSR("AA",P,T,APCHD,M))
IF M'=+M!(APCHC=3)
QUIT
Begin DoDot:2
+7 SET V=$PIECE($GET(^AUPNVMSR(M,0)),U,3)
IF 'V
QUIT
+8 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+9 ;entered in error
IF $PIECE($GET(^AUPNVMSR(M,2)),U,1)
QUIT
+10 IF $$CLINIC^APCLV(V,"C")=30
QUIT
+11 SET APCHC=APCHC+1
SET APCHX(APCHC)=(9999999-APCHD)_U_$PIECE(^AUPNVMSR(M,0),U,4)
+12 QUIT
End DoDot:2
+13 QUIT
End DoDot:1
+14 IF '$DATA(APCHX(1))
SET APCHX(1)="None recorded"
BPX ;
+1 KILL APCHD,APCHC
+2 QUIT APCHX
GETHWB(P,EDATE) ;get last height, height date, weight, weight date and BMI for patient P, return in APCHX("HT"),APCHX("HTD"),APCHX("WT"),APCHX("WTD"),APCHX("BMI")
+1 KILL APCHX
+2 FOR X=1:1:3
SET APCHX(X,"HT")=""
SET APCHX(X,"HTD")=""
SET APCHX(X,"WT")=""
SET APCHX(X,"WTD")=""
SET APCHX(X,"BMI")=""
SET APCHX(X,"WC")=""
SET APCHX(X,"WCD")=""
SET APCHX(X,"WTI")=""
LASTHT ;
+1 IF '$DATA(^AUPNVSIT("AC",P))
QUIT
+2 IF '$DATA(^AUPNVMSR("AC",P))
QUIT
+3 NEW APCHY
+4 SET %=P_"^LAST 3 MEAS HT"
NEW X
SET E=$$START1^APCLDF(%,"APCHY(")
+5 SET APCHX(1,"HT")=$PIECE($GET(APCHY(1)),U,2)
SET APCHX(1,"HTD")=$$FMTE^XLFDT($PIECE($GET(APCHY(1)),U))
+6 SET APCHX(1,"HT")=$SELECT(APCHX(1,"HT")]"":$JUSTIFY(APCHX(1,"HT"),2,0),1:"")
+7 SET APCHX(2,"HT")=$PIECE($GET(APCHY(2)),U,2)
SET APCHX(2,"HTD")=$$FMTE^XLFDT($PIECE($GET(APCHY(2)),U))
+8 SET APCHX(2,"HT")=$SELECT(APCHX(2,"HT")]"":$JUSTIFY(APCHX(2,"HT"),2,0),1:"")
+9 SET APCHX(3,"HT")=$PIECE($GET(APCHY(3)),U,2)
SET APCHX(3,"HTD")=$$FMTE^XLFDT($PIECE($GET(APCHY(3)),U))
+10 SET APCHX(3,"HT")=$SELECT(APCHX(3,"HT")]"":$JUSTIFY(APCHX(3,"HT"),2,0),1:"")
LASTWT ;
+1 KILL APCHY
SET %=P_"^LAST 3 MEAS WT"
NEW X
SET E=$$START1^APCLDF(%,"APCHY(")
+2 SET APCHX(1,"WT")=$PIECE($GET(APCHY(1)),U,2)
SET APCHX(1,"WTD")=$$FMTE^XLFDT($PIECE($GET(APCHY(1)),U))
SET APCHX(1,"WTI")=$PIECE($GET(APCHY(1)),U)
+3 SET APCHX(2,"WT")=$PIECE($GET(APCHY(2)),U,2)
SET APCHX(2,"WTD")=$$FMTE^XLFDT($PIECE($GET(APCHY(2)),U))
SET APCHX(2,"WTI")=$PIECE($GET(APCHY(2)),U)
+4 SET APCHX(3,"WT")=$PIECE($GET(APCHY(3)),U,2)
SET APCHX(3,"WTD")=$$FMTE^XLFDT($PIECE($GET(APCHY(3)),U))
SET APCHX(3,"WTI")=$PIECE($GET(APCHY(3)),U)
LASTWC ;
+1 KILL APCHY
SET %=P_"^LAST 3 MEAS WC"
NEW X
SET E=$$START1^APCLDF(%,"APCHY(")
+2 SET APCHX(1,"WC")=$PIECE($GET(APCHY(1)),U,2)
SET APCHX(1,"WCD")=$$FMTE^XLFDT($PIECE($GET(APCHY(1)),U))
+3 SET APCHX(2,"WC")=$PIECE($GET(APCHY(2)),U,2)
SET APCHX(2,"WCD")=$$FMTE^XLFDT($PIECE($GET(APCHY(2)),U))
+4 SET APCHX(3,"WC")=$PIECE($GET(APCHY(3)),U,2)
SET APCHX(3,"WCD")=$$FMTE^XLFDT($PIECE($GET(APCHY(3)),U))
BMI ;
+1 KILL APCHY
SET %=P_"^LAST 3 MEAS BMI"
NEW X
SET E=$$START1^APCLDF(%,"APCHY(")
+2 SET APCHX(1,"BMI")=$PIECE($GET(APCHY(1)),U,2)
SET APCHX(1,"BMD")=$$FMTE^XLFDT($PIECE($GET(APCHY(1)),U))
+3 SET APCHX(2,"BMI")=$PIECE($GET(APCHY(2)),U,2)
SET APCHX(2,"BMD")=$$FMTE^XLFDT($PIECE($GET(APCHY(2)),U))
+4 SET APCHX(3,"BMI")=$PIECE($GET(APCHY(3)),U,2)
SET APCHX(3,"BMD")=$$FMTE^XLFDT($PIECE($GET(APCHY(3)),U))
+5 ;Patch 8 added BMI
+6 ;F APCHY=1:1:3 D
+7 ;.I APCHX(APCHY,"WT")="" Q ;no weight
+8 ;.S APCHHT=""
+9 ;.I $$AGE^AUPNPAT(P)<19 D Q:APCHHT=""
+10 ;..;Get weight on that date
+11 ;..S Y=0 F S Y=$O(APCHX(Y)) Q:Y'=+Y I APCHX(Y,"HTD")=APCHX(APCHY,"WTD") S APCHHT=APCHX(Y,"HT")
+12 ;.I $$AGE^AUPNPAT(P)>18 D Q:APCHHT=""
+13 ;..S Y=0 F S Y=$O(APCHX(Y)) Q:Y'=+Y I APCHX(Y,"HTD")=APCHX(APCHY,"WTD") S APCHHT=APCHX(Y,"HT") Q
+14 ;..S APCHHT=APCHX(1,"HT")
+15 ;.S %=""
+16 ;.S W=APCHX(APCHY,"WT")*.45359,H=(APCHHT*0.0254),H=(H*H),%=(W/H),%=$J(%,4,1)
+17 ;.S APCHX(APCHY,"BMI")=%
+18 QUIT
ASPIRIN(P,D) ;
+1 IF '$GET(P)
QUIT ""
+2 ;if don't pass date look at all time
IF '$GET(D)
SET D=0
+3 NEW V,I,%
+4 SET %=""
+5 NEW T,T1
SET T=$ORDER(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
+6 SET T1=$ORDER(^ATXAX("B","DM AUDIT ANTI-PLATELET DRUGS",0))
+7 IF 'T
QUIT ""
+8 SET I=0
FOR
SET I=$ORDER(^AUPNVMED("AA",P,I))
IF I'=+I!(%)!(I>(9999999-D))
QUIT
Begin DoDot:1
+9 SET V=0
FOR
SET V=$ORDER(^AUPNVMED("AA",P,I,V))
IF V'=+V!(%)
QUIT
SET G=$PIECE(^AUPNVMED(V,0),U)
Begin DoDot:2
+10 IF $DATA(^ATXAX(T,21,"B",G))
SET %=V
QUIT
+11 IF T1
IF $DATA(^ATXAX(T1,21,"B",G))
SET %=V
QUIT
End DoDot:2
End DoDot:1
+12 IF %]""
Begin DoDot:1
+13 IF $PIECE(^AUPNVMED(%,0),U,8)=""
SET %="Yes - "_$$FMTE^XLFDT($PIECE($PIECE(^AUPNVSIT($PIECE(^AUPNVMED(%,0),U,3),0),U),"."))_" "_$$VAL^XBDIQ1(9000010.14,%,.01)
QUIT
+14 IF $PIECE(^AUPNVMED(%,0),U,8)]""
SET %="Discontinued - "_$$FMTE^XLFDT($PIECE($PIECE(^AUPNVSIT($PIECE(^AUPNVMED(%,0),U,3),0),U),"."))_" "_$$VAL^XBDIQ1(9000010.14,%,.01)
QUIT
End DoDot:1
QUIT %
+15 QUIT "No"