class StatusGenerator::Programme
Public Class Methods
Source
# File app/lib/status_generator/programme.rb, line 11 def initialize( programme_type:, academic_year:, patient:, patient_locations:, consents:, triages:, attendance_record:, vaccination_records:, parents:, consent_notifications: ) @programme_type = programme_type @academic_year = academic_year @patient = patient @patient_locations = patient_locations @consents = consents @triages = triages @attendance_record = attendance_record @vaccination_records = vaccination_records @parents = parents @consent_notifications = find_matching_consent_notifications(consent_notifications) @vaccination_criteria = VaccinationCriteria.new( programme_type:, academic_year:, patient:, vaccination_records: ) end
Creates a new instance of the status generator used to determine the programme status of a patient.
The consents, triages and vaccination_records arguments are expected to already be sorted in reverse chronological order, meaning the most recent item is at the beginning of the array.
Public Instance Methods
Source
# File app/lib/status_generator/programme.rb, line 160 def consent_status consent_generator.status end
Source
# File app/lib/status_generator/programme.rb, line 164 def consent_vaccine_methods consent_generator.vaccine_methods end
Source
# File app/lib/status_generator/programme.rb, line 141 def date if ( delay_vaccination_until_date = triage_generator.delay_vaccination_until_date ) delay_vaccination_until_date elsif vaccinated_vaccination_record vaccinated_vaccination_record.performed_at_date elsif is_absent? attendance_record.date else vaccination_records.map(&:performed_at_date).max end end
Source
# File app/lib/status_generator/programme.rb, line 90 def disease_types return nil if not_eligible? if vaccinated_vaccination_record vaccinated_vaccination_record.disease_types elsif consent_status.in?(%i[given refused conflicts]) consent_generator.disease_types end end
Source
# File app/lib/status_generator/programme.rb, line 100 def dose_sequence return unless is_eligible? # Patients receive dose 5 of Td/IPV by default, regardless of vaccination history return 5 if programme.td_ipv? valid_vaccination_records.count + 1 end
Source
# File app/lib/status_generator/programme.rb, line 156 def location_id vaccinated_vaccination_record&.location_id end
Source
# File app/lib/status_generator/programme.rb, line 44 def programme Programme.find(programme_type, disease_types:, patient:) end
Source
# File app/lib/status_generator/programme.rb, line 48 def status if should_be_vaccinated_already? :vaccinated_already elsif should_be_vaccinated_fully? :vaccinated_fully elsif should_be_cannot_vaccinate_unwell? :cannot_vaccinate_unwell elsif should_be_cannot_vaccinate_refused? :cannot_vaccinate_refused elsif should_be_cannot_vaccinate_contraindicated? :cannot_vaccinate_contraindicated elsif should_be_cannot_vaccinate_absent? :cannot_vaccinate_absent elsif should_be_cannot_vaccinate_do_not_vaccinate? :cannot_vaccinate_do_not_vaccinate elsif should_be_needs_consent_no_contact_details? :needs_consent_no_contact_details elsif should_be_needs_consent_no_response? :needs_consent_no_response elsif should_be_cannot_vaccinate_delay_vaccination? :cannot_vaccinate_delay_vaccination elsif should_be_due? :due elsif should_be_needs_triage? :needs_triage elsif should_be_has_refusal_consent_conflicts? :has_refusal_consent_conflicts elsif should_be_has_refusal_consent_refused? :has_refusal_consent_refused elsif should_be_needs_consent_follow_up_requested? :needs_consent_follow_up_requested elsif should_be_needs_consent_request_failed? :needs_consent_request_failed elsif should_be_needs_consent_request_scheduled? :needs_consent_request_scheduled elsif should_be_needs_consent_request_not_scheduled? :needs_consent_request_not_scheduled else :not_eligible end end
Source
# File app/lib/status_generator/programme.rb, line 123 def vaccine_methods if not_eligible? || triage_generator.status.in?( %i[required invite_to_clinic do_not_vaccinate] ) || consent_status.in?( %i[no_response conflicts refused follow_up_requested] ) return nil end if triage_generator.vaccine_method [triage_generator.vaccine_method] else consent_vaccine_methods end end
Source
# File app/lib/status_generator/programme.rb, line 109 def without_gelatine if not_eligible? || triage_generator.status.in?( %i[required invite_to_clinic do_not_vaccinate] ) || consent_status.in?( %i[no_response conflicts refused follow_up_requested] ) return nil end triage_generator.without_gelatine || consent_generator.without_gelatine end