- MHV7B9 ;WAS/DLF - HL7 message builder SECURE MESSAGING RSP^K11 ; 9/25/08 4:08pm
- ;;1.0;My HealtheVet;**6**;Aug 23, 2005;Build 82
- ;;Per VHA Directive 2004-038, this routine should not be modified.
- ;
- Q
- ;
- RSPK11(MSGROOT,QRY,ERR,DATAROOT,LEN,HL) ; Build query response
- ;
- ; Populates the array pointed to by MSGROOT with an RSP^K11 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).
- ;
- ; Input:
- ; MSGROOT - Global root of message
- ; QRY - Query parameters
- ; 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: RSP^K11 message in MSGROOT
- ; LEN - Length of formatted message
- ;
- N CNT,HIT,EXTIME,MTYPE
- D LOG^MHVUL2("SM RSP-K11 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)
- S LEN=$L(@MSGROOT@(CNT))
- I $P(ERR,"^",4) D
- .S CNT=CNT+1,HIT="0^0^0",@MSGROOT@(CNT)=$$ERR^MHV7BUS(ERR,.HL)
- .S LEN=LEN+$L(@MSGROOT@(CNT))
- S CNT=CNT+1,@MSGROOT@(CNT)=$$QAK^MHV7BUS(.QRY,ERR,HIT,.HL)
- S LEN=LEN+$L(@MSGROOT@(CNT))
- S CNT=CNT+1,@MSGROOT@(CNT)=$$QPD^MHV7BUS(.QRY,EXTIME,.HL)
- S LEN=LEN+$L(@MSGROOT@(CNT))
- ;
- I '$P(ERR,"^",4) D
- .D @(QRY("BUILDER")_"(MSGROOT,DATAROOT,.CNT,.LEN,.HL)")
- ;
- D LOG^MHVUL2("SM RSP-K11 BUILDER","END","S","TRACE")
- Q
- ;
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMHV7B9 1944 printed Feb 18, 2025@23:42 Page 2
- MHV7B9 ;WAS/DLF - HL7 message builder SECURE MESSAGING RSP^K11 ; 9/25/08 4:08pm
- +1 ;;1.0;My HealtheVet;**6**;Aug 23, 2005;Build 82
- +2 ;;Per VHA Directive 2004-038, this routine should not be modified.
- +3 ;
- +4 QUIT
- +5 ;
- RSPK11(MSGROOT,QRY,ERR,DATAROOT,LEN,HL) ; Build query response
- +1 ;
- +2 ; Populates the array pointed to by MSGROOT with an RSP^K11 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 ;
- +10 ; Input:
- +11 ; MSGROOT - Global root of message
- +12 ; QRY - Query parameters
- +13 ; QRY("MID") - original message control ID
- +14 ; ERR - Caret delimited error string
- +15 ; segment^sequence^field^code^ACK type^error text
- +16 ; DATAROOT - Global root of data array
- +17 ; HL - HL7 package array variable
- +18 ;
- +19 ; Output: RSP^K11 message in MSGROOT
- +20 ; LEN - Length of formatted message
- +21 ;
- +22 NEW CNT,HIT,EXTIME,MTYPE
- +23 DO LOG^MHVUL2("SM RSP-K11 BUILDER","BEGIN","S","TRACE")
- +24 ;
- +25 SET HIT=0
- SET EXTIME=""
- +26 IF DATAROOT'=""
- Begin DoDot:1
- +27 SET HIT=+$PIECE($GET(@DATAROOT),"^",1)
- +28 SET EXTIME=$PIECE($GET(@DATAROOT),"^",2)
- +29 QUIT
- End DoDot:1
- +30 SET HIT=HIT_"^"_HIT_"^0"
- +31 ;
- +32 KILL @MSGROOT
- +33 SET CNT=1
- SET @MSGROOT@(CNT)=$$MSA^MHV7BUS($GET(QRY("MID")),ERR,.HL)
- +34 SET LEN=$LENGTH(@MSGROOT@(CNT))
- +35 IF $PIECE(ERR,"^",4)
- Begin DoDot:1
- +36 SET CNT=CNT+1
- SET HIT="0^0^0"
- SET @MSGROOT@(CNT)=$$ERR^MHV7BUS(ERR,.HL)
- +37 SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
- End DoDot:1
- +38 SET CNT=CNT+1
- SET @MSGROOT@(CNT)=$$QAK^MHV7BUS(.QRY,ERR,HIT,.HL)
- +39 SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
- +40 SET CNT=CNT+1
- SET @MSGROOT@(CNT)=$$QPD^MHV7BUS(.QRY,EXTIME,.HL)
- +41 SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
- +42 ;
- +43 IF '$PIECE(ERR,"^",4)
- Begin DoDot:1
- +44 DO @(QRY("BUILDER")_"(MSGROOT,DATAROOT,.CNT,.LEN,.HL)")
- End DoDot:1
- +45 ;
- +46 DO LOG^MHVUL2("SM RSP-K11 BUILDER","END","S","TRACE")
- +47 QUIT
- +48 ;