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

CIMGAGP4.m

Go to the documentation of this file.
CIMGAGP4 ; CMI/TUCSON/LAB - aberdeen area GPRA ;   [ 03/13/00  9:45 AM ]
 ;;1.0;ABERDEEN GPRA REPORT;;JAN 22, 2000
 ;
 ;
IND2023 ;obesity
 S CIMAGE=$$AGE^AUPNPAT(DFN,CIMEDATE)
 I CIMAGE=3!(CIMAGE=4)!(CIMAGE=5) D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),14,1)
 .S V=$$OVERW(DFN,CIMEDATE)
 .I V]"" D S(CIMRPT,$S(CIMTIME:19,1:20),23,1)
 .I V D S(CIMRPT,$S(CIMTIME:19,1:20),29,1)
 .I $D(CIMLIST(13)),CIMTIME,V S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",13,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)="OVERWEIGHT"
 .S V=$$OBESE(DFN,CIMEDATE)
 .I V D S(CIMRPT,$S(CIMTIME:19,1:20),15,1)
 .I $D(CIMLIST(13)),CIMTIME,V S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",13,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)="OBESE"
 I CIMAGE=8!(CIMAGE=9)!(CIMAGE=10) D
 .D S(CIMRPT,$S(CIMTIME:19,1:20),16,1)
 .S V=$$OVERW(DFN,CIMEDATE)
 .I V]"" D S(CIMRPT,$S(CIMTIME:19,1:20),24,1)
 .I V D S(CIMRPT,$S(CIMTIME:19,1:20),30,1)
 .I $D(CIMLIST(13)),CIMTIME,V S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",13,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)="OVERWEIGHT"
 .S V=$$OBESE(DFN,CIMEDATE)
 .I V D S(CIMRPT,$S(CIMTIME:19,1:20),17,1)
 .I $D(CIMLIST(13)),CIMTIME,V S ^XTMP("CIMGAGP",CIMGJ,CIMGH,"LIST",13,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),CIMAGE,DFN)="OBESE"
 Q
S(R,N,P,V) ;
 I 'R Q
 S $P(^CIMAGP(R,N),U,P)=$P($G(^CIMAGP(R,N)),U,P)+V
 Q
 ;
OBESE(P,EDATE) ;
 ;get all weights and heights edate-365 to edate
 ;get last weight/height on same day
 ;calculate BMI
 ;if obese return 1
 ;return 2 if not obese
 ;return null if unable to calculate
 NEW BDATE
 S BDATE=$$FMADD^XLFDT(EDATE,-365)
 NEW CIMGHT,CIMGWT,%,E,Y
 K CIMGHT,CIMGWT
 S %="CIMGWT(",Y=P_"^ALL MEASUREMENT WT;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(Y,%)
 S %="CIMGHT(",Y=P_"^ALL MEASUREMENT HT;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(Y,%)
 I '$D(CIMGHT(1)) Q ""
 I '$D(CIMGWT(1)) Q ""
 NEW CIMROWT,CIMROHT K CIMROWT,CIMROHT
 S Y=0 F  S Y=$O(CIMGWT(Y)) Q:Y'=+Y  S CIMROWT($P(CIMGWT(Y),U))=Y
 S Y=0 F  S Y=$O(CIMGHT(Y)) Q:Y'=+Y  S CIMROHT($P(CIMGHT(Y),U))=Y
 ;get ht/wt on same date
 NEW X,CHT,CWT
 S X=9999999 F  S X=$O(CIMROWT(X),-1) Q:X=""!($D(CHT))  I $D(CIMROHT(X)) S CHT=$P(CIMGHT(CIMROHT(X)),U,2),CWT=$P(CIMGWT(CIMROWT(X)),U,2)
 I '$D(CHT) Q ""
 ;calc bmi
 NEW MWT,MHT,BMI
 S MWT=CWT/2.21,MHT=CHT*.025,BMI=MWT/(MHT*MHT)
 ;determine if obese or not based on table
 NEW AGE S AGE=$$AGE^AUPNPAT(P,EDATE)
 NEW R S R=$O(^APCLBMI("H",$P(^DPT(P,0),U,2),AGE,0))
 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 0
OVERW(P,EDATE) ;
 ;get all weights and heights edate-365 to edate
 ;get last weight/height on same day
 ;calculate BMI
 ;if overweight return 1
 ;return 2 if not overweight
 ;return null if unable to calculate
 NEW BDATE
 S BDATE=$$FMADD^XLFDT(EDATE,-365)
 NEW CIMGHT,CIMGWT,%,E,Y
 K CIMGHT,CIMGWT
 S %="CIMGWT(",Y=P_"^ALL MEASUREMENT WT;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(Y,%)
 S %="CIMGHT(",Y=P_"^ALL MEASUREMENT HT;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(Y,%)
 I '$D(CIMGHT(1)) Q ""
 I '$D(CIMGWT(1)) Q ""
 NEW CIMROWT,CIMROHT K CIMROWT,CIMROHT
 S Y=0 F  S Y=$O(CIMGWT(Y)) Q:Y'=+Y  S CIMROWT($P(CIMGWT(Y),U))=Y
 S Y=0 F  S Y=$O(CIMGHT(Y)) Q:Y'=+Y  S CIMROHT($P(CIMGHT(Y),U))=Y
 ;get ht/wt on same date
 NEW X,CHT,CWT
 S X=9999999 F  S X=$O(CIMROWT(X),-1) Q:X=""!($D(CHT))  I $D(CIMROHT(X)) S CHT=$P(CIMGHT(CIMROHT(X)),U,2),CWT=$P(CIMGWT(CIMROWT(X)),U,2)
 I '$D(CHT) Q ""
 ;calc bmi
 NEW MWT,MHT,BMI
 S MWT=CWT/2.21,MHT=CHT*.025,BMI=MWT/(MHT*MHT)
 ;determine if overweight or not based on table
 NEW AGE S AGE=$$AGE^AUPNPAT(P,EDATE)
 NEW R S R=$O(^APCLBMI("H",$P(^DPT(P,0),U,2),AGE,0))
 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 0