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

BGPD29.m

Go to the documentation of this file.
BGPD29 ; IHS/CMI/LAB - indicator 29 ;
 ;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
 ;
I29 ;EP ;EP - indicator 29
 ;Q:'$D(BGPIND(25))
 S BGPSEX=$P(^DPT(DFN,0),U,2),BGPSEX=$S(BGPSEX="M":1,1:2)
 S BGPBMI=$$BMI(DFN,BGPEDATE,BGPAGEE),BGPBMIC=$S(BGPBMI]"":1,1:0)
 S BGPOVW=$$OW(DFN,BGPBMI,BGPAGEE)
 S BGPOBE=$$OB(DFN,BGPBMI,BGPAGEE)
 S BGPBMI=$$BMI(DFN,BGPEDATE,BGPAGEE),BGPBMIC=$S(BGPBMI]"":1,1:0)
 S BGPOVW=$$OW(DFN,BGPBMI,BGPAGEE)
 S BGPOBE=$$OB(DFN,BGPBMI,BGPAGEE)
 I BGPAGEE>1,BGPAGEE<6 S BGPPN=$S(BGPTIME=1:16,BGPTIME=0:46,BGPTIME=8:86,1:999),BGPPP=1 D S1
 I BGPAGEE>6,BGPAGEE<12 S BGPPN=$S(BGPTIME=1:16,BGPTIME=0:46,BGPTIME=8:86,1:999),BGPPP=2 D S1
 I BGPAGEE>11,BGPAGEE<20 S BGPPN=$S(BGPTIME=1:16,BGPTIME=0:46,BGPTIME=8:86,1:999),BGPPP=3 D S1
 I BGPAGEE>19,BGPAGEE<25 S BGPPN=$S(BGPTIME=1:16,BGPTIME=0:46,BGPTIME=8:86,1:999),BGPPP=4 D S1
 I BGPAGEE>24,BGPAGEE<35 S BGPPN=$S(BGPTIME=1:16,BGPTIME=0:46,BGPTIME=8:86,1:999),BGPPP=5 D S1
 I BGPAGEE>34,BGPAGEE<45 S BGPPN=$S(BGPTIME=1:20,BGPTIME=0:50,BGPTIME=8:90,1:999),BGPPP=3 D S1
 I BGPAGEE>44,BGPAGEE<55 S BGPPN=$S(BGPTIME=1:20,BGPTIME=0:50,BGPTIME=8:90,1:999),BGPPP=4 D S1
 I BGPAGEE>54,BGPAGEE<65 S BGPPN=$S(BGPTIME=1:20,BGPTIME=0:50,BGPTIME=8:90,1:999),BGPPP=5 D S1
 I BGPAGEE>64 S BGPPN=$S(BGPTIME=1:20,BGPTIME=0:50,BGPTIME=8:90,1:999),BGPPP=6 D S1
 I $D(BGPLIST(25)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",25,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPBMI
 Q
S1 ;
 ;set denominator
 D SETPA(BGPRPT,BGPPN,BGPPP,1,BGPSEX,1) ;set denominator # of pats
 D SETPA(BGPRPT,BGPPN,BGPPP,2,BGPSEX,BGPBMIC) ;set # with bmi calc
 D SETPA(BGPRPT,BGPPN,BGPPP,3,BGPSEX,BGPOVW)
 D SETPA(BGPRPT,BGPPN,BGPPP,4,BGPSEX,BGPOBE)
 Q
SETPA(R,N,P,P1,S,V) ;
 NEW X,Y,F,M
 S X=$P($G(^BGPD(R,N)),U,P) ;whole string
 S M=$P(X,"!",1) ;males
 S F=$P(X,"!",2)
 I S=2 S $P(F,"~",P1)=$P(F,"~",P1)+V
 I S=1 S $P(M,"~",P1)=$P(M,"~",P1)+V
 S X=M_"!"_F
 S $P(^BGPD(R,N),U,P)=X
 Q
OB(P,BMI,A) ;EP obese
 I $G(BMI)="" Q ""
 NEW S S S=$P(^DPT(P,0),U,2)
 I S="" Q ""
 NEW R S R=0,R=$O(^APCLBMI("H",S,A,R))
 I 'R S R=$O(^APCLBMI("H",S,A)) I R S R=$O(^APCLBMI("H",S,R,""))
 I 'R Q ""
 I BMI>$P(^APCLBMI(R,0),U,7)!(BMI<$P(^APCLBMI(R,0),U,6)) Q ""
 I BMI'<$P(^APCLBMI(R,0),U,5) Q 1
 Q ""
OW(P,BMI,A) ;EP overweight
 I $G(BMI)="" Q ""
 NEW S S S=$P(^DPT(P,0),U,2)
 I S="" Q ""
 NEW R S R=0,R=$O(^APCLBMI("H",S,A,R))
 I 'R S R=$O(^APCLBMI("H",S,A)) I R S R=$O(^APCLBMI("H",S,R,""))
 I 'R Q ""
 I BMI>$P(^APCLBMI(R,0),U,7)!(BMI<$P(^APCLBMI(R,0),U,6)) Q ""
 I BMI'<$P(^APCLBMI(R,0),U,4) Q 1
 Q ""
HT(P,BDATE,EDATE) ;EP
 I 'P Q ""
 NEW %,BGPARRY,H,E
 S %=P_"^LAST MEAS HT;DURING "_BDATE_"-"_EDATE NEW X S E=$$START1^APCLDF(%,"BGPARRY(") S H=$P($G(BGPARRY(1)),U,2)
 I H="" Q H
 I H["?" Q ""
 S H=$J(H,2,0)
 Q H
WT(P,BDATE,EDATE) ;EP
 I 'P Q ""
 NEW %,E,BGPLW,X,BGPLN,BGPL,BGPLD,BGPLZ,BGPLX,ICD
 K BGPL S BGPLW="" S BGPLX=P_"^LAST 24 MEAS WT;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(BGPLX,"BGPL(")
 S BGPLN=0 F  S BGPLN=$O(BGPL(BGPLN)) Q:BGPLN'=+BGPLN!(BGPLW]"")  D
 .S BGPLZ=$P(BGPL(BGPLN),U,5)
 .I '$D(^AUPNVPOV("AD",BGPLZ)) S BGPLW=$P(BGPL(BGPLN),U,2) Q
 . S BGPLD=0 F  S BGPLD=$O(^AUPNVPOV("AD",BGPLZ,BGPLD)) Q:'BGPLD!(BGPLW]"")  D
 .. S ICD=$P($$ICDDX^ICDCODE($P(^AUPNVPOV(BGPLD,0),U)),U,2) D
 ...I $E(ICD,1,3)="V22" Q
 ...I $E(ICD,1,3)="V23" Q
 ...I $E(ICD,1,3)="V27" Q
 ...I $E(ICD,1,3)="V28" Q
 ...I ICD>629.9999&(ICD<676.95) Q
 ...I ICD>61.49&(ICD<61.71) Q
 ...S BGPLW=$P(BGPL(BGPLN),U,2)
 ..Q
 Q BGPLW
BMI(P,EDATE,AGE) ;EP
 I 'P Q -1
 NEW %,W,H,B,D,%DT,BDATE
 S BDATE=$$FMADD^XLFDT(EDATE,-365),BDATE=$$FMTE^XLFDT(BDATE),EDATE=$$FMTE^XLFDT(EDATE)
 S %=""
 I AGE>19 D  Q %
 .S W=$$WT(P,BDATE,EDATE) I W=""!(W="?") Q
 .S HDATE=$$FMTE^XLFDT($$FMADD^XLFDT($P(^DPT(P,0),U,3),(19*365)))
 .S H=$$HT(P,HDATE,EDATE) I H="" Q
 .;S W=(W/5)*2.3,H=(H*2.5),H=(H*H)/10000,%=(W/H),%=$J(%,4,1)
 .;S W=(W/5)*2.3,H=(H*2.5),H=(H*H)/10000,%=(W/H)
 .S W=W*.45359,H=(H*.0254),H=(H*H),%=(W/H)
 S X=$$HTWTSD(P,BDATE,EDATE)
 I '$P(X,"^") Q %
 I '$P(X,"^",2) Q %
 S W=$P(X,"^"),H=$P(X,"^",2)
 ;S W=(W/5)*2.3,H=(H*2.5),H=(H*H)/10000,%=(W/H),%=$J(%,4,1)
 ;S W=(W/5)*2.3,H=(H*2.5),H=(H*H)/10000,%=(W/H)
 S W=W*.45359,H=(H*.0254),H=(H*H),%=(W/H)
 Q %
HTWTSD(P,BDATE,EDATE) ;get last ht / wt on same day
 I '$G(P) Q ""
 NEW BGPLWTS,BGPLHTS,%,X,BGPLWTS1,BGPLHTS1,Y
 ;get all hts during time frame
 S %=P_"^ALL MEAS HT;DURING "_BDATE_"-"_EDATE NEW X S E=$$START1^APCLDF(%,"BGPLHTS(")
 S Y=0 F  S Y=$O(BGPLHTS(Y)) Q:Y'=+Y  I $P(BGPLHTS(Y),U,2)="?"!($P(BGPLHTS(Y),U,2)="") K BGPLHTS(Y)
 ;set the array up by date
 K BGPLHTS1 S X=0 F  S X=$O(BGPLHTS(X)) Q:X'=+X  S BGPLHTS1($P(BGPLHTS(X),U))=X
 ;get all wts during time frame
 S %=P_"^ALL MEAS WT;DURING "_BDATE_"-"_EDATE NEW X S E=$$START1^APCLDF(%,"BGPLWTS(")
 S Y=0 F  S Y=$O(BGPLWTS(Y)) Q:Y'=+Y  I $P(BGPLWTS(Y),U,2)="?"!($P(BGPLWTS(Y),U,2)="") K BGPLWTS(Y)
 ;set the array up by date
 K BGPLWTS1 S X=0 F  S X=$O(BGPLWTS(X)) Q:X'=+X  S BGPLWTS1($P(BGPLWTS(X),U))=X
 NEW BGPLCHT S BGPLCHT="",X=9999999 F  S X=$O(BGPLWTS1(X),-1) Q:X=""!(BGPLCHT]"")  I $D(BGPLHTS1(X)) S BGPLCHT=$P(BGPLWTS(BGPLWTS1(X)),U,2)_U_$P(BGPLHTS(BGPLHTS1(X)),U,2)
 Q BGPLCHT