tricc-oo 1.5.24__tar.gz → 1.5.26__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 (56) hide show
  1. {tricc_oo-1.5.24/tricc_oo.egg-info → tricc_oo-1.5.26}/PKG-INFO +1 -1
  2. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/pyproject.toml +1 -1
  3. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tests/build.py +12 -15
  4. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tests/test_cql.py +4 -4
  5. tricc_oo-1.5.26/tricc_oo/converters/tricc_to_xls_form.py +86 -0
  6. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/utils.py +1 -1
  7. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/models/tricc.py +2 -0
  8. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/serializers/xls_form.py +1 -9
  9. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/openmrs_form.py +15 -15
  10. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/xls_form.py +16 -16
  11. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/xlsform_cht.py +0 -1
  12. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/visitors/tricc.py +2 -3
  13. {tricc_oo-1.5.24 → tricc_oo-1.5.26/tricc_oo.egg-info}/PKG-INFO +1 -1
  14. tricc_oo-1.5.24/tricc_oo/converters/tricc_to_xls_form.py +0 -55
  15. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/LICENSE +0 -0
  16. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/README.md +0 -0
  17. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/setup.cfg +0 -0
  18. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tests/to_ocl.py +0 -0
  19. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/__init__.py +0 -0
  20. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/__init__.py +0 -0
  21. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  22. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  23. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/cql/cqlListener.py +0 -0
  24. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/cql/cqlParser.py +0 -0
  25. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  26. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/cql_to_operation.py +0 -0
  27. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/datadictionnary.py +0 -0
  28. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/drawio_type_map.py +0 -0
  29. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/converters/xml_to_tricc.py +0 -0
  30. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/models/__init__.py +0 -0
  31. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/models/base.py +0 -0
  32. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/models/calculate.py +0 -0
  33. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/models/lang.py +0 -0
  34. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/models/ocl.py +0 -0
  35. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/models/ordered_set.py +0 -0
  36. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/parsers/__init__.py +0 -0
  37. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/parsers/xml.py +0 -0
  38. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/serializers/__init__.py +0 -0
  39. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/serializers/planuml.py +0 -0
  40. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/__init__.py +0 -0
  41. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/input/__init__.py +0 -0
  42. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  43. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/input/drawio.py +0 -0
  44. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
  45. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/fhir_form.py +0 -0
  46. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/html_form.py +0 -0
  47. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/spice.py +0 -0
  48. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  49. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  50. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/visitors/__init__.py +0 -0
  51. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/visitors/utils.py +0 -0
  52. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo/visitors/xform_pd.py +0 -0
  53. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo.egg-info/SOURCES.txt +0 -0
  54. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo.egg-info/dependency_links.txt +0 -0
  55. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/tricc_oo.egg-info/requires.txt +0 -0
  56. {tricc_oo-1.5.24 → tricc_oo-1.5.26}/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.5.24
3
+ Version: 1.5.26
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.5.24"
7
+ version = "1.5.26"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,20 +1,17 @@
1
- from tricc_oo.strategies.output.spice import SpiceStrategy
2
- from tricc_oo.strategies.output.xlsform_cht_hf import XLSFormCHTHFStrategy
3
- from tricc_oo.strategies.output.xlsform_cht import XLSFormCHTStrategy
4
- from tricc_oo.strategies.output.xlsform_cdss import XLSFormCDSSStrategy
5
- from tricc_oo.strategies.output.xls_form import XLSFormStrategy
6
- from tricc_oo.strategies.output.openmrs_form import OpenMRSStrategy
7
- from tricc_oo.strategies.output.fhir_form import FHIRStrategy
8
- from tricc_oo.strategies.output.html_form import HTMLStrategy
9
-
10
- from tricc_oo.strategies.input.drawio import DrawioStrategy
1
+ from tricc_oo.strategies.output.spice import SpiceStrategy # noqa: F401
2
+ from tricc_oo.strategies.output.xlsform_cht_hf import XLSFormCHTHFStrategy # noqa: F401
3
+ from tricc_oo.strategies.output.xlsform_cht import XLSFormCHTStrategy # noqa: F401
4
+ from tricc_oo.strategies.output.xlsform_cdss import XLSFormCDSSStrategy # noqa: F401
5
+ from tricc_oo.strategies.output.xls_form import XLSFormStrategy # noqa: F401
6
+ from tricc_oo.strategies.output.openmrs_form import OpenMRSStrategy # noqa: F401
7
+ from tricc_oo.strategies.output.fhir_form import FHIRStrategy # noqa: F401
8
+ from tricc_oo.strategies.output.html_form import HTMLStrategy # noqa: F401
9
+ from tricc_oo.strategies.input.drawio import DrawioStrategy # noqa: F401
11
10
  import getopt
12
- import gettext
13
11
  import logging
14
12
  import os
15
13
  import sys
16
14
  import gc
17
- import shutil
18
15
  from pathlib import Path
19
16
 
20
17
  # set up logging to file
@@ -43,15 +40,15 @@ def setup_logger(
43
40
  level=logging.INFO,
44
41
  formatting="[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s",
45
42
  ):
46
- l = logging.getLogger(logger_name)
43
+ logger = logging.getLogger(logger_name)
47
44
  formatter = logging.Formatter(formatting)
48
45
  file_handler = logging.FileHandler(log_file, mode="w+")
49
46
  file_handler.setFormatter(formatter)
50
47
  stream_handler = logging.StreamHandler()
51
48
  stream_handler.setFormatter(formatter)
52
49
 
53
- l.setLevel(level)
54
- l.addHandler(file_handler)
50
+ logger.setLevel(level)
51
+ logger.addHandler(file_handler)
55
52
 
56
53
 
57
54
  class ColorFormatter(logging.Formatter):
@@ -53,9 +53,9 @@ class TestCql(unittest.TestCase):
53
53
 
54
54
  def test_case(self):
55
55
  case_cql = """
56
- case AgeInMonths()
57
- when 0 then 'newborn'
58
- when 1 then 'newborn'
56
+ case AgeInMonths()
57
+ when 0 then 'newborn'
58
+ when 1 then 'newborn'
59
59
  else 'child' end
60
60
  """
61
61
  case_operation = transform_cql_to_operation(case_cql)
@@ -72,7 +72,7 @@ class TestCql(unittest.TestCase):
72
72
 
73
73
  def test_ifs(self):
74
74
  case_cql = """
75
- case
75
+ case
76
76
  when AgeInMonths() <= 2 then true
77
77
  when AgeInYears() > 5 then true
78
78
  else false end
@@ -0,0 +1,86 @@
1
+ import logging
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
4
+ from tricc_oo.models.calculate import TriccNodeInput
5
+ from tricc_oo.models.base import TriccNodeBaseModel, TriccStatic, TriccReference
6
+
7
+ # from babel import _
8
+
9
+ # TRICC_SELECT_MULTIPLE_CALC_EXPRESSION = "count-selected(${{{0}}}) - number(selected(${{{0}}},'opt_none'))"
10
+ # TRICC_SELECT_MULTIPLE_CALC_NONE_EXPRESSION = "selected(${{{0}}},'opt_none')"
11
+ # TRICC_CALC_EXPRESSION = "${{{0}}}>0"
12
+ # TRICC_CALC_NOT_EXPRESSION = "${{{0}}}=0"
13
+ # TRICC_EMPTY_EXPRESSION = "coalesce(${{{0}}},'') != ''"
14
+ # TRICC_SELECTED_EXPRESSION = 'selected(${{{0}}}, "{1}")'
15
+ # TRICC_SELECTED_NEGATE_EXPRESSION = 'count-selected(${{{0}}})>0 and not(selected(${{{0}}}, "{1}"))'
16
+ # TRICC_REF_EXPRESSION = "${{{0}}}"
17
+ TRICC_NEGATE = "not({})"
18
+ # TRICC_NUMBER = "number({})"
19
+ # TRICC_AND_EXPRESSION = '{0} and {1}'
20
+ VERSION_SEPARATOR = "_Vv_"
21
+ INSTANCE_SEPARATOR = "_Ii_"
22
+ BOOLEAN_MAP = {
23
+ str(TRICC_TRUE_VALUE): 1,
24
+ str(TRICC_FALSE_VALUE): 0,
25
+ }
26
+
27
+
28
+ logger = logging.getLogger("default")
29
+
30
+ # gettext language dict {'code':gettext}
31
+
32
+
33
+ def get_export_name(node, replace_dots=True):
34
+ if hasattr(node, 'export_name') and node.export_name is not None:
35
+ return node.export_name
36
+ elif isinstance(node, bool):
37
+ return BOOLEAN_MAP[str(TRICC_TRUE_VALUE)] if node else BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
38
+ elif isinstance(node, TriccReference):
39
+ logger.warning(f"Reference {node.value} use in export, bad serialiuation probable")
40
+ return str(node.value)
41
+ elif isinstance(node, (str, TriccStatic, TriccNodeSelectOption)):
42
+ if isinstance(node, TriccNodeSelectOption):
43
+ value = node.name
44
+ elif isinstance(node, TriccStatic):
45
+ value = node.value
46
+ else:
47
+ value = node
48
+ if isinstance(value, bool): # or r.value in ('true', 'false')
49
+ export_name = BOOLEAN_MAP[str(TRICC_TRUE_VALUE)] if value else BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
50
+ elif value == TRICC_TRUE_VALUE:
51
+ export_name = BOOLEAN_MAP[str(TRICC_TRUE_VALUE)]
52
+ elif value == TRICC_FALSE_VALUE:
53
+ export_name = BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
54
+ elif isinstance(value, str):
55
+ export_name = f"'{clean_str(value, replace_dots=replace_dots)}'"
56
+ else:
57
+ export_name = str(value)
58
+ if hasattr(node, 'export_name'):
59
+ node.export_name = export_name
60
+ return export_name
61
+ elif not hasattr(node, 'export_name'):
62
+ return node
63
+ else:
64
+ node.gen_name()
65
+ if isinstance(node, TriccNodeSelectOption):
66
+ node.export_name = node.name
67
+ elif node.last is False:
68
+ node.export_name = clean_name(
69
+ node.name + VERSION_SEPARATOR + str(node.version),
70
+ replace_dots=replace_dots,
71
+ )
72
+ elif isinstance(node, TriccNodeInput):
73
+ node.export_name = clean_name("load." + node.name, replace_dots=replace_dots)
74
+ else:
75
+ node.export_name = clean_name(node.name, replace_dots=replace_dots)
76
+ return node.export_name
77
+
78
+
79
+ def get_list_names(list):
80
+ names = []
81
+ for elm in list:
82
+ if issubclass(elm.__class__, TriccNodeBaseModel):
83
+ names.append(get_export_name(elm))
84
+ elif isinstance(elm, str):
85
+ names.append(elm)
86
+ return names
@@ -23,7 +23,7 @@ def clean_str(name, replace_dots=False):
23
23
 
24
24
  def clean_name(name, prefix="", replace_dots=False):
25
25
  name = clean_str(name, replace_dots)
26
- if name[0].isdigit():
26
+ if name and name[0].isdigit():
27
27
  name = "id_" + name
28
28
  elif name[0].isdigit() == "_":
29
29
  name = name[1:]
@@ -15,6 +15,8 @@ import logging
15
15
 
16
16
 
17
17
  logger = logging.getLogger(__name__)
18
+ TRICC_TRUE_VALUE = "true"
19
+ TRICC_FALSE_VALUE = "false"
18
20
 
19
21
 
20
22
  class TriccNodeCalculateBase(TriccNodeBaseModel):
@@ -3,7 +3,7 @@ import hashlib
3
3
 
4
4
  # from bs4 import BeautifulSoup
5
5
  from tricc_oo.converters.tricc_to_xls_form import (
6
- get_export_name,
6
+ get_export_name, BOOLEAN_MAP
7
7
  )
8
8
  from tricc_oo.models.lang import SingletonLangClass
9
9
  from tricc_oo.converters.utils import clean_name, remove_html
@@ -13,7 +13,6 @@ from tricc_oo.models.base import (
13
13
  )
14
14
  from tricc_oo.models.calculate import (
15
15
  TriccNodeDisplayCalculateBase,
16
-
17
16
  )
18
17
  from tricc_oo.models.tricc import (
19
18
  TriccNodeActivity, TriccNodeBaseModel, TriccNodeSelectMultiple, TriccNodeSelectOption,
@@ -29,8 +28,6 @@ from tricc_oo.visitors.tricc import (
29
28
  is_ready_to_process,
30
29
  process_reference,
31
30
  add_calculate,
32
- TRICC_TRUE_VALUE,
33
- TRICC_FALSE_VALUE,
34
31
  get_applicability_expression,
35
32
  get_prev_instance_skip_expression,
36
33
  get_process_skip_expression,
@@ -41,11 +38,6 @@ logger = logging.getLogger("default")
41
38
  langs = SingletonLangClass()
42
39
  TRICC_CALC_EXPRESSION = "${{{0}}}>0"
43
40
 
44
- BOOLEAN_MAP = {
45
- str(TRICC_TRUE_VALUE): 1,
46
- str(TRICC_FALSE_VALUE): 0,
47
- }
48
-
49
41
 
50
42
  def start_group(
51
43
  strategy,
@@ -22,8 +22,7 @@ from tricc_oo.models.tricc import (
22
22
  TriccNodeInputModel,
23
23
  TriccNodeBaseModel,
24
24
  TriccNodeDisplayModel,
25
- TriccNodeSelectYesNo
26
- )
25
+ )
27
26
 
28
27
  from tricc_oo.models.calculate import TriccNodeDisplayCalculateBase, TriccNodeDiagnosis
29
28
  from tricc_oo.models.ordered_set import OrderedSet
@@ -36,6 +35,7 @@ UUID_NAMESPACE = uuid.UUID('12345678-1234-5678-9abc-def012345678')
36
35
  CIEL_YES = "1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
37
36
  CIEL_NO = "1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
38
37
 
38
+
39
39
  class OpenMRSStrategy(BaseOutPutStrategy):
40
40
  processes = ["main"]
41
41
  project = None
@@ -193,8 +193,8 @@ class OpenMRSStrategy(BaseOutPutStrategy):
193
193
  if node.hint:
194
194
  question["questionInfo"] = node.hint
195
195
  if node.tricc_type in ['select_one', 'select_multiple']:
196
- labelTrue = None
197
- labelFalse = None
196
+ # labelTrue = None
197
+ # labelFalse = None
198
198
  # Add answers if options
199
199
  if hasattr(node, 'options'):
200
200
  answers = []
@@ -204,10 +204,10 @@ class OpenMRSStrategy(BaseOutPutStrategy):
204
204
  concept_val = self.get_option_value(opt.name)
205
205
  if concept_val == TriccStatic(False):
206
206
  concept_val = CIEL_NO
207
- labelFalse = display
207
+ # labelFalse = display
208
208
  if concept_val == TriccStatic(True):
209
209
  concept_val = CIEL_YES
210
- labelTrue = display
210
+ # labelTrue = display
211
211
  answers.append({
212
212
  "label": display,
213
213
  "concept": concept_val,
@@ -241,7 +241,7 @@ class OpenMRSStrategy(BaseOutPutStrategy):
241
241
  "id": self.get_export_name(node),
242
242
  "type": "obs" if isinstance(node, TriccNodeDiagnosis) else "control",
243
243
  "label": getattr(node, 'label', '').replace('\u00a0', ' ').strip(),
244
- "hide":{
244
+ "hide": {
245
245
  "hideWhenExpression": "true"
246
246
  },
247
247
  "questionOptions": {
@@ -414,16 +414,16 @@ class OpenMRSStrategy(BaseOutPutStrategy):
414
414
 
415
415
  # Operation methods similar, but for string expressions
416
416
  def tricc_operation_equal(self, ref_expressions):
417
- if ref_expressions[1] == TriccStatic(True) or ref_expressions[1] == True or ref_expressions[1] == 'true':
417
+ if ref_expressions[1] == TriccStatic(True) or ref_expressions[1] is True or ref_expressions[1] == 'true':
418
418
  return f"{self._boolean(ref_expressions, '===', CIEL_YES, 'true')}"
419
- elif ref_expressions[1] == TriccStatic(False) or ref_expressions[1] == False or ref_expressions[1] == 'false':
419
+ elif ref_expressions[1] == TriccStatic(False) or ref_expressions[1] is False or ref_expressions[1] == 'false':
420
420
  return f"{self._boolean(ref_expressions, '===', CIEL_NO, 'false')}"
421
421
  return f"{ref_expressions[0]} === {ref_expressions[1]}"
422
422
 
423
423
  def tricc_operation_not_equal(self, ref_expressions):
424
- if ref_expressions[1] == TriccStatic(True) or ref_expressions[1] == True or ref_expressions[1] == 'true':
424
+ if ref_expressions[1] == TriccStatic(True) or ref_expressions[1] is True or ref_expressions[1] == 'true':
425
425
  return f"!{self._boolean(ref_expressions, '===', CIEL_YES, 'true')}"
426
- elif ref_expressions[1] == TriccStatic(False) or ref_expressions[1] == False or ref_expressions[1] == 'false':
426
+ elif ref_expressions[1] == TriccStatic(False) or ref_expressions[1] is False or ref_expressions[1] == 'false':
427
427
  return f"!{self._boolean(ref_expressions, '===', CIEL_NO, 'false')}"
428
428
  return f"{ref_expressions[0]} !== {ref_expressions[1]}"
429
429
 
@@ -494,11 +494,11 @@ class OpenMRSStrategy(BaseOutPutStrategy):
494
494
  return f"{ref_expressions[0]}({','.join(ref_expressions[1:])})"
495
495
 
496
496
  def tricc_operation_istrue(self, ref_expressions):
497
- #return f"{ref_expressions[0]} === true"
497
+ # return f"{ref_expressions[0]} === true"
498
498
  return f"{self._boolean(ref_expressions, '===', CIEL_YES, 'true')}"
499
499
 
500
500
  def tricc_operation_isfalse(self, ref_expressions):
501
- #return f"{ref_expressions[0]} === false"
501
+ # return f"{ref_expressions[0]} === false"
502
502
  return f"{self._boolean(ref_expressions, '===', CIEL_NO, 'false')}"
503
503
 
504
504
  def tricc_operation_parenthesis(self, ref_expressions):
@@ -514,11 +514,11 @@ class OpenMRSStrategy(BaseOutPutStrategy):
514
514
  return f"!isEmpty{ref_expressions[0]})"
515
515
 
516
516
  def tricc_operation_isnottrue(self, ref_expressions):
517
- #return f"{ref_expressions[0]} !== true"
517
+ # return f"{ref_expressions[0]} !== true"
518
518
  return f"!{self._boolean(ref_expressions, '===', CIEL_YES, 'true')}"
519
519
 
520
520
  def tricc_operation_isnotfalse(self, ref_expressions):
521
- #return f"{ref_expressions[0]} !== false"
521
+ # return f"{ref_expressions[0]} !== false"
522
522
  return f"!{self._boolean(ref_expressions, '===', CIEL_NO, 'false')}"
523
523
 
524
524
  def _boolean(self, ref_expressions, operator, answer_uuid, bool_val='false'):
@@ -25,9 +25,11 @@ from tricc_oo.models.tricc import (
25
25
  TriccNodeBaseModel,
26
26
  TriccNodeSelectOption,
27
27
  TriccNodeInputModel,
28
- TriccNodeDisplayModel
28
+ TriccNodeDisplayModel,
29
+ TRICC_FALSE_VALUE,
30
+ TRICC_TRUE_VALUE,
29
31
  )
30
- from tricc_oo.converters.tricc_to_xls_form import get_export_name
32
+ from tricc_oo.converters.tricc_to_xls_form import get_export_name, BOOLEAN_MAP
31
33
 
32
34
  from tricc_oo.models.lang import SingletonLangClass
33
35
 
@@ -37,8 +39,6 @@ from tricc_oo.visitors.tricc import (
37
39
  is_ready_to_process,
38
40
  process_reference,
39
41
  get_node_expressions,
40
- TRICC_TRUE_VALUE,
41
- TRICC_FALSE_VALUE,
42
42
  set_last_version_false,
43
43
  generate_calculate,
44
44
  generate_base,
@@ -49,7 +49,6 @@ from tricc_oo.serializers.xls_form import (
49
49
  end_group,
50
50
  generate_xls_form_export,
51
51
  start_group,
52
- BOOLEAN_MAP,
53
52
  )
54
53
  from tricc_oo.strategies.output.base_output_strategy import BaseOutPutStrategy
55
54
 
@@ -461,7 +460,10 @@ class XLSFormStrategy(BaseOutPutStrategy):
461
460
  return "1"
462
461
 
463
462
  def tricc_operation_native(self, ref_expressions):
463
+
464
464
  if len(ref_expressions) > 0:
465
+ if ref_expressions[0].startswith(("'","`",)):
466
+ ref_expressions[0] = ref_expressions[0][1:-1]
465
467
  if ref_expressions[0] == "GetChoiceName":
466
468
  return f"""jr:choice-name({
467
469
  self.clean_coalesce(ref_expressions[1])
@@ -722,23 +724,21 @@ class XLSFormStrategy(BaseOutPutStrategy):
722
724
  logger.warning(f"reference `{r.value}` still used in a calculate")
723
725
  return f"${{{get_export_name(r.value)}}}"
724
726
  elif isinstance(r, TriccStatic):
725
- if isinstance(r.value, bool): # or r.value in ('true', 'false')
726
- return BOOLEAN_MAP[str(TRICC_TRUE_VALUE)] if r.value else BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
727
- if r.value == TRICC_TRUE_VALUE:
727
+ return get_export_name(r)
728
+ elif isinstance(r, str):
729
+ if r == TRICC_TRUE_VALUE:
728
730
  return BOOLEAN_MAP[str(TRICC_TRUE_VALUE)]
729
- if r.value == TRICC_FALSE_VALUE:
731
+ elif r == TRICC_FALSE_VALUE:
730
732
  return BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
731
- if isinstance(r.value, str):
732
- return f"'{r.value}'"
733
+ elif isinstance(r, str):
734
+ return f"'{r}'"
733
735
  else:
734
- return str(r.value)
735
- elif isinstance(r, str):
736
- return f"{r}"
736
+ return str(r)
737
737
  elif isinstance(r, (int, float)):
738
738
  return str(r)
739
739
  elif isinstance(r, TriccNodeSelectOption):
740
- logger.warning(f"select option {r.get_name()} from {r.select.get_name()} was used as a reference")
741
- return f"'{r.name}'"
740
+ logger.debug(f"select option {r.get_name()} from {r.select.get_name()} was used as a reference")
741
+ return get_export_name(r)
742
742
  elif issubclass(r.__class__, TriccNodeInputModel):
743
743
  return f"coalesce(${{{get_export_name(r)}}},{coalesce_fallback})"
744
744
  elif issubclass(r.__class__, TriccNodeBaseModel):
@@ -33,7 +33,6 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
33
33
 
34
34
  self.inject_version()
35
35
 
36
-
37
36
  def get_cht_input(self, start_pages, **kwargs):
38
37
  empty = langs.get_trads("", force_dict=True)
39
38
  df_input = pd.DataFrame(columns=SURVEY_MAP.keys())
@@ -44,6 +44,8 @@ from tricc_oo.models.tricc import (
44
44
  TriccNodeDisplayModel,
45
45
  TriccNodeMainStart,
46
46
  TriccNodeAcceptDiagnostic,
47
+ TRICC_FALSE_VALUE,
48
+ TRICC_TRUE_VALUE,
47
49
  )
48
50
  from tricc_oo.visitors.utils import PROCESSES
49
51
  from tricc_oo.converters.cql_to_operation import transform_cql_to_operation
@@ -53,9 +55,6 @@ from tricc_oo.converters.tricc_to_xls_form import get_list_names, get_export_nam
53
55
  logger = logging.getLogger("default")
54
56
  ONE_QUESTION_AT_A_TIME = False
55
57
 
56
- TRICC_TRUE_VALUE = "true"
57
- TRICC_FALSE_VALUE = "false"
58
-
59
58
 
60
59
  def merge_node(from_node, to_node):
61
60
  if from_node.activity != to_node.activity:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.5.24
3
+ Version: 1.5.26
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
@@ -1,55 +0,0 @@
1
- import logging
2
- from tricc_oo.converters.utils import clean_name
3
- from tricc_oo.models.tricc import TriccNodeSelectOption
4
- from tricc_oo.models.calculate import TriccNodeInput
5
- from tricc_oo.models.base import TriccNodeBaseModel
6
- # from babel import _
7
-
8
- # TRICC_SELECT_MULTIPLE_CALC_EXPRESSION = "count-selected(${{{0}}}) - number(selected(${{{0}}},'opt_none'))"
9
- # TRICC_SELECT_MULTIPLE_CALC_NONE_EXPRESSION = "selected(${{{0}}},'opt_none')"
10
- # TRICC_CALC_EXPRESSION = "${{{0}}}>0"
11
- # TRICC_CALC_NOT_EXPRESSION = "${{{0}}}=0"
12
- # TRICC_EMPTY_EXPRESSION = "coalesce(${{{0}}},'') != ''"
13
- # TRICC_SELECTED_EXPRESSION = 'selected(${{{0}}}, "{1}")'
14
- # TRICC_SELECTED_NEGATE_EXPRESSION = 'count-selected(${{{0}}})>0 and not(selected(${{{0}}}, "{1}"))'
15
- # TRICC_REF_EXPRESSION = "${{{0}}}"
16
- TRICC_NEGATE = "not({})"
17
- # TRICC_NUMBER = "number({})"
18
- # TRICC_AND_EXPRESSION = '{0} and {1}'
19
- VERSION_SEPARATOR = "_Vv_"
20
- INSTANCE_SEPARATOR = "_Ii_"
21
-
22
-
23
- logger = logging.getLogger("default")
24
-
25
- # gettext language dict {'code':gettext}
26
-
27
-
28
- def get_export_name(node, replace_dots=True):
29
- if isinstance(node, str):
30
- return clean_name(node, replace_dots=replace_dots)
31
- if node.export_name is None:
32
- node.gen_name()
33
- if isinstance(node, TriccNodeSelectOption):
34
- node.export_name = node.name
35
- elif node.last is False:
36
- node.export_name = clean_name(
37
- node.name + VERSION_SEPARATOR + str(node.version),
38
- replace_dots=replace_dots,
39
- )
40
- elif isinstance(node, TriccNodeInput):
41
- node.export_name = clean_name("load." + node.name, replace_dots=replace_dots)
42
- else:
43
- node.export_name = clean_name(node.name, replace_dots=replace_dots)
44
-
45
- return node.export_name
46
-
47
-
48
- def get_list_names(list):
49
- names = []
50
- for elm in list:
51
- if issubclass(elm.__class__, TriccNodeBaseModel):
52
- names.append(get_export_name(elm))
53
- elif isinstance(elm, str):
54
- names.append(elm)
55
- return names
File without changes
File without changes
File without changes
File without changes