ruby-hl7 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +2 -1
  3. data/lib/message.rb +5 -0
  4. data/lib/ruby-hl7.rb +1 -1
  5. data/lib/segment.rb +6 -0
  6. data/lib/segments/mfe.rb +10 -0
  7. data/lib/segments/mfi.rb +13 -0
  8. data/lib/segments/obx.rb +4 -1
  9. data/lib/segments/sft.rb +0 -6
  10. data/lib/test/hl7_messages.rb +30 -24
  11. metadata +11 -46
  12. data/.gitignore +0 -6
  13. data/.travis.yml +0 -15
  14. data/Gemfile +0 -11
  15. data/Gemfile.lock +0 -37
  16. data/NOTES.md +0 -53
  17. data/Rakefile +0 -149
  18. data/VERSION +0 -1
  19. data/VERSION.yml +0 -4
  20. data/examples/proxy_server.rb +0 -26
  21. data/ruby-hl7.gemspec +0 -44
  22. data/spec/basic_parsing_spec.rb +0 -320
  23. data/spec/batch_parsing_spec.rb +0 -52
  24. data/spec/child_segment_spec.rb +0 -66
  25. data/spec/core_ext/date_time_spec.rb +0 -43
  26. data/spec/default_segment_spec.rb +0 -31
  27. data/spec/dynamic_segment_def_spec.rb +0 -37
  28. data/spec/err_segment_spec.rb +0 -26
  29. data/spec/evn_segment_spec.rb +0 -23
  30. data/spec/msa_segment_spec.rb +0 -27
  31. data/spec/msh_segment_spec.rb +0 -28
  32. data/spec/nk1_segment_spec.rb +0 -26
  33. data/spec/obr_segment_spec.rb +0 -45
  34. data/spec/obx_segment_spec.rb +0 -46
  35. data/spec/orc_segment_spec.rb +0 -27
  36. data/spec/pid_segment_spec.rb +0 -70
  37. data/spec/prd_segment_spec.rb +0 -29
  38. data/spec/pv1_segment_spec.rb +0 -23
  39. data/spec/rf1_segment_spec.rb +0 -29
  40. data/spec/segment_field_spec.rb +0 -92
  41. data/spec/segment_generator_spec.rb +0 -32
  42. data/spec/segment_list_storage_spec.rb +0 -47
  43. data/spec/segment_spec.rb +0 -27
  44. data/spec/sft_segment_spec.rb +0 -26
  45. data/spec/spec_helper.rb +0 -12
  46. data/spec/speed_parsing_spec.rb +0 -19
  47. data/spec/spm_segment_spec.rb +0 -26
@@ -1,66 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe HL7::Message do
5
- context 'child segments' do
6
- before :all do
7
- @base = open( './test_data/obxobr.hl7' ).readlines
8
- end
9
-
10
- it 'allows access to child segments' do
11
- msg = HL7::Message.new @base
12
- msg.should_not be_nil
13
- msg[:OBR].should_not be_nil
14
- msg[:OBR].length.should == 3
15
- msg[:OBR][0].children.should_not be_nil
16
- msg[:OBR][0].children.length.should == 6
17
- msg[:OBR][1].children.should_not be_nil
18
- msg[:OBR][1].children.length.should == 3
19
- msg[:OBR][2].children.should_not be_nil
20
- msg[:OBR][2].children.length.should == 1
21
- msg[:OBX][0].children.should_not be_nil
22
- msg[:OBX][0].children.length.should == 1
23
-
24
- msg[:OBR][0].children.each do |x|
25
- x.should_not be_nil
26
- end
27
- msg[:OBR][1].children.each do |x|
28
- x.should_not be_nil
29
- end
30
- msg[:OBR][2].children.each do |x|
31
- x.should_not be_nil
32
- end
33
- end
34
-
35
- it 'allows adding child segments' do
36
- msg = HL7::Message.new @base
37
- msg.should_not be_nil
38
- msg[:OBR].should_not be_nil
39
- ob = HL7::Message::Segment::OBR.new
40
- ob.should_not be_nil
41
-
42
- msg << ob
43
- ob.children.should_not be_nil
44
- ob.segment_parent.should_not be_nil
45
- ob.segment_parent.should == msg
46
- orig_cnt = msg.length
47
-
48
- (1..4).each do |x|
49
- m = HL7::Message::Segment::OBX.new
50
- m.observation_value = "taco"
51
- m.should_not be_nil
52
- /taco/.match(m.to_s).should_not be_nil
53
- ob.children << m
54
- ob.children.length.should == x
55
- m.segment_parent.should_not be_nil
56
- m.segment_parent.should == ob
57
- end
58
-
59
- @base.should_not == msg.to_hl7
60
- msg.length.should_not == orig_cnt
61
- text_ver = msg.to_hl7
62
- /taco/.match(text_ver).should_not be_nil
63
- end
64
- end
65
- end
66
-
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Date do
4
-
5
- subject{ Date.parse('2013-12-02').to_hl7 }
6
-
7
- it "should respond to the HL7 timestamp" do
8
- subject.should eq "20131202"
9
- end
10
- end
11
-
12
- describe "to_hl7 for time related classes" do
13
-
14
- let(:formated_time){ time_now.strftime('%Y%m%d%H%M%S') }
15
- let(:fraction_3){ "." + sprintf('%06d', time_now.to_time.usec)[0, 3] }
16
- let(:fraction_9){ "." + sprintf('%06d', time_now.to_time.usec) + ("0" * 3) }
17
-
18
- shared_examples "a time to_hl7" do
19
- context "without fraction" do
20
- it { time_now.to_time.to_hl7.should eq formated_time }
21
- end
22
-
23
- context "with_fraction" do
24
- it { time_now.to_time.to_hl7(3).should eq formated_time + fraction_3 }
25
-
26
- it { time_now.to_time.to_hl7(9).should eq formated_time + fraction_9 }
27
- end
28
- end
29
-
30
- describe Time do
31
- let(:time_now){ Time.now }
32
-
33
- it_should_behave_like "a time to_hl7"
34
- end
35
-
36
- describe DateTime do
37
- let(:time_now){ DateTime.now }
38
-
39
- it_should_behave_like "a time to_hl7"
40
- end
41
-
42
- end
43
-
@@ -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
- seg.to_s.should == @base_msa
14
- end
15
-
16
- it 'converts to a string' do
17
- seg = HL7::Message::Segment::Default.new( @base_msa )
18
- seg.to_s.should == @base_msa
19
- seg.to_hl7.should == 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
- seg.to_s.should == "NK1|INFO|MORE INFO|||LAST INFO"
29
- end
30
- end
31
- 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
- seg.to_s.should == "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
- seg.to_s.should == "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
- lambda { e3 "TEST" }.should raise_error(NoMethodError)
34
- seg.to_s.should == "MSK|1234|5678"
35
- end
36
- end
37
- end
@@ -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
- lambda do
12
- err = HL7::Message::Segment::ERR.new( @base_err )
13
- err.should_not be_nil
14
- err.to_s.should == @base_err
15
- end.should_not raise_error
16
- end
17
-
18
- it 'allows access to an ERR segment' do
19
- lambda do
20
- err = HL7::Message::Segment::ERR.new( @base_err )
21
- err.severity.should == 'E'
22
- err.error_location.should == 'OBR^1'
23
- end.should_not raise_error
24
- end
25
- end
26
- end
@@ -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
- evn.type_code.should == "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
- evn.event_facility.should == 'A Facility'
19
- evn.recorded_date = Date.new 2001,2,3
20
- evn.recorded_date.should == "20010203"
21
- end
22
- end
23
- end
@@ -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
- lambda do
13
- msa = HL7::Message::Segment::MSA.new( @base_msa )
14
- msa.should_not be_nil
15
- msa.to_s.should == @base_msa
16
- end.should_not raise_error
17
- end
18
-
19
- it 'allows access to an MSA segment' do
20
- lambda do
21
- msa = HL7::Message::Segment::MSA.new( @base_msa )
22
- msa.ack_code.should == "AR"
23
- msa.control_id.should == "ZZ9380 ERR"
24
- end.should_not raise_error
25
- end
26
- end
27
- end
@@ -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
- msh.version_id.should == '2.5'
14
- msh.country_code.should=='AU'
15
- msh.charset.should=='ASCII'
16
- msh.sending_responsible_org.should=='AN ORG'
17
- msh.receiving_network_address.should=='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
- msh.sending_facility.should == 'A Facility'
24
- msh.time = DateTime.iso8601('20010203T040506')
25
- msh.time.should == '20010203040506'
26
- end
27
- end
28
- end
@@ -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
- lambda do
12
- nk1 = HL7::Message::Segment::NK1.new( @base_nk1 )
13
- nk1.should_not be_nil
14
- nk1.to_s.should == @base_nk1
15
- end.should_not raise_error
16
- end
17
-
18
- it 'allows access to an NK1 segment' do
19
- lambda do
20
- nk1 = HL7::Message::Segment::NK1.new( @base_nk1 )
21
- nk1.name.should == 'Mum^Martha^M^^^^L'
22
- nk1.phone_number.should == '^PRN^PH^^1^555^5552006'
23
- end.should_not raise_error
24
- end
25
- end
26
- end
@@ -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
- @obr.to_s.should == @base
13
- @obr.e1.should == "2"
14
- @obr.set_id.should == "2"
15
- @obr.placer_order_number.should == "^USSSA"
16
- @obr.filler_order_number.should == "0000000567^USSSA"
17
- @obr.universal_service_id.should == "37956^CT ABDOMEN^LN"
18
- end
19
-
20
- it 'allows modification of an OBR segment' do
21
- @obr.set_id = 1
22
- @obr.set_id.should == "1"
23
- @obr.placer_order_number = "^DMCRES"
24
- @obr.placer_order_number.should == "^DMCRES"
25
- end
26
-
27
- it 'supports the diagnostic_serv_sect_id method' do
28
- @obr.should respond_to(:diagnostic_serv_sect_id)
29
- @obr.diagnostic_serv_sect_id.should == "NMR"
30
- end
31
-
32
- it 'supports the result_status method' do
33
- @obr.should respond_to(:result_status)
34
- @obr.result_status.should == "P"
35
- end
36
-
37
- it 'supports the reason_for_study method' do
38
- @obr.reason_for_study.should == "R/O TUMOR"
39
- end
40
-
41
- it 'supports the parent_universal_service_identifier method' do
42
- @obr.parent_universal_service_identifier.should == "123"
43
- end
44
- end
45
- end
@@ -1,46 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
- describe HL7::Message::Segment::OBX do
4
- context 'general' do
5
- before :all do
6
- @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"
7
- end
8
-
9
- it 'allows access to an OBX segment' do
10
- obx = HL7::Message::Segment::OBX.new @base
11
- obx.set_id.should == "1"
12
- obx.value_type.should == "NM"
13
- obx.observation_id.should == "30341-2^Erythrocyte sedimentation rate^LN^815117^ESR^99USI^^^Erythrocyte sedimentation rate"
14
- obx.observation_sub_id.should == ""
15
- obx.observation_value.should == "10"
16
- obx.units.should == "mm/h^millimeter per hour^UCUM"
17
- obx.references_range.should == "0 to 17"
18
- obx.abnormal_flags.should == "N"
19
- obx.probability.should == "0.1"
20
- obx.nature_of_abnormal_test.should == ""
21
- obx.observation_result_status.should == "F"
22
- obx.effective_date_of_reference_range.should == ""
23
- obx.user_defined_access_checks.should == ""
24
- obx.observation_date.should == "20110331140551-0800"
25
- obx.producer_id.should == ""
26
- obx.responsible_observer.should == "Observer"
27
- obx.observation_site.should == '^A Site'
28
- obx.observation_method.should == ""
29
- obx.equipment_instance_id.should == ""
30
- obx.analysis_date.should == "20110331150551-0800"
31
- obx.performing_organization_name.should == "Century Hospital^^^^^NIST-AA-1&2.16.840.1.113883.3.72.5.30.1&ISO^XX^^^987"
32
- obx.performing_organization_address.should == "2070 Test Park^^Los Angeles^CA^90067^USA^B^^06037"
33
- obx.performing_organization_medical_director.should == "2343242^Knowsalot^Phil^J.^III^Dr.^^^NIST-AA-1&2.16.840.1.113883.3.72.5.30.1&ISO^L^^^DN"
34
- end
35
-
36
- it 'allows creation of an OBX segment' do
37
- lambda do
38
- obx = HL7::Message::Segment::OBX.new
39
- obx.value_type = "TESTIES"
40
- obx.observation_id = "HR"
41
- obx.observation_sub_id = "2"
42
- obx.observation_value = "SOMETHING HAPPENned"
43
- end.should_not raise_error
44
- end
45
- end
46
- end
@@ -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
- lambda do
13
- orc = HL7::Message::Segment::ORC.new( @base_orc )
14
- orc.should_not be_nil
15
- orc.to_s.should == @base_orc
16
- end.should_not raise_error
17
- end
18
-
19
- it 'allows access to an ORC segment' do
20
- orc = HL7::Message::Segment::ORC.new( @base_orc )
21
- orc.ordering_provider.should == '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
- orc.call_back_phone_number.should == '^WPN^PH^^1^555^5551005'
23
- orc.ordering_facility_name.should == 'Level Seven Healthcare, Inc.^L^^^^&2.16.840.1.113883.19.4.6^ISO^XX^^^1234'
24
- orc.parent_universal_service_identifier.should == '7844'
25
- end
26
- end
27
- end
@@ -1,70 +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||||||||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
- lambda 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.should_not raise_error
19
-
20
- lambda do
21
- ["TEST", "A", 1, 2].each do |x|
22
- pid.admin_sex = x
23
- end
24
- end.should raise_error(HL7::InvalidDataError)
25
- end
26
-
27
- it "sets values correctly" do
28
- pid = HL7::Message::Segment::PID.new @base
29
- pid.set_id.should == "1"
30
- pid.patient_id.should == ""
31
- pid.patient_id_list.should == "333"
32
- pid.alt_patient_id.should == ""
33
- pid.patient_name.should == "LastName^FirstName^MiddleInitial^SR^NickName"
34
- pid.mother_maiden_name.should == ""
35
- pid.patient_dob.should == "19760228"
36
- pid.admin_sex.should == "F"
37
- pid.patient_alias.should == ""
38
- pid.race.should == "2106-3^White^HL70005^CAUC^Caucasian^L"
39
- pid.address.should == ""
40
- pid.country_code.should == ""
41
- pid.phone_home.should == ""
42
- pid.phone_business.should == ""
43
- pid.primary_language.should == ""
44
- pid.marital_status.should == ""
45
- pid.religion.should == ""
46
- pid.account_number.should == "555.55"
47
- pid.social_security_num.should == "012345678"
48
- pid.driver_license_num.should == ""
49
- pid.mothers_id.should == ""
50
- pid.ethnic_group.should == ""
51
- pid.birthplace.should == ""
52
- pid.multi_birth.should == ""
53
- pid.birth_order.should == ""
54
- pid.citizenship.should == ""
55
- pid.vet_status.should == ""
56
- pid.nationality.should == ""
57
- pid.death_date.should == "201011110924-0700"
58
- pid.death_indicator.should == "Y"
59
- pid.id_unknown_indicator.should == ""
60
- pid.id_readability_code.should == ""
61
- pid.last_update_date.should == ""
62
- pid.last_update_facility.should == ""
63
- pid.species_code.should == ""
64
- pid.breed_code.should == ""
65
- pid.strain.should == ""
66
- pid.production_class_code.should == ""
67
- pid.tribal_citizenship.should == ""
68
- end
69
- end
70
- end