ruby-hl7 1.3.3 → 1.4.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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/lib/configuration.rb +30 -0
  3. data/lib/core_ext/date_time.rb +19 -15
  4. data/lib/core_ext/string.rb +2 -0
  5. data/lib/helpers/time_formatter_helper.rb +42 -0
  6. data/lib/message.rb +72 -75
  7. data/lib/message_parser.rb +17 -15
  8. data/lib/ruby-hl7.rb +26 -16
  9. data/lib/segment.rb +63 -47
  10. data/lib/segment_default.rb +6 -4
  11. data/lib/segment_fields.rb +27 -25
  12. data/lib/segment_generator.rb +12 -15
  13. data/lib/segment_list_storage.rb +15 -14
  14. data/lib/segments/aig.rb +2 -0
  15. data/lib/segments/ail.rb +2 -0
  16. data/lib/segments/aip.rb +2 -0
  17. data/lib/segments/ais.rb +2 -0
  18. data/lib/segments/dg1.rb +2 -10
  19. data/lib/segments/err.rb +2 -0
  20. data/lib/segments/evn.rb +2 -1
  21. data/lib/segments/ft1.rb +13 -13
  22. data/lib/segments/fts.rb +2 -0
  23. data/lib/segments/gt1.rb +4 -6
  24. data/lib/segments/in1.rb +2 -1
  25. data/lib/segments/mfe.rb +2 -0
  26. data/lib/segments/mfi.rb +2 -0
  27. data/lib/segments/mrg.rb +2 -0
  28. data/lib/segments/msa.rb +2 -2
  29. data/lib/segments/msh.rb +3 -2
  30. data/lib/segments/nk1.rb +48 -8
  31. data/lib/segments/nte.rb +6 -5
  32. data/lib/segments/obr.rb +4 -3
  33. data/lib/segments/obx.rb +2 -1
  34. data/lib/segments/orc.rb +8 -10
  35. data/lib/segments/oru.rb +2 -1
  36. data/lib/segments/pid.rb +19 -10
  37. data/lib/segments/prd.rb +2 -1
  38. data/lib/segments/prt.rb +23 -0
  39. data/lib/segments/pv1.rb +2 -1
  40. data/lib/segments/pv2.rb +64 -51
  41. data/lib/segments/qrd.rb +2 -1
  42. data/lib/segments/qrf.rb +2 -1
  43. data/lib/segments/rf1.rb +2 -1
  44. data/lib/segments/rgs.rb +2 -0
  45. data/lib/segments/rol.rb +22 -0
  46. data/lib/segments/sch.rb +2 -0
  47. data/lib/segments/sft.rb +2 -0
  48. data/lib/segments/spm.rb +2 -0
  49. data/lib/segments/tq1.rb +2 -0
  50. data/lib/segments/txa.rb +2 -0
  51. data/lib/test/hl7_messages.rb +118 -117
  52. data/lib/version.rb +5 -0
  53. metadata +14 -163
  54. data/.gitignore +0 -7
  55. data/.rubocop.yml +0 -127
  56. data/.travis.yml +0 -20
  57. data/Gemfile +0 -3
  58. data/Gemfile.lock +0 -65
  59. data/LICENSE +0 -19
  60. data/NOTES.md +0 -151
  61. data/README.rdoc +0 -47
  62. data/Rakefile +0 -76
  63. data/VERSION +0 -1
  64. data/VERSION.yml +0 -4
  65. data/examples/proxy_server.rb +0 -26
  66. data/ruby-hl7.gemspec +0 -39
  67. data/spec/ail_segment_spec.rb +0 -28
  68. data/spec/aip_segment_spec.rb +0 -31
  69. data/spec/basic_parsing_spec.rb +0 -319
  70. data/spec/batch_parsing_spec.rb +0 -52
  71. data/spec/child_segment_spec.rb +0 -66
  72. data/spec/core_ext/date_time_spec.rb +0 -43
  73. data/spec/default_segment_spec.rb +0 -31
  74. data/spec/dg1_spec.rb +0 -42
  75. data/spec/dynamic_segment_def_spec.rb +0 -37
  76. data/spec/err_segment_spec.rb +0 -26
  77. data/spec/evn_segment_spec.rb +0 -23
  78. data/spec/ft1_segment_spec.rb +0 -35
  79. data/spec/fts_segment_spec.rb +0 -19
  80. data/spec/gt1_segment_spec.rb +0 -32
  81. data/spec/in1_segment_spec.rb +0 -34
  82. data/spec/message_spec.rb +0 -53
  83. data/spec/messages_spec.rb +0 -24
  84. data/spec/mfe_segment_spec.rb +0 -28
  85. data/spec/mfi_segment_spec.rb +0 -28
  86. data/spec/msa_segment_spec.rb +0 -27
  87. data/spec/msh_segment_spec.rb +0 -28
  88. data/spec/nk1_segment_spec.rb +0 -26
  89. data/spec/obr_segment_spec.rb +0 -45
  90. data/spec/obx_segment_spec.rb +0 -68
  91. data/spec/orc_segment_spec.rb +0 -27
  92. data/spec/pid_segment_spec.rb +0 -78
  93. data/spec/prd_segment_spec.rb +0 -29
  94. data/spec/pv1_segment_spec.rb +0 -23
  95. data/spec/rf1_segment_spec.rb +0 -29
  96. data/spec/sch_segment_spec.rb +0 -32
  97. data/spec/segment_field_spec.rb +0 -110
  98. data/spec/segment_generator_spec.rb +0 -32
  99. data/spec/segment_list_storage_spec.rb +0 -47
  100. data/spec/segment_spec.rb +0 -38
  101. data/spec/sft_segment_spec.rb +0 -26
  102. data/spec/spec_helper.rb +0 -13
  103. data/spec/speed_parsing_spec.rb +0 -19
  104. data/spec/spm_segment_spec.rb +0 -26
  105. data/spec/txa_segment_spec.rb +0 -72
@@ -1,78 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe HL7::Message::Segment::PID do
5
- context 'general' do
6
- before :all do
7
- @base = "PID|1||333||LastName^FirstName^MiddleInitial^SR^NickName||19760228|F||2106-3^White^HL70005^CAUC^Caucasian^L||AA||||||555.55|012345678||||||||||201011110924-0700|Y|||||||||"
8
- end
9
-
10
- it 'validates the admin_sex element' do
11
- pid = HL7::Message::Segment::PID.new
12
- expect do
13
- vals = %w[F M O U A N C] + [ nil ]
14
- vals.each do |x|
15
- pid.admin_sex = x
16
- end
17
- pid.admin_sex = ""
18
- end.not_to raise_error
19
-
20
- expect do
21
- ["TEST", "A", 1, 2].each do |x|
22
- pid.admin_sex = x
23
- end
24
- end.to raise_error(HL7::InvalidDataError)
25
- end
26
-
27
- it "sets values correctly" do
28
- pid = HL7::Message::Segment::PID.new @base
29
- expect(pid.set_id).to eq "1"
30
- expect(pid.patient_id).to eq ""
31
- expect(pid.patient_id_list).to eq "333"
32
- expect(pid.alt_patient_id).to eq ""
33
- expect(pid.patient_name).to eq "LastName^FirstName^MiddleInitial^SR^NickName"
34
- expect(pid.mother_maiden_name).to eq ""
35
- expect(pid.patient_dob).to eq "19760228"
36
- expect(pid.admin_sex).to eq "F"
37
- expect(pid.patient_alias).to eq ""
38
- expect(pid.race).to eq "2106-3^White^HL70005^CAUC^Caucasian^L"
39
- expect(pid.address).to eq ""
40
- expect(pid.county_code).to eq "AA"
41
- expect(pid.phone_home).to eq ""
42
- expect(pid.phone_business).to eq ""
43
- expect(pid.primary_language).to eq ""
44
- expect(pid.marital_status).to eq ""
45
- expect(pid.religion).to eq ""
46
- expect(pid.account_number).to eq "555.55"
47
- expect(pid.social_security_num).to eq "012345678"
48
- expect(pid.driver_license_num).to eq ""
49
- expect(pid.mothers_id).to eq ""
50
- expect(pid.ethnic_group).to eq ""
51
- expect(pid.birthplace).to eq ""
52
- expect(pid.multi_birth).to eq ""
53
- expect(pid.birth_order).to eq ""
54
- expect(pid.citizenship).to eq ""
55
- expect(pid.vet_status).to eq ""
56
- expect(pid.nationality).to eq ""
57
- expect(pid.death_date).to eq "201011110924-0700"
58
- expect(pid.death_indicator).to eq "Y"
59
- expect(pid.id_unknown_indicator).to eq ""
60
- expect(pid.id_readability_code).to eq ""
61
- expect(pid.last_update_date).to eq ""
62
- expect(pid.last_update_facility).to eq ""
63
- expect(pid.species_code).to eq ""
64
- expect(pid.breed_code).to eq ""
65
- expect(pid.strain).to eq ""
66
- expect(pid.production_class_code).to eq ""
67
- expect(pid.tribal_citizenship).to eq ""
68
- end
69
-
70
- it "aliases the county_code field as country_code for backwards compatibility" do
71
- pid = HL7::Message::Segment::PID.new @base
72
- expect(pid.country_code).to eq "AA"
73
-
74
- pid.country_code = "ZZ"
75
- expect(pid.country_code).to eq "ZZ"
76
- end
77
- end
78
- end
@@ -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
- 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
@@ -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
- 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
@@ -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
- 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
@@ -1,32 +0,0 @@
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
@@ -1,110 +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
- 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
@@ -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
- 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
@@ -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
- 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
data/spec/segment_spec.rb DELETED
@@ -1,38 +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
- 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
@@ -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|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 DELETED
@@ -1,13 +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__)
13
- require 'pry'
@@ -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
- expect(doc).not_to be_nil
15
- ends = Time.now
16
- expect(ends-start).to be < 1
17
- end
18
- end
19
- end
@@ -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
- 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
@@ -1,72 +0,0 @@
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