tricc-oo 1.6.22__py3-none-any.whl → 1.6.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tricc_oo/models/base.py +1 -0
- tricc_oo/models/tricc.py +2 -0
- tricc_oo/visitors/tricc.py +62 -23
- {tricc_oo-1.6.22.dist-info → tricc_oo-1.6.23.dist-info}/METADATA +1 -1
- {tricc_oo-1.6.22.dist-info → tricc_oo-1.6.23.dist-info}/RECORD +8 -8
- {tricc_oo-1.6.22.dist-info → tricc_oo-1.6.23.dist-info}/WHEEL +0 -0
- {tricc_oo-1.6.22.dist-info → tricc_oo-1.6.23.dist-info}/licenses/LICENSE +0 -0
- {tricc_oo-1.6.22.dist-info → tricc_oo-1.6.23.dist-info}/top_level.txt +0 -0
tricc_oo/models/base.py
CHANGED
|
@@ -217,6 +217,7 @@ class TriccNodeBaseModel(TriccBaseModel):
|
|
|
217
217
|
expression_inputs: List[Expression] = []
|
|
218
218
|
activity: Optional[FwTriccNodeBaseModel] = None
|
|
219
219
|
ref_def: Optional[Union[int, str]] = None # for medal creator
|
|
220
|
+
is_sequence_defined: bool = False
|
|
220
221
|
|
|
221
222
|
class Config:
|
|
222
223
|
use_enum_values = True # <--
|
tricc_oo/models/tricc.py
CHANGED
|
@@ -301,6 +301,7 @@ class TriccNodeDisplayModel(TriccNodeBaseModel):
|
|
|
301
301
|
class TriccNodeNote(TriccNodeDisplayModel):
|
|
302
302
|
tricc_type: TriccNodeType = TriccNodeType.note
|
|
303
303
|
datatype: str = "string"
|
|
304
|
+
is_sequence_defined: bool = True
|
|
304
305
|
|
|
305
306
|
|
|
306
307
|
class TriccNodeInputModel(TriccNodeDisplayModel):
|
|
@@ -308,6 +309,7 @@ class TriccNodeInputModel(TriccNodeDisplayModel):
|
|
|
308
309
|
constraint_message: Optional[Union[str, Dict[str, str]]] = None
|
|
309
310
|
constraint: Optional[Expression] = None
|
|
310
311
|
save: Optional[str] = None # contribute to another calculate
|
|
312
|
+
is_sequence_defined: bool = True
|
|
311
313
|
|
|
312
314
|
|
|
313
315
|
class TriccNodeDate(TriccNodeInputModel):
|
tricc_oo/visitors/tricc.py
CHANGED
|
@@ -158,19 +158,25 @@ def set_last_version_false(node, processed_nodes):
|
|
|
158
158
|
return last_version
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
def get_version_inheritance(node,
|
|
162
|
-
|
|
163
|
-
#
|
|
161
|
+
def get_version_inheritance(node, all_prev_versions, processed_nodes):
|
|
162
|
+
|
|
163
|
+
# Updated to merge ALL previous versions, not just the last one
|
|
164
|
+
# This ensures inheritance works even when intermediate activities weren't triggered
|
|
165
|
+
|
|
164
166
|
if not issubclass(node.__class__, (TriccNodeInputModel)):
|
|
165
167
|
node.last = True
|
|
166
168
|
if issubclass(node.__class__, (TriccNodeDisplayCalculateBase, TriccNodeEnd)) and node.name is not None:
|
|
167
169
|
# logger.debug("set last to false for node {}
|
|
168
170
|
# and add its link it to next one".format(last_used_calc.get_name()))
|
|
169
171
|
if node.prev_nodes:
|
|
170
|
-
|
|
172
|
+
# Set prev_next_node only with the immediate last version
|
|
173
|
+
for pv in all_prev_versions:
|
|
174
|
+
set_prev_next_node(pv, node)
|
|
171
175
|
else:
|
|
172
176
|
expression = node.expression or node.expression_reference or getattr(node, "relevance", None)
|
|
173
|
-
|
|
177
|
+
# Merge with ALL previous versions, not just the last one
|
|
178
|
+
if all_prev_versions:
|
|
179
|
+
expression = merge_all_expressions(expression, all_prev_versions)
|
|
174
180
|
if node.expression:
|
|
175
181
|
node.expression = expression
|
|
176
182
|
elif node.expression_reference:
|
|
@@ -180,17 +186,21 @@ def get_version_inheritance(node, last_version, processed_nodes):
|
|
|
180
186
|
else:
|
|
181
187
|
node.last = False
|
|
182
188
|
|
|
183
|
-
# Create a calculate node that coalesces
|
|
189
|
+
# Create a calculate node that coalesces all previous saved values with the current node value
|
|
184
190
|
calc_id = generate_id(f"save_{node.save}")
|
|
191
|
+
|
|
192
|
+
# Build reference list with current node and all previous versions
|
|
193
|
+
reference_list = [node] + (all_prev_versions if all_prev_versions else [])
|
|
194
|
+
|
|
185
195
|
calc = TriccNodeCalculate(
|
|
186
196
|
id=calc_id,
|
|
187
197
|
name=node.save,
|
|
188
198
|
path_len=node.path_len + 1,
|
|
189
199
|
expression_reference=TriccOperation(
|
|
190
200
|
TriccOperator.COALESCE,
|
|
191
|
-
|
|
201
|
+
reference_list,
|
|
192
202
|
),
|
|
193
|
-
reference=
|
|
203
|
+
reference=reference_list,
|
|
194
204
|
activity=node.activity,
|
|
195
205
|
group=node.group,
|
|
196
206
|
label=f"Save calculation for {node.label}",
|
|
@@ -201,7 +211,9 @@ def get_version_inheritance(node, last_version, processed_nodes):
|
|
|
201
211
|
# set_last_version_false(calc, processed_nodes)
|
|
202
212
|
processed_nodes.add(calc)
|
|
203
213
|
if issubclass(node.__class__, TriccNodeInputModel):
|
|
204
|
-
|
|
214
|
+
# Coalesce with all previous versions
|
|
215
|
+
coalesce_operands = ["$this"] + (all_prev_versions if all_prev_versions else [])
|
|
216
|
+
node.expression = TriccOperation(TriccOperator.COALESCE, coalesce_operands)
|
|
205
217
|
|
|
206
218
|
|
|
207
219
|
def merge_expression(expression, last_version):
|
|
@@ -216,6 +228,30 @@ def merge_expression(expression, last_version):
|
|
|
216
228
|
return expression
|
|
217
229
|
|
|
218
230
|
|
|
231
|
+
def merge_all_expressions(expression, all_versions):
|
|
232
|
+
"""
|
|
233
|
+
Merge an expression with ALL previous versions, not just the last one.
|
|
234
|
+
This ensures inheritance works even when intermediate versions weren't evaluated
|
|
235
|
+
due to activity relevance conditions.
|
|
236
|
+
"""
|
|
237
|
+
if not all_versions:
|
|
238
|
+
return expression
|
|
239
|
+
|
|
240
|
+
datatype = expression.get_datatype() if expression else "unknown"
|
|
241
|
+
|
|
242
|
+
if datatype == "boolean":
|
|
243
|
+
expression = or_join(all_versions)
|
|
244
|
+
|
|
245
|
+
else:
|
|
246
|
+
# COALESCE through all previous versions, then the current expression
|
|
247
|
+
coalesce_operands = list(all_versions)
|
|
248
|
+
if expression:
|
|
249
|
+
coalesce_operands.append(expression)
|
|
250
|
+
expression = TriccOperation(TriccOperator.COALESCE, coalesce_operands)
|
|
251
|
+
|
|
252
|
+
return expression
|
|
253
|
+
|
|
254
|
+
|
|
219
255
|
def load_calculate(
|
|
220
256
|
node, processed_nodes, stashed_nodes, calculates, used_calculates, warn=False, process=None, **kwargs
|
|
221
257
|
):
|
|
@@ -239,8 +275,14 @@ def load_calculate(
|
|
|
239
275
|
# tricc diagnostic have the same name as proposed diag but will be serialised with different names
|
|
240
276
|
|
|
241
277
|
last_version = set_last_version_false(node, processed_nodes)
|
|
278
|
+
# Get all previous versions from processed_nodes, not just the last one
|
|
279
|
+
node_name = node.name if not isinstance(node, TriccNodeEnd) else node.get_reference()
|
|
280
|
+
all_prev_versions = get_versions(node_name, processed_nodes)
|
|
281
|
+
# Exclude the current node itself
|
|
282
|
+
all_prev_versions = [v for v in all_prev_versions if v != node]
|
|
283
|
+
|
|
242
284
|
if last_version:
|
|
243
|
-
|
|
285
|
+
get_version_inheritance(node, all_prev_versions, processed_nodes)
|
|
244
286
|
|
|
245
287
|
generate_calculates(node, calculates, used_calculates, processed_nodes=processed_nodes, process=process)
|
|
246
288
|
|
|
@@ -2194,9 +2236,9 @@ def get_prev_node_expression(node, processed_nodes, get_overall_exp=False, exclu
|
|
|
2194
2236
|
|
|
2195
2237
|
for act_id in prev_activities:
|
|
2196
2238
|
act_expression_inputs = []
|
|
2197
|
-
|
|
2239
|
+
none_sequence_defined_prev_node = False
|
|
2198
2240
|
for prev_node in prev_activities[act_id]:
|
|
2199
|
-
|
|
2241
|
+
none_sequence_defined_prev_node = none_sequence_defined_prev_node or not prev_node.is_sequence_defined
|
|
2200
2242
|
if (
|
|
2201
2243
|
excluded_name is None
|
|
2202
2244
|
or prev_node != excluded_name
|
|
@@ -2232,8 +2274,8 @@ def get_prev_node_expression(node, processed_nodes, get_overall_exp=False, exclu
|
|
|
2232
2274
|
negate=False,
|
|
2233
2275
|
process=process,
|
|
2234
2276
|
)
|
|
2235
|
-
elif
|
|
2236
|
-
# For
|
|
2277
|
+
elif none_sequence_defined_prev_node:
|
|
2278
|
+
# For nodes with is_sequence_defined = False, AND the activity relevance with the prev expression
|
|
2237
2279
|
activity_relevance = get_node_expression(
|
|
2238
2280
|
prev_node.activity,
|
|
2239
2281
|
processed_nodes=processed_nodes,
|
|
@@ -2554,15 +2596,6 @@ def get_calculation_terms(node, processed_nodes, get_overall_exp=False, negate=F
|
|
|
2554
2596
|
|
|
2555
2597
|
if isinstance(node.expression_reference, (TriccOperation, TriccStatic)):
|
|
2556
2598
|
expression = node.expression_reference
|
|
2557
|
-
elif node.reference is not None and node.expression_reference is not None:
|
|
2558
|
-
expression = get_prev_node_expression(
|
|
2559
|
-
node, processed_nodes=processed_nodes, get_overall_exp=get_overall_exp, process=process
|
|
2560
|
-
)
|
|
2561
|
-
ref_expression = node.expression_reference.format(*[get_export_name(ref) for ref in node.reference])
|
|
2562
|
-
if expression is not None and expression != "":
|
|
2563
|
-
expression = and_join([expression, ref_expression])
|
|
2564
|
-
else:
|
|
2565
|
-
expression = ref_expression
|
|
2566
2599
|
elif expression is None:
|
|
2567
2600
|
expression = get_prev_node_expression(
|
|
2568
2601
|
node, processed_nodes=processed_nodes, get_overall_exp=get_overall_exp, process=process
|
|
@@ -2655,6 +2688,12 @@ def generate_calculate(node, processed_nodes, **kwargs):
|
|
|
2655
2688
|
if node not in processed_nodes:
|
|
2656
2689
|
if kwargs.get("warn", True):
|
|
2657
2690
|
logger.debug("generation of calculate for node {}".format(node.get_name()))
|
|
2691
|
+
|
|
2692
|
+
# Set is_sequence_defined for calculate nodes based on dependencies
|
|
2693
|
+
if issubclass(node.__class__, TriccNodeCalculateBase):
|
|
2694
|
+
# Calculate node is sequence defined if ALL prev_nodes have is_sequence_defined = True
|
|
2695
|
+
node.is_sequence_defined = all(prev_node.is_sequence_defined for prev_node in node.prev_nodes)
|
|
2696
|
+
|
|
2658
2697
|
if (
|
|
2659
2698
|
hasattr(node, "expression")
|
|
2660
2699
|
and (node.expression is None)
|
|
@@ -15,12 +15,12 @@ tricc_oo/converters/cql/cqlListener.py,sha256=fA7-8DcS2Q69ckwjdg57-OfFHBxjTZFdoS
|
|
|
15
15
|
tricc_oo/converters/cql/cqlParser.py,sha256=x3KdrwX9nwENSEJ5Ex7_l5NMnu3kWBO0uLdYu4moTq0,414745
|
|
16
16
|
tricc_oo/converters/cql/cqlVisitor.py,sha256=iHuup2S7OGSVWLEcI4H3oecRqgXztC1sKnew_1P2iGY,33880
|
|
17
17
|
tricc_oo/models/__init__.py,sha256=CgS52LLqdDIaXHvZy08hhu_VaYw80OEdfL_llM9ICBA,108
|
|
18
|
-
tricc_oo/models/base.py,sha256=
|
|
18
|
+
tricc_oo/models/base.py,sha256=f5EQtTSJH9aPanqCc0qD6579TgAirzYaZ5BtQ2Iu0xw,26136
|
|
19
19
|
tricc_oo/models/calculate.py,sha256=uNP0IDUqPQcJq9Co05H8eX5wbR_DikSxuOHxfVE5Dxg,8018
|
|
20
20
|
tricc_oo/models/lang.py,sha256=ZMRwdoPWe01wEDhOM0uRk-6rt3BkoAAZM8mZ61--s3A,2265
|
|
21
21
|
tricc_oo/models/ocl.py,sha256=MybSeB6fgCOUVJ4aektff0vrrTZsyfwZ2Gt_pPBu_FY,8728
|
|
22
22
|
tricc_oo/models/ordered_set.py,sha256=BpXLW8plRAy4te25PIUPvVXPnLPcypvKg3iNPhtPulA,3833
|
|
23
|
-
tricc_oo/models/tricc.py,sha256=
|
|
23
|
+
tricc_oo/models/tricc.py,sha256=H_HPFzFsS_-fFXCx3vdKsw29DFrlTnAscTJE_lQG_Lk,17549
|
|
24
24
|
tricc_oo/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
tricc_oo/parsers/xml.py,sha256=uzkb1y18MHfqVFmZqVh0sKT4cx6u0-NcAT_lV_gHBt8,4208
|
|
26
26
|
tricc_oo/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -41,11 +41,11 @@ tricc_oo/strategies/output/xlsform_cdss.py,sha256=X00Lt5MzV8TX14dR4dFI1MqllI5S1e
|
|
|
41
41
|
tricc_oo/strategies/output/xlsform_cht.py,sha256=lY1xIDxqYxl_lYNVCl3msXZL88No49yEVCpahcHGOn0,28675
|
|
42
42
|
tricc_oo/strategies/output/xlsform_cht_hf.py,sha256=xm6SKirV3nMZvM2w54_zJcXAeAgAkq-EEqGEjnOWv6c,988
|
|
43
43
|
tricc_oo/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
|
-
tricc_oo/visitors/tricc.py,sha256=
|
|
44
|
+
tricc_oo/visitors/tricc.py,sha256=uWfPs4yUqTlVBzQcNGLaf635pOz5ClzJ2yj9pieJANY,114090
|
|
45
45
|
tricc_oo/visitors/utils.py,sha256=j83aAq5s5atXi3OC0jc_uJd54a8XrHHmizeeEbWZQJg,421
|
|
46
46
|
tricc_oo/visitors/xform_pd.py,sha256=ryAnI3V9x3eTmJ2LNsUZfvl0_yfCqo6oBgeSu-WPqaE,9613
|
|
47
|
-
tricc_oo-1.6.
|
|
48
|
-
tricc_oo-1.6.
|
|
49
|
-
tricc_oo-1.6.
|
|
50
|
-
tricc_oo-1.6.
|
|
51
|
-
tricc_oo-1.6.
|
|
47
|
+
tricc_oo-1.6.23.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
|
|
48
|
+
tricc_oo-1.6.23.dist-info/METADATA,sha256=7_BWo-Qm5UcknB4D9LNIO2Gnit5zdxQWHEL4BUFxlLI,8600
|
|
49
|
+
tricc_oo-1.6.23.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
50
|
+
tricc_oo-1.6.23.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
|
|
51
|
+
tricc_oo-1.6.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|