tricc-oo 1.4.27__py3-none-any.whl → 1.4.28__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.
tricc_oo/models/base.py CHANGED
@@ -226,7 +226,7 @@ class TriccNodeBaseModel(TriccBaseModel):
226
226
  label: Optional[Union[str, Dict[str,str]]] = None
227
227
  next_nodes: OrderedSet[TriccNodeBaseModel] = OrderedSet()
228
228
  prev_nodes: OrderedSet[TriccNodeBaseModel] = OrderedSet()
229
- expression: Optional[Union[Expression, TriccOperation]] = None # will be generated based on the input
229
+ expression: Optional[Union[Expression, TriccOperation, TriccStatic]] = None # will be generated based on the input
230
230
  expression_inputs: List[Expression] = []
231
231
  activity: Optional[FwTriccNodeBaseModel] = None
232
232
  ref_def: Optional[Union[int,str]] = None# for medal creator
@@ -87,8 +87,8 @@ class XLSFormStrategy(BaseOutPutStrategy):
87
87
 
88
88
  def clean_coalesce(self, expression):
89
89
  if re.match(r"^coalesce\(\${[^}]+},''\)$", str(expression)):
90
- return expression[9:-4]
91
- return expression
90
+ return str(expression[9:-4])
91
+ return str(expression)
92
92
 
93
93
  def generate_base(self, node, **kwargs):
94
94
  return self.generate_xls_form_condition(node, **kwargs)
@@ -7,6 +7,7 @@ import pandas as pd
7
7
 
8
8
  from tricc_oo.models.lang import SingletonLangClass
9
9
  from tricc_oo.models.calculate import TriccNodeEnd
10
+ from tricc_oo.models.tricc import TriccNodeDisplayModel
10
11
  from tricc_oo.serializers.xls_form import SURVEY_MAP, get_input_line, get_input_calc_line
11
12
  from tricc_oo.strategies.output.xlsform_cdss import XLSFormCDSSStrategy
12
13
  from tricc_oo.converters.tricc_to_xls_form import get_export_name
@@ -366,6 +367,23 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
366
367
  #df_summary.loc[len(df_summary)] = [ 'end group', '' ,'', '', '', '', '', '', '', '', '', '', '', '', '','', '' ]
367
368
  return df_summary
368
369
 
370
+ def get_last_prev_index(self, df, e, depth=0):
371
+ latest = None
372
+ for p in e.prev_nodes:
373
+ if issubclass(p.__class__, (TriccNodeDisplayModel)):
374
+ if hasattr(p, 'select'):
375
+ p = latest.select
376
+ index = df.index[df['name'] == get_export_name(p)].tolist()
377
+
378
+ if not latest or ( index and index[-1] > latest) :
379
+ latest = index[-1]
380
+ if latest is None and depth > 5:
381
+ for p in e.prev_nodes:
382
+ index = get_last_prev_index(df, e, depth+1)
383
+ if not latest and index and index > latest :
384
+ latest = index
385
+ return latest
386
+
369
387
  def export(self, start_pages, version, **kwargs):
370
388
  form_id = None
371
389
  if start_pages[self.processes[0]].root.form_id is not None:
@@ -406,15 +424,13 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
406
424
  ends_prev = []
407
425
  for e in ends:
408
426
 
409
- latest = None
410
- for p in e.prev_nodes:
411
- if not latest or latest.path_len < p.path_len:
412
- latest = p
413
- if hasattr(latest, 'select'):
414
- latest = latest.select
415
- ends_prev.append(
416
- (int(self.df_survey[self.df_survey.name == latest.export_name].index.values[0]), e,)
417
- )
427
+ latest = self.get_last_prev_index(self.df_survey, e)
428
+ if latest:
429
+ ends_prev.append(
430
+ (int(latest), e,)
431
+ )
432
+ else:
433
+ logger.critical(f"impossible to get last index before pause: {e.get_name()}")
418
434
  forms = [form_id]
419
435
  for i, e in ends_prev:
420
436
  new_form_id = f"{form_id}_{clean_name(e.name)}"
@@ -74,13 +74,13 @@ def get_node_expressions(node, processed_nodes, process=None):
74
74
  expression = get_node_expression(node, processed_nodes=processed_nodes, is_calculate=is_calculate, process=process)
75
75
 
76
76
  if is_calculate:
77
- if expression and (not isinstance(expression, str) or expression != '') and expression is not True :
77
+ if expression and (not isinstance(expression, str) or expression != '') and expression is not TriccStatic(True) :
78
78
  num_expression = TriccOperation(
79
79
  TriccOperator.CAST_NUMBER,
80
80
  [expression]
81
81
  )
82
- elif expression is True or (not expression and is_calculate):
83
- expression = TriccStatic(1)
82
+ elif expression is TriccStatic(True) or (not expression and is_calculate):
83
+ expression = TriccStatic(True)
84
84
  else:
85
85
  expression = ''
86
86
  if (
@@ -96,7 +96,7 @@ def get_node_expressions(node, processed_nodes, process=None):
96
96
  def set_last_version_false(node, processed_nodes):
97
97
  node_name = node.name if not isinstance(node, TriccNodeEnd) else node.get_reference()
98
98
  #last_version = get_last_version(node_name, processed_nodes) if issubclass(node.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase, TriccNodeEnd)) and not isinstance(node, TriccNodeSelectOption) else None
99
- last_version = processed_nodes.find_prev(node, lambda item: item.id != node.id and hasattr(item, 'name') and item.name == node_name and issubclass(item.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase, TriccNodeEnd)) and not isinstance(item, TriccNodeSelectOption))
99
+ last_version = processed_nodes.find_prev(node, version_filter(node_name))
100
100
  if last_version and getattr(node, 'process', '') != 'pause':
101
101
  # 0-100 for manually specified instance. 100-200 for auto instance
102
102
  node.version = get_next_version(node.name, processed_nodes, last_version.version + 1, 0)
@@ -41,7 +41,8 @@ def make_breakpoints(df, pausepoint, calculate_name=None, replace_dots=False):
41
41
  raise ValueError("input end field not found in input dataframe")
42
42
  end_inputs_loc = df.index[df['name'] == 'input end'][0]
43
43
  next_begin_group_loc = min([i for i in df.index[df['type'] == 'begin group'] if i > end_inputs_loc])
44
-
44
+ next_pause_point_begin_group_loc = min([i for i in df.index[df['type'] == 'begin group'] if i > pausepoint])
45
+
45
46
  df_input = df.loc[next_begin_group_loc:pausepoint]
46
47
 
47
48
  # Define field types to handle
@@ -125,9 +126,8 @@ def make_breakpoints(df, pausepoint, calculate_name=None, replace_dots=False):
125
126
  ]).reset_index(drop=True)
126
127
 
127
128
  # Handle post-break section
128
- df_after = df.loc[pausepoint+1:].reset_index(drop=True)
129
- if df_after.iloc[0,0] == 'end group':
130
- df_after = df_after.iloc[1:]
129
+ df_after = df.loc[next_pause_point_begin_group_loc:].reset_index(drop=True)
130
+
131
131
 
132
132
  # Final concatenation
133
133
  final_df = pd.concat([df_combined, df_after])
@@ -216,7 +216,7 @@ function {task_name}ResolveIf(contact, report, event, dueDate) {{
216
216
  }}
217
217
 
218
218
  function {task_name}AppliesIf(contact, report, event, dueDate) {{
219
- return report.{calculate_name};
219
+ return report.{calculate_name} === '1';
220
220
  }}
221
221
 
222
222
  module.exports = {{
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.4.27
3
+ Version: 1.4.28
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
@@ -15,7 +15,7 @@ tricc_oo/converters/cql/cqlListener.py,sha256=ketvj7XvO7t047S6A3_gTPvp2MlYk1bojm
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=6YU4FrUT4gE6WlERR1OPvQpq3bBKzG38I68_SZmaAao,24386
18
+ tricc_oo/models/base.py,sha256=_jJMYKvP60gaQSvzmA3TORrcRgv0oF5xG0FEBsE_Nhk,24399
19
19
  tricc_oo/models/calculate.py,sha256=Bw7OGa4OYxHP529wA23CZftMYDL_CA0SPQ0j1IFyTNA,7456
20
20
  tricc_oo/models/lang.py,sha256=SwKaoxyRhE7gH_ZlYyFXzGuTQ5RE19y47LWAA35zYxg,2338
21
21
  tricc_oo/models/ocl.py,sha256=ol35Gl1jCBp0Ven0yxOKzDIZkVL5Kx9uwaR_64pjxKI,8931
@@ -32,15 +32,15 @@ tricc_oo/strategies/input/base_input_strategy.py,sha256=-GQ_xRvJXzn-q_eT8R-wtFOT
32
32
  tricc_oo/strategies/input/drawio.py,sha256=glLts9whixJM4HOV_GAWAK8az_H-eo9aeFAQbn99-4c,13362
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=nUK_eAzlHDLliq2lIkFhOkn1zVTPGTUElfuN9FB9Yrc,31005
35
+ tricc_oo/strategies/output/xls_form.py,sha256=0x0NEvKXY_6W3X4D8vU56i1hlO1CxS9bVxzNbf8cpCk,31015
36
36
  tricc_oo/strategies/output/xlsform_cdss.py,sha256=8oLlgS1Hr6IVvI0O71kIk5oIKXbt2lPVc1SZIjzcSTc,9452
37
- tricc_oo/strategies/output/xlsform_cht.py,sha256=SWu1GKI5PScSX420RiVVaCNCTINeTeLpCoX-zXQIhUE,19486
37
+ tricc_oo/strategies/output/xlsform_cht.py,sha256=QcWcmXqIoaQWqLU2cILqnU7ybKYBs2Xd6cUL0gSr3gw,20148
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=uhOrvms76JIF7EFOzse68IaE6zz4JexeYECML3-eUaA,98055
40
+ tricc_oo/visitors/tricc.py,sha256=5xJpFb6ne9NtcVCfkc_c5jzOv2JINKS9WTui9VIpZHA,97875
41
41
  tricc_oo/visitors/utils.py,sha256=Gol4JNozPEd30Q1l8IPIPhx5fqVyy9R81GofGVebgD8,484
42
- tricc_oo/visitors/xform_pd.py,sha256=HfcpbeeW--Q1wrRrF_uMoPATkzUxMGO5KvXtlPMG31o,9474
43
- tricc_oo-1.4.27.dist-info/METADATA,sha256=4F4fGRYQGhEdNNu3vbhm1L39-cfWaSAZYkk5V1Ciykk,7878
44
- tricc_oo-1.4.27.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
45
- tricc_oo-1.4.27.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
46
- tricc_oo-1.4.27.dist-info/RECORD,,
42
+ tricc_oo/visitors/xform_pd.py,sha256=5KstBH92dfWLoi80MQTMq1YqcFjuFNnDF9wGXoSzt2E,9533
43
+ tricc_oo-1.4.28.dist-info/METADATA,sha256=2M1mKz8ohK38cwGJXlNWHfix0nBaXfVNkZnjB35NuaI,7878
44
+ tricc_oo-1.4.28.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
45
+ tricc_oo-1.4.28.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
46
+ tricc_oo-1.4.28.dist-info/RECORD,,