Skip to content

Conversation

@swebberuk
Copy link
Contributor

@swebberuk swebberuk commented Jan 7, 2026

Provide option to proceed with appointment even when participant has had previous mammogram in last six months.

Description

Added reason_for_continuing column to participants_participantreportedmammogram table.

Added "Proceed with this appointment" link to the "This appointment should not proceed" page. Clicking on link takes user to new page:

image

Added "Reason for continuing" to Mammogram history:

image

Jira link

https://nhsd-jira.digital.nhs.uk/browse/DTOSS-11729

Review notes

Review checklist

  • Check database queries are correctly scoped to current_provider

@swebberuk swebberuk requested a review from a team as a code owner January 7, 2026 08:44
@swebberuk swebberuk changed the title Proceed anyway option Add option to proceed with appointment Jan 7, 2026
@swebberuk swebberuk force-pushed the DTOSS-11729-proceed-anyway branch 2 times, most recently from f4b50f1 to 5be840e Compare January 7, 2026 09:02
<p>Advise the participant that they will be invited for their next scheduled mammogram based on the information provided.</p>

<form action="{{ url('mammograms:attended_not_screened', kwargs={'appointment_pk': appointment.pk}) }}" method="post">
<form action="{{ url('mammograms:attended_not_screened', kwargs={'appointment_pk': presented_appointment.pk}) }}" method="post">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might have noticed HTML5 in-browser form validation sometimes pops up?

We need to make sure the novalidate boolean attributes appears on every form

(Because we do the validation ourselves, and it might conflict)

Suggested change
<form action="{{ url('mammograms:attended_not_screened', kwargs={'appointment_pk': presented_appointment.pk}) }}" method="post">
<form action="{{ url('mammograms:attended_not_screened', kwargs={'appointment_pk': presented_appointment.pk}) }}" method="post" novalidate>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way we can automate that certain attributes are populated on all forms? I think we're likely to forget this sometimes if they need to be manually applied.

Copy link
Contributor

@MatMoore MatMoore Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of ideas:

  • we could hook something into our accessibility baseline check in the playwright tests
  • we could create a form_tag macro, and import it from the form layout

Would suggest creating another ticket for this though

Copy link
Contributor

@malcolmbaig malcolmbaig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — some feedback left inline.


super().__init__(*args, **kwargs)

self.fields["reason_for_continuing"] = CharField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth declaring form fields higher up at the class-level (eg — like we do in SymptomForm, LumpForm, etc), unless there's a reason not to. The fields syntax in the init block seems to work just fine, but I think:

  • The class-level declaration is more idiomatic
  • It's probably better for things like introspection and IDE tooling
  • field logic in the init function is typically expected when there's some dynamic behaviour or customisation needed for a given field

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building on this — could this form be implemented as a ModelForm? If so, benefits would be:

  • your model and fields declarations would make it clear at a glance that this is updating a ParticipantReportedMammogram, and only its reason_for_continuing field is affected.
  • you get the save function for free and don't need to write your own update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the fields outside of the init function. Thanks.

I hadn't considered using ModelForm. I can look into using it if we feel that would be best.

The reason I used the update function is because the associated view inherits from UpdateWithAuditView. The form_valid function of UpdateWithAuditView calls form.update(). The reason I used UpdateWithAuditView is that it ensures an audit record is created and a success message is shown on redirect. Wanted to be consistent with other parts of the app.

Comment on lines 107 to 112

self.when_i_click_edit_previous_mammogram_details()
self.then_i_should_be_on_the_edit_previous_mammogram_form()

self.when_i_click_save()
self.then_i_should_be_on_the_appointment_should_not_proceed_page()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip these steps, given the focus of this scenario is the proceed anyway functionality. We test the edit functionality already in the test case above.

Additionally, I think a good change would be to move those steps related to the edit page to the test_adding_a_mammogram_at_the_same_provider scenario. It's a fairly generic bit of navigation that isn't specifically tied to "adding a mammogram within the last six months".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we can skip those steps, as already tested elsewhere. I've removed them from test_adding_a_mammogram_within_last_six_months_proceed_anyway. Thanks.

I've left those steps in test_adding_a_mammogram_within_last_six_months_do_not_proceed. It is tied to "adding a mammogram within the last six months". when_i_click_edit_previous_mammogram_details clicks the "Edit previous mammogram details" link that appears on the "This appointment should not proceed" page. That page is only shown when the mammogram is within the last six months.

@swebberuk swebberuk requested a review from malcolmbaig January 7, 2026 14:47
@swebberuk swebberuk force-pushed the DTOSS-11729-proceed-anyway branch from f00ecea to 7aa76e2 Compare January 8, 2026 09:30
@swebberuk swebberuk requested a review from MatMoore January 8, 2026 09:58
@swebberuk swebberuk force-pushed the DTOSS-11729-proceed-anyway branch from 7aa76e2 to 347bff7 Compare January 8, 2026 13:22
Copy link
Contributor

@MatMoore MatMoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not too much trouble, can you squash those code review commits into the commits they're amending? Just leaves us with a cleaner git history for anyone looking back on old commits.

Other than that everything looks good to me.

As discussed offline, ModelForm is good for simple CRUD code, though in other places I think we decided against using it as we were overriding a lot of the default behaviour. Happy to go with either approach here though.

If we use ModelForm:

  • the built-in CreateView, UpdateView, DeleteView will all work with it
  • our Create/Update/DeleteWithAuditView classes would need changing, perhaps by moving to save methods for all forms
  • the model's clean methods would be called automatically, which we're missing at the moment

I never got around to customising the templates for ModelChoiceField and ModelMultipleChoiceField like I did the other field classes, so if we do make use of ModelForm we might want to wire those up to the design system in the same way.

@swebberuk swebberuk force-pushed the DTOSS-11729-proceed-anyway branch from 347bff7 to 317783c Compare January 8, 2026 16:11
Provide option to proceed with appointment even when have

had previous mammogram in last six months
@swebberuk swebberuk force-pushed the DTOSS-11729-proceed-anyway branch from 317783c to a99678f Compare January 8, 2026 17:16
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants