VistA-WorldVistAEHR/r/GEN_MED_OTHER-GMV/GMVHS1.m

70 lines
2.6 KiB
Mathematica

GMVHS1 ;HIOFO/FT-RETURN PATIENT DATA UTILITY (cont.) ;6/30/05 16:56
;;5.0;GEN. MED. REC. - VITALS;**3**;Oct 31, 2002
;
; This routine uses the following IAs:
; <None>
;
CALCBMI(GMVNODE,GMVDATE) ; Calculate BMI for a record
; GMVNODE = FILE 120.5 zero node
; GMVDATE = reverse date/time of the weight reading
N GMVADATE,GMVAHGT,GMVBDATE,GMVBHGT,GMVBMI,GMVDFN,GMVH,GMVHTI,GMVIEN,GMVHGT,GMVWDATE,GMVWTI
S GMVHTI=$$GETTYPEI^GMVHS("HT") ;height ien
S GMVWTI=$$GETTYPEI^GMVHS("WT") ;weight ien
S GMVBMI="^",GMVNODE=$G(GMVNODE),GMVDATE=$G(GMVDATE)
I $P(GMVNODE,U,3)'=GMVWTI Q GMVBMI ;not a weight reading
I $P(GMVNODE,U,8)'>0 Q GMVBMI ;weight'>0
S GMVDFN=$P(GMVNODE,U,2)
I 'GMVDFN Q GMVBMI
I 'GMVDATE Q GMVBMI
S GMVWDATE=$P(GMVNODE,U,1) ;date/time of weight
S GMVHGT=0
; Look for exact date/time match for height entry
S GMVIEN=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVDATE,0))
I GMVIEN S GMVHGT=$$HEIGHT(GMVIEN)
I $P(GMVHGT,U,1) S GMVBMI=$$CALC($P(GMVNODE,U,8),$P(GMVHGT,U,1)) Q GMVBMI
; get height and date/time taken before weight
S GMVBDATE=GMVDATE,GMVBHGT=0
F S GMVBDATE=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVBDATE)) Q:GMVBDATE'>0!(+GMVBHGT) D
.S GMVIEN=0
.F S GMVIEN=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVBDATE,GMVIEN)) Q:GMVIEN'>0!(+GMVBHGT) D
..S GMVBHGT=$$HEIGHT(GMVIEN)
..Q
.Q
; get height and date/time taken after weight
S GMVADATE=GMVDATE,GMVAHGT=0
F S GMVADATE=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVADATE),-1) Q:GMVADATE'>0!(+GMVAHGT) D
.S GMVIEN=0
.F S GMVIEN=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVADATE,GMVIEN)) Q:GMVIEN'>0!(+GMVAHGT) D
..S GMVAHGT=$$HEIGHT(GMVIEN)
..Q
.Q
S GMVBDATE=$P(GMVBHGT,U,2),GMVBHGT=$P(GMVBHGT,U,1)
S GMVADATE=$P(GMVAHGT,U,2),GMVAHGT=$P(GMVAHGT,U,1)
I $P(GMVBDATE,".",1)=$P(GMVWDATE,".",1) S GMVBMI=$$CALC($P(GMVNODE,U,8),GMVBHGT) Q GMVBMI
I $P(GMVADATE,".",1)=$P(GMVWDATE,".",1) S GMVBMI=$$CALC($P(GMVNODE,U,8),GMVAHGT) Q GMVBMI
S GMVH=$S(GMVBHGT>0:GMVBHGT,GMVAHGT>0:GMVAHGT,1:"")
I GMVH="" Q GMVBMI
S GMVBMI=$$CALC($P(GMVNODE,U,8),GMVH) Q GMVBMI
Q GMVBMI
;
HEIGHT(GMVIEN) ; Does record have a useable height value? Is yes, return that value.
; GMVIEN = File 120.5 entry number
N GMVX
S GMVIEN=+$G(GMVIEN)
I '$D(^GMR(120.5,GMVIEN,0)) Q 0
I $P($G(^GMR(120.5,GMVIEN,2)),U,1)=1 Q 0
S GMVX=$P(^GMR(120.5,GMVIEN,0),U,8)
I GMVX'>0 Q 0
Q GMVX_U_$P(^GMR(120.5,GMVIEN,0),U,1)
;
CALC(GMVWT,GMVHT) ; Crunch the numbers, return bmi score
; GMVWT (lb)
; GMVHT (in)
N GMVX
S GMVWT=$G(GMVWT),GMVHT=$G(GMVHT)
I 'GMVWT!(GMVHT'>0) Q ""
S GMVWT=GMVWT/2.2,GMVHT=GMVHT*2.54/100
S GMVX=$J(GMVWT/(GMVHT*GMVHT),0,0) S GMVX=GMVX_$S(GMVX>27:"*",1:"")
Q GMVX
;