tricc-oo 1.6.11__tar.gz → 1.6.12__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.
- {tricc_oo-1.6.11/tricc_oo.egg-info → tricc_oo-1.6.12}/PKG-INFO +1 -1
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/pyproject.toml +1 -1
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/serializers/xls_form.py +1 -46
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/xlsform_cht.py +7 -19
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/visitors/tricc.py +44 -9
- {tricc_oo-1.6.11 → tricc_oo-1.6.12/tricc_oo.egg-info}/PKG-INFO +1 -1
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/LICENSE +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/README.md +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/setup.cfg +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tests/build.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tests/test_build.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tests/test_cql.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tests/to_ocl.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/cql/cqlLexer.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/cql/cqlListener.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/cql/cqlParser.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/cql_to_operation.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/datadictionnary.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/drawio_type_map.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/utils.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/converters/xml_to_tricc.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/models/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/models/base.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/models/calculate.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/models/lang.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/models/ocl.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/models/ordered_set.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/models/tricc.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/parsers/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/parsers/xml.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/serializers/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/serializers/planuml.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/input/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/input/drawio.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/dhis2_form.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/fhir_form.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/html_form.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/openmrs_form.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/spice.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/xls_form.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/visitors/__init__.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/visitors/utils.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo/visitors/xform_pd.py +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo.egg-info/SOURCES.txt +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo.egg-info/dependency_links.txt +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo.egg-info/requires.txt +0 -0
- {tricc_oo-1.6.11 → tricc_oo-1.6.12}/tricc_oo.egg-info/top_level.txt +0 -0
|
@@ -64,36 +64,7 @@ def start_group(
|
|
|
64
64
|
groups[name] = 0
|
|
65
65
|
relevance = relevance and cur_group.relevance is not None and cur_group.relevance != ""
|
|
66
66
|
past_instances = len(getattr(cur_group.base_instance, "instances", []))
|
|
67
|
-
group_calc_required = relevance is not None and (len(str(relevance)) > 100 or past_instances > 1)
|
|
68
67
|
calc = None
|
|
69
|
-
if group_calc_required and getattr(cur_group.relevance, 'operator', None) != TriccOperator.ISTRUE:
|
|
70
|
-
|
|
71
|
-
calc = TriccNodeCalculate(
|
|
72
|
-
id=generate_id(get_export_group_name(name)),
|
|
73
|
-
group=cur_group.group,
|
|
74
|
-
activity=cur_group.activity,
|
|
75
|
-
name=get_export_group_name(name),
|
|
76
|
-
expression=cur_group.relevance.copy()
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
if calc not in cur_group.activity.calculates:
|
|
80
|
-
process_reference(
|
|
81
|
-
calc,
|
|
82
|
-
processed_nodes,
|
|
83
|
-
calculates=kwargs.get('calculates', None),
|
|
84
|
-
used_calculates=kwargs.get('used_calculates', None),
|
|
85
|
-
replace_reference=True,
|
|
86
|
-
warn=False,
|
|
87
|
-
codesystems=kwargs.get('codesystems', None)
|
|
88
|
-
)
|
|
89
|
-
cur_group.activity.calculates.append(calc)
|
|
90
|
-
cur_group.activity.nodes[calc.id] = calc
|
|
91
|
-
processed_nodes.add(calc)
|
|
92
|
-
|
|
93
|
-
cur_group.relevance = TriccOperation(
|
|
94
|
-
TriccOperator.ISTRUE,
|
|
95
|
-
[calc]
|
|
96
|
-
)
|
|
97
68
|
|
|
98
69
|
relevance_expression = cur_group.relevance
|
|
99
70
|
relevance_expression = get_applicability_expression(cur_group, processed_nodes, process, relevance_expression)
|
|
@@ -124,23 +95,7 @@ def start_group(
|
|
|
124
95
|
values.append(get_xfrom_trad(strategy, cur_group, column, SURVEY_MAP))
|
|
125
96
|
df_survey.loc[len(df_survey)] = values
|
|
126
97
|
|
|
127
|
-
#
|
|
128
|
-
if calc and len(df_calculate[df_calculate["name"] == get_export_group_name(name)]) == 0:
|
|
129
|
-
calc_values = []
|
|
130
|
-
for column in SURVEY_MAP:
|
|
131
|
-
if column == "type":
|
|
132
|
-
calc_values.append("calculate")
|
|
133
|
-
elif column == "name":
|
|
134
|
-
value = get_export_name(calc)
|
|
135
|
-
calc_values.append(value)
|
|
136
|
-
elif column == "calculation":
|
|
137
|
-
calc_values.append(f"number({strategy.get_tricc_operation_expression(calc.expression)})")
|
|
138
|
-
elif column == "relevance":
|
|
139
|
-
calc_values.append("")
|
|
140
|
-
else:
|
|
141
|
-
calc_values.append(get_xfrom_trad(strategy, cur_group, column, SURVEY_MAP))
|
|
142
|
-
|
|
143
|
-
df_calculate.loc[len(df_calculate)] = calc_values
|
|
98
|
+
# Group calculates are now created during process_calculate phase
|
|
144
99
|
|
|
145
100
|
|
|
146
101
|
# def add_background_color(input_string, color):
|
|
@@ -821,34 +821,22 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
|
|
|
821
821
|
return jar_path
|
|
822
822
|
|
|
823
823
|
def _ensure_odk_validate_jar(self):
|
|
824
|
-
"""Ensure ODK Validate JAR is available by
|
|
824
|
+
"""Ensure ODK Validate JAR is available by downloading from GitHub releases."""
|
|
825
825
|
jar_path = os.path.join(os.path.dirname(__file__), "ODK_Validate.jar")
|
|
826
826
|
|
|
827
827
|
# Check if JAR already exists
|
|
828
828
|
if os.path.exists(jar_path):
|
|
829
829
|
return jar_path
|
|
830
830
|
|
|
831
|
-
#
|
|
832
|
-
|
|
833
|
-
if not os.path.exists(medic_zip_path):
|
|
834
|
-
logger.error("xls2xform-medic zip not found, cannot extract ODK Validate JAR")
|
|
835
|
-
return None
|
|
836
|
-
|
|
831
|
+
# Download JAR from GitHub releases
|
|
832
|
+
jar_url = "https://github.com/getodk/validate/releases/download/v1.19.2/validate.jar"
|
|
837
833
|
try:
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
zip_ref.extract(jar_in_zip, os.path.dirname(__file__))
|
|
842
|
-
|
|
843
|
-
# Move to final location
|
|
844
|
-
extracted_jar = os.path.join(os.path.dirname(__file__), jar_in_zip)
|
|
845
|
-
shutil.move(extracted_jar, jar_path)
|
|
846
|
-
|
|
847
|
-
logger.info(f"Extracted ODK Validate JAR to {jar_path}")
|
|
834
|
+
import urllib.request
|
|
835
|
+
urllib.request.urlretrieve(jar_url, jar_path)
|
|
836
|
+
logger.info(f"Downloaded ODK Validate JAR to {jar_path}")
|
|
848
837
|
return jar_path
|
|
849
|
-
|
|
850
838
|
except Exception as e:
|
|
851
|
-
logger.error(f"Failed to
|
|
839
|
+
logger.error(f"Failed to download ODK Validate JAR: {str(e)}")
|
|
852
840
|
return None
|
|
853
841
|
|
|
854
842
|
def tricc_operation_zscore(self, ref_expressions):
|
|
@@ -57,6 +57,16 @@ logger = logging.getLogger("default")
|
|
|
57
57
|
ONE_QUESTION_AT_A_TIME = False
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
def get_main_activity(activity, processed_nodes):
|
|
61
|
+
"""Traverse up the activity hierarchy to find the main activity (root activity)."""
|
|
62
|
+
activities = list(set(
|
|
63
|
+
n.activity for n in activity.relevance.get_references()
|
|
64
|
+
if hasattr(n, 'activity') and n.activity != activity and n.activity.root in processed_nodes
|
|
65
|
+
))
|
|
66
|
+
if activities:
|
|
67
|
+
return activities[0]
|
|
68
|
+
|
|
69
|
+
|
|
60
70
|
def merge_node(from_node, to_node):
|
|
61
71
|
if from_node.activity != to_node.activity:
|
|
62
72
|
logger.critical("Cannot merge nodes from different activities")
|
|
@@ -123,7 +133,7 @@ def get_last_version(name, processed_nodes, _list=None):
|
|
|
123
133
|
def get_node_expressions(node, processed_nodes, process=None):
|
|
124
134
|
get_overall_exp = issubclass(
|
|
125
135
|
node.__class__,
|
|
126
|
-
(TriccNodeDisplayCalculateBase, TriccNodeProposedDiagnosis, TriccNodeDiagnosis)
|
|
136
|
+
(TriccNodeDisplayCalculateBase, TriccNodeProposedDiagnosis, TriccNodeDiagnosis, TriccNodeActivity)
|
|
127
137
|
) and not isinstance(node, (TriccNodeDisplayBridge))
|
|
128
138
|
expression = None
|
|
129
139
|
# in case of recursive call processed_nodes will be None
|
|
@@ -245,7 +255,29 @@ def load_calculate(
|
|
|
245
255
|
if hasattr(node, "relevance") and (node.relevance is None or isinstance(node.relevance, TriccOperation)):
|
|
246
256
|
node.relevance = get_node_expressions(node, processed_nodes=processed_nodes, process=process)
|
|
247
257
|
# manage not Available
|
|
248
|
-
if isinstance(node,
|
|
258
|
+
if isinstance(node, TriccNodeActivity) and isinstance(node.root, TriccNodeActivityStart):
|
|
259
|
+
past_instances = len(getattr(node.base_instance, "instances", []))
|
|
260
|
+
group_calc_required = False # (len(str(node.relevance)) > 50 or past_instances > 1 or len(node.calculates)>0)
|
|
261
|
+
calc = None
|
|
262
|
+
|
|
263
|
+
if group_calc_required and getattr(node.relevance, 'operator', None) != TriccOperator.ISTRUE:
|
|
264
|
+
main_activity = get_main_activity(node, processed_nodes)
|
|
265
|
+
if main_activity:
|
|
266
|
+
calc = TriccNodeCalculate(
|
|
267
|
+
id=generate_id(f"gc.{node.id}"),
|
|
268
|
+
group=main_activity.group,
|
|
269
|
+
activity=main_activity,
|
|
270
|
+
name=f"gc.{node.name}",
|
|
271
|
+
expression_reference=node.relevance.copy()
|
|
272
|
+
)
|
|
273
|
+
main_activity.calculates.append(calc)
|
|
274
|
+
main_activity.nodes[calc.id] = calc
|
|
275
|
+
processed_nodes.add(calc)
|
|
276
|
+
node.relevance = TriccOperation(
|
|
277
|
+
TriccOperator.ISTRUE,
|
|
278
|
+
[calc]
|
|
279
|
+
)
|
|
280
|
+
elif isinstance(node, TriccNodeSelectNotAvailable):
|
|
249
281
|
# update the checkbox
|
|
250
282
|
if node.parent:
|
|
251
283
|
if len(node.prev_nodes) == 1:
|
|
@@ -1735,14 +1767,14 @@ def replace_next_node(prev_node, next_node, old_node):
|
|
|
1735
1767
|
|
|
1736
1768
|
|
|
1737
1769
|
# Priority constants
|
|
1738
|
-
SAME_GROUP_PRIORITY =
|
|
1739
|
-
PARENT_GROUP_PRIORITY =
|
|
1740
|
-
ACTIVE_ACTIVITY_PRIORITY =
|
|
1741
|
-
NON_START_ACTIVITY_PRIORITY =
|
|
1742
|
-
ACTIVE_ACTIVITY_LOWER_PRIORITY =
|
|
1743
|
-
FLOW_CALCULATE_NODE_PRIORITY =
|
|
1770
|
+
SAME_GROUP_PRIORITY = 4000
|
|
1771
|
+
PARENT_GROUP_PRIORITY = 3000
|
|
1772
|
+
ACTIVE_ACTIVITY_PRIORITY = 1400
|
|
1773
|
+
NON_START_ACTIVITY_PRIORITY = 1300
|
|
1774
|
+
ACTIVE_ACTIVITY_LOWER_PRIORITY = 1200
|
|
1775
|
+
FLOW_CALCULATE_NODE_PRIORITY = 2000
|
|
1744
1776
|
RHOMBUS_PRIORITY = 1000
|
|
1745
|
-
DEFAULT_PRIORITY =
|
|
1777
|
+
DEFAULT_PRIORITY = 1100
|
|
1746
1778
|
|
|
1747
1779
|
|
|
1748
1780
|
def reorder_node_list(node_list, group, processed_nodes):
|
|
@@ -1780,6 +1812,8 @@ def reorder_node_list(node_list, group, processed_nodes):
|
|
|
1780
1812
|
priority += RHOMBUS_PRIORITY
|
|
1781
1813
|
else:
|
|
1782
1814
|
priority += DEFAULT_PRIORITY
|
|
1815
|
+
|
|
1816
|
+
priority = max(priority, max((get_priority(prev_node) for prev_node in node.prev_nodes), default=0))
|
|
1783
1817
|
|
|
1784
1818
|
return priority
|
|
1785
1819
|
|
|
@@ -1829,6 +1863,7 @@ def get_node_expression(in_node, processed_nodes, get_overall_exp=False, is_prev
|
|
|
1829
1863
|
expression = None
|
|
1830
1864
|
negate_expression = None
|
|
1831
1865
|
node = in_node
|
|
1866
|
+
|
|
1832
1867
|
if isinstance(node, (TriccNodeActivityStart, TriccNodeMainStart)):
|
|
1833
1868
|
if is_prev and get_overall_exp:
|
|
1834
1869
|
expression = get_node_expression(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|