tricc-oo 1.5.10__tar.gz → 1.5.12__tar.gz

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.
Files changed (51) hide show
  1. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/PKG-INFO +1 -1
  2. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/pyproject.toml +1 -1
  3. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/xml_to_tricc.py +5 -4
  4. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/models/base.py +2 -0
  5. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/models/tricc.py +1 -1
  6. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/serializers/xls_form.py +1 -1
  7. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/input/drawio.py +1 -5
  8. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/output/xls_form.py +1 -1
  9. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/output/xlsform_cht.py +49 -1
  10. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/visitors/tricc.py +24 -9
  11. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo.egg-info/PKG-INFO +1 -1
  12. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/README.md +0 -0
  13. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/setup.cfg +0 -0
  14. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tests/build.py +0 -0
  15. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tests/test_cql.py +0 -0
  16. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tests/to_ocl.py +0 -0
  17. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/__init__.py +0 -0
  18. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/__init__.py +0 -0
  19. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  20. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  21. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/cql/cqlListener.py +0 -0
  22. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/cql/cqlParser.py +0 -0
  23. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  24. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/cql_to_operation.py +0 -0
  25. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/datadictionnary.py +0 -0
  26. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/drawio_type_map.py +0 -0
  27. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
  28. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/converters/utils.py +0 -0
  29. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/models/__init__.py +0 -0
  30. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/models/calculate.py +0 -0
  31. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/models/lang.py +0 -0
  32. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/models/ocl.py +0 -0
  33. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/models/ordered_set.py +0 -0
  34. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/parsers/__init__.py +0 -0
  35. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/parsers/xml.py +0 -0
  36. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/serializers/__init__.py +0 -0
  37. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/serializers/planuml.py +0 -0
  38. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/__init__.py +0 -0
  39. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/input/__init__.py +0 -0
  40. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  41. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
  42. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/output/spice.py +0 -0
  43. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  44. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  45. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/visitors/__init__.py +0 -0
  46. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/visitors/utils.py +0 -0
  47. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo/visitors/xform_pd.py +0 -0
  48. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo.egg-info/SOURCES.txt +0 -0
  49. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo.egg-info/dependency_links.txt +0 -0
  50. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo.egg-info/requires.txt +0 -0
  51. {tricc_oo-1.5.10 → tricc_oo-1.5.12}/tricc_oo.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.5.10
3
+ Version: 1.5.12
4
4
  Summary: Python library that converts CDSS L2 in L3
5
5
  Project-URL: Homepage, https://github.com/SwissTPH/tricc
6
6
  Project-URL: Issues, https://github.com/SwissTPH/tricc/issues
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tricc-oo"
7
- version = "1.5.10"
7
+ version = "1.5.12"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -905,12 +905,13 @@ def get_edges(diagram):
905
905
  def process_factor_edge(edge, nodes):
906
906
  factor = edge.value.strip()
907
907
  if factor != 1:
908
+ source = nodes[edge.source]
908
909
  return TriccNodeCalculate(
909
910
  id=edge.id,
910
- expression_reference=TriccOperation(TriccOperator.MULTIPLIED, [nodes[edge.source],TriccStatic(factor)]),
911
- reference=[nodes[edge.source]],
912
- activity=nodes[edge.source].activity,
913
- group=nodes[edge.source].group,
911
+ expression_reference=TriccOperation(TriccOperator.MULTIPLIED, [TriccReference(nodes[edge.source].name),TriccStatic(float(factor))]),
912
+ reference=[TriccReference(source.name)],
913
+ activity=source.activity,
914
+ group=source.group,
914
915
  label="factor {}".format(factor),
915
916
  )
916
917
  return None
@@ -142,6 +142,8 @@ class TriccBaseModel(BaseModel):
142
142
  instance.id = generate_id(f"{self.id}{nb_instance}")
143
143
  instance.instance = int(nb_instance)
144
144
  instance.base_instance = self
145
+ if hasattr(self, 'instances'):
146
+ self.instances[nb_instance] = instance
145
147
 
146
148
 
147
149
  # assign the defualt group
@@ -98,7 +98,6 @@ class TriccNodeActivity(TriccNodeBaseModel):
98
98
  else:
99
99
  instance = super().make_instance(instance_nb, activity=None)
100
100
  base_instance = (self.base_instance or self)
101
- base_instance.instances[instance_nb] = instance
102
101
  instance.base_instance = base_instance
103
102
  # instance.base_instance = self
104
103
  # we duplicate all the related nodes (not the calculate, duplication is manage in calculate version code)
@@ -283,6 +282,7 @@ class TriccNodeGoTo(TriccNodeBaseModel):
283
282
  tricc_type: TriccNodeType = TriccNodeType.goto
284
283
  link: Union[TriccNodeActivity, triccId]
285
284
  datatype: str = 'n/a'
285
+ instance: int = 1
286
286
 
287
287
  # no need ot copy
288
288
  def make_instance(self, instance_nb, activity, **kwargs):
@@ -275,7 +275,7 @@ def get_xfrom_trad(strategy, node, column, mapping, clean_html=False):
275
275
  elif column == "appearance":
276
276
  if (
277
277
  isinstance(node, TriccNodeSelect)
278
- and len(node.options) > 9
278
+ and len(node.options) > 13
279
279
  and not any(o.image or o.hint for o in node.options.values())
280
280
  ):
281
281
  value = "autocomplete"
@@ -226,11 +226,7 @@ class DrawioStrategy(BaseInputStrategy):
226
226
  # walk thought the next page
227
227
  max_instance = 1
228
228
  if node.instance == 0 or next_page.root.instance == 0:
229
- for other_page in next_page.instances.values():
230
- if int(other_page.instance) > int(max_instance):
231
- max_instance = other_page.instance
232
- # auto instance starts at 101
233
- next_page = next_page.make_instance()
229
+ next_page = next_page.make_instance((1000+node.activity.instance) if node.activity.instance>1 else None)
234
230
  else:
235
231
  # return existing instance if any
236
232
  next_page = next_page.make_instance(node.instance)
@@ -390,7 +390,7 @@ class XLSFormStrategy(BaseOutPutStrategy):
390
390
  return f"{ref_expressions[0]} mod {ref_expressions[1]}"
391
391
  def tricc_operation_minus(self, ref_expressions):
392
392
  if len(ref_expressions)>1:
393
- return ' - '.join(ref_expressions)
393
+ return ' - '.join(map(str,ref_expressions))
394
394
  elif len(ref_expressions)==1:
395
395
  return f'-{ref_expressions[0]}'
396
396
  def tricc_operation_plus(self, ref_expressions):
@@ -223,10 +223,10 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
223
223
  "",
224
224
  "",
225
225
  ]
226
- self.get_contact_inputs(df_input)
227
226
  inputs = self.export_inputs(start_pages[self.processes[0]], **kwargs)
228
227
  for input in inputs:
229
228
  df_input.loc[len(df_input)] = get_input_line(input)
229
+ self.get_contact_inputs(df_input)
230
230
  df_input.loc[len(df_input)] = [
231
231
  "hidden",
232
232
  "external_id",
@@ -310,6 +310,7 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
310
310
  "",
311
311
  "",
312
312
  ]
313
+ self.get_contact_inputs_calculate(df_input)
313
314
  df_input.loc[len(df_input)] = [
314
315
  "calculate",
315
316
  "created_by_person_uuid",
@@ -459,7 +460,54 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
459
460
 
460
461
  def get_contact_inputs(self, df_input):
461
462
  empty = langs.get_trads("", force_dict=True)
463
+ if not len(df_input[df_input['name'] == 'sex']):
464
+ df_input.loc[len(df_input)] = [
465
+ "hidden",
466
+ "sex",
467
+ *list(langs.get_trads("Sex", force_dict=True).values()),
468
+ *list(empty.values()),
469
+ *list(empty.values()),
470
+ "",
471
+ "hidden",
472
+ "",
473
+ *list(empty.values()),
474
+ "",
475
+ "",
476
+ "",
477
+ *list(empty.values()),
478
+ "",
479
+ "",
480
+ "",
481
+ "",
482
+ "",
483
+ ]
484
+ if not len(df_input[df_input['name'] == 'date_of_birth']):
485
+ df_input.loc[len(df_input)] = [
486
+ "hidden",
487
+ "date_of_birth",
488
+ *list(langs.get_trads("Date of birth", force_dict=True).values()),
489
+ *list(empty.values()),
490
+ *list(empty.values()),
491
+ "",
492
+ "hidden",
493
+ "",
494
+ *list(empty.values()),
495
+ "",
496
+ "",
497
+ "",
498
+ *list(empty.values()),
499
+ "",
500
+ "",
501
+ "",
502
+ "",
503
+ "",
504
+ ]
462
505
 
506
+ return df_input
507
+
508
+
509
+ def get_contact_inputs_calculate(self, df_input):
510
+ empty = langs.get_trads("", force_dict=True)
463
511
  df_input.loc[len(df_input)] = [
464
512
  "calculate",
465
513
  "patient_sex",
@@ -94,6 +94,8 @@ def get_node_expressions(node, processed_nodes, process=None):
94
94
  return expression
95
95
 
96
96
  def set_last_version_false(node, processed_nodes):
97
+ if isinstance(node, (TriccNodeDiagnosis, TriccNodeSelectOption)):
98
+ return
97
99
  node_name = node.name if not isinstance(node, TriccNodeEnd) else node.get_reference()
98
100
  #last_version = get_last_version(node_name, processed_nodes) if issubclass(node.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase, TriccNodeEnd)) and not isinstance(node, TriccNodeSelectOption) else None
99
101
  last_version = processed_nodes.find_prev(node, version_filter(node_name))
@@ -191,9 +193,12 @@ def process_calculate(node,processed_nodes, stashed_nodes, calculates, used_calc
191
193
  ):
192
194
  if kwargs.get('warn', True):
193
195
  logger.debug('Processing relevance for node {0}'.format(node.get_name()))
196
+ # tricc diagnostic have the same name as proposed diag but will be serialised with different names
197
+
194
198
  last_version = set_last_version_false(node, processed_nodes)
195
199
  if last_version:
196
200
  last_version = get_version_inheritance(node, last_version, processed_nodes)
201
+
197
202
  generate_calculates(node,calculates, used_calculates,processed_nodes=processed_nodes, process=process)
198
203
 
199
204
 
@@ -489,6 +494,7 @@ def generate_calculates(node,calculates, used_calculates,processed_nodes, proces
489
494
  #add_save_calculate(calc_node, calculates, used_calculates,processed_nodes)
490
495
  for calc in list_calc:
491
496
  node.activity.nodes[calc.id] = calc
497
+ add_calculate(calculates, calc)
492
498
  return list_calc
493
499
 
494
500
 
@@ -674,6 +680,8 @@ def process_operation_reference(operation, node, processed_nodes, calculates, us
674
680
  node_reference.append(last_found)
675
681
  reference.append(TriccReference(ref))
676
682
  if replace_reference:
683
+ if not issubclass(last_found.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase, TriccNodeInput)):
684
+ last_found = get_node_expression(last_found, processed_nodes, is_prev=True)
677
685
  if isinstance(operation, (TriccOperation)):
678
686
  if modified_operation is None:
679
687
  modified_operation = operation.copy(keep_node=True)
@@ -689,9 +697,13 @@ def process_operation_reference(operation, node, processed_nodes, calculates, us
689
697
  if warn:
690
698
  logger.warning(f"Could not resolve label '{option_label}' for reference {ref}")
691
699
  return False
692
-
693
-
694
- node.path_len = max(node.path_len, last_found.path_len)
700
+ if hasattr(last_found, 'path_len'):
701
+ path_len = last_found.path_len
702
+ elif isinstance(last_found, TriccOperation):
703
+ path_len = max(getattr(n, 'path_len', 0) for n in last_found.get_references())
704
+ else:
705
+ path_len = 0
706
+ node.path_len = max(node.path_len, path_len)
695
707
  for ref in real_ref_list:
696
708
  if is_prev_processed(ref, node, processed_nodes=processed_nodes, local=False) is False:
697
709
  return False
@@ -1270,7 +1282,7 @@ def set_prev_next_node(source_node, target_node, replaced_node=None, edge_only =
1270
1282
  set_next_node(source_node, target_node, replaced_node, edge_only)
1271
1283
 
1272
1284
  if activity and not any([(e.source == source_id) and ( e.target == target_id) for e in activity.edges]):
1273
- label = "continue" if issubclass(source_node.__class__, TriccNodeSelectYesNo) else None
1285
+ label = "continue" if issubclass(source_node.__class__, TriccNodeSelect) else None
1274
1286
  activity.edges.append(TriccEdge(id = generate_id(), source = source_id, target = target_id, value = label))
1275
1287
 
1276
1288
  def remove_prev_next(prev_node, next_node, activity=None):
@@ -1431,11 +1443,11 @@ def reorder_node_list(node_list, group, processed_nodes):
1431
1443
  # Check for parent group
1432
1444
  elif hasattr(group, "group") and group.group and node_group and node_group.id == group.group.id:
1433
1445
  priority += PARENT_GROUP_PRIORITY
1434
- # Check for active activities (not start nodes)
1435
- elif activity and not isinstance(activity.root, TriccNodeActivityStart) and activity in active_activities:
1446
+ # Check for active activities (not main)
1447
+ elif activity and isinstance(activity.root, TriccNodeActivityStart) and activity in active_activities:
1436
1448
  priority += ACTIVE_ACTIVITY_PRIORITY
1437
- # Check for non-start activities
1438
- elif activity and not isinstance(activity.root, TriccNodeActivityStart):
1449
+ # Check for non main activities
1450
+ elif activity and isinstance(activity.root, TriccNodeActivityStart):
1439
1451
  priority += NON_START_ACTIVITY_PRIORITY
1440
1452
  # Check for active activities (lower priority)
1441
1453
  elif activity and activity in active_activities:
@@ -1799,12 +1811,15 @@ def create_determine_diagnosis_activity(diags):
1799
1811
  activity.calculates.append(r)
1800
1812
  activity.calculates.append(c)
1801
1813
  set_prev_next_node(r, d, edge_only=False)
1802
- set_prev_next_node(d, f, edge_only=False)
1814
+ set_prev_next_node(d, end, edge_only=False)
1815
+ wait2 = get_activity_wait([activity.root], diags_conf, [f], edge_only=False)
1803
1816
  activity.nodes[d.options[0].id] = d.options[0]
1804
1817
  activity.nodes[d.options[1].id] = d.options[1]
1805
1818
  activity.nodes[d.id]=d
1806
1819
  activity.nodes[r.id]=r
1807
1820
  activity.nodes[c.id]=c
1821
+ activity.nodes[f.id]=f
1822
+ activity.nodes[wait2.id]=wait2
1808
1823
  # fallback
1809
1824
 
1810
1825
  options = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.5.10
3
+ Version: 1.5.12
4
4
  Summary: Python library that converts CDSS L2 in L3
5
5
  Project-URL: Homepage, https://github.com/SwissTPH/tricc
6
6
  Project-URL: Issues, https://github.com/SwissTPH/tricc/issues
File without changes
File without changes
File without changes
File without changes
File without changes