source: WorldVistAEHR/trunk/r/GEN_MED_OTHER-GMV/GMVHS.m@ 1742

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

initial load of WorldVistAEHR

File size: 9.0 KB
Line 
1GMVHS ;HIOFO/FT-RETURN PATIENT DATA UTILITY ;6/10/05 11:32
2 ;;5.0;GEN. MED. REC. - VITALS;**3**;Oct 31, 2002
3 ;
4 ; This routine uses the following IAs:
5 ; #10040 - FILE 44 references (supported)
6 ; #10104 - ^XLFSTR calls (supported)
7 ;
8 ; This routine supports the following IAs:
9 ; EN1 - 4791 (private)
10 ;
11EN1 ; Entry to gather patients vital/measurment data
12 ; Input variables
13 ;
14 ; DFN = Entry number of patient in Patient file. (Required)
15 ; GMRVSTR = types of vital/measurments desired. Use the abbreviations
16 ; found in the Vital Type (120.51) file. For multiple
17 ; vitals, use the ; as a delimiter. (Required)
18 ; GMRVSTR(0) = GMRVSTDT^GMRVENDT^GMRVOCC^GMRVSORD
19 ; where GMRVSTDT = The start date/time that the utility will
20 ; use in obtaining patient data. (Required)
21 ; GMRVENDT = The end date/time that the utility will use
22 ; to stop the search. (Required)
23 ; GMRVOCC = The number of occurrences of the data that
24 ; is desired by the search. (Required)
25 ; GMRVSORD = The sort order desired in output. 0 will sort
26 ; the data by vital type, then by date/time entered.
27 ; 1 will sort the data by date/time entered, then by
28 ; vital type. (REQUIRED)
29 ; GMRVSTR("LT") = ^TYP1^[TYP2^...] (OPTIONAL)
30 ; THIS VARIABLE IS AN ^ DELIMITED LIST OF HOSPITAL LOCATION
31 ; TYPES TO EXTRACT MEASUREMENT DATA FOR. E.G., ^C^M^, WILL
32 ; EXTRACT DATA FOR ONLY THOSE MEASUREMENTS TAKEN ON CLINICS
33 ; OR MODULES.
34 ;
35 ; Output variables:
36 ;
37 ; The utility will create an array with the desired information. The
38 ; array structure will be as follows if '$P(GMRVSTR,"^",4):
39 ; ^UTILITY($J,"GMRVD",GMRVTYP,GMRVRDT,GMRVIEN)=GMRVDATA
40 ; or if $P(GMRVSTR,"^",4) then the following will be returned:
41 ; ^UTILITY($J,"GMRVD",GMRVRDT,GMRVTYP,GMRVIEN)=GMRVDATA
42 ; where GMRVRDT = Reverse FileMan date/time.
43 ; 9999999-Date/time vital/measurement was taken.
44 ; GMRVTYP = The abbreviation used in the GMRVSTR string for the
45 ; type of vital/measurment taken.
46 ; GMRVIEN = Entry number in file Vital/Measurement (120.5) file.
47 ;
48 ; $P(GMRVDATA,"^",1) = date/time of the reading (FileMan internal)
49 ; $P(GMRVDATA,"^",2) = Patient (#2) number (i.e., DFN)
50 ; $P(GMRVDATA,"^",3) = vital type ien (File 120.51)
51 ; $P(GMRVDATA,"^",4) = date/time of data entry (FileMan internal)
52 ; $P(GMRVDATA,"^",5) = hospital location ien (File 44)
53 ; $P(GMRVDATA,"^",6) = user ien (File 200)
54 ; $P(GMRVDATA,"^",7) = always null
55 ; $P(GMRVDATA,"^",8) = reading (e.g., 98.6, Unavailable)
56 ; $P(GMRVDATA,"^",9) = always null
57 ; $P(GMRVDATA,"^",10) = the first qualifier
58 ; $P(GMRVDATA,"^",11) = the second qualifier
59 ; $P(GMRVDATA,"^",12)= "*" for abnormal measurement, otherwise = ""
60 ; $P(GMRVDATA,"^",13)= values in centigrade for T; kilos for WT;
61 ; centimeters for HT and Circumference/Girth;
62 ; and mmHg for CVP
63 ; $P(GMRVDATA,"^",14)= Body Mass Index
64 ; $P(GMRVDATA,"^",15)= L/Min of supplemental O2
65 ; $P(GMRVDATA,"^",16)= % of supplemental O2
66 ; $P(GMRVDATA,"^",17)= all qualifiers delimited by semi-colons
67 ; The variable GMRVSTR will be killed upon exit.
68 ;
69 Q:'$D(GMRVSTR(0))!'($D(GMRVSTR)#2)!'($D(DFN)#2)
70 Q:DFN'>0
71 I $G(GMRVSTR("LT"))="" S GMRVSTR("LT")="" ;hospital location list
72HSKPING ; Housekeeping
73 K ^UTILITY($J,"GMRVD")
74 N GMVABNML,GMVDATA,GMVEND,GMVHTIEN,GMVIEN,GMVLOOP,GMVMAX,GMVNODE,GMVOCC,GMVRATE,GMVSORD,GMVSTART,GMVTIEN,GMVTYPE,GMVWTIEN
75 D RANGE
76 F GMVLOOP=1:1:$L(GMRVSTR,";") D
77 .S GMVTYPE=$P(GMRVSTR,";",GMVLOOP)
78 .Q:GMVTYPE=""
79 .S GMVMAX(GMVTYPE)=0
80 .Q
81 S GMVOCC=$P(GMRVSTR(0),U,3) ;max # of occurrences
82 S GMVSORD=$P(GMRVSTR(0),U,4) ;sort order
83 S GMVWTIEN=$$GETTYPEI("WT"),GMVHTIEN=$$GETTYPEI("HT")
84 F GMRVSTR(1)=1:1:$L(GMRVSTR,";") S GMVTYPE=$P(GMRVSTR,";",GMRVSTR(1)) I $L(GMVTYPE) S GMVSTART=$S($P(GMRVSTR(0),"^",2):9999999-$P(GMRVSTR(0),"^",2)-.0000001,1:0),GMVEND=9999999-$P(GMRVSTR(0),"^"),GMRVSTR("O")=0 D GETDATE
85 K GMRVSTR
86 Q
87GETDATE ; Loop thru AA xref
88 S GMVTIEN=$O(^GMRD(120.51,"C",GMVTYPE,0)) ;vital type ien
89 Q:'GMVTIEN
90 S GMVLOOP=GMVSTART
91 F S GMVLOOP=$O(^GMR(120.5,"AA",DFN,GMVTIEN,GMVLOOP)) Q:GMVLOOP>GMVEND!(GMVLOOP'>0) D GETNODE Q:GMVMAX(GMVTYPE)>GMVOCC
92 Q
93GETNODE ; Get patient record
94 S GMVIEN=0
95 F S GMVIEN=$O(^GMR(120.5,"AA",DFN,GMVTIEN,GMVLOOP,GMVIEN)) Q:GMVIEN'>0!(GMVMAX(GMVTYPE)>GMVOCC) I '$P($G(^GMR(120.5,+GMVIEN,2)),U) D
96 .S GMVNODE=$G(^GMR(120.5,+GMVIEN,0))
97 .Q:GMVNODE=""!($P(GMVNODE,U,8)="")
98 .I $L(GMRVSTR("LT")) Q:$P(GMVNODE,U,5)'>0 Q:GMRVSTR("LT")'[("^"_$$GET1^DIQ(44,$P(GMVNODE,U,5)_",",2,"I")_"^") ;hospital location check
99 .;max # of occurrence check needed
100 .S GMVMAX(GMVTYPE)=GMVMAX(GMVTYPE)+1
101 .S GMVRATE=$P(GMVNODE,U,8)
102 .D ZERONODE
103 .D QUALS
104 .I GMVTYPE="PO2" D PO2($P(GMVNODE,U,10))
105 .D METRIC
106 .D:$P(GMVNODE,U,3)=GMVWTIEN BMI ;calculate BMI for weight
107 .D:$$TEXT(GMVRATE) ABNORMAL
108 .D SET
109 .Q
110 Q
111GETTYPEI(GMVTIEN) ; Return vital type (120.51) ien
112 ; GMVTIEN = vital type abbreviation
113 S GMVTIEN=$G(GMVTIEN)
114 I GMVTIEN="" Q 0
115 Q $O(^GMRD(120.51,"C",GMVTIEN,0))
116 ;
117ZERONODE ; Get zero node data
118 S GMVDATA=$P($G(GMVNODE),U,1,8)_"^^^^^^^^^"
119 Q
120QUALS ; Get qualifiers for record
121 N GMVQCNT,GMVQIEN,GMVQLIST,GMVQUALS
122 S (GMVQCNT,GMVQIEN)=0,GMVQLIST=""
123 F S GMVQIEN=$O(^GMR(120.5,GMVIEN,5,"B",GMVQIEN)) Q:'GMVQIEN D
124 .S GMVQCNT=GMVQCNT+1
125 .S GMVQUALS(GMVQCNT)=$P($G(^GMRD(120.52,+GMVQIEN,0)),U,1)
126 .Q
127 I $D(GMVQUALS(1)) S $P(GMVDATA,U,10)=GMVQUALS(1)
128 I $D(GMVQUALS(2)) S $P(GMVDATA,U,11)=GMVQUALS(2)
129 I $O(GMVQUALS(0)) D
130 .S GMVQCNT=0
131 .F S GMVQCNT=$O(GMVQUALS(GMVQCNT)) Q:'GMVQCNT D
132 ..S GMVQLIST=GMVQLIST_GMVQUALS(GMVQCNT)_";"
133 ..Q
134 .Q
135 I $G(GMVQLIST)]"" D
136 .S GMVQLIST=$E(GMVQLIST,1,$L(GMVQLIST)-1)
137 .S $P(GMVDATA,U,17)=GMVQLIST
138 .Q
139 Q
140PO2(X) ; Get flow rate and liters/minute for Pulse Oximetry reading
141 N GMVCONC,GMVFLOW
142 S (GMVFLOW,GMVCONC)=""
143 I X["%" D
144 .S GMVCONC=$P(X,"%")
145 .I GMVCONC["l/min" S GMVCONC=$P(GMVCONC,"l/min",2)
146 I X["l/min" D
147 .S GMVFLOW=$P(X,"l/min")
148 .I GMVFLOW["%" S GMVFLOW=$P(GMVFLOW,"%",2)
149 S GMVFLOW=$$STRIP^XLFSTR(GMVFLOW," ")
150 S GMVCONC=$$STRIP^XLFSTR(GMVCONC," ")
151 S $P(GMVDATA,U,15)=GMVFLOW
152 S $P(GMVDATA,U,16)=GMVCONC
153 Q
154METRIC ; Calculate metric value for temperature, height, weight and
155 ; circumference/girth
156 N GMVMETRC
157 S GMVMETRC=""
158 Q:'$$TEXT(GMVRATE) ;quit if not a numeric reading
159 I GMVTYPE="T" D
160 .S GMVMETRC=$J(GMVRATE-32*5/9,0,1)
161 .Q
162 I GMVTYPE="HT" D
163 .S GMVMETRC=$J(2.54*GMVRATE,0,2)
164 .Q
165 I GMVTYPE="WT" D
166 .S GMVMETRC=$J(GMVRATE*.45359237,0,2)
167 .Q
168 I GMVTYPE="CG" D
169 .S GMVMETRC=$J(2.54*GMVRATE,0,2)
170 .Q
171 I GMVTYPE="CVP" D
172 .S GMVMETRC=$J(GMVRATE/1.36,0,2)
173 .Q
174 I GMVMETRC]"" S $P(GMVDATA,U,13)=GMVMETRC
175 Q
176ABNORMAL ; Is reading outside of normal range?
177 N GMVASTRK,GMVDIA,GMVSYS
178 S GMVASTRK=""
179 I GMVTYPE="T" D
180 .S:GMVRATE>$P(GMVABNML("T"),U,1) GMVASTRK="*"
181 .S:GMVRATE<$P(GMVABNML("T"),U,2) GMVASTRK="*"
182 .Q
183 I GMVTYPE="P" D
184 .S:GMVRATE>$P(GMVABNML("P"),U,1) GMVASTRK="*"
185 .S:GMVRATE<$P(GMVABNML("P"),U,2) GMVASTRK="*"
186 .Q
187 I GMVTYPE="R" D
188 .S:GMVRATE>$P(GMVABNML("R"),U,1) GMVASTRK="*"
189 .S:GMVRATE<$P(GMVABNML("R"),U,2) GMVASTRK="*"
190 .Q
191 I GMVTYPE="BP" D
192 .S GMVSYS=$P(GMVRATE,"/",1)
193 .S GMVDIA=$S($P(GMVRATE,"/",3)="":$P(GMVRATE,"/",2),1:$P(GMVRATE,"/",3))
194 .S:GMVSYS>$P(GMVABNML("BP"),U,7) GMVASTRK="*"
195 .S:GMVSYS<$P(GMVABNML("BP"),U,9) GMVASTRK="*"
196 .S:GMVDIA>$P(GMVABNML("BP"),U,8) GMVASTRK="*"
197 .S:GMVDIA<$P(GMVABNML("BP"),U,10) GMVASTRK="*"
198 .Q
199 I GMVTYPE="CVP" D
200 .S:GMVRATE>$P(GMVABNML("CVP"),U,1) GMVASTRK="*"
201 .S:GMVRATE<$P(GMVABNML("CVP"),U,2) GMVASTRK="*"
202 .Q
203 I GMVTYPE="PO2" D
204 .S:GMVRATE<$P(GMVABNML("PO2"),U,2) GMVASTRK="*"
205 .Q
206 S $P(GMVDATA,U,12)=GMVASTRK
207 Q
208BMI ; Calculate Body Mass Index
209 N GMVBMI
210 S GMVBMI=""
211 S GMVBMI=$$CALCBMI^GMVHS1(GMVNODE,GMVLOOP)
212 S $P(GMVDATA,U,14)=GMVBMI
213 Q
214SET ; Set UTILITY($J,"GMRVD") node
215 S:'GMVSORD ^UTILITY($J,"GMRVD",GMVTYPE,GMVLOOP,GMVIEN)=GMVDATA
216 S:GMVSORD ^UTILITY($J,"GMRVD",GMVLOOP,GMVTYPE,GMVIEN)=GMVDATA
217 Q
218TEXT(RATE) ; Is rate a text code?
219 ; Returns 0 if RATE has a text code and 1 if a numeric reading
220 N GMVYES
221 S RATE=$G(RATE),GMVYES=1
222 I "REFUSEDPASSUNAVAILABLE"[$$UP^XLFSTR(RATE) S GMVYES=0
223 Q GMVYES
224 ;
225RANGE ; Find normal ranges and store in array
226 N GMVPIEN,GMVPNODE
227 S GMVABNML("T")="0^0" ;high^low
228 S GMVABNML("P")="0^0" ;high^low
229 S GMVABNML("R")="0^0" ;high^low
230 S GMVABNML("CVP")="0^0" ;high^low
231 S GMVABNML("PO2")="0^0" ;low
232 S GMVABNML("BP")="0^0^0^0" ;sys high^sys low^dia high^dia low
233 S GMVPIEN=$O(^GMRD(120.57,0))
234 Q:'GMVPIEN
235 S GMVPNODE=$G(^GMRD(120.57,GMVPIEN,1))
236 S GMVABNML("T")=$P(GMVPNODE,U,1)_U_$P(GMVPNODE,U,2)
237 S GMVABNML("P")=$P(GMVPNODE,U,3)_U_$P(GMVPNODE,U,4)
238 S GMVABNML("R")=$P(GMVPNODE,U,5)_U_$P(GMVPNODE,U,6)
239 S GMVABNML("BP")=$P(GMVPNODE,U,7)_U_$P(GMVPNODE,U,9)_U_$P(GMVPNODE,U,8)_U_$P(GMVPNODE,U,10)
240 S GMVABNML("CVP")=$P(GMVPNODE,U,11)_U_$P(GMVPNODE,U,12)
241 S GMVABNML("PO2")=""_U_$P(GMVPNODE,U,13)
242 Q
Note: See TracBrowser for help on using the repository browser.