RORHL7A ;HCIOFO/SG - HL7 UTILITIES ; 4/4/07 1:07pm
;;1.5;CLINICAL CASE REGISTRIES;**2**;Feb 17, 2006;Build 6
;
Q
;
;***** ADDS THE SEGMENT TO THE HL7 MESSAGE BUFFER
;
; SEG Complete HL7 segment
;
; The ADDSEGC^RORHL7A procedure adds the HL7 segment to the HL7
; message buffer defined by the ROREXT("HL7BUF") parameter
; (the ^TMP("HLS",$J), by default). The <TAB>, <CR> and <LF>
; characters are replaced with spaces. Long segments are split
; among sub-nodes of the main segment node in the destination
; buffer.
;
; The RORHL array and some nodes of the ROREXT array must be
; initialized (either by the $$INIT^RORHL7 or manually) before
; calling this procedure.
;
ADDSEGC(SEG) ;
N I1,I2,MAXLEN,NODE,PTR,PTR1,SID,SL
S NODE=ROREXT("HL7BUF"),PTR=$G(ROREXT("HL7PTR"))+1
S HLFS=RORHL("FS"),HLECH=RORHL("ECH")
Q:$P(SEG,HLFS)="" ; Segment Name
;--- Assign the Set ID if necessary
S SID=$$SETID($P(SEG,HLFS))
S:SID>0 $P(SEG,HLFS,2)=SID
;--- Remove empty trailing fields
S I2=$L(SEG,HLFS)
F I1=I2:-1:1 Q:$TR($P(SEG,HLFS,I1),HLECH)'=""
S:I1<I2 $P(SEG,HLFS,I1+1,I2)=""
;--- Store the segment
S SL=$L(SEG),MAXLEN=245 K @NODE@(PTR)
S @NODE@(PTR)=$TR($E(SEG,1,MAXLEN),$C(9,10,13)," ")
S ROREXT("HL7SIZE")=$G(ROREXT("HL7SIZE"))+SL+1
;--- Split the segment into sub-nodes if necessary
D:SL>MAXLEN
. S I2=MAXLEN
. F PTR1=1:1 S I1=I2+1,I2=I1+MAXLEN-1 Q:I1>SL D
. . S @NODE@(PTR,PTR1)=$TR($E(SEG,I1,I2),$C(9,10,13)," ")
;--- Save the pointer
S ROREXT("HL7PTR")=PTR
Q
;
;***** ASSEMBLES THE SEGMENT AND ADDS IT TO THE HL7 MESSAGE BUFFER
;
; .FIELDS Reference to a local variable where the HL7
; fields are stored
;
; FIELDS(
; 0) Segment name
; I, Field value
; i) Continuation of the value if it is
; ... longer than than 245 characters
;
; The ADDSEGF^RORHL7A procedure assembles the HL7 segment from
; provided field values and adds it to the HL7 message buffer
; defined by the ROREXT("HL7BUF") node (the ^TMP("HLS",$J), by
; default). The <TAB>, <CR> and <LF> characters are replaced with
; spaces. Long segments are split among sub-nodes of the main
; segment node in the destination buffer.
;
; The RORHL array and some nodes of the ROREXT array must be
; initialized (either by the $$INIT^RORHL7 or manually) before
; calling this procedure.
;
ADDSEGF(FIELDS) ;
; RORBUF Temporary buffer for the segment construction
; RORIS Current continuation subscript in the HL7 buffer
; RORNODE Closed root of the HL7 message buffer
; RORPTR Current subscript in the HL7 message buffer
; RORSL Number of characters that can be appended to the
; RORBUF before it has to be emptied into the HL7
; message buffer
;
N FLD,I,LASTFLD,RORBUF,RORIS,RORNODE,RORPTR,RORSL
Q:$G(FIELDS(0))="" ; Segment Name
S RORNODE=ROREXT("HL7BUF"),RORPTR=$G(ROREXT("HL7PTR"))+1
S HLFS=RORHL("FS"),HLECH=RORHL("ECH")
;--- Assign the Set ID if necessary
S I=$$SETID(FIELDS(0))
S:I>0 FIELDS(1)=I
;--- Remove empty trailing fields
S I=$NA(FIELDS(" "))
F S I=$$Q^RORUTL18(I,-1) Q:I="" Q:$TR(@I,HLECH)'="" K @I
;--- Initialize construction variables
S RORBUF=FIELDS(0),I=$L(RORBUF)
S ROREXT("HL7SIZE")=$G(ROREXT("HL7SIZE"))+I+1
S RORIS=0,RORSL=245-I
;--- Append the fields and store the segment
S LASTFLD=+$O(FIELDS(" "),-1)
F FLD=1:1:LASTFLD D
. D APPEND(HLFS_$G(FIELDS(FLD)))
. ;--- Process the field continuation nodes
. S I=""
. F S I=$O(FIELDS(FLD,I)) Q:I="" D APPEND(FIELDS(FLD,I))
;--- Flush the buffer if necessary
D:RORBUF'=""
. I 'RORIS S @RORNODE@(RORPTR)=RORBUF Q
. S @RORNODE@(RORPTR,RORIS)=RORBUF
S ROREXT("HL7PTR")=RORPTR
Q
;
;***** APPENDS THE FIELD VALUE TO THE HL7 SEGMENT
;
; VAL Value of the field (or its part)
;
; This is an internal function. Do not call it directly.
;
APPEND(VAL) ;
N BASE,L
S VAL=$TR(VAL,$C(9,10,13)," "),L=$L(VAL)
S ROREXT("HL7SIZE")=$G(ROREXT("HL7SIZE"))+L
I L'>RORSL S RORBUF=RORBUF_VAL,RORSL=RORSL-L Q
;---
S RORBUF=RORBUF_$E(VAL,1,RORSL),L=L-RORSL
S BASE=1
F D Q:L'>0
. I 'RORIS S @RORNODE@(RORPTR)=RORBUF
. E S @RORNODE@(RORPTR,RORIS)=RORBUF
. S BASE=BASE+RORSL,RORIS=RORIS+1,RORSL=245
. S RORBUF=$E(VAL,BASE,BASE+RORSL-1),L=L-RORSL
S RORSL=-L
Q
;
;***** RETURNS THE BHS SEGMENT
;
; BID Batch message ID
;
; [BDT] Batch message creation time in internal FileMan
; format (NOW by default)
;
; [COMMENT] Optional comment
;
; The RORHL local variable must be initialized by the $$INIT^RORHL7
; function before calling this entry point.
;
BHS(BID,BDT,COMMENT) ;
N CS,SEG,TMP
D BHS^HLFNC3(.RORHL,BID,.SEG)
Q:$G(SEG)="" ""
S HLFS=RORHL("FS"),HLECH=RORHL("ECH"),CS=$E(HLECH,1)
;--- Post-processing
S SEG=SEG_$G(SEG(1))
S:$G(BDT)'>0 BDT=$$NOW^XLFDT
S TMP=$E($P($$SITE^VASITE,U,3),1,3)
S $P(SEG,HLFS,4)=TMP_CS_$G(^XMB("NETNAME"))_CS_"DNS"
S $P(SEG,HLFS,5)="ROR AAC"
S $P(SEG,HLFS,7)=$$FMTHL7^XLFDT(BDT)
S TMP=$P(SEG,HLFS,9)
S $P(TMP,CS,3)=$P(TMP,CS,3)_$E(HLECH,2)_$G(RORHL("ETN"))
S $P(SEG,HLFS,9)=TMP
S $P(SEG,HLFS,10)=$G(COMMENT)
Q SEG
;
;***** RETURNS BTS SEGMENT
;
; MSGCNT Batch message count
; [COMMENT] Batch comment
;
; The RORHL variable must be initialized by the INIT^HLFNC2 before
; calling this entry point
;
BTS(MSGCNT,COMMENT) ;
Q "BTS"_RORHL("FS")_MSGCNT_RORHL("FS")_$G(COMMENT)
;
;***** LOADS THE HL7 FIELD (OR ITS PART) TO THE BUFFER
;
; VAL Value of the field (or its part)
;
; FLD Number of the field in the segment (piece number)
;
FIELD(VAL,FLD) ;
N BASE,L
S:FLD>RORFLD RORFLD=FLD,RORIS=0,RORSL=245
S L=$L(VAL),BASE=1
F RORIS=RORIS:1 D Q:L'>0
. I 'RORIS S RORSEG(RORFLD)=$G(RORSEG(RORFLD))_$E(VAL,BASE,BASE+RORSL-1)
. E S RORSEG(RORFLD,RORIS)=$G(RORSEG(RORFLD,RORIS))_$E(VAL,BASE,BASE+RORSL-1)
. S BASE=BASE+RORSL,L=L-RORSL,RORSL=245
S RORSL=-L
Q
;
;***** LOADS THE HL7 SEGMENT INTO THE RPOVIDED BUFFER
;
; .RORSEG Reference to a local variable where the HL7
; fields will be stored. The fields are stored
; in the following format:
;
; RORSEG(FldNum)=FldVal
;
; If the value is longer that 245 characters then
; the continuation nodes are created:
;
; RORSEG(FldNum,#)=FldValCont
;
; ROR8SRC Closed root of the source buffer containing
; the HL7 segment
;
LOADSEG(RORSEG,ROR8SRC) ;
N BUF,FLD,I,IFL,NFL,RORFLD,RORIS,RORSL
S HLFS=RORHL("FS") K RORSEG
;--- Process the main segment
S BUF=$G(@ROR8SRC),NFL=$L(BUF,HLFS)
F IFL=1:1:NFL S RORSEG(IFL-1)=$P(BUF,HLFS,IFL)
Q:$D(@ROR8SRC)<10
;--- Process the sub-segments
S (FLD,RORFLD)=NFL-1,RORIS=0,RORSL=245-$L(RORSEG(FLD))
S I=""
F S I=$O(@ROR8SRC@(I)) Q:I="" D
. S BUF=@ROR8SRC@(I),NFL=$L(BUF,HLFS)
. D FIELD($P(BUF,HLFS),FLD)
. F IFL=2:1:NFL S FLD=FLD+1 D FIELD($P(BUF,HLFS,IFL),FLD)
Q
;
;***** RETURNS TEXT EXPLANATIONS OF THE HL7 MESSAGE STATUS
;
; MSGST Status value returned by the $$MSGSTAT^HLUTIL
;
MSGSTXT(MSGST) ;
N ST S ST=+MSGST
Q:'ST "Message does not exist"
Q:ST=1 "Waiting in queue"
Q:ST=1.5 "Opening connection"
Q:ST=1.7 "Awaiting response"
Q:ST=2 "Awaiting application ack"
Q:ST=3 "Successfully completed"
Q:ST=4 "Error"
Q:ST=8 "Being generated"
Q:ST=9 "Awaiting processing"
Q "Unknown"
;
;***** ASSIGNS THE 'SET ID'
;
; SEGNAME Name of the HL7 segment
; [DISINC] Disable increment of the Set ID
;
; Return Values:
; "" Not required for this segment
; >0 Value for the Set ID field
;
SETID(SEGNAME,DISINC) ;
N SETID
Q:$G(SEGNAME)="" ""
S SETID=+$G(ROREXT("HL7SID",SEGNAME))
Q:SETID'>0 ""
S:'$G(DISINC) ROREXT("HL7SID",SEGNAME)=SETID+1
Q SETID
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORHL7A 8108 printed Nov 22, 2024@16:52:20 Page 2
RORHL7A ;HCIOFO/SG - HL7 UTILITIES ; 4/4/07 1:07pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**2**;Feb 17, 2006;Build 6
+2 ;
+3 QUIT
+4 ;
+5 ;***** ADDS THE SEGMENT TO THE HL7 MESSAGE BUFFER
+6 ;
+7 ; SEG Complete HL7 segment
+8 ;
+9 ; The ADDSEGC^RORHL7A procedure adds the HL7 segment to the HL7
+10 ; message buffer defined by the ROREXT("HL7BUF") parameter
+11 ; (the ^TMP("HLS",$J), by default). The <TAB>, <CR> and <LF>
+12 ; characters are replaced with spaces. Long segments are split
+13 ; among sub-nodes of the main segment node in the destination
+14 ; buffer.
+15 ;
+16 ; The RORHL array and some nodes of the ROREXT array must be
+17 ; initialized (either by the $$INIT^RORHL7 or manually) before
+18 ; calling this procedure.
+19 ;
ADDSEGC(SEG) ;
+1 NEW I1,I2,MAXLEN,NODE,PTR,PTR1,SID,SL
+2 SET NODE=ROREXT("HL7BUF")
SET PTR=$GET(ROREXT("HL7PTR"))+1
+3 SET HLFS=RORHL("FS")
SET HLECH=RORHL("ECH")
+4 ; Segment Name
if $PIECE(SEG,HLFS)=""
QUIT
+5 ;--- Assign the Set ID if necessary
+6 SET SID=$$SETID($PIECE(SEG,HLFS))
+7 if SID>0
SET $PIECE(SEG,HLFS,2)=SID
+8 ;--- Remove empty trailing fields
+9 SET I2=$LENGTH(SEG,HLFS)
+10 FOR I1=I2:-1:1
if $TRANSLATE($PIECE(SEG,HLFS,I1),HLECH)'=""
QUIT
+11 if I1<I2
SET $PIECE(SEG,HLFS,I1+1,I2)=""
+12 ;--- Store the segment
+13 SET SL=$LENGTH(SEG)
SET MAXLEN=245
KILL @NODE@(PTR)
+14 SET @NODE@(PTR)=$TRANSLATE($EXTRACT(SEG,1,MAXLEN),$CHAR(9,10,13)," ")
+15 SET ROREXT("HL7SIZE")=$GET(ROREXT("HL7SIZE"))+SL+1
+16 ;--- Split the segment into sub-nodes if necessary
+17 if SL>MAXLEN
Begin DoDot:1
+18 SET I2=MAXLEN
+19 FOR PTR1=1:1
SET I1=I2+1
SET I2=I1+MAXLEN-1
if I1>SL
QUIT
Begin DoDot:2
+20 SET @NODE@(PTR,PTR1)=$TRANSLATE($EXTRACT(SEG,I1,I2),$CHAR(9,10,13)," ")
End DoDot:2
End DoDot:1
+21 ;--- Save the pointer
+22 SET ROREXT("HL7PTR")=PTR
+23 QUIT
+24 ;
+25 ;***** ASSEMBLES THE SEGMENT AND ADDS IT TO THE HL7 MESSAGE BUFFER
+26 ;
+27 ; .FIELDS Reference to a local variable where the HL7
+28 ; fields are stored
+29 ;
+30 ; FIELDS(
+31 ; 0) Segment name
+32 ; I, Field value
+33 ; i) Continuation of the value if it is
+34 ; ... longer than than 245 characters
+35 ;
+36 ; The ADDSEGF^RORHL7A procedure assembles the HL7 segment from
+37 ; provided field values and adds it to the HL7 message buffer
+38 ; defined by the ROREXT("HL7BUF") node (the ^TMP("HLS",$J), by
+39 ; default). The <TAB>, <CR> and <LF> characters are replaced with
+40 ; spaces. Long segments are split among sub-nodes of the main
+41 ; segment node in the destination buffer.
+42 ;
+43 ; The RORHL array and some nodes of the ROREXT array must be
+44 ; initialized (either by the $$INIT^RORHL7 or manually) before
+45 ; calling this procedure.
+46 ;
ADDSEGF(FIELDS) ;
+1 ; RORBUF Temporary buffer for the segment construction
+2 ; RORIS Current continuation subscript in the HL7 buffer
+3 ; RORNODE Closed root of the HL7 message buffer
+4 ; RORPTR Current subscript in the HL7 message buffer
+5 ; RORSL Number of characters that can be appended to the
+6 ; RORBUF before it has to be emptied into the HL7
+7 ; message buffer
+8 ;
+9 NEW FLD,I,LASTFLD,RORBUF,RORIS,RORNODE,RORPTR,RORSL
+10 ; Segment Name
if $GET(FIELDS(0))=""
QUIT
+11 SET RORNODE=ROREXT("HL7BUF")
SET RORPTR=$GET(ROREXT("HL7PTR"))+1
+12 SET HLFS=RORHL("FS")
SET HLECH=RORHL("ECH")
+13 ;--- Assign the Set ID if necessary
+14 SET I=$$SETID(FIELDS(0))
+15 if I>0
SET FIELDS(1)=I
+16 ;--- Remove empty trailing fields
+17 SET I=$NAME(FIELDS(" "))
+18 FOR
SET I=$$Q^RORUTL18(I,-1)
if I=""
QUIT
if $TRANSLATE(@I,HLECH)'=""
QUIT
KILL @I
+19 ;--- Initialize construction variables
+20 SET RORBUF=FIELDS(0)
SET I=$LENGTH(RORBUF)
+21 SET ROREXT("HL7SIZE")=$GET(ROREXT("HL7SIZE"))+I+1
+22 SET RORIS=0
SET RORSL=245-I
+23 ;--- Append the fields and store the segment
+24 SET LASTFLD=+$ORDER(FIELDS(" "),-1)
+25 FOR FLD=1:1:LASTFLD
Begin DoDot:1
+26 DO APPEND(HLFS_$GET(FIELDS(FLD)))
+27 ;--- Process the field continuation nodes
+28 SET I=""
+29 FOR
SET I=$ORDER(FIELDS(FLD,I))
if I=""
QUIT
DO APPEND(FIELDS(FLD,I))
End DoDot:1
+30 ;--- Flush the buffer if necessary
+31 if RORBUF'=""
Begin DoDot:1
+32 IF 'RORIS
SET @RORNODE@(RORPTR)=RORBUF
QUIT
+33 SET @RORNODE@(RORPTR,RORIS)=RORBUF
End DoDot:1
+34 SET ROREXT("HL7PTR")=RORPTR
+35 QUIT
+36 ;
+37 ;***** APPENDS THE FIELD VALUE TO THE HL7 SEGMENT
+38 ;
+39 ; VAL Value of the field (or its part)
+40 ;
+41 ; This is an internal function. Do not call it directly.
+42 ;
APPEND(VAL) ;
+1 NEW BASE,L
+2 SET VAL=$TRANSLATE(VAL,$CHAR(9,10,13)," ")
SET L=$LENGTH(VAL)
+3 SET ROREXT("HL7SIZE")=$GET(ROREXT("HL7SIZE"))+L
+4 IF L'>RORSL
SET RORBUF=RORBUF_VAL
SET RORSL=RORSL-L
QUIT
+5 ;---
+6 SET RORBUF=RORBUF_$EXTRACT(VAL,1,RORSL)
SET L=L-RORSL
+7 SET BASE=1
+8 FOR
Begin DoDot:1
+9 IF 'RORIS
SET @RORNODE@(RORPTR)=RORBUF
+10 IF '$TEST
SET @RORNODE@(RORPTR,RORIS)=RORBUF
+11 SET BASE=BASE+RORSL
SET RORIS=RORIS+1
SET RORSL=245
+12 SET RORBUF=$EXTRACT(VAL,BASE,BASE+RORSL-1)
SET L=L-RORSL
End DoDot:1
if L'>0
QUIT
+13 SET RORSL=-L
+14 QUIT
+15 ;
+16 ;***** RETURNS THE BHS SEGMENT
+17 ;
+18 ; BID Batch message ID
+19 ;
+20 ; [BDT] Batch message creation time in internal FileMan
+21 ; format (NOW by default)
+22 ;
+23 ; [COMMENT] Optional comment
+24 ;
+25 ; The RORHL local variable must be initialized by the $$INIT^RORHL7
+26 ; function before calling this entry point.
+27 ;
BHS(BID,BDT,COMMENT) ;
+1 NEW CS,SEG,TMP
+2 DO BHS^HLFNC3(.RORHL,BID,.SEG)
+3 if $GET(SEG)=""
QUIT ""
+4 SET HLFS=RORHL("FS")
SET HLECH=RORHL("ECH")
SET CS=$EXTRACT(HLECH,1)
+5 ;--- Post-processing
+6 SET SEG=SEG_$GET(SEG(1))
+7 if $GET(BDT)'>0
SET BDT=$$NOW^XLFDT
+8 SET TMP=$EXTRACT($PIECE($$SITE^VASITE,U,3),1,3)
+9 SET $PIECE(SEG,HLFS,4)=TMP_CS_$GET(^XMB("NETNAME"))_CS_"DNS"
+10 SET $PIECE(SEG,HLFS,5)="ROR AAC"
+11 SET $PIECE(SEG,HLFS,7)=$$FMTHL7^XLFDT(BDT)
+12 SET TMP=$PIECE(SEG,HLFS,9)
+13 SET $PIECE(TMP,CS,3)=$PIECE(TMP,CS,3)_$EXTRACT(HLECH,2)_$GET(RORHL("ETN"))
+14 SET $PIECE(SEG,HLFS,9)=TMP
+15 SET $PIECE(SEG,HLFS,10)=$GET(COMMENT)
+16 QUIT SEG
+17 ;
+18 ;***** RETURNS BTS SEGMENT
+19 ;
+20 ; MSGCNT Batch message count
+21 ; [COMMENT] Batch comment
+22 ;
+23 ; The RORHL variable must be initialized by the INIT^HLFNC2 before
+24 ; calling this entry point
+25 ;
BTS(MSGCNT,COMMENT) ;
+1 QUIT "BTS"_RORHL("FS")_MSGCNT_RORHL("FS")_$GET(COMMENT)
+2 ;
+3 ;***** LOADS THE HL7 FIELD (OR ITS PART) TO THE BUFFER
+4 ;
+5 ; VAL Value of the field (or its part)
+6 ;
+7 ; FLD Number of the field in the segment (piece number)
+8 ;
FIELD(VAL,FLD) ;
+1 NEW BASE,L
+2 if FLD>RORFLD
SET RORFLD=FLD
SET RORIS=0
SET RORSL=245
+3 SET L=$LENGTH(VAL)
SET BASE=1
+4 FOR RORIS=RORIS:1
Begin DoDot:1
+5 IF 'RORIS
SET RORSEG(RORFLD)=$GET(RORSEG(RORFLD))_$EXTRACT(VAL,BASE,BASE+RORSL-1)
+6 IF '$TEST
SET RORSEG(RORFLD,RORIS)=$GET(RORSEG(RORFLD,RORIS))_$EXTRACT(VAL,BASE,BASE+RORSL-1)
+7 SET BASE=BASE+RORSL
SET L=L-RORSL
SET RORSL=245
End DoDot:1
if L'>0
QUIT
+8 SET RORSL=-L
+9 QUIT
+10 ;
+11 ;***** LOADS THE HL7 SEGMENT INTO THE RPOVIDED BUFFER
+12 ;
+13 ; .RORSEG Reference to a local variable where the HL7
+14 ; fields will be stored. The fields are stored
+15 ; in the following format:
+16 ;
+17 ; RORSEG(FldNum)=FldVal
+18 ;
+19 ; If the value is longer that 245 characters then
+20 ; the continuation nodes are created:
+21 ;
+22 ; RORSEG(FldNum,#)=FldValCont
+23 ;
+24 ; ROR8SRC Closed root of the source buffer containing
+25 ; the HL7 segment
+26 ;
LOADSEG(RORSEG,ROR8SRC) ;
+1 NEW BUF,FLD,I,IFL,NFL,RORFLD,RORIS,RORSL
+2 SET HLFS=RORHL("FS")
KILL RORSEG
+3 ;--- Process the main segment
+4 SET BUF=$GET(@ROR8SRC)
SET NFL=$LENGTH(BUF,HLFS)
+5 FOR IFL=1:1:NFL
SET RORSEG(IFL-1)=$PIECE(BUF,HLFS,IFL)
+6 if $DATA(@ROR8SRC)<10
QUIT
+7 ;--- Process the sub-segments
+8 SET (FLD,RORFLD)=NFL-1
SET RORIS=0
SET RORSL=245-$LENGTH(RORSEG(FLD))
+9 SET I=""
+10 FOR
SET I=$ORDER(@ROR8SRC@(I))
if I=""
QUIT
Begin DoDot:1
+11 SET BUF=@ROR8SRC@(I)
SET NFL=$LENGTH(BUF,HLFS)
+12 DO FIELD($PIECE(BUF,HLFS),FLD)
+13 FOR IFL=2:1:NFL
SET FLD=FLD+1
DO FIELD($PIECE(BUF,HLFS,IFL),FLD)
End DoDot:1
+14 QUIT
+15 ;
+16 ;***** RETURNS TEXT EXPLANATIONS OF THE HL7 MESSAGE STATUS
+17 ;
+18 ; MSGST Status value returned by the $$MSGSTAT^HLUTIL
+19 ;
MSGSTXT(MSGST) ;
+1 NEW ST
SET ST=+MSGST
+2 if 'ST
QUIT "Message does not exist"
+3 if ST=1
QUIT "Waiting in queue"
+4 if ST=1.5
QUIT "Opening connection"
+5 if ST=1.7
QUIT "Awaiting response"
+6 if ST=2
QUIT "Awaiting application ack"
+7 if ST=3
QUIT "Successfully completed"
+8 if ST=4
QUIT "Error"
+9 if ST=8
QUIT "Being generated"
+10 if ST=9
QUIT "Awaiting processing"
+11 QUIT "Unknown"
+12 ;
+13 ;***** ASSIGNS THE 'SET ID'
+14 ;
+15 ; SEGNAME Name of the HL7 segment
+16 ; [DISINC] Disable increment of the Set ID
+17 ;
+18 ; Return Values:
+19 ; "" Not required for this segment
+20 ; >0 Value for the Set ID field
+21 ;
SETID(SEGNAME,DISINC) ;
+1 NEW SETID
+2 if $GET(SEGNAME)=""
QUIT ""
+3 SET SETID=+$GET(ROREXT("HL7SID",SEGNAME))
+4 if SETID'>0
QUIT ""
+5 if '$GET(DISINC)
SET ROREXT("HL7SID",SEGNAME)=SETID+1
+6 QUIT SETID