class ProcessConsentFormJob
Public Instance Methods
Source
# File app/jobs/process_consent_form_job.rb, line 24 def perform(consent_form_id) @consent_form = ConsentForm.includes(:consent_form_programmes).find(consent_form_id) if already_matched? # This covers the case where the job is re-run # after the ethnicity flow is completed. if (patient = @consent_form.matched_patient) patient.assign_ethnicity_from!(@consent_form) end return end begin if match_with_exact_nhs_number # Match if we find a patient with the PDS NHS number elsif location_patients.count == 1 # If we found exactly one, match the consent form to this patient match_to_only_patient(location_patients.first) elsif pds_patient && matching_patients.empty? # If no patients are found, store the PDS NHS number in the consent form. # A nurse may then create a patient record and we can try this job again update_consent_form_nhs_number end # If we found: # - No patients with the NHS number from the PDS record # - 2 or more patients in the original session, matching with no NHS number # - 1 or more patients in any session, matching with no NHS number # Then do nothing; the nurse needs to match manually or create a new patient rescue NHS::PDS::InvalidSearchData, NHS::PDS::TooManyMatches => e Sentry.capture_exception(e, level: "warning") ensure send_confirmation_notification end end