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

APCHS2A3.m

Go to the documentation of this file.
APCHS2A3 ; IHS/CMI/LAB - BODY MASS INDEX & RELATIVE WEIGHT FOR MEASUREMENT TRANSFORMS ;
 ;;2.0;IHS PCC SUITE;**4,13**;MAY 14, 2009;Build 9
 ;
BMI(APCHPAT,APCHWT,APCHDATE) ; ENTRY POINT - TO OBTAIN BODY MASS INDEX
 NEW APCHDOB,APCHSEX,APCHAGE,APCHSX,APCHHT,APCHBMI,APCHPRW,APCHSWT,APCHCOMT,APCHRW,APCHMDT,APCHDA
 ;------------
 I (APCHWT="")!(APCHDATE="")!(APCHPAT="") S APCHCOMT="!MISSING VALUE" G ERROR  ;IHS/CMI/LAB 091615
 ;------------
 D COMMON G:$E(APCHCOMT)="!" ERROR
 I $G(APCHHT)="" S APCHCOMT="!NO HEIGHT FOR PATIENT" G ERROR
 ;S APCHWT=(APCHWT/5)*2.3,APCHHT=(APCHHT*2.5),APCHHT=(APCHHT*APCHHT)/10000,APCHBMI=(APCHWT/APCHHT),APCHBMI=$J(APCHBMI,5,1)
 S APCHWT=APCHWT*.45359,APCHHT=(APCHHT*.0254),APCHHT=APCHHT*APCHHT,APCHBMI=(APCHWT/APCHHT),APCHBMI=$J(APCHBMI,5,1)
 S APCHSWT=APCHBMI_$S(APCHCOMT]"":" **",1:"   ")
 G EXIT
 ;
RW(APCHPAT,APCHWT,APCHDATE) ; ENTRY POINT - TO OBTAIN RELATIVE WEIGHT PERCENTAGE
 NEW APCHDOB,APCHSEX,APCHAGE,APCHSX,APCHHT,APCHBMI,APCHPRW,APCHSWT,APCHCOMT,APCHRW,APCHMDT,APCHDA
 ;------------
 I (APCHWT="")!(APCHDATE="")!(APCHPAT="") S APCHCOMT="!MISSING VALUE" G ERROR  ;IHS/CMI/LAB 091615
 ;------------
 D COMMON G:$E(APCHCOMT)="!" ERROR
 I (APCHHT>70)!(APCHHT<58)&(APCHSEX="F") S APCHCOMT="!HEIGHT OUT OF RANGE FOR SEX." G ERROR
 I (APCHHT>75)!(APCHHT<61)&(APCHSEX="M") S APCHCOMT="!HEIGHT OUT OF RANGE FOR SEX." G ERROR
 S APCHHT=APCHHT-57,APCHRW=$P($T(SIZES+APCHHT),";;",APCHSX),APCHPRW=(APCHWT*100/APCHRW)\1
 S APCHSWT=APCHPRW_"%"_$S(APCHCOMT]"":" **",1:"   ")
 G EXIT
ERROR S APCHSWT="***",APCHCOMT="*** "_$E(APCHCOMT,2,$L(APCHCOMT))
EXIT K X,X1,X2 ; note that the rest of the variables were NEWed
 S Y=APCHSWT_"^"_$G(APCHCOMT)
 K APCHDOB,APCHSEX,APCHAGE,APCHSX,APCHHT,APCHBMI,APCHPRW,APCHSWT,APCHCOMT,APCHRW,APCHMDT,APCHDA,APCHDATE,APCHPAT,APCHWT,APCHHPTR
 Q Y
 ;
COMMON ;OBTAIN DOB, AGE, SEX, and COMN
 ;------------
 S APCHHPTR=$O(^AUTTMSR("B","HT",0))   ;IHS/CMI/GRL APCH*2.0*9
 ;I '$D(^AUPNVMSR("AA",APCHPAT,1)) S APCHCOMT="!NO HEIGHT FOR PATIENT." Q
 I '$D(^AUPNVMSR("AA",APCHPAT,APCHHPTR)) S APCHCOMT="!NO HEIGHT FOR PATIENT." Q  ;IHS/CMI/GRL  APCH*2.0*9
 S APCHDOB=$P(^DPT(APCHPAT,0),U,3),APCHSEX=$P(^DPT(APCHPAT,0),U,2),X2=APCHDOB,X1=DT D ^%DTC S APCHAGE=X,APCHSX=$S(APCHSEX="M":2,APCHSEX="F":3,1:"")
 S APCHCOMT=""
 S APCHDA="",APCHHDA=""
NXTHT S APCHDA=0 F  S APCHDA=$O(^AUPNVMSR("AA",APCHPAT,APCHHPTR,APCHDATE,APCHDA)) Q:APCHDA'=+APCHDA  D
 .Q:$P($G(^AUPNVMSR(APCHDA,2)),U,1)
 .S APCHHDA=APCHDA
 S APCHDA=APCHHDA
 G:APCHDA]"" HITE  ;IHS/CMI/GRL  APCH*2.0*9
 ;S APCHDA=$O(^AUPNVMSR("AA",APCHPAT,1,APCHDATE,"")) G:APCHDA]"" HITE
NXTDATE S APCHDATE=$O(^AUPNVMSR("AA",APCHPAT,APCHHPTR,APCHDATE)) G:APCHDATE]"" NXTHT   ;IHS/CMI/GRL  APCH*2.9*9
 ;S APCHDATE=$O(^AUPNVMSR("AA",APCHPAT,1,APCHDATE)) G:APCHDATE]"" NXTHT
 S APCHCOMT="!NO HEIGHT IN APPROPRIATE TIME FRAME FOR COMPUTING BMI AND %RW." Q
HITE S X1=9999999-(APCHDATE\1),X2=APCHDOB D ^%DTC S APCHMDT=X
 S APCHHT=$P(^AUPNVMSR(APCHDA,0),U,4),X1=DT,X2=9999999-(APCHDATE\1) D ^%DTC
 I ((X>90)&(APCHAGE<1096))!((X>180)&(APCHAGE<4381))!((X>365)&(APCHAGE<6571))!((APCHMDT<6571)&(APCHAGE>6571)) S APCHCOMT="** HEIGHT MAY BE OLD."
 Q
 ;
 ;; TEMPORARY ENTRY POINTS UNTIL FILEMAN WILL ACCEPT $$FUNCTIONS
 ;
SIZES ;;
 ;;;;107
 ;;;;110
 ;;;;113
 ;;120;;116
 ;;123;;119
 ;;126;;123
 ;;130;;126
 ;;133;;130
 ;;138;;134
 ;;142;;138
 ;;146;;143
 ;;150;;147
 ;;155;;152
 ;;159
 ;;164
 ;;168
 ;;173
 ;;177