source: FOIAVistA/trunk/r/GEN_MED_OTHER-GMV/GMVHS1.m@ 710

Last change on this file since 710 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.6 KB
Line 
1GMVHS1 ;HIOFO/FT-RETURN PATIENT DATA UTILITY (cont.) ;6/30/05 16:56
2 ;;5.0;GEN. MED. REC. - VITALS;**3**;Oct 31, 2002
3 ;
4 ; This routine uses the following IAs:
5 ; <None>
6 ;
7CALCBMI(GMVNODE,GMVDATE) ; Calculate BMI for a record
8 ; GMVNODE = FILE 120.5 zero node
9 ; GMVDATE = reverse date/time of the weight reading
10 N GMVADATE,GMVAHGT,GMVBDATE,GMVBHGT,GMVBMI,GMVDFN,GMVH,GMVHTI,GMVIEN,GMVHGT,GMVWDATE,GMVWTI
11 S GMVHTI=$$GETTYPEI^GMVHS("HT") ;height ien
12 S GMVWTI=$$GETTYPEI^GMVHS("WT") ;weight ien
13 S GMVBMI="^",GMVNODE=$G(GMVNODE),GMVDATE=$G(GMVDATE)
14 I $P(GMVNODE,U,3)'=GMVWTI Q GMVBMI ;not a weight reading
15 I $P(GMVNODE,U,8)'>0 Q GMVBMI ;weight'>0
16 S GMVDFN=$P(GMVNODE,U,2)
17 I 'GMVDFN Q GMVBMI
18 I 'GMVDATE Q GMVBMI
19 S GMVWDATE=$P(GMVNODE,U,1) ;date/time of weight
20 S GMVHGT=0
21 ; Look for exact date/time match for height entry
22 S GMVIEN=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVDATE,0))
23 I GMVIEN S GMVHGT=$$HEIGHT(GMVIEN)
24 I $P(GMVHGT,U,1) S GMVBMI=$$CALC($P(GMVNODE,U,8),$P(GMVHGT,U,1)) Q GMVBMI
25 ; get height and date/time taken before weight
26 S GMVBDATE=GMVDATE,GMVBHGT=0
27 F S GMVBDATE=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVBDATE)) Q:GMVBDATE'>0!(+GMVBHGT) D
28 .S GMVIEN=0
29 .F S GMVIEN=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVBDATE,GMVIEN)) Q:GMVIEN'>0!(+GMVBHGT) D
30 ..S GMVBHGT=$$HEIGHT(GMVIEN)
31 ..Q
32 .Q
33 ; get height and date/time taken after weight
34 S GMVADATE=GMVDATE,GMVAHGT=0
35 F S GMVADATE=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVADATE),-1) Q:GMVADATE'>0!(+GMVAHGT) D
36 .S GMVIEN=0
37 .F S GMVIEN=$O(^GMR(120.5,"AA",GMVDFN,GMVHTI,GMVADATE,GMVIEN)) Q:GMVIEN'>0!(+GMVAHGT) D
38 ..S GMVAHGT=$$HEIGHT(GMVIEN)
39 ..Q
40 .Q
41 S GMVBDATE=$P(GMVBHGT,U,2),GMVBHGT=$P(GMVBHGT,U,1)
42 S GMVADATE=$P(GMVAHGT,U,2),GMVAHGT=$P(GMVAHGT,U,1)
43 I $P(GMVBDATE,".",1)=$P(GMVWDATE,".",1) S GMVBMI=$$CALC($P(GMVNODE,U,8),GMVBHGT) Q GMVBMI
44 I $P(GMVADATE,".",1)=$P(GMVWDATE,".",1) S GMVBMI=$$CALC($P(GMVNODE,U,8),GMVAHGT) Q GMVBMI
45 S GMVH=$S(GMVBHGT>0:GMVBHGT,GMVAHGT>0:GMVAHGT,1:"")
46 I GMVH="" Q GMVBMI
47 S GMVBMI=$$CALC($P(GMVNODE,U,8),GMVH) Q GMVBMI
48 Q GMVBMI
49 ;
50HEIGHT(GMVIEN) ; Does record have a useable height value? Is yes, return that value.
51 ; GMVIEN = File 120.5 entry number
52 N GMVX
53 S GMVIEN=+$G(GMVIEN)
54 I '$D(^GMR(120.5,GMVIEN,0)) Q 0
55 I $P($G(^GMR(120.5,GMVIEN,2)),U,1)=1 Q 0
56 S GMVX=$P(^GMR(120.5,GMVIEN,0),U,8)
57 I GMVX'>0 Q 0
58 Q GMVX_U_$P(^GMR(120.5,GMVIEN,0),U,1)
59 ;
60CALC(GMVWT,GMVHT) ; Crunch the numbers, return bmi score
61 ; GMVWT (lb)
62 ; GMVHT (in)
63 N GMVX
64 S GMVWT=$G(GMVWT),GMVHT=$G(GMVHT)
65 I 'GMVWT!(GMVHT'>0) Q ""
66 S GMVWT=GMVWT/2.2,GMVHT=GMVHT*2.54/100
67 S GMVX=$J(GMVWT/(GMVHT*GMVHT),0,0) S GMVX=GMVX_$S(GMVX>27:"*",1:"")
68 Q GMVX
69 ;
Note: See TracBrowser for help on using the repository browser.