source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMSVUT5.m@ 824

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

initial load of WorldVistAEHR

File size: 4.0 KB
Line 
1SCMSVUT5 ;BPFO/JRP - IEMM UTILTIES (CONT);7/29/2002
2 ;;5.3;Scheduling;**254,293**;Aug 13, 1993
3 ;
4PARSE(INARR,OUTARR,SEP,SUB,MAX) ;Parse array into individual fields
5 ;Input : INARR - Array containing data to parse (full global ref)
6 ; INARR = First 245 characters of data
7 ; INARR(1..n) = Continuation nodes
8 ; OR
9 ; INARR(x) = First 245 characters of data
10 ; INARR(x,1..n) = Continuation nodes
11 ; OUTARR - Array to put parsed data into (full global ref)
12 ; SEP - Field separator (defaults to ^) (1 character)
13 ; SUB - Starting subscript of OUTARR (defaults to 0)
14 ; MAX - Maximum length of output node (defaults to 245)
15 ;Output : None
16 ; OUTARR(SUB) = First piece (MAX characters)
17 ; OUTARR(SUB,1..n) = Continuation nodes
18 ; OUTARR(SUB+X) = Xth piece (MAX characters)
19 ; OUTARR(SUB+X,1..n) = Continuation nodes
20 ;Notes : OUTARR is initialized (KILLed) on entry
21 ; : Assumes that INARR and OUTARR are defined and valid
22 ;
23 ;Declare variables
24 N NODE,STOP,DATA,INFO,FLD,SEPCNT,CN,OUT,TMP,ROOT,OUTNODE
25 K @OUTARR
26 S SEP=$G(SEP) S SEP=$E(SEP,1) S:SEP="" SEP="^"
27 S SUB=+$G(SUB)
28 S MAX=+$G(MAX) S:'MAX MAX=245
29 S NODE=INARR
30 S INFO=$G(@NODE)
31 S ROOT=$$OREF^DILF(INARR)
32 S FLD=1
33 S SEPCNT=$L(INFO,SEP)
34 S STOP=0
35 S OUTNODE=$NA(@OUTARR@(SUB))
36 S CN=0
37 F S DATA=$P(INFO,SEP,FLD) D Q:STOP
38 .I FLD=SEPCNT D Q
39 ..D ADDNODE
40 ..S NODE=$Q(@NODE)
41 ..I (NODE="")!(NODE'[ROOT) S STOP=1 Q
42 ..S INFO=$G(@NODE)
43 ..S SEPCNT=$L(INFO,SEP)
44 ..S FLD=1
45 .D ADDNODE
46 .S SUB=SUB+1
47 .S CN=0
48 .S OUTNODE=$NA(@OUTARR@(SUB))
49 .S FLD=FLD+1
50 Q
51ADDNODE ;Used by PARSE to add data to output node (handles continuation nodes)
52 S TMP=$G(@OUTNODE)
53 I ($L(TMP)+$L(DATA))<(MAX+1) S @OUTNODE=TMP_DATA Q
54 S @OUTNODE=TMP_$E(DATA,1,(MAX-$L(TMP)))
55 S CN=CN+1
56 S DATA=$E(DATA,(MAX-$L(TMP)+1),$L(DATA))
57 S OUTNODE=$NA(@OUTARR@(SUB,CN))
58 I DATA'="" D ADDNODE
59 Q
60 ;
61 ;
62SEGPRSE(SEGMENT,OUTARR,FS) ;Parse HL7 segment by field separator
63 ;Input : SEGMENT - Array containing HL7 segment to parse
64 ; (full global ref)
65 ; SEGMENT = First 245 characters of segment
66 ; SEGMENT(1..n) = Continuation nodes
67 ; OR
68 ; SEGMENT(x) = First 245 characters of segment
69 ; SEGMENT(x,1..n) = Continuation nodes
70 ; OUTARR - Array to put parsed segment into (full global ref)
71 ; FS - HL7 field separator (defaults to ^) (1 character)
72 ;Output : None
73 ; OUTARR(0) = Segment name
74 ; OUTARR(seq#) = Data (first 245 characters)
75 ; OUTARR(seq#,1..n) Continuation nodes
76 ;Notes : OUTARR is initialized (KILLed) on entry
77 ; : Assumes SEGMENT and OUTARR are defined and valid
78 ;
79 D PARSE($G(SEGMENT),$G(OUTARR),$G(FS),0,245)
80 Q
81 ;
82SEQPRSE(SEQDATA,OUTARR,ENCODE) ;Parse HL7 sequence by component
83 ;Input : SEQDATA - Array containing seq to parse (full global ref)
84 ; SEQDATA = First 245 characters of sequence
85 ; SEQDATA(1..n) = Continuation nodes
86 ; OR
87 ; SEQDATA(x) = First 245 characters of sequence
88 ; SEQDATA(x,1..n) = Continuation nodes
89 ; OUTARR - Array to put parsed sequence into (full global ref)
90 ; ENCODE - HL7 encoding characters (defaults to ~|\&) (4 chars)
91 ;Output : None
92 ; OUTARR(rep#,comp#) = Data (first 245 characters)
93 ; OUTARR(rep#,comp#,1..n) = Continuation nodes
94 ;Notes : OUTARR is initialized (KILLed) on entry
95 ; : Assumes SEQDATA and OUTARR are defined and valid
96 ;
97 ;Declare variables
98 N RS,CS,INFO,DATA,REP,COMP
99 S ENCODE=$G(ENCODE,"~|\&")
100 S ENCODE=$E(ENCODE,1,4) S:$L(ENCODE)'=4 ENCODE="~|\&"
101 S CS=$E(ENCODE,1)
102 S RS=$E(ENCODE,2)
103 S INFO=$NA(^TMP("SCMSVUT5",$J,"SEQPRSE"))
104 D PARSE($G(SEQDATA),INFO,RS,1,245)
105 S REP=0
106 F S REP=+$O(@INFO@(REP)) Q:'REP D PARSE($NA(@INFO@(REP)),$NA(@OUTARR@(REP)),CS,1,245)
107 K @INFO
108 Q
109
Note: See TracBrowser for help on using the repository browser.