Skip to content

Improve previous mammogram form and display#1196

Open
MatMoore wants to merge 6 commits intomainfrom
DTOSS-12370-mammogram-fixes
Open

Improve previous mammogram form and display#1196
MatMoore wants to merge 6 commits intomainfrom
DTOSS-12370-mammogram-fixes

Conversation

@MatMoore
Copy link
Contributor

@MatMoore MatMoore commented Mar 18, 2026

Description

Refactoring

  • Moved the form into the mammograms app. We'd previously moved the views and urls.
  • Removed provider field from the ParticipantReportedMammogram model. We're not relying on it now that we pass in the appointment (which is linked to the current provider).
  • Removed unnecessary service for fetching the provider of the participant's most recent appointment

Distinguish NHS and non-NHS providers when adding previous mammograms

  • Allow the user to choose "Another NHS breast screening unit"
  • The prototype has a drop down here. But instead, we are using a free text input. Later down the line we will probably replace with an autocomplete input.
Screenshot of the new input Screenshot of the display

Align approximate dates with the prototype

  • Radios were already done in another PR
  • The text on the card display needed updating
Screenshot of the display

Make exact date hint text dynamic

Previously the example was hardcoded to "15 3 2025". It's now calculated to be 9 months ago.

Jira link

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

Review notes

  • The requested change to round off relative dates was added in Improve relative date formatting #1192
  • We have a separate ticket to split the card into mammograms from screening history, and reported mammograms, so I've only looked at reported mammograms here.
  • I've made the new text input full width, as 2/3 width was too short for a typical provider name when I tested it

Review checklist

  • Check database queries are correctly scoped to current_provider

This is medical information collected in the context of
an appointment, so it should live in the mammograms app
alongside the corresponding views.
Previously we were planning to have an autocomplete field
so that the user could select the specific provider on this form.

We've now decided to just use a simple free text input, so
alter the model accordingly.

Instead of location_type=NHS_BREAST_SCREENING_UNIT, use SAME_PROVIDER
(to match the provider of the current screening episode) or
ANOTHER_NHS_PROVIDER.

The foriegn key to provider is reundant in the case when
SAME_PROVIDER is selected, because this model is now linked to provider.

If ANOTHER_NHS_PROVIDER is selected, we will populate location_details.
Note: the prototype says "Approximately taken 6 months or more ago:"
which we've decided to shorten to "Taken 6 months or more ago:"
When we first implemented this form, it wasn't linked to an appointment,
which meant that to get the current provider we had to separately query
the most recent provider for the participant.

Now that the mammograms are linked to an appointment, we can directly
access the provider from there, which simplifies the code.
previous_mammograms:
- location_type: NHS_BREAST_SCREENING_UNIT
- location_type: SAME_PROVIDER
provider:
Copy link
Contributor

Choose a reason for hiding this comment

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

As we've removed provider_id from participants_participantreportedmammogram, do we need to remove provider from previous_mammograms in these .yml files?

When I try make rebuild-db I get an error. Can workaround it by adding mammogram.pop("provider", None) to create_reported_mammograms in seed_demo_data.py.

  File "dtos-manage-breast-screening/manage_breast_screening/nonprod/management/commands/seed_demo_data.py", line 285, in create_reported_mammograms
    appointment_mammogram = ParticipantReportedMammogramFactory(
        appointment=appointment,
        **mammogram,
    )
  File "dtos-manage-breast-screening/.venv/lib/python3.14/site-packages/django/db/models/base.py", line 590, in __init__
    raise TypeError(
    ...<2 lines>...
    )
TypeError: ParticipantReportedMammogram() got unexpected keyword arguments: 'provider'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we do, just pushed another commit to fix this.

@sonarqubecloud
Copy link

Copy link
Contributor

@swebberuk swebberuk left a comment

Choose a reason for hiding this comment

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

👍🏻

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.

2 participants