| 1 | MHV7T ;WAS/GPM - HL7 TRANSMITTER ; [8/22/05 11:54pm]
|
---|
| 2 | ;;1.0;My HealtheVet;;Aug 23, 2005
|
---|
| 3 | ;;Per VHA Directive 2004-038, this routine should not be modified.
|
---|
| 4 | ;
|
---|
| 5 | Q
|
---|
| 6 | ;
|
---|
| 7 | XMIT(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
|
---|
| 8 | ; Builds and sends the desired HL7 message based on the mode and
|
---|
| 9 | ; builder passed in XMT. If the builder requires other information
|
---|
| 10 | ; to build the message, it can be passed as additional subscripts of
|
---|
| 11 | ; XMT or REQ. REQ is used for request or query related parameters,
|
---|
| 12 | ; XMT for transmission and control related parameters.
|
---|
| 13 | ;
|
---|
| 14 | ; The message builder sent in XMT("BUILDER") is called to build the
|
---|
| 15 | ; desired message.
|
---|
| 16 | ;
|
---|
| 17 | ; An immediate mode response is indicated by XMT("MODE") of I, and
|
---|
| 18 | ; sent on the current interface as an original mode acknowledgement.
|
---|
| 19 | ;
|
---|
| 20 | ; A deferred mode response is indicated by XMT("MODE") of D, and
|
---|
| 21 | ; sent on the interface associated with XMT("PROTOCOL") as an
|
---|
| 22 | ; enhanced mode application acknowledgement.
|
---|
| 23 | ;
|
---|
| 24 | ; A message may be initiated by using the deferred mode settings.
|
---|
| 25 | ; Synchronous messages cannot be initiate with this API.
|
---|
| 26 | ;
|
---|
| 27 | ; Integration Agreements:
|
---|
| 28 | ; 2161 : INIT^HLFNC2
|
---|
| 29 | ; 2164 : GENERATE^HLMA
|
---|
| 30 | ; 2165 : GENACK^HLMA1
|
---|
| 31 | ;
|
---|
| 32 | ; Input:
|
---|
| 33 | ; REQ - Request parameters and Message ID of original message
|
---|
| 34 | ; XMT - Transmission parameters
|
---|
| 35 | ; XMT("MODE") - Priority or mode of the transmission
|
---|
| 36 | ; XMT("PROTOCOL") - Protocol for deferred transmissions
|
---|
| 37 | ; XMT("BUILDER") - Name/tag of message builder routine
|
---|
| 38 | ; XMT("HLMTIENS") - Original message IEN - Immediate mode
|
---|
| 39 | ; ERR - Caret delimited error string
|
---|
| 40 | ; segment^sequence^field^code^ACK type^error text
|
---|
| 41 | ; DATAROOT - Global root of data array
|
---|
| 42 | ; HL - HL7 package array variable
|
---|
| 43 | ;
|
---|
| 44 | ; Output: HL7 Message Transmitted
|
---|
| 45 | ;
|
---|
| 46 | N MSGROOT,HLRSLT,HLP
|
---|
| 47 | I XMT("MODE")="D" D ;Deferred mode
|
---|
| 48 | . D LOG^MHV7U("TRANSMIT","DEFERRED MODE","S",0)
|
---|
| 49 | . K HL
|
---|
| 50 | . D INIT^HLFNC2(XMT("PROTOCOL"),.HL)
|
---|
| 51 | . I $G(HL) S ERR=HL D LOG^MHV7U("PROTOCOL INIT FAIL",ERR,"S",0) Q
|
---|
| 52 | . D LOG^MHV7U("PROTOCOL INIT","DONE "_XMT("MODE"),"S",0)
|
---|
| 53 | . S MSGROOT="^TMP(""HLS"",$J)"
|
---|
| 54 | . D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.HL)")
|
---|
| 55 | . D LOG^MHV7U("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I",0)
|
---|
| 56 | . D GENERATE^HLMA(XMT("PROTOCOL"),"GM",1,.HLRSLT,"",.HLP)
|
---|
| 57 | . K @MSGROOT
|
---|
| 58 | . D LOG^MHV7U("TRANSMIT "_$P(XMT("BUILDER"),"^"),.HLRSLT,"M",0)
|
---|
| 59 | . Q
|
---|
| 60 | ;
|
---|
| 61 | I XMT("MODE")="I" D ;Immediate mode
|
---|
| 62 | . D LOG^MHV7U("TRANSMIT","IMMEDIATE MODE","S",0)
|
---|
| 63 | . S MSGROOT="^TMP(""HLA"",$J)"
|
---|
| 64 | . D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.HL)")
|
---|
| 65 | . D LOG^MHV7U("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I",0)
|
---|
| 66 | . D GENACK^HLMA1(HL("EID"),XMT("HLMTIENS"),HL("EIDS"),"GM",1,.HLRSLT)
|
---|
| 67 | . K @MSGROOT
|
---|
| 68 | . D LOG^MHV7U("TRANSMIT "_$P(XMT("BUILDER"),"^"),.HLRSLT,"M",0)
|
---|
| 69 | . Q
|
---|
| 70 | D LOG^MHV7U("TRANSMIT","COMPLETE","S",0)
|
---|
| 71 | Q
|
---|
| 72 | ;
|
---|
| 73 | EMAIL(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
|
---|
| 74 | ; Builds and sends the desired HL7 message via email.
|
---|
| 75 | ; This will only be used until the MHV server can establish normal
|
---|
| 76 | ; HL7 receivers.
|
---|
| 77 | ;
|
---|
| 78 | ; If the builder requires other information to build the message, it
|
---|
| 79 | ; can be passed as additional subscripts of XMT or REQ. REQ is used
|
---|
| 80 | ; for request or query related parameters, XMT for transmission and
|
---|
| 81 | ; control related parameters.
|
---|
| 82 | ;
|
---|
| 83 | ; The message builder sent in XMT("BUILDER") is called to build the
|
---|
| 84 | ; desired message.
|
---|
| 85 | ;
|
---|
| 86 | ; Integration Agreements:
|
---|
| 87 | ; 2161 : INIT^HLFNC2, MSH^HLFNC2
|
---|
| 88 | ; 10070 : ^XMD
|
---|
| 89 | ;
|
---|
| 90 | ; Input:
|
---|
| 91 | ; REQ - Request parameters and Message ID of original message
|
---|
| 92 | ; XMT - Transmission parameters
|
---|
| 93 | ; XMT("PROTOCOL") - Protocol for deferred transmissions
|
---|
| 94 | ; XMT("BUILDER") - Name/tag of message builder routine
|
---|
| 95 | ; XMT("SAF") - Sending Facility
|
---|
| 96 | ; XMT("EMAIL") - Email Address to use
|
---|
| 97 | ; ERR - Caret delimited error string
|
---|
| 98 | ; segment^sequence^field^code^ACK type^error text
|
---|
| 99 | ; DATAROOT - Global root of data array
|
---|
| 100 | ; HL - HL7 package array variable
|
---|
| 101 | ;
|
---|
| 102 | ; Output: HL7 Message Transmitted
|
---|
| 103 | ;
|
---|
| 104 | N MSGROOT,MID,MSH,CNT
|
---|
| 105 | N TEXT,XMDUN,XMDUZ,XMTEXT,XMROU,XMSTRIP,XMSUB,XMY,XMZ,XMDF,XMMG
|
---|
| 106 | D LOG^MHV7U("TRANSMIT","EMAIL","S",0)
|
---|
| 107 | K HL
|
---|
| 108 | D INIT^HLFNC2(XMT("PROTOCOL"),.HL)
|
---|
| 109 | I $G(HL) S ERR=HL D LOG^MHV7U("PROTOCOL INIT FAIL",ERR,"S",0) Q
|
---|
| 110 | D LOG^MHV7U("PROTOCOL INIT","DONE EMAIL","S",0)
|
---|
| 111 | S MSGROOT="^TMP(""MHV7TEM"",$J)"
|
---|
| 112 | D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.HL)")
|
---|
| 113 | D LOG^MHV7U("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I",0)
|
---|
| 114 | S MID=+$H_"-"_$P($H,",",2)
|
---|
| 115 | S HL("SAF")=XMT("SAF")
|
---|
| 116 | D MSH^HLFNC2(.HL,MID,.MSH)
|
---|
| 117 | S XMDF="",(XMDUN,XMDUZ)="My HealtheVet Package"
|
---|
| 118 | S XMY(XMT("EMAIL"))=""
|
---|
| 119 | S XMSUB=XMT("SAF")_" MHV PACKAGE MESSAGE"
|
---|
| 120 | S XMTEXT="TEXT("
|
---|
| 121 | S TEXT(1)=MSH
|
---|
| 122 | F CNT=1:1 Q:'$D(@MSGROOT@(CNT)) S TEXT(CNT+1)=@MSGROOT@(CNT)
|
---|
| 123 | D ^XMD
|
---|
| 124 | K @MSGROOT
|
---|
| 125 | I $D(XMMG) D LOG^MHV7U("EMAIL TRANSMIT","FAILURE: "_XMMG,"S",0) Q
|
---|
| 126 | D LOG^MHV7U("EMAIL TRANSMIT","SUCCESS: "_XMZ,"S",0)
|
---|
| 127 | Q
|
---|