tricc-oo 1.6.5.dev2__tar.gz → 1.6.6__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 (57) hide show
  1. {tricc_oo-1.6.5.dev2/tricc_oo.egg-info → tricc_oo-1.6.6}/PKG-INFO +1 -1
  2. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/pyproject.toml +1 -1
  3. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/tricc_to_xls_form.py +2 -0
  4. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/models/base.py +1 -1
  5. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/xls_form.py +9 -3
  6. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/visitors/tricc.py +52 -35
  7. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6/tricc_oo.egg-info}/PKG-INFO +1 -1
  8. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/LICENSE +0 -0
  9. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/README.md +0 -0
  10. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/setup.cfg +0 -0
  11. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tests/build.py +0 -0
  12. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tests/test_build.py +0 -0
  13. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tests/test_cql.py +0 -0
  14. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tests/to_ocl.py +0 -0
  15. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/__init__.py +0 -0
  16. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/__init__.py +0 -0
  17. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  18. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  19. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/cql/cqlListener.py +0 -0
  20. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/cql/cqlParser.py +0 -0
  21. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  22. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/cql_to_operation.py +0 -0
  23. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/datadictionnary.py +0 -0
  24. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/drawio_type_map.py +0 -0
  25. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/utils.py +0 -0
  26. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/converters/xml_to_tricc.py +0 -0
  27. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/models/__init__.py +0 -0
  28. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/models/calculate.py +0 -0
  29. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/models/lang.py +0 -0
  30. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/models/ocl.py +0 -0
  31. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/models/ordered_set.py +0 -0
  32. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/models/tricc.py +0 -0
  33. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/parsers/__init__.py +0 -0
  34. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/parsers/xml.py +0 -0
  35. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/serializers/__init__.py +0 -0
  36. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/serializers/planuml.py +0 -0
  37. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/serializers/xls_form.py +0 -0
  38. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/__init__.py +0 -0
  39. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/input/__init__.py +0 -0
  40. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  41. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/input/drawio.py +0 -0
  42. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
  43. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/dhis2_form.py +0 -0
  44. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/fhir_form.py +0 -0
  45. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/html_form.py +0 -0
  46. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/openmrs_form.py +0 -0
  47. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/spice.py +0 -0
  48. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  49. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/xlsform_cht.py +0 -0
  50. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  51. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/visitors/__init__.py +0 -0
  52. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/visitors/utils.py +0 -0
  53. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo/visitors/xform_pd.py +0 -0
  54. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo.egg-info/SOURCES.txt +0 -0
  55. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo.egg-info/dependency_links.txt +0 -0
  56. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/tricc_oo.egg-info/requires.txt +0 -0
  57. {tricc_oo-1.6.5.dev2 → tricc_oo-1.6.6}/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.6.5.dev2
3
+ Version: 1.6.6
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.6.5.dev002"
7
+ version = "1.6.6"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -43,6 +43,8 @@ def get_export_name(node, replace_dots=True):
43
43
  value = node.name
44
44
  elif isinstance(node, TriccStatic):
45
45
  value = node.value
46
+ if isinstance(value, TriccNodeSelectOption):
47
+ value = value.name
46
48
  else:
47
49
  value = node
48
50
  if isinstance(value, bool): # or r.value in ('true', 'false')
@@ -274,7 +274,7 @@ class TriccNodeBaseModel(TriccBaseModel):
274
274
 
275
275
 
276
276
  class TriccStatic(BaseModel):
277
- value: Union[str, float, int, bool]
277
+ value: Union[str, float, int, bool, TriccNodeBaseModel]
278
278
 
279
279
  def __init__(self, value):
280
280
  super().__init__(value=value)
@@ -495,7 +495,12 @@ class XLSFormStrategy(BaseOutPutStrategy):
495
495
  parts = []
496
496
  for s in ref_expressions[1:]:
497
497
  # for option with numeric value
498
- cleaned_s = s if isinstance(s, str) else "'" + str(s) + "'"
498
+ if isinstance(s, str):
499
+ cleaned_s = s
500
+ elif isinstance(s, TriccNodeSelectOption):
501
+ cleaned_s = s.name
502
+ else:
503
+ cleaned_s = "'" + str(s) + "'"
499
504
  parts.append(f"selected({self.clean_coalesce(ref_expressions[0])}, {cleaned_s})")
500
505
  if len(parts) == 1:
501
506
  return parts[0]
@@ -724,11 +729,12 @@ class XLSFormStrategy(BaseOutPutStrategy):
724
729
  # @param r reference to be translated
725
730
  if isinstance(r, TriccOperation):
726
731
  return self.get_tricc_operation_expression(r)
732
+ elif isinstance(r, (TriccStatic, str, int, float)):
733
+ return get_export_name(r)
727
734
  elif isinstance(r, TriccReference):
728
735
  logger.warning(f"reference `{r.value}` still used in a calculate")
729
736
  return f"${{{get_export_name(r.value)}}}"
730
- elif isinstance(r, (TriccStatic, str, int, float)):
731
- return get_export_name(r)
737
+
732
738
  elif isinstance(r, TriccNodeSelectOption):
733
739
  logger.debug(f"select option {r.get_name()} from {r.select.get_name()} was used as a reference")
734
740
  return get_export_name(r)
@@ -1737,6 +1737,7 @@ PARENT_GROUP_PRIORITY = 6000
1737
1737
  ACTIVE_ACTIVITY_PRIORITY = 5000
1738
1738
  NON_START_ACTIVITY_PRIORITY = 4000
1739
1739
  ACTIVE_ACTIVITY_LOWER_PRIORITY = 3000
1740
+ FLOW_CALCULATE_NODE_PRIORITY = 6500
1740
1741
  RHOMBUS_PRIORITY = 1000
1741
1742
  DEFAULT_PRIORITY = 2000
1742
1743
 
@@ -1763,6 +1764,9 @@ def reorder_node_list(node_list, group, processed_nodes):
1763
1764
  # Check for non main activities
1764
1765
  elif activity and isinstance(activity.root, TriccNodeActivityStart):
1765
1766
  priority += NON_START_ACTIVITY_PRIORITY
1767
+ # Check for display calculate and end nodes with prev_nodes
1768
+ elif (issubclass(node.__class__, TriccNodeDisplayCalculateBase) or isinstance(node, TriccNodeEnd)) and not isinstance(node, TriccNodeActivityEnd) and hasattr(node, 'prev_nodes') and len(node.prev_nodes) > 0:
1769
+ priority += FLOW_CALCULATE_NODE_PRIORITY
1766
1770
  # Check for active activities (lower priority)
1767
1771
  elif activity and activity in active_activities:
1768
1772
  priority += ACTIVE_ACTIVITY_LOWER_PRIORITY
@@ -2024,7 +2028,7 @@ def get_accept_diagnostic_node(code, display, severity, priority, activity):
2024
2028
  return node
2025
2029
 
2026
2030
 
2027
- def get_diagnostic_node(code, display, severity, priority, activity):
2031
+ def get_diagnostic_node(code, display, severity, priority, activity, option):
2028
2032
  node = TriccNodeCalculate(
2029
2033
  id=generate_id("final." + code),
2030
2034
  name="final." + code,
@@ -2035,7 +2039,7 @@ def get_diagnostic_node(code, display, severity, priority, activity):
2035
2039
  expression_reference=or_join(
2036
2040
  [
2037
2041
  TriccOperation(TriccOperator.ISTRUE, [TriccReference("pre_final." + code)]),
2038
- TriccOperation(TriccOperator.SELECTED, [TriccReference("tricc.manual.diag"), TriccStatic(code)]),
2042
+ TriccOperation(TriccOperator.SELECTED, [TriccReference("tricc.manual.diag"), TriccStatic(option)]),
2039
2043
  ]
2040
2044
  ),
2041
2045
  )
@@ -2094,9 +2098,18 @@ def create_determine_diagnosis_activity(diags):
2094
2098
  group=activity,
2095
2099
  required=TriccStatic(False),
2096
2100
  )
2101
+ options = []
2097
2102
  for proposed in diags:
2103
+ option = TriccNodeSelectOption(
2104
+ id=generate_id(proposed.name),
2105
+ name=proposed.name,
2106
+ label=proposed.label,
2107
+ list_name=f.list_name,
2108
+ relevance=proposed.activity.applicability,
2109
+ select=f,
2110
+ )
2098
2111
  d = get_accept_diagnostic_node(proposed.name, proposed.label, proposed.severity, proposed.priority, activity)
2099
- c = get_diagnostic_node(proposed.name, proposed.label, proposed.severity, proposed.priority, activity)
2112
+ c = get_diagnostic_node(proposed.name, proposed.label, proposed.severity, proposed.priority, activity, option)
2100
2113
  diags_conf.append(d)
2101
2114
  r = TriccNodeRhombus(
2102
2115
  path=start,
@@ -2121,17 +2134,7 @@ def create_determine_diagnosis_activity(diags):
2121
2134
  activity.nodes[wait2.id] = wait2
2122
2135
  # fallback
2123
2136
 
2124
- options = [
2125
- TriccNodeSelectOption(
2126
- id=generate_id(d.name),
2127
- name=d.name,
2128
- label=d.label,
2129
- list_name=f.list_name,
2130
- relevance=d.activity.applicability,
2131
- select=f,
2132
- )
2133
- for d in diags
2134
- ]
2137
+
2135
2138
  f.options = dict(zip(range(0, len(options)), options))
2136
2139
  activity.nodes[f.id] = f
2137
2140
  set_prev_next_node(f, end, edge_only=False)
@@ -2239,10 +2242,22 @@ def get_count_terms(node, processed_nodes, get_overall_exp, negate=False, proces
2239
2242
  return TriccOperation(TriccOperator.PLUS, [TriccOperation(TriccOperator.CAST_NUMBER, [term]) for term in terms])
2240
2243
 
2241
2244
 
2245
+ def get_none_option(node):
2246
+ if hasattr(node, "options"):
2247
+ for opt in node.options.values():
2248
+ if opt.name == "opt_none":
2249
+ return opt
2250
+ return None
2251
+
2252
+
2242
2253
  def get_count_terms_details(prev_node, processed_nodes, get_overall_exp, negate=False, process=None):
2243
- operation_none = TriccOperation(TriccOperator.SELECTED, [prev_node, TriccStatic("opt_none")])
2254
+ opt_none = get_none_option(prev_node)
2255
+ if opt_none:
2256
+ operation_none = TriccOperation(TriccOperator.SELECTED, [prev_node, TriccStatic(opt_none)])
2257
+ else:
2258
+ operation_none = TriccOperation(TriccOperator.SELECTED, [prev_node, TriccStatic("opt_none")])
2244
2259
  if isinstance(prev_node, TriccNodeSelectYesNo):
2245
- return TriccOperation(TriccOperator.SELECTED, [prev_node, TriccStatic(prev_node.options[0].name)])
2260
+ return TriccOperation(TriccOperator.SELECTED, [prev_node, TriccStatic(prev_node.options[0])])
2246
2261
  elif issubclass(prev_node.__class__, TriccNodeSelect):
2247
2262
  if negate:
2248
2263
  return
@@ -2554,7 +2569,7 @@ def get_selected_option_expression_single(option_node, negate):
2554
2569
 
2555
2570
  def get_selected_option_expression_multiple(option_node, negate):
2556
2571
 
2557
- selected = TriccOperation(TriccOperator.SELECTED, [option_node.select, option_node])
2572
+ selected = TriccOperation(TriccOperator.SELECTED, [option_node.select, TriccStatic(option_node)])
2558
2573
 
2559
2574
  if negate:
2560
2575
  return TriccOperation(
@@ -2624,24 +2639,26 @@ def generate_base(node, processed_nodes, **kwargs):
2624
2639
  # we don't overright if define in the diagram
2625
2640
  if node.constraint is None:
2626
2641
  if isinstance(node, TriccNodeSelectMultiple):
2627
- node.constraint = or_join(
2628
- [
2629
- TriccOperation(
2630
- TriccOperator.EQUAL,
2631
- ["$this", TriccStatic("opt_none")],
2632
- ),
2633
- TriccOperation(
2634
- TriccOperator.NOT,
2635
- [
2636
- TriccOperation(
2637
- TriccOperator.SELECTED,
2638
- ["$this", TriccStatic("opt_none")],
2639
- )
2640
- ],
2641
- ),
2642
- ]
2643
- ) # '.=\'opt_none\' or not(selected(.,\'opt_none\'))'
2644
- node.constraint_message = "**None** cannot be selected together with choice."
2642
+ none_opt = get_none_option(node)
2643
+ if none_opt:
2644
+ node.constraint = or_join(
2645
+ [
2646
+ TriccOperation(
2647
+ TriccOperator.EQUAL,
2648
+ ["$this", TriccStatic(none_opt)],
2649
+ ),
2650
+ TriccOperation(
2651
+ TriccOperator.NOT,
2652
+ [
2653
+ TriccOperation(
2654
+ TriccOperator.SELECTED,
2655
+ ["$this", TriccStatic(none_opt)],
2656
+ )
2657
+ ],
2658
+ ),
2659
+ ]
2660
+ ) # '.=\'opt_none\' or not(selected(.,\'opt_none\'))'
2661
+ node.constraint_message = "**None** cannot be selected together with choice."
2645
2662
  elif node.tricc_type in (
2646
2663
  TriccNodeType.integer,
2647
2664
  TriccNodeType.decimal,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.6.5.dev2
3
+ Version: 1.6.6
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