ruby-hl7 1.2.3 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +7 -0
- data/.rubocop.yml +127 -0
- data/.travis.yml +20 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +65 -0
- data/NOTES.md +151 -0
- data/README.rdoc +5 -0
- data/Rakefile +76 -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/ft1.rb +63 -0
- data/lib/segments/gt1.rb +75 -0
- data/lib/segments/pid.rb +13 -1
- data/lib/segments/txa.rb +28 -0
- data/ruby-hl7.gemspec +39 -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/ft1_segment_spec.rb +35 -0
- data/spec/fts_segment_spec.rb +19 -0
- data/spec/gt1_segment_spec.rb +32 -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
- data/spec/txa_segment_spec.rb +72 -0
- metadata +155 -18
- data/lib/segments/zcf.rb +0 -22
@@ -0,0 +1,29 @@
|
|
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
|
+
expect(prd.provider_role).to eql 'RP'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should set the name' do
|
14
|
+
expect(prd.provider_name).to eql 'LastName^FirstName^MiddleInitial^SR^NickName'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set the provider_address' do
|
18
|
+
expect(prd.provider_address).to eql '444 Home Street^Apt B^Ann Arbor^MI^99999^USA'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should set the provider_location' do
|
22
|
+
expect(prd.provider_location).to eql '^^^A Wonderful Clinic'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should set provider_communication_information' do
|
26
|
+
expect(prd.provider_communication_information).to eql '^WPN^PH^^^07^5555555'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
expect(pv1.patient_class).to eq "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
|
+
expect(pv1.referring_doctor).to eq "Smith^John"
|
19
|
+
pv1.admit_date = Date.new(2014, 1, 1)
|
20
|
+
expect(pv1.admit_date).to eq '20140101'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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
|
+
expect(rf1.referral_status).to eq 'P^Pending^HL70283'
|
14
|
+
expect(rf1.referral_priority).to eq 'R^Routine^HL70280'
|
15
|
+
expect(rf1.referral_type).to eq 'GRF^General referral^HL70281'
|
16
|
+
expect(rf1.referral_disposition).to eq 'AM^Assume management^HL70282'
|
17
|
+
expect(rf1.originating_referral_identifier).to eq '8094'
|
18
|
+
expect(rf1.effective_date).to eq '20060705'
|
19
|
+
expect(rf1.process_date).to eq '20060705'
|
20
|
+
expect(rf1.external_referral_identifier).to eq '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
|
+
expect(rf1.expiration_date).to eq '20581201'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message::Segment::SCH do
|
5
|
+
context 'general' do
|
6
|
+
before :all do
|
7
|
+
@base_sch = 'SCH|||||681|S^SCHEDULED|^BONE DENSITY PB,cf/RH |30^30 MINUTE APPOINTMENT|45|m|^^45^200905260930^200905261015|||||||||polly^^POLLY BRESCOCK|^^^^^^ ||||SCHEDULED'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates an SCH segment' do
|
11
|
+
expect do
|
12
|
+
sch = HL7::Message::Segment::SCH.new( @base_sch )
|
13
|
+
expect(sch).not_to be_nil
|
14
|
+
expect(sch.to_s).to eq @base_sch
|
15
|
+
end.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows access to an SCH segment' do
|
19
|
+
expect do
|
20
|
+
sch = HL7::Message::Segment::SCH.new( @base_sch )
|
21
|
+
expect(sch.schedule_id).to eq '681'
|
22
|
+
expect(sch.event_reason).to eq 'S^SCHEDULED'
|
23
|
+
expect(sch.appointment_reason).to eq '^BONE DENSITY PB,cf/RH '
|
24
|
+
expect(sch.appointment_type).to eq '30^30 MINUTE APPOINTMENT'
|
25
|
+
expect(sch.appointment_duration).to eq '45'
|
26
|
+
expect(sch.appointment_duration_units).to eq 'm'
|
27
|
+
expect(sch.entered_by_person).to eq 'polly^^POLLY BRESCOCK'
|
28
|
+
expect(sch.filler_status_code).to eq 'SCHEDULED'
|
29
|
+
end.not_to raise_error
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,110 @@
|
|
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
|
+
expect(msg.to_s).to eq @base
|
26
|
+
expect(msg.no_block).to eq "no_block"
|
27
|
+
expect(msg.validating).to eq "validated"
|
28
|
+
expect(msg.converting).to eq "Xconverted"
|
29
|
+
|
30
|
+
msg.no_block = "NO_BLOCK"
|
31
|
+
expect(msg.no_block).to eq "NO_BLOCK"
|
32
|
+
|
33
|
+
msg.validating = "good"
|
34
|
+
expect(msg.validating).to eq "good"
|
35
|
+
msg.validating = "bad"
|
36
|
+
expect(msg.validating).to eq ""
|
37
|
+
|
38
|
+
msg.converting = "empty"
|
39
|
+
expect(msg.converting).to eq "XXempty"
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'is not evaluated on read access by eXXX alias' do
|
43
|
+
msg = MockSegment.new(@base)
|
44
|
+
|
45
|
+
expect(msg.e1).to eq "no_block"
|
46
|
+
expect(msg.e2).to eq "validated"
|
47
|
+
expect(msg.e3).to eq "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
|
+
expect(msg.e1).to eq "NO_BLOCK"
|
55
|
+
|
56
|
+
msg.e2 = "good"
|
57
|
+
expect(msg.e2).to eq "good"
|
58
|
+
msg.e2 = "bad"
|
59
|
+
expect(msg.e2).to eq "bad"
|
60
|
+
|
61
|
+
msg.e3 = "empty"
|
62
|
+
expect(msg.e3).to eq "empty"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#[]' do
|
67
|
+
it 'allows index access to the segment' do
|
68
|
+
msg = HL7::Message::Segment.new(@base)
|
69
|
+
expect(msg[0]).to eq 'Mock'
|
70
|
+
expect(msg[1]).to eq 'no_block'
|
71
|
+
expect(msg[2]).to eq 'validated'
|
72
|
+
expect(msg[3]).to eq 'converted'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#[]=' do
|
77
|
+
it 'allows index assignment to the segment' do
|
78
|
+
msg = HL7::Message::Segment.new(@base)
|
79
|
+
msg[0] = 'Kcom'
|
80
|
+
expect(msg[0]).to eq 'Kcom'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#alias_field' do
|
85
|
+
context 'with a valid field' do
|
86
|
+
it 'uses alias field names' do
|
87
|
+
msg = MockSegment.new(@base)
|
88
|
+
expect(msg.no_block).to eq "no_block"
|
89
|
+
expect(msg.no_block_alias).to eq "no_block"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'with an invalid field' do
|
94
|
+
|
95
|
+
class MockInvalidSegment < HL7::Message::Segment
|
96
|
+
weight 1
|
97
|
+
add_field :no_block
|
98
|
+
alias_field :no_block_alias, :invalid_field
|
99
|
+
add_field :second
|
100
|
+
add_field :third
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
it 'throws an error when the field is invalid' do
|
105
|
+
msg = MockInvalidSegment.new(@base)
|
106
|
+
expect{ msg.no_block_alias }.to raise_error(HL7::InvalidDataError)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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
|
+
expect(segment_generator.valid_segments_parts?).to 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
|
+
expect(segment_generator.valid_segments_parts?).to 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
|
@@ -0,0 +1,47 @@
|
|
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
|
+
expect(segment.accepts?(:OBR)).to be true
|
16
|
+
expect(segment.child_types).to 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
|
+
expect(segment_instance.respond_to?(method)).to 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
|
+
expect(segment_instance.respond_to?(:children)).to 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
|
@@ -0,0 +1,38 @@
|
|
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
|
+
expect(segment.length).to eq 3
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'enumerable' do
|
13
|
+
it 'enumerates over elements' do
|
14
|
+
seg = HL7::Message::Segment::Default.new
|
15
|
+
segment_count = 0
|
16
|
+
seg.each do |s|
|
17
|
+
segment_count = segment_count + 1
|
18
|
+
end
|
19
|
+
expect(segment_count).to eq(seg.length)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'is_child_segment?' do
|
24
|
+
let(:segment){ HL7::Message::Segment.new "MSA|AR|ZZ9380 ERR" }
|
25
|
+
it "return false when is not set" do
|
26
|
+
expect(segment.is_child_segment?).to be false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'convert_to_ts' do
|
31
|
+
let(:time_now){ DateTime.now }
|
32
|
+
let(:formated_time){ time_now.strftime('%Y%m%d%H%M%S') }
|
33
|
+
|
34
|
+
it "should conver to the hl7 time format" do
|
35
|
+
expect(HL7::Message::Segment.convert_to_ts(time_now)).to eq formated_time
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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|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
|
+
expect do
|
12
|
+
sft = HL7::Message::Segment::SFT.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 SFT segment' do
|
19
|
+
expect do
|
20
|
+
sft = HL7::Message::Segment::SFT.new( @base_sft )
|
21
|
+
expect(sft.software_product_name).to eq 'An Lab System'
|
22
|
+
expect(sft.software_install_date).to eq '20080817'
|
23
|
+
end.not_to raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
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__)
|
13
|
+
require 'pry'
|
@@ -0,0 +1,19 @@
|
|
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
|
+
expect(doc).not_to be_nil
|
15
|
+
ends = Time.now
|
16
|
+
expect(ends-start).to be < 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
expect do
|
12
|
+
spm = HL7::Message::Segment::SPM.new( @base_spm )
|
13
|
+
expect(spm).not_to be_nil
|
14
|
+
expect(spm.to_s).to eq @base_spm
|
15
|
+
end.not_to raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows access to an SPM segment' do
|
19
|
+
expect do
|
20
|
+
spm = HL7::Message::Segment::SPM.new( @base_spm )
|
21
|
+
expect(spm.specimen_type).to eq '122554006^Capillary blood specimen^SCT^BLDC^Blood capillary^HL70070^20080131^2.5.1'
|
22
|
+
expect(spm.set_id).to eq '1'
|
23
|
+
end.not_to raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe HL7::Message::Segment::TXA do
|
5
|
+
let(:segment) do
|
6
|
+
"TXA|1|AR|AP|20220611113300|1^Name|20220611|2022061110||1^Creator|" \
|
7
|
+
"1^Author|1^Typer|A^V02^UID^TC|A^V01^UID^TC|01|02|file.txt|C|P|AV|ST||" \
|
8
|
+
"2022061110|DC|AR|FileName|202206111011"
|
9
|
+
end
|
10
|
+
let(:filled_txa) { HL7::Message::Segment::TXA.new segment }
|
11
|
+
|
12
|
+
it 'allows access to an TXA segment' do
|
13
|
+
expect(filled_txa.set_id).to eq('1')
|
14
|
+
expect(filled_txa.document_type).to eq('AR')
|
15
|
+
expect(filled_txa.document_content_presentation).to eq('AP')
|
16
|
+
expect(filled_txa.activity_date_time).to eq('20220611113300')
|
17
|
+
expect(filled_txa.primary_activity_provider_code).to eq('1^Name')
|
18
|
+
expect(filled_txa.origination_date_time).to eq('20220611')
|
19
|
+
expect(filled_txa.transcription_date_time).to eq('2022061110')
|
20
|
+
expect(filled_txa.edit_date_time).to eq('')
|
21
|
+
expect(filled_txa.originator_code).to eq('1^Creator')
|
22
|
+
expect(filled_txa.assigned_document_authenticator).to eq('1^Author')
|
23
|
+
expect(filled_txa.transcriptionist_code).to eq('1^Typer')
|
24
|
+
expect(filled_txa.unique_document_number).to eq('A^V02^UID^TC')
|
25
|
+
expect(filled_txa.parent_document_number).to eq('A^V01^UID^TC')
|
26
|
+
expect(filled_txa.placer_order_number).to eq('01')
|
27
|
+
expect(filled_txa.filler_order_number).to eq('02')
|
28
|
+
expect(filled_txa.unique_document_file_name).to eq('file.txt')
|
29
|
+
expect(filled_txa.document_completion_status).to eq('C')
|
30
|
+
expect(filled_txa.document_confidentiality_status).to eq('P')
|
31
|
+
expect(filled_txa.document_availability_status).to eq('AV')
|
32
|
+
expect(filled_txa.document_storage_status).to eq('ST')
|
33
|
+
expect(filled_txa.document_change_reason).to eq('')
|
34
|
+
expect(filled_txa.authentication_person_time_stamp).to eq('2022061110')
|
35
|
+
expect(filled_txa.distributed_copies_code).to eq('DC')
|
36
|
+
expect(filled_txa.folder_assignment).to eq('AR')
|
37
|
+
expect(filled_txa.document_title).to eq('FileName')
|
38
|
+
expect(filled_txa.agreed_due_date_time).to eq('202206111011')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows creation of an TXA segment' do
|
42
|
+
txa = HL7::Message::Segment::TXA.new
|
43
|
+
txa.set_id = '1'
|
44
|
+
txa.document_type = 'AR'
|
45
|
+
txa.document_content_presentation = 'AP'
|
46
|
+
txa.activity_date_time = '20220611113300'
|
47
|
+
txa.primary_activity_provider_code = '1^Name'
|
48
|
+
txa.origination_date_time = '20220611'
|
49
|
+
txa.transcription_date_time = '2022061110'
|
50
|
+
txa.edit_date_time = ''
|
51
|
+
txa.originator_code = '1^Creator'
|
52
|
+
txa.assigned_document_authenticator = '1^Author'
|
53
|
+
txa.transcriptionist_code = '1^Typer'
|
54
|
+
txa.unique_document_number = 'A^V02^UID^TC'
|
55
|
+
txa.parent_document_number = 'A^V01^UID^TC'
|
56
|
+
txa.placer_order_number = '01'
|
57
|
+
txa.filler_order_number = '02'
|
58
|
+
txa.unique_document_file_name = 'file.txt'
|
59
|
+
txa.document_completion_status = 'C'
|
60
|
+
txa.document_confidentiality_status = 'P'
|
61
|
+
txa.document_availability_status = 'AV'
|
62
|
+
txa.document_storage_status = 'ST'
|
63
|
+
txa.document_change_reason = ''
|
64
|
+
txa.authentication_person_time_stamp = '2022061110'
|
65
|
+
txa.distributed_copies_code = 'DC'
|
66
|
+
txa.folder_assignment = 'AR'
|
67
|
+
txa.document_title = 'FileName'
|
68
|
+
txa.agreed_due_date_time = '202206111011'
|
69
|
+
|
70
|
+
expect(txa.to_s).to eq(segment)
|
71
|
+
end
|
72
|
+
end
|