source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDVWHLE1.m@ 1141

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

initial load of WorldVistAEHR

File size: 9.2 KB
RevLine 
[613]1SDVWHLE1 ;ENHANCED HL7 TRANSMIT DRIVERS (CONTINUED) FOR SDAPI and MAKE AN APPOINTMENT REQUEST 11/18/06
2 ;;5.3;Scheduling;**502**;Aug 13, 1993 ;Build 14
3 ; Copyright (C) 2007 WorldVistA
4 ;
5 ; This program is free software; you can redistribute it and/or modify
6 ; it under the terms of the GNU General Public License as published by
7 ; the Free Software Foundation; either version 2 of the License, or
8 ; (at your option) any later version.
9 ;
10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU General Public License for more details.
14 ;
15 ; You should have received a copy of the GNU General Public License
16 ; along with this program; if not, write to the Free Software
17 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 ;
19TRNSMKPI(PATIENTN,SSN,SD1,SC,STYP,SDARRAY,OUTIN,MSGCTRL,SDVWNVAI) ;
20 ;;
21 ;;;
22 ;;HL7TRANSMIT DRIVER FOR
23 ; MAKE AN APPOINTMENT AS WITH ANALOGOUS $$EN^VWSDMKPI CALL
24 ;
25 ;
26 ;HOWEVER, DATE/TIMES ARE EXTERNAL FORM,PATIENT SSN OR OTHER LOOKUP ID INSTEAD OF PATIENT DFN
27 ;AND LOCATION (CLINIC) EXTERNAL NAMES INSTEAD OF INTERNAL IEN,
28 ;
29 ;
30 ;;INPUT : MSGCTRL PASSED BY REFERENCE TO RECEIVE THIS BACK AFTER TRANSMITTING
31 ;;THEN;
32 ;
33 ;SSN AS PATIENT SSN OR OTHER UNIQUE PATIENT LOOKUP ID INSTEAD OF DFN (REQUIRED)
34 ; PATIENTN PATIENT NAME (REQUIRED)
35 ;; SD1 APPOINTMENT DATE(EXTERNAL FORMAT)(REQUIRED)
36 ;;; SC CLINIC FOR APPOINTMENT(EXTERNAL FORMAT) (REQUIRED)
37 ;;;; STYP =(REQUIRED)
38 ;;;;; =1 c&p
39 ; =2 10-10
40 ; =3 SCHEDULED APPOINTMENT
41 ; =4 UNSCHEDULED VISIT
42 ; OUTIN= "O" for oupatient or "I" for inpatient
43 ; SDARRAY AS DEFINED BELOW ( WITH DATE/TIMES IN EXTERNAL DATE/TIME FORMAT)
44 ; (PASSED ARRAYS WITH NUMERIC INFO W/O QUOTES AND NON-NUMERIC ENCLOSED WITH QUOTES)
45 ; SDVWNVAI OPTIONAL PASSED ARGUMENT WITH VALUES AS DEFINED BELOW REGARDING ICN CONNECTION
46 ;
47 ;
48 ;;;;;OUTPUT;;;;; Q
49 ;"NEW MESSAGE ERROR"
50 ;; "PID"
51 ; "PV1"
52 ; "PV2"
53 ; "NTE"_INDEX
54 ; "STYP"
55 ; "HOSPLOC"
56 ;
57 ; EXAMPLE AS IF ANALOGOUS CALL MADE AS BELOW:
58 ;
59 ;; N DFN(SSN AND PATIENT NAME INSTEAD),SD1,SC(HOSP LOCATION
60 ;; (CLINIC) EXT FORMAT NAME INSTEAD,STYP,
61 ; N SDARRAY (DATE/TIMES IN EXTERNAL FORMAT),IER
62 ; N SDVWNVAI ; EXIST AS NON-VA RELATED PFSS EVENT MODE
63 ; = "D" DISABLING THE NEED FOR ICN
64 ; = "O" AS OTHER NON-VA ICN SYSTEM ( FUTURE)
65 ; S XQORMUTE = 1 ;SILENT MODE FOR NON-INTERACTIVE MODE W/O WRITE IN XQOR ROUTINES
66 ; S SDVWNVAI = "D" ; NON-VA TESTING HERE WITH DISABLING THE NEED FOR ICN
67 ; S SSN=100001234 ; DFN=1
68 ; S SD1="JAN 23, 2007@09:30"; SD1=3070123.0930
69 ; S SC="RADIOLOGY CLINIC" ; S SC=3
70 ; S STYP=3
71 ; S OUTIN="O" for outpatient clinic
72 ; S SDARRAY("DATE NOW")= "DATE NOW" ; D NOW^%DTC S X2=X\1 S Y=X2 D DD^%DT S SDARRAY("DATE NOW")=Y
73 ; S SDARRAY("APPT TYPE")=9
74 ; S SDARRAY("SCHED_REQ_TYPE")="O"
75 ; S SDARRAY("NEXT APPT IND")=0
76 ; S SDARRAY("FOLLOWUP VISIT INDICATOR")=0 ; 0 FOR NO
77 ; S SDARRAY("DATA ENTRY CLERK")="NEW PERSON NAME" ; DUZ
78 ; ;THEN PARAMETERS CONVERTED TO INTERNAL VALUE
79 ; S IER=$$EN^SDVWMKPI(DFN,SD1,SC,STYP,.SDARRAY)
80 ;
81 ;
82 ; SDARRAY ELEMENT DEFINITIONS FOLLOW:
83 ;
84 ;
85 ;
86 ;
87 ; SDARRAY("DATE NOW") (REQ AT TIME REQUEST MADE)
88 ;
89 ; SDARRAY("LAB DATE TIME ASSOCIATED") =
90 ; "" OR DATE/TIME (OPTIONAL)
91 ;
92 ; SDARRAY("X-RAY DATE TIME ASSOCIATED") =
93 ; "" OR DATE/TIME (OPTIONAL)
94 ;
95 ; SDARRAY("EKG DATE TIME ASSOCIATED") =
96 ; "" OR DATE/TIME (OPTIONAL)
97 ;
98 ; SDARRAY("APPT TYPE") = 9 (REQUIRED)
99 ; 9 for REGULAR APPOINTMENT TYPE
100 ; ptr 409.1
101 ; SDARRAY("APPT SUB-CATEGORY") = "0" (NOT USED)
102 ; "0" for none
103 ; ptr 35.2
104 ;
105 ;; SDARRAY("SCHED_REQ_TYPE")='O' (REQUIRED)
106 ; 'O' FOR OTHER THAN 'NEXT AVA.' APPT.;
107 ; set of codes
108 ; SDARRAY("NEXT APPT IND")=0 (REQUIRED)
109 ; 0 FOR NO
110 ; SDARRAY("DESIRED DATE TIME OF APPT")=SD (OPTIONAL)
111 ; SDARRAY("FOLLOWUP VISIT INDICATOR")= (REQUIRED)
112 ; "0" FOR NO
113 ; "1" FOR YES
114 ;
115 ;
116 ;
117 ; SDARRAY("X RAY DATA FREE TEXT")= (OPTIONAL)
118 ; SDARRAY("OTHER DATA FREE TEXT")= (OPTIONAL)
119 ; SDARRAY("OTHER WARD LOCATION")= (OPTIONAL)
120 ;
121 ;
122 ; SDARRAY("DATA ENTRY CLERK")= (REQUIRED)
123 ; DUZ OF NEW PERSON (FILE 200) PTR
124 ;
125 ; SDARRAY("PRIOR XRAY RESULTS TO CLINIC")= (OPTIONAL)
126 ; "Y" OR ""
127 ;
128 ;
129 ; SDARRAY("CHECKED-IN DATE")= (OPTIONAL)
130 ; "" OR DATE APPOINTMENT MADE
131 ; FOR AN UNSCHEDULED VISIT
132 ;
133 ; VWSDNVAI ; (OPTIONAL) EXIST AS NON-VA RELATED PFSS EVENT MODE
134 ; = "D" DISABLING THE NEED FOR ICN
135 ; = "O" AS OTHER NON-VA ICN SYSTEM ( FUTURE)
136 ;
137 ;
138 N APPARMS,HLSTATS,ERROR,SEG,WHO
139 N HLMSTATE,ERROR,INDEX,CONSTRUC,IFLAG,ERR
140 N X,INTE,HOSPLOC,Y
141 ;
142 ;
143 ;;BUILD PARAMETERS
144 S APPARMS("COUNTRY")="USA"
145 S APPARMS("FIELD SEPARATOR")="|"
146 S APPARMS("ENCODING CHARACTERS")="^~\&"
147 S APPARMS("VERSION")=2.4
148 S APPARMS("MESSAGE TYPE")="ADT"
149 S APPARMS("EVENT")="A08" ; PATIENT UPDATE
150 S ERR=""
151 S ERROR=""
152 ;
153 ;;CREATE NEW MESSAGE
154 ;;
155 I '$$NEWMSG^HLOAPI(.APPARMS,.HLMSTATE,.ERROR) Q "NEW MESSAGE ERROR"
156 ;
157 ;
158 ;Use message control ID in MSH segment for sync flag
159 ;
160 ;
161 ;CREATE SEGMENT
162 D SET^HLOAPI(.SEG,"PID",0)
163 D SET^HLOAPI(.SEG,SSN,3)
164 D SET^HLOAPI(.SEG,PATIENTN,5)
165 D SET^HLOAPI(.SEG,SSN,19)
166 ;
167 ;; ADD SEGMENT
168 I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"PID"
169 ;
170 ;
171 ;
172 ;;CREATE SEGMENT
173 ;
174 D SET^HLOAPI(.SEG,"PV1",0)
175 D SET^HLOAPI(.SEG,OUTIN,2) ;"O" or "I" oupatient or inpatient
176 ;D SET^HLOAPI(.SEG,IEN,3) ;HOSP LOC IEN NOT AVAILABLE
177 D SET^HLOAPI(.SEG,SDARRAY("APPT TYPE"),4) ;ADMISSION TYPE (APPOINTMENT TYPE)
178 D SET^HLOAPI(.SEG,STYP,10) ; HOSPITAL SERVICE (PURPOSE OF VISIT)
179 ;CONVERT EXTERNAL DATE/TIME TO FM INTERNAL, THEN TO HL7
180 S X=SD1 S %DT="T" D ^%DT S INTE=Y ;EXT TO FM INTERNAL
181 ;
182 D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),44) ; DATE/TIME TO MAKE APPT
183 ;
184 ;; ADD SEGMENT
185 ;;
186 ;TEMP BELOW;
187 ;S X=$P(SDARRAY(1),";",1) D ^%DT S INTE=Y ;EXT TO FM INTERNAL
188 ;D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),2) ;WHEN START DATE
189 ;;
190 I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"PV1"
191 ;
192 ;
193 ;CREATE SEGMENT
194 ;
195 D SET^HLOAPI(.SEG,"PV2",0)
196 I $D(SDARRAY("DESIRED DATE TIME OF APPT"))>0 D
197 .S X=SDARRAY("DESIRED DATE TIME OF APPT") S %DT="T" D ^%DT S INTE=Y ;EXT TO FM INTERNAL
198 .D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),8) ;EXPECTED(DESIRED) DATE/TIME OF VISIT
199 E D
200 .S X=SD1 S %DT="T" D ^%DT S INTE=Y ;EXT TO FM INTERNAL
201 .D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),8) ;EXPECTED(DESIRED) DATE/TIME OF VISIT
202 S X=SDARRAY("DATE NOW") D ^%DT S INTE=Y\1 ;EXT TO FM INTERNAL
203 D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),46) ;EXPECTED(DESIRED) DATE/TIME OF VISIT
204 ;
205 ;ADD SEGMENT TO MESSAGE
206 ;
207 I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"PV2"
208 ;
209 ;
210 ;
211 ;CREATE NTE SEGMENT FOR STYP
212 ;
213 D SET^HLOAPI(.SEG,"NTE",0)
214 D SET^HLOAPI(.SEG,"STYP="_STYP,3)
215 ;
216 ;; ADD SEGMENT
217 ;
218 I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"STYP"
219 ;
220 ;
221 ;
222 ;
223 ;
224 ;CREATE NTE SEGMENT FOR SC HOSPITAL LOCATION (CLINIC)
225 ;
226 D SET^HLOAPI(.SEG,"NTE",0)
227 D SET^HLOAPI(.SEG,"SDLOCATE="_""""_SC_"""",3)
228 ;
229 ;; ADD SEGMENT
230 ;
231 I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"HOSPLOC"
232 ;
233 ;
234 ;
235 ;
236 ;CREATE NTE SEGMENTS FROM SDARRAY ELEMENTS
237 S INDEX=0
238 F S INDEX=$O(SDARRAY(INDEX)) Q:INDEX="" D
239 .D SET^HLOAPI(.SEG,"NTE",0)
240 .I INDEX=+INDEX S CONSTRUC="SDARRAY("_INDEX_")="
241 .I INDEX'=+INDEX S CONSTRUC="SDARRAY("_""""_INDEX_""""_")="
242 .I SDARRAY(INDEX)=+SDARRAY(INDEX) S CONSTRUC=CONSTRUC_SDARRAY(INDEX)
243 .I SDARRAY(INDEX)'=+SDARRAY(INDEX) S CONSTRUC=CONSTRUC_""""_SDARRAY(INDEX)_""""
244 .D SET^HLOAPI(.SEG,CONSTRUC,3) ; COMMENTS STORING SDARRAY(?)ARRAY ELEMENT
245 .;
246 .;ADD SEGMENT TO MESSAGE
247 .;
248 .S IFLAG=0
249 .I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S IFLAG="NTE"_INDEX
250 .;
251 .I IFLAG'=0 Q
252 I IFLAG'=0 Q IFLAG
253 ;
254 ; NOW OPTIONAL NTE SEGMENT IF SDVWNVAI IS DEFINED
255 ;
256 I $D(SDVWNVAI) D
257 .;
258 .;CREATE NTE SEGMENT FOR SDVWNVAI
259 .;
260 .D SET^HLOAPI(.SEG,"NTE",0)
261 .D SET^HLOAPI(.SEG,"SDVWNVAI="_SDVWNVAI,3)
262 .;
263 .;; ADD SEGMENT
264 .;
265 .I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"SDVWNVAI"
266 .;
267 .;
268 .;
269 ;
270 ; DEFINE SENDING AND RECEIVING PARAMETERS
271 S APPARMS("SENDING APPLICATION")="VWSD HLO EXT"
272 S APPARMS("ACCEPT ACK TYPE")="NE" ;"AL" ;"NE" ;"AL"
273 ;S APPARMS("APP ACK RESPONSE")="APPACKRR^SDVWHLEX"
274 ;S APPARMS("ACCEPT ACK RESPONSE")="MSGPROC^SDVWHLEX"
275 ;REVERSE BELOW
276 S APPARMS("ACCEPT ACK RESPONSE")="APPACKRR^SDVWHLEX" ; WHEN COMIT ACK , SU OR AE RETURN MADE
277 S APPARMS("APP ACK RESPONSE")="MSGPROC^SDVWHLEX" ; WHEN NO ACK RETURN MADE
278 S APPARMS("APP ACK TYPE")="NE" ;"AL" ;"NE" ;"AL"
279 S WHO("RECEIVING APPLICATION")="VWSD RECEIVER"
280 S WHO("FACILITY LINK NAME")="VWSDTSMML"
281 ;
282 ;SEND MESSAGE
283 ;
284 I '$$SENDONE^HLOAPI1(.HLMSTATE,.APPARMS,.WHO,.ERROR) Q "ERR="_ERR_" ERROR="_ERROR
285 S MSGCTRL=HLMSTATE("HDR","MESSAGE CONTROL ID") ;HLMSTATE("ID")
286 Q "OK"
Note: See TracBrowser for help on using the repository browser.