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
data/test/test_child_segment.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class ChildSegment < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@base = open( './test_data/obxobr.hl7' ).readlines
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_access_children
|
12
|
-
msg = HL7::Message.new @base
|
13
|
-
assert_not_nil msg
|
14
|
-
assert_not_nil msg[:OBR]
|
15
|
-
assert_equal( 3, msg[:OBR].length )
|
16
|
-
assert_not_nil msg[:OBR].first.children
|
17
|
-
assert_equal( 5, msg[:OBR].first.children.length )
|
18
|
-
|
19
|
-
msg[:OBR].first.children.each do |x|
|
20
|
-
assert_not_nil x
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_add_children
|
25
|
-
msg = HL7::Message.new @base
|
26
|
-
assert_not_nil msg
|
27
|
-
assert_not_nil msg[:OBR]
|
28
|
-
ob = HL7::Message::Segment::OBR.new
|
29
|
-
assert_not_nil ob
|
30
|
-
|
31
|
-
msg << ob
|
32
|
-
assert_not_nil ob.children
|
33
|
-
assert_not_nil ob.segment_parent
|
34
|
-
assert_equal(msg, ob.segment_parent)
|
35
|
-
orig_cnt = msg.length
|
36
|
-
|
37
|
-
(1..4).each do |x|
|
38
|
-
m = HL7::Message::Segment::OBX.new
|
39
|
-
m.observation_value = "taco"
|
40
|
-
assert_not_nil m
|
41
|
-
assert_not_nil /taco/.match( m.to_s )
|
42
|
-
ob.children << m
|
43
|
-
assert_equal(x, ob.children.length)
|
44
|
-
assert_not_nil m.segment_parent
|
45
|
-
assert_equal(ob, m.segment_parent)
|
46
|
-
end
|
47
|
-
|
48
|
-
assert_not_equal( @base, msg.to_hl7 )
|
49
|
-
assert_not_equal( orig_cnt, msg.length )
|
50
|
-
text_ver = msg.to_hl7
|
51
|
-
assert_not_nil /taco/.match( text_ver )
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class MsaSegment < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@base_msa = "MSA|AR|ZZ9380 ERR"
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_storing_existing_segment
|
12
|
-
seg = HL7::Message::Segment::Default.new( @base_msa )
|
13
|
-
assert_equal( @base_msa, seg.to_s )
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_to_s
|
17
|
-
seg = HL7::Message::Segment::Default.new( @base_msa )
|
18
|
-
assert_equal( @base_msa, seg.to_s )
|
19
|
-
assert_equal( seg.to_s, seg.to_hl7 )
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_create_raw_segment
|
23
|
-
seg = HL7::Message::Segment::Default.new
|
24
|
-
seg.e0 = "NK1"
|
25
|
-
seg.e1 = "INFO"
|
26
|
-
seg.e2 = "MORE INFO"
|
27
|
-
seg.e5 = "LAST INFO"
|
28
|
-
assert_equal( "NK1|INFO|MORE INFO|||LAST INFO", seg.to_s )
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class DynamicSegmentDefinition < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_block_definition
|
11
|
-
seg = HL7::Message::Segment.new do |s|
|
12
|
-
s.e0 = "MSK"
|
13
|
-
s.e1 = "1234"
|
14
|
-
s.e2 = "5678"
|
15
|
-
end
|
16
|
-
|
17
|
-
assert_equal( "MSK|1234|5678", seg.to_s )
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_ruby_block_initializer
|
21
|
-
seg = HL7::Message::Segment.new do
|
22
|
-
e0 "MSK"
|
23
|
-
e1 "1234"
|
24
|
-
e2 "5678"
|
25
|
-
end
|
26
|
-
|
27
|
-
assert_equal( "MSK|1234|5678", seg.to_s )
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_shouldnt_pollute_caller_namespace
|
31
|
-
seg = HL7::Message::Segment.new do |s|
|
32
|
-
s.e0 = "MSK"
|
33
|
-
s.e1 = "1234"
|
34
|
-
s.e2 = "5678"
|
35
|
-
end
|
36
|
-
|
37
|
-
assert_raises(NoMethodError) do
|
38
|
-
e3 "TEST"
|
39
|
-
end
|
40
|
-
assert_equal( "MSK|1234|5678", seg.to_s )
|
41
|
-
end
|
42
|
-
end
|
data/test/test_msa_segment.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class MsaSegment < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@base_msa = "MSA|AR|ZZ9380 ERR"
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_create_msa
|
12
|
-
assert_nothing_raised do
|
13
|
-
msa = HL7::Message::Segment::MSA.new( @base_msa )
|
14
|
-
assert_not_nil( msa )
|
15
|
-
assert_equal( @base_msa, msa.to_s )
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_access_msa
|
20
|
-
assert_nothing_raised do
|
21
|
-
msa = HL7::Message::Segment::MSA.new( @base_msa )
|
22
|
-
assert_equal( "AR", msa.ack_code )
|
23
|
-
assert_equal( "ZZ9380 ERR", msa.control_id )
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
data/test/test_obr_segment.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class ObrSegment < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@base = "OBR|2|^USSSA|0000000567^USSSA|37956^CT ABDOMEN^LN|||199405021550|||||||||||||0000763|||||P||||||R/O TUMOR|202300&BAKER&MARK&E|||01&LOCHLEAR&JUDY"
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_read
|
12
|
-
obr = HL7::Message::Segment::OBR.new @base
|
13
|
-
assert_equal( @base, obr.to_s )
|
14
|
-
assert_equal( "2", obr.e1 )
|
15
|
-
assert_equal( "2", obr.set_id )
|
16
|
-
assert_equal( "^USSSA", obr.placer_order_number )
|
17
|
-
assert_equal( "0000000567^USSSA", obr.filler_order_number )
|
18
|
-
assert_equal( "37956^CT ABDOMEN^LN", obr.universal_service_id )
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_create
|
22
|
-
obr = HL7::Message::Segment::OBR.new
|
23
|
-
obr.set_id = 1
|
24
|
-
assert_equal( "1", obr.set_id )
|
25
|
-
obr.placer_order_number = "^DMCRES"
|
26
|
-
assert_equal( "^DMCRES", obr.placer_order_number )
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
data/test/test_obx_segment.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class ObxSegment < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@base = "OBX||TX|FIND^FINDINGS^L|1|This is a test on 05/02/94."
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_initial_read
|
12
|
-
obx = HL7::Message::Segment::OBX.new @base
|
13
|
-
assert_equal( "", obx.set_id )
|
14
|
-
assert_equal( "TX", obx.value_type )
|
15
|
-
assert_equal( "FIND^FINDINGS^L", obx.observation_id )
|
16
|
-
assert_equal( "1", obx.observation_sub_id )
|
17
|
-
assert_equal( "This is a test on 05/02/94.", obx.observation_value )
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_creation
|
21
|
-
obx = HL7::Message::Segment::OBX.new
|
22
|
-
obx.value_type = "TESTIES"
|
23
|
-
obx.observation_id = "HR"
|
24
|
-
obx.observation_sub_id = "2"
|
25
|
-
obx.observation_value = "SOMETHING HAPPENned"
|
26
|
-
end
|
27
|
-
end
|
data/test/test_pid_segment.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-hl7'
|
5
|
-
|
6
|
-
class PidSegment < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@base = "PID|||333||LastName^FirstName^MiddleInitial^SR^NickName||19760228|F||||||||||555. 55|012345678"
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_admin_sex_limits
|
12
|
-
pid = HL7::Message::Segment::PID.new
|
13
|
-
assert_nothing_raised do
|
14
|
-
vals = %w[F M O U A N] + [ nil ]
|
15
|
-
vals.each do |x|
|
16
|
-
pid.admin_sex = x
|
17
|
-
end
|
18
|
-
pid.admin_sex = ""
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_raises( HL7::InvalidDataError ) do
|
22
|
-
["TEST", "A", 1, 2].each do |x|
|
23
|
-
pid.admin_sex = x
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/test/test_speed_parsing.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
$: << '../lib'
|
3
|
-
require 'time'
|
4
|
-
require 'test/unit'
|
5
|
-
require 'ruby-hl7'
|
6
|
-
|
7
|
-
class SpeedParsing < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
@msg = open( "./test_data/lotsunknowns.hl7" ).readlines
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_large_unknown_segments
|
13
|
-
start = Time.now
|
14
|
-
doc = HL7::Message.new @msg
|
15
|
-
assert_not_nil doc
|
16
|
-
ends = Time.now
|
17
|
-
assert ((ends-start) < 1)
|
18
|
-
end
|
19
|
-
end
|