tricc-oo 1.5.22__py3-none-any.whl → 1.5.24__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.
- tests/build.py +17 -23
- tests/test_cql.py +37 -108
- tests/to_ocl.py +15 -17
- tricc_oo/__init__.py +0 -6
- tricc_oo/converters/codesystem_to_ocl.py +51 -40
- tricc_oo/converters/cql/cqlLexer.py +1 -0
- tricc_oo/converters/cql/cqlListener.py +1 -0
- tricc_oo/converters/cql/cqlParser.py +1 -0
- tricc_oo/converters/cql/cqlVisitor.py +1 -0
- tricc_oo/converters/cql_to_operation.py +125 -123
- tricc_oo/converters/datadictionnary.py +45 -54
- tricc_oo/converters/drawio_type_map.py +143 -61
- tricc_oo/converters/tricc_to_xls_form.py +14 -24
- tricc_oo/converters/utils.py +3 -3
- tricc_oo/converters/xml_to_tricc.py +286 -231
- tricc_oo/models/__init__.py +2 -1
- tricc_oo/models/base.py +300 -308
- tricc_oo/models/calculate.py +63 -49
- tricc_oo/models/lang.py +26 -27
- tricc_oo/models/ocl.py +146 -161
- tricc_oo/models/ordered_set.py +15 -19
- tricc_oo/models/tricc.py +145 -89
- tricc_oo/parsers/xml.py +15 -30
- tricc_oo/serializers/planuml.py +4 -6
- tricc_oo/serializers/xls_form.py +81 -135
- tricc_oo/strategies/input/base_input_strategy.py +28 -32
- tricc_oo/strategies/input/drawio.py +59 -71
- tricc_oo/strategies/output/base_output_strategy.py +142 -67
- tricc_oo/strategies/output/fhir_form.py +377 -0
- tricc_oo/strategies/output/html_form.py +224 -0
- tricc_oo/strategies/output/openmrs_form.py +647 -0
- tricc_oo/strategies/output/spice.py +106 -127
- tricc_oo/strategies/output/xls_form.py +263 -222
- tricc_oo/strategies/output/xlsform_cdss.py +623 -142
- tricc_oo/strategies/output/xlsform_cht.py +108 -115
- tricc_oo/strategies/output/xlsform_cht_hf.py +13 -24
- tricc_oo/visitors/tricc.py +1297 -1016
- tricc_oo/visitors/utils.py +16 -16
- tricc_oo/visitors/xform_pd.py +91 -89
- {tricc_oo-1.5.22.dist-info → tricc_oo-1.5.24.dist-info}/METADATA +127 -84
- tricc_oo-1.5.24.dist-info/RECORD +50 -0
- tricc_oo-1.5.24.dist-info/licenses/LICENSE +373 -0
- tricc_oo-1.5.22.dist-info/RECORD +0 -46
- {tricc_oo-1.5.22.dist-info → tricc_oo-1.5.24.dist-info}/WHEEL +0 -0
- {tricc_oo-1.5.22.dist-info → tricc_oo-1.5.24.dist-info}/top_level.txt +0 -0
tricc_oo/serializers/xls_form.py
CHANGED
|
@@ -3,15 +3,28 @@ import hashlib
|
|
|
3
3
|
|
|
4
4
|
# from bs4 import BeautifulSoup
|
|
5
5
|
from tricc_oo.converters.tricc_to_xls_form import (
|
|
6
|
-
negate_term,
|
|
7
|
-
VERSION_SEPARATOR,
|
|
8
|
-
INSTANCE_SEPARATOR,
|
|
9
6
|
get_export_name,
|
|
10
7
|
)
|
|
11
|
-
from tricc_oo.converters.utils import clean_name, remove_html
|
|
12
8
|
from tricc_oo.models.lang import SingletonLangClass
|
|
13
|
-
from tricc_oo.
|
|
14
|
-
import
|
|
9
|
+
from tricc_oo.converters.utils import clean_name, remove_html
|
|
10
|
+
from tricc_oo.models.base import (
|
|
11
|
+
TriccOperator,
|
|
12
|
+
TriccOperation, TriccStatic, TriccReference, and_join, TriccNodeType
|
|
13
|
+
)
|
|
14
|
+
from tricc_oo.models.calculate import (
|
|
15
|
+
TriccNodeDisplayCalculateBase,
|
|
16
|
+
|
|
17
|
+
)
|
|
18
|
+
from tricc_oo.models.tricc import (
|
|
19
|
+
TriccNodeActivity, TriccNodeBaseModel, TriccNodeSelectMultiple, TriccNodeSelectOption,
|
|
20
|
+
TriccNodeSelectOne,
|
|
21
|
+
TriccNodeSelect,
|
|
22
|
+
TriccNodeMoreInfo,
|
|
23
|
+
TriccNodeDisplayModel,
|
|
24
|
+
TriccNodeAcceptDiagnostic,
|
|
25
|
+
TriccNodeNote,
|
|
26
|
+
)
|
|
27
|
+
from typing import Dict
|
|
15
28
|
from tricc_oo.visitors.tricc import (
|
|
16
29
|
is_ready_to_process,
|
|
17
30
|
process_reference,
|
|
@@ -35,7 +48,15 @@ BOOLEAN_MAP = {
|
|
|
35
48
|
|
|
36
49
|
|
|
37
50
|
def start_group(
|
|
38
|
-
strategy,
|
|
51
|
+
strategy,
|
|
52
|
+
cur_group,
|
|
53
|
+
groups,
|
|
54
|
+
df_survey,
|
|
55
|
+
df_calculate,
|
|
56
|
+
processed_nodes,
|
|
57
|
+
process,
|
|
58
|
+
relevance=False,
|
|
59
|
+
**kwargs,
|
|
39
60
|
):
|
|
40
61
|
name = get_export_name(cur_group)
|
|
41
62
|
|
|
@@ -46,34 +67,26 @@ def start_group(
|
|
|
46
67
|
else:
|
|
47
68
|
groups[name] = 0
|
|
48
69
|
is_activity = isinstance(cur_group, TriccNodeActivity)
|
|
49
|
-
relevance =
|
|
50
|
-
relevance and cur_group.relevance is not None and cur_group.relevance != ""
|
|
51
|
-
)
|
|
52
|
-
|
|
70
|
+
relevance = relevance and cur_group.relevance is not None and cur_group.relevance != ""
|
|
53
71
|
|
|
54
|
-
group_calc_required = (
|
|
55
|
-
False and relevance and not is_activity and len(relevance) > 100
|
|
56
|
-
)
|
|
72
|
+
group_calc_required = False and relevance and not is_activity and len(relevance) > 100
|
|
57
73
|
|
|
58
74
|
relevance_expression = cur_group.relevance
|
|
59
75
|
relevance_expression = get_applicability_expression(cur_group, processed_nodes, process, relevance_expression)
|
|
60
76
|
relevance_expression = get_prev_instance_skip_expression(cur_group, processed_nodes, process, relevance_expression)
|
|
61
77
|
relevance_expression = get_process_skip_expression(cur_group, processed_nodes, process, relevance_expression)
|
|
62
|
-
|
|
78
|
+
|
|
63
79
|
if not relevance:
|
|
64
80
|
relevance_expression = ""
|
|
65
81
|
elif isinstance(relevance_expression, (TriccOperation, TriccStatic)):
|
|
66
|
-
relevance_expression = strategy.get_tricc_operation_expression(
|
|
67
|
-
relevance_expression
|
|
68
|
-
)
|
|
69
|
-
|
|
82
|
+
relevance_expression = strategy.get_tricc_operation_expression(relevance_expression)
|
|
70
83
|
|
|
71
84
|
# elif is_activity:
|
|
72
85
|
# relevance_expression = TRICC_CALC_EXPRESSION.format(get_export_name(cur_group.root))
|
|
73
86
|
elif group_calc_required:
|
|
74
87
|
relevance_expression = TRICC_CALC_EXPRESSION.format("gcalc_" + name)
|
|
75
88
|
|
|
76
|
-
|
|
89
|
+
# group
|
|
77
90
|
values = []
|
|
78
91
|
for column in SURVEY_MAP:
|
|
79
92
|
if column == "type":
|
|
@@ -92,11 +105,8 @@ def start_group(
|
|
|
92
105
|
values.append(get_xfrom_trad(strategy, cur_group, column, SURVEY_MAP))
|
|
93
106
|
df_survey.loc[len(df_survey)] = values
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
group_calc_required
|
|
98
|
-
and len(df_calculate[df_calculate["name"] == "gcalc_" + name]) == 0
|
|
99
|
-
):
|
|
108
|
+
# calc
|
|
109
|
+
if group_calc_required and len(df_calculate[df_calculate["name"] == "gcalc_" + name]) == 0:
|
|
100
110
|
calc_values = []
|
|
101
111
|
for column in SURVEY_MAP:
|
|
102
112
|
if column == "type":
|
|
@@ -105,15 +115,11 @@ def start_group(
|
|
|
105
115
|
value = "gcalc_" + name
|
|
106
116
|
calc_values.append(value)
|
|
107
117
|
elif column == "calculation":
|
|
108
|
-
calc_values.append(
|
|
109
|
-
get_attr_if_exists(strategy, cur_group, "relevance", SURVEY_MAP)
|
|
110
|
-
)
|
|
118
|
+
calc_values.append(get_attr_if_exists(strategy, cur_group, "relevance", SURVEY_MAP))
|
|
111
119
|
elif column == "relevance":
|
|
112
120
|
calc_values.append("")
|
|
113
121
|
else:
|
|
114
|
-
calc_values.append(
|
|
115
|
-
get_xfrom_trad(strategy, cur_group, column, SURVEY_MAP)
|
|
116
|
-
)
|
|
122
|
+
calc_values.append(get_xfrom_trad(strategy, cur_group, column, SURVEY_MAP))
|
|
117
123
|
|
|
118
124
|
df_calculate.loc[len(df_calculate)] = calc_values
|
|
119
125
|
|
|
@@ -177,7 +183,8 @@ def end_group(strategy, cur_group, groups, df_survey, **kwargs):
|
|
|
177
183
|
# if reference not in used_saves
|
|
178
184
|
# , then create calculate node reference_1 # and save is used_saves 'reference' : 1
|
|
179
185
|
# else create calculate node reference_(used_saves['reference']+1) # and update used_saves['reference'] += 1
|
|
180
|
-
# once done, walkthrough again and remame
|
|
186
|
+
# once done, walkthrough again and remame
|
|
187
|
+
# reference_(used_saves['reference']) to reference and create the other save
|
|
181
188
|
|
|
182
189
|
|
|
183
190
|
ODK_TRICC_TYPE_MAP = {
|
|
@@ -258,8 +265,6 @@ def get_xfrom_trad(strategy, node, column, mapping, clean_html=False):
|
|
|
258
265
|
new_column = arr[0] if arr[0] != "media" else "::".join(arr[0:2])
|
|
259
266
|
trad = arr[-1] if new_column != column else None
|
|
260
267
|
value = get_attr_if_exists(strategy, node, new_column, mapping)
|
|
261
|
-
# the pattern is to look for if that define a string if(test>0, 'strin')
|
|
262
|
-
pattern = r"concat\(|[^\}] *, *'[^']"
|
|
263
268
|
if (
|
|
264
269
|
issubclass(node.__class__, TriccNodeDisplayCalculateBase)
|
|
265
270
|
and column == "calculation"
|
|
@@ -282,12 +287,7 @@ def get_xfrom_trad(strategy, node, column, mapping, clean_html=False):
|
|
|
282
287
|
value = "autocomplete"
|
|
283
288
|
elif isinstance(node, TriccNodeNote) and "countdown-timer" in node.name:
|
|
284
289
|
value = "countdown-timer"
|
|
285
|
-
elif (
|
|
286
|
-
column == "appearance"
|
|
287
|
-
and isinstance(node, TriccNodeAcceptDiagnostic)
|
|
288
|
-
and node.severity
|
|
289
|
-
and not value
|
|
290
|
-
):
|
|
290
|
+
elif column == "appearance" and isinstance(node, TriccNodeAcceptDiagnostic) and node.severity and not value:
|
|
291
291
|
if node.severity == "severe":
|
|
292
292
|
value = "severe"
|
|
293
293
|
elif node.severity == "moderate":
|
|
@@ -311,7 +311,6 @@ def generate_choice_filter(strategy, node):
|
|
|
311
311
|
if not isinstance(node, (TriccNodeSelectMultiple, TriccNodeSelectOne)):
|
|
312
312
|
return
|
|
313
313
|
relevances = {}
|
|
314
|
-
option_filter = {}
|
|
315
314
|
for o in node.options.values():
|
|
316
315
|
if o.relevance and o.relevance != TriccStatic(True):
|
|
317
316
|
key = gen_operation_hash(o.relevance)
|
|
@@ -321,9 +320,7 @@ def generate_choice_filter(strategy, node):
|
|
|
321
320
|
basic = "string-length(choice_filter)=0"
|
|
322
321
|
# TODO remove when the bug regarding filter + image will be fixed
|
|
323
322
|
if any(i.image is not None for i in node.options.values()):
|
|
324
|
-
basic = TriccOperation(
|
|
325
|
-
TriccOperator.AND, ["string-length(choice_filter)=0", node.relevance]
|
|
326
|
-
)
|
|
323
|
+
basic = TriccOperation(TriccOperator.AND, ["string-length(choice_filter)=0", node.relevance])
|
|
327
324
|
|
|
328
325
|
choice_filter = TriccOperation(TriccOperator.OR, [basic])
|
|
329
326
|
for k, op in relevances.items():
|
|
@@ -348,10 +345,7 @@ def generate_choice_filter(strategy, node):
|
|
|
348
345
|
def get_attr_if_exists(strategy, node, column, map_array):
|
|
349
346
|
if column in map_array:
|
|
350
347
|
mapping = map_array[column]
|
|
351
|
-
if (
|
|
352
|
-
isinstance(mapping, Dict)
|
|
353
|
-
and getattr(node, "tricc_type", None) in map_array[column]
|
|
354
|
-
):
|
|
348
|
+
if isinstance(mapping, Dict) and getattr(node, "tricc_type", None) in map_array[column]:
|
|
355
349
|
tricc_type = map_array[column][node.tricc_type]
|
|
356
350
|
if tricc_type[:6] == "select":
|
|
357
351
|
return tricc_type + " " + node.list_name
|
|
@@ -376,11 +370,7 @@ def get_attr_if_exists(strategy, node, column, map_array):
|
|
|
376
370
|
[
|
|
377
371
|
node.applicability,
|
|
378
372
|
value,
|
|
379
|
-
(
|
|
380
|
-
TriccStatic(False)
|
|
381
|
-
if node.applicability.get_datatype() == "boolean"
|
|
382
|
-
else TriccStatic("")
|
|
383
|
-
),
|
|
373
|
+
(TriccStatic(False) if node.applicability.get_datatype() == "boolean" else TriccStatic("")),
|
|
384
374
|
],
|
|
385
375
|
)
|
|
386
376
|
if column == "name":
|
|
@@ -394,11 +384,7 @@ def get_attr_if_exists(strategy, node, column, map_array):
|
|
|
394
384
|
|
|
395
385
|
elif isinstance(value, (TriccOperation, TriccStatic, TriccReference)):
|
|
396
386
|
expression = strategy.get_tricc_operation_expression(value)
|
|
397
|
-
return (
|
|
398
|
-
expression.replace("$this", ".")
|
|
399
|
-
if isinstance(expression, str)
|
|
400
|
-
else expression
|
|
401
|
-
)
|
|
387
|
+
return expression.replace("$this", ".") if isinstance(expression, str) else expression
|
|
402
388
|
elif value is not None:
|
|
403
389
|
return str(value) if not isinstance(value, dict) else value
|
|
404
390
|
else:
|
|
@@ -426,9 +412,7 @@ def get_more_info_select(strategy, node):
|
|
|
426
412
|
values.append(get_export_name(node) + "_optin")
|
|
427
413
|
elif column == "hint":
|
|
428
414
|
print(get_xfrom_trad(strategy, node, column, SURVEY_MAP, clean_html=True))
|
|
429
|
-
values.append(
|
|
430
|
-
get_xfrom_trad(strategy, node, column, SURVEY_MAP, clean_html=True)
|
|
431
|
-
)
|
|
415
|
+
values.append(get_xfrom_trad(strategy, node, column, SURVEY_MAP, clean_html=True))
|
|
432
416
|
elif column == "relevance":
|
|
433
417
|
values.append(get_xfrom_trad(strategy, node.parent, column, SURVEY_MAP))
|
|
434
418
|
else:
|
|
@@ -446,9 +430,7 @@ def get_more_info_message(strategy, node):
|
|
|
446
430
|
elif column.startswith("hint"):
|
|
447
431
|
values.append(langs.get_trads("", trad=None))
|
|
448
432
|
else:
|
|
449
|
-
values.append(
|
|
450
|
-
get_xfrom_trad(strategy, node, column, SURVEY_MAP, clean_html=True)
|
|
451
|
-
)
|
|
433
|
+
values.append(get_xfrom_trad(strategy, node, column, SURVEY_MAP, clean_html=True))
|
|
452
434
|
return values
|
|
453
435
|
|
|
454
436
|
|
|
@@ -499,29 +481,18 @@ def generate_xls_form_export(
|
|
|
499
481
|
if node in stashed_nodes:
|
|
500
482
|
stashed_nodes.remove(node)
|
|
501
483
|
if kwargs.get("warn", True):
|
|
502
|
-
logger.debug(
|
|
503
|
-
|
|
504
|
-
node.get_name()
|
|
505
|
-
)
|
|
506
|
-
)
|
|
507
|
-
if issubclass(
|
|
508
|
-
node.__class__, (TriccNodeDisplayCalculateBase, TriccNodeDisplayModel)
|
|
509
|
-
):
|
|
484
|
+
logger.debug("generate_xls_form_export: unstashing processed node{} ".format(node.get_name()))
|
|
485
|
+
if issubclass(node.__class__, (TriccNodeDisplayCalculateBase, TriccNodeDisplayModel)):
|
|
510
486
|
if isinstance(node, TriccNodeSelectOption):
|
|
511
487
|
values = []
|
|
512
488
|
for column in CHOICE_MAP:
|
|
513
|
-
values.append(
|
|
514
|
-
get_xfrom_trad(strategy, node, column, CHOICE_MAP, True)
|
|
515
|
-
)
|
|
489
|
+
values.append(get_xfrom_trad(strategy, node, column, CHOICE_MAP, True))
|
|
516
490
|
# add only if not existing
|
|
517
491
|
if (
|
|
518
492
|
len(
|
|
519
493
|
df_choice[
|
|
520
494
|
(df_choice["list_name"] == node.list_name)
|
|
521
|
-
& (
|
|
522
|
-
df_choice["value"]
|
|
523
|
-
== BOOLEAN_MAP.get(str(node.name), node.name)
|
|
524
|
-
)
|
|
495
|
+
& (df_choice["value"] == BOOLEAN_MAP.get(str(node.name), node.name))
|
|
525
496
|
]
|
|
526
497
|
)
|
|
527
498
|
== 0
|
|
@@ -529,34 +500,22 @@ def generate_xls_form_export(
|
|
|
529
500
|
df_choice.loc[len(df_choice)] = values
|
|
530
501
|
elif isinstance(node, TriccNodeMoreInfo):
|
|
531
502
|
df_survey.loc[len(df_survey)] = get_more_info_select(strategy, node)
|
|
532
|
-
df_survey.loc[len(df_survey)] = get_more_info_message(
|
|
533
|
-
strategy, node
|
|
534
|
-
)
|
|
503
|
+
df_survey.loc[len(df_survey)] = get_more_info_message(strategy, node)
|
|
535
504
|
if len(df_choice[(df_choice["list_name"] == "more_info")]) == 0:
|
|
536
505
|
df_choice.loc[len(df_choice)] = get_more_info_choice(strategy)
|
|
537
|
-
elif
|
|
538
|
-
node.tricc_type in ODK_TRICC_TYPE_MAP
|
|
539
|
-
and ODK_TRICC_TYPE_MAP[node.tricc_type] is not None
|
|
540
|
-
):
|
|
506
|
+
elif node.tricc_type in ODK_TRICC_TYPE_MAP and ODK_TRICC_TYPE_MAP[node.tricc_type] is not None:
|
|
541
507
|
if ODK_TRICC_TYPE_MAP[node.tricc_type] == "calculate":
|
|
542
508
|
values = []
|
|
543
509
|
for column in SURVEY_MAP:
|
|
544
510
|
value = get_xfrom_trad(strategy, node, column, SURVEY_MAP)
|
|
545
511
|
if (
|
|
546
512
|
column == "default"
|
|
547
|
-
and issubclass(
|
|
548
|
-
node.__class__, TriccNodeDisplayCalculateBase
|
|
549
|
-
)
|
|
513
|
+
and issubclass(node.__class__, TriccNodeDisplayCalculateBase)
|
|
550
514
|
and value == ""
|
|
551
515
|
):
|
|
552
516
|
value = 0
|
|
553
517
|
values.append(value)
|
|
554
|
-
if (
|
|
555
|
-
len(
|
|
556
|
-
df_calculate[df_calculate.name == get_export_name(node)]
|
|
557
|
-
)
|
|
558
|
-
== 0
|
|
559
|
-
):
|
|
518
|
+
if len(df_calculate[df_calculate.name == get_export_name(node)]) == 0:
|
|
560
519
|
df_calculate.loc[len(df_calculate)] = values
|
|
561
520
|
else:
|
|
562
521
|
df_calculate.loc[len(df_calculate)] = values
|
|
@@ -564,29 +523,19 @@ def generate_xls_form_export(
|
|
|
564
523
|
elif ODK_TRICC_TYPE_MAP[node.tricc_type] != "":
|
|
565
524
|
values = []
|
|
566
525
|
for column in SURVEY_MAP:
|
|
567
|
-
values.append(
|
|
568
|
-
get_xfrom_trad(strategy, node, column, SURVEY_MAP)
|
|
569
|
-
)
|
|
526
|
+
values.append(get_xfrom_trad(strategy, node, column, SURVEY_MAP))
|
|
570
527
|
df_survey.loc[len(df_survey)] = values
|
|
571
528
|
else:
|
|
572
|
-
logger.warning(
|
|
573
|
-
"node {} have an unmapped type {}".format(
|
|
574
|
-
node.get_name(), node.tricc_type
|
|
575
|
-
)
|
|
576
|
-
)
|
|
529
|
+
logger.warning("node {} have an unmapped type {}".format(node.get_name(), node.tricc_type))
|
|
577
530
|
else:
|
|
578
|
-
logger.warning(
|
|
579
|
-
"node {} have an unsupported type {}".format(
|
|
580
|
-
node.get_name(), node.tricc_type
|
|
581
|
-
)
|
|
582
|
-
)
|
|
531
|
+
logger.warning("node {} have an unsupported type {}".format(node.get_name(), node.tricc_type))
|
|
583
532
|
# continue walk °
|
|
584
533
|
return True
|
|
585
534
|
return False
|
|
586
535
|
|
|
587
536
|
|
|
588
537
|
def get_input_line(node, replace_dots=True):
|
|
589
|
-
label = langs.get_trads(node.label, force_dict=True)
|
|
538
|
+
# label = langs.get_trads(node.label, force_dict=True)
|
|
590
539
|
empty = langs.get_trads("", force_dict=True)
|
|
591
540
|
return [
|
|
592
541
|
"hidden",
|
|
@@ -595,24 +544,24 @@ def get_input_line(node, replace_dots=True):
|
|
|
595
544
|
*list(empty.values()), # hint
|
|
596
545
|
*list(empty.values()), # help
|
|
597
546
|
"", # default
|
|
598
|
-
"hidden", #'appearance', clean_name
|
|
599
|
-
"", #'constraint',
|
|
600
|
-
*list(empty.values()), #'constraint_message'
|
|
601
|
-
"", #'relevance'
|
|
602
|
-
"", #'disabled'
|
|
603
|
-
"", #'required'
|
|
604
|
-
*list(empty.values()), #'required message'
|
|
605
|
-
"", #'read only'
|
|
547
|
+
"hidden", # 'appearance', clean_name
|
|
548
|
+
"", # 'constraint',
|
|
549
|
+
*list(empty.values()), # 'constraint_message'
|
|
550
|
+
"", # 'relevance'
|
|
551
|
+
"", # 'disabled'
|
|
552
|
+
"", # 'required'
|
|
553
|
+
*list(empty.values()), # 'required message'
|
|
554
|
+
"", # 'read only'
|
|
606
555
|
"",
|
|
607
|
-
"", #'expression'
|
|
608
|
-
"", #'repeat_count'
|
|
609
|
-
"", #'image'
|
|
556
|
+
"", # 'expression'
|
|
557
|
+
"", # 'repeat_count'
|
|
558
|
+
"", # 'image'
|
|
610
559
|
"",
|
|
611
560
|
]
|
|
612
561
|
|
|
613
562
|
|
|
614
563
|
def get_input_calc_line(node, replace_dots=True):
|
|
615
|
-
label = langs.get_trads(node.label, force_dict=True)
|
|
564
|
+
# label = langs.get_trads(node.label, force_dict=True)
|
|
616
565
|
empty = langs.get_trads("", force_dict=True)
|
|
617
566
|
return [
|
|
618
567
|
"calculate",
|
|
@@ -621,20 +570,17 @@ def get_input_calc_line(node, replace_dots=True):
|
|
|
621
570
|
*list(empty.values()), # hint
|
|
622
571
|
*list(empty.values()), # help
|
|
623
572
|
"", # default
|
|
624
|
-
"", #'appearance', clean_name
|
|
625
|
-
"", #'constraint',
|
|
626
|
-
*list(empty.values()), #'constraint_message'
|
|
627
|
-
"", #'relevance'
|
|
628
|
-
"", #'disabled'
|
|
629
|
-
"", #'required'
|
|
630
|
-
*list(empty.values()), #'required message'
|
|
631
|
-
"", #'read only'
|
|
632
|
-
"../inputs/contact/"
|
|
633
|
-
+ clean_name(node.name, replace_dots=replace_dots), #'expression'
|
|
573
|
+
"", # 'appearance', clean_name
|
|
574
|
+
"", # 'constraint',
|
|
575
|
+
*list(empty.values()), # 'constraint_message'
|
|
576
|
+
"", # 'relevance'
|
|
577
|
+
"", # 'disabled'
|
|
578
|
+
"", # 'required'
|
|
579
|
+
*list(empty.values()), # 'required message'
|
|
580
|
+
"", # 'read only'
|
|
581
|
+
"../inputs/contact/" + clean_name(node.name, replace_dots=replace_dots), # 'expression'
|
|
634
582
|
"",
|
|
635
|
-
"", #'repeat_count'
|
|
636
|
-
"", #'image'
|
|
583
|
+
"", # 'repeat_count'
|
|
584
|
+
"", # 'image'
|
|
637
585
|
"", # choice filter
|
|
638
586
|
]
|
|
639
|
-
|
|
640
|
-
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import abc
|
|
2
2
|
|
|
3
|
-
from tricc_oo.models import (
|
|
3
|
+
from tricc_oo.models.tricc import (
|
|
4
4
|
TriccNodeMainStart,
|
|
5
5
|
TriccNodeActivity,
|
|
6
|
-
TriccEdge,
|
|
7
6
|
)
|
|
8
7
|
from tricc_oo.converters.utils import generate_id
|
|
9
8
|
from tricc_oo.visitors.tricc import (
|
|
10
9
|
get_activity_wait,
|
|
11
|
-
stashed_node_func,
|
|
12
10
|
set_prev_next_node,
|
|
13
11
|
export_proposed_diags,
|
|
14
|
-
create_determine_diagnosis_activity
|
|
12
|
+
create_determine_diagnosis_activity,
|
|
15
13
|
)
|
|
16
|
-
from itertools import chain
|
|
17
14
|
import logging
|
|
18
15
|
|
|
19
16
|
logger = logging.getLogger("default")
|
|
@@ -27,7 +24,14 @@ class BaseInputStrategy:
|
|
|
27
24
|
def execute_linked_process(self, project):
|
|
28
25
|
# create an overall activity only if not specified
|
|
29
26
|
if "main" not in project.start_pages:
|
|
30
|
-
page_processes = [
|
|
27
|
+
page_processes = [
|
|
28
|
+
(
|
|
29
|
+
p.root.process,
|
|
30
|
+
p,
|
|
31
|
+
)
|
|
32
|
+
for p in list(project.pages.values())
|
|
33
|
+
if getattr(p.root, "process", None)
|
|
34
|
+
]
|
|
31
35
|
sorted_pages = {}
|
|
32
36
|
diags = []
|
|
33
37
|
for a in project.pages.values():
|
|
@@ -38,34 +42,31 @@ class BaseInputStrategy:
|
|
|
38
42
|
if diag.name not in seen_diags:
|
|
39
43
|
unique_diags.append(diag)
|
|
40
44
|
seen_diags.add(diag.name)
|
|
41
|
-
severity_order = {
|
|
42
|
-
unique_diags = sorted(
|
|
45
|
+
severity_order = {"severe": 3, "moderate": 2, "mild": 1, "light": 0}
|
|
46
|
+
unique_diags = sorted(
|
|
47
|
+
unique_diags,
|
|
48
|
+
key=lambda x: (
|
|
49
|
+
-getattr(severity_order, x.severity or "light", 0),
|
|
50
|
+
x.label,
|
|
51
|
+
),
|
|
52
|
+
)
|
|
43
53
|
for process in self.processes:
|
|
44
54
|
if process in [p[0] for p in page_processes]:
|
|
45
|
-
sorted_pages[process] = [
|
|
46
|
-
|
|
47
|
-
]
|
|
48
|
-
elif process == 'determine-diagnosis' and diags:
|
|
55
|
+
sorted_pages[process] = [p[1] for p in page_processes if p[0] == process]
|
|
56
|
+
elif process == "determine-diagnosis" and diags:
|
|
49
57
|
diags_activity = create_determine_diagnosis_activity(unique_diags)
|
|
50
|
-
sorted_pages[process] = [
|
|
51
|
-
|
|
52
|
-
]
|
|
53
|
-
project.start_pages['determine-diagnosis'] = diags_activity
|
|
58
|
+
sorted_pages[process] = [diags_activity]
|
|
59
|
+
project.start_pages["determine-diagnosis"] = diags_activity
|
|
54
60
|
root_process = sorted_pages[list(sorted_pages.keys())[0]][0].root
|
|
55
61
|
root = TriccNodeMainStart(
|
|
56
|
-
id=generate_id(
|
|
62
|
+
id=generate_id("s-main"),
|
|
57
63
|
form_id=root_process.form_id,
|
|
58
64
|
label=root_process.label,
|
|
59
|
-
process=
|
|
65
|
+
process="main",
|
|
60
66
|
)
|
|
61
67
|
nodes = {}
|
|
62
68
|
nodes[root.id] = root
|
|
63
|
-
app = TriccNodeActivity(
|
|
64
|
-
id=generate_id('a-main'),
|
|
65
|
-
name=root_process.name,
|
|
66
|
-
root=root,
|
|
67
|
-
nodes=nodes
|
|
68
|
-
)
|
|
69
|
+
app = TriccNodeActivity(id=generate_id("a-main"), name=root_process.name, root=root, nodes=nodes)
|
|
69
70
|
root.activity = app
|
|
70
71
|
# loop back to app to avoid None
|
|
71
72
|
app.activity = app
|
|
@@ -85,20 +86,15 @@ class BaseInputStrategy:
|
|
|
85
86
|
)
|
|
86
87
|
else:
|
|
87
88
|
for a in nodes:
|
|
88
|
-
set_prev_next_node(
|
|
89
|
-
prev_bridge,
|
|
90
|
-
a,
|
|
91
|
-
edge_only=True
|
|
92
|
-
)
|
|
89
|
+
set_prev_next_node(prev_bridge, a, edge_only=True)
|
|
93
90
|
app.nodes[prev_bridge.id] = prev_bridge
|
|
94
|
-
|
|
91
|
+
|
|
95
92
|
for n in nodes.values():
|
|
96
93
|
n.activity = app
|
|
97
94
|
n.group = app
|
|
98
95
|
app.nodes[n.id] = n
|
|
99
96
|
prev_process = process
|
|
100
97
|
|
|
101
|
-
|
|
102
98
|
return app
|
|
103
99
|
else:
|
|
104
100
|
return project.start_pages["main"]
|
|
@@ -106,7 +102,7 @@ class BaseInputStrategy:
|
|
|
106
102
|
def __init__(self, input_path):
|
|
107
103
|
self.input_path = input_path
|
|
108
104
|
|
|
109
|
-
|
|
105
|
+
# walking function
|
|
110
106
|
@abc.abstractmethod
|
|
111
107
|
def execute(in_filepath, media_path):
|
|
112
108
|
pass
|