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,28 @@
|
|
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
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,27 @@
|
|
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
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1,45 @@
|
|
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
|
@@ -0,0 +1,68 @@
|
|
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
|
@@ -0,0 +1,27 @@
|
|
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
|
@@ -0,0 +1,78 @@
|
|
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
|
@@ -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
|