ruby-hl7 0.3 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +40 -0
- data/lib/ruby-hl7.rb +112 -69
- data/lib/segments/err.rb +12 -0
- data/lib/segments/evn.rb +1 -1
- data/lib/segments/msa.rb +2 -2
- data/lib/segments/msh.rb +4 -1
- data/lib/segments/nk1.rb +14 -0
- data/lib/segments/nte.rb +1 -1
- data/lib/segments/obr.rb +6 -4
- data/lib/segments/obx.rb +2 -1
- data/lib/segments/orc.rb +34 -0
- data/lib/segments/oru.rb +1 -1
- data/lib/segments/pid.rb +3 -2
- data/lib/segments/pv1.rb +1 -1
- data/lib/segments/pv2.rb +1 -1
- data/lib/segments/qrd.rb +1 -1
- data/lib/segments/qrf.rb +1 -1
- data/lib/segments/sft.rb +15 -0
- data/lib/segments/spm.rb +35 -0
- data/lib/string.rb +5 -0
- data/lib/test/hl7_messages.rb +309 -0
- data/test_data/cerner/cerner_bordetella.hl7 +1 -0
- data/test_data/cerner/cerner_en.hl7 +1 -0
- data/test_data/cerner/cerner_lead.hl7 +1 -0
- data/test_data/cerner/cerner_sequential.hl7 +1 -0
- data/test_data/empty-batch.hl7 +1 -0
- data/test_data/nist/ORU_R01_2.5.1_SampleTestCase1.er7 +1 -0
- data/test_data/nist/ORU_R01_2.5.1_SampleTestCase2.er7 +1 -0
- data/test_data/nist/ORU_R01_2.5.1_SampleTestCase3.er7 +1 -0
- data/test_data/nist/ORU_R01_2.5.1_SampleTestCase4.er7 +1 -0
- data/test_data/nist/ORU_R01_2.5.1_SampleTestCase5.er7 +1 -0
- data/test_data/nist/ORU_R01_2.5.1_SampleTestCase6.er7 +1 -0
- data/test_data/realm/realm-animal-rabies.hl7 +1 -0
- data/test_data/realm/realm-bad-batch.hl7 +1 -0
- data/test_data/realm/realm-batch.hl7 +1 -0
- data/test_data/realm/realm-campylobacter-jejuni.hl7 +1 -0
- data/test_data/realm/realm-cj-badloinc.hl7 +1 -0
- data/test_data/realm/realm-cj-joeslab.hl7 +1 -0
- data/test_data/realm/realm-cj.hl7 +1 -0
- data/test_data/realm/realm-err.hl7 +1 -0
- data/test_data/realm/realm-hepatitis-c-virus.hl7 +1 -0
- data/test_data/realm/realm-lead-laboratory-result.hl7 +2 -0
- data/test_data/realm/realm-minimal-message.hl7 +1 -0
- metadata +85 -39
- data/README +0 -24
- data/test/test_basic_parsing.rb +0 -337
- data/test/test_child_segment.rb +0 -54
- data/test/test_default_segment.rb +0 -31
- data/test/test_dynamic_segment_def.rb +0 -42
- data/test/test_msa_segment.rb +0 -27
- data/test/test_obr_segment.rb +0 -29
- data/test/test_obx_segment.rb +0 -27
- data/test/test_pid_segment.rb +0 -28
- data/test/test_speed_parsing.rb +0 -19
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|HealthSentry^HealthSentry^L|Baseline West MC^33D1234567^L|VISN_OUT^VISN_OUT^L|VISN_OUT^VISN_OUT^L|201011041640||ORU^R01^ORU_R01|201010010913000771|P|2.5.1|||||||||PHLabReport-NoAck^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|HealthSentry^HealthSentry^L|Baseline West MC^33D1234567^L|VISN_OUT^VISN_OUT^L|VISN_OUT^VISN_OUT^L|201011041640||ORU^R01^ORU_R01|201010010913000771|P|2.5.1|||||||||PHLabReport-NoAck^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|HealthSentry^HealthSentry^L|Baseline West MC^33D1234567^L|VISN_OUT^VISN_OUT^L|VISN_OUT^VISN_OUT^L|201010010913||ORU^R01^ORU_R01|201010010913000772|P|2.5.1|||||||||PHLabReport-NoAck^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|HealthSentry^HealthSentry^L|Baseline West MC^33D1234567^L|VISN_OUT^VISN_OUT^L|VISN_OUT^VISN_OUT^L|201011041640||ORU^R01^ORU_R01|201010010913000771|P|2.5.1|||||||||PHLabReport-NoAck^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
FHS|^~\&||Lab1^2.16.840.1.113883.19.3.1^ISO||SPH^2.16.840.1.113883.19.3.2^ISO|20080723123558-0400
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20100929110702||ORU^R01^ORU_R01|NIST-100929110701660|P|2.5.1|||||||||PHLabReport-NoAck^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20100929110745||ORU^R01^ORU_R01|NIST-100929110745131|P|2.5.1|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20100929110828||ORU^R01^ORU_R01|NIST-100929110828087|P|2.5.1|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20100929110904||ORU^R01^ORU_R01|NIST-100929110904401|P|2.5.1|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20100929110939||ORU^R01^ORU_R01|NIST-100929110939497|P|2.5.1|||||||||PHLabReport-NoAck^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20100929111016||ORU^R01^ORU_R01|NIST-100929111015653|P|2.5.1|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~&|Lab1^1234^CLIA|^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
FHS|^~\&||Lab1^2.16.840.1.113883.19.3.1^ISO||SPH^2.16.840.1.113883.19.3.2^ISO|20080723123558-0400
|
@@ -0,0 +1 @@
|
|
1
|
+
FHS|^~\&||Lab1^2.16.840.1.113883.19.3.1^ISO||SPH^2.16.840.1.113883.19.3.2^ISO|20080723123558-0400
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~&|Lab1^1234^CLIA|^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|Lab1^1234^CLIA|^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|Lab1^1234^CLIA|Joe's Lab^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|Lab1^1234^CLIA|Joe's Lab^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~\&|Lab1^1234^CLIA|^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~&|Lab1^1234^CLIA|^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
@@ -0,0 +1,2 @@
|
|
1
|
+
MSH|^~&|Lab1^1234^CLIA|^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
2
|
+
5.1||||||N^Not Hispanic or Latino^HL70189^^^^2.5.1||||||||N|||200808151000-0700|Reliable^2.16.840.1.113883.19.3.1^ISO
|
@@ -0,0 +1 @@
|
|
1
|
+
MSH|^~&|Lab1^1234^CLIA|^1234^CLIA|ELR^2.16.840.1.113883.19.3.2^ISO|SPH^2.16.840.1.113883.19.3.2^ISO|20080818183002.1-0700||ORU^R01^ORU_R01|1234567890|P^T|2.5.1|||NE|NE|USA||||USELR1.0^^2.16.840.1.114222.4.10.3^ISO
|
metadata
CHANGED
@@ -1,37 +1,54 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-hl7
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: "1.0"
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Mark Guzman
|
8
|
-
autorequire:
|
13
|
+
autorequire:
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-12-05 00:00:00 -06:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rake
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 49
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 8
|
32
|
+
- 7
|
23
33
|
version: 0.8.7
|
24
|
-
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rubyforge
|
27
|
-
|
28
|
-
|
29
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
30
41
|
requirements:
|
31
42
|
- - ">="
|
32
43
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
44
|
+
hash: 7
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 0
|
48
|
+
- 4
|
49
|
+
version: 2.0.4
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
35
52
|
description: A simple library to parse and generate HL7 2.x messages
|
36
53
|
email: segfault@hasno.info
|
37
54
|
executables: []
|
@@ -39,31 +56,60 @@ executables: []
|
|
39
56
|
extensions: []
|
40
57
|
|
41
58
|
extra_rdoc_files:
|
42
|
-
- README
|
59
|
+
- README.rdoc
|
43
60
|
- LICENSE
|
44
61
|
files:
|
45
|
-
- lib/ruby-hl7.rb
|
46
|
-
- lib/segments/evn.rb
|
47
|
-
- lib/segments/msa.rb
|
48
62
|
- lib/segments/msh.rb
|
49
|
-
- lib/segments/
|
50
|
-
- lib/segments/obr.rb
|
63
|
+
- lib/segments/msa.rb
|
51
64
|
- lib/segments/obx.rb
|
65
|
+
- lib/segments/spm.rb
|
66
|
+
- lib/segments/err.rb
|
67
|
+
- lib/segments/nte.rb
|
52
68
|
- lib/segments/oru.rb
|
53
|
-
- lib/segments/pid.rb
|
54
69
|
- lib/segments/pv1.rb
|
70
|
+
- lib/segments/orc.rb
|
71
|
+
- lib/segments/sft.rb
|
72
|
+
- lib/segments/obr.rb
|
73
|
+
- lib/segments/qrf.rb
|
74
|
+
- lib/segments/nk1.rb
|
75
|
+
- lib/segments/pid.rb
|
55
76
|
- lib/segments/pv2.rb
|
56
77
|
- lib/segments/qrd.rb
|
57
|
-
- lib/segments/
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
78
|
+
- lib/segments/evn.rb
|
79
|
+
- lib/string.rb
|
80
|
+
- lib/ruby-hl7.rb
|
81
|
+
- lib/test/hl7_messages.rb
|
82
|
+
- test_data/realm/realm-cj-badloinc.hl7
|
83
|
+
- test_data/realm/realm-bad-batch.hl7
|
84
|
+
- test_data/realm/realm-hepatitis-c-virus.hl7
|
85
|
+
- test_data/realm/realm-lead-laboratory-result.hl7
|
86
|
+
- test_data/realm/realm-animal-rabies.hl7
|
87
|
+
- test_data/realm/realm-cj.hl7
|
88
|
+
- test_data/realm/realm-batch.hl7
|
89
|
+
- test_data/realm/realm-campylobacter-jejuni.hl7
|
90
|
+
- test_data/realm/realm-err.hl7
|
91
|
+
- test_data/realm/realm-minimal-message.hl7
|
92
|
+
- test_data/realm/realm-cj-joeslab.hl7
|
61
93
|
- test_data/lotsunknowns.hl7
|
94
|
+
- test_data/test.hl7
|
95
|
+
- test_data/empty_segments.hl7
|
62
96
|
- test_data/obxobr.hl7
|
63
97
|
- test_data/rqi_r04.hl7
|
64
|
-
- test_data/
|
98
|
+
- test_data/cerner/cerner_lead.hl7
|
99
|
+
- test_data/cerner/cerner_bordetella.hl7
|
100
|
+
- test_data/cerner/cerner_sequential.hl7
|
101
|
+
- test_data/cerner/cerner_en.hl7
|
102
|
+
- test_data/empty.hl7
|
103
|
+
- test_data/nist/ORU_R01_2.5.1_SampleTestCase6.er7
|
104
|
+
- test_data/nist/ORU_R01_2.5.1_SampleTestCase4.er7
|
105
|
+
- test_data/nist/ORU_R01_2.5.1_SampleTestCase3.er7
|
106
|
+
- test_data/nist/ORU_R01_2.5.1_SampleTestCase5.er7
|
107
|
+
- test_data/nist/ORU_R01_2.5.1_SampleTestCase2.er7
|
108
|
+
- test_data/nist/ORU_R01_2.5.1_SampleTestCase1.er7
|
109
|
+
- test_data/empty-batch.hl7
|
110
|
+
- test_data/adt_a01.hl7
|
65
111
|
- test_data/test2.hl7
|
66
|
-
- README
|
112
|
+
- README.rdoc
|
67
113
|
- LICENSE
|
68
114
|
has_rdoc: true
|
69
115
|
homepage: http://rubyforge.org/ruby-hl7
|
@@ -75,31 +121,31 @@ rdoc_options: []
|
|
75
121
|
require_paths:
|
76
122
|
- lib
|
77
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
78
125
|
requirements:
|
79
126
|
- - ">="
|
80
127
|
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
|
128
|
+
hash: 59
|
129
|
+
segments:
|
130
|
+
- 1
|
131
|
+
- 8
|
132
|
+
- 6
|
133
|
+
version: 1.8.6
|
83
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
84
136
|
requirements:
|
85
137
|
- - ">="
|
86
138
|
- !ruby/object:Gem::Version
|
139
|
+
hash: 3
|
140
|
+
segments:
|
141
|
+
- 0
|
87
142
|
version: "0"
|
88
|
-
version:
|
89
143
|
requirements: []
|
90
144
|
|
91
145
|
rubyforge_project: ruby-hl7
|
92
|
-
rubygems_version: 1.3.
|
146
|
+
rubygems_version: 1.3.7
|
93
147
|
signing_key:
|
94
148
|
specification_version: 3
|
95
149
|
summary: Ruby HL7 Library
|
96
|
-
test_files:
|
97
|
-
|
98
|
-
- test/test_child_segment.rb
|
99
|
-
- test/test_default_segment.rb
|
100
|
-
- test/test_dynamic_segment_def.rb
|
101
|
-
- test/test_msa_segment.rb
|
102
|
-
- test/test_obr_segment.rb
|
103
|
-
- test/test_obx_segment.rb
|
104
|
-
- test/test_pid_segment.rb
|
105
|
-
- test/test_speed_parsing.rb
|
150
|
+
test_files: []
|
151
|
+
|
data/README
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
=Ruby HL7 Library README
|
2
|
-
|
3
|
-
A simple way to parse and create hl7 2.x messages with ruby.
|
4
|
-
Examples can be found in HL7::Message
|
5
|
-
The version id can be found in the HL7::VERSION constant.
|
6
|
-
|
7
|
-
* Bug tracking: http://trac.hasno.info/ruby-hl7
|
8
|
-
* Subversion: svn://hasno.info/ruby-hl7
|
9
|
-
* Git: git://github.com/segfault/ruby-hl7.git
|
10
|
-
* Docs: http://ruby-hl7.rubyforge.org
|
11
|
-
* Rubyforge: http://rubyforge.org/projects/ruby-hl7
|
12
|
-
* Lists
|
13
|
-
* Developers: mailto:ruby-hl7-devel@rubyforge.org
|
14
|
-
* Users: mailto:ruby-hl7-users@rubyforge.org
|
15
|
-
|
16
|
-
Copyright (c) 2006-2008 Mark Guzman
|
17
|
-
|
18
|
-
== Download and Installation
|
19
|
-
Install the gem using the following command:
|
20
|
-
gem install ruby-hl7
|
21
|
-
|
22
|
-
|
23
|
-
== License
|
24
|
-
see the LICENSE file
|
data/test/test_basic_parsing.rb
DELETED
@@ -1,337 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class BasicParsing < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@simple_msh_txt = open( './test_data/test.hl7' ).readlines.first
|
9
|
-
@empty_txt = open( './test_data/empty.hl7' ).readlines.first
|
10
|
-
@empty_segments_txt = open( './test_data/empty_segments.hl7' ).readlines.first
|
11
|
-
@base_msh = "MSH|^~\\&|LAB1||DESTINATION||19910127105114||ORU^R03|LAB1003929"
|
12
|
-
@base_msh_alt_delims = "MSH$@~\\&|LAB1||DESTINATION||19910127105114||ORU^R03|LAB1003929"
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_simple_msh
|
16
|
-
msg = HL7::Message.new
|
17
|
-
msg.parse @simple_msh_txt
|
18
|
-
assert_equal( @simple_msh_txt, msg.to_hl7 )
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_parse_delims
|
22
|
-
msg = HL7::Message.new( @base_msh )
|
23
|
-
assert_equal( "|", msg.element_delim )
|
24
|
-
assert_equal( "^", msg.item_delim )
|
25
|
-
|
26
|
-
msg = HL7::Message.new( @base_msh_alt_delims )
|
27
|
-
assert_equal( "$", msg.element_delim )
|
28
|
-
assert_equal( "@", msg.item_delim )
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_constructor_parse
|
32
|
-
msg = HL7::Message.new( @simple_msh_txt )
|
33
|
-
assert_equal( @simple_msh_txt, msg.to_hl7 )
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_class_parse
|
37
|
-
msg = HL7::Message.parse( @simple_msh_txt )
|
38
|
-
assert_equal( @simple_msh_txt, msg.to_hl7 )
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_not_string_or_enumerable
|
42
|
-
assert_raise( HL7::ParseError ) do
|
43
|
-
msg = HL7::Message.parse( :MSHthis_shouldnt_parse_at_all )
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_parse_empty
|
48
|
-
msg = HL7::Message.new @empty_txt
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_message_to_string
|
52
|
-
msg = HL7::Message.new
|
53
|
-
msg.parse @simple_msh_txt
|
54
|
-
orig = @simple_msh_txt.gsub( /\r/, "\n" )
|
55
|
-
assert_equal( orig, msg.to_s )
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_to_s_vs_to_hl7
|
59
|
-
msg = HL7::Message.new( @simple_msh_txt )
|
60
|
-
assert_not_equal( msg.to_s, msg.to_hl7 )
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_segment_numeric_accessor
|
64
|
-
msg = HL7::Message.new
|
65
|
-
msg.parse @simple_msh_txt
|
66
|
-
assert_equal( @base_msh, msg[0].to_s )
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_segment_string_accessor
|
70
|
-
msg = HL7::Message.new
|
71
|
-
msg.parse @simple_msh_txt
|
72
|
-
assert_equal( @base_msh, msg["MSH"].to_s )
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_segment_symbol_accessor
|
76
|
-
msg = HL7::Message.new
|
77
|
-
msg.parse @simple_msh_txt
|
78
|
-
assert_equal( @base_msh, msg[:MSH].to_s )
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_segment_numeric_mutator
|
82
|
-
msg = HL7::Message.new
|
83
|
-
msg.parse @simple_msh_txt
|
84
|
-
inp = HL7::Message::Segment::Default.new
|
85
|
-
msg[1] = inp
|
86
|
-
assert_equal( inp, msg[1] )
|
87
|
-
|
88
|
-
assert_raise( HL7::Exception ) do
|
89
|
-
msg[2] = Class.new
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_segment_missing_accessor
|
94
|
-
msg = HL7::Message.new
|
95
|
-
msg.parse @simple_msh_txt
|
96
|
-
assert_nothing_raised do
|
97
|
-
assert_equal( nil, msg[:does_not_exist] )
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_segment_string_mutator
|
102
|
-
msg = HL7::Message.new
|
103
|
-
msg.parse @simple_msh_txt
|
104
|
-
inp = HL7::Message::Segment::NTE.new
|
105
|
-
msg["NTE"] = inp
|
106
|
-
assert_equal( inp, msg["NTE"] )
|
107
|
-
|
108
|
-
assert_raise( HL7::Exception ) do
|
109
|
-
msg["NTE"] = Class.new
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_segment_symbol_accessor
|
114
|
-
msg = HL7::Message.new
|
115
|
-
msg.parse @simple_msh_txt
|
116
|
-
inp = HL7::Message::Segment::NTE.new
|
117
|
-
msg[:NTE] = inp
|
118
|
-
assert_equal( inp, msg[:NTE] )
|
119
|
-
|
120
|
-
assert_raise( HL7::Exception ) do
|
121
|
-
msg[:NTE] = Class.new
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_element_accessor
|
126
|
-
msg = HL7::Message.new
|
127
|
-
msg.parse @simple_msh_txt
|
128
|
-
assert_equal( "LAB1", msg[:MSH].sending_app )
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_element_mutator
|
132
|
-
msg = HL7::Message.new
|
133
|
-
msg.parse @simple_msh_txt
|
134
|
-
msg[:MSH].sending_app = "TEST"
|
135
|
-
assert_equal( "TEST", msg[:MSH].sending_app )
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_element_missing_accessor
|
139
|
-
msg = HL7::Message.new
|
140
|
-
msg.parse @simple_msh_txt
|
141
|
-
assert_raise( HL7::Exception, NoMethodError ) do
|
142
|
-
msg[:MSH].does_not_really_exist_here
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_element_missing_mutator
|
147
|
-
msg = HL7::Message.new
|
148
|
-
msg.parse @simple_msh_txt
|
149
|
-
assert_raise( HL7::Exception, NoMethodError ) do
|
150
|
-
msg[:MSH].does_not_really_exist_here = "TEST"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_element_numeric_accessor
|
155
|
-
msg = HL7::Message.new( @simple_msh_txt )
|
156
|
-
|
157
|
-
assert_equal( "LAB1", msg[:MSH].e2 )
|
158
|
-
assert_equal( "", msg[:MSH].e3 )
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_element_numeric_mutator
|
162
|
-
msg = HL7::Message.parse( @simple_msh_txt )
|
163
|
-
msg[:MSH].e2 = "TESTING1234"
|
164
|
-
assert_equal( "TESTING1234", msg[:MSH].e2 )
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_segment_append
|
168
|
-
msg = HL7::Message.new
|
169
|
-
assert_nothing_raised do
|
170
|
-
msg << HL7::Message::Segment::MSH.new
|
171
|
-
msg << HL7::Message::Segment::NTE.new
|
172
|
-
end
|
173
|
-
|
174
|
-
assert_raises( HL7::Exception ) do
|
175
|
-
msg << Class.new
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
|
180
|
-
def test_segment_sort
|
181
|
-
msg = HL7::Message.new
|
182
|
-
pv1 = HL7::Message::Segment::PV1.new
|
183
|
-
msg << pv1
|
184
|
-
msh = HL7::Message::Segment::MSH.new
|
185
|
-
msg << msh
|
186
|
-
nte = HL7::Message::Segment::NTE.new
|
187
|
-
msg << nte
|
188
|
-
nte2 = HL7::Message::Segment::NTE.new
|
189
|
-
msg << nte
|
190
|
-
msh.sending_app = "TEST"
|
191
|
-
|
192
|
-
|
193
|
-
initial = msg.to_s
|
194
|
-
sorted = msg.sort
|
195
|
-
final = sorted.to_s
|
196
|
-
assert_not_equal( initial, final )
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_segment_auto_set_id
|
200
|
-
msg = HL7::Message.new
|
201
|
-
msh = HL7::Message::Segment::MSH.new
|
202
|
-
msg << msh
|
203
|
-
ntea = HL7::Message::Segment::NTE.new
|
204
|
-
ntea.comment = "first"
|
205
|
-
msg << ntea
|
206
|
-
nteb = HL7::Message::Segment::NTE.new
|
207
|
-
nteb.comment = "second"
|
208
|
-
msg << nteb
|
209
|
-
ntec = HL7::Message::Segment::NTE.new
|
210
|
-
ntec.comment = "third"
|
211
|
-
msg << ntec
|
212
|
-
assert_equal( "1", ntea.set_id )
|
213
|
-
assert_equal( "2", nteb.set_id )
|
214
|
-
assert_equal( "3", ntec.set_id )
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_enumerable_parsing
|
218
|
-
test_file = open( './test_data/test.hl7' )
|
219
|
-
assert_not_nil( test_file )
|
220
|
-
|
221
|
-
msg = HL7::Message.new( test_file )
|
222
|
-
assert_equal( @simple_msh_txt, msg.to_hl7 )
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_segment_to_info
|
226
|
-
msg = HL7::Message.new( @simple_msh_txt )
|
227
|
-
assert_not_nil( msg[1].to_info )
|
228
|
-
end
|
229
|
-
|
230
|
-
def test_segment_use_raw_array
|
231
|
-
inp = "NTE|1|ME TOO"
|
232
|
-
nte = HL7::Message::Segment::NTE.new( inp.split( '|' ) )
|
233
|
-
assert_equal( inp, nte.to_s )
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_mllp_output
|
237
|
-
msg = HL7::Message.new( @simple_msh_txt )
|
238
|
-
expect = "\x0b%s\x1c\r" % msg.to_hl7
|
239
|
-
assert_equal( expect, msg.to_mllp )
|
240
|
-
end
|
241
|
-
|
242
|
-
def test_parse_mllp
|
243
|
-
raw = "\x0b%s\x1c\r" % @simple_msh_txt
|
244
|
-
msg = HL7::Message.parse( raw )
|
245
|
-
assert_not_nil( msg )
|
246
|
-
assert_equal( @simple_msh_txt, msg.to_hl7 )
|
247
|
-
assert_equal( raw, msg.to_mllp )
|
248
|
-
end
|
249
|
-
|
250
|
-
def test_mllp_output_parse
|
251
|
-
msg = HL7::Message.parse( @simple_msh_txt )
|
252
|
-
assert_not_nil( msg )
|
253
|
-
assert_nothing_raised do
|
254
|
-
post_mllp = HL7::Message.parse( msg.to_mllp )
|
255
|
-
assert_not_nil( post_mllp )
|
256
|
-
assert_equal( msg.to_hl7, post_mllp.to_hl7 )
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
def test_child_segment_accessor
|
261
|
-
obr = HL7::Message::Segment::OBR.new
|
262
|
-
assert_nothing_raised do
|
263
|
-
assert_not_nil( obr.children )
|
264
|
-
assert_equal( 0, obr.children.length )
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
def test_child_segment_addition
|
269
|
-
obr = HL7::Message::Segment::OBR.new
|
270
|
-
assert_nothing_raised do
|
271
|
-
assert_equal( 0, obr.children.length )
|
272
|
-
(1..5).each do |x|
|
273
|
-
obr.children << HL7::Message::Segment::OBX.new
|
274
|
-
assert_equal( x, obr.children.length )
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
def test_child_segment_invalid_addition
|
280
|
-
obr = HL7::Message::Segment::OBR.new
|
281
|
-
assert_raises(HL7::Exception) do
|
282
|
-
obr.children << Class.new
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_grouped_sequenced_segments
|
287
|
-
#multible obr's with multiple obx's
|
288
|
-
msg = HL7::Message.parse( @simple_msh_txt )
|
289
|
-
orig_output = msg.to_hl7
|
290
|
-
orig_obx_cnt = msg[:OBX].length
|
291
|
-
(1..10).each do |obr_id|
|
292
|
-
obr = HL7::Message::Segment::OBR.new
|
293
|
-
msg << obr
|
294
|
-
(1..10).each do |obx_id|
|
295
|
-
obx = HL7::Message::Segment::OBX.new
|
296
|
-
obr.children << obx
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
assert_not_nil( msg[:OBR] )
|
301
|
-
assert_equal( 11, msg[:OBR].length )
|
302
|
-
assert_not_nil( msg[:OBX] )
|
303
|
-
assert_equal( 102, msg[:OBX].length )
|
304
|
-
assert_equal( "2", msg[:OBR][4].children[1].set_id ) # confirm the id's
|
305
|
-
assert_equal( "2", msg[:OBR][5].children[1].set_id ) # confirm the id's
|
306
|
-
|
307
|
-
final_output = msg.to_hl7
|
308
|
-
assert_not_equal( orig_output, final_output )
|
309
|
-
end
|
310
|
-
|
311
|
-
def test_index_accessor
|
312
|
-
msg = HL7::Message.parse( @simple_msh_txt )
|
313
|
-
assert_equal( 1, msg.index( "PID" ) )
|
314
|
-
assert_equal( 1, msg.index( :PID ) )
|
315
|
-
assert_equal( 2, msg.index( "PV1" ) )
|
316
|
-
assert_equal( 2, msg.index( :PV1 ) )
|
317
|
-
assert_equal( nil, msg.index( "TACOBELL" ) )
|
318
|
-
assert_equal( nil, msg.index( nil ) )
|
319
|
-
assert_equal( nil, msg.index( 1 ) )
|
320
|
-
end
|
321
|
-
|
322
|
-
def test_segment_field_block
|
323
|
-
pid = HL7::Message::Segment::PID.new
|
324
|
-
assert_raises( HL7::InvalidDataError ) do
|
325
|
-
pid.admin_sex = "TEST"
|
326
|
-
end
|
327
|
-
assert_nothing_raised do
|
328
|
-
pid.admin_sex = "F"
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
def test_empty_segment
|
333
|
-
msg = HL7::Message.new @empty_segments_txt
|
334
|
-
|
335
|
-
end
|
336
|
-
|
337
|
-
end
|