DGQEHL73 ;ALB/JFP - VIC HL7 Message Builder (A08); 09/01/96
;;5.3;REGISTRATION;**73,120,148,1015**;DEC 11,1996;Build 21
;;Per VHA Directive 10-93-142, this routine should not be modified.
;
BLDA08(XMITPTR,HL,MID,XMITARRY,INSRTPNT) ;
; -- Build either a batch or single HL7 A08 message for VIC
;
;Input : XMITPTR - Pointer to entry in PATIENT file (#2)
; HL - Array containing HL7 variables - pass by reference
; (This is the output of the call to INIT^HLFNC2())
; MID - Message Control ID to use in batch MSH segment
; XMITARRY - Array to store HL7 message in (full global ref)
; (Defaults to ^TMP("HLS",$J))
; INSRTPNT - Line to begin inserting message text at
; (Defaults to 1)
;Output : LINES - Number of lines in message (success)
; XMITARRY(N) = Line N of HL7 message
; XMITARRY(N,M) = Continuation number M of line N
; -1^Error - Unable to build message / bad input
;
;Notes 1. It is the responsibility of the calling program to
; initialize (i.e. KILL) XMITARRY
; 2. If MID is defined in the parameter list, a batch MSH segment
; will be built. Otherwise a HL7 v1.6 will build the MSH
; segment.
;
; -- Check input
S XMITPTR=+$G(XMITPTR)
Q:('$D(^DPT(XMITPTR,0))) "-1^Did not pass valid pointer to PATIENT file"
Q:($O(HL(""))="") "-1^Did not pass variables required to interact with the HL7 package"
S MID=$G(MID)
S XMITARRY=$G(XMITARRY)
S:(XMITARRY="") XMITARRY="^TMP(""HLS"","_$J_")"
S INSRTPNT=$G(INSRTPNT)
S:(INSRTPNT="") INSRTPNT=1
; -- Declare variables
N LINESADD,CURLINE,RESULT,ERROR,VAFSTR
N VAFEVN,VAFPID,VAFPV1,VAFZEL,VAFZSP,VAFZPD
;
S LINESADD=0
S CURLINE=INSRTPNT
S ERROR=0
; -- Build MSH segment for BATCH transmission, otherwise skip
I (MID'="") D
.; -- Build MSH segment
.K RESULT D MSH^HLFNC2(.HL,MID,.RESULT)
.; -- Check for results of call
.I (RESULT="") S ERROR="-1^Unable to create MSH segment for a batch transmission" Q
.; -- Copy MSH segment into HL7 message
.S @XMITARRY@(CURLINE)=RESULT
.; -- Increment number of lines added
.S LINESADD=LINESADD+1
; -- Error building MSH segment - done
Q:(ERROR) ERROR
; -- Build Segments associated with an A08 Message
;
; -- -- Build EVN
S VAFEVN=$$EVN^VAFHLEVN("A08","")
S CURLINE=CURLINE+1
S LINESADD=LINESADD+1
S @HL7XMIT@(CURLINE)=VAFEVN
; -- -- Build PID
S VAFSTR="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19"
S VAFPID=$$EN^VAFHLPID(XMITPTR,VAFSTR)
S CURLINE=CURLINE+1
S LINESADD=LINESADD+1
S @HL7XMIT@(CURLINE)=VAFPID
; -- -- Build PV1 (note: this is a null segment)
S VAFPV1="PV1^1"
S CURLINE=CURLINE+1
S LINESADD=LINESADD+1
S @HL7XMIT@(CURLINE)=VAFPV1
; -- -- Build ZEL
S VAFSTR="1,2,3,4,5,6,7,8,9,10,11,12,13"
S VAFZEL=$$EN^VAFHLZEL(XMITPTR,VAFSTR,1)
S CURLINE=CURLINE+1
S LINESADD=LINESADD+1
; -- The Datacards side of interface is hard coded, to the number of
; fields specified in the original interface specification. If
; fields are added to the segment definition, it causes the VIC
; machine error. This code corrects the problem by truncating the
; results of the national call after the 14th piece.
S VAFZEL=$P(VAFZEL,HLFS,1,14)
S @HL7XMIT@(CURLINE)=VAFZEL
; -- -- Build ZSP
S VAFZSP=$$EN^VAFHLZSP(XMITPTR)
S LINESADD=LINESADD+1
S CURLINE=CURLINE+1
; -- The Datacards side of interface is hard coded, to the number of
; fields specified in the original interface specification. If
; fields are added to the segment definition, it causes the VIC
; machine error. This code corrects the problem by truncating the
; results of the national call after the 5th piece.
S VAFZSP=$P(VAFZSP,HLFS,1,5)
S @HL7XMIT@(CURLINE)=VAFZSP
;
; -- -- Build ZPD
S VAFSTR="1,17"
S VAFZPD=$$EN^VAFHLZPD(XMITPTR,VAFSTR)
S LINESADD=LINESADD+1
S CURLINE=CURLINE+1
; -- Change POW indicator in piece 17 from Y/N to 1/0
; to work with the DataCard interface.
S $P(VAFZPD,"^",18)=$S($P(VAFZPD,"^",18)="Y":1,1:0)
; -- The Datacards side of interface is hard coded, to the number of
; fields specified in the original interface specification. If
; fields are added to the segment definition, it causes the VIC
; machine error. This code corrects the problem by truncating the
; results of the national call after the 18th piece.
S VAFZPD=$P(VAFZPD,HLFS,1,18)
S @HL7XMIT@(CURLINE)=VAFZPD
;
Q LINESADD
END ; -- End of code
;
DGQEHL73 ;ALB/JFP - VIC HL7 Message Builder (A08); 09/01/96
+1 ;;5.3;REGISTRATION;**73,120,148,1015**;DEC 11,1996;Build 21
+2 ;;Per VHA Directive 10-93-142, this routine should not be modified.
+3 ;
BLDA08(XMITPTR,HL,MID,XMITARRY,INSRTPNT) ;
+1 ; -- Build either a batch or single HL7 A08 message for VIC
+2 ;
+3 ;Input : XMITPTR - Pointer to entry in PATIENT file (#2)
+4 ; HL - Array containing HL7 variables - pass by reference
+5 ; (This is the output of the call to INIT^HLFNC2())
+6 ; MID - Message Control ID to use in batch MSH segment
+7 ; XMITARRY - Array to store HL7 message in (full global ref)
+8 ; (Defaults to ^TMP("HLS",$J))
+9 ; INSRTPNT - Line to begin inserting message text at
+10 ; (Defaults to 1)
+11 ;Output : LINES - Number of lines in message (success)
+12 ; XMITARRY(N) = Line N of HL7 message
+13 ; XMITARRY(N,M) = Continuation number M of line N
+14 ; -1^Error - Unable to build message / bad input
+15 ;
+16 ;Notes 1. It is the responsibility of the calling program to
+17 ; initialize (i.e. KILL) XMITARRY
+18 ; 2. If MID is defined in the parameter list, a batch MSH segment
+19 ; will be built. Otherwise a HL7 v1.6 will build the MSH
+20 ; segment.
+21 ;
+22 ; -- Check input
+23 SET XMITPTR=+$GET(XMITPTR)
+24 IF ('$DATA(^DPT(XMITPTR,0)))
QUIT "-1^Did not pass valid pointer to PATIENT file"
+25 IF ($ORDER(HL(""))="")
QUIT "-1^Did not pass variables required to interact with the HL7 package"
+26 SET MID=$GET(MID)
+27 SET XMITARRY=$GET(XMITARRY)
+28 IF (XMITARRY="")
SET XMITARRY="^TMP(""HLS"","_$JOB_")"
+29 SET INSRTPNT=$GET(INSRTPNT)
+30 IF (INSRTPNT="")
SET INSRTPNT=1
+31 ; -- Declare variables
+32 NEW LINESADD,CURLINE,RESULT,ERROR,VAFSTR
+33 NEW VAFEVN,VAFPID,VAFPV1,VAFZEL,VAFZSP,VAFZPD
+34 ;
+35 SET LINESADD=0
+36 SET CURLINE=INSRTPNT
+37 SET ERROR=0
+38 ; -- Build MSH segment for BATCH transmission, otherwise skip
+39 IF (MID'="")
Begin DoDot:1
+40 ; -- Build MSH segment
+41 KILL RESULT
DO MSH^HLFNC2(.HL,MID,.RESULT)
+42 ; -- Check for results of call
+43 IF (RESULT="")
SET ERROR="-1^Unable to create MSH segment for a batch transmission"
QUIT
+44 ; -- Copy MSH segment into HL7 message
+45 SET @XMITARRY@(CURLINE)=RESULT
+46 ; -- Increment number of lines added
+47 SET LINESADD=LINESADD+1
End DoDot:1
+48 ; -- Error building MSH segment - done
+49 IF (ERROR)
QUIT ERROR
+50 ; -- Build Segments associated with an A08 Message
+51 ;
+52 ; -- -- Build EVN
+53 SET VAFEVN=$$EVN^VAFHLEVN("A08","")
+54 SET CURLINE=CURLINE+1
+55 SET LINESADD=LINESADD+1
+56 SET @HL7XMIT@(CURLINE)=VAFEVN
+57 ; -- -- Build PID
+58 SET VAFSTR="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19"
+59 SET VAFPID=$$EN^VAFHLPID(XMITPTR,VAFSTR)
+60 SET CURLINE=CURLINE+1
+61 SET LINESADD=LINESADD+1
+62 SET @HL7XMIT@(CURLINE)=VAFPID
+63 ; -- -- Build PV1 (note: this is a null segment)
+64 SET VAFPV1="PV1^1"
+65 SET CURLINE=CURLINE+1
+66 SET LINESADD=LINESADD+1
+67 SET @HL7XMIT@(CURLINE)=VAFPV1
+68 ; -- -- Build ZEL
+69 SET VAFSTR="1,2,3,4,5,6,7,8,9,10,11,12,13"
+70 SET VAFZEL=$$EN^VAFHLZEL(XMITPTR,VAFSTR,1)
+71 SET CURLINE=CURLINE+1
+72 SET LINESADD=LINESADD+1
+73 ; -- The Datacards side of interface is hard coded, to the number of
+74 ; fields specified in the original interface specification. If
+75 ; fields are added to the segment definition, it causes the VIC
+76 ; machine error. This code corrects the problem by truncating the
+77 ; results of the national call after the 14th piece.
+78 SET VAFZEL=$PIECE(VAFZEL,HLFS,1,14)
+79 SET @HL7XMIT@(CURLINE)=VAFZEL
+80 ; -- -- Build ZSP
+81 SET VAFZSP=$$EN^VAFHLZSP(XMITPTR)
+82 SET LINESADD=LINESADD+1
+83 SET CURLINE=CURLINE+1
+84 ; -- The Datacards side of interface is hard coded, to the number of
+85 ; fields specified in the original interface specification. If
+86 ; fields are added to the segment definition, it causes the VIC
+87 ; machine error. This code corrects the problem by truncating the
+88 ; results of the national call after the 5th piece.
+89 SET VAFZSP=$PIECE(VAFZSP,HLFS,1,5)
+90 SET @HL7XMIT@(CURLINE)=VAFZSP
+91 ;
+92 ; -- -- Build ZPD
+93 SET VAFSTR="1,17"
+94 SET VAFZPD=$$EN^VAFHLZPD(XMITPTR,VAFSTR)
+95 SET LINESADD=LINESADD+1
+96 SET CURLINE=CURLINE+1
+97 ; -- Change POW indicator in piece 17 from Y/N to 1/0
+98 ; to work with the DataCard interface.
+99 SET $PIECE(VAFZPD,"^",18)=$SELECT($PIECE(VAFZPD,"^",18)="Y":1,1:0)
+100 ; -- The Datacards side of interface is hard coded, to the number of
+101 ; fields specified in the original interface specification. If
+102 ; fields are added to the segment definition, it causes the VIC
+103 ; machine error. This code corrects the problem by truncating the
+104 ; results of the national call after the 18th piece.
+105 SET VAFZPD=$PIECE(VAFZPD,HLFS,1,18)
+106 SET @HL7XMIT@(CURLINE)=VAFZPD
+107 ;
+108 QUIT LINESADD
END ; -- End of code
+1 ;