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

Dynamic PDF group key lookup #145

Merged
merged 2 commits into from
Oct 5, 2023
Merged

Dynamic PDF group key lookup #145

merged 2 commits into from
Oct 5, 2023

Conversation

ramonski
Copy link
Contributor

@ramonski ramonski commented Oct 4, 2023

Description of the issue/feature this PR addresses

This PR allows to provide a custom group key to split PDFs by a custom criteria, e.g. the Client UID and the Patient MRN if senaite.patient is installed.

Example code

from bika.lims.interfaces import IAnalysisRequest
from senaite.impress.interfaces import IGroupKeyProvider
from zope.component import adapter
from zope.interface import implementer


@implementer(IGroupKeyProvider)
@adapter(IAnalysisRequest)
class GroupKeyProvider(object):
    """Provide a grouping key for PDF separation
    """
    def __init__(self, context):
        self.context = context

    def __call__(self):
        client_uid = self.context.getClientUID()
        mrn = self.context.getMedicalRecordNumberValue()
        if mrn:
            return "%s_%s" % (client_uid, mrn)
        return client_uid

Current behavior before PR

PDFs are grouped hard coded by the key getClientUID.

Desired behavior after PR is merged

Group key retrieved by an Adapter lookup on the object.

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

@ramonski ramonski requested a review from xispa October 4, 2023 19:12
Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

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

Excellent thanks!

@xispa xispa merged commit db03e8c into 2.x Oct 5, 2023
@xispa xispa deleted the dynamic-group-key branch October 5, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants