source: ccr/trunk/p/C0CVITAL.m@ 1632

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

Changed license to AGPL. Some clean-up for XINDEX

  • Property svn:mergeinfo set to (toggle deleted branches)
    /ccr/branches/ohum/o-old/p/C0CVITAL.m1290
    /ccr/branches/ohum/p/C0CVITAL.m1291-1543
    /ccr/branches/ohum/p/p/C0CVITAL.m1287-1289
File size: 21.8 KB
Line 
1C0CVITAL ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
3 ;
4 ; This program is free software: you can redistribute it and/or modify
5 ; it under the terms of the GNU Affero General Public License as
6 ; published by the Free Software Foundation, either version 3 of the
7 ; License, or (at your option) any later version.
8 ;
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU Affero General Public License for more details.
13 ;
14 ; You should have received a copy of the GNU Affero General Public License
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ;
17 W "NO ENTRY FROM TOP",!
18 Q
19 ;
20EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
21 ;
22 ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
23 ; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
24 ;
25 N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
26 S C0CVLMT=$$GET^C0CPARMS("VITLIMIT") ; GET THE LIMIT PARM
27 S C0CVSTRT=$$GET^C0CPARMS("VITSTART") ; GET START PARM
28 D DT^DILF(,C0CVLMT,.C0CEDT) ;
29 D DT^DILF(,C0CVSTRT,.C0CSDT) ;
30 ;D DT^DILF(,C0CVLMT,.C0CSDT) ; GPL TESTING
31 ;D DT^DILF(,C0CVSTRT,.C0CEDT) ;
32 W "VITALS START: ",C0CVSTRT," LIMIT: ",C0CVLMT,!
33 I $$RPMS^C0CUTIL() D VITRPMS QUIT
34 I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VITVISTA QUIT
35 ;I $$SYSNAME^C0CSYS()="RPMS" D VITRPMS
36 ;E D VITVISTA
37 Q
38 ;
39VITVISTA ; EXTRACT VITALS FROM VISTA INTO PROVIDED XML TEMPLATE
40 D FASTVIT^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT) ; GPL THIS ONE WORKS FOR AT
41 ; LEAST ONE SET OF VITALS - TO DO, CALL IT REPETIVELY TO GET EARLIER VITALS
42 ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT)
43 ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CSDT,C0CEDT)
44 ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CVSTRT,C0CVLMT) ; GPL LET GMR HANDLE THE DATES
45 I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT
46 I $P(VITRSLT(1),U,2)="No vitals found." D Q ; NULL RESULT FROM RPC
47 . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
48 . S @VITOUTXML@(0)=0
49 I $P(VITRSLT(1),U,2)="No vitals found." Q ; QUIT
50 ; ZWR RPCRSLT
51 S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
52 S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
53 K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
54 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
55 D SORTVIST(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
56 ; I DEBUG ZWR VDATES ;DEBUG
57 S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
58 ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
59 S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
60 F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
61 . I $D(VITRSLT(VSORT(J))) D
62 . . S VITVMAP=$NA(@VITTVMAP@(J))
63 . . K @VITVMAP
64 . . I DEBUG W "VMAP= ",VITVMAP,!
65 . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
66 . . I DEBUG W "VITAL ",VSORT(J),!
67 . . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
68 . . I DEBUG W $P(VITPTMP,U,4),!
69 . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
70 . . ;B ;gpl
71 . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
72 . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D ;
73 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1"
74 . . I $P(VITPTMP,U,2)="HT" D
75 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
76 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
77 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
78 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
79 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
80 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
81 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
82 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
83 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
84 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
85 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
86 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
87 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
88 . . E I $P(VITPTMP,U,2)="WT" D
89 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
90 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
91 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
92 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
93 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
94 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
95 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
96 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
97 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
98 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
99 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
100 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
101 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
102 . . E I $P(VITPTMP,U,2)="BP" D
103 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
104 . . . ;S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
105 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
106 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
107 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
108 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
109 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
110 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
111 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
112 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
113 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
114 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
115 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
116 . . E I $P(VITPTMP,U,2)="T" D
117 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
118 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
119 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
120 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
121 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
122 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
123 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
124 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
125 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
126 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
127 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
128 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
129 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
130 . . E I $P(VITPTMP,U,2)="R" D
131 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
132 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
133 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
134 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
135 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
136 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
137 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
138 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
139 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
140 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
141 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
142 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
143 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
144 . . E I $P(VITPTMP,U,2)="P" D
145 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
146 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
147 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
148 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
149 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
150 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
151 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
152 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
153 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
154 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
155 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
156 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
157 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
158 . . E I $P(VITPTMP,U,2)="PN" D
159 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
160 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
161 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
162 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
163 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
164 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
165 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
166 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
167 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
168 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
169 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
170 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
171 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
172 . . E I $P(VITPTMP,U,2)="BMI" D
173 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
174 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
175 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
176 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
177 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
178 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
179 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
180 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="60621009"
181 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
182 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
183 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
184 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
185 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
186 . . E D
187 . . . ;W "IN VITAL: OTHER",!
188 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
189 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
190 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
191 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
192 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
193 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
194 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
195 . . . ;S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
196 . . . ;S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
197 . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
198 . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
199 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
200 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
201 . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D ;
202 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1" ;
203 . . S VITARYTMP=$NA(@VITTARYTMP@(J))
204 . . K @VITARYTMP
205 . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
206 . . I J=1 D ; FIRST ONE IS JUST A COPY
207 . . . ; W "FIRST ONE",!
208 . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
209 . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
210 . . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
211 . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
212 ; ZWR ^TMP($J,"VITALS",*)
213 ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
214 I DEBUG D PARY^C0CXPATH(VITOUTXML)
215 N VITTMP,I
216 D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
217 I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
218 . W "VITALS MISSING ",!
219 . F I=1:1:VITTMP(0) W VITTMP(I),!
220 Q
221 ;
222VITRPMS ; EXTRACT VITALS FROM RPMS INTO PROVIDED XML TEMPLATE
223 ; RPMS VITAL RPC ONLY RETURNS LATEST VITAL IN SPECIFIED DATE RANGE NOT ALL VITALS IN DATE RANGE
224 ; WE NEED TO SETUP THE VARIABLES THE INTERNAL CALL NEEDS TO BYPASS A HARD CODE OF ONE VITAL FOR DATE RANGE
225 N END,START,DATA
226 D DT^DILF("",C0CVLMT,.END)
227 D DT^DILF("",C0CVSTRT,.START)
228 ; RPC OUTPUT FORMAT:
229 ; vfile ien^vital name^vital abbr^date/time taken(FM FORMAT)^value+units (US & metric)
230 D QUERY^BEHOVM("LISTX") ; RUN QUERY VITALS CALL
231 I '$D(^TMP("CIAVMRPC",$J)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT
232 ;ZW ^TMP("CIAVMRPC",$J)
233 S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
234 S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
235 K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
236 N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
237 D SORTRPMS(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
238 S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
239 ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
240 S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
241 F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
242 . I $D(^TMP("CIAVMRPC",$J,0,(VSORT(J)))) D
243 . . S VITVMAP=$NA(@VITTVMAP@(J))
244 . . K @VITVMAP
245 . . I DEBUG W "VMAP= ",VITVMAP,!
246 . . S VITPTMP=^TMP("CIAVMRPC",$J,0,(VSORT(J))) ; DATE SORTED VITAL FROM RETURN ARRAY
247 . . I DEBUG W "VITAL ",VSORT(J),!
248 . . I DEBUG W ^TMP("CIAVMRPC",$J,0,(VSORT(J)))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
249 . . I DEBUG W $P(VITPTMP,U,4),!
250 . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
251 . . I $P(VITPTMP,U,3)="HT" D
252 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
253 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
254 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
255 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
256 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
257 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
258 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
259 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
260 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
261 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
262 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
263 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
264 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
265 . . E I $P(VITPTMP,U,3)="WT" D
266 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
267 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
268 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
269 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
270 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
271 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
272 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
273 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
274 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
275 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
276 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
277 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
278 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
279 . . E I $P(VITPTMP,U,3)="BP" D
280 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
281 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
282 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
283 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
284 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
285 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
286 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
287 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
288 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
289 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
290 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
291 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
292 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
293 . . E I $P(VITPTMP,U,3)="TMP" D
294 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
295 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
296 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
297 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
298 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
299 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
300 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
301 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
302 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
303 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
304 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
305 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
306 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
307 . . E I $P(VITPTMP,U,3)="RS" D
308 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
309 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
310 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
311 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
312 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
313 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
314 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
315 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
316 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
317 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
318 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
319 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
320 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
321 . . E I $P(VITPTMP,U,3)="PU" D
322 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
323 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
324 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
325 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
326 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
327 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
328 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
329 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
330 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
331 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
332 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
333 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
334 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
335 . . E I $P(VITPTMP,U,3)="PA" D
336 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
337 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
338 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
339 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
340 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
341 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
342 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
343 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
344 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
345 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
346 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
347 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
348 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
349 . . E D
350 . . . ;W "IN VITAL: OTHER",!
351 . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
352 . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
353 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
354 . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
355 . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
356 . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
357 . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
358 . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
359 . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
360 . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
361 . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
362 . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
363 . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
364 . . S VITARYTMP=$NA(@VITTARYTMP@(J))
365 . . K @VITARYTMP
366 . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
367 . . I J=1 D ; FIRST ONE IS JUST A COPY
368 . . . ; W "FIRST ONE",!
369 . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
370 . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
371 . . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
372 . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
373 ; ZWR ^TMP($J,"VITALS",*)
374 ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
375 I DEBUG D PARY^C0CXPATH(VITOUTXML)
376 N VITTMP,I
377 D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
378 I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
379 . W "VITALS MISSING ",!
380 . F I=1:1:VITTMP(0) W VITTMP(I),!
381 K ^TMP("CIAVMRPC",$J)
382 Q
383 ;
384SORTRPMS(VDT) ; RUN DATE SORTING ALGORITHM FOR RPMS
385 ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
386 ; OF DATES IN THE VITALS RESULTS
387 N VDTI,VDTJ,VTDCNT
388 S VTDCNT=0 ; COUNT TO BUILD ARRAY
389 S VDTJ="" ; USED TO VISIT THE RESULTS
390 F VDTI=0:0 D Q:$O(^TMP("CIAVMRPC",$J,0,VDTJ))="" ; VISIT ALL RESULTS
391 . S VDTJ=$O(^TMP("CIAVMRPC",$J,0,VDTJ)) ; NEXT RESULT
392 . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
393 . S VDT(VTDCNT)=$P(^TMP("CIAVMRPC",$J,0,VDTJ),U,4) ; PULL OUT THE DATE
394 S VDT(0)=VTDCNT
395 Q
396 ;
397SORTVIST(VDT) ; RUN DATE SORTING ALGORITHM FOR VISTA
398 ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
399 ; OF DATES IN THE VITALS RESULTS
400 N VDTI,VDTJ,VTDCNT
401 S VTDCNT=0 ; COUNT TO BUILD ARRAY
402 S VDTJ="" ; USED TO VISIT THE RESULTS
403 F VDTI=0:0 D Q:$O(VITRSLT(VDTJ))="" ; VISIT ALL RESULTS
404 . S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
405 . S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
406 . S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
407 S VDT(0)=VTDCNT
408 Q
409 ;
Note: See TracBrowser for help on using the repository browser.