Class: QME::Randomizer::RandomPatientCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/qme/randomizer/random_patient_creator.rb

Class Method Summary collapse

Class Method Details

.parse_events(event_list) ⇒ Array

Parses a list of event hashes into an array of Entry objects

Parameters:

  • event_list (Array)

    list of event hashes

Returns:

  • (Array)

    array of Entry objects



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/qme/randomizer/random_patient_creator.rb', line 33

def self.parse_events(event_list)
  event_list.collect do |event|
    if event.class==String.class
      # skip String elements in the event list, patient randomization templates
      # introduce String elements to simplify tailing-comma handling when generating
      # JSON using ERb
      nil
    else
      Entry.from_event_hash(event)
    end
  end.compact
end

.parse_hash(patient_hash) ⇒ Record

Parses a patient hash containing demographic and event information

Parameters:

  • patient_hash (Hash)

    patient data

Returns:

  • (Record)

    a representation of the patient that can be inserted into MongoDB



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/qme/randomizer/random_patient_creator.rb', line 9

def self.parse_hash(patient_hash)
  patient_record = Record.new
  patient_record.first = patient_hash['first']
  patient_record.last = patient_hash['last']
  patient_record.gender = patient_hash['gender']
  patient_record.medical_record_number = patient_hash['medical_record_number']
  patient_record.birthdate = patient_hash['birthdate']
  patient_record.race = patient_hash['race']
  patient_record.ethnicity = patient_hash['ethnicity']
  # pophealth needs languages... please do not remove
  patient_record.languages = patient_hash['languages']
  #patient_record['addresses'] = patient_hash['addresses']
  patient_hash['events'].each do |key, value|
    patient_record.send("#{key}=".to_sym, parse_events(value))
  end
  patient_record['measures'] = QME::Importer::MeasurePropertiesGenerator.instance.generate_properties(patient_record)
  
  patient_record
end