Skip to content

Commit

Permalink
Merge pull request #84 from senaite/patient-wo-mrn-listing
Browse files Browse the repository at this point in the history
Display "Not defined" in listing for patients without MRN set
  • Loading branch information
ramonski authored Sep 20, 2023
2 parents 196f8f1 + 9664d29 commit 467910b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
1.4.0 (unreleased)
------------------

- #84 Display "Not defined" in listing for patients without MRN set
- #85 Display MRN instead of fullname in temporary identifier widget
- #83 Fix Patients are not created on Add sample form submit
- #82 Fix traceback when adding a patient
Expand Down
22 changes: 11 additions & 11 deletions src/senaite/patient/browser/patientfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
# Some rights reserved, see README and LICENSE.

import collections

from bika.lims import api
from bika.lims import senaiteMessageFactory as _
from bika.lims.interfaces import IClient
from bika.lims.utils import get_email_link
from bika.lims.utils import get_image
from bika.lims.utils import get_link
from senaite.app.listing.view import ListingView
from senaite.patient import messageFactory as _sp
from senaite.patient.api import to_identifier_type_name
from senaite.patient.api import tuplify_identifiers
from senaite.patient.catalog import PATIENT_CATALOG
from senaite.patient.i18n import translate as t
from senaite.patient.permissions import AddPatient


Expand Down Expand Up @@ -154,12 +155,13 @@ def folderitem(self, obj, item, index):
url = api.get_url(obj)

# MRN
mrn = obj.getMRN() or obj.getId()
if mrn:
mrn = api.safe_unicode(mrn).encode("utf8")
item["mrn"] = mrn
item["replace"]["mrn"] = get_link(
url, value=mrn)
mrn = obj.getMRN()
if not mrn:
item["before"]["mrn"] = get_image("info", width=16)
mrn = t(_sp("mrn_not_defined", default="Not defined"))

item["mrn"] = self.to_utf8(mrn)
item["replace"]["mrn"] = get_link(url, value=mrn)

# Patient Identifiers
identifiers = obj.getIdentifiers()
Expand All @@ -171,15 +173,13 @@ def folderitem(self, obj, item, index):
if fullname:
fullname = api.safe_unicode(fullname).encode("utf8")
item["fullname"] = fullname
item["replace"]["fullname"] = get_link(
url, value=fullname)
item["replace"]["fullname"] = get_link(url, value=fullname)

# Email
email = obj.getEmail()
if email:
item["email"] = email
item["replace"]["email"] = get_email_link(
email, value=email)
item["replace"]["email"] = get_email_link(email, value=email)

# Email Report
email_report = obj.getEmailReport()
Expand Down
39 changes: 39 additions & 0 deletions src/senaite/patient/i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
#
# This file is part of SENAITE.PATIENT.
#
# SENAITE.PATIENT is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright 2020-2022 by it's authors.
# Some rights reserved, see README and LICENSE.

from bika.lims import api


def translate(msgid, **kwargs):
"""Translate any zope i18n msgid returned from MessageFactory
"""
msgid = api.safe_unicode(msgid)

# XX: If the msgid is from type `Message`, Zope's i18n translate tool gives
# priority `Message.domain` over the domain passed through kwargs
domain = kwargs.pop("domain", "senaite.patient")
params = {
"domain": getattr(msgid, "domain", domain),
"context": api.get_request(),
}
params.update(kwargs)

ts = api.get_tool("translation_service")
return ts.translate(msgid, **params)

0 comments on commit 467910b

Please sign in to comment.