Module: ChangeHealth::Models

Defined in:
lib/change_health/models/model.rb,
lib/change_health/models/eligibility/provider.rb,
lib/change_health/models/eligibility/encounter.rb,
lib/change_health/models/eligibility/subscriber.rb,
lib/change_health/models/claim/submission/address.rb,
lib/change_health/models/claim/submission/provider.rb,
lib/change_health/models/claim/submission/receiver.rb,
lib/change_health/models/claim/submission/dependent.rb,
lib/change_health/models/claim/submission/diagnosis.rb,
lib/change_health/models/claim/submission/submitter.rb,
lib/change_health/models/claim/submission/subscriber.rb,
lib/change_health/models/claim/submission/service_line.rb,
lib/change_health/models/trading_partner/trading_partner.rb,
lib/change_health/models/claim/submission/other_payer_name.rb,
lib/change_health/models/claim/submission/claim_information.rb,
lib/change_health/models/claim/submission/report_information.rb,
lib/change_health/models/claim/submission/contact_information.rb,
lib/change_health/models/claim/submission/drug_identification.rb,
lib/change_health/models/claim/submission/professional_service.rb,
lib/change_health/models/claim/submission/institutional_service.rb,
lib/change_health/models/claim/submission/other_subscriber_name.rb,
lib/change_health/models/claim/submission/claim_code_information.rb,
lib/change_health/models/claim/submission/claim_date_information.rb,
lib/change_health/models/claim/submission/service_facility_location.rb,
lib/change_health/models/claim/submission/billing_pay_to_address_name.rb,
lib/change_health/models/claim/submission/other_subscriber_information.rb,
lib/change_health/models/claim/submission/line_adjudication_information.rb,
lib/change_health/models/claim/submission/claim_supplemental_information.rb

Defined Under Namespace

Modules: Claim, Eligibility Classes: Model, TradingPartner

Constant Summary collapse

DATE_FORMAT =
'%Y%m%d'.freeze
DATE_HOUR_FORMAT =
'%Y%m%d%H%M'.freeze
HOUR_FORMAT =
'%H%M'.freeze
DATE_FORMATTER =

Deprecated should use date_formatter instead

lambda { |date|
  time_formatter(date, DATE_FORMAT)
}
PARSE_DATE =
lambda { |d|
  begin
    d = Date.strptime(d.tr('-', ''), ChangeHealth::Models::DATE_FORMAT)
  rescue StandardError
  end

  d
}
POSTAL_CODE_FORMATTER =
lambda { |postal_code|
  begin
    formatted_postal_code = postal_code&.to_s&.tr('-', '')
  rescue StandardError
  end
  formatted_postal_code || postal_code
}
CONTROL_NUMBER =
-> { '%09d' % rand(1_000_000_000) }

Class Method Summary collapse

Class Method Details

.date_formatter(date) ⇒ Object



12
13
14
# File 'lib/change_health/models/model.rb', line 12

def self.date_formatter(date)
  time_formatter(date, DATE_FORMAT)
end

.date_hour_formatter(date_hour) ⇒ Object



16
17
18
# File 'lib/change_health/models/model.rb', line 16

def self.date_hour_formatter(date_hour)
  time_formatter(date_hour, DATE_HOUR_FORMAT)
end

.hour_formatter(hour) ⇒ Object



20
21
22
# File 'lib/change_health/models/model.rb', line 20

def self.hour_formatter(hour)
  time_formatter(hour, HOUR_FORMAT)
end

.time_formatter(time, format) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/change_health/models/model.rb', line 24

def self.time_formatter(time, format)
  begin
    time = Time.parse(time) if time.is_a?(String)
  rescue ArgumentError
  end

  time = time.strftime(format) if time.respond_to?(:strftime)

  time
end