Skip to content

[wip] Allow symptoms to be highlighted to image readers#1385

Closed
swebberuk wants to merge 1 commit intomainfrom
DTOSS-12818-highlight-symptom
Closed

[wip] Allow symptoms to be highlighted to image readers#1385
swebberuk wants to merge 1 commit intomainfrom
DTOSS-12818-highlight-symptom

Conversation

@swebberuk
Copy link
Copy Markdown
Contributor

Description

Add option for breast pain and 'other' symptoms to be highlighted to readers.

Display info text for symptoms that are always highlighted to readers.

Add highlight_to_readers column to symptoms table.

Use 'Highlight to image readers' tag on medical info page.

Jira link

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

@swebberuk swebberuk force-pushed the DTOSS-12818-highlight-symptom branch from b48c08a to bc0f9c4 Compare April 28, 2026 15:04

def _get_heading_description(self):
suffix = " a recognised symptom of breast cancer. Information recorded here will be highlighted during image reading."
if self.symptom_type_name == "lump":
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Feels awkward that BaseSymptomFormView has logic about lumps.

Could override get_context_data for lumps, but then would have to duplicate in AddSymptomLumpView and UpdateSymptomLumpView.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new highlight_to_readers flag on symptoms so that breast pain and “other” symptoms can optionally be highlighted to image readers, and updates the medical information UI/presenters to display a “Highlight to image readers” tag when appropriate.

Changes:

  • Added highlight_to_readers boolean field to participants.Symptom plus a schema migration and updated factories.
  • Added a “Highlight this symptom to readers?” choice field to Breast pain and Other symptom forms/templates, and updated view tests accordingly.
  • Updated symptom presenters (and related tests/system tests) to render a “Highlight to image readers” tag in summary lists.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
manage_breast_screening/participants/models/symptom.py Adds HighlightToReaderChoices and highlight_to_readers model field.
manage_breast_screening/participants/migrations/0068_symptom_highlight_to_readers.py Adds DB column for highlight_to_readers.
manage_breast_screening/participants/migrations/max_migration.txt Bumps max migration pointer to 0068.
manage_breast_screening/participants/tests/factories.py Updates SymptomFactory to set highlight_to_readers.
manage_breast_screening/mammograms/forms/symptom_forms.py Adds highlight_to_readers ChoiceField and maps it into model create/update for Breast pain & Other.
manage_breast_screening/mammograms/jinja2/.../forms/breast_pain.jinja Renders the new highlight_to_readers field.
manage_breast_screening/mammograms/jinja2/.../forms/other.jinja Renders the new highlight_to_readers field.
manage_breast_screening/mammograms/views/symptom_views.py Adds/centralises heading description text for symptom forms.
manage_breast_screening/mammograms/presenters/symptom_presenter.py Appends “Highlight to image readers” tag to summary-list keys when flagged.
manage_breast_screening/mammograms/tests/forms/test_symptom_forms.py Updates form tests to require/accept highlight_to_readers for Breast pain & Other.
manage_breast_screening/mammograms/tests/views/test_symptom_views.py Updates view POST tests to include highlight_to_readers for Breast pain & Other.
manage_breast_screening/mammograms/tests/presenters/test_symptom_presenter.py Updates presenter expectations for tagged key rendering.
manage_breast_screening/mammograms/tests/presenters/test_medical_information_presenter.py Updates medical-information presenter expectations for tagged key rendering.
manage_breast_screening/tests/system/clinical/test_recording_symptoms.py Adjusts Playwright locators to cope with key text changing due to the appended tag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 174 to 177
def and_the_lump_on_the_right_breast_is_listed(self):
key = self.page.locator(
".nhsuk-summary-list__key", has=self.page.get_by_text("Lump", exact=True)
".nhsuk-summary-list__key", has=self.page.get_by_text("Lump")
)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

This file updates some summary-list lookups to avoid exact=True (needed now that a tag is appended), but and_the_lump_is_no_longer_listed() further down still searches for get_by_text("Lump", exact=True). With the new tag, that exact-text assertion is likely to become brittle/fail; consider updating that locator to be non-exact (or to target the key element more directly).

Copilot uses AI. Check for mistakes.
Comment on lines 159 to 163
],
},
"key": {
"text": "Lump",
"html": 'Lump<strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
},
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

There’s now branching behaviour in SymptomPresenter.build_summary_list_row() for when highlight_to_readers is False (it should fall back to a plain-text key). The tests only cover the highlighted (True) path. Adding a test case for highlight_to_readers=False would prevent regressions in the non-highlighted rendering.

Copilot uses AI. Check for mistakes.
Comment on lines 66 to 90
@@ -84,7 +84,7 @@ def test_formats_symptoms_summary_list(self):
],
},
"key": {
"text": "Swelling or shape change",
"html": 'Swelling or shape change<strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>',
},
"value": {
"html": "Both breasts<br>Less than 3 months ago<br>Not investigated",
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

MedicalInformationPresenter.symptom_rows assertions now expect the highlighted-tag HTML, but there isn’t any coverage for the case where a symptom has highlight_to_readers=False (where the key should remain plain text). Consider adding an additional symptom in this test (or a new test) with highlight_to_readers=False and asserting the tag is omitted.

Copilot uses AI. Check for mistakes.
recently_resolved = models.BooleanField(null=False, default=False)
when_resolved = models.CharField(blank=True, null=False)

highlight_to_readers = models.BooleanField(null=False, default=True)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

highlight_to_readers is being defaulted to True at the model level. Given this PR introduces an option specifically for breast pain/other symptoms, a global default of True risks marking symptoms as highlighted even when no explicit choice was made (e.g. existing rows after migration, or any code path that creates a Symptom without the form). Consider defaulting to False on the model and setting True explicitly only for symptom types that are always highlighted (or via the form logic for those types).

Suggested change
highlight_to_readers = models.BooleanField(null=False, default=True)
highlight_to_readers = models.BooleanField(null=False, default=False)

Copilot uses AI. Check for mistakes.
migrations.AddField(
model_name='symptom',
name='highlight_to_readers',
field=models.BooleanField(default=True),
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

This migration will backfill all existing Symptom rows with highlight_to_readers=True (because of the default=True on AddField). That looks inconsistent with the requirement to add an option for breast pain/“other” symptoms, and could cause existing records to appear/behave as highlighted when they previously weren’t. Consider adding the field with a safe default (e.g. False) and a data migration to set True only for symptom types that should always be highlighted (leaving breast pain/other as False unless explicitly chosen).

Suggested change
field=models.BooleanField(default=True),
field=models.BooleanField(default=False),

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +71
def _get_heading_description(self):
suffix = " a recognised symptom of breast cancer. Information recorded here will be highlighted during image reading."
if self.symptom_type_name == "lump":
return "Lumps are" + suffix
return f"{self.symptom_type_name.capitalize()} is" + suffix
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

heading_description currently always says the information "will be highlighted during image reading" for every symptom type (including Breast pain / Other where highlighting is optional per the PR description). This is likely misleading. Consider only showing this description for symptom types that are always highlighted, and using different copy (or none) for symptom types where the user can choose whether to highlight.

Copilot uses AI. Check for mistakes.
Comment on lines +142 to +145
if self._symptom.highlight_to_readers:
tag = '<strong class="nhsuk-tag app-nowrap nhsuk-tag--yellow">Highlight to image readers</strong>'
key = {"html": mark_safe(f"{escape(self._symptom.symptom_type.name)}{tag}")}
else:
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

The summary-list key HTML concatenates the symptom name directly with the tag with no separator. Unless CSS is adding spacing, this will render as a single joined string (e.g. LumpHighlight to image readers). Consider inserting whitespace and/or a margin utility class between the label and tag, and using format_html() instead of mark_safe() to avoid hand-building safe HTML.

Copilot uses AI. Check for mistakes.
Add option for breast pain and 'other' symptoms to be highlighted to readers

Display info text for symptoms that are always highlighted to readers

Add highlight_to_readers column to participants_symptom

Use 'Highlight to image readers' tag on medical info page
@swebberuk swebberuk force-pushed the DTOSS-12818-highlight-symptom branch from bc0f9c4 to ff01330 Compare April 28, 2026 16:03
@sonarqubecloud
Copy link
Copy Markdown

@swebberuk
Copy link
Copy Markdown
Contributor Author

will raise new version

@swebberuk swebberuk closed this Apr 28, 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.

2 participants