tricc-oo 1.0.1__py3-none-any.whl → 1.4.15__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 +213 -0
- tests/test_cql.py +197 -0
- tests/to_ocl.py +51 -0
- {tricc → tricc_oo}/__init__.py +3 -1
- tricc_oo/converters/codesystem_to_ocl.py +169 -0
- tricc_oo/converters/cql/cqlLexer.py +822 -0
- tricc_oo/converters/cql/cqlListener.py +1632 -0
- tricc_oo/converters/cql/cqlParser.py +11204 -0
- tricc_oo/converters/cql/cqlVisitor.py +913 -0
- tricc_oo/converters/cql_to_operation.py +402 -0
- tricc_oo/converters/datadictionnary.py +115 -0
- tricc_oo/converters/drawio_type_map.py +222 -0
- tricc_oo/converters/tricc_to_xls_form.py +61 -0
- tricc_oo/converters/utils.py +65 -0
- tricc_oo/converters/xml_to_tricc.py +1003 -0
- tricc_oo/models/__init__.py +4 -0
- tricc_oo/models/base.py +732 -0
- tricc_oo/models/calculate.py +216 -0
- tricc_oo/models/ocl.py +281 -0
- tricc_oo/models/ordered_set.py +125 -0
- tricc_oo/models/tricc.py +418 -0
- tricc_oo/parsers/xml.py +138 -0
- tricc_oo/serializers/__init__.py +0 -0
- tricc_oo/serializers/xls_form.py +745 -0
- tricc_oo/strategies/__init__.py +0 -0
- tricc_oo/strategies/input/__init__.py +0 -0
- tricc_oo/strategies/input/base_input_strategy.py +111 -0
- tricc_oo/strategies/input/drawio.py +317 -0
- tricc_oo/strategies/output/base_output_strategy.py +148 -0
- tricc_oo/strategies/output/spice.py +365 -0
- tricc_oo/strategies/output/xls_form.py +697 -0
- tricc_oo/strategies/output/xlsform_cdss.py +189 -0
- tricc_oo/strategies/output/xlsform_cht.py +200 -0
- tricc_oo/strategies/output/xlsform_cht_hf.py +334 -0
- tricc_oo/visitors/__init__.py +0 -0
- tricc_oo/visitors/tricc.py +2198 -0
- tricc_oo/visitors/utils.py +17 -0
- tricc_oo/visitors/xform_pd.py +264 -0
- tricc_oo-1.4.15.dist-info/METADATA +219 -0
- tricc_oo-1.4.15.dist-info/RECORD +46 -0
- {tricc_oo-1.0.1.dist-info → tricc_oo-1.4.15.dist-info}/WHEEL +1 -1
- tricc_oo-1.4.15.dist-info/top_level.txt +2 -0
- tricc/converters/mc_to_tricc.py +0 -542
- tricc/converters/tricc_to_xls_form.py +0 -553
- tricc/converters/utils.py +0 -44
- tricc/converters/xml_to_tricc.py +0 -740
- tricc/models/tricc.py +0 -1093
- tricc/parsers/xml.py +0 -81
- tricc/serializers/xls_form.py +0 -364
- tricc/strategies/input/base_input_strategy.py +0 -80
- tricc/strategies/input/drawio.py +0 -246
- tricc/strategies/input/medalcreator.py +0 -168
- tricc/strategies/output/base_output_strategy.py +0 -92
- tricc/strategies/output/xls_form.py +0 -194
- tricc/strategies/output/xlsform_cdss.py +0 -46
- tricc/strategies/output/xlsform_cht.py +0 -106
- tricc/visitors/tricc.py +0 -375
- tricc_oo-1.0.1.dist-info/LICENSE +0 -78
- tricc_oo-1.0.1.dist-info/METADATA +0 -229
- tricc_oo-1.0.1.dist-info/RECORD +0 -26
- tricc_oo-1.0.1.dist-info/top_level.txt +0 -2
- venv/bin/vba_extract.py +0 -78
- {tricc → tricc_oo}/converters/__init__.py +0 -0
- {tricc → tricc_oo}/models/lang.py +0 -0
- {tricc/serializers → tricc_oo/parsers}/__init__.py +0 -0
- {tricc → tricc_oo}/serializers/planuml.py +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from tricc_oo.models.tricc import TriccNodeActivity
|
|
3
|
+
from tricc_oo.models.calculate import TriccNodeProposedDiagnosis, TriccNodeInput
|
|
4
|
+
from tricc_oo.serializers.xls_form import (
|
|
5
|
+
get_diagnostic_none_line,
|
|
6
|
+
get_diagnostic_start_group_line,
|
|
7
|
+
get_diagnostic_stop_group_line)
|
|
8
|
+
from tricc_oo.converters.tricc_to_xls_form import get_export_name
|
|
9
|
+
from tricc_oo.strategies.output.xls_form import XLSFormStrategy
|
|
10
|
+
from tricc_oo.models.lang import SingletonLangClass
|
|
11
|
+
from tricc_oo.converters.utils import clean_name
|
|
12
|
+
|
|
13
|
+
langs = SingletonLangClass()
|
|
14
|
+
logger = logging.getLogger("default")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class XLSFormCDSSStrategy(XLSFormStrategy):
|
|
19
|
+
|
|
20
|
+
def process_export(self, start_pages, **kwargs):
|
|
21
|
+
diags = []
|
|
22
|
+
self.activity_export(start_pages[self.processes[0]], **kwargs)
|
|
23
|
+
#self.add_tab_breaks_choice()
|
|
24
|
+
self.add_wfx_choice()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def export_inputs(self, activity, inputs = [], **kwargs):
|
|
28
|
+
for node in activity.nodes.values():
|
|
29
|
+
if isinstance(node, TriccNodeActivity):
|
|
30
|
+
inputs = self.export_inputs(node, inputs, **kwargs)
|
|
31
|
+
if isinstance(node, TriccNodeInput):
|
|
32
|
+
inputs.append(node)
|
|
33
|
+
return inputs
|
|
34
|
+
|
|
35
|
+
def tricc_operation_has_qualifier(self, ref_expressions):
|
|
36
|
+
raise NotImplementedError(f"This type of opreration is not supported in this strategy")
|
|
37
|
+
def tricc_operation_age_day(self, ref_expressions):
|
|
38
|
+
dob_node_name= ref_expressions[0].value if ref_expressions else 'birthday'
|
|
39
|
+
return f'int((today()-date(${{{dob_node_name}}})))'
|
|
40
|
+
def tricc_operation_age_month(self, ref_expressions):
|
|
41
|
+
dob_node_name= ref_expressions[0].value if ref_expressions else 'birthday'
|
|
42
|
+
return f'int((today()-date(${{{dob_node_name}}})) div 30.25)'
|
|
43
|
+
def tricc_operation_age_year(self, ref_expressions):
|
|
44
|
+
dob_node_name= ref_expressions[0].value if ref_expressions else 'birthday'
|
|
45
|
+
return f'int((today()-date(${{{dob_node_name}}})) div 365.25)'
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def add_wfx_choice(self):
|
|
49
|
+
empty = langs.get_trads('', force_dict =True)
|
|
50
|
+
new_rows = [
|
|
51
|
+
['wfl', 'y45_0', *list(empty.values()),*list(empty.values()), 'f', 0, 110, -0.3833, 0.09029, 2.4607],
|
|
52
|
+
['wfa', 'y45_1', *list(empty.values()),*list(empty.values()), 'f', 0, 18500, -0.3833, 0.0903, 2.4777],
|
|
53
|
+
['wfh', 'y45_2', *list(empty.values()),*list(empty.values()), 'f', 0, 125, -0.3833, 0.0903, 2.4947],
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
for row in new_rows:
|
|
57
|
+
self.df_choice.loc[len(self.df_choice)] = row
|
|
58
|
+
|
|
59
|
+
label = langs.get_trads('hidden', force_dict =True)
|
|
60
|
+
empty = langs.get_trads('', force_dict =True)
|
|
61
|
+
self.df_survey.loc[len(self.df_survey)] = [
|
|
62
|
+
'select_one wfl',
|
|
63
|
+
"wfl",
|
|
64
|
+
*list(label.values()) ,
|
|
65
|
+
*list(empty.values()) ,#hint
|
|
66
|
+
*list(empty.values()) ,#help
|
|
67
|
+
'',#default
|
|
68
|
+
'',#'appearance', clean_name
|
|
69
|
+
'',#'constraint',
|
|
70
|
+
*list(empty.values()) ,#'constraint_message'
|
|
71
|
+
'0',#'relevance'
|
|
72
|
+
'',#'disabled'
|
|
73
|
+
'1',#'required'
|
|
74
|
+
*list(empty.values()) ,#'required message'
|
|
75
|
+
'',#'read only'
|
|
76
|
+
'',#'expression'
|
|
77
|
+
'',#'repeat_count'
|
|
78
|
+
'',#'image'
|
|
79
|
+
''
|
|
80
|
+
]
|
|
81
|
+
self.df_survey.loc[len(self.df_survey)] = [
|
|
82
|
+
'select_one wfa',
|
|
83
|
+
"wfa",
|
|
84
|
+
*list(label.values()) ,
|
|
85
|
+
*list(empty.values()) ,#hint
|
|
86
|
+
*list(empty.values()) ,#help
|
|
87
|
+
'',#default
|
|
88
|
+
'',#'appearance', clean_name
|
|
89
|
+
'',#'constraint',
|
|
90
|
+
*list(empty.values()) ,#'constraint_message'
|
|
91
|
+
'0',#'relevance'
|
|
92
|
+
'',#'disabled'
|
|
93
|
+
'1',#'required'
|
|
94
|
+
*list(empty.values()) ,#'required message'
|
|
95
|
+
'',#'read only'
|
|
96
|
+
'',#'expression'
|
|
97
|
+
'',#'repeat_count'
|
|
98
|
+
'',#'image'
|
|
99
|
+
''
|
|
100
|
+
]
|
|
101
|
+
self.df_survey.loc[len(self.df_survey)] = [
|
|
102
|
+
'select_one wfh',
|
|
103
|
+
"wfh",
|
|
104
|
+
*list(label.values()) ,
|
|
105
|
+
*list(empty.values()) ,#hint
|
|
106
|
+
*list(empty.values()) ,#help
|
|
107
|
+
'',#default
|
|
108
|
+
'',#'appearance', clean_name
|
|
109
|
+
'',#'constraint',
|
|
110
|
+
*list(empty.values()) ,#'constraint_message'
|
|
111
|
+
'0',#'relevance'
|
|
112
|
+
'',#'disabled'
|
|
113
|
+
'1',#'required'
|
|
114
|
+
*list(empty.values()) ,#'required message'
|
|
115
|
+
'',#'read only'
|
|
116
|
+
'',#'expression'
|
|
117
|
+
'',#'repeat_count'
|
|
118
|
+
'',#'image'
|
|
119
|
+
''
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
def add_tab_breaks_choice(self):
|
|
123
|
+
label = langs.get_trads('hidden', force_dict =True)
|
|
124
|
+
empty = langs.get_trads('', force_dict =True)
|
|
125
|
+
self.df_survey.loc[len(self.df_survey)] = [
|
|
126
|
+
'select_one tab-label-4',
|
|
127
|
+
"tab_label_4",
|
|
128
|
+
*list(label.values()) ,
|
|
129
|
+
*list(empty.values()) ,#hint
|
|
130
|
+
*list(empty.values()) ,#help
|
|
131
|
+
'',#default
|
|
132
|
+
'',#'appearance', clean_name
|
|
133
|
+
'',#'constraint',
|
|
134
|
+
*list(empty.values()) ,#'constraint_message'
|
|
135
|
+
'0',#'relevance'
|
|
136
|
+
'',#'disabled'
|
|
137
|
+
'1',#'required'
|
|
138
|
+
*list(empty.values()) ,#'required message'
|
|
139
|
+
'',#'read only'
|
|
140
|
+
'',#'expression'
|
|
141
|
+
'',#'repeat_count'
|
|
142
|
+
'',#'image'
|
|
143
|
+
''
|
|
144
|
+
]
|
|
145
|
+
new_rows = [
|
|
146
|
+
['tab-label-4', 0, langs.get_trads('--'),*list(empty.values()),'','','','','',''],
|
|
147
|
+
['tab-label-4', 1, langs.get_trads('--'),*list(empty.values()),'','','','','',''],
|
|
148
|
+
['tab-label-4', 2, langs.get_trads('1/2'),*list(empty.values()),'','','','','',''],
|
|
149
|
+
['tab-label-4', 3, langs.get_trads('1/2'),*list(empty.values()),'','','','','',''],
|
|
150
|
+
['tab-label-4', 4, langs.get_trads('1'),*list(empty.values()),'','','','','',''],
|
|
151
|
+
['tab-label-4', 5, langs.get_trads('1'),*list(empty.values()),'','','','','',''],
|
|
152
|
+
['tab-label-4', 6, langs.get_trads('1 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
153
|
+
['tab-label-4', 7, langs.get_trads('1 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
154
|
+
['tab-label-4', 8, langs.get_trads('2'),*list(empty.values()),'','','','','',''],
|
|
155
|
+
['tab-label-4', 9, langs.get_trads('2'),*list(empty.values()),'','','','','',''],
|
|
156
|
+
['tab-label-4', 10, langs.get_trads('2 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
157
|
+
['tab-label-4', 11, langs.get_trads('2 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
158
|
+
['tab-label-4', 12, langs.get_trads('3'),*list(empty.values()),'','','','','',''],
|
|
159
|
+
['tab-label-4', 13, langs.get_trads('3'),*list(empty.values()),'','','','','',''],
|
|
160
|
+
['tab-label-4', 14, langs.get_trads('3 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
161
|
+
['tab-label-4', 15, langs.get_trads('3 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
162
|
+
['tab-label-4', 16, langs.get_trads('4'),*list(empty.values()),'','','','','',''],
|
|
163
|
+
['tab-label-4', 17, langs.get_trads('4'),*list(empty.values()),'','','','','',''],
|
|
164
|
+
['tab-label-4', 18, langs.get_trads('4 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
165
|
+
['tab-label-4', 19, langs.get_trads('4 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
166
|
+
['tab-label-4', 20, langs.get_trads('5'),*list(empty.values()),'','','','','',''],
|
|
167
|
+
['tab-label-4', 21, langs.get_trads('5'),*list(empty.values()),'','','','','',''],
|
|
168
|
+
['tab-label-4', 22, langs.get_trads('5 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
169
|
+
['tab-label-4', 23, langs.get_trads('5 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
170
|
+
['tab-label-4', 24, langs.get_trads('6'),*list(empty.values()),'','','','','',''],
|
|
171
|
+
['tab-label-4', 25, langs.get_trads('6'),*list(empty.values()),'','','','','',''],
|
|
172
|
+
['tab-label-4', 26, langs.get_trads('6 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
173
|
+
['tab-label-4', 27, langs.get_trads('6 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
174
|
+
['tab-label-4', 28, langs.get_trads('7'),*list(empty.values()),'','','','','',''],
|
|
175
|
+
['tab-label-4', 29, langs.get_trads('7'),*list(empty.values()),'','','','','',''],
|
|
176
|
+
['tab-label-4', 30, langs.get_trads('7 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
177
|
+
['tab-label-4', 31, langs.get_trads('7 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
178
|
+
['tab-label-4', 32, langs.get_trads('8'),*list(empty.values()),'','','','','',''],
|
|
179
|
+
['tab-label-4', 33, langs.get_trads('8'),*list(empty.values()),'','','','','',''],
|
|
180
|
+
['tab-label-4', 34, langs.get_trads('8 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
181
|
+
['tab-label-4', 35, langs.get_trads('8 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
182
|
+
['tab-label-4', 36, langs.get_trads('9'),*list(empty.values()),'','','','','',''],
|
|
183
|
+
['tab-label-4', 37, langs.get_trads('9'),*list(empty.values()),'','','','','',''],
|
|
184
|
+
['tab-label-4', 38, langs.get_trads('9 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
185
|
+
['tab-label-4', 39, langs.get_trads('9 and 1/2'),*list(empty.values()),'','','','','',''],
|
|
186
|
+
['tab-label-4', 40, langs.get_trads('10'),*list(empty.values()),'','','','','','']
|
|
187
|
+
]
|
|
188
|
+
for row in new_rows:
|
|
189
|
+
self.df_choice.loc[len(self.df_choice)] = row
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
import re
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
from tricc_oo.models.lang import SingletonLangClass
|
|
9
|
+
from tricc_oo.models.calculate import TriccNodeEnd
|
|
10
|
+
from tricc_oo.serializers.xls_form import SURVEY_MAP, get_input_line
|
|
11
|
+
from tricc_oo.strategies.output.xlsform_cdss import XLSFormCDSSStrategy
|
|
12
|
+
from tricc_oo.converters.tricc_to_xls_form import get_export_name
|
|
13
|
+
from tricc_oo.converters.utils import clean_name, remove_html
|
|
14
|
+
from tricc_oo.visitors.xform_pd import make_breakpoints, get_task_js
|
|
15
|
+
|
|
16
|
+
langs = SingletonLangClass()
|
|
17
|
+
logger = logging.getLogger("default")
|
|
18
|
+
|
|
19
|
+
class XLSFormCHTStrategy(XLSFormCDSSStrategy):
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def process_export(self, start_pages, **kwargs):
|
|
23
|
+
diags = []
|
|
24
|
+
self.activity_export(start_pages[self.processes[0]], **kwargs)
|
|
25
|
+
#self.add_tab_breaks_choice()
|
|
26
|
+
cht_header = pd.DataFrame(columns=SURVEY_MAP.keys())
|
|
27
|
+
cht_input_df = self.get_cht_input( start_pages, **kwargs)
|
|
28
|
+
self.df_survey= self.df_survey[~self.df_survey['name'].isin(cht_input_df['name'])]
|
|
29
|
+
self.df_survey.reset_index(drop=True, inplace=True)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
self.df_survey = pd.concat([cht_input_df, self.df_survey ,self.get_cht_summary() ], ignore_index=True)
|
|
33
|
+
|
|
34
|
+
def get_cht_input(self, start_pages, **kwargs):
|
|
35
|
+
df_input = pd.DataFrame(columns=SURVEY_MAP.keys())
|
|
36
|
+
#[ #type, '',#name ''#label, '',#hint '',#help '',#default '',#'appearance', '',#'constraint', '',#'constraint_message' '',#'relevance' '',#'disabled' '',#'required' '',#'required message' '',#'read only' '',#'expression' '',#'repeat_count' ''#'image' ],
|
|
37
|
+
df_input.loc[len(df_input)] = [ 'begin group', 'inputs' ,*list(langs.get_trads('Inputs', force_dict = True).values()), *list(langs.get_trads('', force_dict = True).values()), *list(langs.get_trads('', force_dict = True).values()), '', 'field-list', '', *list(langs.get_trads('', force_dict = True).values()), './source = "user"', '','', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
38
|
+
df_input.loc[len(df_input)] = [ 'hidden', 'source', *list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
39
|
+
df_input.loc[len(df_input)] = [ 'hidden', 'source_id',*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
40
|
+
inputs = self.export_inputs( start_pages[self.processes[0]], **kwargs)
|
|
41
|
+
for input in inputs:
|
|
42
|
+
df_input.loc[len(df_input)] = get_input_line(input)
|
|
43
|
+
df_input.loc[len(df_input)] = [
|
|
44
|
+
'hidden', 'data_load',
|
|
45
|
+
*list(langs.get_trads('NO_LABEL', force_dict = True).values()),
|
|
46
|
+
*list(langs.get_trads('', force_dict = True).values()),
|
|
47
|
+
*list(langs.get_trads('', force_dict = True).values()),
|
|
48
|
+
'', 'hidden', '',
|
|
49
|
+
*list(langs.get_trads('', force_dict = True).values()),
|
|
50
|
+
'', '','',
|
|
51
|
+
*list(langs.get_trads('', force_dict = True).values())
|
|
52
|
+
,'', '', '', ''
|
|
53
|
+
]
|
|
54
|
+
df_input.loc[len(df_input)] = [ 'hidden', 'task_id' ,*list(langs.get_trads('Task ID', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
55
|
+
df_input.loc[len(df_input)] = [ 'begin group ', 'contact' ,*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
56
|
+
df_input.loc[len(df_input)] = [ 'db:person', '_id', *list(langs.get_trads('Patient ID', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', 'db-object', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
57
|
+
df_input.loc[len(df_input)] = [ 'string', 'patient_id' ,*list(langs.get_trads('Medic ID', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', 'hidden', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
58
|
+
df_input.loc[len(df_input)] = [ 'string', 'patient_name',*list(langs.get_trads('Patient Name', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', 'hidden', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
59
|
+
df_input.loc[len(df_input)] = [ 'date', 'date_of_birth',*list(langs.get_trads('Date of birth', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', 'hidden', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
60
|
+
df_input.loc[len(df_input)] = [ 'string', 'sex',*list(langs.get_trads('Patient Sex', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', 'hidden', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
61
|
+
df_input.loc[len(df_input)] = [ 'end group', '' ,*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
62
|
+
df_input.loc[len(df_input)] = [ 'end group', '' ,*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()) ,'', '', '', '', '' ]
|
|
63
|
+
df_input.loc[len(df_input)] = [ 'calculate', '_id' ,*list(langs.get_trads('label', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '../inputs/contact/_id', '', '' , '' ]
|
|
64
|
+
df_input.loc[len(df_input)] = [ 'calculate', 'patient_uuid' ,*list(langs.get_trads('label', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '../inputs/contact/patient_id', '', '' , '' ]
|
|
65
|
+
df_input.loc[len(df_input)] = [ 'calculate', 'p_name' ,*list(langs.get_trads('label', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '../inputs/contact/patient_name', '', '' , '' ]
|
|
66
|
+
|
|
67
|
+
df_input.loc[len(df_input)] = [ 'calculate', 'p_age_days' ,*list(langs.get_trads('label', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', 'int((today()-date(${date_of_birth})))', '', '' , '' ]
|
|
68
|
+
df_input.loc[len(df_input)] = [ 'calculate', 'p_age_months' ,*list(langs.get_trads('label', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', 'int(${id.age_day} div 30.4)', '', '' , '' ]
|
|
69
|
+
df_input.loc[len(df_input)] = [ 'calculate', 'p_age_years' ,*list(langs.get_trads('label', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', 'int(${p_age_month} div 12)', '', '' , '' ]
|
|
70
|
+
df_input.loc[len(df_input)] = [ 'calculate', 'p_sex' ,*list(langs.get_trads('label', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '../inputs/contact/sex', '', '' , '' ]
|
|
71
|
+
df_input.loc[len(df_input)] = [ 'calculate', 'p_dob',*list(langs.get_trads('Date of birth', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()),*list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', '', '', *list(langs.get_trads('', force_dict = True).values()), '', 'date(../inputs/contact/date_of_birth)', '','' , '' ]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
return df_input
|
|
75
|
+
|
|
76
|
+
def get_cht_summary(self):
|
|
77
|
+
|
|
78
|
+
df_summary = pd.DataFrame(columns=SURVEY_MAP.keys())
|
|
79
|
+
#[ #type, '',#name ''#label, '',#hint '',#help '',#default '',#'appearance', '',#'constraint', '',#'constraint_message' '',#'relevance' '',#'disabled' '',#'required' '',#'required message' '',#'read only' '',#'expression' '',#'repeat_count' ''#'image' ],
|
|
80
|
+
#df_summary.loc[len(df_summary)] = [ 'begin group', 'group_summary' , 'Summary', '', '', '', 'field-list summary', '', '', '', '', '', '', '', '', '', '' ]
|
|
81
|
+
#df_summary.loc[len(df_summary)] = [ 'note', 'r_patient_info', '**${patient_name}** ID: ${patient_id}', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ]
|
|
82
|
+
#df_summary.loc[len(df_summary)] = [ 'note', 'r_followup', 'Follow Up <i class=“fa fa-flag”></i>', '', '', '', '', '', '','', '', '', '', '', '', '', '' ]
|
|
83
|
+
#df_summary.loc[len(df_summary)] = [ 'note', 'r_followup_note' ,'FOLLOWUP instruction', '', '', '', '', '', '', '','', '', '', '', '', '', '' ]
|
|
84
|
+
#df_summary.loc[len(df_summary)] = [ 'end group', '' ,'', '', '', '', '', '', '', '', '', '', '', '', '','', '' ]
|
|
85
|
+
return df_summary
|
|
86
|
+
|
|
87
|
+
def export(self, start_pages, version, **kwargs):
|
|
88
|
+
form_id = None
|
|
89
|
+
if start_pages[self.processes[0]].root.form_id is not None:
|
|
90
|
+
form_id= str(start_pages[self.processes[0]].root.form_id )
|
|
91
|
+
else:
|
|
92
|
+
logger.critical("form id required in the first start node")
|
|
93
|
+
exit(1)
|
|
94
|
+
title = remove_html(start_pages[self.processes[0]].root.label)
|
|
95
|
+
file_name = form_id + ".xlsx"
|
|
96
|
+
# make a 'settings' tab
|
|
97
|
+
now = datetime.datetime.now()
|
|
98
|
+
version=now.strftime('%Y%m%d%H%M')
|
|
99
|
+
indx=[[1]]
|
|
100
|
+
# CHT FORCE file name to be equal to id
|
|
101
|
+
|
|
102
|
+
newfilename = form_id + ".xlsx"
|
|
103
|
+
newpath = os.path.join(self.output_path, newfilename)
|
|
104
|
+
media_path = os.path.join(self.output_path, form_id + "-media")
|
|
105
|
+
|
|
106
|
+
settings={'form_title':title,'form_id':form_id,'version':version,'default_language':'English (en)','style':'pages'}
|
|
107
|
+
df_settings=pd.DataFrame(settings,index=indx)
|
|
108
|
+
df_settings.head()
|
|
109
|
+
if len(self.df_survey[self.df_survey['name'] == 'version'] ):
|
|
110
|
+
self.df_survey.loc[ self.df_survey['name'] == 'version', 'label'] = f"v{version}"
|
|
111
|
+
#create a Pandas Excel writer using XlsxWriter as the engine
|
|
112
|
+
writer = pd.ExcelWriter(newpath, engine='xlsxwriter')
|
|
113
|
+
self.df_survey.to_excel(writer, sheet_name='survey',index=False)
|
|
114
|
+
self.df_choice.to_excel(writer, sheet_name='choices',index=False)
|
|
115
|
+
df_settings.to_excel(writer, sheet_name='settings',index=False)
|
|
116
|
+
writer.close()
|
|
117
|
+
# pause
|
|
118
|
+
ends = []
|
|
119
|
+
for p in self.project.pages.values():
|
|
120
|
+
p_ends = list(filter(lambda x: issubclass(x.__class__, TriccNodeEnd) and getattr(x, 'hint', None) is not None, p.nodes.values() ))
|
|
121
|
+
if p_ends:
|
|
122
|
+
ends += p_ends
|
|
123
|
+
if ends:
|
|
124
|
+
ends_prev = []
|
|
125
|
+
for e in ends:
|
|
126
|
+
|
|
127
|
+
latest = None
|
|
128
|
+
for p in e.prev_nodes:
|
|
129
|
+
if not latest or latest.path_len < p.path_len:
|
|
130
|
+
latest = p
|
|
131
|
+
if hasattr(latest, 'select'):
|
|
132
|
+
latest = latest.select
|
|
133
|
+
ends_prev.append(
|
|
134
|
+
(int(self.df_survey[self.df_survey.name == latest.export_name].index.values[0]), e,)
|
|
135
|
+
)
|
|
136
|
+
forms = [form_id]
|
|
137
|
+
for i, e in ends_prev:
|
|
138
|
+
new_form_id = f"{form_id}_{clean_name(e.name)}"
|
|
139
|
+
newfilename = f"{new_form_id}.xlsx"
|
|
140
|
+
newpath = os.path.join(self.output_path, newfilename)
|
|
141
|
+
settings={'form_title':title,'form_id':f"{new_form_id}",'version':version,'default_language':'English (en)','style':'pages'}
|
|
142
|
+
df_settings=pd.DataFrame(settings,index=indx)
|
|
143
|
+
df_settings.head()
|
|
144
|
+
task_df, hidden_names = make_breakpoints(self.df_survey, i, e.name, replace_dots=True)
|
|
145
|
+
# deactivate the end node
|
|
146
|
+
task_df.loc[task_df['name'] == get_export_name(e), 'calculation'] = 0
|
|
147
|
+
#print fileds
|
|
148
|
+
writer = pd.ExcelWriter(newpath, engine='xlsxwriter')
|
|
149
|
+
task_df.to_excel(writer, sheet_name='survey',index=False)
|
|
150
|
+
self.df_choice.to_excel(writer, sheet_name='choices',index=False)
|
|
151
|
+
df_settings.to_excel(writer, sheet_name='settings',index=False)
|
|
152
|
+
writer.close()
|
|
153
|
+
newfilename = f"{new_form_id}.js"
|
|
154
|
+
newpath = os.path.join(self.output_path, newfilename)
|
|
155
|
+
with open(newpath, 'w') as f:
|
|
156
|
+
f.write(
|
|
157
|
+
get_task_js(
|
|
158
|
+
new_form_id,
|
|
159
|
+
e.name,
|
|
160
|
+
f"continue {title}",
|
|
161
|
+
forms,
|
|
162
|
+
hidden_names,
|
|
163
|
+
self.df_survey,
|
|
164
|
+
repalce_dots=False,
|
|
165
|
+
task_title=e.hint
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
f.close()
|
|
169
|
+
forms.append(new_form_id)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
media_path_tmp = os.path.join(self.output_path, 'media-tmp')
|
|
174
|
+
if (os.path.isdir(media_path_tmp)):
|
|
175
|
+
if os.path.isdir(media_path): # check if it exists, because if it does, error will be raised
|
|
176
|
+
shutil.rmtree(media_path)
|
|
177
|
+
# (later change to make folder complaint to CHT)
|
|
178
|
+
os.mkdir(media_path)
|
|
179
|
+
|
|
180
|
+
file_names = os.listdir(media_path_tmp)
|
|
181
|
+
for file_name in file_names:
|
|
182
|
+
shutil.move(os.path.join(media_path_tmp, file_name), media_path)
|
|
183
|
+
shutil.rmtree(media_path_tmp)
|
|
184
|
+
|
|
185
|
+
def tricc_operation_zscore(self, ref_expressions):
|
|
186
|
+
y, ll, m, s = self.get_zscore_params(ref_expressions)
|
|
187
|
+
# return ((Math.pow((y / m), l) - 1) / (s * l));
|
|
188
|
+
return f"cht:extension-lib('{ref_expressions[0][1:-1]}.js',{self.clean_coalesce(ref_expressions[1])} ,{self.clean_coalesce(ref_expressions[2])} ,{self.clean_coalesce(ref_expressions[3])})"
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def tricc_operation_izscore(self, ref_expressions):
|
|
192
|
+
z, ll, m, s = self.get_zscore_params(ref_expressions)
|
|
193
|
+
# return (m * (z*s*l-1)^(1/l));
|
|
194
|
+
return f"cht:extension-lib('{ref_expressions[0][1:-1]}.js',{self.clean_coalesce(ref_expressions[1])} ,{self.clean_coalesce(ref_expressions[2])} ,{self.clean_coalesce(ref_expressions[3])}, true)"
|
|
195
|
+
|
|
196
|
+
def tricc_operation_drug_dosage(self, ref_expressions):
|
|
197
|
+
# drug name
|
|
198
|
+
# age
|
|
199
|
+
#weight
|
|
200
|
+
return f"cht:extension-lib('drugs.js',{','.join(map(self.clean_coalesce, ref_expressions))})"
|