HLOCNRT ;DAOU/ALA-Generate HL7 Optimized Message ; 17 Jun 2005 12:57 PM
;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
;
;**Program Description**
; This program takes a current HL7 1.6 message and converts
; it to use the new HL Optimized code if it follows the standard
; 1.6 methodology of protocols.
;
; **If the VistA HL7 Protocol does not exist, calls to HL Optimized
; will have to be coded separately and this program cannot be used**
Q
;
EN(HLOPRTCL,ARYTYP,HLP) ;Entry Point
; Input Parameters
; HLOPRTCL = Protocol IEN or Protocol Name
; ARYTYP = The array where HL7 message resides
; HLP = Additional HL7 message parameters
;
; Output
; ZTSTOP = Stop processing flag (used by HDR)
; HLORESL = Error parameter
;
NEW HLORESL,HLMSTATE,APPARMS,WHOTO,WHO,ERROR,HLOMESG
S ZTSTOP=0,HLORESL=1
;
; Get IEN of protocol if name is passed
I HLOPRTCL'?.N S HLOPRTCL=+$O(^ORD(101,"B",HLOPRTCL,0))
I '$D(^ORD(101,HLOPRTCL)) S HLORESL="^99^HL7 1.6 Protocol not found",ZTSTOP=1 Q HLORESL
;
; If the VistA HL7 Protocol exists, call the Conversion Utility
; to set up the APPARMS, WHO or WHOTO arrays from protocol
; logical link
D APAR^HLOCVU(HLOPRTCL,.APPARMS,.WHO,.WHOTO)
;
; If special HLP parameters are defined, convert them
I $D(HLP) D
. I $G(HLP("SECURITY"))'="" S APPARMS("SECURITY")=HLP("SECURITY")
. I $G(HLP("CONTPTR"))'="" S APPARMS("CONTINUATION POINTER")=HLP("CONTPTR")
. I $G(HLP("QUEUE"))'="" S APPARMS("QUEUE")=HLP("QUEUE")
;
; Create HL Optimized message
I '$$NEWMSG^HLOAPI(.APPARMS,.HLMSTATE,.ERROR) S HLORESL="^99^"_ERROR,ZTSTOP=1 Q HLORESL
I $E(ARYTYP,1)="G" S HLOMESG="^TMP(""HLS"",$J)"
I $E(ARYTYP,1)="L" S HLOMESG="HLA(""HLS"")"
;
; Move the existing message from array into HL Optimized
D MOVEMSG^HLOAPI(.HLMSTATE,HLOMESG)
;
; Send message via HL Optimized
I $D(WHOTO) D Q HLORESL
. I '$$SENDMANY^HLOAPI1(.HLMSTATE,.APPARMS,.WHOTO) S HLORESL="^99^Unable to send message",ZTSTOP=1 Q
. S HLORESL=1
;
I '$$SENDONE^HLOAPI1(.HLMSTATE,.APPARMS,.WHO,.ERROR) S HLORESL="^99^"_ERROR,ZTSTOP=1 Q HLORESL
Q HLORESL
HLOCNRT ;DAOU/ALA-Generate HL7 Optimized Message ; 17 Jun 2005 12:57 PM
+1 ;;1.6;HEALTH LEVEL SEVEN;**126**;Oct 13, 1995
+2 ;
+3 ;**Program Description**
+4 ; This program takes a current HL7 1.6 message and converts
+5 ; it to use the new HL Optimized code if it follows the standard
+6 ; 1.6 methodology of protocols.
+7 ;
+8 ; **If the VistA HL7 Protocol does not exist, calls to HL Optimized
+9 ; will have to be coded separately and this program cannot be used**
+10 QUIT
+11 ;
EN(HLOPRTCL,ARYTYP,HLP) ;Entry Point
+1 ; Input Parameters
+2 ; HLOPRTCL = Protocol IEN or Protocol Name
+3 ; ARYTYP = The array where HL7 message resides
+4 ; HLP = Additional HL7 message parameters
+5 ;
+6 ; Output
+7 ; ZTSTOP = Stop processing flag (used by HDR)
+8 ; HLORESL = Error parameter
+9 ;
+10 NEW HLORESL,HLMSTATE,APPARMS,WHOTO,WHO,ERROR,HLOMESG
+11 SET ZTSTOP=0
SET HLORESL=1
+12 ;
+13 ; Get IEN of protocol if name is passed
+14 IF HLOPRTCL'?.N
SET HLOPRTCL=+$ORDER(^ORD(101,"B",HLOPRTCL,0))
+15 IF '$DATA(^ORD(101,HLOPRTCL))
SET HLORESL="^99^HL7 1.6 Protocol not found"
SET ZTSTOP=1
QUIT HLORESL
+16 ;
+17 ; If the VistA HL7 Protocol exists, call the Conversion Utility
+18 ; to set up the APPARMS, WHO or WHOTO arrays from protocol
+19 ; logical link
+20 DO APAR^HLOCVU(HLOPRTCL,.APPARMS,.WHO,.WHOTO)
+21 ;
+22 ; If special HLP parameters are defined, convert them
+23 IF $DATA(HLP)
Begin DoDot:1
+24 IF $GET(HLP("SECURITY"))'=""
SET APPARMS("SECURITY")=HLP("SECURITY")
+25 IF $GET(HLP("CONTPTR"))'=""
SET APPARMS("CONTINUATION POINTER")=HLP("CONTPTR")
+26 IF $GET(HLP("QUEUE"))'=""
SET APPARMS("QUEUE")=HLP("QUEUE")
End DoDot:1
+27 ;
+28 ; Create HL Optimized message
+29 IF '$$NEWMSG^HLOAPI(.APPARMS,.HLMSTATE,.ERROR)
SET HLORESL="^99^"_ERROR
SET ZTSTOP=1
QUIT HLORESL
+30 IF $EXTRACT(ARYTYP,1)="G"
SET HLOMESG="^TMP(""HLS"",$J)"
+31 IF $EXTRACT(ARYTYP,1)="L"
SET HLOMESG="HLA(""HLS"")"
+32 ;
+33 ; Move the existing message from array into HL Optimized
+34 DO MOVEMSG^HLOAPI(.HLMSTATE,HLOMESG)
+35 ;
+36 ; Send message via HL Optimized
+37 IF $DATA(WHOTO)
Begin DoDot:1
+38 IF '$$SENDMANY^HLOAPI1(.HLMSTATE,.APPARMS,.WHOTO)
SET HLORESL="^99^Unable to send message"
SET ZTSTOP=1
QUIT
+39 SET HLORESL=1
End DoDot:1
QUIT HLORESL
+40 ;
+41 IF '$$SENDONE^HLOAPI1(.HLMSTATE,.APPARMS,.WHO,.ERROR)
SET HLORESL="^99^"_ERROR
SET ZTSTOP=1
QUIT HLORESL
+42 QUIT HLORESL