Sha256: aa391e135e72e82ba83a7a915d31eacc5119922995331c20a7d215c8bea3c322

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

module Roqua
  module Healthy
    module A19
      class AddressParser
        attr_reader :message

        def initialize(message)
          @message = message
        end

        def address_type
          return nil unless record
          record.fetch('PID.11.7')
        end

        def street
          return nil if record.blank? || record.fetch('PID.11.1').blank?
          record.fetch('PID.11.1').fetch('PID.11.1.1')
        end

        def city
          return nil unless record
          record.fetch('PID.11.3')
        end

        def zipcode
          return nil unless record
          record.fetch('PID.11.5')
        end

        def country
          return nil unless record
          record.fetch('PID.11.6')
        end

        def record
          @record = nil
          @record ||= message.fetch('PID').fetch('PID.11').find { |record| record.fetch('PID.11.7', :unknown_type_of_address_record) == 'M' }
          @record ||= message.fetch('PID').fetch('PID.11').find { |record| record.fetch('PID.11.7', :unknown_type_of_address_record) == 'H' }
          @record ||= message.fetch('PID').fetch('PID.11').find { |record| record.fetch('PID.11.7', :unknown_type_of_address_record) == 'L' }
          @record
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
roqua-healthy-1.2.0 lib/roqua/healthy/a19/address_parser.rb
roqua-healthy-1.1.9 lib/roqua/healthy/a19/address_parser.rb
roqua-healthy-1.1.8 lib/roqua/healthy/a19/address_parser.rb
roqua-healthy-1.1.7 lib/roqua/healthy/a19/address_parser.rb
roqua-healthy-1.1.6 lib/roqua/healthy/a19/address_parser.rb
roqua-healthy-1.1.5 lib/roqua/healthy/a19/address_parser.rb
roqua-healthy-1.1.4 lib/roqua/healthy/a19/address_parser.rb
roqua-healthy-1.1.3 lib/roqua/healthy/a19/address_parser.rb