MHV7B2 ;WAS/GPM - HL7 message builder ORP^O10 ; [12/24/07 5:43pm]
;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
;;Per VHA Directive 2004-038, this routine should not be modified.
;
Q
;
ORPO10(MSGROOT,REQ,ERR,DATAROOT,LEN,HL) ; Build refill request response
;
; Populates the array pointed to by MSGROOT with an ORP^O10 order
; response message by calling the appropriate segment builders based
; on the type of response ACK or NAK. Extracted data pointed to
; by DATAROOT, errors, and request parameters are used to build the
; segments. An error number in ERR^4 indicates a NAK is needed.
;
; Integration Agreements:
; 3065 : $$HLNAME^XLFNAME
; 10112 : $$SITE^VASITE
;
; Input:
; MSGROOT - Global root of message
; REQ - Query parameters
; REQ("TYPE") - Request type number
; REQ("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: ORP^O10 message in MSGROOT
; LEN - Length of formatted message
;
N CNT,HIT,I
D LOG^MHVUL2("ORP-O10 BUILDER","BEGIN","S","TRACE")
;
K @MSGROOT
S CNT=1,@MSGROOT@(CNT)=$$MSA^MHV7BUS($G(REQ("MID")),ERR,.HL),LEN=$L(@MSGROOT@(CNT))
I $P(ERR,"^",4) S CNT=CNT+1,@MSGROOT@(CNT)=$$ERR^MHV7BUS(ERR,.HL),LEN=LEN+$L(@MSGROOT@(CNT))
S CNT=CNT+1,@MSGROOT@(CNT)=$$PID^MHV7BUS(.REQ,.HL),LEN=LEN+$L(@MSGROOT@(CNT))
;
I '$P(ERR,"^",4),DATAROOT'="" D
. F I=1:1 Q:'$D(@DATAROOT@(I)) D
.. S CNT=CNT+1,@MSGROOT@(CNT)=$$ORC(@DATAROOT@(I),.HL),LEN=LEN+$L(@MSGROOT@(CNT))
.. S CNT=CNT+1,@MSGROOT@(CNT)=$$RXE(@DATAROOT@(I),.HL),LEN=LEN+$L(@MSGROOT@(CNT))
.. Q
. Q
;
D LOG^MHVUL2("ORP-O10 BUILDER","END","S","TRACE")
Q
;
ORC(DATA,HL) ;build ORC segment
N ORC,STATUS,CONTROL
S STATUS=$P(DATA,"^",2)
S CONTROL=$S(STATUS=1:"OK",1:"UA")
S ORC(0)="ORC"
S ORC(1)=CONTROL ;order control
S ORC(2)=$P(DATA,"^",3) ;placer order number
S ORC(3)=$P(DATA,"^",3) ;filler order number
Q $$BLDSEG^MHV7U(.ORC,.HL)
;
RXE(DATA,HL) ;build RXE segment
N RXE,STATUS,CONTROL
S STATUS=$P(DATA,"^",2)
S CONTROL=$S(STATUS=1:"OK",1:"UA")
S RXE(0)="RXE"
S RXE(1,1,1,1)=1 ;order quantity
S RXE(1,1,4,1)=$P(DATA,"^",4) ;order start time
S RXE(2,1,1)=CONTROL ;give code identifier
S RXE(2,1,2)=STATUS ;give code text
S RXE(2,1,3)="HL70119" ;give code system
S RXE(3)=1 ;give amount
S RXE(5)="1 refill unit" ;give units
;S RXE(7)="" ;division number
S RXE(15)=$P(DATA,"^",1) ;prescription number
Q $$BLDSEG^MHV7U(.RXE,.HL)
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMHV7B2 2813 printed Nov 22, 2024@17:25:52 Page 2
MHV7B2 ;WAS/GPM - HL7 message builder ORP^O10 ; [12/24/07 5:43pm]
+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 ;
ORPO10(MSGROOT,REQ,ERR,DATAROOT,LEN,HL) ; Build refill request response
+1 ;
+2 ; Populates the array pointed to by MSGROOT with an ORP^O10 order
+3 ; response message by calling the appropriate segment builders based
+4 ; on the type of response ACK or NAK. Extracted data pointed to
+5 ; by DATAROOT, errors, and request parameters are used to build the
+6 ; segments. An error number in ERR^4 indicates a NAK is needed.
+7 ;
+8 ; Integration Agreements:
+9 ; 3065 : $$HLNAME^XLFNAME
+10 ; 10112 : $$SITE^VASITE
+11 ;
+12 ; Input:
+13 ; MSGROOT - Global root of message
+14 ; REQ - Query parameters
+15 ; REQ("TYPE") - Request type number
+16 ; REQ("MID") - original message control ID
+17 ; ERR - Caret delimited error string
+18 ; segment^sequence^field^code^ACK type^error text
+19 ; DATAROOT - Global root of data array
+20 ; HL - HL7 package array variable
+21 ;
+22 ; Output: ORP^O10 message in MSGROOT
+23 ; LEN - Length of formatted message
+24 ;
+25 NEW CNT,HIT,I
+26 DO LOG^MHVUL2("ORP-O10 BUILDER","BEGIN","S","TRACE")
+27 ;
+28 KILL @MSGROOT
+29 SET CNT=1
SET @MSGROOT@(CNT)=$$MSA^MHV7BUS($GET(REQ("MID")),ERR,.HL)
SET LEN=$LENGTH(@MSGROOT@(CNT))
+30 IF $PIECE(ERR,"^",4)
SET CNT=CNT+1
SET @MSGROOT@(CNT)=$$ERR^MHV7BUS(ERR,.HL)
SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
+31 SET CNT=CNT+1
SET @MSGROOT@(CNT)=$$PID^MHV7BUS(.REQ,.HL)
SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
+32 ;
+33 IF '$PIECE(ERR,"^",4)
IF DATAROOT'=""
Begin DoDot:1
+34 FOR I=1:1
if '$DATA(@DATAROOT@(I))
QUIT
Begin DoDot:2
+35 SET CNT=CNT+1
SET @MSGROOT@(CNT)=$$ORC(@DATAROOT@(I),.HL)
SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
+36 SET CNT=CNT+1
SET @MSGROOT@(CNT)=$$RXE(@DATAROOT@(I),.HL)
SET LEN=LEN+$LENGTH(@MSGROOT@(CNT))
+37 QUIT
End DoDot:2
+38 QUIT
End DoDot:1
+39 ;
+40 DO LOG^MHVUL2("ORP-O10 BUILDER","END","S","TRACE")
+41 QUIT
+42 ;
ORC(DATA,HL) ;build ORC segment
+1 NEW ORC,STATUS,CONTROL
+2 SET STATUS=$PIECE(DATA,"^",2)
+3 SET CONTROL=$SELECT(STATUS=1:"OK",1:"UA")
+4 SET ORC(0)="ORC"
+5 ;order control
SET ORC(1)=CONTROL
+6 ;placer order number
SET ORC(2)=$PIECE(DATA,"^",3)
+7 ;filler order number
SET ORC(3)=$PIECE(DATA,"^",3)
+8 QUIT $$BLDSEG^MHV7U(.ORC,.HL)
+9 ;
RXE(DATA,HL) ;build RXE segment
+1 NEW RXE,STATUS,CONTROL
+2 SET STATUS=$PIECE(DATA,"^",2)
+3 SET CONTROL=$SELECT(STATUS=1:"OK",1:"UA")
+4 SET RXE(0)="RXE"
+5 ;order quantity
SET RXE(1,1,1,1)=1
+6 ;order start time
SET RXE(1,1,4,1)=$PIECE(DATA,"^",4)
+7 ;give code identifier
SET RXE(2,1,1)=CONTROL
+8 ;give code text
SET RXE(2,1,2)=STATUS
+9 ;give code system
SET RXE(2,1,3)="HL70119"
+10 ;give amount
SET RXE(3)=1
+11 ;give units
SET RXE(5)="1 refill unit"
+12 ;S RXE(7)="" ;division number
+13 ;prescription number
SET RXE(15)=$PIECE(DATA,"^",1)
+14 QUIT $$BLDSEG^MHV7U(.RXE,.HL)
+15 ;