-
Notifications
You must be signed in to change notification settings - Fork 9
Do not allow vaccination of absent children #3743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
a33d38a
to
2269452
Compare
2269452
to
cd02163
Compare
cd02163
to
631deac
Compare
631deac
to
e114b7b
Compare
e114b7b
to
45d62dd
Compare
45d62dd
to
67f0b83
Compare
|
joins(:patient_session).where(patient_session: { patient:, session: }) | ||
end | ||
|
||
scope :allows_recording_vaccination, -> { attending.or(completed) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same logic as:
.has_registration_status(%w[attending completed]) |
I wonder if there's a way we can refactor this so the same logic is used in both places, perhaps something like this:
STATUSES_FOR_RECORDING_VACCINATION = %w[attending completed]
scope :allows_recording_vaccination, -> { where(status: STATUSES_FOR_RECORDING_VACCINATION) }
.has_registration_status(STATUSES_FOR_RECORDING_VACCINATION)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this refactor. There is a third place that used .has_registration_status(%w[attending completed])
, namely the record controller, but in this case the purpose is to check that they are attending, not to check they can receive a vaccination. I have chosen for now to not replace that instance.
67f0b83
to
6bbe91e
Compare
317d83b
to
380eb8b
Compare
In the next commit we will enforce that a child is registered as attending. We therefore fix the tests so that the children are attending when this is appropriate and required.
Ideally we would get the error message to be a direct link to the child on the registration page, see x-govuk/govuk-form-builder#566 for why this is not yet possible. I could not find a way to test this feature with an e2e test as our testing library uses a mocked browser that does not actually allow you to open a second tab in which to modify the attendance while submitting the vaccination.
380eb8b
to
775c80e
Compare
|
def attending?(session:) | ||
patient_sessions | ||
.includes(:registration_status) | ||
.find_by(session:) | ||
&.registration_status | ||
&.attending? | ||
end | ||
|
||
def completed?(session:) | ||
patient_sessions | ||
.includes(:registration_status) | ||
.find_by(session:) | ||
&.registration_status | ||
&.completed? | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see where these methods are used.
.exists? | ||
date = performed_at.to_date | ||
errors.add( | ||
:session_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it makes sense for this error to be attached to :session_id
, I wonder if :base
is more appropriate (since it's more like a general validation error for the model rather than a specific attribute).
patient_full_name: patient.full_name, | ||
display_date: | ||
date.today? ? "Today (#{date.to_fs(:long)})" : date.to_fs(:long), | ||
location_name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
location_name
is an optional value that's only set when recording a vaccination in a clinic session. I think you'll want to use the logic from the vaccination_record_location
helper.
This PR provides a fix for https://nhsd-jira.digital.nhs.uk/browse/MAV-1212