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' },
  'number of fetuses in early pregnancy': { patient: 'numberoffetuses' },
  '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



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

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



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

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
  )
  modifier = field_existence_modifier.text_value.strip
  existence = modifier == 'missing' ? 'fields_missing' : 'fields_populated'
  { "#{subject}.#{existence}" => { Canql::EQUALS => field_names } }
end