source: WorldVistAEHR/trunk/r/AUTOMATED_LAB_INSTRUMENTS-LA/LA7VORM.m@ 861

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

initial load of WorldVistAEHR

File size: 8.6 KB
RevLine 
[613]1LA7VORM ;DALOI/DLR - LAB ORM (Order) message PROCESSOR ; April 13, 2004
2 ;;5.2;AUTOMATED LAB INSTRUMENTS;**27,42,46,64**;Sep 27, 1994
3IN ;
4 D ORM^LA7VHL
5 Q
6 ;
7OBR ;;OBR
8 N LA760,LA76205,LA7629,LA7ACC,LA7CEDT,LA7CSCS,LA7CSNM,LA7CSTY,LA7DCODE,LA7HSITE,LA7I,LA7NCS,LA7OTST,LA7OTSTN,LA7PF1,LA7PF2,LA7RCI,LA7SPCS,LA7SPNM,LA7SPTY,LA7USID,LA7X,LA7Y,RTST,RTSTN
9 ;
10 ; OBR Set ID
11 S LA7SOBR=$$P^LA7VHLU(.LA7SEG,2,LA7FS)
12 ;
13 ; Placer order number
14 S LA7SID=$$P^LA7VHLU(.LA7SEG,3,LA7FS)
15 ;
16 ; Universal service ID
17 S LA7USID=$$P^LA7VHLU(.LA7SEG,5,LA7FS)
18 S LA7OTSTN=$P(LA7USID,LA7CS)
19 I LA7OTSTN="" D Q
20 . N LA7X
21 . S LA7X="PID-"_LA7SPID_"/OBR-"_LA7SOBR
22 . D CREATE^LA7LOG(26)
23 ;
24 S LA7OTST=$$UNESC^LA7VHLU3($P(LA7USID,LA7CS,2),LA7FS_LA7ECH)
25 S LA7NCS=$P(LA7USID,LA7CS,3) ; Name of coding system
26 S RTSTN=$P(LA7USID,LA7CS,4)
27 S RTST=$$UNESC^LA7VHLU3($P(LA7USID,LA7CS,5),LA7FS_LA7ECH)
28 ;
29 ; No ORC segment
30 I LA7SEQ<20 D Q
31 . D CREATE^LA7LOG(29)
32 ;
33 ; Missing patient name
34 I $G(LA7PNM)="" D Q
35 . D CREATE^LA7LOG(30)
36 ;
37 ; Non-VA system, not using NLT codes/file #60 tests
38 I LA7NCS'="99VA64" D
39 . I RTSTN="" S RTSTN=LA7OTST
40 . I RTST="" S RTST=LA7OTSTN
41 ;
42 ; Specimen collection date/time
43 S LA7CDT=$$HL7TFM^XLFDT($P($$P^LA7VHLU(.LA7SEG,8,LA7FS),LA7CS),"L")
44 ;
45 ; Specimen end collection date/time (timed collection)
46 S LA7CEDT=$$HL7TFM^XLFDT($P($$P^LA7VHLU(.LA7SEG,9,LA7FS),LA7CS),"L")
47 ;
48 ; Collection volume
49 S LA7VOL=""
50 S LA7X=$$P^LA7VHLU(.LA7SEG,10,LA7FS)
51 I $L($P(LA7X,LA7CS)) D
52 . S $P(LA7VOL,"^")=$P(LA7X,LA7CS) ; volume
53 . S $P(LA7VOL,"^",2)=$P(LA7X,LA7CS,2) ; volume units
54 . S $P(LA7VOL,"^",3)=$P(LA7X,LA7CS,3) ; volume coding system
55 ;
56 ; Specimen action code
57 S LA7X=$$P^LA7VHLU(.LA7SEG,12,LA7FS),LA7SAC=""
58 I LA7X="A" S LA7SAC="Add ordered tests to the existing specimen"
59 I LA7X="G" S LA7SAC="Generated order; reflex order"
60 ;
61 ; Danger code
62 S LA7X=$P($$P^LA7VHLU(.LA7SEG,13,LA7FS),LA7CS,2)
63 S LA7DCODE=$$UNESC^LA7VHLU3(LA7X,LA7FS_LA7ECH)
64 I LA7DCODE]"" D
65 . S LA7DCODE=$$TRIM^XLFSTR(LA7DCODE,"RL"," ")
66 . S LA7DCODE="Danger Code - "_LA7DCODE
67 ;
68 ; Relevant clinical information
69 S LA7X=$$P^LA7VHLU(.LA7SEG,14,LA7FS)
70 S LA7RCI=$$UNESC^LA7VHLU3(LA7X,LA7FS_LA7ECH)
71 I LA7RCI]"" D
72 . S LA7RCI=$$TRIM^XLFSTR(LA7RCI,"RL"," ")
73 . S LA7RCI="Relevant clinical information - "_LA7RCI
74 ;
75 ; Specimen source - specimen code - name of specimen coding system
76 ; If no primary then try alternate
77 S LA7X=$$P^LA7VHLU(.LA7SEG,16,LA7FS)
78 S LA7SPTY=$P($P(LA7X,LA7CS),$E(LA7ECH,4))
79 S LA7SPNM=$P($P(LA7X,LA7CS),$E(LA7ECH,4),2)
80 S LA7SPCS=$P($P(LA7X,LA7CS),$E(LA7ECH,4),3)
81 I LA7SPTY="" D
82 . S LA7SPTY=$P($P(LA7X,LA7CS),$E(LA7ECH,4),4)
83 . S LA7SPNM=$P($P(LA7X,LA7CS),$E(LA7ECH,4),5)
84 . S LA7SPCS=$P($P(LA7X,LA7CS),$E(LA7ECH,4),6)
85 ;
86 ; Collection sample from body site
87 S LA7CSTY=$P($P(LA7X,LA7CS,4),$E(LA7ECH,4))
88 S LA7CSNM=$P($P(LA7X,LA7CS,4),$E(LA7ECH,4),2)
89 S LA7CSCS=$P($P(LA7X,LA7CS,4),$E(LA7ECH,4),3)
90 ;
91 ; Placer's ordering provider (last name, first name, mi [id])
92 ; Only process if LA7POP from ORC-12 is blank.
93 I LA7POP="" D
94 . S LA7X=$$P^LA7VHLU(.LA7SEG,17,LA7FS)
95 . S LA7POP=$$XCNTFM^LA7VHLU4(LA7X,LA7ECH)
96 . I LA7POP="^^" S LA7POP=""
97 ;
98 ; Specimen urgency
99 S LA7UR=$P($$P^LA7VHLU(.LA7SEG,28,LA7FS),LA7CS,6)
100 ; If no urgency see if it came in ORC-7
101 I LA7UR="" S LA7UR=$G(LA7OUR)
102 ;
103 ; Look for receiving facility in OBR, then use receiving facility from MSH
104 S LA7X=$P($$P^LA7VHLU(.LA7SEG,35,LA7FS),LA7CS,7)
105 S LA7HSITE=$$FINDSITE^LA7VHLU2(LA7X,1,1)
106 I LA7HSITE'>0 S LA7HSITE=$$FINDSITE^LA7VHLU2(LA7RFAC,1,0)
107 ;
108 ; Find an "active" shipping configuration for this pair.
109 S LA7629=0
110 I LA7CSITE,LA7HSITE D
111 . N LA7X
112 . S LA7X=0
113 . F S LA7X=$O(^LAHM(62.9,"CH",LA7CSITE,LA7HSITE,LA7X)) Q:'LA7X I $P($G(^LAHM(62.9,LA7X,0)),"^",4) S LA7629=LA7X Q
114 ; Log error and quit if no active shipping configuration identified
115 I 'LA7629 D Q
116 . D CREATE^LA7LOG(39)
117 ;
118 S LA7Y=$$DTTO^LA7SMU2(LA7629,LA7OTSTN,LA7SPTY,LA7NCS,LA7SPCS,LA7UR,LA7CSTY_"^"_LA7CSNM_"^"_LA7CSCS)
119 S LA760=$P(LA7Y,"^"),LA761=$P(LA7Y,"^",2),LA762=$P(LA7Y,"^",3),LA76205=$P(LA7Y,"^",4)
120 I $P(LA7Y,"^",5)'="" S LA7OTSTN=$P(LA7Y,"^",5),LA7OTST=$P(LA7Y,"^",6)
121 F LA7I=1:1:4 I '$P(LA7Y,"^",LA7I) D
122 . I LA7I=3,LA760,"MISPCYEM"[$P(^LAB(60,LA760,0),"^",4) Q
123 . S LA7X="No local "_$P("lab test^topography^collection sample^urgency","^",LA7I)_" mapped."
124 . N LA7I,LA7Y
125 . D CREATE^LA7LOG(47)
126 ;
127 ; Placer fields 1 & 2
128 S LA7X=$$P^LA7VHLU(.LA7SEG,19,LA7FS)
129 I LA7X'="",LA7X[LA7CS S LA7X=$TR(LA7X,LA7CS,"^")
130 S LA7PF1=$$UNESC^LA7VHLU3(LA7X,LA7FS_LA7ECH)
131 S LA7X=$$P^LA7VHLU(.LA7SEG,20,LA7FS)
132 I LA7X'="",LA7X[LA7CS S LA7X=$TR(LA7X,LA7CS,"^")
133 S LA7PF2=$$UNESC^LA7VHLU3(LA7X,LA7FS_LA7ECH)
134 S LA7ACC=$P(LA7PF2,"^",6)
135 ;
136 ; New order - add to LAB PENDING ORDERS file #69.6
137 I LA7OTYPE="NW" D NW
138 ;
139 Q
140 ;
141NW ; Create new order in LAB PENDING ORDERS file #69.6
142 ;
143 N FDA,I,LA76964,LA7DIE,LA7I,LA7IEN,LA7PATID,LA7SSITE,LA7STAT,LA7WP
144 ;
145 ; Get lock on 69.6
146 L +^LRO(69.6,0):99999
147 I '$T D Q
148 . D CREATE^LA7LOG(31)
149 ;
150 S LA7696=$O(^LRO(69.6,"AD",$S($P(LA7SM,"^",2)'="":$P(LA7SM,"^",2),1:0),LA7SID,0))
151 ;
152 ; Find "In-Transit" status in #64.061
153 S LA7STAT=$$FIND1^DIC(64.061,"","OMX","In-Transit","","I $P(^LAB(64.061,Y,0),U,7)=""U""")
154 ;
155 ; Create entry in LAB PENDING ORDER ENTRY file, log error if not added
156 I $G(LA7696)'>0 D
157 . S FDA(1,69.6,"+1,",.01)=LA7PNM
158 . S FDA(1,69.6,"+1,",6)=LA7STAT
159 . D UPDATE^DIE("","FDA(1)","LA7IEN","LA7DIE(1)")
160 . S LA7696=LA7IEN(1)
161 . I LA7696<1 D CREATE^LA7LOG(32)
162 ;
163 L -^LRO(69.6,0)
164 I LA7696<1 Q
165 ;
166 L +^LRO(69.6,LA7696):99999
167 I '$T D Q ;cannot get lock on ENTRY in 69.6
168 . D CREATE^LA7LOG(33)
169 ;
170 ; Prevent duplication of tests
171 I $D(^LRO(69.6,LA7696,2,"C",LA7OTSTN)) D UNLOCK Q
172 ;
173 ; Determine entry in INSTITUTION file (#4) that's the sending site.
174 S LA7SSITE=$$FINDSITE^LA7VHLU2(LA7SFAC,2,0)
175 ;
176 ; Patient id to store with order
177 S LA7PATID=LA7SSN
178 I LA7PATID="" D
179 . S LA7PATID=$P($G(LA7PTID3(1)),$E(LA7ECH))
180 . I LA7PATID'="" Q
181 . I LA7PTID4'="" S LA7PATID=$P($P(LA7PTID4,$E(LA7ECH,2)),$E(LA7ECH))
182 . I LA7PATID'="" Q
183 . I LA7PTID2'="" S LA7PATID=$P(LA7PTID2,$E(LA7ECH))
184 ;
185 S FDA(2,69.6,LA7696_",",.01)=LA7PNM
186 S FDA(2,69.6,LA7696_",",.02)=LA7SEX
187 S FDA(2,69.6,LA7696_",",.03)=LA7DOB
188 I $G(LA7PRACE)'="" S FDA(2,69.6,LA7696_",",.06)=LA7PRACE
189 S FDA(2,69.6,LA7696_",",.09)=LA7PATID
190 S FDA(2,69.6,LA7696_",",1)=LA7SSITE
191 S FDA(2,69.6,LA7696_",",2)=LA7CSITE
192 S FDA(2,69.6,LA7696_",",3)=LA7SID
193 S FDA(2,69.6,LA7696_",",3.2)=LA7ACC
194 I LA761 S FDA(2,69.6,LA7696_",",4)=LA761
195 I LA762 S FDA(2,69.6,LA7696_",",5)=LA762
196 S FDA(2,69.6,LA7696_",",10)=LA7ORDT
197 S FDA(2,69.6,LA7696_",",11)=LA7CDT
198 S FDA(2,69.6,LA7696_",",11.1)=LA7CEDT
199 S FDA(2,69.6,LA7696_",",14)=LA7MEDT
200 S FDA(2,69.6,LA7696_",",17)=LA7MID
201 I $P(LA7SM,"^",2)'="" S LA7X=$P(LA7SM,"^",2)
202 E S LA7X=LA7SFAC_"-"_$E($$FMTHL7^XLFDT(LA7MEDT),1,8)
203 S FDA(2,69.6,LA7696_",",18)=LA7X
204 S FDA(2,69.6,LA7696_",",700)=LA7FS_LA7ECH
205 I LA7PTID3'="" S FDA(2,69.6,LA7696_",",700.02)=LA7PTID3
206 I LA7PTID4'="" S FDA(2,69.6,LA7696_",",700.04)=LA7PTID4
207 D FILE^DIE("","FDA(2)","LA7DIE(2)")
208 ;
209 ; Add test to order
210 S FDA(3,69.64,"+2,"_LA7696_",",.01)=LA7OTST
211 S FDA(3,69.64,"+2,"_LA7696_",",1)=LA7OTSTN
212 S FDA(3,69.64,"+2,"_LA7696_",",2)=RTST
213 S FDA(3,69.64,"+2,"_LA7696_",",3)=RTSTN
214 S FDA(3,69.64,"+2,"_LA7696_",",4)=LA7UR
215 I LA760 S FDA(3,69.64,"+2,"_LA7696_",",11)=LA760
216 I LA76205 S FDA(3,69.64,"+2,"_LA7696_",",12)=LA76205
217 I $P(LA7POP,"^",3)'="" S FDA(3,69.64,"+2,"_LA7696_",",13)=$P(LA7POP,"^",3)
218 I LA7USID'="" S FDA(3,69.64,"+2,"_LA7696_",",700.04)=LA7USID
219 I LA7PF1'="" S FDA(3,69.64,"+2,"_LA7696_",",700.18)=LA7PF1
220 I LA7PF2'="" S FDA(3,69.64,"+2,"_LA7696_",",700.19)=LA7PF2
221 D UPDATE^DIE("","FDA(3)","LA76964","LA7DIE(3)")
222 ;
223 ; If no test status - set to In-transit.
224 I $G(LA76964(2)),$P($G(^LRO(69.6,LA7696,2,LA76964(2),0)),"^",6)="" D
225 . S FDA(4,69.64,LA76964(2)_","_LA7696_",",5)=LA7STAT
226 . D FILE^DIE("","FDA(4)","LA7DIE(4)")
227 ;
228 ; Check for comments to store with order.
229 ; Begin sections with <space> to avoid FM word wrap.
230 S LA7I=1
231 I 'LA760 S LA7WP(LA7I,0)="For test "_LA7OTST
232 E S LA7WP(LA7I,0)="For test "_$$GET1^DIQ(60,LA760_",",.01)
233 ;
234 I LA7SAC'="" S LA7I=LA7I+1,LA7WP(LA7I,0)=" "_LA7SAC
235 ;
236 I LA7DCODE'="" F I=1:250:$L(LA7DCODE) S LA7I=LA7I+1,LA7WP(LA7I,0)=$S(I=1:" ",1:"")_$E(LA7DCODE,I,I+249)
237 ;
238 I LA7RCI'="" F I=1:250:$L(LA7RCI) S LA7I=LA7I+1,LA7WP(LA7I,0)=$S(I=1:" ",1:"")_$E(LA7RCI,I,I+249)
239 ;
240 I LA760,"MISPCYEM"[$P(^LAB(60,LA760,0),"^",4) D
241 . S LA7I=LA7I+1,LA7WP(LA7I,0)=" Specimen source: "_LA7SPNM_" ["_LA7SPCS_": "_LA7SPTY_"]"
242 . S LA7I=LA7I+1,LA7WP(LA7I,0)=" Collection sample: "_LA7CSNM_" ["_LA7CSCS_": "_LA7CSTY_"]"
243 ;
244 I $O(LA7WP(1)) D WP^DIE(69.6,LA7696_",",99,"A","LA7WP","LA7DIE(99)")
245 ;
246 D CLEAN^DILF
247 D UNLOCK
248 Q
249 ;
250UNLOCK ; unlock entry in file #69.6
251 L -^LRO(69.6,LA7696)
252 Q
Note: See TracBrowser for help on using the repository browser.