ruby-hl7 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +2 -1
- data/lib/message.rb +5 -0
- data/lib/ruby-hl7.rb +1 -1
- data/lib/segment.rb +6 -0
- data/lib/segments/mfe.rb +10 -0
- data/lib/segments/mfi.rb +13 -0
- data/lib/segments/obx.rb +4 -1
- data/lib/segments/sft.rb +0 -6
- data/lib/test/hl7_messages.rb +30 -24
- metadata +11 -46
- data/.gitignore +0 -6
- data/.travis.yml +0 -15
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -37
- data/NOTES.md +0 -53
- data/Rakefile +0 -149
- data/VERSION +0 -1
- data/VERSION.yml +0 -4
- data/examples/proxy_server.rb +0 -26
- data/ruby-hl7.gemspec +0 -44
- data/spec/basic_parsing_spec.rb +0 -320
- data/spec/batch_parsing_spec.rb +0 -52
- data/spec/child_segment_spec.rb +0 -66
- data/spec/core_ext/date_time_spec.rb +0 -43
- data/spec/default_segment_spec.rb +0 -31
- data/spec/dynamic_segment_def_spec.rb +0 -37
- data/spec/err_segment_spec.rb +0 -26
- data/spec/evn_segment_spec.rb +0 -23
- data/spec/msa_segment_spec.rb +0 -27
- data/spec/msh_segment_spec.rb +0 -28
- data/spec/nk1_segment_spec.rb +0 -26
- data/spec/obr_segment_spec.rb +0 -45
- data/spec/obx_segment_spec.rb +0 -46
- data/spec/orc_segment_spec.rb +0 -27
- data/spec/pid_segment_spec.rb +0 -70
- data/spec/prd_segment_spec.rb +0 -29
- data/spec/pv1_segment_spec.rb +0 -23
- data/spec/rf1_segment_spec.rb +0 -29
- data/spec/segment_field_spec.rb +0 -92
- data/spec/segment_generator_spec.rb +0 -32
- data/spec/segment_list_storage_spec.rb +0 -47
- data/spec/segment_spec.rb +0 -27
- data/spec/sft_segment_spec.rb +0 -26
- data/spec/spec_helper.rb +0 -12
- data/spec/speed_parsing_spec.rb +0 -19
- data/spec/spm_segment_spec.rb +0 -26
data/spec/prd_segment_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::PRD do
|
5
|
-
context 'general' do
|
6
|
-
let (:base) { 'PRD|RP|LastName^FirstName^MiddleInitial^SR^NickName|444 Home Street^Apt B^Ann Arbor^MI^99999^USA|^^^A Wonderful Clinic|^WPN^PH^^^07^5555555|PH|4796^AUSHICPR|20130109163307+1000|20140109163307+1000' }
|
7
|
-
let (:prd) { HL7::Message::Segment::PRD.new base }
|
8
|
-
|
9
|
-
it 'should set the provider_role' do
|
10
|
-
prd.provider_role.should eql 'RP'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should set the name' do
|
14
|
-
prd.provider_name.should eql 'LastName^FirstName^MiddleInitial^SR^NickName'
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should set the provider_address' do
|
18
|
-
prd.provider_address.should eql '444 Home Street^Apt B^Ann Arbor^MI^99999^USA'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should set the provider_location' do
|
22
|
-
prd.provider_location.should eql '^^^A Wonderful Clinic'
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should set provider_communication_information' do
|
26
|
-
prd.provider_communication_information.should eql '^WPN^PH^^^07^5555555'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/spec/pv1_segment_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::PV1 do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base = "PV1||R|||||||||||||||A|||V02^19900607~H02^19900607"
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'allows access to an PV1 segment' do
|
11
|
-
pv1 = HL7::Message::Segment::PV1.new @base
|
12
|
-
pv1.patient_class.should == "R"
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'allows creation of an OBX segment' do
|
16
|
-
pv1= HL7::Message::Segment::PV1.new
|
17
|
-
pv1.referring_doctor="Smith^John"
|
18
|
-
pv1.referring_doctor.should == "Smith^John"
|
19
|
-
pv1.admit_date = Date.new(2014, 1, 1)
|
20
|
-
pv1.admit_date.should == '20140101'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/spec/rf1_segment_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::RF1 do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base = 'RF1|P^Pending^HL70283|R^Routine^HL70280|GRF^General referral^HL70281|AM^Assume management^HL70282||8094|20060705||20060705||42'
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'allows access to an RF1 segment' do
|
12
|
-
rf1 = HL7::Message::Segment::RF1.new @base
|
13
|
-
rf1.referral_status.should == 'P^Pending^HL70283'
|
14
|
-
rf1.referral_priority.should == 'R^Routine^HL70280'
|
15
|
-
rf1.referral_type.should == 'GRF^General referral^HL70281'
|
16
|
-
rf1.referral_disposition.should == 'AM^Assume management^HL70282'
|
17
|
-
rf1.originating_referral_identifier.should == '8094'
|
18
|
-
rf1.effective_date.should == '20060705'
|
19
|
-
rf1.process_date.should == '20060705'
|
20
|
-
rf1.external_referral_identifier.should == '42'
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'allows creation of an RF1 segment' do
|
24
|
-
rf1 = HL7::Message::Segment::RF1.new
|
25
|
-
rf1.expiration_date=Date.new(2058, 12, 1)
|
26
|
-
rf1.expiration_date.should == '20581201'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/spec/segment_field_spec.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
class MockSegment < HL7::Message::Segment
|
5
|
-
weight 1
|
6
|
-
add_field :no_block
|
7
|
-
alias_field :no_block_alias, :no_block
|
8
|
-
add_field :validating do |value|
|
9
|
-
value == "bad" ? nil : value
|
10
|
-
end
|
11
|
-
add_field :converting do |value|
|
12
|
-
"X" + value
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe HL7::Message::Segment do
|
17
|
-
before :all do
|
18
|
-
@base = "Mock|no_block|validated|converted"
|
19
|
-
end
|
20
|
-
|
21
|
-
context "block on field definitions" do
|
22
|
-
it 'is evaluated on access by field name' do
|
23
|
-
msg = MockSegment.new(@base)
|
24
|
-
|
25
|
-
msg.to_s.should == @base
|
26
|
-
msg.no_block.should == "no_block"
|
27
|
-
msg.validating.should == "validated"
|
28
|
-
msg.converting.should == "Xconverted"
|
29
|
-
|
30
|
-
msg.no_block = "NO_BLOCK"
|
31
|
-
msg.no_block.should == "NO_BLOCK"
|
32
|
-
|
33
|
-
msg.validating = "good"
|
34
|
-
msg.validating.should == "good"
|
35
|
-
msg.validating = "bad"
|
36
|
-
msg.validating.should == ""
|
37
|
-
|
38
|
-
msg.converting = "empty"
|
39
|
-
msg.converting.should == "XXempty"
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'is not evaluated on read access by eXXX alias' do
|
43
|
-
msg = MockSegment.new(@base)
|
44
|
-
|
45
|
-
msg.e1.should == "no_block"
|
46
|
-
msg.e2.should == "validated"
|
47
|
-
msg.e3.should == "converted"
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'is not evaluated on write access by eXXX alias' do
|
51
|
-
msg = MockSegment.new(@base)
|
52
|
-
|
53
|
-
msg.e1 = "NO_BLOCK"
|
54
|
-
msg.e1.should == "NO_BLOCK"
|
55
|
-
|
56
|
-
msg.e2 = "good"
|
57
|
-
msg.e2.should == "good"
|
58
|
-
msg.e2 = "bad"
|
59
|
-
msg.e2.should == "bad"
|
60
|
-
|
61
|
-
msg.e3 = "empty"
|
62
|
-
msg.e3.should == "empty"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#alias_field' do
|
67
|
-
context 'with a valid field' do
|
68
|
-
it 'uses alias field names' do
|
69
|
-
msg = MockSegment.new(@base)
|
70
|
-
msg.no_block.should == "no_block"
|
71
|
-
msg.no_block_alias.should == "no_block"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'with an invalid field' do
|
76
|
-
|
77
|
-
class MockInvalidSegment < HL7::Message::Segment
|
78
|
-
weight 1
|
79
|
-
add_field :no_block
|
80
|
-
alias_field :no_block_alias, :invalid_field
|
81
|
-
add_field :second
|
82
|
-
add_field :third
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
it 'throws an error when the field is invalid' do
|
87
|
-
msg = MockInvalidSegment.new(@base)
|
88
|
-
lambda{ msg.no_block_alias }.should raise_error
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HL7::Message::SegmentGenerator do
|
4
|
-
describe 'valid_segments_parts?' do
|
5
|
-
|
6
|
-
let(:element){ "MSH|1|2|3" }
|
7
|
-
let(:delimiter){ HL7::Message::Delimiter.new('|', '^', '\r') }
|
8
|
-
let(:segment_generator) do
|
9
|
-
HL7::Message::SegmentGenerator.new(element, nil, delimiter)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return true if @seg_parts is an array of one element or more" do
|
13
|
-
segment_generator.valid_segments_parts?.should be true
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'when is empty' do
|
17
|
-
it "should return false if empty_segment_is_error is false" do
|
18
|
-
segment_generator.seg_parts = nil
|
19
|
-
HL7.ParserConfig[:empty_segment_is_error] = false
|
20
|
-
segment_generator.valid_segments_parts?.should be false
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should raise an error if empty_segment_is_error is true" do
|
24
|
-
HL7.ParserConfig[:empty_segment_is_error] = true
|
25
|
-
segment_generator.seg_parts = nil
|
26
|
-
expect do
|
27
|
-
segment_generator.valid_segments_parts?
|
28
|
-
end.to raise_error HL7::EmptySegmentNotAllowed
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class SegmentNoChildren< HL7::Message::Segment
|
4
|
-
end
|
5
|
-
|
6
|
-
class SegmentWithChildren < HL7::Message::Segment
|
7
|
-
has_children [:NTE,:ORC,:SPM]
|
8
|
-
end
|
9
|
-
|
10
|
-
describe HL7::Message::SegmentListStorage do
|
11
|
-
describe "self#add_child_type" do
|
12
|
-
it "should allow to add a new segment type as child" do
|
13
|
-
SegmentWithChildren.add_child_type :OBR
|
14
|
-
segment = SegmentWithChildren.new
|
15
|
-
segment.accepts?(:OBR).should be true
|
16
|
-
segment.child_types.should include :OBR
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "Adding children has_children and add_child_type" do
|
21
|
-
subject do
|
22
|
-
segment_instance = segment_class.new
|
23
|
-
[:accepts?, :child_types, :children].each do |method|
|
24
|
-
segment_instance.respond_to?(method).should be true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "when child_types is not present" do
|
29
|
-
let(:segment_class){ SegmentNoChildren }
|
30
|
-
|
31
|
-
it "by adding add_child_type should respond to the children methods" do
|
32
|
-
segment_instance = segment_class.new
|
33
|
-
segment_instance.respond_to?(:children).should be false
|
34
|
-
segment_class.add_child_type(:OBR)
|
35
|
-
subject
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "when child_types is present" do
|
40
|
-
let(:segment_class){ SegmentWithChildren }
|
41
|
-
|
42
|
-
it "should respond to the children methods" do
|
43
|
-
subject
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/spec/segment_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HL7::Message::Segment do
|
4
|
-
describe 'length' do
|
5
|
-
|
6
|
-
it "should return the length of the elements" do
|
7
|
-
segment = HL7::Message::Segment.new "MSA|AR|ZZ9380 ERR"
|
8
|
-
segment.length.should eq 3
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'is_child_segment?' do
|
13
|
-
let(:segment){ HL7::Message::Segment.new "MSA|AR|ZZ9380 ERR" }
|
14
|
-
it "return false when is not set" do
|
15
|
-
segment.is_child_segment?.should be false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'convert_to_ts' do
|
20
|
-
let(:time_now){ DateTime.now }
|
21
|
-
let(:formated_time){ time_now.strftime('%Y%m%d%H%M%S') }
|
22
|
-
|
23
|
-
it "should conver to the hl7 time format" do
|
24
|
-
HL7::Message::Segment.convert_to_ts(time_now).should eq formated_time
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/sft_segment_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::SFT do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base_sft = 'SFT|1|Level Seven Healthcare Software, Inc.^L^^^^&2.16.840.1.113883.19.4.6^ISO^XX^^^1234|1.2|An Lab System|56734||20080817'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'creates an SFT segment' do
|
11
|
-
lambda do
|
12
|
-
sft = HL7::Message::Segment::SFT.new( @base_sft )
|
13
|
-
sft.should_not be_nil
|
14
|
-
sft.to_s.should == @base_sft
|
15
|
-
end.should_not raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows access to an SFT segment' do
|
19
|
-
lambda do
|
20
|
-
sft = HL7::Message::Segment::SFT.new( @base_sft )
|
21
|
-
sft.software_product_name.should == 'An Lab System'
|
22
|
-
sft.software_install_date.should == '20080817'
|
23
|
-
end.should_not raise_error
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
|
-
if ENV["COVERAGE"]
|
4
|
-
SimpleCov.start do
|
5
|
-
add_filter "/test/"
|
6
|
-
add_filter "/spec/"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
# ruby-hl7 loads the rest of the files in lib
|
11
|
-
require File.expand_path('../../lib/ruby-hl7', __FILE__)
|
12
|
-
require File.expand_path('../../lib/test/hl7_messages', __FILE__)
|
data/spec/speed_parsing_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'time'
|
4
|
-
|
5
|
-
describe HL7::Message do
|
6
|
-
context 'speed parsing' do
|
7
|
-
before :all do
|
8
|
-
@msg = open( "./test_data/lotsunknowns.hl7" ).readlines
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'parses large, unknown segments rapidly' do
|
12
|
-
start = Time.now
|
13
|
-
doc = HL7::Message.new @msg
|
14
|
-
doc.should_not be_nil
|
15
|
-
ends = Time.now
|
16
|
-
(ends-start).should be < 1
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/spec/spm_segment_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::SPM do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base_spm = 'SPM|1|23456&EHR&2.16.840.1.113883.19.3.2.3&ISO^9700122&Lab&2.16.840.1.113883.19.3.1.6&ISO||122554006^Capillary blood specimen^SCT^BLDC^Blood capillary^HL70070^20080131^2.5.1||HEPA^Ammonium heparin^HL70371^^^^2.5.1|CAP^Capillary Specimen^HL70488^^^^2.5.1|181395001^Venous structure of digit^SCT^^^^20080731|||P^Patient^HL60369^^^^2.5.1|50^uL&Micro Liter&UCUM&&&&1.6|||||200808151030-0700|200808151100-0700'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'creates an SPM segment' do
|
11
|
-
lambda do
|
12
|
-
spm = HL7::Message::Segment::SPM.new( @base_spm )
|
13
|
-
spm.should_not be_nil
|
14
|
-
spm.to_s.should == @base_spm
|
15
|
-
end.should_not raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows access to an SPM segment' do
|
19
|
-
lambda do
|
20
|
-
spm = HL7::Message::Segment::SPM.new( @base_spm )
|
21
|
-
spm.specimen_type.should == '122554006^Capillary blood specimen^SCT^BLDC^Blood capillary^HL70070^20080131^2.5.1'
|
22
|
-
spm.set_id.should == '1'
|
23
|
-
end.should_not raise_error
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|