Skip to content

Conversation

@swebberuk
Copy link
Contributor

@swebberuk swebberuk commented Jan 26, 2026

Add "Add additional image details" page. This is the page that is shown when a user selects "No, add additional image details..." from the "Record images taken" page.

Also included changes to have an incrementing total count of images, and to show "Repeat or extra image details captured on the next screen" message if any count > 1.

Note: This PR does not include the stepper input component. In this PR the form uses IntegerField for the image count fields. Will add stepper input component in a later PR.

Page is not linked to from any other pages yet. Can be accessed directly at http://127.0.0.1:8000/mammograms/1cbea52c-e47d-45e6-a12d-360b37056131/add-additional-image-details/

Description

image

Jira link

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

Review notes

Review checklist

  • Check database queries are correctly scoped to current_provider

@swebberuk swebberuk force-pushed the DTOSS-11826-add-additional-image-details branch from df7cb95 to 60085ba Compare January 26, 2026 08:19
{% endfor %}
{% for error_list in form.non_field_errors() %}
{% set ns.errors = ns.errors + [{"text": ",".join(error_list)}] %}
{% for error in form.non_field_errors() %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this change to avoid error message being displayed as "E,n,t,e,r, ,a,t, ,l,e,a,s,t, ,o,n,e, ,i,m,a,g,e, ,c,o,u,n,t"

The error message is being set by doing self.add_error(None, "Enter at least one image count") in add_additional_image_details_form.py.

image

@swebberuk swebberuk marked this pull request as ready for review January 26, 2026 08:28
@swebberuk swebberuk mentioned this pull request Jan 26, 2026
1 task
{% block bodyEnd %}
{{ super() }}

<script>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

The backend looks good, but it looks like there's some missing CSS for progressive enhancement.

I'm not sure if need any more validation on the javascript side for invalid inputs. I just noticed that we are coercing bad values to 0 which seemed a bit suspicious.

additional_details=self.cleaned_data.get("additional_details", ""),
)

self._add_series_if_provided(study, "MLO", "R", "rmlo_count")
Copy link
Contributor

Choose a reason for hiding this comment

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

[Suggestion; not blocking] We could potentially optimise this by using bulk_create instead of create https://docs.djangoproject.com/en/6.0/ref/models/querysets/#bulk-create

// Function to get all currently visible count inputs
const getCountInputs = () => {
return [
document.getElementById('id_rmlo_count'),
Copy link
Contributor

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 would be simpler to use a data attribute rather than looking these up individually by ID. Something like document.querySelectorAll('[data-count-input]')?

@colinrotherham are there any conventions we should follow for this kind of thing?

view_position=view_position,
laterality=laterality,
count=count,
)
Copy link
Contributor

@malcolmbaig malcolmbaig Jan 27, 2026

Choose a reason for hiding this comment

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

We'll need to decide how we handle a scenario where the user presses the back button and re-submits the form (with or without changes to the field values). Currently this flow creates an additional set of Series records with each re-submission.

Potential options:

  • Delete all Series under the given Study and re-create
  • Detect existing Series records in the view and redirect somewhere (Check information?) with an info message

Copy link
Contributor

@MatMoore MatMoore Jan 28, 2026

Choose a reason for hiding this comment

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

I've gone with a recreate in #943 (for the case where the default number of images were taken)

You might be able to reuse the StudyService from there.

Copy link
Contributor Author

@swebberuk swebberuk Jan 30, 2026

Choose a reason for hiding this comment

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

Altered to use StudyService.

"<uuid:pk>/add-additional-image-details/",
add_additional_image_details_view.AddAdditionalImageDetailsView.as_view(),
name="add_additional_image_details",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about naming here, and opting for nouns to describe resources where possible — would /image-details suffice here?

Copy link
Contributor

@MatMoore MatMoore Jan 27, 2026

Choose a reason for hiding this comment

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

I suspect we've been a bit consistent with URLs, and could adopt a common convention.

e.g. we could do something like this, throughout the service:

Method URL Description
GET /NOUN display a collection
GET /NOUN/<id> display a specific item
GET/POST /NOUN/new form for adding an item
GET/POST /NOUN/<id>/edit form for editing an item
GET/DELETE /NOUN/<id>/delete delete an item

Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@swebberuk swebberuk force-pushed the DTOSS-11826-add-additional-image-details branch from 41b49e2 to 5d51dd6 Compare January 27, 2026 14:58
@swebberuk swebberuk force-pushed the DTOSS-11826-add-additional-image-details branch from a9c2eb4 to 8dfc5a9 Compare January 27, 2026 19:17
@MatMoore MatMoore dismissed their stale review January 28, 2026 11:49

My comments are addressed now

If any counts > 1 then show message about repeat images
Added app-js-only to hide elements when javascript not enabled
Renamed add_additional_image_details to add_image_details

Replaced /add-additional-image-details/ with /image-details/new
@swebberuk swebberuk force-pushed the DTOSS-11826-add-additional-image-details branch 2 times, most recently from 0cea346 to a537064 Compare January 29, 2026 17:50
@swebberuk swebberuk force-pushed the DTOSS-11826-add-additional-image-details branch from a537064 to 6f3eee7 Compare January 30, 2026 08:58
@sonarqubecloud
Copy link

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.

3 participants