tricc-oo 1.5.8__py3-none-any.whl → 1.5.10__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/converters/drawio_type_map.py +1 -1
- tricc_oo/converters/xml_to_tricc.py +0 -11
- tricc_oo/models/base.py +7 -3
- tricc_oo/models/calculate.py +1 -2
- tricc_oo/models/tricc.py +4 -3
- tricc_oo/serializers/xls_form.py +2 -2
- tricc_oo/strategies/input/drawio.py +1 -1
- tricc_oo/strategies/output/xlsform_cht.py +478 -306
- tricc_oo/visitors/tricc.py +146 -131
- {tricc_oo-1.5.8.dist-info → tricc_oo-1.5.10.dist-info}/METADATA +1 -1
- {tricc_oo-1.5.8.dist-info → tricc_oo-1.5.10.dist-info}/RECORD +13 -13
- {tricc_oo-1.5.8.dist-info → tricc_oo-1.5.10.dist-info}/WHEEL +0 -0
- {tricc_oo-1.5.8.dist-info → tricc_oo-1.5.10.dist-info}/top_level.txt +0 -0
|
@@ -129,7 +129,7 @@ TYPE_MAP = {
|
|
|
129
129
|
},
|
|
130
130
|
TriccNodeType.rhombus: {
|
|
131
131
|
"objects": ["UserObject", "object"],
|
|
132
|
-
"attributes": ["save", "expression", 'label'],
|
|
132
|
+
"attributes": ["save", "expression", 'label','priority'],
|
|
133
133
|
"mandatory_attributes": ["reference"],
|
|
134
134
|
"model": TriccNodeRhombus
|
|
135
135
|
},
|
|
@@ -475,17 +475,6 @@ def get_max_version(dict):
|
|
|
475
475
|
return max_version
|
|
476
476
|
|
|
477
477
|
|
|
478
|
-
def update_calc_version(calculates, name):
|
|
479
|
-
if name in calculates and len(calculates[name]) > 1:
|
|
480
|
-
ordered_list = sorted(list(calculates[name].values()), key=lambda x: x.path_len)
|
|
481
|
-
i = 1
|
|
482
|
-
len_max = len(calculates[name])
|
|
483
|
-
for elm in ordered_list:
|
|
484
|
-
elm.version = i
|
|
485
|
-
elm.last = (i == len_max)
|
|
486
|
-
i += 1
|
|
487
|
-
|
|
488
|
-
|
|
489
478
|
def get_max_named_version(calculates, name):
|
|
490
479
|
max = 0
|
|
491
480
|
if name in calculates:
|
tricc_oo/models/base.py
CHANGED
|
@@ -106,7 +106,7 @@ class TriccBaseModel(BaseModel):
|
|
|
106
106
|
external_id: triccId = None
|
|
107
107
|
tricc_type: TriccNodeType
|
|
108
108
|
datatype: str = None
|
|
109
|
-
instance: int =
|
|
109
|
+
instance: int = 0
|
|
110
110
|
base_instance: Optional[TriccBaseModel] = None
|
|
111
111
|
last: bool = None
|
|
112
112
|
version: int = 1
|
|
@@ -123,7 +123,9 @@ class TriccBaseModel(BaseModel):
|
|
|
123
123
|
def to_dict(self):
|
|
124
124
|
return {key: value for key, value in vars(self).items() if not key.startswith('_')}
|
|
125
125
|
|
|
126
|
-
def make_instance(self, nb_instance, **kwargs):
|
|
126
|
+
def make_instance(self, nb_instance=None, **kwargs):
|
|
127
|
+
if nb_instance == None:
|
|
128
|
+
nb_instance = self.get_next_instance()
|
|
127
129
|
instance = self.copy()
|
|
128
130
|
attr_dict = self.to_dict()
|
|
129
131
|
for attr, value in attr_dict.items():
|
|
@@ -257,7 +259,7 @@ class TriccNodeBaseModel(TriccBaseModel):
|
|
|
257
259
|
|
|
258
260
|
|
|
259
261
|
|
|
260
|
-
def make_instance(self, instance_nb, activity=None):
|
|
262
|
+
def make_instance(self, instance_nb=None, activity=None):
|
|
261
263
|
instance = super().make_instance(instance_nb)
|
|
262
264
|
instance.group = activity
|
|
263
265
|
if hasattr(self, 'activity') and activity is not None:
|
|
@@ -630,6 +632,8 @@ def not_clean(a):
|
|
|
630
632
|
# @param list_or
|
|
631
633
|
# @param and elm use upstream
|
|
632
634
|
def clean_or_list(list_or, elm_and=None):
|
|
635
|
+
if len(list_or) == 1:
|
|
636
|
+
return list(list_or)
|
|
633
637
|
if TriccStatic(True) in list_or:
|
|
634
638
|
return [TriccStatic(True)]
|
|
635
639
|
for a in list(list_or):
|
tricc_oo/models/calculate.py
CHANGED
|
@@ -53,7 +53,7 @@ class TriccNodeCount(TriccNodeDisplayCalculateBase):
|
|
|
53
53
|
class TriccNodeProposedDiagnosis(TriccNodeDisplayCalculateBase):
|
|
54
54
|
tricc_type: TriccNodeType = TriccNodeType.proposed_diagnosis
|
|
55
55
|
severity: str = None
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
|
|
58
58
|
class TriccNodeFakeCalculateBase(TriccNodeCalculateBase):
|
|
59
59
|
...
|
|
@@ -131,7 +131,6 @@ class TriccNodeRhombus(TriccNodeCalculateBase,TriccRhombusMixIn):
|
|
|
131
131
|
class TriccNodeDiagnosis(TriccNodeDisplayCalculateBase):
|
|
132
132
|
tricc_type: TriccNodeType = TriccNodeType.diagnosis
|
|
133
133
|
severity: str = None
|
|
134
|
-
priority: Union[float, int, None] = None
|
|
135
134
|
def __init__(self, **data):
|
|
136
135
|
data['reference'] = f'"final.{data["name"]}" is true'
|
|
137
136
|
super().__init__(**data)
|
tricc_oo/models/tricc.py
CHANGED
|
@@ -18,6 +18,7 @@ class TriccNodeCalculateBase(TriccNodeBaseModel):
|
|
|
18
18
|
expression_reference: Union[str, TriccOperation] = None
|
|
19
19
|
last: bool = None
|
|
20
20
|
datatype: str = 'boolean'
|
|
21
|
+
priority: Union[float, int, None] = None
|
|
21
22
|
# to use the enum value of the TriccNodeType
|
|
22
23
|
class Config:
|
|
23
24
|
use_enum_values = True # <--
|
|
@@ -32,8 +33,8 @@ class TriccNodeCalculateBase(TriccNodeBaseModel):
|
|
|
32
33
|
instance.reference = [e.copy() if isinstance(e, (TriccReference, TriccOperation)) else (TriccReference(e.name) if hasattr(e, 'name') else e) for e in self.reference]
|
|
33
34
|
else:
|
|
34
35
|
instance.reference = None
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
if instance.base_instance != self:
|
|
37
|
+
instance.version = self.version + 1
|
|
37
38
|
return instance
|
|
38
39
|
|
|
39
40
|
def __init__(self, **data):
|
|
@@ -85,7 +86,7 @@ class TriccNodeActivity(TriccNodeBaseModel):
|
|
|
85
86
|
applicability: Optional[Union[Expression, TriccOperation]] = None
|
|
86
87
|
|
|
87
88
|
# redefine
|
|
88
|
-
def make_instance(self, instance_nb, **kwargs):
|
|
89
|
+
def make_instance(self, instance_nb=None, **kwargs):
|
|
89
90
|
from tricc_oo.models.calculate import (
|
|
90
91
|
TriccNodeDisplayBridge,
|
|
91
92
|
TriccNodeBridge,
|
tricc_oo/serializers/xls_form.py
CHANGED
|
@@ -305,14 +305,14 @@ def gen_operation_hash(op):
|
|
|
305
305
|
|
|
306
306
|
|
|
307
307
|
def generate_choice_filter(strategy, node):
|
|
308
|
-
if isinstance(node, TriccNodeSelectOption) and node.relevance:
|
|
308
|
+
if isinstance(node, TriccNodeSelectOption) and node.relevance and node.relevance != TriccStatic(True):
|
|
309
309
|
return gen_operation_hash(node.relevance)
|
|
310
310
|
if not isinstance(node, (TriccNodeSelectMultiple, TriccNodeSelectOne)):
|
|
311
311
|
return
|
|
312
312
|
relevances = {}
|
|
313
313
|
option_filter = {}
|
|
314
314
|
for o in node.options.values():
|
|
315
|
-
if o.relevance:
|
|
315
|
+
if o.relevance and o.relevance != TriccStatic(True):
|
|
316
316
|
key = gen_operation_hash(o.relevance)
|
|
317
317
|
if key not in relevances:
|
|
318
318
|
relevances[key] = o.relevance
|
|
@@ -230,7 +230,7 @@ class DrawioStrategy(BaseInputStrategy):
|
|
|
230
230
|
if int(other_page.instance) > int(max_instance):
|
|
231
231
|
max_instance = other_page.instance
|
|
232
232
|
# auto instance starts at 101
|
|
233
|
-
next_page = next_page.make_instance(
|
|
233
|
+
next_page = next_page.make_instance()
|
|
234
234
|
else:
|
|
235
235
|
# return existing instance if any
|
|
236
236
|
next_page = next_page.make_instance(node.instance)
|