tricc-oo 1.5.10__py3-none-any.whl → 1.5.12__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.
@@ -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
tricc_oo/models/base.py CHANGED
@@ -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
tricc_oo/models/tricc.py CHANGED
@@ -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
@@ -9,38 +9,38 @@ tricc_oo/converters/datadictionnary.py,sha256=WWKcTtKLfc4aduHcDBhr4JSfU2NqRMaslw
9
9
  tricc_oo/converters/drawio_type_map.py,sha256=VsiKJuAcM_kaSacxZgMaMEfEMVwVAbJjxrRj4TDMIxc,7254
10
10
  tricc_oo/converters/tricc_to_xls_form.py,sha256=bJVd-FLrivrCxGI6mO2i0V7GVVuJZdaDuwcEf3gHNR8,2327
11
11
  tricc_oo/converters/utils.py,sha256=UyndDORsDbRV5-gYW-yInK5ztjtYdeCw6K-mrYr1Emk,1688
12
- tricc_oo/converters/xml_to_tricc.py,sha256=pJpDLAsDX9dAhmviR6AtZRnPPlK6ajmPBoSp7TfAlhs,37117
12
+ tricc_oo/converters/xml_to_tricc.py,sha256=5kuG6j9zJNFr5PFBc0drLpnNznFntpu3idT7eO1UzY4,37166
13
13
  tricc_oo/converters/cql/cqlLexer.py,sha256=t0-QvDv5kxCiBZJ9SfDumFOgnRSry_HJpakBZV224Ig,49126
14
14
  tricc_oo/converters/cql/cqlListener.py,sha256=ketvj7XvO7t047S6A3_gTPvp2MlYk1bojmkl10v5E6Y,57523
15
15
  tricc_oo/converters/cql/cqlParser.py,sha256=hIUdR907WX24P2Jlrxk-H0IT94n51yh_ZsCmwQhnFas,414730
16
16
  tricc_oo/converters/cql/cqlVisitor.py,sha256=SWSDIqVYBhucR4VgLn_EPNs7LV9yCqsOmzFZ0bmRSGc,33865
17
17
  tricc_oo/models/__init__.py,sha256=Rdk1fsNXHrbmXTQD1O7i0NC_A6os648Ap6CtWRliOg8,92
18
- tricc_oo/models/base.py,sha256=mqeAnC1mfZkdEm49dFiYoGImC5CWHG2Rl7frG1pE8sk,24547
18
+ tricc_oo/models/base.py,sha256=qCR26kdCip3a9cJRl-dmq3qiHdpxNHtFW3jGe0bwRIo,24637
19
19
  tricc_oo/models/calculate.py,sha256=sHuUEFc88yUZMtYWIG09wNOiOsbemj8wEoulVPXwcys,7486
20
20
  tricc_oo/models/lang.py,sha256=SwKaoxyRhE7gH_ZlYyFXzGuTQ5RE19y47LWAA35zYxg,2338
21
21
  tricc_oo/models/ocl.py,sha256=ol35Gl1jCBp0Ven0yxOKzDIZkVL5Kx9uwaR_64pjxKI,8931
22
22
  tricc_oo/models/ordered_set.py,sha256=wbbmppjgKy0xcKD9kIAbT4kgNkuwTILPxRw_KAAoPEY,4178
23
- tricc_oo/models/tricc.py,sha256=sds17Ea4Hj-tibtI_DYKkqrN8QSCvo98L09SovcsL84,16669
23
+ tricc_oo/models/tricc.py,sha256=FMksoYJsoKbDs3JtM42ooUV7T9E9X0E3_1TU3oumspI,16631
24
24
  tricc_oo/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  tricc_oo/parsers/xml.py,sha256=vq9PA5Zt4G3QMtZ1zgyN8110O1w19Jqt6JClJYhHJlU,4410
26
26
  tricc_oo/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  tricc_oo/serializers/planuml.py,sha256=a81YKsjgng-h2H_rmFE2J5FeBBUaH8kRGT8YrvzpEKE,455
28
- tricc_oo/serializers/xls_form.py,sha256=p1nNFMBHretUc2z773DBUatSNjrCLL8FHi3BYP6Di1s,22784
28
+ tricc_oo/serializers/xls_form.py,sha256=KwPOMD594ru0BXW_ZxHyJTg-to8Yyl3jKUEtQP5afOE,22785
29
29
  tricc_oo/strategies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  tricc_oo/strategies/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  tricc_oo/strategies/input/base_input_strategy.py,sha256=-GQ_xRvJXzn-q_eT8R-wtFOTWzPtdNj79zjmsH6x070,4065
32
- tricc_oo/strategies/input/drawio.py,sha256=HQ2nT7tr3WpGMRjTJYEACBMgx6Ep-ORq5ifoVLzwtwY,13336
32
+ tricc_oo/strategies/input/drawio.py,sha256=qVX4-roFhnsgQSBA9gD9upz18FnBFs7-UeyHaZ_pNU4,13165
33
33
  tricc_oo/strategies/output/base_output_strategy.py,sha256=WiJwqm4g_x-rbksrjoE0ABhNMtM0_fAMoPH34RKZdc0,7173
34
34
  tricc_oo/strategies/output/spice.py,sha256=s_COahyYCoc4Xv5TGh_AW9evDOW6GOex0Xwa_JWeLsI,11280
35
- tricc_oo/strategies/output/xls_form.py,sha256=1jNkF8qZXonDh-aOKpVN7HEBrRufKn_7ECvpNnQC73g,31037
35
+ tricc_oo/strategies/output/xls_form.py,sha256=OGN_qYYv8oXZPNPyoxyYcSP253MLzigLIBFntpsExKo,31046
36
36
  tricc_oo/strategies/output/xlsform_cdss.py,sha256=8oLlgS1Hr6IVvI0O71kIk5oIKXbt2lPVc1SZIjzcSTc,9452
37
- tricc_oo/strategies/output/xlsform_cht.py,sha256=YCL7gQlq9CU1GQxPSy5C8fYfPTI1XDPx9G9sr2RZFWM,22359
37
+ tricc_oo/strategies/output/xlsform_cht.py,sha256=I7-J5Q8kqzYPm2EOeurIji-AlTejsWJzvJKvtMyJQ-4,23824
38
38
  tricc_oo/strategies/output/xlsform_cht_hf.py,sha256=0D_H68a2S7oLKJENEePaRGIocrRIF45BofHlLOtGsKo,2206
39
39
  tricc_oo/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- tricc_oo/visitors/tricc.py,sha256=LSRMeEzrDfUSxJ_TXKpmK0Yv04ay_eZzdTVorYrEJOo,99465
40
+ tricc_oo/visitors/tricc.py,sha256=b3zD6vZLQE7WgsONMINgTNZ4nHNp5WrP_-jN5jlezAc,100328
41
41
  tricc_oo/visitors/utils.py,sha256=Gol4JNozPEd30Q1l8IPIPhx5fqVyy9R81GofGVebgD8,484
42
42
  tricc_oo/visitors/xform_pd.py,sha256=jgjBLbfElVdi0NmClhw6NK6qNcIgWYm4KMXfVwiQwXM,9705
43
- tricc_oo-1.5.10.dist-info/METADATA,sha256=hJqShfaDh9YStARMPOS6TywQa44RE930nUqBuda2A1I,7878
44
- tricc_oo-1.5.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
- tricc_oo-1.5.10.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
46
- tricc_oo-1.5.10.dist-info/RECORD,,
43
+ tricc_oo-1.5.12.dist-info/METADATA,sha256=61NtmcXTkpaJMZbXWErFFd41g8oA4symkAclic--urc,7878
44
+ tricc_oo-1.5.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ tricc_oo-1.5.12.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
46
+ tricc_oo-1.5.12.dist-info/RECORD,,