Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MHV7T

MHV7T.m

Go to the documentation of this file.
  1. 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
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. XMIT(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
  1. ; Builds and sends the desired HL7 message based on the mode and
  1. ; builder passed in XMT. If the builder requires other information
  1. ; to build the message, it can be passed as additional subscripts of
  1. ; XMT or REQ. REQ is used for request or query related parameters,
  1. ; XMT for transmission and control related parameters.
  1. ;
  1. ; The message builder sent in XMT("BUILDER") is called to build the
  1. ; desired message.
  1. ;
  1. ; A synchronous response is indicated by XMT("MODE") of S, and sent
  1. ; on the current interface as an original mode acknowledgement.
  1. ;
  1. ; An asynchronous response is indicated by XMT("MODE") of A, and
  1. ; sent on the interface associated with XMT("PROTOCOL") as an
  1. ; enhanced mode application acknowledgement. Large messages can be
  1. ; sent as a bolus (series of messages without batch formatting) by
  1. ; specifying an XMT("MAX SIZE").
  1. ;
  1. ; A message may be initiated by using the asynchronous mode settings
  1. ; Synchronous messages cannot be initiated with this API.
  1. ;
  1. ; Integration Agreements:
  1. ; 2161 : INIT^HLFNC2
  1. ; 2164 : GENERATE^HLMA
  1. ; 2165 : GENACK^HLMA1
  1. ;
  1. ; Input:
  1. ; REQ - Request parameters and Message ID of original message
  1. ; XMT - Transmission parameters
  1. ; XMT("MODE") - Mode of the transmission
  1. ; XMT("PROTOCOL") - Protocol for deferred transmissions
  1. ; XMT("BUILDER") - Name/tag of message builder routine
  1. ; XMT("HLMTIENS") - Original message IEN - Immediate mode
  1. ; XMT("MAX SIZE") - Maximum message size (asynch only)
  1. ; ERR - Caret delimited error string
  1. ; segment^sequence^field^code^ACK type^error text
  1. ; DATAROOT - Global root of data array
  1. ; HL - HL7 package array variable
  1. ;
  1. ; Output: HL7 Message Transmitted
  1. ;
  1. N MSGROOT,HLRSLT,HLP,MSGLEN
  1. D LOG^MHVUL2("TRANSMIT","BEGIN","S","TRACE")
  1. I XMT("MODE")="A" D ;Asynchronous mode
  1. . D LOG^MHVUL2("TRANSMIT","ASYNCHRONOUS","S","TRACE")
  1. . K HL
  1. . D INIT^HLFNC2(XMT("PROTOCOL"),.HL)
  1. . I $G(HL) S ERR=HL D LOG^MHVUL2("PROTOCOL INIT FAILURE",ERR,"S","ERROR") Q
  1. . D LOG^MHVUL2("PROTOCOL INIT","DONE "_XMT("MODE"),"S","DEBUG")
  1. . S MSGROOT="^TMP(""HLS"",$J)"
  1. . D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
  1. . D LOG^MHVUL2("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
  1. . I MSGLEN<XMT("MAX SIZE")!'XMT("MAX SIZE") D Q
  1. . . D GENERATE^HLMA(XMT("PROTOCOL"),"GM",1,.HLRSLT,"",.HLP)
  1. . . K @MSGROOT
  1. . . D LOG^MHVUL2("TRANSMIT "_$P(XMT("BUILDER"),"^"),.HLRSLT,"M","DEBUG")
  1. . . Q
  1. . D BOLUS^MHV7TB(MSGROOT,.XMT,.HL)
  1. . Q
  1. ;
  1. I XMT("MODE")="S" D ;Synchronous mode
  1. . D LOG^MHVUL2("TRANSMIT","SYNCHRONOUS","S",0)
  1. . S MSGROOT="^TMP(""HLA"",$J)"
  1. . D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
  1. . D LOG^MHVUL2("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
  1. . D GENACK^HLMA1(HL("EID"),XMT("HLMTIENS"),HL("EIDS"),"GM",1,.HLRSLT)
  1. . K @MSGROOT
  1. . D LOG^MHVUL2("TRANSMIT "_$P(XMT("BUILDER"),"^"),.HLRSLT,"M","DEBUG")
  1. . Q
  1. D LOG^MHVUL2("TRANSMIT","END","S","TRACE")
  1. Q
  1. ;
  1. EMAIL(REQ,XMT,ERR,DATAROOT,HL) ;Build and Transmit HL7 message
  1. ; Builds and sends the desired HL7 message via email.
  1. ; This will only be used until the MHV server can establish normal
  1. ; HL7 receivers.
  1. ;
  1. ; If the builder requires other information to build the message, it
  1. ; can be passed as additional subscripts of XMT or REQ. REQ is used
  1. ; for request or query related parameters, XMT for transmission and
  1. ; control related parameters.
  1. ;
  1. ; The message builder sent in XMT("BUILDER") is called to build the
  1. ; desired message.
  1. ;
  1. ; Integration Agreements:
  1. ; 2161 : INIT^HLFNC2
  1. ; MSH^HLFNC2
  1. ; 10070 : ^XMD
  1. ;
  1. ; Input:
  1. ; REQ - Request parameters and Message ID of original message
  1. ; XMT - Transmission parameters
  1. ; XMT("PROTOCOL") - Protocol for deferred transmissions
  1. ; XMT("BUILDER") - Name/tag of message builder routine
  1. ; XMT("SAF") - Sending Facility
  1. ; XMT("EMAIL") - Email Address to use
  1. ; ERR - Caret delimited error string
  1. ; segment^sequence^field^code^ACK type^error text
  1. ; DATAROOT - Global root of data array
  1. ; HL - HL7 package array variable
  1. ;
  1. ; Output: HL7 Message Transmitted
  1. ;
  1. N MSGROOT,MID,MSH,CNT,MSGLEN
  1. N TEXT,XMDUN,XMDUZ,XMTEXT,XMROU,XMSTRIP,XMSUB,XMY,XMZ,XMDF,XMMG
  1. D LOG^MHVUL2("TRANSMIT","EMAIL","S","TRACE")
  1. K HL
  1. D INIT^HLFNC2(XMT("PROTOCOL"),.HL)
  1. I $G(HL) S ERR=HL D LOG^MHVUL2("PROTOCOL INIT FAIL",ERR,"S","ERROR") Q
  1. D LOG^MHVUL2("PROTOCOL INIT","DONE EMAIL","S","DEBUG")
  1. S MSGROOT="^TMP(""MHV7TEM"",$J)"
  1. D @(XMT("BUILDER")_"(MSGROOT,.REQ,ERR,DATAROOT,.MSGLEN,.HL)")
  1. D LOG^MHVUL2("BUILD "_$P(XMT("BUILDER"),"^"),MSGROOT,"I","DEBUG")
  1. S MID=+$H_"-"_$P($H,",",2)
  1. S HL("SAF")=XMT("SAF")
  1. D MSH^HLFNC2(.HL,MID,.MSH)
  1. S XMDF="",(XMDUN,XMDUZ)="My HealtheVet Package"
  1. S XMY(XMT("EMAIL"))=""
  1. S XMSUB=XMT("SAF")_" MHV PACKAGE MESSAGE"
  1. S XMTEXT="TEXT("
  1. S TEXT(1)=MSH
  1. F CNT=1:1 Q:'$D(@MSGROOT@(CNT)) S TEXT(CNT+1)=@MSGROOT@(CNT)
  1. D ^XMD
  1. K @MSGROOT
  1. I $D(XMMG) D LOG^MHVUL2("EMAIL TRANSMIT","FAILURE: "_XMMG,"S","ERROR") Q
  1. D LOG^MHVUL2("EMAIL TRANSMIT","SUCCESS: "_XMZ,"S","TRACE")
  1. Q