Sha256: 05c73c3e58cc5017d037f952f87d1bb5b98fedbf7e190732b34a6a1f8d17a7e5

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module HealthcarePhony
  # Public: Creates a Religion object for a Patient by randomly choosing a value from a YAML file.
  class Religion
    attr_accessor :code,
                  :description,
                  :coding_system

    # Public: Initializes an EthnicGroup. Pass in hash of different parameters, currently this includes:
    # religion_data_file - YAML file containing religion information to randomly choose from if different options than
    # those that come with gem are desired.  See {religion.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/religion.yml]
    # for default values.
    def initialize(init_args = {})
      # TODO: allow a way for caller to pass in a custom set of codes to choose from
      # TODO: allow a way for caller to pass in % blank

      data_file = if !init_args[:religion_data_file].nil?
                    init_args[:religion_data_file]
                  else
                    "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/religion.yml"
                  end
      r_array = Psych.load_file(data_file)

      random_religion = r_array.nil? ? '' : r_array.sample

      @code = random_religion[:code]
      @description = random_religion[:description]
      @coding_system = random_religion[:coding_system]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
healthcare_phony-0.7.0 lib/healthcare_phony/religion.rb
healthcare_phony-0.6.0 lib/healthcare_phony/religion.rb
healthcare_phony-0.5.1 lib/healthcare_phony/religion.rb
healthcare_phony-0.5.0 lib/healthcare_phony/religion.rb