ruby-hl7 1.2.3 → 1.3.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/.gitignore +7 -0
- data/.rubocop.yml +127 -0
- data/.travis.yml +20 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +58 -0
- data/NOTES.md +121 -0
- data/README.rdoc +5 -0
- data/Rakefile +77 -0
- data/VERSION +1 -0
- data/VERSION.yml +4 -0
- data/examples/proxy_server.rb +26 -0
- data/lib/ruby-hl7.rb +1 -1
- data/lib/segments/pid.rb +13 -1
- data/ruby-hl7.gemspec +38 -0
- data/spec/ail_segment_spec.rb +28 -0
- data/spec/aip_segment_spec.rb +31 -0
- data/spec/basic_parsing_spec.rb +319 -0
- data/spec/batch_parsing_spec.rb +52 -0
- data/spec/child_segment_spec.rb +66 -0
- data/spec/core_ext/date_time_spec.rb +43 -0
- data/spec/default_segment_spec.rb +31 -0
- data/spec/dg1_spec.rb +42 -0
- data/spec/dynamic_segment_def_spec.rb +37 -0
- data/spec/err_segment_spec.rb +26 -0
- data/spec/evn_segment_spec.rb +23 -0
- data/spec/fts_segment_spec.rb +19 -0
- data/spec/in1_segment_spec.rb +34 -0
- data/spec/message_spec.rb +53 -0
- data/spec/messages_spec.rb +24 -0
- data/spec/mfe_segment_spec.rb +28 -0
- data/spec/mfi_segment_spec.rb +28 -0
- data/spec/msa_segment_spec.rb +27 -0
- data/spec/msh_segment_spec.rb +28 -0
- data/spec/nk1_segment_spec.rb +26 -0
- data/spec/obr_segment_spec.rb +45 -0
- data/spec/obx_segment_spec.rb +68 -0
- data/spec/orc_segment_spec.rb +27 -0
- data/spec/pid_segment_spec.rb +78 -0
- data/spec/prd_segment_spec.rb +29 -0
- data/spec/pv1_segment_spec.rb +23 -0
- data/spec/rf1_segment_spec.rb +29 -0
- data/spec/sch_segment_spec.rb +32 -0
- data/spec/segment_field_spec.rb +110 -0
- data/spec/segment_generator_spec.rb +32 -0
- data/spec/segment_list_storage_spec.rb +47 -0
- data/spec/segment_spec.rb +38 -0
- data/spec/sft_segment_spec.rb +26 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/speed_parsing_spec.rb +19 -0
- data/spec/spm_segment_spec.rb +26 -0
- metadata +117 -13
- data/lib/segments/zcf.rb +0 -22
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message do
|
5
|
+
context 'batch parsing' do
|
6
|
+
it 'should have a class method HL7::Message.parse_batch' do
|
7
|
+
expect(HL7::Message).to respond_to(:parse_batch)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should raise an exception when parsing an empty batch' do
|
11
|
+
# :empty_batch message contains a valid batch envelope with no
|
12
|
+
# contents
|
13
|
+
expect do
|
14
|
+
HL7::Message.parse_batch HL7MESSAGES[:empty_batch]
|
15
|
+
end.to raise_exception(HL7::ParseError, 'empty_batch_message')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should raise an exception when parsing a single message as a batch' do
|
19
|
+
expect do
|
20
|
+
HL7::Message.parse_batch HL7MESSAGES[:realm_minimal_message]
|
21
|
+
end.to raise_exception(HL7::ParseError, 'badly_formed_batch_message')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should yield multiple messages from a valid batch' do
|
25
|
+
count = 0
|
26
|
+
HL7::Message.parse_batch(HL7MESSAGES[:realm_batch]) do |m|
|
27
|
+
count += 1
|
28
|
+
end
|
29
|
+
expect(count).to eq 2
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'String extension' do
|
35
|
+
before :all do
|
36
|
+
@batch_message = HL7MESSAGES[:realm_batch]
|
37
|
+
@plain_message = HL7MESSAGES[:realm_minimal_message]
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should respond_to :hl7_batch?' do
|
41
|
+
expect(@batch_message.hl7_batch?).to be true
|
42
|
+
expect(@plain_message).to respond_to(:hl7_batch?)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should return true when passed a batch message' do
|
46
|
+
expect(@batch_message).to be_an_hl7_batch
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return false when passed a plain message' do
|
50
|
+
expect(@plain_message).not_to be_an_hl7_batch
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message do
|
5
|
+
context 'child segments' do
|
6
|
+
before :all do
|
7
|
+
@base = open( './test_data/obxobr.hl7' ).readlines
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'allows access to child segments' do
|
11
|
+
msg = HL7::Message.new @base
|
12
|
+
expect(msg).not_to be_nil
|
13
|
+
expect(msg[:OBR]).not_to be_nil
|
14
|
+
expect(msg[:OBR].length).to eq 3
|
15
|
+
expect(msg[:OBR][0].children).not_to be_nil
|
16
|
+
expect(msg[:OBR][0].children.length).to eq 6
|
17
|
+
expect(msg[:OBR][1].children).not_to be_nil
|
18
|
+
expect(msg[:OBR][1].children.length).to eq 3
|
19
|
+
expect(msg[:OBR][2].children).not_to be_nil
|
20
|
+
expect(msg[:OBR][2].children.length).to eq 1
|
21
|
+
expect(msg[:OBX][0].children).not_to be_nil
|
22
|
+
expect(msg[:OBX][0].children.length).to eq 1
|
23
|
+
|
24
|
+
msg[:OBR][0].children.each do |x|
|
25
|
+
expect(x).not_to be_nil
|
26
|
+
end
|
27
|
+
msg[:OBR][1].children.each do |x|
|
28
|
+
expect(x).not_to be_nil
|
29
|
+
end
|
30
|
+
msg[:OBR][2].children.each do |x|
|
31
|
+
expect(x).not_to be_nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'allows adding child segments' do
|
36
|
+
msg = HL7::Message.new @base
|
37
|
+
expect(msg).not_to be_nil
|
38
|
+
expect(msg[:OBR]).not_to be_nil
|
39
|
+
ob = HL7::Message::Segment::OBR.new
|
40
|
+
expect(ob).not_to be_nil
|
41
|
+
|
42
|
+
msg << ob
|
43
|
+
expect(ob.children).not_to be_nil
|
44
|
+
expect(ob.segment_parent).not_to be_nil
|
45
|
+
expect(ob.segment_parent).to eq msg
|
46
|
+
orig_cnt = msg.length
|
47
|
+
|
48
|
+
(1..4).each do |x|
|
49
|
+
m = HL7::Message::Segment::OBX.new
|
50
|
+
m.observation_value = "taco"
|
51
|
+
expect(m).not_to be_nil
|
52
|
+
expect(/taco/.match(m.to_s)).not_to be_nil
|
53
|
+
ob.children << m
|
54
|
+
expect(ob.children.length).to eq x
|
55
|
+
expect(m.segment_parent).not_to be_nil
|
56
|
+
expect(m.segment_parent).to eq ob
|
57
|
+
end
|
58
|
+
|
59
|
+
expect(@base).not_to eq msg.to_hl7
|
60
|
+
expect(msg.length).not_to eq orig_cnt
|
61
|
+
text_ver = msg.to_hl7
|
62
|
+
expect(/taco/.match(text_ver)).not_to be_nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Date do
|
4
|
+
|
5
|
+
subject{ Date.parse('2013-12-02').to_hl7 }
|
6
|
+
|
7
|
+
it "should respond to the HL7 timestamp" do
|
8
|
+
expect(subject).to eq "20131202"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "to_hl7 for time related classes" do
|
13
|
+
|
14
|
+
let(:formated_time){ time_now.strftime('%Y%m%d%H%M%S') }
|
15
|
+
let(:fraction_3){ "." + sprintf('%06d', time_now.to_time.usec)[0, 3] }
|
16
|
+
let(:fraction_9){ "." + sprintf('%06d', time_now.to_time.usec) + ("0" * 3) }
|
17
|
+
|
18
|
+
shared_examples "a time to_hl7" do
|
19
|
+
context "without fraction" do
|
20
|
+
it { expect(time_now.to_time.to_hl7).to eq formated_time }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with_fraction" do
|
24
|
+
it { expect(time_now.to_time.to_hl7(3)).to eq formated_time + fraction_3 }
|
25
|
+
|
26
|
+
it { expect(time_now.to_time.to_hl7(9)).to eq formated_time + fraction_9 }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Time do
|
31
|
+
let(:time_now){ Time.now }
|
32
|
+
|
33
|
+
it_should_behave_like "a time to_hl7"
|
34
|
+
end
|
35
|
+
|
36
|
+
describe DateTime do
|
37
|
+
let(:time_now){ DateTime.now }
|
38
|
+
|
39
|
+
it_should_behave_like "a time to_hl7"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message::Segment::Default do
|
5
|
+
context 'general' do
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
@base_msa = "MSA|AR|ZZ9380 ERR"
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'stores an existing segment' do
|
12
|
+
seg = HL7::Message::Segment::Default.new( @base_msa )
|
13
|
+
expect(seg.to_s).to eq @base_msa
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'converts to a string' do
|
17
|
+
seg = HL7::Message::Segment::Default.new( @base_msa )
|
18
|
+
expect(seg.to_s).to eq @base_msa
|
19
|
+
expect(seg.to_hl7).to eq seg.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'creates a raw segment' do
|
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
|
+
expect(seg.to_s).to eq "NK1|INFO|MORE INFO|||LAST INFO"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/dg1_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe HL7::Message::Segment::DG1 do
|
5
|
+
context "reading" do
|
6
|
+
let(:base_string) do
|
7
|
+
"DG1|1|I9|71596^OSTEOARTHROS NOS-L/LEG ^I9|OSTEOARTHROS NOS-L/LEG |20170615140551-0800||A|"
|
8
|
+
end
|
9
|
+
let(:segment){ HL7::Message::Segment::DG1.new(base_string) }
|
10
|
+
|
11
|
+
it "allows access to an DG1 segment" do
|
12
|
+
expect(segment.set_id).to eq("1")
|
13
|
+
expect(segment.diagnosis_coding_method).to eq("I9")
|
14
|
+
expect(segment.diagnosis_code).to eq("71596^OSTEOARTHROS NOS-L/LEG ^I9")
|
15
|
+
expect(segment.diagnosis_description).to eq("OSTEOARTHROS NOS-L/LEG ")
|
16
|
+
expect(segment.diagnosis_date_time).to eq("20170615140551-0800")
|
17
|
+
expect(segment.diagnosis_type).to eq("")
|
18
|
+
expect(segment.major_diagnostic_category).to eq("A")
|
19
|
+
expect(segment.diagnosis_related_group).to eq("")
|
20
|
+
expect(segment.drg_approval_indicator).to eq(nil)
|
21
|
+
expect(segment.drg_grouper_review_code).to eq(nil)
|
22
|
+
expect(segment.outlier_type).to eq(nil)
|
23
|
+
expect(segment.outlier_days).to eq(nil)
|
24
|
+
expect(segment.outlier_cost).to eq(nil)
|
25
|
+
expect(segment.grouper_version_and_type).to eq(nil)
|
26
|
+
expect(segment.diagnosis_priority).to eq(nil)
|
27
|
+
expect(segment.diagnosis_clinician).to eq(nil)
|
28
|
+
expect(segment.diagnosis_classification).to eq(nil)
|
29
|
+
expect(segment.confidential_indicator).to eq(nil)
|
30
|
+
expect(segment.attestation_date_time).to eq(nil)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "creating" do
|
35
|
+
let(:segment){ HL7::Message::Segment::DG1.new }
|
36
|
+
|
37
|
+
it "allows creation of an DGH segment" do
|
38
|
+
segment.set_id = "2"
|
39
|
+
expect(segment.set_id).to eq("2")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'dynamic segment definition' do
|
5
|
+
context 'general' do
|
6
|
+
it 'accepts a block with a parameter' do
|
7
|
+
seg = HL7::Message::Segment.new do |s|
|
8
|
+
s.e0 = "MSK"
|
9
|
+
s.e1 = "1234"
|
10
|
+
s.e2 = "5678"
|
11
|
+
end
|
12
|
+
|
13
|
+
expect(seg.to_s).to eq "MSK|1234|5678"
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'accepts a block without a parameter' do
|
17
|
+
seg = HL7::Message::Segment.new do
|
18
|
+
e0 "MSK"
|
19
|
+
e1 "1234"
|
20
|
+
e2 "5678"
|
21
|
+
end
|
22
|
+
|
23
|
+
expect(seg.to_s).to eq "MSK|1234|5678"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "doesn't pollute the caller namespace" do
|
27
|
+
seg = HL7::Message::Segment.new do |s|
|
28
|
+
s.e0 = "MSK"
|
29
|
+
s.e1 = "1234"
|
30
|
+
s.e2 = "5678"
|
31
|
+
end
|
32
|
+
|
33
|
+
expect { e3 "TEST" }.to raise_error(NoMethodError)
|
34
|
+
expect(seg.to_s).to eq "MSK|1234|5678"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message::Segment::ERR do
|
5
|
+
context 'general' do
|
6
|
+
before :all do
|
7
|
+
@base_err = 'ERR||OBR^1|100^Segment sequence error^HL70357|E|||Missing required OBR segment|Email help desk for further information on this error||||^NET^Internet^helpdesk@hl7.org'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates an ERR segment' do
|
11
|
+
expect do
|
12
|
+
err = HL7::Message::Segment::ERR.new( @base_err )
|
13
|
+
expect(err).not_to be_nil
|
14
|
+
expect(err.to_s).to eq @base_err
|
15
|
+
end.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows access to an ERR segment' do
|
19
|
+
expect do
|
20
|
+
err = HL7::Message::Segment::ERR.new( @base_err )
|
21
|
+
expect(err.severity).to eq 'E'
|
22
|
+
expect(err.error_location).to eq 'OBR^1'
|
23
|
+
end.not_to raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message::Segment::EVN do
|
5
|
+
context 'general' do
|
6
|
+
before :all do
|
7
|
+
@base = "EVN|A04|20060705000000"
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'allows access to an EVN segment' do
|
11
|
+
evn = HL7::Message::Segment::EVN.new @base
|
12
|
+
expect(evn.type_code).to eq "A04"
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'allows creation of an EVN segment' do
|
16
|
+
evn = HL7::Message::Segment::EVN.new
|
17
|
+
evn.event_facility="A Facility"
|
18
|
+
expect(evn.event_facility).to eq 'A Facility'
|
19
|
+
evn.recorded_date = Date.new 2001,2,3
|
20
|
+
expect(evn.recorded_date).to eq "20010203"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HL7::Message::Segment::FTS do
|
4
|
+
context 'general' do
|
5
|
+
before :all do
|
6
|
+
base_string = 'FTS||End of File'
|
7
|
+
@fts = HL7::Message::Segment::FTS.new(base_string)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates an FTS segment' do
|
11
|
+
expect(@fts).to_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'allows access to an FTS segment' do
|
15
|
+
expect(@fts.file_batch_count).to eq('')
|
16
|
+
expect(@fts.file_trailer_comment).to eq('End of File')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message::Segment::IN1 do
|
5
|
+
context 'general' do
|
6
|
+
before :all do
|
7
|
+
@base_in1 = 'IN1|1||752|ACORDIA NATIONAL||||A|GRP|||||||SMITH^JOHN|19|19700102||||||||||||||||||WC23732763278A|||||||||||||||||X'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates an IN1 segment' do
|
11
|
+
expect do
|
12
|
+
in1 = HL7::Message::Segment::IN1.new( @base_in1 )
|
13
|
+
expect(in1).not_to be_nil
|
14
|
+
expect(in1.to_s).to eq @base_in1
|
15
|
+
end.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows access to an IN1 segment' do
|
19
|
+
expect do
|
20
|
+
in1 = HL7::Message::Segment::IN1.new( @base_in1 )
|
21
|
+
expect(in1.set_id).to eq '1'
|
22
|
+
expect(in1.insurance_company_id).to eq '752'
|
23
|
+
expect(in1.insurance_company_name).to eq 'ACORDIA NATIONAL'
|
24
|
+
expect(in1.group_number).to eq 'A'
|
25
|
+
expect(in1.group_name).to eq 'GRP'
|
26
|
+
expect(in1.name_of_insured).to eq 'SMITH^JOHN'
|
27
|
+
expect(in1.insureds_relationship_to_patient).to eq '19'
|
28
|
+
expect(in1.insureds_date_of_birth).to eq '19700102'
|
29
|
+
expect(in1.policy_number).to eq 'WC23732763278A'
|
30
|
+
expect(in1.vip_indicator).to eq 'X'
|
31
|
+
end.not_to raise_error
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HL7::Message do
|
4
|
+
describe "#correction?" do
|
5
|
+
let(:hl7) { HL7::Message.new data }
|
6
|
+
subject { hl7.correction? }
|
7
|
+
|
8
|
+
context "when is a correction" do
|
9
|
+
let(:data) {
|
10
|
+
[
|
11
|
+
'OBR|1|A241Z^LAB||123456^A TEST^L|||201508181431||1234||||None|201502181432||||OMG123||||20150818143300', # "F" final
|
12
|
+
'OBX|1|ST|123456^AA OBSERVATION^L^4567890^FIRST OBSERVATION^LN||42|ug/dL^Micrograms per Deciliter^UCUM|<10 ug/dL|H|||F||||OMG',
|
13
|
+
'NTE|1||SOME',
|
14
|
+
'NTE|2||THOUGHTS',
|
15
|
+
'OBR|2|A241Z^LAB||123456^A TEST^L|||201508181431||1234||||None|201502181432||||OMG123||||20150818143300', # "C" corrected
|
16
|
+
'OBX|1|ST|123456^AA OBSERVATION^L^4567890^FIRST OBSERVATION^LN||42|ug/dL^Micrograms per Deciliter^UCUM|<10 ug/dL|H|||C||||OMG',
|
17
|
+
'NTE|1||SOME',
|
18
|
+
'NTE|2||THOUGHTS',
|
19
|
+
].join("\r")
|
20
|
+
}
|
21
|
+
|
22
|
+
it { is_expected.to be true }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when is not a correction" do
|
26
|
+
let(:data) {
|
27
|
+
[
|
28
|
+
'OBR|1|A241Z^LAB||123456^A TEST^L|||201508181431||1234||||None|201502181432||||OMG123||||20150818143300', # "F" final
|
29
|
+
'OBX|1|ST|123456^AA OBSERVATION^L^4567890^FIRST OBSERVATION^LN||42|ug/dL^Micrograms per Deciliter^UCUM|<10 ug/dL|H|||F||||OMG',
|
30
|
+
'NTE|1||SOME',
|
31
|
+
'NTE|2||THOUGHTS',
|
32
|
+
'OBR|2|A241Z^LAB||123456^A TEST^L|||201508181431||1234||||None|201502181432||||OMG123||||20150818143300', # "F" final
|
33
|
+
'OBX|1|ST|123456^AA OBSERVATION^L^4567890^FIRST OBSERVATION^LN||42|ug/dL^Micrograms per Deciliter^UCUM|<10 ug/dL|H|||F||||OMG',
|
34
|
+
'NTE|1||SOME',
|
35
|
+
'NTE|2||THOUGHTS',
|
36
|
+
].join("\r")
|
37
|
+
}
|
38
|
+
|
39
|
+
it { is_expected.to be false }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when there are no results (OBX) segments" do
|
43
|
+
let(:data) {
|
44
|
+
[
|
45
|
+
'OBR|1|A241Z^LAB||123456^A TEST^L|||201508181431||1234||||None|201502181432||||OMG123||||20150818143300',
|
46
|
+
'OBR|2|A241Z^LAB||123456^A TEST^L|||201508181431||1234||||None|201502181432||||OMG123||||20150818143300'
|
47
|
+
].join("\r")
|
48
|
+
}
|
49
|
+
|
50
|
+
it { is_expected.to be false }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "HL7 Messages" do
|
4
|
+
it 'processes multiple known messages without failing' do
|
5
|
+
expect do
|
6
|
+
HL7MESSAGES.each_pair do |key, hl7|
|
7
|
+
HL7::Message.new(hl7)
|
8
|
+
end
|
9
|
+
end.not_to raise_exception
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'MFN M13 Messages' do
|
13
|
+
it "extracts the MSH" do
|
14
|
+
expect(HL7::Message.new(HL7MESSAGES[:mfn_m13])[:MSH].sending_app).to eq 'HL7REG'
|
15
|
+
end
|
16
|
+
it 'extracts the MFI' do
|
17
|
+
expect(HL7::Message.new(HL7MESSAGES[:mfn_m13])[:MFI].master_file_identifier).to eq 'HL70006^RELIGION^HL70175'
|
18
|
+
end
|
19
|
+
it 'extracts the MFE' do
|
20
|
+
expect(HL7::Message.new(HL7MESSAGES[:mfn_m13])[:MFE][0].mfn_control_id).to eq '6772333'
|
21
|
+
expect(HL7::Message.new(HL7MESSAGES[:mfn_m13])[:MFE][1].mfn_control_id).to eq '6772334'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|