Skip to content
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

Display "Not defined" in listing for patients without MRN set #84

Merged
merged 5 commits into from
Sep 20, 2023

Conversation

xispa
Copy link
Member

@xispa xispa commented Sep 20, 2023

Description of the issue/feature this PR addresses

When the configuration option "Require Medical Record Number (MRN)" is disabled, the "MRN" field in Patient add/edit view is not required and therefore, Patient objects with empty MRN can be created. In those cases, the internal ID of the patient is displayed in the patients listing.

This Pull Request displays "Not defined" instead of the object internal ID for patients with an empty MRN.

Current behavior before PR

Patient internal id is displayed as MRN in listing for patients without MRN set.

Desired behavior after PR is merged

"Not defined", along with an alert is displayed as MRN in listing for patients without MRN set

Captura de 2023-09-20 11-27-01

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@xispa xispa requested a review from ramonski September 20, 2023 11:30
url, value=mrn)
mrn = obj.getMRN()
if not mrn:
item["before"]["mrn"] = self.icon_tag("info", width=16)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed with 3c6d98a

"""Returns the translated message
"""
ts = api.get_tool("translation_service")
return ts.translate(message)
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 you should pass in here the context and request as well to make it work in different languages.
Also see Products.CMFPlone.TranslationServiceTool.TranslationServiceTool.translate

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that Plone's ts ultimately relies on Zope's i18n translate function. And if the message passed in is from type Message, i18n gives priority to the domain and other info set at Message level, regardless of what you pass through kwargs: https://github.com/zopefoundation/zope.i18n/blob/bb0b8d2ee88a1e280cc86d858e7a2524ba0dc8d9/src/zope/i18n/__init__.py#L164-L170

Since we always rely on our own add-on MessageFactory, the domain is always assigned to the message and therefore, there is no need to explicitely pass the domain. However, I agree is always a good idea to be consistent, so I added a translate function (that we could eventually port to senaite.core and replace the existing utils.t): 3c6d98a

Copy link
Member Author

Choose a reason for hiding this comment

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

[..] that we could eventually port to senaite.core and replace the existing utils.t): 3c6d98a

Done with senaite/senaite.core#2389

@ramonski ramonski merged commit 467910b into master Sep 20, 2023
0 of 2 checks passed
@ramonski ramonski deleted the patient-wo-mrn-listing branch September 20, 2023 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants