source: ccr/branches/ohum/p/C0CVIT2.m@ 1476

Last change on this file since 1476 was 1433, checked in by Sam Habiel, 12 years ago

Update based on OHUM's latest routines

File size: 20.5 KB
Line 
1C0CVIT2 ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
2 ;;1.2;C0C;;May 11, 2012;Build 47
3 ;Copyright 2008,2009 George Lilly, University of Minnesota and others.
4 ;Licensed under the terms of the GNU General Public License.
5 ;See attached copy of the License.
6 ;
7 ;This program is free software; you can redistribute it and/or modify
8 ;it under the terms of the GNU General Public License as published by
9 ;the Free Software Foundation; either version 2 of the License, or
10 ;(at your option) any later version.
11 ;
12 ;This program is distributed in the hope that it will be useful,
13 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;GNU General Public License for more details.
16 ;
17 ;You should have received a copy of the GNU General Public License along
18 ;with this program; if not, write to the Free Software Foundation, Inc.,
19 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 ;
21 W "NO ENTRY FROM TOP",!
22 Q
23 ;
24EXTRACT(VITXML,DFN,VITOUT) ; EXTRACT VITAL SIGNS INTO XML TEMPLATE
25 ; VITXML AND VITOUT ARE PASSED BY NAME SO GLOBALS CAN BE USED
26 ;
27 ; USE THE FOLLOWING TEMPLATE FOR THE RNF2 ARRAYS
28 ; THAT GET PASSED TO *GET ROUTINES
29 ;C0C[NAME]=$NA(^TMP("C0CCCR",$J,DFN,"C0C(NAME))
30 N C0CVIT
31 S C0CVIT=$NA(^TMP("C0CCCR",$J,DFN,"C0CVIT"))
32 ; USE THE FOLLOWING TEMPLATE FOR GETTING/GENERATING THE RNF2 ARRAYS
33 ; THAT GET INSERTED INTO THE XML TEMPLATE
34 ; D GET[VISTA/RPMS](DFN,C0CIMM) ; GET VARS
35 I $$RPMS^C0CUTIL() D GETRPMS(DFN,C0CVIT) ; GET VARS
36 I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D GETVISTA(DFN,C0CVIT)
37 ; USE THE FOLLOWING TEMPATE FOR MAPPING RNF2 ARRAYS TO XML TEMPLATE
38 ; D MAP([NAME]XML,C0C[NAME],[NAME]OUT) ;MAP RESULTS FOR PROCEDURES
39 D MAP(VITXML,C0CVIT,VITOUT) ;MAP RESULTS FOR PROCEDURES
40 Q
41 ;
42GETVISTA(DFN,C0CVIT) ; CALLS VITALS^ORQQVI TO GET VITAL SIGNS.
43 ; ERETURNS THEM IN RNF2 ARRAYS PASSED BY NAME
44 ; C0CVIT: VITAL SIGNS
45 ; READY TO BE MAPPED TO XML BY MAP^C0CVIT2
46 ; THESE RETURN ARRAYS ARE NOT INITIALIZED, BUT ARE ADDED TO IF THEY
47 ; EXIST.
48 ;
49 ; KILL OF ARRAYS IS TAKEN CARE OF IN ^C0CCCR (K ^TMP("C0CCCR",$J))
50 ;
51 ; SETUP RPC/API CALL HERE
52 ; USE START AND END DATES FROM PARAMETERS IF REQUIRED
53 ;
54 N VIT,DATA,START,END
55 ; RPC REQUIRES FM DATES NOT T-* DATES
56 D DT^DILF(,$$GET^C0CPARMS("VITLIMIT"),.END) ; GET THE LIMIT PARM
57 D DT^DILF(,$$GET^C0CPARMS("VITSTART"),.START) ; GET START PARM
58 ; RPC CALL (ORY,DFN,ORSDT,OREDT):
59 ;ORY: return variable
60 ;DFN: patient identifier from Patient File [#2]
61 ;ORSDT: start date/time in Fileman format
62 ;OREDT: end date/time in Fileman format
63 ; OUTPUT FORMAT:
64 ;vital measurement ien^vital type^rate^date/time taken
65 D VITALS^ORQQVI(.VIT,DFN,START,END) ; RUN QUERY VITALS CALL
66 I '$D(VIT) S @VITOUT@(0)=0 K VIT Q ; RETURN NOT FOUND, KILL ARRAY AND QUIT
67 I $P(VIT(1),U,2)="No vitals found." D Q ; signal no vitals and quit
68 . I $D(VITOUT) S @VITOUT@(0)=0
69 . K VIT
70 ;
71 ; PREFORM SORT HERE IF NEEDED
72 ;
73 ; SORT IS REQUIRED FOR VITAL SIGNS - LATEST VITALS NEED TO BE LISTED FIRST
74 ; COPIED SORT LOGIC:
75 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
76 D VITSORT(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
77 S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
78 ; VSORT IS VITALS IN REVERSE ORDER
79 ;
80 ; MAP EACH ROW OF RPC/API TO RNF1 ARRAY
81 ; RNF1 ARRAY FORMAT:
82 ; VAR("NAME_OF_RIM_VARIABLE")=VALUE
83 ;
84 ; VITAL SIGNS ARE DONE DIFFERENTLY DUE TO THE DIFFERENT TYPES OF VITAL SIGNS
85 ; THIS LOOP WILL GET EACH ROW, DETERMINE THE TYPE, AND CALL THE RESPECTIVE PROCESSING METHOD
86 ; THAT WILL DO THE MAPPING TO RNF1 STYLE ARRAYS
87 N C0CVI,C0CC,ZRNF
88 ;S C0CVI="" ; INITIALIZE FOR $O
89 F C0CC=1:1:VSORT(0) S C0CVI=VSORT(C0CC) D ; FOR EACH VITAL SIGN IN THE LIST
90 . I DEBUG W VIT(C0CVI),!
91 . ; FIGURE OUT WHICH TYPE OF VITAL SIGN IT IS (HEIGHT, WEIGHT, BLOOD PRESSURE, TEMPERATURE, RESPIRATION, PULSE, PAIN, OTHER)
92 . D:$P(VIT(C0CVI),U,3)="HT" HEIGHT1($$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT"),$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"in")
93 . D:$P(VIT(C0CVI),U,3)="WT" WEIGHT1($$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT"),$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"lbs")
94 . D:$P(VIT(C0CVI),U,3)="BP" BP1($$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT"),$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"")
95 . D:$P(VIT(C0CVI),U,3)="T" TMP1($$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT"),$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"F")
96 . D:$P(VIT(C0CVI),U,3)="R" RESP1($$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT"),$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"")
97 . D:$P(VIT(C0CVI),U,3)="P" PULSE1($$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT"),$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"")
98 . D:$P(VIT(C0CVI),U,3)="PN" PAIN1($$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT"),$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"")
99 . D:'$D(ZRNF) OTHER1($$FMDTOUTC^C0CUTIL($P(C0CVI,U,4),"DT"),"OTHER VITAL",$P(^GMR(120.5,$P(VIT(C0CVI),U,1),0),U,6),$P(VIT(C0CVI),U,3),"UNKNOWN") ;IF THE VITAL ISN'T DEFINED IT IS OTHER
100 . D RNF1TO2^C0CRNF(C0CVIT,"ZRNF") ;ADD THIS ROW TO THE ARRAY
101 . K ZRNF
102 ; SAVE RIM VARIABLES SEE C0CRIMA
103 N ZRIM S ZRIM=$NA(^TMP("C0CRIM","VARS",DFN,"VITALS"))
104 M @ZRIM=@C0CVIT@("V")
105 Q
106 ;
107GETRPMS(DFN,C0CVIT) ; CALLS QUERY^BEHOVM TO GET VITAL SIGNS.
108 ; ERETURNS THEM IN RNF2 ARRAYS PASSED BY NAME
109 ; C0CVIT: VITAL SIGNS
110 ; READY TO BE MAPPED TO XML BY MAP^C0CVIT2
111 ; THESE RETURN ARRAYS ARE NOT INITIALIZED, BUT ARE ADDED TO IF THEY
112 ; EXIST.
113 ;
114 ; KILL OF ARRAYS IS TAKEN CARE OF IN ^C0CCCR (K ^TMP("C0CCCR",$J))
115 ;
116 ; SETUP RPC/API CALL HERE
117 ; USE START AND END DATES FROM PARAMETERS IF REQUIRED
118 ;
119 ; RPMS VITAL RPC ONLY RETURNS LATEST VITAL IN SPECIFIED DATE RANGE NOT ALL VITALS IN DATE RANGE
120 ; WE NEED TO SETUP THE VARIABLES THE INTERNAL CALL NEEDS TO BYPASS A HARD CODE OF ONE VITAL FOR DATE RANGE
121 N C0CEDT,C0CSDT,VIT,DATA,START,END
122 ; RPC REQUIRES FM DATES NOT T-* DATES
123 D DT^DILF(,$$GET^C0CPARMS("VITLIMIT"),.END) ; GET THE LIMIT PARM
124 D DT^DILF(,$$GET^C0CPARMS("VITSTART"),.START) ; GET START PARM
125 ; RPC OUTPUT FORMAT:
126 ; vfile ien^vital name^vital abbr^date/time taken(FM FORMAT)^value+units (US & metric)
127 D QUERY^BEHOVM("LISTX") ; RUN QUERY VITALS CALL
128 I '$D(^TMP("CIAVMRPC",$J)) S @VITOUT@(0)=0 K ^TMP("CIAVMRPC",$J) Q ; RETURN NOT FOUND, KILL ARRAY AND QUIT
129 ; MOVE THE ARRAY TO LOCAL VARIABLE
130 M VIT=^TMP("CIAVMRPC",$J,0)
131 ; RPC CLEANUP
132 K ^TMP("CIAVMRPC",$J),VITS,RMAX,START,END,DATA,METRIC,VSTR,VUNT
133 ;
134 ; PREFORM SORT HERE IF NEEDED
135 ;
136 ; SORT IS REQUIRED FOR VITAL SIGNS - LATEST VITALS NEED TO BE LISTED FIRST
137 ; COPIED SORT LOGIC:
138 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
139 D VITSORT(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
140 S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
141 ; VSORT IS VITALS IN REVERSE ORDER
142 ;
143 ; MAP EACH ROW OF RPC/API TO RNF1 ARRAY
144 ; RNF1 ARRAY FORMAT:
145 ; VAR("NAME_OF_RIM_VARIABLE")=VALUE
146 ;
147 ; VITAL SIGNS ARE DONE DIFFERENTLY DUE TO THE DIFFERENT TYPES OF VITAL SIGNS
148 ; THIS LOOP WILL GET EACH ROW, DETERMINE THE TYPE, AND CALL THE RESPECTIVE PROCESSING METHOD
149 ; THAT WILL DO THE MAPPING TO RNF1 STYLE ARRAYS
150 N C0CVI,C0CC,ZRNF
151 ;S C0CVI="" ; INITIALIZE FOR $O
152 F C0CC=1:1:VSORT(0) S C0CVI=VSORT(C0CC) D ; FOR EACH VITAL SIGN IN THE LIST
153 . I DEBUG W VIT(C0CVI),!
154 . ; FIGURE OUT WHICH TYPE OF VITAL SIGN IT IS (HEIGHT, WEIGHT, BLOOD PRESSURE, TEMPERATURE, RESPIRATION, PULSE, PAIN, OTHER)
155 . D:$P(VIT(C0CVI),U,3)="HT" HEIGHT
156 . D:$P(VIT(C0CVI),U,3)="WT" WEIGHT
157 . D:$P(VIT(C0CVI),U,3)="BP" BP
158 . D:$P(VIT(C0CVI),U,3)="TMP" TMP
159 . D:$P(VIT(C0CVI),U,3)="RS" RESP
160 . D:$P(VIT(C0CVI),U,3)="PU" PULSE
161 . D:$P(VIT(C0CVI),U,3)="PA" PAIN
162 . D:'$D(ZRNF) OTHER ;IF THE VITAL ISN'T DEFINED IT IS OTHER
163 . D RNF1TO2^C0CRNF(C0CVIT,"ZRNF") ;ADD THIS ROW TO THE ARRAY
164 . K ZRNF
165 ; SAVE RIM VARIABLES SEE C0CRIMA
166 N ZRIM S ZRIM=$NA(^TMP("C0CRIM","VARS",DFN,"VITALS"))
167 M @ZRIM=@C0CVIT@("V")
168 Q
169 ;
170HEIGHT
171 I DEBUG W "IN VITAL: HEIGHT",!
172 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC ; UNIQUE OBJID
173 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
174 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
175 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
176 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
177 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
178 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
179 S ZRNF("VITALSIGNSDESCCODEVALUE")="248327008"
180 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
181 S ZRNF("VITALSIGNSCODEVERSION")=""
182 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
183 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
184 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
185 Q
186 ;
187WEIGHT
188 I DEBUG W "IN VITAL: WEIGHT",!
189 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
190 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
191 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
192 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
193 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
194 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
195 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
196 S ZRNF("VITALSIGNSDESCCODEVALUE")="107647005"
197 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
198 S ZRNF("VITALSIGNSCODEVERSION")=""
199 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
200 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
201 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
202 Q
203 ;
204BP
205 I DEBUG W "IN VITAL: BLOOD PRESSURE",!
206 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
207 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
208 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
209 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
210 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
211 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
212 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
213 S ZRNF("VITALSIGNSDESCCODEVALUE")="392570002"
214 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
215 S ZRNF("VITALSIGNSCODEVERSION")=""
216 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
217 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
218 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
219 Q
220 ;
221TMP
222 I DEBUG W "IN VITAL: TEMPERATURE",!
223 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
224 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
225 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
226 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
227 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
228 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
229 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
230 S ZRNF("VITALSIGNSDESCCODEVALUE")="309646008"
231 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
232 S ZRNF("VITALSIGNSCODEVERSION")=""
233 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
234 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
235 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
236 Q
237 ;
238RESP
239 I DEBUG W "IN VITAL: RESPIRATION",!
240 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
241 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
242 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
243 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
244 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
245 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
246 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
247 S ZRNF("VITALSIGNSDESCCODEVALUE")="366147009"
248 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
249 S ZRNF("VITALSIGNSCODEVERSION")=""
250 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
251 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
252 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
253 Q
254 ;
255PULSE
256 I DEBUG W "IN VITAL: PULSE",!
257 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
258 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
259 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
260 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
261 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
262 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
263 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
264 S ZRNF("VITALSIGNSDESCCODEVALUE")="366199006"
265 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
266 S ZRNF("VITALSIGNSCODEVERSION")=""
267 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
268 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
269 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
270 Q
271 ;
272PAIN
273 I DEBUG W "IN VITAL: PAIN",!
274 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
275 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
276 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
277 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
278 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
279 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
280 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
281 S ZRNF("VITALSIGNSDESCCODEVALUE")="22253000"
282 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
283 S ZRNF("VITALSIGNSCODEVERSION")=""
284 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
285 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
286 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
287 Q
288 ;
289OTHER
290 I DEBUG W "IN VITAL: OTHER",!
291 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
292 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
293 S ZRNF("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VIT(C0CVI),U,4),"DT")
294 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")=$P(VIT(C0CVI),U,2)
295 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
296 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
297 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
298 S ZRNF("VITALSIGNSDESCCODEVALUE")=""
299 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")=""
300 S ZRNF("VITALSIGNSCODEVERSION")=""
301 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VIT(C0CVI),U,1),12)),U,4)
302 S ZRNF("VITALSIGNSTESTRESULTVALUE")=$P($P(VIT(C0CVI),U,5)," ",1)
303 S ZRNF("VITALSIGNSTESTRESULTUNIT")=$P($P(VIT(C0CVI),U,5)," ",2)
304 Q
305 ;
306 ;TEMPORARY, THINKING ON HOW TO REFACTOR (CJE)
307HEIGHT1(DT,ACTOR,VALUE,UNIT)
308 I DEBUG W "IN VITAL: HEIGHT",!
309 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC ; UNIQUE OBJID
310 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
311 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
312 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
313 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
314 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
315 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
316 S ZRNF("VITALSIGNSDESCCODEVALUE")="248327008"
317 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
318 S ZRNF("VITALSIGNSCODEVERSION")=""
319 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
320 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
321 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
322 Q
323 ;
324WEIGHT1(DT,ACTOR,VALUE,UNIT)
325 I DEBUG W "IN VITAL: WEIGHT",!
326 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
327 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
328 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
329 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
330 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
331 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
332 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
333 S ZRNF("VITALSIGNSDESCCODEVALUE")="107647005"
334 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
335 S ZRNF("VITALSIGNSCODEVERSION")=""
336 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
337 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
338 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
339 Q
340 ;
341BP1(DT,ACTOR,VALUE,UNIT)
342 I DEBUG W "IN VITAL: BLOOD PRESSURE",!
343 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
344 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
345 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
346 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
347 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
348 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
349 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
350 S ZRNF("VITALSIGNSDESCCODEVALUE")="392570002"
351 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
352 S ZRNF("VITALSIGNSCODEVERSION")=""
353 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
354 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
355 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
356 Q
357 ;
358TMP1(DT,ACTOR,VALUE,UNIT)
359 I DEBUG W "IN VITAL: TEMPERATURE",!
360 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
361 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
362 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
363 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
364 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
365 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
366 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
367 S ZRNF("VITALSIGNSDESCCODEVALUE")="309646008"
368 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
369 S ZRNF("VITALSIGNSCODEVERSION")=""
370 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
371 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
372 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
373 Q
374 ;
375RESP1(DT,ACTOR,VALUE,UNIT)
376 I DEBUG W "IN VITAL: RESPIRATION",!
377 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
378 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
379 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
380 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
381 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
382 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
383 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
384 S ZRNF("VITALSIGNSDESCCODEVALUE")="366147009"
385 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
386 S ZRNF("VITALSIGNSCODEVERSION")=""
387 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
388 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
389 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
390 Q
391 ;
392PULSE1(DT,ACTOR,VALUE,UNIT)
393 I DEBUG W "IN VITAL: PULSE",!
394 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
395 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
396 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
397 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
398 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
399 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
400 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
401 S ZRNF("VITALSIGNSDESCCODEVALUE")="366199006"
402 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
403 S ZRNF("VITALSIGNSCODEVERSION")=""
404 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
405 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
406 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
407 Q
408 ;
409PAIN1(DT,ACTOR,VALUE,UNIT)
410 I DEBUG W "IN VITAL: PAIN",!
411 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
412 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
413 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
414 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
415 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
416 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
417 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
418 S ZRNF("VITALSIGNSDESCCODEVALUE")="22253000"
419 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
420 S ZRNF("VITALSIGNSCODEVERSION")=""
421 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
422 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
423 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
424 Q
425 ;
426OTHER1(DT,TEXT,ACTOR,VALUE,UNIT)
427 I DEBUG W "IN VITAL: OTHER",!
428 S ZRNF("VITALSIGNSDATAOBJECTID")="VITAL"_C0CC
429 S ZRNF("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
430 S ZRNF("VITALSIGNSEXACTDATETIME")=DT
431 S ZRNF("VITALSIGNSDESCRIPTIONTEXT")=TEXT
432 S ZRNF("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
433 S ZRNF("VITALSIGNSTESTOBJECTID")="VITALTEST"_C0CC
434 S ZRNF("VITALSIGNSTESTTYPETEXT")="OBSERVED"
435 S ZRNF("VITALSIGNSDESCCODEVALUE")=""
436 S ZRNF("VITALSIGNSDESCCODINGSYSTEM")=""
437 S ZRNF("VITALSIGNSCODEVERSION")=""
438 S ZRNF("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_ACTOR
439 S ZRNF("VITALSIGNSTESTRESULTVALUE")=VALUE
440 S ZRNF("VITALSIGNSTESTRESULTUNIT")=UNIT
441 Q
442 ;
443VITSORT(VDT) ; RUN DATE SORTING ALGORITHM
444 ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
445 ; OF DATES IN THE VITALS RESULTS
446 N VDTI,VDTJ,VTDCNT
447 S VTDCNT=0 ; COUNT TO BUILD ARRAY
448 S VDTJ="" ; USED TO VISIT THE RESULTS
449 F VDTI=0:0 D Q:$O(VIT(VDTJ))="" ; VISIT ALL RESULTS
450 . S VDTJ=$O(VIT(VDTJ)) ; NEXT RESULT
451 . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
452 . S VDT(VTDCNT)=$P(VIT(VDTJ),U,4) ; PULL OUT THE DATE
453 S VDT(0)=VTDCNT
454 Q
455 ;
456MAP(VITXML,C0CVIT,VITOUT) ; MAP VITAL SIGNS XML
457 ;
458 N ZTEMP S ZTEMP=$NA(^TMP("C0CCCR",$J,DFN,"VITTEMP")) ;WORK AREA FOR TEMPLATE
459 K @ZTEMP
460 N ZBLD
461 S ZBLD=$NA(^TMP("C0CCCR",$J,DFN,"VITBLD")) ; BUILD LIST AREA
462 D QUEUE^C0CXPATH(ZBLD,VITXML,1,1) ; FIRST LINE
463 N ZINNER
464 ; XPATH NEEDS TO MATCH YOUR SECTION
465 D QUERY^C0CXPATH(VITXML,"//VitalSigns/Result","ZINNER") ;ONE VITAL SIGN
466 N ZTMP,ZVAR,ZI
467 S ZI=""
468 F S ZI=$O(@C0CVIT@("V",ZI)) Q:ZI="" D ;FOR EACH VITAL SIGN
469 . S ZTMP=$NA(@ZTEMP@(ZI)) ;THIS VITAL SIGN XML
470 . S ZVAR=$NA(@C0CVIT@("V",ZI)) ;THIS VITAL SIGN VARIABLES
471 . D MAP^C0CXPATH("ZINNER",ZVAR,ZTMP) ; MAP THE VITAL SIGN
472 . D QUEUE^C0CXPATH(ZBLD,ZTMP,1,@ZTMP@(0)) ;QUEUE FOR BUILD
473 D QUEUE^C0CXPATH(ZBLD,VITXML,@VITXML@(0),@VITXML@(0))
474 N ZZTMP ; IS THIS NEEDED?
475 D BUILD^C0CXPATH(ZBLD,VITOUT) ;BUILD FINAL XML
476 K @ZTEMP,@ZBLD
477 Q
478 ;
Note: See TracBrowser for help on using the repository browser.