MHV7B1 ;WAS/GPM - HL7 message builder RTB^K13 ; [1/7/08 10:45pm]
;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
;;Per VHA Directive 2004-038, this routine should not be modified.
;
Q
;
RTBK13(MSGROOT,QRY,ERR,DATAROOT,LEN,HL) ; Build query response
;
; Populates the array pointed to by MSGROOT with an RTB^K13 query
; response message by calling the appropriate segment builders based
; on the type of response ACK/Data or NAK. Extracted data pointed to
; by DATAROOT, errors, hit counts, and query information are used to
; build the segments.
; An error number in ERR^4 indicates a NAK is needed.
; DATAROOT being null indicates a dataless ACK (testing purposes).
; Multiple types of RDF/RDT are supported based on the type of
; data in the response. The appropriate domain specific builder is
; called based on QRY("BUILDER"). Note that this is a different
; routine than the XMT("BUILDER").
;
; Input:
; MSGROOT - Global root of message
; QRY - Query parameters
; QRY("BUILDER") - Domain specific builder routine
; QRY("MID") - original message control ID
; ERR - Caret delimited error string
; segment^sequence^field^code^ACK type^error text
; DATAROOT - Global root of data array
; HL - HL7 package array variable
;
; Output: RTB^K13 message in MSGROOT
; LEN - Length of formatted message
;
N CNT,RDT,HIT,EXTIME
D LOG^MHVUL2("RTB-K13 BUILDER","BEGIN","S","TRACE")
;
S HIT=0,EXTIME=""
I DATAROOT'="" D
. S HIT=+$P($G(@DATAROOT),"^",1)
. S EXTIME=$P($G(@DATAROOT),"^",2)
. Q
S HIT=HIT_"^"_HIT_"^0"
;
K @MSGROOT
S CNT=1,@MSGROOT@(CNT)=$$MSA^MHV7BUS($G(QRY("MID")),ERR,.HL),LEN=$L(@MSGROOT@(CNT))
I $P(ERR,"^",4) S CNT=CNT+1,HIT="0^0^0",@MSGROOT@(CNT)=$$ERR^MHV7BUS(ERR,.HL),LEN=LEN+$L(@MSGROOT@(CNT))
S CNT=CNT+1,@MSGROOT@(CNT)=$$QAK^MHV7BUS(.QRY,ERR,HIT,.HL),LEN=LEN+$L(@MSGROOT@(CNT))
S CNT=CNT+1,@MSGROOT@(CNT)=$$QPD^MHV7BUS(.QRY,EXTIME,.HL),LEN=LEN+$L(@MSGROOT@(CNT))
I '$P(ERR,"^",4) D
. D @("RDF^"_QRY("BUILDER")_"(MSGROOT,.CNT,.LEN,.HL)")
. Q:DATAROOT=""
. Q:HIT<1
. D @("RDT^"_QRY("BUILDER")_"(MSGROOT,DATAROOT,.CNT,.LEN,.HL)")
. Q
;
D LOG^MHVUL2("RTB-K13 BUILDER","END","S","TRACE")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMHV7B1 2299 printed Dec 13, 2024@02:15:37 Page 2
MHV7B1 ;WAS/GPM - HL7 message builder RTB^K13 ; [1/7/08 10:45pm]
+1 ;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;
RTBK13(MSGROOT,QRY,ERR,DATAROOT,LEN,HL) ; Build query response
+1 ;
+2 ; Populates the array pointed to by MSGROOT with an RTB^K13 query
+3 ; response message by calling the appropriate segment builders based
+4 ; on the type of response ACK/Data or NAK. Extracted data pointed to
+5 ; by DATAROOT, errors, hit counts, and query information are used to
+6 ; build the segments.
+7 ; An error number in ERR^4 indicates a NAK is needed.
+8 ; DATAROOT being null indicates a dataless ACK (testing purposes).
+9 ; Multiple types of RDF/RDT are supported based on the type of
+10 ; data in the response. The appropriate domain specific builder is
+11 ; called based on QRY("BUILDER"). Note that this is a different
+12 ; routine than the XMT("BUILDER").
+13 ;
+14 ; Input:
+15 ; MSGROOT - Global root of message
+16 ; QRY - Query parameters
+17 ; QRY("BUILDER") - Domain specific builder routine
+18 ; QRY("MID") - original message control ID
+19 ; ERR - Caret delimited error string
+20 ; segment^sequence^field^code^ACK type^error text
+21 ; DATAROOT - Global root of data array
+22 ; HL - HL7 package array variable
+23 ;
+24 ; Output: RTB^K13 message in MSGROOT
+25 ; LEN - Length of formatted message
+26 ;
+27 NEW CNT,RDT,HIT,EXTIME
+28 DO LOG^MHVUL2("RTB-K13 BUILDER","BEGIN","S","TRACE")
+29 ;
+30 SET HIT=0
SET EXTIME=""
+31 IF DATAROOT'=""
Begin DoDot:1
+32 SET HIT=+$PIECE($GET(@DATAROOT),"^",1)
+33 SET EXTIME=$PIECE($GET(@DATAROOT),"^",2)
+34 QUIT
End DoDot:1
+35 SET HIT=HIT_"^"_HIT_"^0"
+36 ;
+37 KILL @MSGROOT
+38 SET CNT=1
SET @MSGROOT@(CNT)=$$MSA^MHV7BUS($GET(QRY("MID")),ERR,.HL)
SET LEN=$LENGTH(@MSGROOT@(CNT))
+39 IF $PIECE(ERR,"^",4)
SET CNT=CNT+1
SET HIT="0^0^0"
SET @MSGROOT@(CNT)=$$ERR^MHV7BUS(ERR,.HL)
SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
+40 SET CNT=CNT+1
SET @MSGROOT@(CNT)=$$QAK^MHV7BUS(.QRY,ERR,HIT,.HL)
SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
+41 SET CNT=CNT+1
SET @MSGROOT@(CNT)=$$QPD^MHV7BUS(.QRY,EXTIME,.HL)
SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
+42 IF '$PIECE(ERR,"^",4)
Begin DoDot:1
+43 DO @("RDF^"_QRY("BUILDER")_"(MSGROOT,.CNT,.LEN,.HL)")
+44 if DATAROOT=""
QUIT
+45 if HIT<1
QUIT
+46 DO @("RDT^"_QRY("BUILDER")_"(MSGROOT,DATAROOT,.CNT,.LEN,.HL)")
+47 QUIT
End DoDot:1
+48 ;
+49 DO LOG^MHVUL2("RTB-K13 BUILDER","END","S","TRACE")
+50 QUIT
+51 ;