source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBCNRHLU.m@ 1608

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

initial load of FOIAVistA 6/30/08 version

File size: 3.7 KB
Line 
1IBCNRHLU ;DAOU/DMK - e-Pharmacy HL7 Utilities ;24-MAY-2004
2 ;;2.0;INTEGRATED BILLING;**251**;21-MAR-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ; Description
6 ;
7 ; e-Pharmacy HL7 Utilities
8 ;
9 ; Entry points:
10 ; TRAN1 - Convert HL7 special characters (specific)
11 ; TRAN2 - Convert HL7 special characters (general)
12 ;
13 Q
14 ;
15TRAN1(VALUE) ; Convert HL7 special characters
16 ;
17 ; Specific to the following standard VistA HL7 application definition
18 ; HL7 FIELD SEPARATOR = |
19 ; HL7 ENCODING CHARACTERS = ^~\&
20 ;
21 ; Input parameter:
22 ; VALUE = HL7 message field, component, or subcomponent value
23 ; Invoked if value contains escape character (\)
24 ;
25 ; Output parameter:
26 ; NEWVALUE = Converted HL7 message field, component, or subcomponent value
27 ;
28 N CONVERT,I,LAST,NEWVALUE,S,S3
29 ;
30 ; Initialize last string position involing converted special character
31 S LAST=0
32 ;
33 ; Initialize scratch string varaible
34 S S=""
35 ;
36 ; Initialize conversion array
37 ;
38 ; | = field separator
39 ; Transferred as \F\ and converted to |
40 S CONVERT("\F\")="|"
41 ;
42 ; ^ = component separator
43 ; Transferred as \S\ and NOT converted to ^ (FileMan delimiter)
44 ;S CONVERT("\S\")="^"
45 ;
46 ; ~ = repetitive separator
47 ; Transferred as \R\ and converted to ~
48 S CONVERT("\R\")="~"
49 ;
50 ; \ = escape character
51 ; Transferred as \E\ and converted to \
52 S CONVERT("\E\")="\"
53 ;
54 ; & = subcomponent separator
55 ; Transferred as \T\ and converted to &
56 S CONVERT("\T\")="&"
57 ;
58 ; Check and covert
59 F I=1:1:$L(VALUE) D
60 . S S=S_$E(VALUE,I)
61 . I (I-3)'<LAST D
62 .. ;
63 .. ; Check last 3 characters and convert if necessary
64 .. S S3=$E(S,$L(S)-2,$L(S))
65 .. I $D(CONVERT(S3)) D
66 ... S LAST=I
67 ... S S=$E(S,1,$L(S)-3)_CONVERT(S3)
68 S NEWVALUE=S
69 Q NEWVALUE
70 ;
71TRAN2(VALUE,HLFS,HLECH) ; Convert HL7 special characters
72 ;
73 ; General to the following:
74 ;
75 ; HL7 Component Separator = $E(HLECH,1)
76 ; HL7 Repetition Separator = $E(HLECH,2) = $E(HL("ECH"),2)
77 ; HL7 Escape Character = $E(HLECH,3) = $E(HL("ECH"),3)
78 ; HL7 Subcomponent = $E(HLECH,4)
79 ;
80 ; Invoked if value contains escape character (VALUE[$E(HL("ECH"),3)
81 ;
82 ; Expected variable
83 ; U = "^"
84 ;
85 ; Input parameters:
86 ; VALUE = HL7 message field, component, or subcomponent value
87 ; HLFS = HL7 field separator = HL7 variable HL("FS")
88 ; HLECH = HL7 encoding characters = HL7 variable HL("ECH")
89 ;
90 ; Output parameter:
91 ; NEWVALUE = Converted HL7 message field, component, or subcomponent value
92 ; Quit if any input parameters undefined
93 I '$D(VALUE)!'$D(HLFS)!'$D(HLECH) Q
94 ;
95 N CONVERT,HLEC,I,LAST,NEWVALUE,S,S3
96 ;
97 ; Initialize HL7 escape character variable
98 S HLEC=$E(HLECH,3)
99 ;
100 ; Initialize last string position involing converted special character
101 S LAST=0
102 ;
103 ; Initialize scratch string varaible
104 S S=""
105 ;
106 ; Initialize conversion array
107 ; Do not covert to caret (^) (FileMan delimiter)
108 ;
109 ; Field separator
110 ; Transferred as HLEC_"F"_HLEC and converted to HLFS
111 S CONVERT(HLEC_"F"_HLEC)=HLFS
112 ;
113 ; Component separator
114 ; Transferred as HLEC_"S"_HLEC and converted to $E(HLECH,1)
115 I $E(HLECH,1)'=U S CONVERT(HLEC_"S"_HLEC)=$E(HLECH,1)
116 ;
117 ; Repetitive separator
118 ; Transferred as HLEC_"R"_HLEC and converted to $E(HLECH,2)
119 I $E(HLECH,2)'=U S CONVERT(HLEC_"R"_HLEC)=$E(HLECH,2)
120 ;
121 ; Escape character
122 ; Transferred as HLEC_"E"_HLEC and converted to $E(HLECH,3)
123 I $E(HLECH,3)'=U S CONVERT(HLEC_"E"_HLEC)=$E(HLECH,3)
124 ;
125 ; Subcomponent separator
126 ; Transferred as HLEC_"T"_HLEC and converted to $E(HLECH,4)
127 I $E(HLECH,4)'=U S CONVERT(HLEC_"T"_HLEC)=$E(HLECH,4)
128 ;
129 ; Check and covert
130 F I=1:1:$L(VALUE) D
131 . S S=S_$E(VALUE,I)
132 . I (I-3)'<LAST D
133 .. ;
134 .. ; Check last 3 characters and convert if necessary
135 .. S S3=$E(S,$L(S)-2,$L(S))
136 .. I $D(CONVERT(S3)) D
137 ... S LAST=I
138 ... S S=$E(S,1,$L(S)-3)_CONVERT(S3)
139 S NEWVALUE=S
140 Q NEWVALUE
Note: See TracBrowser for help on using the repository browser.