MHV7T ;WAS/GPM - HL7 TRANSMITTER ; 10/25/05 4:10pm [12/24/07 9:45pm]
;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
;;Per VHA Directive 2004-038, this routine should not be modified.
;
Q
;
XMIT(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
; Builds and sends the desired HL7 message based on the mode and
; builder passed in XMT. If the builder requires other information
; to build the message, it can be passed as additional subscripts of
; XMT or REQ. REQ is used for request or query related parameters,
; XMT for transmission and control related parameters.
;
; The message builder sent in XMT("BUILDER") is called to build the
; desired message.
;
; A synchronous response is indicated by XMT("MODE") of S, and sent
; on the current interface as an original mode acknowledgement.
;
; An asynchronous response is indicated by XMT("MODE") of A, and
; sent on the interface associated with XMT("PROTOCOL") as an
; enhanced mode application acknowledgement. Large messages can be
; sent as a bolus (series of messages without batch formatting) by
; specifying an XMT("MAX SIZE").
;
; A message may be initiated by using the asynchronous mode settings
; Synchronous messages cannot be initiated with this API.
;
; Integration Agreements:
; 2161 : INIT^HLFNC2
; 2164 : GENERATE^HLMA
; 2165 : GENACK^HLMA1
;
; Input:
; REQ - Request parameters and Message ID of original message
; XMT - Transmission parameters
; XMT("MODE") - Mode of the transmission
; XMT("PROTOCOL") - Protocol for deferred transmissions
; XMT("BUILDER") - Name/tag of message builder routine
; XMT("HLMTIENS") - Original message IEN - Immediate mode
; XMT("MAX SIZE") - Maximum message size (asynch only)
; ERR - Caret delimited error string
; segment^sequence^field^code^ACK type^error text
; DATAROOT - Global root of data array
; HL - HL7 package array variable
;
; Output: HL7 Message Transmitted
;
N MSGROOT,HLRSLT,HLP,MSGLEN
D LOG^MHVUL2("TRANSMIT","BEGIN","S","TRACE")
I XMT("MODE")="A" D ;Asynchronous mode
. D LOG^MHVUL2("TRANSMIT","ASYNCHRONOUS","S","TRACE")
. K HL
. D INIT^HLFNC2(XMT("PROTOCOL"),.HL)
. I $G(HL) S ERR=HL D LOG^MHVUL2("PROTOCOL INIT FAILURE",ERR,"S","ERROR") Q
. D LOG^MHVUL2("PROTOCOL INIT","DONE "_XMT("MODE"),"S","DEBUG")
. S MSGROOT="^TMP(""HLS"",$J)"
. D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
. D LOG^MHVUL2("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
. I MSGLEN<XMT("MAX SIZE")!'XMT("MAX SIZE") D Q
. . D GENERATE^HLMA(XMT("PROTOCOL"),"GM",1,.HLRSLT,"",.HLP)
. . K @MSGROOT
. . D LOG^MHVUL2("TRANSMIT "_$P(XMT("BUILDER"),"^"),.HLRSLT,"M","DEBUG")
. . Q
. D BOLUS^MHV7TB(MSGROOT,.XMT,.HL)
. Q
;
I XMT("MODE")="S" D ;Synchronous mode
. D LOG^MHVUL2("TRANSMIT","SYNCHRONOUS","S",0)
. S MSGROOT="^TMP(""HLA"",$J)"
. D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
. D LOG^MHVUL2("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
. D GENACK^HLMA1(HL("EID"),XMT("HLMTIENS"),HL("EIDS"),"GM",1,.HLRSLT)
. K @MSGROOT
. D LOG^MHVUL2("TRANSMIT "_$P(XMT("BUILDER"),"^"),.HLRSLT,"M","DEBUG")
. Q
D LOG^MHVUL2("TRANSMIT","END","S","TRACE")
Q
;
EMAIL(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
; Builds and sends the desired HL7 message via email.
; This will only be used until the MHV server can establish normal
; HL7 receivers.
;
; If the builder requires other information to build the message, it
; can be passed as additional subscripts of XMT or REQ. REQ is used
; for request or query related parameters, XMT for transmission and
; control related parameters.
;
; The message builder sent in XMT("BUILDER") is called to build the
; desired message.
;
; Integration Agreements:
; 2161 : INIT^HLFNC2
; MSH^HLFNC2
; 10070 : ^XMD
;
; Input:
; REQ - Request parameters and Message ID of original message
; XMT - Transmission parameters
; XMT("PROTOCOL") - Protocol for deferred transmissions
; XMT("BUILDER") - Name/tag of message builder routine
; XMT("SAF") - Sending Facility
; XMT("EMAIL") - Email Address to use
; ERR - Caret delimited error string
; segment^sequence^field^code^ACK type^error text
; DATAROOT - Global root of data array
; HL - HL7 package array variable
;
; Output: HL7 Message Transmitted
;
N MSGROOT,MID,MSH,CNT,MSGLEN
N TEXT,XMDUN,XMDUZ,XMTEXT,XMROU,XMSTRIP,XMSUB,XMY,XMZ,XMDF,XMMG
D LOG^MHVUL2("TRANSMIT","EMAIL","S","TRACE")
K HL
D INIT^HLFNC2(XMT("PROTOCOL"),.HL)
I $G(HL) S ERR=HL D LOG^MHVUL2("PROTOCOL INIT FAIL",ERR,"S","ERROR") Q
D LOG^MHVUL2("PROTOCOL INIT","DONE EMAIL","S","DEBUG")
S MSGROOT="^TMP(""MHV7TEM"",$J)"
D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
D LOG^MHVUL2("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
S MID=+$H_"-"_$P($H,",",2)
S HL("SAF")=XMT("SAF")
D MSH^HLFNC2(.HL,MID,.MSH)
S XMDF="",(XMDUN,XMDUZ)="My HealtheVet Package"
S XMY(XMT("EMAIL"))=""
S XMSUB=XMT("SAF")_" MHV PACKAGE MESSAGE"
S XMTEXT="TEXT("
S TEXT(1)=MSH
F CNT=1:1 Q:'$D(@MSGROOT@(CNT)) S TEXT(CNT+1)=@MSGROOT@(CNT)
D ^XMD
K @MSGROOT
I $D(XMMG) D LOG^MHVUL2("EMAIL TRANSMIT","FAILURE: "_XMMG,"S","ERROR") Q
D LOG^MHVUL2("EMAIL TRANSMIT","SUCCESS: "_XMZ,"S","TRACE")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMHV7T 5645 printed Dec 13, 2024@02:16:01 Page 2
MHV7T ;WAS/GPM - HL7 TRANSMITTER ; 10/25/05 4:10pm [12/24/07 9:45pm]
+1 ;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;
XMIT(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
+1 ; Builds and sends the desired HL7 message based on the mode and
+2 ; builder passed in XMT. If the builder requires other information
+3 ; to build the message, it can be passed as additional subscripts of
+4 ; XMT or REQ. REQ is used for request or query related parameters,
+5 ; XMT for transmission and control related parameters.
+6 ;
+7 ; The message builder sent in XMT("BUILDER") is called to build the
+8 ; desired message.
+9 ;
+10 ; A synchronous response is indicated by XMT("MODE") of S, and sent
+11 ; on the current interface as an original mode acknowledgement.
+12 ;
+13 ; An asynchronous response is indicated by XMT("MODE") of A, and
+14 ; sent on the interface associated with XMT("PROTOCOL") as an
+15 ; enhanced mode application acknowledgement. Large messages can be
+16 ; sent as a bolus (series of messages without batch formatting) by
+17 ; specifying an XMT("MAX SIZE").
+18 ;
+19 ; A message may be initiated by using the asynchronous mode settings
+20 ; Synchronous messages cannot be initiated with this API.
+21 ;
+22 ; Integration Agreements:
+23 ; 2161 : INIT^HLFNC2
+24 ; 2164 : GENERATE^HLMA
+25 ; 2165 : GENACK^HLMA1
+26 ;
+27 ; Input:
+28 ; REQ - Request parameters and Message ID of original message
+29 ; XMT - Transmission parameters
+30 ; XMT("MODE") - Mode of the transmission
+31 ; XMT("PROTOCOL") - Protocol for deferred transmissions
+32 ; XMT("BUILDER") - Name/tag of message builder routine
+33 ; XMT("HLMTIENS") - Original message IEN - Immediate mode
+34 ; XMT("MAX SIZE") - Maximum message size (asynch only)
+35 ; ERR - Caret delimited error string
+36 ; segment^sequence^field^code^ACK type^error text
+37 ; DATAROOT - Global root of data array
+38 ; HL - HL7 package array variable
+39 ;
+40 ; Output: HL7 Message Transmitted
+41 ;
+42 NEW MSGROOT,HLRSLT,HLP,MSGLEN
+43 DO LOG^MHVUL2("TRANSMIT","BEGIN","S","TRACE")
+44 ;Asynchronous mode
IF XMT("MODE")="A"
Begin DoDot:1
+45 DO LOG^MHVUL2("TRANSMIT","ASYNCHRONOUS","S","TRACE")
+46 KILL HL
+47 DO INIT^HLFNC2(XMT("PROTOCOL"),.HL)
+48 IF $GET(HL)
SET ERR=HL
DO LOG^MHVUL2("PROTOCOL INIT FAILURE",ERR,"S","ERROR")
QUIT
+49 DO LOG^MHVUL2("PROTOCOL INIT","DONE "_XMT("MODE"),"S","DEBUG")
+50 SET MSGROOT="^TMP(""HLS"",$J)"
+51 DO @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
+52 DO LOG^MHVUL2("BUILD "_$PIECE(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
+53 IF MSGLEN<XMT("MAX SIZE")!'XMT("MAX SIZE")
Begin DoDot:2
+54 DO GENERATE^HLMA(XMT("PROTOCOL"),"GM",1,.HLRSLT,"",.HLP)
+55 KILL @MSGROOT
+56 DO LOG^MHVUL2("TRANSMIT "_$PIECE(XMT("BUILDER"),"^"),.HLRSLT,"M","DEBUG")
+57 QUIT
End DoDot:2
QUIT
+58 DO BOLUS^MHV7TB(MSGROOT,.XMT,.HL)
+59 QUIT
End DoDot:1
+60 ;
+61 ;Synchronous mode
IF XMT("MODE")="S"
Begin DoDot:1
+62 DO LOG^MHVUL2("TRANSMIT","SYNCHRONOUS","S",0)
+63 SET MSGROOT="^TMP(""HLA"",$J)"
+64 DO @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
+65 DO LOG^MHVUL2("BUILD "_$PIECE(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
+66 DO GENACK^HLMA1(HL("EID"),XMT("HLMTIENS"),HL("EIDS"),"GM",1,.HLRSLT)
+67 KILL @MSGROOT
+68 DO LOG^MHVUL2("TRANSMIT "_$PIECE(XMT("BUILDER"),"^"),.HLRSLT,"M","DEBUG")
+69 QUIT
End DoDot:1
+70 DO LOG^MHVUL2("TRANSMIT","END","S","TRACE")
+71 QUIT
+72 ;
EMAIL(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
+1 ; Builds and sends the desired HL7 message via email.
+2 ; This will only be used until the MHV server can establish normal
+3 ; HL7 receivers.
+4 ;
+5 ; If the builder requires other information to build the message, it
+6 ; can be passed as additional subscripts of XMT or REQ. REQ is used
+7 ; for request or query related parameters, XMT for transmission and
+8 ; control related parameters.
+9 ;
+10 ; The message builder sent in XMT("BUILDER") is called to build the
+11 ; desired message.
+12 ;
+13 ; Integration Agreements:
+14 ; 2161 : INIT^HLFNC2
+15 ; MSH^HLFNC2
+16 ; 10070 : ^XMD
+17 ;
+18 ; Input:
+19 ; REQ - Request parameters and Message ID of original message
+20 ; XMT - Transmission parameters
+21 ; XMT("PROTOCOL") - Protocol for deferred transmissions
+22 ; XMT("BUILDER") - Name/tag of message builder routine
+23 ; XMT("SAF") - Sending Facility
+24 ; XMT("EMAIL") - Email Address to use
+25 ; ERR - Caret delimited error string
+26 ; segment^sequence^field^code^ACK type^error text
+27 ; DATAROOT - Global root of data array
+28 ; HL - HL7 package array variable
+29 ;
+30 ; Output: HL7 Message Transmitted
+31 ;
+32 NEW MSGROOT,MID,MSH,CNT,MSGLEN
+33 NEW TEXT,XMDUN,XMDUZ,XMTEXT,XMROU,XMSTRIP,XMSUB,XMY,XMZ,XMDF,XMMG
+34 DO LOG^MHVUL2("TRANSMIT","EMAIL","S","TRACE")
+35 KILL HL
+36 DO INIT^HLFNC2(XMT("PROTOCOL"),.HL)
+37 IF $GET(HL)
SET ERR=HL
DO LOG^MHVUL2("PROTOCOL INIT FAIL",ERR,"S","ERROR")
QUIT
+38 DO LOG^MHVUL2("PROTOCOL INIT","DONE EMAIL","S","DEBUG")
+39 SET MSGROOT="^TMP(""MHV7TEM"",$J)"
+40 DO @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
+41 DO LOG^MHVUL2("BUILD "_$PIECE(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
+42 SET MID=+$HOROLOG_"-"_$PIECE($HOROLOG,",",2)
+43 SET HL("SAF")=XMT("SAF")
+44 DO MSH^HLFNC2(.HL,MID,.MSH)
+45 SET XMDF=""
SET (XMDUN,XMDUZ)="My HealtheVet Package"
+46 SET XMY(XMT("EMAIL"))=""
+47 SET XMSUB=XMT("SAF")_" MHV PACKAGE MESSAGE"
+48 SET XMTEXT="TEXT("
+49 SET TEXT(1)=MSH
+50 FOR CNT=1:1
if '$DATA(@MSGROOT@(CNT))
QUIT
SET TEXT(CNT+1)=@MSGROOT@(CNT)
+51 DO ^XMD
+52 KILL @MSGROOT
+53 IF $DATA(XMMG)
DO LOG^MHVUL2("EMAIL TRANSMIT","FAILURE: "_XMMG,"S","ERROR")
QUIT
+54 DO LOG^MHVUL2("EMAIL TRANSMIT","SUCCESS: "_XMZ,"S","TRACE")
+55 QUIT