source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/VAFHLU.m@ 1742

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

initial load of WorldVistAEHR

File size: 2.0 KB
Line 
1VAFHLU ;BPFO/JRP - SEGMENT BUILDING UTILTIES ;7/12/2002
2 ;;5.3;Registration;**415,508**;Aug 13, 1993
3 ;
4 Q
5MAKEIT(SEGNAME,SEGARR,FIRST245,ADTLNODE) ;Make segment
6 ;Input : SEGNAME - Name of segment being built
7 ; SEGARR - Array continue segment data (pass by value)
8 ; SEGARR(X) = Value for sequence N
9 ; SEGARR(X,Y) = Repetition Y of sequence X
10 ; SEGARR(X,Y,Z) = Component Z of repetition Y of sequence X
11 ; SEGARR(X,Y,Z,A) = Subcomponent A of component Z of
12 ; repetition Y of sequence X
13 ; FIRST245 - Variable to return first 245 characters of
14 ; segment in (pass by value)
15 ; ADTLNODE - Array for continuation nodes (pass by value)
16 ;Assumed: HL7 encoding chars (output of INIT^HLFNC2 or INIT^HLTRANS)
17 ;Output : None
18 ; FIRST245 = First 245 characters of segment
19 ; ADTLNODE(1..n) = Continuation of segment
20 ;Notes : Validity & existance of input is assumed
21 ; : Assumes no single element contained in SEGARR is greater
22 ; than 245 characters
23 ; : Continuation nodes are added at element boundaries
24 ;
25 ;Declare variables
26 N SUB1,SUB2,SUB3,CS,RS,FS,SS,OUTREF,X
27 K FIRST245,ADTLNODE
28 ;Get HL7 separators (attempts to use HL() array)
29 S FS=$S($D(HL("FS")):HL("FS"),1:HLFS)
30 S X=$S($D(HL("ECH")):HL("ECH"),1:HLECH)
31 S CS=$E(X,1),RS=$E(X,2),SS=$E(X,4)
32 ;Build output
33 S OUTREF=$NA(FIRST245)
34 S @OUTREF=SEGNAME
35 I '$O(SEGARR(0)) S X="",Y=FS D ADD Q
36 F SUB1=1:1:$O(SEGARR(""),-1) D
37 .S X=$G(SEGARR(SUB1)),Y=FS D ADD
38 .F SUB2=1:1:$O(SEGARR(SUB1,""),-1) D
39 ..S X=$G(SEGARR(SUB1,SUB2)),Y=$S(SUB2=1:"",1:RS) D ADD
40 ..F SUB3=1:1:$O(SEGARR(SUB1,SUB2,""),-1) D
41 ...S X=$G(SEGARR(SUB1,SUB2,SUB3)),Y=$S(SUB3=1:"",1:CS) D ADD
42 ...F SUB4=1:1:$O(SEGARR(SUB1,SUB2,SUB3,""),-1) D
43 ....S X=$G(SEGARR(SUB1,SUB2,SUB3,SUB4)),Y=$S(SUB4=1:"",1:SS) D ADD
44 Q
45ADD ;Add to output - account for continuation node
46 I ($L(@OUTREF)+$L(X)+1)>245 D
47 .S X1=1+$O(ADTLNODE(""),-1)
48 .S OUTREF=$NA(ADTLNODE(X1))
49 .S @OUTREF=""
50 S @OUTREF=@OUTREF_Y_X
51 Q
Note: See TracBrowser for help on using the repository browser.