source: WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHV7T.m@ 613

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

initial load of WorldVistAEHR

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