source: WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHV7B1.m@ 619

Last change on this file since 619 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

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