ruby-hl7 1.0.3 → 1.1.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 +7 -0
 - data/README.rdoc +5 -5
 - data/lib/core_ext/date_time.rb +65 -0
 - data/lib/core_ext/string.rb +6 -0
 - data/lib/message.rb +272 -0
 - data/lib/message_parser.rb +75 -0
 - data/lib/ruby-hl7.rb +15 -637
 - data/lib/segment.rb +189 -0
 - data/lib/segment_default.rb +18 -0
 - data/lib/segment_fields.rb +117 -0
 - data/lib/segment_generator.rb +55 -0
 - data/lib/segment_list_storage.rb +79 -0
 - data/lib/segments/evn.rb +14 -8
 - data/lib/segments/in1.rb +54 -0
 - data/lib/segments/msh.rb +23 -17
 - data/lib/segments/obr.rb +23 -10
 - data/lib/segments/obx.rb +15 -4
 - data/lib/segments/orc.rb +19 -3
 - data/lib/segments/pid.rb +13 -6
 - data/lib/segments/prd.rb +18 -0
 - data/lib/segments/pv1.rb +6 -2
 - data/lib/segments/pv2.rb +18 -15
 - data/lib/segments/rf1.rb +22 -0
 - data/lib/segments/zcf.rb +23 -0
 - data/test_data/obxobr.hl7 +1 -1
 - metadata +94 -110
 - data/lib/string.rb +0 -5
 
    
        data/lib/segments/evn.rb
    CHANGED
    
    | 
         @@ -1,12 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: UTF-8
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'ruby-hl7'
         
     | 
| 
       3 
3 
     | 
    
         
             
            class HL7::Message::Segment::EVN < HL7::Message::Segment
         
     | 
| 
       4 
     | 
    
         
            -
              weight 0 # should occur after the MSH segment 
     | 
| 
       5 
     | 
    
         
            -
              add_field :type_code 
     | 
| 
       6 
     | 
    
         
            -
              add_field :recorded_date 
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
       9 
     | 
    
         
            -
              add_field : 
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
               
     | 
| 
      
 4 
     | 
    
         
            +
              weight 0 # should occur after the MSH segment
         
     | 
| 
      
 5 
     | 
    
         
            +
              add_field :type_code
         
     | 
| 
      
 6 
     | 
    
         
            +
              add_field :recorded_date do |value|
         
     | 
| 
      
 7 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              add_field :planned_date do |value|
         
     | 
| 
      
 10 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
              add_field :reason_code
         
     | 
| 
      
 13 
     | 
    
         
            +
              add_field :operator_id
         
     | 
| 
      
 14 
     | 
    
         
            +
              add_field :event_occurred do |value|
         
     | 
| 
      
 15 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              add_field :event_facility
         
     | 
| 
       12 
18 
     | 
    
         
             
            end
         
     | 
    
        data/lib/segments/in1.rb
    ADDED
    
    | 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: UTF-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            # via https://github.com/bbhoss/ruby-hl7/blob/master/lib/segments/in1.rb
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'ruby-hl7'
         
     | 
| 
      
 4 
     | 
    
         
            +
            class HL7::Message::Segment::IN1 < HL7::Message::Segment
         
     | 
| 
      
 5 
     | 
    
         
            +
              add_field :set_id
         
     | 
| 
      
 6 
     | 
    
         
            +
              add_field :insurance_plan_id
         
     | 
| 
      
 7 
     | 
    
         
            +
              add_field :insurance_company_id
         
     | 
| 
      
 8 
     | 
    
         
            +
              add_field :insurance_company_name
         
     | 
| 
      
 9 
     | 
    
         
            +
              add_field :insurance_company_address
         
     | 
| 
      
 10 
     | 
    
         
            +
              add_field :insurance_company_contact_person
         
     | 
| 
      
 11 
     | 
    
         
            +
              add_field :insurance_company_phone_number
         
     | 
| 
      
 12 
     | 
    
         
            +
              add_field :group_number
         
     | 
| 
      
 13 
     | 
    
         
            +
              add_field :group_name
         
     | 
| 
      
 14 
     | 
    
         
            +
              add_field :insureds_group_employee_id
         
     | 
| 
      
 15 
     | 
    
         
            +
              add_field :insureds_group_employee_name
         
     | 
| 
      
 16 
     | 
    
         
            +
              add_field :plan_effective_date
         
     | 
| 
      
 17 
     | 
    
         
            +
              add_field :plan_expiration_date
         
     | 
| 
      
 18 
     | 
    
         
            +
              add_field :authorization_information
         
     | 
| 
      
 19 
     | 
    
         
            +
              add_field :plan_type
         
     | 
| 
      
 20 
     | 
    
         
            +
              add_field :name_of_insured
         
     | 
| 
      
 21 
     | 
    
         
            +
              add_field :insureds_relationship_to_patient
         
     | 
| 
      
 22 
     | 
    
         
            +
              add_field :insureds_date_of_birth
         
     | 
| 
      
 23 
     | 
    
         
            +
              add_field :insureds_address
         
     | 
| 
      
 24 
     | 
    
         
            +
              add_field :assignment_of_benefits
         
     | 
| 
      
 25 
     | 
    
         
            +
              add_field :coordination_of_benefits
         
     | 
| 
      
 26 
     | 
    
         
            +
              add_field :coordination_of_benefits_priority
         
     | 
| 
      
 27 
     | 
    
         
            +
              add_field :notice_of_admission_flag
         
     | 
| 
      
 28 
     | 
    
         
            +
              add_field :notice_of_admission_date
         
     | 
| 
      
 29 
     | 
    
         
            +
              add_field :report_of_eligibility_flag
         
     | 
| 
      
 30 
     | 
    
         
            +
              add_field :report_of_eligibility_date
         
     | 
| 
      
 31 
     | 
    
         
            +
              add_field :release_information_code
         
     | 
| 
      
 32 
     | 
    
         
            +
              add_field :pre_admit_cert
         
     | 
| 
      
 33 
     | 
    
         
            +
              add_field :verification_date_time
         
     | 
| 
      
 34 
     | 
    
         
            +
              add_field :verification_by
         
     | 
| 
      
 35 
     | 
    
         
            +
              add_field :type_of_agreement_code
         
     | 
| 
      
 36 
     | 
    
         
            +
              add_field :billing_status
         
     | 
| 
      
 37 
     | 
    
         
            +
              add_field :lifetime_reserve_days
         
     | 
| 
      
 38 
     | 
    
         
            +
              add_field :delay_before_lr_day
         
     | 
| 
      
 39 
     | 
    
         
            +
              add_field :company_plan_code
         
     | 
| 
      
 40 
     | 
    
         
            +
              add_field :policy_number
         
     | 
| 
      
 41 
     | 
    
         
            +
              add_field :policy_deductible
         
     | 
| 
      
 42 
     | 
    
         
            +
              add_field :policy_limit_amount
         
     | 
| 
      
 43 
     | 
    
         
            +
              add_field :policy_limit_days
         
     | 
| 
      
 44 
     | 
    
         
            +
              add_field :room_rate_semi_private
         
     | 
| 
      
 45 
     | 
    
         
            +
              add_field :room_rate_private
         
     | 
| 
      
 46 
     | 
    
         
            +
              add_field :insureds_employment_status
         
     | 
| 
      
 47 
     | 
    
         
            +
              add_field :insureds_sex
         
     | 
| 
      
 48 
     | 
    
         
            +
              add_field :insureds_employer_address
         
     | 
| 
      
 49 
     | 
    
         
            +
              add_field :verification_status
         
     | 
| 
      
 50 
     | 
    
         
            +
              add_field :prior_insurance_plan_id
         
     | 
| 
      
 51 
     | 
    
         
            +
              add_field :coverage_type
         
     | 
| 
      
 52 
     | 
    
         
            +
              add_field :handicap
         
     | 
| 
      
 53 
     | 
    
         
            +
              add_field :insureds_id_number
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/segments/msh.rb
    CHANGED
    
    | 
         @@ -2,24 +2,30 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'ruby-hl7'
         
     | 
| 
       3 
3 
     | 
    
         
             
            class HL7::Message::Segment::MSH < HL7::Message::Segment
         
     | 
| 
       4 
4 
     | 
    
         
             
              weight( -1 ) # the msh should always start a message
         
     | 
| 
       5 
     | 
    
         
            -
              add_field :enc_chars 
     | 
| 
       6 
     | 
    
         
            -
              add_field :sending_app 
     | 
| 
       7 
     | 
    
         
            -
              add_field :sending_facility 
     | 
| 
       8 
     | 
    
         
            -
              add_field :recv_app 
     | 
| 
       9 
     | 
    
         
            -
              add_field :recv_facility 
     | 
| 
       10 
     | 
    
         
            -
              add_field :time 
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
               
     | 
| 
       13 
     | 
    
         
            -
              add_field : 
     | 
| 
       14 
     | 
    
         
            -
              add_field : 
     | 
| 
       15 
     | 
    
         
            -
              add_field : 
     | 
| 
       16 
     | 
    
         
            -
              add_field : 
     | 
| 
       17 
     | 
    
         
            -
              add_field : 
     | 
| 
       18 
     | 
    
         
            -
              add_field : 
     | 
| 
       19 
     | 
    
         
            -
              add_field : 
     | 
| 
       20 
     | 
    
         
            -
              add_field : 
     | 
| 
       21 
     | 
    
         
            -
              add_field : 
     | 
| 
      
 5 
     | 
    
         
            +
              add_field :enc_chars
         
     | 
| 
      
 6 
     | 
    
         
            +
              add_field :sending_app
         
     | 
| 
      
 7 
     | 
    
         
            +
              add_field :sending_facility
         
     | 
| 
      
 8 
     | 
    
         
            +
              add_field :recv_app
         
     | 
| 
      
 9 
     | 
    
         
            +
              add_field :recv_facility
         
     | 
| 
      
 10 
     | 
    
         
            +
              add_field :time do |value|
         
     | 
| 
      
 11 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              add_field :security
         
     | 
| 
      
 14 
     | 
    
         
            +
              add_field :message_type
         
     | 
| 
      
 15 
     | 
    
         
            +
              add_field :message_control_id
         
     | 
| 
      
 16 
     | 
    
         
            +
              add_field :processing_id
         
     | 
| 
      
 17 
     | 
    
         
            +
              add_field :version_id
         
     | 
| 
      
 18 
     | 
    
         
            +
              add_field :seq
         
     | 
| 
      
 19 
     | 
    
         
            +
              add_field :continue_ptr
         
     | 
| 
      
 20 
     | 
    
         
            +
              add_field :accept_ack_type
         
     | 
| 
      
 21 
     | 
    
         
            +
              add_field :app_ack_type
         
     | 
| 
      
 22 
     | 
    
         
            +
              add_field :country_code
         
     | 
| 
      
 23 
     | 
    
         
            +
              add_field :charset
         
     | 
| 
       22 
24 
     | 
    
         
             
              add_field :principal_language_of_message
         
     | 
| 
       23 
25 
     | 
    
         
             
              add_field :alternate_character_set_handling_scheme
         
     | 
| 
       24 
26 
     | 
    
         
             
              add_field :message_profile_identifier
         
     | 
| 
      
 27 
     | 
    
         
            +
              add_field :sending_responsible_org
         
     | 
| 
      
 28 
     | 
    
         
            +
              add_field :receiving_responsible_org
         
     | 
| 
      
 29 
     | 
    
         
            +
              add_field :sending_network_address
         
     | 
| 
      
 30 
     | 
    
         
            +
              add_field :receiving_network_address
         
     | 
| 
       25 
31 
     | 
    
         
             
            end
         
     | 
    
        data/lib/segments/obr.rb
    CHANGED
    
    | 
         @@ -1,30 +1,40 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: UTF-8
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'ruby-hl7'
         
     | 
| 
       3 
3 
     | 
    
         
             
            class HL7::Message::Segment::OBR < HL7::Message::Segment
         
     | 
| 
       4 
     | 
    
         
            -
              weight 89 #  
     | 
| 
       5 
     | 
    
         
            -
              has_children [:NTE,:OBX,: 
     | 
| 
      
 4 
     | 
    
         
            +
              weight 89 # obx.weight-1
         
     | 
| 
      
 5 
     | 
    
         
            +
              has_children [:NTE,:OBX,:SPM]
         
     | 
| 
       6 
6 
     | 
    
         
             
              add_field :set_id
         
     | 
| 
       7 
7 
     | 
    
         
             
              add_field :placer_order_number
         
     | 
| 
       8 
8 
     | 
    
         
             
              add_field :filler_order_number
         
     | 
| 
       9 
9 
     | 
    
         
             
              add_field :universal_service_id
         
     | 
| 
       10 
10 
     | 
    
         
             
              add_field :priority
         
     | 
| 
       11 
     | 
    
         
            -
              add_field :requested_date
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
               
     | 
| 
      
 11 
     | 
    
         
            +
              add_field :requested_date do |value|
         
     | 
| 
      
 12 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              add_field :observation_date do |value|
         
     | 
| 
      
 15 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              add_field :observation_end_date do |value|
         
     | 
| 
      
 18 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
       14 
20 
     | 
    
         
             
              add_field :collection_volume
         
     | 
| 
       15 
21 
     | 
    
         
             
              add_field :collector_identifier
         
     | 
| 
       16 
22 
     | 
    
         
             
              add_field :specimen_action_code
         
     | 
| 
       17 
23 
     | 
    
         
             
              add_field :danger_code
         
     | 
| 
       18 
24 
     | 
    
         
             
              add_field :relevant_clinical_info
         
     | 
| 
       19 
     | 
    
         
            -
              add_field :specimen_received_date
         
     | 
| 
      
 25 
     | 
    
         
            +
              add_field :specimen_received_date do |value|
         
     | 
| 
      
 26 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
       20 
28 
     | 
    
         
             
              add_field :specimen_source
         
     | 
| 
       21 
29 
     | 
    
         
             
              add_field :ordering_provider
         
     | 
| 
       22 
30 
     | 
    
         
             
              add_field :order_callback_phone_number
         
     | 
| 
       23 
31 
     | 
    
         
             
              add_field :placer_field_1
         
     | 
| 
       24 
32 
     | 
    
         
             
              add_field :placer_field_2
         
     | 
| 
       25 
     | 
    
         
            -
              add_field : 
     | 
| 
       26 
     | 
    
         
            -
              add_field : 
     | 
| 
       27 
     | 
    
         
            -
              add_field :results_status_change_date
         
     | 
| 
      
 33 
     | 
    
         
            +
              add_field :filer_field_1
         
     | 
| 
      
 34 
     | 
    
         
            +
              add_field :filer_field_2
         
     | 
| 
      
 35 
     | 
    
         
            +
              add_field :results_status_change_date do |value|
         
     | 
| 
      
 36 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
       28 
38 
     | 
    
         
             
              add_field :charge_to_practice
         
     | 
| 
       29 
39 
     | 
    
         
             
              add_field :diagnostic_serv_sect_id
         
     | 
| 
       30 
40 
     | 
    
         
             
              add_field :result_status
         
     | 
| 
         @@ -38,7 +48,9 @@ class HL7::Message::Segment::OBR < HL7::Message::Segment 
     | 
|
| 
       38 
48 
     | 
    
         
             
              add_field :assistant_result_interpreter
         
     | 
| 
       39 
49 
     | 
    
         
             
              add_field :technician
         
     | 
| 
       40 
50 
     | 
    
         
             
              add_field :transcriptionist
         
     | 
| 
       41 
     | 
    
         
            -
              add_field :scheduled_date
         
     | 
| 
      
 51 
     | 
    
         
            +
              add_field :scheduled_date do |value|
         
     | 
| 
      
 52 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
       42 
54 
     | 
    
         
             
              add_field :number_of_sample_containers
         
     | 
| 
       43 
55 
     | 
    
         
             
              add_field :transport_logistics_of_sample
         
     | 
| 
       44 
56 
     | 
    
         
             
              add_field :collectors_comment
         
     | 
| 
         @@ -52,4 +64,5 @@ class HL7::Message::Segment::OBR < HL7::Message::Segment 
     | 
|
| 
       52 
64 
     | 
    
         
             
              add_field :filler_supplemental_service_info
         
     | 
| 
       53 
65 
     | 
    
         
             
              add_field :medically_necessary_dup_procedure_reason #longest method name ever. sry.
         
     | 
| 
       54 
66 
     | 
    
         
             
              add_field :result_handling
         
     | 
| 
      
 67 
     | 
    
         
            +
              add_field :parent_universal_service_identifier
         
     | 
| 
       55 
68 
     | 
    
         
             
            end
         
     | 
    
        data/lib/segments/obx.rb
    CHANGED
    
    | 
         @@ -14,14 +14,25 @@ class HL7::Message::Segment::OBX < HL7::Message::Segment 
     | 
|
| 
       14 
14 
     | 
    
         
             
              add_field :probability
         
     | 
| 
       15 
15 
     | 
    
         
             
              add_field :nature_of_abnormal_test
         
     | 
| 
       16 
16 
     | 
    
         
             
              add_field :observation_result_status
         
     | 
| 
       17 
     | 
    
         
            -
              add_field :effective_date_of_reference_range
         
     | 
| 
      
 17 
     | 
    
         
            +
              add_field :effective_date_of_reference_range do |value|
         
     | 
| 
      
 18 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
       18 
20 
     | 
    
         
             
              add_field :user_defined_access_checks
         
     | 
| 
       19 
     | 
    
         
            -
              add_field :observation_date
         
     | 
| 
      
 21 
     | 
    
         
            +
              add_field :observation_date do |value|
         
     | 
| 
      
 22 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
       20 
24 
     | 
    
         
             
              add_field :producer_id
         
     | 
| 
       21 
25 
     | 
    
         
             
              add_field :responsible_observer
         
     | 
| 
       22 
26 
     | 
    
         
             
              add_field :observation_method
         
     | 
| 
       23 
27 
     | 
    
         
             
              add_field :equipment_instance_id
         
     | 
| 
       24 
     | 
    
         
            -
              add_field :analysis_date
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
              add_field :analysis_date do |value|
         
     | 
| 
      
 29 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
              add_field :observation_site
         
     | 
| 
      
 32 
     | 
    
         
            +
              add_field :observation_instance_id
         
     | 
| 
      
 33 
     | 
    
         
            +
              add_field :mood_code
         
     | 
| 
      
 34 
     | 
    
         
            +
              add_field :performing_organization_name
         
     | 
| 
      
 35 
     | 
    
         
            +
              add_field :performing_organization_address
         
     | 
| 
      
 36 
     | 
    
         
            +
              add_field :performing_organization_medical_director
         
     | 
| 
       26 
37 
     | 
    
         
             
            end
         
     | 
| 
       27 
38 
     | 
    
         | 
    
        data/lib/segments/orc.rb
    CHANGED
    
    | 
         @@ -1,6 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: UTF-8
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'ruby-hl7'
         
     | 
| 
       3 
3 
     | 
    
         
             
            class HL7::Message::Segment::ORC < HL7::Message::Segment
         
     | 
| 
      
 4 
     | 
    
         
            +
              weight 88 # obr.weight-1
         
     | 
| 
      
 5 
     | 
    
         
            +
              has_children [:OBR]
         
     | 
| 
       4 
6 
     | 
    
         
             
              add_field :order_control
         
     | 
| 
       5 
7 
     | 
    
         
             
              add_field :placer_order_number
         
     | 
| 
       6 
8 
     | 
    
         
             
              add_field :filler_order_number
         
     | 
| 
         @@ -9,18 +11,23 @@ class HL7::Message::Segment::ORC < HL7::Message::Segment 
     | 
|
| 
       9 
11 
     | 
    
         
             
              add_field :response_flag
         
     | 
| 
       10 
12 
     | 
    
         
             
              add_field :quantity_timing
         
     | 
| 
       11 
13 
     | 
    
         
             
              add_field :parent
         
     | 
| 
       12 
     | 
    
         
            -
              add_field :date_time_of_transaction
         
     | 
| 
      
 14 
     | 
    
         
            +
              add_field :date_time_of_transaction do |value|
         
     | 
| 
      
 15 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
       13 
17 
     | 
    
         
             
              add_field :entered_by
         
     | 
| 
       14 
18 
     | 
    
         
             
              add_field :verified_by
         
     | 
| 
       15 
19 
     | 
    
         
             
              add_field :ordering_provider
         
     | 
| 
       16 
20 
     | 
    
         
             
              add_field :enterers_location
         
     | 
| 
       17 
21 
     | 
    
         
             
              add_field :call_back_phone_number
         
     | 
| 
       18 
     | 
    
         
            -
              add_field :order_effective_date_time
         
     | 
| 
      
 22 
     | 
    
         
            +
              add_field :order_effective_date_time do |value|
         
     | 
| 
      
 23 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
       19 
25 
     | 
    
         
             
              add_field :order_control_code_reason
         
     | 
| 
       20 
26 
     | 
    
         
             
              add_field :entering_organization
         
     | 
| 
       21 
27 
     | 
    
         
             
              add_field :entering_device
         
     | 
| 
       22 
28 
     | 
    
         
             
              add_field :action_by
         
     | 
| 
       23 
     | 
    
         
            -
              add_field : 
     | 
| 
      
 29 
     | 
    
         
            +
              add_field :advanced_beneficiary_notice_code
         
     | 
| 
      
 30 
     | 
    
         
            +
              add_field :ordering_facility_name
         
     | 
| 
       24 
31 
     | 
    
         
             
              add_field :ordering_facility_address
         
     | 
| 
       25 
32 
     | 
    
         
             
              add_field :ordering_facility_phone_number
         
     | 
| 
       26 
33 
     | 
    
         
             
              add_field :ordering_provider_address
         
     | 
| 
         @@ -31,4 +38,13 @@ class HL7::Message::Segment::ORC < HL7::Message::Segment 
     | 
|
| 
       31 
38 
     | 
    
         
             
              add_field :order_type
         
     | 
| 
       32 
39 
     | 
    
         
             
              add_field :enterer_authorization_mode
         
     | 
| 
       33 
40 
     | 
    
         
             
              add_field :parent_universal_service_identifier
         
     | 
| 
      
 41 
     | 
    
         
            +
              
         
     | 
| 
      
 42 
     | 
    
         
            +
              private
         
     | 
| 
      
 43 
     | 
    
         
            +
              def self.convert_to_ts(value) #:nodoc:
         
     | 
| 
      
 44 
     | 
    
         
            +
                if value.is_a?(Time) or value.is_a?(Date)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  return value.to_hl7
         
     | 
| 
      
 46 
     | 
    
         
            +
                else
         
     | 
| 
      
 47 
     | 
    
         
            +
                  return value
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
       34 
50 
     | 
    
         
             
            end
         
     | 
    
        data/lib/segments/pid.rb
    CHANGED
    
    | 
         @@ -9,10 +9,12 @@ class HL7::Message::Segment::PID < HL7::Message::Segment 
     | 
|
| 
       9 
9 
     | 
    
         
             
              add_field :alt_patient_id
         
     | 
| 
       10 
10 
     | 
    
         
             
              add_field :patient_name
         
     | 
| 
       11 
11 
     | 
    
         
             
              add_field :mother_maiden_name
         
     | 
| 
       12 
     | 
    
         
            -
              add_field :patient_dob
         
     | 
| 
      
 12 
     | 
    
         
            +
              add_field :patient_dob do |value|
         
     | 
| 
      
 13 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
       13 
15 
     | 
    
         
             
              add_field :admin_sex do |sex|
         
     | 
| 
       14 
     | 
    
         
            -
                unless /^[ 
     | 
| 
       15 
     | 
    
         
            -
                  raise HL7::InvalidDataError.new( "bad administrative sex value (not F|M|O|U|A|N)" )
         
     | 
| 
      
 16 
     | 
    
         
            +
                unless /^[FMOUANC]$/.match(sex) || sex == nil || sex == ""
         
     | 
| 
      
 17 
     | 
    
         
            +
                  raise HL7::InvalidDataError.new( "bad administrative sex value (not F|M|O|U|A|N|C)" )
         
     | 
| 
       16 
18 
     | 
    
         
             
                end
         
     | 
| 
       17 
19 
     | 
    
         
             
                sex = "" unless sex
         
     | 
| 
       18 
20 
     | 
    
         
             
                sex
         
     | 
| 
         @@ -28,7 +30,8 @@ class HL7::Message::Segment::PID < HL7::Message::Segment 
     | 
|
| 
       28 
30 
     | 
    
         
             
              add_field :religion
         
     | 
| 
       29 
31 
     | 
    
         
             
              add_field :account_number
         
     | 
| 
       30 
32 
     | 
    
         
             
              add_field :social_security_num
         
     | 
| 
       31 
     | 
    
         
            -
              add_field : 
     | 
| 
      
 33 
     | 
    
         
            +
              add_field :driver_license_num
         
     | 
| 
      
 34 
     | 
    
         
            +
              add_field :mothers_id
         
     | 
| 
       32 
35 
     | 
    
         
             
              add_field :ethnic_group
         
     | 
| 
       33 
36 
     | 
    
         
             
              add_field :birthplace
         
     | 
| 
       34 
37 
     | 
    
         
             
              add_field :multi_birth
         
     | 
| 
         @@ -36,11 +39,15 @@ class HL7::Message::Segment::PID < HL7::Message::Segment 
     | 
|
| 
       36 
39 
     | 
    
         
             
              add_field :citizenship
         
     | 
| 
       37 
40 
     | 
    
         
             
              add_field :vet_status
         
     | 
| 
       38 
41 
     | 
    
         
             
              add_field :nationality
         
     | 
| 
       39 
     | 
    
         
            -
              add_field :death_date
         
     | 
| 
      
 42 
     | 
    
         
            +
              add_field :death_date do |value|
         
     | 
| 
      
 43 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
       40 
45 
     | 
    
         
             
              add_field :death_indicator
         
     | 
| 
       41 
46 
     | 
    
         
             
              add_field :id_unknown_indicator
         
     | 
| 
       42 
47 
     | 
    
         
             
              add_field :id_readability_code
         
     | 
| 
       43 
     | 
    
         
            -
              add_field :last_update_date
         
     | 
| 
      
 48 
     | 
    
         
            +
              add_field :last_update_date do |value|
         
     | 
| 
      
 49 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
       44 
51 
     | 
    
         
             
              add_field :last_update_facility
         
     | 
| 
       45 
52 
     | 
    
         
             
              add_field :species_code
         
     | 
| 
       46 
53 
     | 
    
         
             
              add_field :breed_code
         
     | 
    
        data/lib/segments/prd.rb
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: UTF-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'ruby-hl7'
         
     | 
| 
      
 3 
     | 
    
         
            +
            class HL7::Message::Segment::PRD < HL7::Message::Segment
         
     | 
| 
      
 4 
     | 
    
         
            +
              weight 2
         
     | 
| 
      
 5 
     | 
    
         
            +
              add_field :provider_role
         
     | 
| 
      
 6 
     | 
    
         
            +
              add_field :provider_name
         
     | 
| 
      
 7 
     | 
    
         
            +
              add_field :provider_address
         
     | 
| 
      
 8 
     | 
    
         
            +
              add_field :provider_location
         
     | 
| 
      
 9 
     | 
    
         
            +
              add_field :provider_communication_information
         
     | 
| 
      
 10 
     | 
    
         
            +
              add_field :preferred_method_of_contact
         
     | 
| 
      
 11 
     | 
    
         
            +
              add_field :provider_identifiers
         
     | 
| 
      
 12 
     | 
    
         
            +
              add_field :effective_start_date_of_provider_role do |value|
         
     | 
| 
      
 13 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
              add_field :effective_end_date_of_provider_role do |value|
         
     | 
| 
      
 16 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/segments/pv1.rb
    CHANGED
    
    | 
         @@ -45,8 +45,12 @@ class HL7::Message::Segment::PV1 < HL7::Message::Segment 
     | 
|
| 
       45 
45 
     | 
    
         
             
              add_field :account_status
         
     | 
| 
       46 
46 
     | 
    
         
             
              add_field :pending_location
         
     | 
| 
       47 
47 
     | 
    
         
             
              add_field :prior_temporary_location
         
     | 
| 
       48 
     | 
    
         
            -
              add_field :admit_date
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
              add_field :admit_date do |value|
         
     | 
| 
      
 49 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
              add_field :discharge_date do |value|
         
     | 
| 
      
 52 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
       50 
54 
     | 
    
         
             
              add_field :current_patient_balance
         
     | 
| 
       51 
55 
     | 
    
         
             
              add_field :total_charges
         
     | 
| 
       52 
56 
     | 
    
         
             
              add_field :total_adjustments
         
     | 
    
        data/lib/segments/pv2.rb
    CHANGED
    
    | 
         @@ -35,19 +35,22 @@ class HL7::Message::Segment::PV2 < HL7::Message::Segment 
     | 
|
| 
       35 
35 
     | 
    
         
             
              add_field :recurring_service_code
         
     | 
| 
       36 
36 
     | 
    
         
             
              add_field :billing_media_code
         
     | 
| 
       37 
37 
     | 
    
         
             
              add_field :expected_surgery_date
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
               
     | 
| 
       40 
     | 
    
         
            -
               
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              # Adding military fields
         
     | 
| 
      
 40 
     | 
    
         
            +
              [ :military_partnership_code,
         
     | 
| 
      
 41 
     | 
    
         
            +
                :military_non_availibility_code,
         
     | 
| 
      
 42 
     | 
    
         
            +
                :newborn_baby_indicator,
         
     | 
| 
      
 43 
     | 
    
         
            +
                :baby_detained_indicator,
         
     | 
| 
      
 44 
     | 
    
         
            +
                :mode_of_arrival_code,
         
     | 
| 
      
 45 
     | 
    
         
            +
                :recreational_drug_use_code,
         
     | 
| 
      
 46 
     | 
    
         
            +
                :precaution_code,
         
     | 
| 
      
 47 
     | 
    
         
            +
                :patient_condition_code,
         
     | 
| 
      
 48 
     | 
    
         
            +
                :living_will_code,
         
     | 
| 
      
 49 
     | 
    
         
            +
                :organ_donor_code,
         
     | 
| 
      
 50 
     | 
    
         
            +
                :advance_directive_code,
         
     | 
| 
      
 51 
     | 
    
         
            +
                :patient_status_effective_date,
         
     | 
| 
      
 52 
     | 
    
         
            +
                :expected_loa_return_date,
         
     | 
| 
      
 53 
     | 
    
         
            +
                :expected_preadmission_testing_date,
         
     | 
| 
      
 54 
     | 
    
         
            +
                :notify_clergy_code
         
     | 
| 
      
 55 
     | 
    
         
            +
               ].each { |f| add_field f }
         
     | 
| 
       53 
56 
     | 
    
         
             
            end
         
     | 
    
        data/lib/segments/rf1.rb
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: UTF-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'ruby-hl7'
         
     | 
| 
      
 3 
     | 
    
         
            +
            class HL7::Message::Segment::RF1 < HL7::Message::Segment
         
     | 
| 
      
 4 
     | 
    
         
            +
              weight 0 # should occur after the MSH segment
         
     | 
| 
      
 5 
     | 
    
         
            +
              add_field :referral_status
         
     | 
| 
      
 6 
     | 
    
         
            +
              add_field :referral_priority
         
     | 
| 
      
 7 
     | 
    
         
            +
              add_field :referral_type
         
     | 
| 
      
 8 
     | 
    
         
            +
              add_field :referral_disposition
         
     | 
| 
      
 9 
     | 
    
         
            +
              add_field :referral_category
         
     | 
| 
      
 10 
     | 
    
         
            +
              add_field :originating_referral_identifier
         
     | 
| 
      
 11 
     | 
    
         
            +
              add_field :effective_date do |value|
         
     | 
| 
      
 12 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              add_field :expiration_date do |value|
         
     | 
| 
      
 15 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              add_field :process_date do |value|
         
     | 
| 
      
 18 
     | 
    
         
            +
                convert_to_ts(value)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
              add_field :referral_reason
         
     | 
| 
      
 21 
     | 
    
         
            +
              add_field :external_referral_identifier
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/segments/zcf.rb
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'ruby-hl7'
         
     | 
| 
      
 2 
     | 
    
         
            +
            class HL7::Message::Segment::ZCF < HL7::Message::Segment
         
     | 
| 
      
 3 
     | 
    
         
            +
              add_field :custom_field_1
         
     | 
| 
      
 4 
     | 
    
         
            +
              add_field :custom_field_2
         
     | 
| 
      
 5 
     | 
    
         
            +
              add_field :custom_field_3
         
     | 
| 
      
 6 
     | 
    
         
            +
              add_field :custom_field_4
         
     | 
| 
      
 7 
     | 
    
         
            +
              add_field :custom_field_5
         
     | 
| 
      
 8 
     | 
    
         
            +
              add_field :custom_field_6
         
     | 
| 
      
 9 
     | 
    
         
            +
              add_field :custom_field_7
         
     | 
| 
      
 10 
     | 
    
         
            +
              add_field :custom_field_8
         
     | 
| 
      
 11 
     | 
    
         
            +
              add_field :custom_field_9
         
     | 
| 
      
 12 
     | 
    
         
            +
              add_field :custom_field_10
         
     | 
| 
      
 13 
     | 
    
         
            +
              add_field :custom_field_11
         
     | 
| 
      
 14 
     | 
    
         
            +
              add_field :custom_field_12
         
     | 
| 
      
 15 
     | 
    
         
            +
              add_field :custom_field_13
         
     | 
| 
      
 16 
     | 
    
         
            +
              add_field :custom_field_14
         
     | 
| 
      
 17 
     | 
    
         
            +
              add_field :custom_field_15
         
     | 
| 
      
 18 
     | 
    
         
            +
              add_field :custom_field_16
         
     | 
| 
      
 19 
     | 
    
         
            +
              add_field :custom_field_17
         
     | 
| 
      
 20 
     | 
    
         
            +
              add_field :custom_field_18
         
     | 
| 
      
 21 
     | 
    
         
            +
              add_field :custom_field_19
         
     | 
| 
      
 22 
     | 
    
         
            +
              add_field :custom_field_20
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     |