Skip to content

Commit c15bc3f

Browse files
authored
Merge pull request #40 from senaite/compat-2537
Compatibility with core#2537
2 parents 11c4d85 + dc0773c commit c15bc3f

File tree

7 files changed

+55
-16
lines changed

7 files changed

+55
-16
lines changed

docs/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
1.2.0 (unreleased)
55
------------------
66

7+
- #40 Compatibility with core#2537 (Support multi-text on result entry)
78
- #39 Compatibility with core#2584 (SampleType to DX)
89
- #38 Compatibility with core#2595 (Move ARAnalysesField logic to data manager)
910
- #37 Compatibility with core#2567 (AnalysisCategory to DX)

src/senaite/ast/config.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
u"(Susceptible, increased exposure) and R (Resistant)"),
115115
"choices": "0:|1:S|2:I|3:R",
116116
"sort_key": 530,
117-
"string_result": True,
117+
"result_type": "select",
118118
"point_of_capture": AST_POINT_OF_CAPTURE,
119119
"calculation": AST_CALCULATION_TITLE,
120120
},
@@ -129,7 +129,7 @@
129129
# XXX This is a choices field, but choices are populated on creation
130130
"choices": "",
131131
"sort_key": 505,
132-
"string_result": True,
132+
"result_type": "select",
133133
"point_of_capture": AST_POINT_OF_CAPTURE,
134134
"calculation": AST_CALCULATION_TITLE,
135135
},
@@ -144,7 +144,7 @@
144144
u"disk charge."),
145145
"size": "3",
146146
"sort_key": 510,
147-
"string_result": True,
147+
"result_type": "string",
148148
"point_of_capture": AST_POINT_OF_CAPTURE,
149149
"calculation": AST_CALCULATION_TITLE,
150150
},
@@ -160,7 +160,7 @@
160160
u"susceptible to an antibiotic."),
161161
"size": "3",
162162
"sort_key": 520,
163-
"string_result": True,
163+
"result_type": "string",
164164
"point_of_capture": AST_POINT_OF_CAPTURE,
165165
"calculation": AST_CALCULATION_TITLE,
166166
},
@@ -176,7 +176,7 @@
176176
u"susceptible to an antibiotic."),
177177
"size": "5",
178178
"sort_key": 520,
179-
"string_result": True,
179+
"result_type": "string",
180180
"point_of_capture": AST_POINT_OF_CAPTURE,
181181
"calculation": AST_CALCULATION_TITLE,
182182
},
@@ -187,7 +187,7 @@
187187
# XXX senaite.app.listing has no support for boolean types (interim)
188188
"type": "boolean",
189189
"sort_key": 540,
190-
"string_result": True,
190+
"result_type": "select",
191191
"point_of_capture": AST_POINT_OF_CAPTURE,
192192
"calculation": AST_CALCULATION_TITLE,
193193
},
@@ -200,9 +200,8 @@
200200
u"representatives"),
201201
# XXX This is a choices field, but choices are populated on creation
202202
"choices": "",
203-
"type": "multichoice",
203+
"result_type": "multichoice",
204204
"sort_key": 550,
205-
"string_result": True,
206205
"point_of_capture": AST_POINT_OF_CAPTURE,
207206
"calculation": AST_CALCULATION_TITLE,
208207
},
@@ -212,8 +211,7 @@
212211
"sort_key": 500,
213212
# The options are the list of microorganisms and are automatically
214213
# added when the corresponding analysis is initialized
215-
"options_type": "multiselect",
216-
"string_result": False,
214+
"result_type": "multiselect",
217215
"point_of_capture": "lab",
218216
"calculation": None,
219217
}

src/senaite/ast/profiles/default/metadata.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
dependencies before installing this add-on own profile.
77
-->
88
<metadata>
9-
<version>1202</version>
9+
<version>1203</version>
1010

1111
<!-- Be sure to install the following dependencies if not yet installed -->
1212
<dependencies>

src/senaite/ast/setuphandlers.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,15 @@ def setup_ast_services(portal, update_existing=True):
227227

228228
description = settings.get("description", AUTOGENERATED)
229229
sort_key = settings.get("sort_key", 1000)
230-
options_type = settings.get("options_type", "select")
231-
string_result = settings.get("string_result", False)
230+
result_type = settings.get("result_type", "select")
232231
poc = settings.get("point_of_capture", AST_POINT_OF_CAPTURE)
233232
calc_name = settings.get("calculation", AST_CALCULATION_TITLE)
234233

235234
service.setKeyword(key)
236235
service.setTitle(title)
237236
service.setDescription(description)
238237
service.setSortKey(sort_key)
239-
service.setResultOptionsType(options_type)
240-
service.setStringResult(string_result)
238+
service.setResultType(result_type)
241239
service.setPointOfCapture(poc)
242240

243241
# Get the calculation

src/senaite/ast/upgrade/v01_02_000.py

+34
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
from senaite.ast import logger
2323
from senaite.ast import PRODUCT_NAME
2424
from senaite.ast.config import AST_POINT_OF_CAPTURE
25+
from senaite.ast.config import SERVICES_SETTINGS
2526
from senaite.ast.setuphandlers import revoke_edition_permissions
2627
from senaite.ast.setuphandlers import setup_workflows
2728
from senaite.core.catalog import ANALYSIS_CATALOG
29+
from senaite.core.catalog import SETUP_CATALOG
2830
from senaite.core.upgrade import upgradestep
2931
from senaite.core.upgrade.utils import UpgradeUtils
3032

@@ -91,3 +93,35 @@ def update_role_mappings_for(object_or_brain):
9193
def revoke_setup_permissions(tool):
9294
portal = tool.aq_inner.aq_parent
9395
revoke_edition_permissions(portal)
96+
97+
98+
def restore_ast_result_type(tool):
99+
"""Setup analysis/service result types
100+
"""
101+
logger.info("Restore ResultType from AST-like services ...")
102+
# analysis services
103+
query = {
104+
"portal_type": "AnalysisService",
105+
"point_of_capture": AST_POINT_OF_CAPTURE
106+
}
107+
brains = api.search(query, SETUP_CATALOG)
108+
total = len(brains)
109+
for num, brain in enumerate(brains):
110+
111+
if num and num % 1000 == 0:
112+
logger.info("Setup result types %s/%s" % (num, total))
113+
114+
obj = api.get_object(brain)
115+
if not obj:
116+
continue
117+
118+
keyword = obj.getKeyword()
119+
settings = SERVICES_SETTINGS.get(keyword)
120+
if not settings:
121+
continue
122+
123+
result_type = settings.get("result_type")
124+
obj.setResultType(result_type)
125+
obj._p_deactivate()
126+
127+
logger.info("Restore ResultType from AST-like services [DONE]")

src/senaite/ast/upgrade/v01_02_000.zcml

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
xmlns="http://namespaces.zope.org/zope"
33
xmlns:genericsetup="http://namespaces.zope.org/genericsetup">
44

5+
<genericsetup:upgradeStep
6+
title="SENAITE AST 1.2.0: Restore ResultType for AST-like services"
7+
description="Restore ResultType for AST-like services"
8+
source="1202"
9+
destination="1203"
10+
handler="senaite.ast.upgrade.v01_02_000.restore_ast_result_type"
11+
profile="senaite.ast:default"/>
12+
513
<genericsetup:upgradeStep
614
title="SENAITE AST 1.2.0: Revoke edit permissions for AST setup objects"
715
description="Revoke edit permissions for AST setup objects"

src/senaite/ast/workflow/analysis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def after_initialize(analysis):
4646
options = zip(range(len(names)), names)
4747
options = map(lambda m: {"ResultValue": m[0], "ResultText": m[1]}, options)
4848
analysis.setResultOptions(options)
49-
analysis.setResultOptionsType("multiselect")
49+
analysis.setResultType("multiselect")
5050
analysis.reindexObject()
5151

5252

0 commit comments

Comments
 (0)