source: WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHV7B2.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.7 KB
Line 
1MHV7B2 ;WAS/GPM - HL7 message builder ORP^O10 ; [12/24/07 5:43pm]
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 ;
7ORPO10(MSGROOT,REQ,ERR,DATAROOT,LEN,HL) ; Build refill request response
8 ;
9 ; Populates the array pointed to by MSGROOT with an ORP^O10 order
10 ; response message by calling the appropriate segment builders based
11 ; on the type of response ACK or NAK. Extracted data pointed to
12 ; by DATAROOT, errors, and request parameters are used to build the
13 ; segments. An error number in ERR^4 indicates a NAK is needed.
14 ;
15 ; Integration Agreements:
16 ; 3065 : $$HLNAME^XLFNAME
17 ; 10112 : $$SITE^VASITE
18 ;
19 ; Input:
20 ; MSGROOT - Global root of message
21 ; REQ - Query parameters
22 ; REQ("TYPE") - Request type number
23 ; REQ("MID") - original message control ID
24 ; ERR - Caret delimited error string
25 ; segment^sequence^field^code^ACK type^error text
26 ; DATAROOT - Global root of data array
27 ; HL - HL7 package array variable
28 ;
29 ; Output: ORP^O10 message in MSGROOT
30 ; LEN - Length of formatted message
31 ;
32 N CNT,HIT,I
33 D LOG^MHVUL2("ORP-O10 BUILDER","BEGIN","S","TRACE")
34 ;
35 K @MSGROOT
36 S CNT=1,@MSGROOT@(CNT)=$$MSA^MHV7BUS($G(REQ("MID")),ERR,.HL),LEN=$L(@MSGROOT@(CNT))
37 I $P(ERR,"^",4) S CNT=CNT+1,@MSGROOT@(CNT)=$$ERR^MHV7BUS(ERR,.HL),LEN=LEN+$L(@MSGROOT@(CNT))
38 S CNT=CNT+1,@MSGROOT@(CNT)=$$PID^MHV7BUS(.REQ,.HL),LEN=LEN+$L(@MSGROOT@(CNT))
39 ;
40 I '$P(ERR,"^",4),DATAROOT'="" D
41 . F I=1:1 Q:'$D(@DATAROOT@(I)) D
42 .. S CNT=CNT+1,@MSGROOT@(CNT)=$$ORC(@DATAROOT@(I),.HL),LEN=LEN+$L(@MSGROOT@(CNT))
43 .. S CNT=CNT+1,@MSGROOT@(CNT)=$$RXE(@DATAROOT@(I),.HL),LEN=LEN+$L(@MSGROOT@(CNT))
44 .. Q
45 . Q
46 ;
47 D LOG^MHVUL2("ORP-O10 BUILDER","END","S","TRACE")
48 Q
49 ;
50ORC(DATA,HL) ;build ORC segment
51 N ORC,STATUS,CONTROL
52 S STATUS=$P(DATA,"^",2)
53 S CONTROL=$S(STATUS=1:"OK",1:"UA")
54 S ORC(0)="ORC"
55 S ORC(1)=CONTROL ;order control
56 S ORC(2)=$P(DATA,"^",3) ;placer order number
57 S ORC(3)=$P(DATA,"^",3) ;filler order number
58 Q $$BLDSEG^MHV7U(.ORC,.HL)
59 ;
60RXE(DATA,HL) ;build RXE segment
61 N RXE,STATUS,CONTROL
62 S STATUS=$P(DATA,"^",2)
63 S CONTROL=$S(STATUS=1:"OK",1:"UA")
64 S RXE(0)="RXE"
65 S RXE(1,1,1,1)=1 ;order quantity
66 S RXE(1,1,4,1)=$P(DATA,"^",4) ;order start time
67 S RXE(2,1,1)=CONTROL ;give code identifier
68 S RXE(2,1,2)=STATUS ;give code text
69 S RXE(2,1,3)="HL70119" ;give code system
70 S RXE(3)=1 ;give amount
71 S RXE(5)="1 refill unit" ;give units
72 ;S RXE(7)="" ;division number
73 S RXE(15)=$P(DATA,"^",1) ;prescription number
74 Q $$BLDSEG^MHV7U(.RXE,.HL)
75 ;
Note: See TracBrowser for help on using the repository browser.