Skip to content

Commit

Permalink
Merge branch '1.x' of github.com:senaite/senaite.referral into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
xispa committed Jul 24, 2024
2 parents 9785b5d + 207bc66 commit 2678daa
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/senaite/referral/adapters/listing/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from senaite.app.listing.interfaces import IListingViewAdapter
from senaite.referral import check_installed
from senaite.referral import messageFactory as _
from senaite.referral.utils import get_services_mapping
from zope.component import adapter
from zope.interface import implementer

Expand Down Expand Up @@ -148,17 +147,10 @@ def referring_services(self):
referring laboratory, if any
"""
if self._referring_services is None:
self._referring_services = []
inbound_sample = self.context.getInboundSample()
if not inbound_sample:
self._referring_services = []
return self._referring_services

# Look up the uids of the requested services
services = get_services_mapping()
keywords = inbound_sample.getAnalyses() or []
services_uids = map(lambda key: services.get(key), keywords)
self._referring_services = filter(api.is_uid, services_uids)

if inbound_sample:
self._referring_services = inbound_sample.getRawServices()
return self._referring_services

@check_installed(None)
Expand Down
21 changes: 21 additions & 0 deletions src/senaite/referral/browser/workflow/analysisrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# Some rights reserved, see README and LICENSE.

from bika.lims.browser.workflow import RequestContextAware
from bika.lims.browser.workflow.analysisrequest import \
WorkflowActionSaveAnalysesAdapter
from bika.lims.interfaces import IAnalysisRequest
from bika.lims.interfaces import IWorkflowActionUIDsAdapter
from zope.interface import implementer

Expand All @@ -34,3 +37,21 @@ def __call__(self, action, uids):
url = "{}/referral_ship_samples?uids={}".format(self.back_url,
",".join(uids))
return self.redirect(redirect_url=url)


class SaveAnalysesAdapter(WorkflowActionSaveAnalysesAdapter):

def get_uids_from_request(self):
"""Returns the UIDs from the request plus those from the analyses from
the inound shipment that were once requested, if any
"""
uids = super(SaveAnalysesAdapter, self).get_uids_from_request()
if not IAnalysisRequest.providedBy(self.context):
return uids

inbound_sample = self.context.getInboundSample()
if not inbound_sample:
return uids

uids.extend(inbound_sample.getRawServices())
return list(set(uids))
12 changes: 12 additions & 0 deletions src/senaite/referral/browser/workflow/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@
provides="bika.lims.interfaces.IWorkflowActionAdapter"
permission="zope.Public" />

<!-- Analysis Request: "save_analyses"
Prevents services that were initially requested by the referring laboratory
to be manually removed through manage_analyses view
-->
<adapter
name="workflow_action_save_analyses"
for="bika.lims.interfaces.IAnalysisRequest
senaite.referral.interfaces.ISenaiteReferralLayer"
factory=".analysisrequest.SaveAnalysesAdapter"
provides="bika.lims.interfaces.IWorkflowActionAdapter"
permission="zope.Public" />

</configure>

0 comments on commit 2678daa

Please sign in to comment.