ruby-hl7 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/configuration.rb +30 -0
- data/lib/core_ext/date_time.rb +19 -15
- data/lib/core_ext/string.rb +2 -0
- data/lib/helpers/time_formatter_helper.rb +42 -0
- data/lib/message.rb +72 -75
- data/lib/message_parser.rb +17 -15
- data/lib/ruby-hl7.rb +26 -16
- data/lib/segment.rb +63 -47
- data/lib/segment_default.rb +6 -4
- data/lib/segment_fields.rb +27 -25
- data/lib/segment_generator.rb +12 -15
- data/lib/segment_list_storage.rb +15 -14
- data/lib/segments/aig.rb +2 -0
- data/lib/segments/ail.rb +2 -0
- data/lib/segments/aip.rb +2 -0
- data/lib/segments/ais.rb +2 -0
- data/lib/segments/dg1.rb +2 -10
- data/lib/segments/err.rb +2 -0
- data/lib/segments/evn.rb +2 -1
- data/lib/segments/ft1.rb +13 -13
- data/lib/segments/fts.rb +2 -0
- data/lib/segments/gt1.rb +4 -6
- data/lib/segments/in1.rb +2 -1
- data/lib/segments/mfe.rb +2 -0
- data/lib/segments/mfi.rb +2 -0
- data/lib/segments/mrg.rb +2 -0
- data/lib/segments/msa.rb +2 -2
- data/lib/segments/msh.rb +3 -2
- data/lib/segments/nk1.rb +48 -8
- data/lib/segments/nte.rb +6 -5
- data/lib/segments/obr.rb +4 -3
- data/lib/segments/obx.rb +2 -1
- data/lib/segments/orc.rb +8 -10
- data/lib/segments/oru.rb +2 -1
- data/lib/segments/pid.rb +19 -10
- data/lib/segments/prd.rb +2 -1
- data/lib/segments/prt.rb +23 -0
- data/lib/segments/pv1.rb +2 -1
- data/lib/segments/pv2.rb +64 -51
- data/lib/segments/qrd.rb +2 -1
- data/lib/segments/qrf.rb +2 -1
- data/lib/segments/rf1.rb +2 -1
- data/lib/segments/rgs.rb +2 -0
- data/lib/segments/rol.rb +22 -0
- data/lib/segments/sch.rb +2 -0
- data/lib/segments/sft.rb +2 -0
- data/lib/segments/spm.rb +2 -0
- data/lib/segments/tq1.rb +2 -0
- data/lib/segments/txa.rb +2 -0
- data/lib/test/hl7_messages.rb +118 -117
- data/lib/version.rb +5 -0
- metadata +14 -163
- data/.gitignore +0 -7
- data/.rubocop.yml +0 -127
- data/.travis.yml +0 -20
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -65
- data/LICENSE +0 -19
- data/NOTES.md +0 -151
- data/README.rdoc +0 -47
- data/Rakefile +0 -76
- data/VERSION +0 -1
- data/VERSION.yml +0 -4
- data/examples/proxy_server.rb +0 -26
- data/ruby-hl7.gemspec +0 -39
- data/spec/ail_segment_spec.rb +0 -28
- data/spec/aip_segment_spec.rb +0 -31
- data/spec/basic_parsing_spec.rb +0 -319
- 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/dg1_spec.rb +0 -42
- 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/ft1_segment_spec.rb +0 -35
- data/spec/fts_segment_spec.rb +0 -19
- data/spec/gt1_segment_spec.rb +0 -32
- data/spec/in1_segment_spec.rb +0 -34
- data/spec/message_spec.rb +0 -53
- data/spec/messages_spec.rb +0 -24
- data/spec/mfe_segment_spec.rb +0 -28
- data/spec/mfi_segment_spec.rb +0 -28
- 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 -68
- data/spec/orc_segment_spec.rb +0 -27
- data/spec/pid_segment_spec.rb +0 -78
- 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/sch_segment_spec.rb +0 -32
- data/spec/segment_field_spec.rb +0 -110
- data/spec/segment_generator_spec.rb +0 -32
- data/spec/segment_list_storage_spec.rb +0 -47
- data/spec/segment_spec.rb +0 -38
- data/spec/sft_segment_spec.rb +0 -26
- data/spec/spec_helper.rb +0 -13
- data/spec/speed_parsing_spec.rb +0 -19
- data/spec/spm_segment_spec.rb +0 -26
- data/spec/txa_segment_spec.rb +0 -72
@@ -1,31 +0,0 @@
|
|
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
DELETED
@@ -1,42 +0,0 @@
|
|
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
|
@@ -1,37 +0,0 @@
|
|
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
|
data/spec/err_segment_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
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
|
data/spec/evn_segment_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
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
|
data/spec/ft1_segment_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::FT1 do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base_ft1 = 'FT1|1|||20180705|20180705|||Description||1||||||123456^The Location|||R45.82^Worries~H18.892^Other specified disorders of cornea|1043312457^Provider^Testing^^^^|1043312457^Provider^Testing^^^^||||99392^HEART FAILURE COMPOSITE|'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'creates an FT1 segment' do
|
11
|
-
expect do
|
12
|
-
ft1 = HL7::Message::Segment::FT1.new( @base_ft1 )
|
13
|
-
expect(ft1).not_to be_nil
|
14
|
-
expect(ft1.to_s).to eq @base_ft1
|
15
|
-
end.not_to raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows access to an FT1 segment' do
|
19
|
-
expect do
|
20
|
-
ft1 = HL7::Message::Segment::FT1.new( @base_ft1 )
|
21
|
-
expect(ft1.set_id).to eq '1'
|
22
|
-
expect(ft1.date_of_service).to eq '20180705'
|
23
|
-
expect(ft1.transaction_posting_date).to eq '20180705'
|
24
|
-
expect(ft1.transaction_description).to eq 'Description'
|
25
|
-
expect(ft1.transaction_quantity).to eq '1'
|
26
|
-
expect(ft1.assigned_patient_location).to eq '123456^The Location'
|
27
|
-
expect(ft1.diagnosis_code).to eq 'R45.82^Worries~H18.892^Other specified disorders of cornea'
|
28
|
-
expect(ft1.performed_by_provider).to eq '1043312457^Provider^Testing^^^^'
|
29
|
-
expect(ft1.ordering_provider).to eq '1043312457^Provider^Testing^^^^'
|
30
|
-
expect(ft1.procedure_code).to eq '99392^HEART FAILURE COMPOSITE'
|
31
|
-
|
32
|
-
end.not_to raise_error
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/spec/fts_segment_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
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
|
data/spec/gt1_segment_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::GT1 do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base_gt1 = 'GT1||440|Crusher^Beverly||1003 Elm Street^^Enterprise^MD^29433|(330)644-1234^^^bcrusher@ufp.net^^330^6441234| |19600411000000|F||18|339-33-6657||||||||F||||||||||M'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'creates an GT1 segment' do
|
11
|
-
expect do
|
12
|
-
gt1 = HL7::Message::Segment::GT1.new( @base_gt1 )
|
13
|
-
expect(gt1).not_to be_nil
|
14
|
-
expect(gt1.to_s).to eq @base_gt1
|
15
|
-
end.not_to raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows access to an GT1 segment' do
|
19
|
-
expect do
|
20
|
-
gt1 = HL7::Message::Segment::GT1.new( @base_gt1 )
|
21
|
-
expect(gt1.guarantor_number).to eq '440'
|
22
|
-
expect(gt1.guarantor_name).to eq 'Crusher^Beverly'
|
23
|
-
expect(gt1.guarantor_address).to eq '1003 Elm Street^^Enterprise^MD^29433'
|
24
|
-
expect(gt1.guarantor_date_of_birth).to eq '19600411000000'
|
25
|
-
expect(gt1.guarantor_sex).to eq 'F'
|
26
|
-
expect(gt1.guarantor_relationship).to eq '18'
|
27
|
-
expect(gt1.guarantor_ssn).to eq '339-33-6657'
|
28
|
-
expect(gt1.guarantor_employment_status).to eq 'F'
|
29
|
-
end.not_to raise_error
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/in1_segment_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
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
|
data/spec/message_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
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
|
data/spec/messages_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
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
|
data/spec/mfe_segment_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::MFE do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base_sft = 'MFE|MAD|6772331|200106290500|BUD^Buddhist^HL70006|CE'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'creates an MFE segment' do
|
11
|
-
expect do
|
12
|
-
sft = HL7::Message::Segment::MFE.new( @base_sft )
|
13
|
-
expect(sft).not_to be_nil
|
14
|
-
expect(sft.to_s).to eq(@base_sft)
|
15
|
-
end.not_to raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows access to an MFE segment' do
|
19
|
-
expect do
|
20
|
-
sft = HL7::Message::Segment::MFE.new( @base_sft )
|
21
|
-
expect(sft.record_level_event_code).to eq 'MAD'
|
22
|
-
expect(sft.mfn_control_id).to eq '6772331'
|
23
|
-
expect(sft.primary_key_value).to eq 'BUD^Buddhist^HL70006'
|
24
|
-
expect(sft.primary_key_value_type).to eq 'CE'
|
25
|
-
end.not_to raise_error
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/spec/mfi_segment_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::MFI do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base_sft = 'MFI|HL70006^RELIGION^HL70175|TEST|UPD|||AL'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'creates an MFI segment' do
|
11
|
-
expect do
|
12
|
-
sft = described_class.new( @base_sft )
|
13
|
-
expect(sft).not_to be_nil
|
14
|
-
expect(sft.to_s).to eq(@base_sft)
|
15
|
-
end.not_to raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows access to an MFI segment' do
|
19
|
-
expect do
|
20
|
-
sft = described_class.new( @base_sft )
|
21
|
-
expect(sft.master_file_identifier).to eq 'HL70006^RELIGION^HL70175'
|
22
|
-
expect(sft.master_file_application_identifier).to eq 'TEST'
|
23
|
-
expect(sft.file_level_event_code).to eq 'UPD'
|
24
|
-
expect(sft.response_level_code).to eq 'AL'
|
25
|
-
end.not_to raise_error
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/spec/msa_segment_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
$: << '../lib'
|
3
|
-
require 'ruby-hl7'
|
4
|
-
|
5
|
-
describe HL7::Message::Segment::MSA do
|
6
|
-
context 'general' do
|
7
|
-
before :all do
|
8
|
-
@base_msa = "MSA|AR|ZZ9380 ERR"
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'creates an MSA segment' do
|
12
|
-
expect do
|
13
|
-
msa = HL7::Message::Segment::MSA.new( @base_msa )
|
14
|
-
expect(msa).not_to be_nil
|
15
|
-
expect(msa.to_s).to eq @base_msa
|
16
|
-
end.not_to raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'allows access to an MSA segment' do
|
20
|
-
expect do
|
21
|
-
msa = HL7::Message::Segment::MSA.new( @base_msa )
|
22
|
-
expect(msa.ack_code).to eq "AR"
|
23
|
-
expect(msa.control_id).to eq "ZZ9380 ERR"
|
24
|
-
end.not_to raise_error
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/msh_segment_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::MSH do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base = "MSH|^~\\&||ABCHS||AUSDHSV|20070101112951||ADT^A04^ADT_A01|12334456778890|P|2.5|||NE|NE|AU|ASCII|ENGLISH|||AN ORG|||RECNET.ORG"
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'allows access to an MSH segment' do
|
11
|
-
msh = HL7::Message::Segment::MSH.new @base
|
12
|
-
msh.enc_chars='^~\\&'
|
13
|
-
expect(msh.version_id).to eq '2.5'
|
14
|
-
expect(msh.country_code).to eq 'AU'
|
15
|
-
expect(msh.charset).to eq 'ASCII'
|
16
|
-
expect(msh.sending_responsible_org).to eq 'AN ORG'
|
17
|
-
expect(msh.receiving_network_address).to eq 'RECNET.ORG'
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'allows creation of an MSH segment' do
|
21
|
-
msh = HL7::Message::Segment::MSH.new
|
22
|
-
msh.sending_facility="A Facility"
|
23
|
-
expect(msh.sending_facility).to eq 'A Facility'
|
24
|
-
msh.time = DateTime.iso8601('20010203T040506')
|
25
|
-
expect(msh.time).to eq '20010203040506'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/spec/nk1_segment_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::NK1 do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base_nk1 = 'NK1|1|Mum^Martha^M^^^^L|MTH^Mother^HL70063^^^^2.5.1| 444 Home Street^Apt B^Ann Arbor^MI^99999^USA^H|^PRN^PH^^1^555^5552006'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'creates an NK1 segment' do
|
11
|
-
expect do
|
12
|
-
nk1 = HL7::Message::Segment::NK1.new( @base_nk1 )
|
13
|
-
expect(nk1).not_to be_nil
|
14
|
-
expect(nk1.to_s).to eq @base_nk1
|
15
|
-
end.not_to raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'allows access to an NK1 segment' do
|
19
|
-
expect do
|
20
|
-
nk1 = HL7::Message::Segment::NK1.new( @base_nk1 )
|
21
|
-
expect(nk1.name).to eq 'Mum^Martha^M^^^^L'
|
22
|
-
expect(nk1.phone_number).to eq '^PRN^PH^^1^555^5552006'
|
23
|
-
end.not_to raise_error
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/obr_segment_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::OBR do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base = "OBR|2|^USSSA|0000000567^USSSA|37956^CT ABDOMEN^LN|||199405021550|||||||||||||0000763||||NMR|P||||||R/O TUMOR|202300&BAKER&MARK&E|||01&LOCHLEAR&JUDY|||||||||||||||123"
|
8
|
-
@obr = HL7::Message::Segment::OBR.new @base
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'allows access to an OBR segment' do
|
12
|
-
expect(@obr.to_s).to eq @base
|
13
|
-
expect(@obr.e1).to eq "2"
|
14
|
-
expect(@obr.set_id).to eq "2"
|
15
|
-
expect(@obr.placer_order_number).to eq "^USSSA"
|
16
|
-
expect(@obr.filler_order_number).to eq "0000000567^USSSA"
|
17
|
-
expect(@obr.universal_service_id).to eq "37956^CT ABDOMEN^LN"
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'allows modification of an OBR segment' do
|
21
|
-
@obr.set_id = 1
|
22
|
-
expect(@obr.set_id).to eq "1"
|
23
|
-
@obr.placer_order_number = "^DMCRES"
|
24
|
-
expect(@obr.placer_order_number).to eq "^DMCRES"
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'supports the diagnostic_serv_sect_id method' do
|
28
|
-
expect(@obr).to respond_to(:diagnostic_serv_sect_id)
|
29
|
-
expect(@obr.diagnostic_serv_sect_id).to eq "NMR"
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'supports the result_status method' do
|
33
|
-
expect(@obr).to respond_to(:result_status)
|
34
|
-
expect(@obr.result_status).to eq "P"
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'supports the reason_for_study method' do
|
38
|
-
expect(@obr.reason_for_study).to eq "R/O TUMOR"
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'supports the parent_universal_service_identifier method' do
|
42
|
-
expect(@obr.parent_universal_service_identifier).to eq "123"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/spec/obx_segment_spec.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe HL7::Message::Segment::OBX do
|
5
|
-
context 'general' do
|
6
|
-
before :all do
|
7
|
-
@base = "OBX|1|NM|30341-2^Erythrocyte sedimentation rate^LN^815117^ESR^99USI^^^Erythrocyte sedimentation rate||10|mm/h^millimeter per hour^UCUM|0 to 17|N|0.1||F|||20110331140551-0800||Observer|||20110331150551-0800|^A Site|||Century Hospital^^^^^NIST-AA-1&2.16.840.1.113883.3.72.5.30.1&ISO^XX^^^987|2070 Test Park^^Los Angeles^CA^90067^USA^B^^06037|2343242^Knowsalot^Phil^J.^III^Dr.^^^NIST-AA-1&2.16.840.1.113883.3.72.5.30.1&ISO^L^^^DN"
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'allows access to an OBX segment' do
|
11
|
-
obx = HL7::Message::Segment::OBX.new @base
|
12
|
-
expect(obx.set_id).to eq "1"
|
13
|
-
expect(obx.value_type).to eq "NM"
|
14
|
-
expect(obx.observation_id).to eq "30341-2^Erythrocyte sedimentation rate^LN^815117^ESR^99USI^^^Erythrocyte sedimentation rate"
|
15
|
-
expect(obx.observation_sub_id).to eq ""
|
16
|
-
expect(obx.observation_value).to eq "10"
|
17
|
-
expect(obx.units).to eq "mm/h^millimeter per hour^UCUM"
|
18
|
-
expect(obx.references_range).to eq "0 to 17"
|
19
|
-
expect(obx.abnormal_flags).to eq "N"
|
20
|
-
expect(obx.probability).to eq "0.1"
|
21
|
-
expect(obx.nature_of_abnormal_test).to eq ""
|
22
|
-
expect(obx.observation_result_status).to eq "F"
|
23
|
-
expect(obx.effective_date_of_reference_range).to eq ""
|
24
|
-
expect(obx.user_defined_access_checks).to eq ""
|
25
|
-
expect(obx.observation_date).to eq "20110331140551-0800"
|
26
|
-
expect(obx.producer_id).to eq ""
|
27
|
-
expect(obx.responsible_observer).to eq "Observer"
|
28
|
-
expect(obx.observation_site).to eq '^A Site'
|
29
|
-
expect(obx.observation_method).to eq ""
|
30
|
-
expect(obx.equipment_instance_id).to eq ""
|
31
|
-
expect(obx.analysis_date).to eq "20110331150551-0800"
|
32
|
-
expect(obx.performing_organization_name).to eq "Century Hospital^^^^^NIST-AA-1&2.16.840.1.113883.3.72.5.30.1&ISO^XX^^^987"
|
33
|
-
expect(obx.performing_organization_address).to eq "2070 Test Park^^Los Angeles^CA^90067^USA^B^^06037"
|
34
|
-
expect(obx.performing_organization_medical_director).to eq "2343242^Knowsalot^Phil^J.^III^Dr.^^^NIST-AA-1&2.16.840.1.113883.3.72.5.30.1&ISO^L^^^DN"
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'allows creation of an OBX segment' do
|
38
|
-
expect do
|
39
|
-
obx = HL7::Message::Segment::OBX.new
|
40
|
-
obx.value_type = "TESTIES"
|
41
|
-
obx.observation_id = "HR"
|
42
|
-
obx.observation_sub_id = "2"
|
43
|
-
obx.observation_value = "SOMETHING HAPPENned"
|
44
|
-
end.not_to raise_error
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "#correction?" do
|
48
|
-
let(:obx) { HL7::Message::Segment::OBX.new data }
|
49
|
-
subject { obx.correction? }
|
50
|
-
|
51
|
-
context "when is a correction" do
|
52
|
-
let(:data) {
|
53
|
-
'OBX|1|ST|123456^AA OBSERVATION^L^4567890^FIRST OBSERVATION^LN||42|ug/dL^Micrograms per Deciliter^UCUM|<10 ug/dL|H|||C||||OMG'
|
54
|
-
}
|
55
|
-
|
56
|
-
it { is_expected.to be true }
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when is not a correction" do
|
60
|
-
let(:data) {
|
61
|
-
'OBX|1|ST|123456^AA OBSERVATION^L^4567890^FIRST OBSERVATION^LN||42|ug/dL^Micrograms per Deciliter^UCUM|<10 ug/dL|H|||F||||OMG'
|
62
|
-
}
|
63
|
-
|
64
|
-
it { is_expected.to be false }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/spec/orc_segment_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
$: << '../lib'
|
3
|
-
require 'ruby-hl7'
|
4
|
-
|
5
|
-
describe HL7::Message::Segment::ORC do
|
6
|
-
context 'general' do
|
7
|
-
before :all do
|
8
|
-
@base_orc = 'ORC|RE|23456^EHR^2.16.840.1.113883.19.3.2.3^ISO|9700123^Lab^2.16.840.1.113883.19.3.1.6^ISO|||||||||1234^Admit^Alan^A^III^Dr^^^&2.16.840.1.113883.19.4.6^ISO^L^^^EI^&2.16.840.1.113883.19.4.6^ISO^^^^^^^^MD||^WPN^PH^^1^555^5551005|||||||Level Seven Healthcare, Inc.^L^^^^&2.16.840.1.113883.19.4.6^ISO^XX^^^1234|1005 Healthcare Drive^^Ann Arbor^MI^99999^USA^B|^WPN^PH^^1^555^5553001|4444 Healthcare Drive^Suite 123^Ann Arbor^MI^99999^USA^B|||||||7844'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'creates an ORC segment' do
|
12
|
-
expect do
|
13
|
-
orc = HL7::Message::Segment::ORC.new( @base_orc )
|
14
|
-
expect(orc).not_to be_nil
|
15
|
-
expect(orc.to_s).to eq @base_orc
|
16
|
-
end.not_to raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'allows access to an ORC segment' do
|
20
|
-
orc = HL7::Message::Segment::ORC.new( @base_orc )
|
21
|
-
expect(orc.ordering_provider).to eq '1234^Admit^Alan^A^III^Dr^^^&2.16.840.1.113883.19.4.6^ISO^L^^^EI^&2.16.840.1.113883.19.4.6^ISO^^^^^^^^MD'
|
22
|
-
expect(orc.call_back_phone_number).to eq '^WPN^PH^^1^555^5551005'
|
23
|
-
expect(orc.ordering_facility_name).to eq 'Level Seven Healthcare, Inc.^L^^^^&2.16.840.1.113883.19.4.6^ISO^XX^^^1234'
|
24
|
-
expect(orc.parent_universal_service_identifier).to eq '7844'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|