-
Notifications
You must be signed in to change notification settings - Fork 4
Add benign lump form #739
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
Add benign lump form #739
Conversation
c07c407 to
e4e0a15
Compare
cb048cf to
1665396
Compare
|
Do we need to add a I found we'd done something similar for sympton views: So I did the same for the implanted medical devices changes I made: Maybe we feel that behaviour is already sufficiently covered by the playwright tests in |
| **kwargs, | ||
| ): | ||
| if min_value is None: | ||
| min_value = date.today().year - 80 |
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.
Just noticed a possible problem here - fields can be created when the form is declared, rather than when the form is instantiated, so the field's validation could get stale if the app doesn't restart. Maybe less of an issue here, but definitely in the SplitDateField.
Is it possible to make min_value/max_value a callable?
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.
Yes, good point. I've attempted to address this in 6cc2573. WDYT?
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.
looks good to me 👍🏻
| messages.add_message( | ||
| self.request, | ||
| messages.SUCCESS, | ||
| "Added benign lump history", |
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 think the pattern elsewhere is "Noun added" rather than "Added noun" - not sure which we prefer but they should be consistent
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.
Updated
manage_breast_screening/mammograms/forms/benign_lump_history_item_form.py
Show resolved
Hide resolved
MatMoore
left a comment
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 think there might be some visually hidden text missing - see inline comment
|
We'll want a specific error for the conditional text inputs for treatment location. |
@swebberuk exactly this — I tend to add view tests if there's some complex behaviour (or permutations of some kind) that aren't adequately covered by the system test. In this case, I think the system test is sufficient. |
| "max_value", "Year must be less than %(max_value)s" | ||
| ), | ||
| code="max_value", | ||
| params={"max_value": max_value}, |
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.
If using the message "Year must be less than %(max_value)s" then should this be: params={"max_value": max_value + 1},
It was suggested on Slack that the error message could be "Year of procedure cannot be in the future" - so don't know if we need to make it configurable? To avoid blocking merging this PR, maybe we can review the error message as part of a separate ticket?
Here is a link to a related comment from a different PR: #742 (comment)
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.
Maybe we can raise another ticket that looks at both the YearField and the SplitDateField? Both will need some tweaking to the error messages I think
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 think a ticket to revisit these would be a good idea, including potentially making the error message configurable. For this PR, I'll adjust these to "Year must be (value) or later" and "Year must be (value) or earlier".
| "min_value", "Year must be greater than %(min_value)s" | ||
| ), | ||
| code="min_value", | ||
| params={"min_value": min_value}, |
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.
Similar question as for max value validation, should this be: params={"min_value": min_value - 1},
manage_breast_screening/mammograms/forms/benign_lump_history_item_form.py
Show resolved
Hide resolved
Updated in 6ba8a1c and screenshot replaced in PR description |
6ba8a1c to
695bee4
Compare
|
The review app at this URL has been deleted: |
| bounds["max"] = 2002 | ||
| form = TestForm(data={"field": 2003}) | ||
| assert not form.is_valid() | ||
| assert form.errors["field"] == ["Year must be less than 2002"] |
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.
Need to change to Year must be 2002 or earlier and line 56 to Year must be 2000 or later.
Introduce the initial template, form object and routing for creating benign lump history items on the medical info screen.
- Introduce YearField as a specific type of IntegerField that validates for a year between 80 years ago and today. - Use this in the benign lump history item form.
Matching the choice in the prototype to make this heading aria-hidden=true.
The current YearField validation on min and max value is implemented in a way that means values based on the current year will only be evaluated on module import. An application restart after moving from one year to the next would be needed to ensure current year is correct. This isn't a huge bug necessarily with our current use cases, but it's an inconvenient issue to leave in the codebase. This commit switches to using min_value_callable and max_value_callable to determine the year bounds. These can be overridden, but by default specify a range of 80 years to current year.
695bee4 to
43d26fa
Compare
swebberuk
left a comment
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.
👍
Description
Add the form for adding a benign lump history item.
See commit messages for summary of changes.
Validation errors — no data submitted
Validation errors — no location details
Jira link
https://nhsd-jira.digital.nhs.uk/browse/DTOSS-11451
Review notes
The YearField isn't customizable in terms of the range it checks for. Does it need to be at this stage?< no longer the case after the changes introduced following this comment Add benign lump form #739 (comment)Review checklist