module PatientMergeFormConcern
Public Instance Methods
Source
# File app/forms/concerns/patient_merge_form_concern.rb, line 17 def existing_patient return if nhs_number.blank? @existing_patient ||= find_existing(patient_policy_scope) || find_existing(Patient.where.missing(:patient_locations)) end
Source
# File app/forms/concerns/patient_merge_form_concern.rb, line 25 def find_existing(scope) scope .where.not(id: patient.id) .includes(:vaccination_records) .find_by(nhs_number: nhs_number) end
Source
# File app/forms/concerns/patient_merge_form_concern.rb, line 12 def nhs_number=(value) super(value.presence&.gsub(/\s/, "")) end
Calls superclass method
Source
# File app/forms/concerns/patient_merge_form_concern.rb, line 32 def save return false if invalid? if existing_patient PatientMerger.call( to_keep: existing_patient, to_destroy: patient, user: current_user ) end true end