VistA-WorldVistAEHR/r/SCHEDULING-SD-SC/SDVWHLE1.m

287 lines
9.2 KiB
Mathematica

SDVWHLE1 ;ENHANCED HL7 TRANSMIT DRIVERS (CONTINUED) FOR SDAPI and MAKE AN APPOINTMENT REQUEST 11/18/06
;;5.3;Scheduling;**502**;Aug 13, 1993 ;Build 14
; Copyright (C) 2007 WorldVistA
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
;
TRNSMKPI(PATIENTN,SSN,SD1,SC,STYP,SDARRAY,OUTIN,MSGCTRL,SDVWNVAI) ;
;;
;;;
;;HL7TRANSMIT DRIVER FOR
; MAKE AN APPOINTMENT AS WITH ANALOGOUS $$EN^VWSDMKPI CALL
;
;
;HOWEVER, DATE/TIMES ARE EXTERNAL FORM,PATIENT SSN OR OTHER LOOKUP ID INSTEAD OF PATIENT DFN
;AND LOCATION (CLINIC) EXTERNAL NAMES INSTEAD OF INTERNAL IEN,
;
;
;;INPUT : MSGCTRL PASSED BY REFERENCE TO RECEIVE THIS BACK AFTER TRANSMITTING
;;THEN;
;
;SSN AS PATIENT SSN OR OTHER UNIQUE PATIENT LOOKUP ID INSTEAD OF DFN (REQUIRED)
; PATIENTN PATIENT NAME (REQUIRED)
;; SD1 APPOINTMENT DATE(EXTERNAL FORMAT)(REQUIRED)
;;; SC CLINIC FOR APPOINTMENT(EXTERNAL FORMAT) (REQUIRED)
;;;; STYP =(REQUIRED)
;;;;; =1 c&p
; =2 10-10
; =3 SCHEDULED APPOINTMENT
; =4 UNSCHEDULED VISIT
; OUTIN= "O" for oupatient or "I" for inpatient
; SDARRAY AS DEFINED BELOW ( WITH DATE/TIMES IN EXTERNAL DATE/TIME FORMAT)
; (PASSED ARRAYS WITH NUMERIC INFO W/O QUOTES AND NON-NUMERIC ENCLOSED WITH QUOTES)
; SDVWNVAI OPTIONAL PASSED ARGUMENT WITH VALUES AS DEFINED BELOW REGARDING ICN CONNECTION
;
;
;;;;;OUTPUT;;;;; Q
;"NEW MESSAGE ERROR"
;; "PID"
; "PV1"
; "PV2"
; "NTE"_INDEX
; "STYP"
; "HOSPLOC"
;
; EXAMPLE AS IF ANALOGOUS CALL MADE AS BELOW:
;
;; N DFN(SSN AND PATIENT NAME INSTEAD),SD1,SC(HOSP LOCATION
;; (CLINIC) EXT FORMAT NAME INSTEAD,STYP,
; N SDARRAY (DATE/TIMES IN EXTERNAL FORMAT),IER
; N SDVWNVAI ; EXIST AS NON-VA RELATED PFSS EVENT MODE
; = "D" DISABLING THE NEED FOR ICN
; = "O" AS OTHER NON-VA ICN SYSTEM ( FUTURE)
; S XQORMUTE = 1 ;SILENT MODE FOR NON-INTERACTIVE MODE W/O WRITE IN XQOR ROUTINES
; S SDVWNVAI = "D" ; NON-VA TESTING HERE WITH DISABLING THE NEED FOR ICN
; S SSN=100001234 ; DFN=1
; S SD1="JAN 23, 2007@09:30"; SD1=3070123.0930
; S SC="RADIOLOGY CLINIC" ; S SC=3
; S STYP=3
; S OUTIN="O" for outpatient clinic
; S SDARRAY("DATE NOW")= "DATE NOW" ; D NOW^%DTC S X2=X\1 S Y=X2 D DD^%DT S SDARRAY("DATE NOW")=Y
; S SDARRAY("APPT TYPE")=9
; S SDARRAY("SCHED_REQ_TYPE")="O"
; S SDARRAY("NEXT APPT IND")=0
; S SDARRAY("FOLLOWUP VISIT INDICATOR")=0 ; 0 FOR NO
; S SDARRAY("DATA ENTRY CLERK")="NEW PERSON NAME" ; DUZ
; ;THEN PARAMETERS CONVERTED TO INTERNAL VALUE
; S IER=$$EN^SDVWMKPI(DFN,SD1,SC,STYP,.SDARRAY)
;
;
; SDARRAY ELEMENT DEFINITIONS FOLLOW:
;
;
;
;
; SDARRAY("DATE NOW") (REQ AT TIME REQUEST MADE)
;
; SDARRAY("LAB DATE TIME ASSOCIATED") =
; "" OR DATE/TIME (OPTIONAL)
;
; SDARRAY("X-RAY DATE TIME ASSOCIATED") =
; "" OR DATE/TIME (OPTIONAL)
;
; SDARRAY("EKG DATE TIME ASSOCIATED") =
; "" OR DATE/TIME (OPTIONAL)
;
; SDARRAY("APPT TYPE") = 9 (REQUIRED)
; 9 for REGULAR APPOINTMENT TYPE
; ptr 409.1
; SDARRAY("APPT SUB-CATEGORY") = "0" (NOT USED)
; "0" for none
; ptr 35.2
;
;; SDARRAY("SCHED_REQ_TYPE")='O' (REQUIRED)
; 'O' FOR OTHER THAN 'NEXT AVA.' APPT.;
; set of codes
; SDARRAY("NEXT APPT IND")=0 (REQUIRED)
; 0 FOR NO
; SDARRAY("DESIRED DATE TIME OF APPT")=SD (OPTIONAL)
; SDARRAY("FOLLOWUP VISIT INDICATOR")= (REQUIRED)
; "0" FOR NO
; "1" FOR YES
;
;
;
; SDARRAY("X RAY DATA FREE TEXT")= (OPTIONAL)
; SDARRAY("OTHER DATA FREE TEXT")= (OPTIONAL)
; SDARRAY("OTHER WARD LOCATION")= (OPTIONAL)
;
;
; SDARRAY("DATA ENTRY CLERK")= (REQUIRED)
; DUZ OF NEW PERSON (FILE 200) PTR
;
; SDARRAY("PRIOR XRAY RESULTS TO CLINIC")= (OPTIONAL)
; "Y" OR ""
;
;
; SDARRAY("CHECKED-IN DATE")= (OPTIONAL)
; "" OR DATE APPOINTMENT MADE
; FOR AN UNSCHEDULED VISIT
;
; VWSDNVAI ; (OPTIONAL) EXIST AS NON-VA RELATED PFSS EVENT MODE
; = "D" DISABLING THE NEED FOR ICN
; = "O" AS OTHER NON-VA ICN SYSTEM ( FUTURE)
;
;
N APPARMS,HLSTATS,ERROR,SEG,WHO
N HLMSTATE,ERROR,INDEX,CONSTRUC,IFLAG,ERR
N X,INTE,HOSPLOC,Y
;
;
;;BUILD PARAMETERS
S APPARMS("COUNTRY")="USA"
S APPARMS("FIELD SEPARATOR")="|"
S APPARMS("ENCODING CHARACTERS")="^~\&"
S APPARMS("VERSION")=2.4
S APPARMS("MESSAGE TYPE")="ADT"
S APPARMS("EVENT")="A08" ; PATIENT UPDATE
S ERR=""
S ERROR=""
;
;;CREATE NEW MESSAGE
;;
I '$$NEWMSG^HLOAPI(.APPARMS,.HLMSTATE,.ERROR) Q "NEW MESSAGE ERROR"
;
;
;Use message control ID in MSH segment for sync flag
;
;
;CREATE SEGMENT
D SET^HLOAPI(.SEG,"PID",0)
D SET^HLOAPI(.SEG,SSN,3)
D SET^HLOAPI(.SEG,PATIENTN,5)
D SET^HLOAPI(.SEG,SSN,19)
;
;; ADD SEGMENT
I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"PID"
;
;
;
;;CREATE SEGMENT
;
D SET^HLOAPI(.SEG,"PV1",0)
D SET^HLOAPI(.SEG,OUTIN,2) ;"O" or "I" oupatient or inpatient
;D SET^HLOAPI(.SEG,IEN,3) ;HOSP LOC IEN NOT AVAILABLE
D SET^HLOAPI(.SEG,SDARRAY("APPT TYPE"),4) ;ADMISSION TYPE (APPOINTMENT TYPE)
D SET^HLOAPI(.SEG,STYP,10) ; HOSPITAL SERVICE (PURPOSE OF VISIT)
;CONVERT EXTERNAL DATE/TIME TO FM INTERNAL, THEN TO HL7
S X=SD1 S %DT="T" D ^%DT S INTE=Y ;EXT TO FM INTERNAL
;
D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),44) ; DATE/TIME TO MAKE APPT
;
;; ADD SEGMENT
;;
;TEMP BELOW;
;S X=$P(SDARRAY(1),";",1) D ^%DT S INTE=Y ;EXT TO FM INTERNAL
;D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),2) ;WHEN START DATE
;;
I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"PV1"
;
;
;CREATE SEGMENT
;
D SET^HLOAPI(.SEG,"PV2",0)
I $D(SDARRAY("DESIRED DATE TIME OF APPT"))>0 D
.S X=SDARRAY("DESIRED DATE TIME OF APPT") S %DT="T" D ^%DT S INTE=Y ;EXT TO FM INTERNAL
.D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),8) ;EXPECTED(DESIRED) DATE/TIME OF VISIT
E D
.S X=SD1 S %DT="T" D ^%DT S INTE=Y ;EXT TO FM INTERNAL
.D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),8) ;EXPECTED(DESIRED) DATE/TIME OF VISIT
S X=SDARRAY("DATE NOW") D ^%DT S INTE=Y\1 ;EXT TO FM INTERNAL
D SET^HLOAPI(.SEG,$$HLDATE^HLFNC(INTE,"TS"),46) ;EXPECTED(DESIRED) DATE/TIME OF VISIT
;
;ADD SEGMENT TO MESSAGE
;
I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"PV2"
;
;
;
;CREATE NTE SEGMENT FOR STYP
;
D SET^HLOAPI(.SEG,"NTE",0)
D SET^HLOAPI(.SEG,"STYP="_STYP,3)
;
;; ADD SEGMENT
;
I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"STYP"
;
;
;
;
;
;CREATE NTE SEGMENT FOR SC HOSPITAL LOCATION (CLINIC)
;
D SET^HLOAPI(.SEG,"NTE",0)
D SET^HLOAPI(.SEG,"SDLOCATE="_""""_SC_"""",3)
;
;; ADD SEGMENT
;
I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"HOSPLOC"
;
;
;
;
;CREATE NTE SEGMENTS FROM SDARRAY ELEMENTS
S INDEX=0
F S INDEX=$O(SDARRAY(INDEX)) Q:INDEX="" D
.D SET^HLOAPI(.SEG,"NTE",0)
.I INDEX=+INDEX S CONSTRUC="SDARRAY("_INDEX_")="
.I INDEX'=+INDEX S CONSTRUC="SDARRAY("_""""_INDEX_""""_")="
.I SDARRAY(INDEX)=+SDARRAY(INDEX) S CONSTRUC=CONSTRUC_SDARRAY(INDEX)
.I SDARRAY(INDEX)'=+SDARRAY(INDEX) S CONSTRUC=CONSTRUC_""""_SDARRAY(INDEX)_""""
.D SET^HLOAPI(.SEG,CONSTRUC,3) ; COMMENTS STORING SDARRAY(?)ARRAY ELEMENT
.;
.;ADD SEGMENT TO MESSAGE
.;
.S IFLAG=0
.I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S IFLAG="NTE"_INDEX
.;
.I IFLAG'=0 Q
I IFLAG'=0 Q IFLAG
;
; NOW OPTIONAL NTE SEGMENT IF SDVWNVAI IS DEFINED
;
I $D(SDVWNVAI) D
.;
.;CREATE NTE SEGMENT FOR SDVWNVAI
.;
.D SET^HLOAPI(.SEG,"NTE",0)
.D SET^HLOAPI(.SEG,"SDVWNVAI="_SDVWNVAI,3)
.;
.;; ADD SEGMENT
.;
.I '$$ADDSEG^HLOAPI(.HLMSTATE,.SEG) S ERR=ERR_"^"_"SDVWNVAI"
.;
.;
.;
;
; DEFINE SENDING AND RECEIVING PARAMETERS
S APPARMS("SENDING APPLICATION")="VWSD HLO EXT"
S APPARMS("ACCEPT ACK TYPE")="NE" ;"AL" ;"NE" ;"AL"
;S APPARMS("APP ACK RESPONSE")="APPACKRR^SDVWHLEX"
;S APPARMS("ACCEPT ACK RESPONSE")="MSGPROC^SDVWHLEX"
;REVERSE BELOW
S APPARMS("ACCEPT ACK RESPONSE")="APPACKRR^SDVWHLEX" ; WHEN COMIT ACK , SU OR AE RETURN MADE
S APPARMS("APP ACK RESPONSE")="MSGPROC^SDVWHLEX" ; WHEN NO ACK RETURN MADE
S APPARMS("APP ACK TYPE")="NE" ;"AL" ;"NE" ;"AL"
S WHO("RECEIVING APPLICATION")="VWSD RECEIVER"
S WHO("FACILITY LINK NAME")="VWSDTSMML"
;
;SEND MESSAGE
;
I '$$SENDONE^HLOAPI1(.HLMSTATE,.APPARMS,.WHO,.ERROR) Q "ERR="_ERR_" ERROR="_ERROR
S MSGCTRL=HLMSTATE("HDR","MESSAGE CONTROL ID") ;HLMSTATE("ID")
Q "OK"