tricc-oo 1.6.23__py3-none-any.whl → 1.6.25__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/tricc.py CHANGED
@@ -99,6 +99,7 @@ class TriccNodeActivity(TriccNodeBaseModel):
99
99
  # - case definition
100
100
  calculates: List[TriccNodeCalculateBase] = []
101
101
  applicability: Optional[Union[Expression, TriccOperation]] = None
102
+ is_sequence_defined: bool = False
102
103
 
103
104
  # redefine
104
105
  def make_instance(self, instance_nb=None, **kwargs):
@@ -294,7 +295,8 @@ class TriccNodeDisplayModel(TriccNodeBaseModel):
294
295
  default: Optional[Union[Expression, TriccOperation, TriccReference, TriccStatic]] = None
295
296
  trigger: Optional[Union[Expression, TriccOperation, TriccReference]] = None
296
297
  priority: Union[float, int, None] = None
297
-
298
+ concept_type: str = None
299
+ datatype: str = None
298
300
  # to use the enum value of the TriccNodeType
299
301
 
300
302
 
@@ -43,6 +43,7 @@ TRICC_CALC_EXPRESSION = "${{{0}}}>0"
43
43
 
44
44
  def get_export_group_name(in_node): return f"gcalc_{get_export_name(in_node)}"
45
45
 
46
+ def get_export_group_required(in_node): return in_node.relevance and in_node.relevance != TriccStatic(True)
46
47
 
47
48
  def start_group(
48
49
  strategy,
@@ -65,9 +66,9 @@ def start_group(
65
66
  groups[name] = 0
66
67
  relevance = relevance and cur_group.relevance is not None and cur_group.relevance != ""
67
68
  past_instances = len(getattr(cur_group.base_instance, "instances", []))
68
- group_calc_required = relevance is not None and (len(str(relevance)) > 100 or past_instances > 1)
69
+ group_calc_required = get_export_group_required(cur_group)
69
70
  calc = None
70
- if group_calc_required and getattr(cur_group.relevance, 'operator', None) != TriccOperator.ISTRUE:
71
+ if group_calc_required and len(df_calculate[df_calculate["name"] == get_export_group_name(cur_group)]) == 0:
71
72
 
72
73
  calc = TriccNodeCalculate(
73
74
  id=generate_id(get_export_group_name(name)),
@@ -356,8 +357,7 @@ def generate_choice_filter(strategy, node):
356
357
  choice_filter = TriccOperation(TriccOperator.OR, [basic])
357
358
  for k, op in relevances.items():
358
359
  choice_filter.append(
359
- TriccOperation(
360
- TriccOperator.AND,
360
+ and_join(
361
361
  [
362
362
  TriccOperation(
363
363
  TriccOperator.EQUAL,
@@ -367,7 +367,7 @@ def generate_choice_filter(strategy, node):
367
367
  ],
368
368
  ),
369
369
  op,
370
- ],
370
+ ]
371
371
  )
372
372
  )
373
373
  return strategy.get_tricc_operation_expression(choice_filter)
@@ -19,7 +19,7 @@ from tricc_oo.models.ordered_set import OrderedSet
19
19
  from tricc_oo.models.calculate import (
20
20
  TriccNodeEnd,
21
21
  TriccNodeDisplayCalculateBase,
22
-
22
+ TriccNodeActivityStart,
23
23
  )
24
24
  from tricc_oo.models.tricc import (
25
25
  TriccNodeCalculateBase,
@@ -28,6 +28,7 @@ from tricc_oo.models.tricc import (
28
28
  TriccNodeSelect,
29
29
  TriccNodeInputModel,
30
30
  TriccNodeDisplayModel,
31
+ TriccNodeMainStart,
31
32
  TRICC_FALSE_VALUE,
32
33
  TRICC_TRUE_VALUE,
33
34
  )
@@ -50,6 +51,8 @@ from tricc_oo.serializers.xls_form import (
50
51
  SURVEY_MAP,
51
52
  end_group,
52
53
  generate_xls_form_export,
54
+ get_export_group_name,
55
+ get_export_group_required,
53
56
  start_group,
54
57
  )
55
58
  from tricc_oo.strategies.output.base_output_strategy import BaseOutPutStrategy
@@ -745,6 +748,13 @@ class XLSFormStrategy(BaseOutPutStrategy):
745
748
  elif isinstance(r, TriccNodeSelectOption):
746
749
  logger.debug(f"select option {r.get_name()} from {r.select.get_name()} was used as a reference")
747
750
  return get_export_name(r)
751
+ elif isinstance(r, TriccNodeActivityStart):
752
+ if get_export_group_required(r.activity):
753
+ return f"${{{get_export_group_name(r.activity)}}}"
754
+ else:
755
+ return f"({self.get_tricc_operation_expression(r.relevance)})"
756
+ elif isinstance(r, TriccNodeMainStart):
757
+ return "1"
748
758
  elif issubclass(r.__class__, (TriccNodeInputModel, TriccNodeSelect)):
749
759
  return f"coalesce(${{{get_export_name(r)}}},{coalesce_fallback})"
750
760
  elif issubclass(r.__class__, TriccNodeBaseModel):
@@ -811,13 +811,6 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
811
811
  logger.error(f"CHT XLSForm validation error for {os.path.basename(xls_file)}: {str(e)}")
812
812
  all_valid = False
813
813
 
814
- jar_in_zip = "site-packages/pyxform/validators/odk_validate/bin/ODK_Validate.jar"
815
- zip_ref.extract(jar_in_zip, os.path.dirname(__file__))
816
-
817
- # Move to final location
818
- extracted_jar = os.path.join(os.path.dirname(__file__), jar_in_zip)
819
- shutil.move(extracted_jar, jar_path)
820
-
821
814
  logger.info(f"Extracted ODK Validate JAR to {jar_path}")
822
815
  return jar_path
823
816
 
@@ -240,7 +240,7 @@ def merge_all_expressions(expression, all_versions):
240
240
  datatype = expression.get_datatype() if expression else "unknown"
241
241
 
242
242
  if datatype == "boolean":
243
- expression = or_join(all_versions)
243
+ expression = or_join([expression, *all_versions])
244
244
 
245
245
  else:
246
246
  # COALESCE through all previous versions, then the current expression
@@ -2265,8 +2265,7 @@ def get_prev_node_expression(node, processed_nodes, get_overall_exp=False, exclu
2265
2265
  if act_expression_inputs:
2266
2266
  act_sub = or_join(act_expression_inputs)
2267
2267
  # if there is condition fallback on the calling activity condition
2268
- if act_sub == TriccStatic(True):
2269
- act_sub = get_node_expression(
2268
+ act_relevance = get_node_expression(
2270
2269
  prev_node.activity,
2271
2270
  processed_nodes=processed_nodes,
2272
2271
  get_overall_exp=get_overall_exp,
@@ -2274,17 +2273,25 @@ def get_prev_node_expression(node, processed_nodes, get_overall_exp=False, exclu
2274
2273
  negate=False,
2275
2274
  process=process,
2276
2275
  )
2277
- elif none_sequence_defined_prev_node:
2276
+ if act_sub == TriccStatic(True):
2277
+ act_sub = act_relevance
2278
+ elif act_relevance != TriccStatic(True) and none_sequence_defined_prev_node:
2278
2279
  # For nodes with is_sequence_defined = False, AND the activity relevance with the prev expression
2279
- activity_relevance = get_node_expression(
2280
- prev_node.activity,
2281
- processed_nodes=processed_nodes,
2282
- get_overall_exp=get_overall_exp,
2283
- is_prev=True,
2284
- negate=False,
2285
- process=process,
2286
- )
2287
- act_sub = and_join([activity_relevance, act_sub])
2280
+ # activity_relevance = get_node_expression(
2281
+ # prev_node.activity,
2282
+ # processed_nodes=processed_nodes,
2283
+ # get_overall_exp=get_overall_exp,
2284
+ # is_prev=True,
2285
+ # negate=False,
2286
+ # process=process,
2287
+ # )
2288
+ act_sub = and_join([
2289
+ TriccOperation(
2290
+ TriccOperator.ISTRUE,
2291
+ [prev_node.activity.root]
2292
+ ),
2293
+ act_sub
2294
+ ])
2288
2295
  add_sub_expression(expression_inputs, act_sub)
2289
2296
  # avoid void is there is not conditions to avoid looping too much itme
2290
2297
  # expression_inputs = clean_or_list(
@@ -2661,13 +2668,10 @@ def get_selected_option_expression_multiple(option_node, negate):
2661
2668
  selected = TriccOperation(TriccOperator.SELECTED, [option_node.select, TriccStatic(option_node)])
2662
2669
 
2663
2670
  if negate:
2664
- return TriccOperation(
2665
- operator=TriccOperator.AND,
2666
- resource=[
2671
+ return and_join([
2667
2672
  TriccOperation(operator=TriccOperator.NOT, resource=[selected]),
2668
2673
  TriccOperation(operator=TriccOperator.ISNOTNULL, resource=[option_node.select]),
2669
- ],
2670
- )
2674
+ ])
2671
2675
 
2672
2676
  else:
2673
2677
  return selected
@@ -2778,7 +2782,7 @@ def generate_base(node, processed_nodes, **kwargs):
2778
2782
  )
2779
2783
  constraints_max = "The maximum value is {0}.".format(node.max)
2780
2784
  if len(constraints) > 1:
2781
- node.constraint = TriccOperation(TriccOperator.AND, constraints)
2785
+ node.constraint = and_join(constraints)
2782
2786
  node.constraint_message = (constraints_min + " " + constraints_max).strip()
2783
2787
  elif len(constraints) == 1:
2784
2788
  node.constraint = constraints[0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.6.23
3
+ Version: 1.6.25
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
@@ -20,12 +20,12 @@ tricc_oo/models/calculate.py,sha256=uNP0IDUqPQcJq9Co05H8eX5wbR_DikSxuOHxfVE5Dxg,
20
20
  tricc_oo/models/lang.py,sha256=ZMRwdoPWe01wEDhOM0uRk-6rt3BkoAAZM8mZ61--s3A,2265
21
21
  tricc_oo/models/ocl.py,sha256=MybSeB6fgCOUVJ4aektff0vrrTZsyfwZ2Gt_pPBu_FY,8728
22
22
  tricc_oo/models/ordered_set.py,sha256=BpXLW8plRAy4te25PIUPvVXPnLPcypvKg3iNPhtPulA,3833
23
- tricc_oo/models/tricc.py,sha256=H_HPFzFsS_-fFXCx3vdKsw29DFrlTnAscTJE_lQG_Lk,17549
23
+ tricc_oo/models/tricc.py,sha256=dUh0H9hyzwH4VDFDkKIsEjyV794FYTbpJp8F1JugiOU,17640
24
24
  tricc_oo/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  tricc_oo/parsers/xml.py,sha256=uzkb1y18MHfqVFmZqVh0sKT4cx6u0-NcAT_lV_gHBt8,4208
26
26
  tricc_oo/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  tricc_oo/serializers/planuml.py,sha256=t57587-6L3aDncpHh58lS77Zft8yxDE9DPtXx2BeUSU,132
28
- tricc_oo/serializers/xls_form.py,sha256=E0VKcAXoVvGfinMZXOmo-90uypjsGAKS2S3-mtvAT7I,24215
28
+ tricc_oo/serializers/xls_form.py,sha256=SZPvZK6y4l_2v3HuGWITHmKd5rTClhHWvbUU3RendFg,24249
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=BEODXS74na1QRRcJVQ4cxiD8F7uRqaLyhE3QzKpGVvk,3891
@@ -36,16 +36,16 @@ tricc_oo/strategies/output/fhir_form.py,sha256=hbL921pe1Doun4IQrJuZ_Sq2fCh98G3gr
36
36
  tricc_oo/strategies/output/html_form.py,sha256=qSleEZOMV_-Z04y-i-ucyd5rgAYWAyjPwMrw0IHtCRM,8604
37
37
  tricc_oo/strategies/output/openmrs_form.py,sha256=ne6TwAyhafR-WDs27QTKKFl85VD5sij_VEJtK6ZjOIE,28996
38
38
  tricc_oo/strategies/output/spice.py,sha256=QMeoismVC3PdbvwTK0PtUjWX9jl9780fbQIXn76fMXw,10761
39
- tricc_oo/strategies/output/xls_form.py,sha256=ISpZEjPHiKV9TEDwQnGf0hf2eLSw4RXP_SVbiMEBIEY,33434
39
+ tricc_oo/strategies/output/xls_form.py,sha256=yz1G7Mdf4ZpdXaKU6YV8rjNQ288pwUzTh13aI5Up6AI,33884
40
40
  tricc_oo/strategies/output/xlsform_cdss.py,sha256=X00Lt5MzV8TX14dR4dFI1MqllI5S1e13bKbeysWM9uA,17435
41
- tricc_oo/strategies/output/xlsform_cht.py,sha256=lY1xIDxqYxl_lYNVCl3msXZL88No49yEVCpahcHGOn0,28675
41
+ tricc_oo/strategies/output/xlsform_cht.py,sha256=66sTRqVL9ZUL8NpX2f0xCRQ-siUKcKphosR9y7wsbuM,28326
42
42
  tricc_oo/strategies/output/xlsform_cht_hf.py,sha256=xm6SKirV3nMZvM2w54_zJcXAeAgAkq-EEqGEjnOWv6c,988
43
43
  tricc_oo/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- tricc_oo/visitors/tricc.py,sha256=uWfPs4yUqTlVBzQcNGLaf635pOz5ClzJ2yj9pieJANY,114090
44
+ tricc_oo/visitors/tricc.py,sha256=VL1Ds4a7gCA0V7Mo2qPipT2uV4dcXDK2_swLdxZavDA,114272
45
45
  tricc_oo/visitors/utils.py,sha256=j83aAq5s5atXi3OC0jc_uJd54a8XrHHmizeeEbWZQJg,421
46
46
  tricc_oo/visitors/xform_pd.py,sha256=ryAnI3V9x3eTmJ2LNsUZfvl0_yfCqo6oBgeSu-WPqaE,9613
47
- tricc_oo-1.6.23.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
48
- tricc_oo-1.6.23.dist-info/METADATA,sha256=7_BWo-Qm5UcknB4D9LNIO2Gnit5zdxQWHEL4BUFxlLI,8600
49
- tricc_oo-1.6.23.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
50
- tricc_oo-1.6.23.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
51
- tricc_oo-1.6.23.dist-info/RECORD,,
47
+ tricc_oo-1.6.25.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
48
+ tricc_oo-1.6.25.dist-info/METADATA,sha256=If9bVy3gEm3zT0OMh6UPuUJxsFndAk_MtcglJXUH4LQ,8600
49
+ tricc_oo-1.6.25.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
50
+ tricc_oo-1.6.25.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
51
+ tricc_oo-1.6.25.dist-info/RECORD,,