Module: Canql::Nodes::Patient::FieldExists

Defined in:
lib/canql/nodes/patient.rb

Constant Summary collapse

FIELDS =
{
  'date of birth':          { patient: 'birthdate', mother: 'birthdate' },
  'dob':                    { patient: 'birthdate', mother: 'birthdate' },
  'postcode':               { patient: 'postcode',  mother: 'postcode'  },
  'nhs number':             { patient: 'nhsnumber', mother: 'nhsnumber' },
  'birth weight':           { patient: 'weight' },
  'place of delivery':      { patient: 'placeofdelivery' },
  'sex':                    { patient: 'sex' },
  'outcome':                { patient: 'outcome' },
  'edd':                    { patient: 'expecteddeliverydate' },
  'expected delivery date': { patient: 'expecteddeliverydate' },
  'booking hospital':       { patient: 'booking_hospital' }
}.freeze

Instance Method Summary collapse

Instance Method Details

#actual_field_names(fields, subject) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/canql/nodes/patient.rb', line 43

def actual_field_names(fields, subject)
  actual_fields = []
  fields.each do |f|
    f = f.downcase.to_sym
    actual_fields << FIELDS[f][subject] unless FIELDS[f].nil? || FIELDS[f][subject].nil?
  end
  actual_fields
end

#meta_data_itemObject



33
34
35
36
37
38
39
40
41
# File 'lib/canql/nodes/patient.rb', line 33

def 
  subject = reverse_scan_for_marker(:subject) == 'mother' ? 'mother' : 'patient'
  field_names = actual_field_names(
    patient_field_list.text_values_for_marker(:patient_field_name), subject.to_sym
  )
  modifer = field_existance_modifier.text_value.strip
  existance = modifer != 'missing' ? 'fields_populated' : 'fields_missing'
  { "#{subject}.#{existance}" => { Canql::EQUALS => field_names } }
end