tricc-oo 1.6.4__py3-none-any.whl → 1.6.5.dev1__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.
@@ -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(strategy.get_tricc_operation_expression(calc.expression))
111
127
  elif column == "relevance":
112
128
  calc_values.append("")
113
129
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.6.4
3
+ Version: 1.6.5.dev1
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
@@ -8,7 +8,7 @@ tricc_oo/converters/codesystem_to_ocl.py,sha256=Fh7Vk73OsxljZKu1k6H9uzYwz334tpQT
8
8
  tricc_oo/converters/cql_to_operation.py,sha256=PUyV_YpUY98Ox0H_F_CN3UUf_I-BhFZVOcWWKTtwecM,14492
9
9
  tricc_oo/converters/datadictionnary.py,sha256=T2HLCBo4Am1p0kFqSH1r0PqbD8AC2IGuWkbvMvSCru0,3658
10
10
  tricc_oo/converters/drawio_type_map.py,sha256=UCPiGs7Lw0bigKScmZUnmOhACBz-FiDq92jHkI7RTSQ,9113
11
- tricc_oo/converters/tricc_to_xls_form.py,sha256=HZh0tQoKfRMPshJvEBwCOGqYGA1ZJLJ67bwV79qtlwk,3486
11
+ tricc_oo/converters/tricc_to_xls_form.py,sha256=REyJQPay3ltILCxLIPQU3-gCl5qfiTOlS9-bRPDUP_o,3772
12
12
  tricc_oo/converters/utils.py,sha256=JZrtrvvOfXwdkw49pKauzinOcauWwsy-CVcw36TjyLo,1684
13
13
  tricc_oo/converters/xml_to_tricc.py,sha256=T7oFEr56yNZ0empqlev6AaVrairl3evFciji-SeNmyA,39588
14
14
  tricc_oo/converters/cql/cqlLexer.py,sha256=8HArbRphcrpnAG4uogJ2rHv4tc1WLzjN0B1uFeYILAc,49141
@@ -26,7 +26,7 @@ tricc_oo/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
26
26
  tricc_oo/parsers/xml.py,sha256=uzkb1y18MHfqVFmZqVh0sKT4cx6u0-NcAT_lV_gHBt8,4208
27
27
  tricc_oo/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  tricc_oo/serializers/planuml.py,sha256=t57587-6L3aDncpHh58lS77Zft8yxDE9DPtXx2BeUSU,132
29
- tricc_oo/serializers/xls_form.py,sha256=CTv2-UtpoCsgrLCdY1SEmpP6cZfnniKSEyTwuyct6Gg,21567
29
+ tricc_oo/serializers/xls_form.py,sha256=hv8P2Uq-0pzaxZ9fjMr7E0L_0a4oXFUOAuL6NpMrz-o,22208
30
30
  tricc_oo/strategies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  tricc_oo/strategies/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  tricc_oo/strategies/input/base_input_strategy.py,sha256=BEODXS74na1QRRcJVQ4cxiD8F7uRqaLyhE3QzKpGVvk,3891
@@ -45,8 +45,8 @@ tricc_oo/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
45
45
  tricc_oo/visitors/tricc.py,sha256=V4ai-rPjAbLSGdcKRBQiXohe6IqhZNCVyVjJLxYiavQ,107896
46
46
  tricc_oo/visitors/utils.py,sha256=j83aAq5s5atXi3OC0jc_uJd54a8XrHHmizeeEbWZQJg,421
47
47
  tricc_oo/visitors/xform_pd.py,sha256=ryAnI3V9x3eTmJ2LNsUZfvl0_yfCqo6oBgeSu-WPqaE,9613
48
- tricc_oo-1.6.4.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
49
- tricc_oo-1.6.4.dist-info/METADATA,sha256=UeHJ7oRz6JMRUiXb2Dtp8s3bzfCLxIDeld4SMKwfqKo,8599
50
- tricc_oo-1.6.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
51
- tricc_oo-1.6.4.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
52
- tricc_oo-1.6.4.dist-info/RECORD,,
48
+ tricc_oo-1.6.5.dev1.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
49
+ tricc_oo-1.6.5.dev1.dist-info/METADATA,sha256=3gCCtuliIQAt7wPxtiRnsHuPIoUmtWXba9Ntg7-SniU,8604
50
+ tricc_oo-1.6.5.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
51
+ tricc_oo-1.6.5.dev1.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
52
+ tricc_oo-1.6.5.dev1.dist-info/RECORD,,