tricc-oo 1.6.5__tar.gz → 1.6.5.dev2__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/tricc_oo.egg-info → tricc_oo-1.6.5.dev2}/PKG-INFO +1 -1
  2. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/pyproject.toml +1 -1
  3. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/tricc_to_xls_form.py +8 -2
  4. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/serializers/xls_form.py +32 -16
  5. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/visitors/tricc.py +26 -0
  6. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2/tricc_oo.egg-info}/PKG-INFO +1 -1
  7. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/LICENSE +0 -0
  8. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/README.md +0 -0
  9. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/setup.cfg +0 -0
  10. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tests/build.py +0 -0
  11. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tests/test_build.py +0 -0
  12. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tests/test_cql.py +0 -0
  13. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tests/to_ocl.py +0 -0
  14. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/__init__.py +0 -0
  15. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/__init__.py +0 -0
  16. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  17. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  18. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/cql/cqlListener.py +0 -0
  19. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/cql/cqlParser.py +0 -0
  20. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  21. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/cql_to_operation.py +0 -0
  22. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/datadictionnary.py +0 -0
  23. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/drawio_type_map.py +0 -0
  24. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/utils.py +0 -0
  25. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/converters/xml_to_tricc.py +0 -0
  26. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/models/__init__.py +0 -0
  27. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/models/base.py +0 -0
  28. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/models/calculate.py +0 -0
  29. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/models/lang.py +0 -0
  30. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/models/ocl.py +0 -0
  31. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/models/ordered_set.py +0 -0
  32. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/models/tricc.py +0 -0
  33. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/parsers/__init__.py +0 -0
  34. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/parsers/xml.py +0 -0
  35. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/serializers/__init__.py +0 -0
  36. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/serializers/planuml.py +0 -0
  37. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/__init__.py +0 -0
  38. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/input/__init__.py +0 -0
  39. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  40. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/input/drawio.py +0 -0
  41. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
  42. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/dhis2_form.py +0 -0
  43. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/fhir_form.py +0 -0
  44. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/html_form.py +0 -0
  45. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/openmrs_form.py +0 -0
  46. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/spice.py +0 -0
  47. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/xls_form.py +0 -0
  48. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  49. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/xlsform_cht.py +0 -0
  50. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  51. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/visitors/__init__.py +0 -0
  52. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/visitors/utils.py +0 -0
  53. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo/visitors/xform_pd.py +0 -0
  54. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo.egg-info/SOURCES.txt +0 -0
  55. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo.egg-info/dependency_links.txt +0 -0
  56. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/tricc_oo.egg-info/requires.txt +0 -0
  57. {tricc_oo-1.6.5 → tricc_oo-1.6.5.dev2}/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
3
+ Version: 1.6.5.dev2
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"
7
+ version = "1.6.5.dev002"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  from tricc_oo.converters.utils import clean_name, clean_str
3
- from tricc_oo.models.tricc import TriccNodeSelectOption, TRICC_TRUE_VALUE, TRICC_FALSE_VALUE
3
+ from tricc_oo.models.tricc import TriccNodeSelectOption, TRICC_TRUE_VALUE, TRICC_FALSE_VALUE, TriccNodeActivity
4
4
  from tricc_oo.models.calculate import TriccNodeInput
5
5
  from tricc_oo.models.base import TriccNodeBaseModel, TriccStatic, TriccReference
6
6
 
@@ -64,8 +64,14 @@ def get_export_name(node, replace_dots=True):
64
64
  return node
65
65
  else:
66
66
  node.gen_name()
67
- if isinstance(node, TriccNodeSelectOption):
67
+ if isinstance(node, TriccNodeActivity) and getattr(node, 'instance', 1)>1:
68
+ node.export_name = clean_name(
69
+ node.name + INSTANCE_SEPARATOR + str(node.instance),
70
+ replace_dots=replace_dots,
71
+ )
72
+ elif isinstance(node, TriccNodeSelectOption):
68
73
  node.export_name = node.name
74
+
69
75
  elif node.last is False:
70
76
  node.export_name = clean_name(
71
77
  node.name + VERSION_SEPARATOR + str(node.version),
@@ -6,13 +6,14 @@ from tricc_oo.converters.tricc_to_xls_form import (
6
6
  get_export_name, BOOLEAN_MAP
7
7
  )
8
8
  from tricc_oo.models.lang import SingletonLangClass
9
- from tricc_oo.converters.utils import clean_name, remove_html
9
+ from tricc_oo.converters.utils import clean_name, remove_html, generate_id
10
10
  from tricc_oo.models.base import (
11
11
  TriccOperator,
12
12
  TriccOperation, TriccStatic, TriccReference, and_join, TriccNodeType
13
13
  )
14
14
  from tricc_oo.models.calculate import (
15
15
  TriccNodeDisplayCalculateBase,
16
+ TriccNodeCalculate
16
17
  )
17
18
  from tricc_oo.models.tricc import (
18
19
  TriccNodeActivity, TriccNodeBaseModel, TriccNodeSelectMultiple, TriccNodeSelectOption,
@@ -38,6 +39,7 @@ logger = logging.getLogger("default")
38
39
  langs = SingletonLangClass()
39
40
  TRICC_CALC_EXPRESSION = "${{{0}}}>0"
40
41
 
42
+ def get_export_group_name(in_node):return f"gcalc_{get_export_name(in_node)}"
41
43
 
42
44
  def start_group(
43
45
  strategy,
@@ -60,24 +62,38 @@ def start_group(
60
62
  groups[name] = 0
61
63
  is_activity = isinstance(cur_group, TriccNodeActivity)
62
64
  relevance = relevance and cur_group.relevance is not None and cur_group.relevance != ""
63
-
64
- group_calc_required = False and relevance and not is_activity and len(relevance) > 100
65
-
65
+ past_instances = len(getattr(cur_group.base_instance, "instances", []))
66
+ group_calc_required = relevance is not None and (len(str(relevance)) > 100 or past_instances>1)
67
+ calc = None
68
+ if group_calc_required and getattr(cur_group.relevance, 'operator', None) != TriccOperator.ISTRUE:
69
+
70
+ calc = TriccNodeCalculate(
71
+ id=generate_id(get_export_group_name(name)),
72
+ group=cur_group,
73
+ activity=cur_group.activity,
74
+ name=get_export_group_name(name),
75
+ expression=cur_group.relevance
76
+ )
77
+ if calc not in cur_group.calculates:
78
+ cur_group.calculates.append(calc)
79
+ processed_nodes.add(calc)
80
+
81
+ cur_group.relevance = TriccOperation(
82
+ TriccOperator.ISTRUE,
83
+ [calc]
84
+ )
85
+
66
86
  relevance_expression = cur_group.relevance
67
87
  relevance_expression = get_applicability_expression(cur_group, processed_nodes, process, relevance_expression)
68
88
  relevance_expression = get_prev_instance_skip_expression(cur_group, processed_nodes, process, relevance_expression)
69
89
  relevance_expression = get_process_skip_expression(cur_group, processed_nodes, process, relevance_expression)
70
90
 
91
+
71
92
  if not relevance:
72
- relevance_expression = ""
93
+ relevance_expression_str = ""
73
94
  elif isinstance(relevance_expression, (TriccOperation, TriccStatic)):
74
- relevance_expression = strategy.get_tricc_operation_expression(relevance_expression)
75
-
76
- # elif is_activity:
77
- # relevance_expression = TRICC_CALC_EXPRESSION.format(get_export_name(cur_group.root))
78
- elif group_calc_required:
79
- relevance_expression = TRICC_CALC_EXPRESSION.format("gcalc_" + name)
80
-
95
+ relevance_expression_str = strategy.get_tricc_operation_expression(relevance_expression)
96
+
81
97
  # group
82
98
  values = []
83
99
  for column in SURVEY_MAP:
@@ -91,23 +107,23 @@ def start_group(
91
107
  if relevance_expression is True:
92
108
  values.append("")
93
109
  else:
94
- values.append(relevance_expression)
110
+ values.append(relevance_expression_str)
95
111
 
96
112
  else:
97
113
  values.append(get_xfrom_trad(strategy, cur_group, column, SURVEY_MAP))
98
114
  df_survey.loc[len(df_survey)] = values
99
115
 
100
116
  # calc
101
- if group_calc_required and len(df_calculate[df_calculate["name"] == "gcalc_" + name]) == 0:
117
+ if calc and len(df_calculate[df_calculate["name"] == get_export_group_name(name)]) == 0:
102
118
  calc_values = []
103
119
  for column in SURVEY_MAP:
104
120
  if column == "type":
105
121
  calc_values.append("calculate")
106
122
  elif column == "name":
107
- value = "gcalc_" + name
123
+ value = get_export_name(calc)
108
124
  calc_values.append(value)
109
125
  elif column == "calculation":
110
- calc_values.append(get_attr_if_exists(strategy, cur_group, "relevance", SURVEY_MAP))
126
+ calc_values.append(f"number({strategy.get_tricc_operation_expression(calc.expression)}")
111
127
  elif column == "relevance":
112
128
  calc_values.append("")
113
129
  else:
@@ -542,6 +542,32 @@ def generate_calculates(node, calculates, used_calculates, processed_nodes, proc
542
542
  for calc in list_calc:
543
543
  node.activity.nodes[calc.id] = calc
544
544
  add_calculate(calculates, calc)
545
+
546
+ # Add CONTAINS calculations for each option in select multiple (except opt_none)
547
+ if isinstance(node, TriccNodeSelectMultiple):
548
+ for option in node.options.values():
549
+ if not option.name.startswith("opt_"):
550
+ calc_id = generate_id(f"contains_{node.id}_{option.name}")
551
+ expression = TriccOperation(TriccOperator.CONTAINS, [node, TriccStatic(option.name)])
552
+ calc_node = TriccNodeCalculate(
553
+ name=option.name,
554
+ id=calc_id,
555
+ group=node.group,
556
+ activity=node.activity,
557
+ label=f"contains: {node.get_name()} contains '{option.name}'",
558
+ path_len=node.path_len + 1,
559
+ last=True,
560
+ expression=expression,
561
+ )
562
+ node.activity.calculates.append(calc_node)
563
+ last_version = set_last_version_false(calc_node, processed_nodes)
564
+ if last_version:
565
+ calc_node.expression = merge_expression(calc_node.expression, last_version)
566
+ processed_nodes.add(calc_node)
567
+ list_calc.append(calc_node)
568
+ node.activity.nodes[calc_node.id] = calc_node
569
+ add_calculate(calculates, calc_node)
570
+
545
571
  return list_calc
546
572
 
547
573
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.6.5
3
+ Version: 1.6.5.dev2
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