Skip to content

Commit

Permalink
Merge pull request #40 from senaite/compat-2537
Browse files Browse the repository at this point in the history
Compatibility with core#2537
  • Loading branch information
ramonski authored Nov 29, 2024
2 parents 11c4d85 + dc0773c commit c15bc3f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.2.0 (unreleased)
------------------

- #40 Compatibility with core#2537 (Support multi-text on result entry)
- #39 Compatibility with core#2584 (SampleType to DX)
- #38 Compatibility with core#2595 (Move ARAnalysesField logic to data manager)
- #37 Compatibility with core#2567 (AnalysisCategory to DX)
Expand Down
18 changes: 8 additions & 10 deletions src/senaite/ast/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
u"(Susceptible, increased exposure) and R (Resistant)"),
"choices": "0:|1:S|2:I|3:R",
"sort_key": 530,
"string_result": True,
"result_type": "select",
"point_of_capture": AST_POINT_OF_CAPTURE,
"calculation": AST_CALCULATION_TITLE,
},
Expand All @@ -129,7 +129,7 @@
# XXX This is a choices field, but choices are populated on creation
"choices": "",
"sort_key": 505,
"string_result": True,
"result_type": "select",
"point_of_capture": AST_POINT_OF_CAPTURE,
"calculation": AST_CALCULATION_TITLE,
},
Expand All @@ -144,7 +144,7 @@
u"disk charge."),
"size": "3",
"sort_key": 510,
"string_result": True,
"result_type": "string",
"point_of_capture": AST_POINT_OF_CAPTURE,
"calculation": AST_CALCULATION_TITLE,
},
Expand All @@ -160,7 +160,7 @@
u"susceptible to an antibiotic."),
"size": "3",
"sort_key": 520,
"string_result": True,
"result_type": "string",
"point_of_capture": AST_POINT_OF_CAPTURE,
"calculation": AST_CALCULATION_TITLE,
},
Expand All @@ -176,7 +176,7 @@
u"susceptible to an antibiotic."),
"size": "5",
"sort_key": 520,
"string_result": True,
"result_type": "string",
"point_of_capture": AST_POINT_OF_CAPTURE,
"calculation": AST_CALCULATION_TITLE,
},
Expand All @@ -187,7 +187,7 @@
# XXX senaite.app.listing has no support for boolean types (interim)
"type": "boolean",
"sort_key": 540,
"string_result": True,
"result_type": "select",
"point_of_capture": AST_POINT_OF_CAPTURE,
"calculation": AST_CALCULATION_TITLE,
},
Expand All @@ -200,9 +200,8 @@
u"representatives"),
# XXX This is a choices field, but choices are populated on creation
"choices": "",
"type": "multichoice",
"result_type": "multichoice",
"sort_key": 550,
"string_result": True,
"point_of_capture": AST_POINT_OF_CAPTURE,
"calculation": AST_CALCULATION_TITLE,
},
Expand All @@ -212,8 +211,7 @@
"sort_key": 500,
# The options are the list of microorganisms and are automatically
# added when the corresponding analysis is initialized
"options_type": "multiselect",
"string_result": False,
"result_type": "multiselect",
"point_of_capture": "lab",
"calculation": None,
}
Expand Down
2 changes: 1 addition & 1 deletion src/senaite/ast/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
dependencies before installing this add-on own profile.
-->
<metadata>
<version>1202</version>
<version>1203</version>

<!-- Be sure to install the following dependencies if not yet installed -->
<dependencies>
Expand Down
6 changes: 2 additions & 4 deletions src/senaite/ast/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,15 @@ def setup_ast_services(portal, update_existing=True):

description = settings.get("description", AUTOGENERATED)
sort_key = settings.get("sort_key", 1000)
options_type = settings.get("options_type", "select")
string_result = settings.get("string_result", False)
result_type = settings.get("result_type", "select")
poc = settings.get("point_of_capture", AST_POINT_OF_CAPTURE)
calc_name = settings.get("calculation", AST_CALCULATION_TITLE)

service.setKeyword(key)
service.setTitle(title)
service.setDescription(description)
service.setSortKey(sort_key)
service.setResultOptionsType(options_type)
service.setStringResult(string_result)
service.setResultType(result_type)
service.setPointOfCapture(poc)

# Get the calculation
Expand Down
34 changes: 34 additions & 0 deletions src/senaite/ast/upgrade/v01_02_000.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
from senaite.ast import logger
from senaite.ast import PRODUCT_NAME
from senaite.ast.config import AST_POINT_OF_CAPTURE
from senaite.ast.config import SERVICES_SETTINGS
from senaite.ast.setuphandlers import revoke_edition_permissions
from senaite.ast.setuphandlers import setup_workflows
from senaite.core.catalog import ANALYSIS_CATALOG
from senaite.core.catalog import SETUP_CATALOG
from senaite.core.upgrade import upgradestep
from senaite.core.upgrade.utils import UpgradeUtils

Expand Down Expand Up @@ -91,3 +93,35 @@ def update_role_mappings_for(object_or_brain):
def revoke_setup_permissions(tool):
portal = tool.aq_inner.aq_parent
revoke_edition_permissions(portal)


def restore_ast_result_type(tool):
"""Setup analysis/service result types
"""
logger.info("Restore ResultType from AST-like services ...")
# analysis services
query = {
"portal_type": "AnalysisService",
"point_of_capture": AST_POINT_OF_CAPTURE
}
brains = api.search(query, SETUP_CATALOG)
total = len(brains)
for num, brain in enumerate(brains):

if num and num % 1000 == 0:
logger.info("Setup result types %s/%s" % (num, total))

obj = api.get_object(brain)
if not obj:
continue

keyword = obj.getKeyword()
settings = SERVICES_SETTINGS.get(keyword)
if not settings:
continue

result_type = settings.get("result_type")
obj.setResultType(result_type)
obj._p_deactivate()

logger.info("Restore ResultType from AST-like services [DONE]")
8 changes: 8 additions & 0 deletions src/senaite/ast/upgrade/v01_02_000.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup">

<genericsetup:upgradeStep
title="SENAITE AST 1.2.0: Restore ResultType for AST-like services"
description="Restore ResultType for AST-like services"
source="1202"
destination="1203"
handler="senaite.ast.upgrade.v01_02_000.restore_ast_result_type"
profile="senaite.ast:default"/>

<genericsetup:upgradeStep
title="SENAITE AST 1.2.0: Revoke edit permissions for AST setup objects"
description="Revoke edit permissions for AST setup objects"
Expand Down
2 changes: 1 addition & 1 deletion src/senaite/ast/workflow/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def after_initialize(analysis):
options = zip(range(len(names)), names)
options = map(lambda m: {"ResultValue": m[0], "ResultText": m[1]}, options)
analysis.setResultOptions(options)
analysis.setResultOptionsType("multiselect")
analysis.setResultType("multiselect")
analysis.reindexObject()


Expand Down

0 comments on commit c15bc3f

Please sign in to comment.