source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCVUTSC.m@ 794

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

initial load of FOIAVistA 6/30/08 version

File size: 2.5 KB
Line 
1PRCVUTSC ;WOIFO/DST - Convert non-formatted string ; 2/11/03 4:52pm
2 ;;5.1;IFCAP;**81**;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5CONV(STR,ACT,SC) ;
6 ;
7 ; Initial data for HL7, HL() array, will be used in this routine.
8 ; Such as HL("ECH"), HL("FS")...
9 ;
10 ; Input:
11 ; STR - A string to be convert
12 ; ACT - Action, E - from escape sequences to special char
13 ; C - from special char to escape sequences
14 ; SC - String of special character used in this HL7 message
15 ; SC char 1 - Field separator
16 ; char 2 - Component separator
17 ; char 3 - Repetition separator
18 ; char 4 - Escape sequence character
19 ; char 5 - Subcomponent separator
20 ;
21 ; Output:
22 ; STR1 - A converted string
23 ;
24 N LEN,SP,SP1,STR1,PRCVFS,PRCVCS,PRCVRS,PRCVES,PRCVSS
25 I $L($G(STR))=0!($L($G(ACT))=0) Q ""
26 S PRCVFS=$E(SC,1)
27 S PRCVCS=$E(SC,2)
28 S PRCVRS=$E(SC,3)
29 S PRCVES=$E(SC,4)
30 S PRCVSS=$E(SC,5)
31 S LEN=$L(STR)
32 I ACT="C" D TOC Q STR1
33 ;
34TOE ; Converted from Escape Sequences to special characters
35 ; PRCVFS <== \F\ Field separator
36 ; PRCVCS <== \S\ Component separator
37 ; PRCVRS <== \R\ Repetition separator
38 ; PRCVES <== \E\ Escape sequence character
39 ; PRCVSS <== \T\ Sub-component separator
40 ;
41 N I,J,K,LEN1,SE,SE1,SP,STR2
42 S LEN1=0
43 S STR1=STR
44 ;
45 ; Go through special characters listed in CH and converted, one by one.
46 ;
47 F K=1:1 Q:$P($T(CH+K),";;",2)']"" D
48 . S SE=$P($P($T(CH+K),";;",2),";",2) ; correspond special character
49 . F I=1:1 S STR2(I)=$P(STR1,SE,I) Q:STR2(I)="" S SE1(I)=SE
50 . K STR2(I)
51 . F J=1:1:I-1 S LEN1=LEN1+$L(STR2(J))+$L(SE1(J))
52 . I LEN1>$L(STR1) K SE1(I-1)
53 . S LEN1=0
54 . S SP=$P($P($T(CH+K),";;",2),";",1)
55 . S STR2=""
56 . F I=1:1 Q:$G(STR2(I))']"" D
57 .. S STR2=STR2_STR2(I)
58 .. S:$D(SE1(I)) STR2=STR2_@SP
59 . S STR1=STR2
60 . K SP,STR2
61 Q STR1
62 ;
63TOC ; Converted from special characters to Escape Sequences
64 ; PRCVFS ==> \F\ Field separator
65 ; PRCVCS ==> \S\ Component separator
66 ; PRCVRS ==> \R\ Repetition separator
67 ; PRCVES ==> \E\ Escape sequence character
68 ; PRCVSS ==> \T\ Sub-component separator
69 ;
70 N C1,I
71 S STR1=""
72 F I=1:1:LEN D
73 . S C1=$E(STR,I)
74 . S STR1=STR1_$S(C1=PRCVFS:"\F\",C1=PRCVCS:"\S\",C1=PRCVRS:"\R\",C1=PRCVES:"\E\",C1=PRCVSS:"\T\",1:C1)
75 . Q
76 Q
77 ;
78CH ; Convert characters
79 ;;PRCVFS;\F\;Field separator
80 ;;PRCVCS;\S\;Component separator
81 ;;PRCVRS;\R\;Repetition separator
82 ;;PRCVES;\E\;Escape sequence character
83 ;;PRCVSS;\T\;Subcomponent separator
84 ;;
Note: See TracBrowser for help on using the repository browser.