diff --git a/docs/changelog.rst b/docs/changelog.rst index 2e48f6c..061bb8e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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) diff --git a/src/senaite/ast/config.py b/src/senaite/ast/config.py index 9c9fa6a..2667060 100644 --- a/src/senaite/ast/config.py +++ b/src/senaite/ast/config.py @@ -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, }, @@ -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, }, @@ -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, }, @@ -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, }, @@ -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, }, @@ -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, }, @@ -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, }, @@ -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, } diff --git a/src/senaite/ast/profiles/default/metadata.xml b/src/senaite/ast/profiles/default/metadata.xml index 2bc3e64..e5c2285 100644 --- a/src/senaite/ast/profiles/default/metadata.xml +++ b/src/senaite/ast/profiles/default/metadata.xml @@ -6,7 +6,7 @@ dependencies before installing this add-on own profile. --> - 1202 + 1203 diff --git a/src/senaite/ast/setuphandlers.py b/src/senaite/ast/setuphandlers.py index ab4f224..b80b425 100644 --- a/src/senaite/ast/setuphandlers.py +++ b/src/senaite/ast/setuphandlers.py @@ -227,8 +227,7 @@ 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) @@ -236,8 +235,7 @@ def setup_ast_services(portal, update_existing=True): 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 diff --git a/src/senaite/ast/upgrade/v01_02_000.py b/src/senaite/ast/upgrade/v01_02_000.py index 547470f..3fcee36 100644 --- a/src/senaite/ast/upgrade/v01_02_000.py +++ b/src/senaite/ast/upgrade/v01_02_000.py @@ -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 @@ -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]") diff --git a/src/senaite/ast/upgrade/v01_02_000.zcml b/src/senaite/ast/upgrade/v01_02_000.zcml index b63486f..4acb82c 100644 --- a/src/senaite/ast/upgrade/v01_02_000.zcml +++ b/src/senaite/ast/upgrade/v01_02_000.zcml @@ -2,6 +2,14 @@ xmlns="http://namespaces.zope.org/zope" xmlns:genericsetup="http://namespaces.zope.org/genericsetup"> + +