yahl7 0.1.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
  4. data/.github/dependabot.yml +7 -0
  5. data/CHANGELOG.md +64 -0
  6. data/CODE_OF_CONDUCT.md +74 -25
  7. data/CONTRIBUTING.md +47 -0
  8. data/README.md +19 -3
  9. data/lib/yahl7/v2/{segment_field_names.rb → alias_field_names.rb} +14 -7
  10. data/lib/yahl7/v2/alias_person_name.rb +65 -0
  11. data/lib/yahl7/v2/data_type/cnn.rb +29 -0
  12. data/lib/yahl7/v2/data_type/dt.rb +28 -0
  13. data/lib/yahl7/v2/data_type/ft.rb +26 -0
  14. data/lib/yahl7/v2/data_type/ndl.rb +30 -0
  15. data/lib/yahl7/v2/data_type/ts.rb +24 -0
  16. data/lib/yahl7/v2/data_type/xad.rb +31 -0
  17. data/lib/yahl7/v2/data_type/xpn.rb +40 -0
  18. data/lib/yahl7/v2/data_type/xtn.rb +29 -0
  19. data/lib/yahl7/v2/data_type.rb +20 -0
  20. data/lib/yahl7/v2/date_time.rb +1 -1
  21. data/lib/yahl7/v2/error/invalid_format_error.rb +12 -0
  22. data/lib/yahl7/v2/message/adt.rb +2 -0
  23. data/lib/yahl7/v2/message/oru.rb +1 -0
  24. data/lib/yahl7/v2/message.rb +10 -0
  25. data/lib/yahl7/v2/segment/al1.rb +21 -0
  26. data/lib/yahl7/v2/segment/dg1.rb +36 -0
  27. data/lib/yahl7/v2/segment/evn.rb +23 -0
  28. data/lib/yahl7/v2/segment/in1.rb +68 -0
  29. data/lib/yahl7/v2/segment/msh.rb +4 -2
  30. data/lib/yahl7/v2/segment/nte.rb +3 -2
  31. data/lib/yahl7/v2/segment/obr.rb +13 -12
  32. data/lib/yahl7/v2/segment/obx.rb +11 -5
  33. data/lib/yahl7/v2/segment/orc.rb +8 -7
  34. data/lib/yahl7/v2/segment/pd1.rb +36 -0
  35. data/lib/yahl7/v2/segment/pid.rb +11 -10
  36. data/lib/yahl7/v2/segment/pv1.rb +7 -6
  37. data/lib/yahl7/v2.rb +6 -1
  38. data/lib/yahl7/version.rb +1 -1
  39. metadata +23 -3
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YAHL7
4
+ module V2
5
+ class Segment
6
+ # EVN segments are used to communicate necessary trigger information to
7
+ # receiving applications.
8
+ class EVN < YAHL7::V2::Segment
9
+ include YAHL7::V2::AliasFieldNames
10
+
11
+ define_field_names({
12
+ event_type_code: 1,
13
+ recorded_datetime: { index: 2, class: YAHL7::V2::DataType::TS },
14
+ planned_event_datetime: { index: 3, class: YAHL7::V2::DataType::TS },
15
+ event_reason_code: 4,
16
+ operator_id: 5,
17
+ event_occurred: { index: 6, class: YAHL7::V2::DataType::TS },
18
+ event_facility: 7
19
+ })
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YAHL7
4
+ module V2
5
+ class Segment
6
+ # IN1 segments contain patient insurance coverage information.
7
+ class IN1 < YAHL7::V2::Segment
8
+ include YAHL7::V2::AliasFieldNames
9
+
10
+ define_field_names({
11
+ set_id: 1,
12
+ insurance_plan_id: 2,
13
+ insurance_company_id: 3,
14
+ insurance_company_name: 4,
15
+ insurance_company_address: { index: 5, class: YAHL7::V2::DataType::XAD },
16
+ insurance_company_contact_person: { index: 6, class: YAHL7::V2::DataType::XPN },
17
+ insurance_company_contact_number: { index: 7, class: YAHL7::V2::DataType::XTN },
18
+ group_number: 8,
19
+ group_name: 9,
20
+ insured_group_employee_id: 10,
21
+ insured_group_employee_name: 11,
22
+ plan_effective_date: { index: 12, class: YAHL7::V2::DataType::DT },
23
+ plan_expiration_date: { index: 13, class: YAHL7::V2::DataType::DT },
24
+ authorization_information: 14,
25
+ plan_type: 15,
26
+ insured_name: { index: 16, class: YAHL7::V2::DataType::XPN },
27
+ insured_relationship_to_patient: 17,
28
+ insured_date_of_birth: 18,
29
+ insured_address: { index: 19, class: YAHL7::V2::DataType::XAD },
30
+ assignment_of_benefits: 20,
31
+ coordination_of_benefits: 21,
32
+ coordination_of_benefit_priority: 22,
33
+ notice_of_admission_flag: 23,
34
+ notice_of_admission_date: { index: 24, class: YAHL7::V2::DataType::DT },
35
+ report_of_eligibility_flag: 25,
36
+ report_of_eligibility_date: { index: 26, class: YAHL7::V2::DataType::DT },
37
+ release_information_code: 27,
38
+ preadmit_certification: 28,
39
+ verification_datetime: 29,
40
+ verification_by: 30,
41
+ type_of_agreement_code: 31,
42
+ billing_status: 32,
43
+ lifetime_reserve_days: 33,
44
+ delay_before_lifetime_reserve_days: 34,
45
+ company_plan_code: 35,
46
+ policy_number: 36,
47
+ policy_deductible: 37,
48
+ policy_limit_amount: 38,
49
+ policy_limit_days: 39,
50
+ room_rate_semi_private: 40,
51
+ room_rate_private: 41,
52
+ insured_employment_status: 42,
53
+ insured_administrative_sex: 43,
54
+ insured_employer_address: { index: 44, class: YAHL7::V2::DataType::XAD },
55
+ verification_status: 45,
56
+ prior_insurance_plan_id: 46,
57
+ coverage_type: 47,
58
+ handicap: 48,
59
+ insured_id_number: 49,
60
+ signature_code: 50,
61
+ signature_code_date: { index: 51, class: YAHL7::V2::DataType::DT },
62
+ insured_birth_place: 52,
63
+ vip_indicator: 53
64
+ })
65
+ end
66
+ end
67
+ end
68
+ end
@@ -3,8 +3,10 @@
3
3
  module YAHL7
4
4
  module V2
5
5
  class Segment
6
+ # MSH segments contain the intent, source, and destination of the HL7
7
+ # message.
6
8
  class MSH < YAHL7::V2::Segment
7
- include YAHL7::V2::SegmentFieldNames
9
+ include YAHL7::V2::AliasFieldNames
8
10
 
9
11
  define_field_names({
10
12
  field_separator: 1,
@@ -13,7 +15,7 @@ module YAHL7
13
15
  sending_facility: 4,
14
16
  receiving_application: 5,
15
17
  receiving_facility: 6,
16
- message_datetime: 7,
18
+ message_datetime: { index: 7, class: YAHL7::V2::DataType::TS },
17
19
  security: 8,
18
20
  message_type: 9,
19
21
  message_control_id: 10,
@@ -3,13 +3,14 @@
3
3
  module YAHL7
4
4
  module V2
5
5
  class Segment
6
+ # NTE segments contain notes and comments.
6
7
  class NTE < YAHL7::V2::Segment
7
- include YAHL7::V2::SegmentFieldNames
8
+ include YAHL7::V2::AliasFieldNames
8
9
 
9
10
  define_field_names({
10
11
  set_id: 1,
11
12
  source_of_comment: 2,
12
- comment: 3,
13
+ comment: { index: 3, class: YAHL7::V2::DataType::FT },
13
14
  comment_type: 4
14
15
  })
15
16
  end
@@ -3,8 +3,9 @@
3
3
  module YAHL7
4
4
  module V2
5
5
  class Segment
6
+ # OBR segments contain observation request information about a patient.
6
7
  class OBR < YAHL7::V2::Segment
7
- include YAHL7::V2::SegmentFieldNames
8
+ include YAHL7::V2::AliasFieldNames
8
9
 
9
10
  define_field_names({
10
11
  set_id: 1,
@@ -12,23 +13,23 @@ module YAHL7
12
13
  filler_order_number: 3,
13
14
  universal_service_identifier: 4,
14
15
  priority: 5,
15
- requested_datetime: 6,
16
- observation_datetime: 7,
17
- observation_end_datetime: 8,
16
+ requested_datetime: { index: 6, class: YAHL7::V2::DataType::TS },
17
+ observation_datetime: { index: 7, class: YAHL7::V2::DataType::TS },
18
+ observation_end_datetime: { index: 8, class: YAHL7::V2::DataType::TS },
18
19
  collection_volume: 9,
19
20
  collector_identifier: 10,
20
21
  specimen_action_code: 11,
21
22
  danger_code: 12,
22
23
  relevant_clinical_information: 13,
23
- specimen_received_datetime: 14,
24
+ specimen_received_datetime: { index: 14, class: YAHL7::V2::DataType::TS },
24
25
  specimen_source: 15,
25
26
  ordering_provider: 16,
26
- order_callback_phone_number: 17,
27
+ order_callback_phone_number: { index: 17, class: YAHL7::V2::DataType::XTN },
27
28
  placer_field1: 18,
28
29
  placer_field2: 19,
29
30
  filler_field1: 20,
30
31
  filler_field2: 21,
31
- result_report_datetime: 22,
32
+ result_report_datetime: { index: 22, class: YAHL7::V2::DataType::TS },
32
33
  charge_to_practice: 23,
33
34
  diagnostic_service_section_id: 24,
34
35
  result_status: 25,
@@ -38,11 +39,11 @@ module YAHL7
38
39
  parent: 29,
39
40
  transportation_mode: 30,
40
41
  reason_for_study: 31,
41
- principal_result_interpreter: 32,
42
- assistant_result_interpreter: 33,
43
- technician: 34,
44
- transcriptionist: 35,
45
- scheduled_datetime: 36,
42
+ principal_result_interpreter: { index: 32, class: YAHL7::V2::DataType::NDL },
43
+ assistant_result_interpreter: { index: 33, class: YAHL7::V2::DataType::NDL },
44
+ technician: { index: 34, class: YAHL7::V2::DataType::NDL },
45
+ transcriptionist: { index: 35, class: YAHL7::V2::DataType::NDL },
46
+ scheduled_datetime: { index: 36, class: YAHL7::V2::DataType::TS },
46
47
  number_of_sample_containers: 37,
47
48
  transport_logistics_collected_samples: 38,
48
49
  collector_comment: 39,
@@ -3,30 +3,36 @@
3
3
  module YAHL7
4
4
  module V2
5
5
  class Segment
6
+ # OBX segments contain observation result information.
6
7
  class OBX < YAHL7::V2::Segment
7
- include YAHL7::V2::SegmentFieldNames
8
+ include YAHL7::V2::AliasFieldNames
8
9
 
9
10
  define_field_names({
10
11
  set_id: 1,
11
12
  value_type: 2,
12
13
  observation_identifier: 3,
13
14
  observation_sub_id: 4,
14
- observation_value: 5,
15
+ # Skip observation_value; the logic here is
16
+ # somewhat complex
15
17
  units: 6,
16
18
  reference_range: 7,
17
19
  abnormal_flags: 8,
18
20
  probability: 9,
19
21
  nature_of_abnormal_test: 10,
20
22
  observation_result_status: 11,
21
- effective_date_of_reference_range: 12,
23
+ effective_date_of_reference_range: { index: 12, class: YAHL7::V2::DataType::TS },
22
24
  user_defined_access_checks: 13,
23
- observation_datetime: 14,
25
+ observation_datetime: { index: 14, class: YAHL7::V2::DataType::TS },
24
26
  producer_id: 15,
25
27
  responsible_observer: 16,
26
28
  observation_method: 17,
27
29
  equipment_instance_identifier: 18,
28
- analysis_datetime: 19
30
+ analysis_datetime: { index: 19, class: YAHL7::V2::DataType::TS }
29
31
  })
32
+
33
+ def observation_value
34
+ self[5]
35
+ end
30
36
  end
31
37
  end
32
38
  end
@@ -3,8 +3,9 @@
3
3
  module YAHL7
4
4
  module V2
5
5
  class Segment
6
+ # ORC segments contain information common to all orders.
6
7
  class ORC < YAHL7::V2::Segment
7
- include YAHL7::V2::SegmentFieldNames
8
+ include YAHL7::V2::AliasFieldNames
8
9
 
9
10
  define_field_names({
10
11
  order_control: 1,
@@ -20,20 +21,20 @@ module YAHL7
20
21
  verified_by: 11,
21
22
  ordering_provider: 12,
22
23
  enterer_location: 13,
23
- callback_phone_number: 14,
24
- order_effective_datetime: 15,
24
+ callback_phone_number: { index: 14, class: YAHL7::V2::DataType::XTN },
25
+ order_effective_datetime: { index: 15, class: YAHL7::V2::DataType::TS },
25
26
  order_control_code_reason: 16,
26
27
  entering_organization: 17,
27
28
  entering_device: 18,
28
29
  action_by: 19,
29
30
  advanced_beneficiary_notice_code: 20,
30
31
  ordering_facility_name: 21,
31
- ordering_facility_address: 22,
32
- ordering_facility_phone_number: 23,
33
- ordering_provider_address: 24,
32
+ ordering_facility_address: { index: 22, class: YAHL7::V2::DataType::XAD },
33
+ ordering_facility_phone_number: { index: 23, class: YAHL7::V2::DataType::XTN },
34
+ ordering_provider_address: { index: 24, class: YAHL7::V2::DataType::XAD },
34
35
  order_status_modifier: 25,
35
36
  advanced_beneficiary_notice_override_reason: 26,
36
- filler_expected_availability_datetime: 27,
37
+ filler_expected_availability_datetime: { index: 27, class: YAHL7::V2::DataType::TS },
37
38
  confidentiality_code: 28,
38
39
  order_type: 29,
39
40
  enterer_authorization_code: 30
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YAHL7
4
+ module V2
5
+ class Segment
6
+ # PD1 segments contain additional patient demographic information.
7
+ class PD1 < YAHL7::V2::Segment
8
+ include YAHL7::V2::AliasFieldNames
9
+
10
+ define_field_names({
11
+ living_dependency: 1,
12
+ living_arrangement: 2,
13
+ patient_primary_facility: 3,
14
+ patient_primary_care_provider: 4,
15
+ student_indicator: 5,
16
+ handicap: 6,
17
+ living_will_code: 7,
18
+ organ_donor_code: 8,
19
+ separate_bill: 9,
20
+ duplicate_patient: 10,
21
+ publicity_code: 11,
22
+ protection_indicator: 12,
23
+ protection_indicator_effective_date: { index: 13, class: YAHL7::V2::DataType::DT },
24
+ place_of_worship: 14,
25
+ advance_directive_code: 15,
26
+ immunization_registry_status: 16,
27
+ immunization_registry_status_effective_date: { index: 17, class: YAHL7::V2::DataType::DT },
28
+ publicity_code_effective_date: { index: 18, class: YAHL7::V2::DataType::DT },
29
+ military_branch: 19,
30
+ military_rank_grade: 20,
31
+ military_status: 21
32
+ })
33
+ end
34
+ end
35
+ end
36
+ end
@@ -3,24 +3,25 @@
3
3
  module YAHL7
4
4
  module V2
5
5
  class Segment
6
+ # PID segments contain standard patient demographic information.
6
7
  class PID < YAHL7::V2::Segment
7
- include YAHL7::V2::SegmentFieldNames
8
+ include YAHL7::V2::AliasFieldNames
8
9
 
9
10
  define_field_names({
10
11
  set_id: 1,
11
12
  patient_id: 2,
12
13
  patient_identifier_list: 3,
13
14
  alternate_patient_id: 4,
14
- patient_name: 5,
15
- mothers_maiden_name: 6,
16
- datetime_of_birth: 7,
15
+ patient_name: { index: 5, class: YAHL7::V2::DataType::XPN },
16
+ mothers_maiden_name: { index: 6, class: YAHL7::V2::DataType::XPN },
17
+ datetime_of_birth: { index: 7, class: YAHL7::V2::DataType::TS },
17
18
  administrative_sex: 8,
18
- patient_alias: 9,
19
+ patient_alias: { index: 9, class: YAHL7::V2::DataType::XPN },
19
20
  patient_race: 10,
20
- patient_address: 11,
21
+ patient_address: { index: 11, class: YAHL7::V2::DataType::XAD },
21
22
  country_code: 12,
22
- phone_number_home: 13,
23
- phone_number_business: 14,
23
+ phone_number_home: { index: 13, class: YAHL7::V2::DataType::XTN },
24
+ phone_number_business: { index: 14, class: YAHL7::V2::DataType::XTN },
24
25
  primary_language: 15,
25
26
  marital_status: 16,
26
27
  religion: 17,
@@ -35,11 +36,11 @@ module YAHL7
35
36
  citizenship: 26,
36
37
  veteran_military_service: 27,
37
38
  nationality: 28,
38
- patient_death_datetime: 29,
39
+ patient_death_datetime: { index: 29, class: YAHL7::V2::DataType::TS },
39
40
  patient_death_indicator: 30,
40
41
  identity_unknown_indicator: 31,
41
42
  identity_reliability_code: 32,
42
- last_update_datetime: 33,
43
+ last_update_datetime: { index: 33, class: YAHL7::V2::DataType::TS },
43
44
  last_update_facility: 34,
44
45
  species_code: 35,
45
46
  breed_code: 36,
@@ -3,8 +3,9 @@
3
3
  module YAHL7
4
4
  module V2
5
5
  class Segment
6
+ # PV1 segments contain information about the patient visit.
6
7
  class PV1 < YAHL7::V2::Segment
7
- include YAHL7::V2::SegmentFieldNames
8
+ include YAHL7::V2::AliasFieldNames
8
9
 
9
10
  define_field_names({
10
11
  set_id: 1,
@@ -31,17 +32,17 @@ module YAHL7
31
32
  courtesy_code: 22,
32
33
  credit_rating: 23,
33
34
  contract_code: 24,
34
- contract_effective_date: 25,
35
+ contract_effective_date: { index: 25, class: YAHL7::V2::DataType::DT },
35
36
  contract_amount: 26,
36
37
  contract_period: 27,
37
38
  interest_code: 28,
38
39
  transfer_to_bad_debt_code: 29,
39
- transfer_to_bad_debt_date: 30,
40
+ transfer_to_bad_debt_date: { index: 30, class: YAHL7::V2::DataType::DT },
40
41
  bad_debt_agency_code: 31,
41
42
  bad_debt_transfer_amount: 32,
42
43
  bad_debt_recovery_amount: 33,
43
44
  delete_account_indicator: 34,
44
- delete_account_date: 35,
45
+ delete_account_date: { index: 35, class: YAHL7::V2::DataType::DT },
45
46
  discharge_disposition: 36,
46
47
  discharged_to_location: 37,
47
48
  diet_type: 38,
@@ -50,8 +51,8 @@ module YAHL7
50
51
  account_status: 41,
51
52
  pending_location: 42,
52
53
  prior_temporary_location: 43,
53
- admit_datetime: 44,
54
- discharge_datetime: 45,
54
+ admit_datetime: { index: 44, class: YAHL7::V2::DataType::TS },
55
+ discharge_datetime: { index: 45, class: YAHL7::V2::DataType::TS },
55
56
  current_patient_balance: 46,
56
57
  total_charges: 47,
57
58
  total_adjustments: 48,
data/lib/yahl7/v2.rb CHANGED
@@ -1,8 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'v2/segment_field_names'
3
+ Dir[File.join(__dir__, 'v2', 'error', '*.rb')].sort.each { |f| require f }
4
+
5
+ require_relative 'v2/alias_field_names'
6
+ require_relative 'v2/alias_person_name'
7
+ require_relative 'v2/data_type'
4
8
  require_relative 'v2/date_time'
5
9
  require_relative 'v2/formatter'
10
+
6
11
  require_relative 'v2/parser'
7
12
 
8
13
  module YAHL7
data/lib/yahl7/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YAHL7
4
- VERSION = '0.1.0'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahl7
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mylan Connolly
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-31 00:00:00.000000000 Z
11
+ date: 2021-09-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple HL7 parser that focuses on being robust and easy to use
14
14
  email:
@@ -17,12 +17,16 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
21
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
22
+ - ".github/dependabot.yml"
20
23
  - ".github/workflows/main.yml"
21
24
  - ".gitignore"
22
25
  - ".rspec"
23
26
  - ".rubocop.yml"
24
27
  - CHANGELOG.md
25
28
  - CODE_OF_CONDUCT.md
29
+ - CONTRIBUTING.md
26
30
  - ERRATA.md
27
31
  - Gemfile
28
32
  - LICENSE.txt
@@ -32,7 +36,19 @@ files:
32
36
  - bin/setup
33
37
  - lib/yahl7.rb
34
38
  - lib/yahl7/v2.rb
39
+ - lib/yahl7/v2/alias_field_names.rb
40
+ - lib/yahl7/v2/alias_person_name.rb
41
+ - lib/yahl7/v2/data_type.rb
42
+ - lib/yahl7/v2/data_type/cnn.rb
43
+ - lib/yahl7/v2/data_type/dt.rb
44
+ - lib/yahl7/v2/data_type/ft.rb
45
+ - lib/yahl7/v2/data_type/ndl.rb
46
+ - lib/yahl7/v2/data_type/ts.rb
47
+ - lib/yahl7/v2/data_type/xad.rb
48
+ - lib/yahl7/v2/data_type/xpn.rb
49
+ - lib/yahl7/v2/data_type/xtn.rb
35
50
  - lib/yahl7/v2/date_time.rb
51
+ - lib/yahl7/v2/error/invalid_format_error.rb
36
52
  - lib/yahl7/v2/field_parser.rb
37
53
  - lib/yahl7/v2/formatter.rb
38
54
  - lib/yahl7/v2/message.rb
@@ -44,14 +60,18 @@ files:
44
60
  - lib/yahl7/v2/scanner/io.rb
45
61
  - lib/yahl7/v2/scanner/string.rb
46
62
  - lib/yahl7/v2/segment.rb
63
+ - lib/yahl7/v2/segment/al1.rb
64
+ - lib/yahl7/v2/segment/dg1.rb
65
+ - lib/yahl7/v2/segment/evn.rb
66
+ - lib/yahl7/v2/segment/in1.rb
47
67
  - lib/yahl7/v2/segment/msh.rb
48
68
  - lib/yahl7/v2/segment/nte.rb
49
69
  - lib/yahl7/v2/segment/obr.rb
50
70
  - lib/yahl7/v2/segment/obx.rb
51
71
  - lib/yahl7/v2/segment/orc.rb
72
+ - lib/yahl7/v2/segment/pd1.rb
52
73
  - lib/yahl7/v2/segment/pid.rb
53
74
  - lib/yahl7/v2/segment/pv1.rb
54
- - lib/yahl7/v2/segment_field_names.rb
55
75
  - lib/yahl7/version.rb
56
76
  - yahl7.gemspec
57
77
  homepage: https://github.com/mylanconnolly/yahl7