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' },
  'date of vital status': { patient: 'dateofvitalstatus', mother: 'dateofvitalstatus' },
  'delivery postcode': { patient: 'delivery_postcode' },
  'booking postcode': { patient: 'booking_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' },
  'screening status': { patient: 'screeningstatus' },
  'number of fetuses at delivery': { patient: 'numoffetusesatdelivery' },
  'malformed in set': { patient: 'malformedinset' },
  'gestation at delivery': { patient: 'gestationallength' },
  'booking date': { patient: 'firstbookingdate' }
}.freeze

Instance Method Summary collapse

Instance Method Details

#actual_field_names(fields, subject) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/canql/nodes/patient.rb', line 73

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



63
64
65
66
67
68
69
70
71
# File 'lib/canql/nodes/patient.rb', line 63

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_missing' : 'fields_populated'
  { "#{subject}.#{existance}" => { Canql::EQUALS => field_names } }
end