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
|
@@ -8,7 +8,11 @@ import pandas as pd
|
|
|
8
8
|
from tricc_oo.models.lang import SingletonLangClass
|
|
9
9
|
from tricc_oo.models.calculate import TriccNodeEnd
|
|
10
10
|
from tricc_oo.models.tricc import TriccNodeDisplayModel
|
|
11
|
-
from tricc_oo.serializers.xls_form import
|
|
11
|
+
from tricc_oo.serializers.xls_form import (
|
|
12
|
+
SURVEY_MAP,
|
|
13
|
+
get_input_line,
|
|
14
|
+
get_input_calc_line,
|
|
15
|
+
)
|
|
12
16
|
from tricc_oo.strategies.output.xlsform_cdss import XLSFormCDSSStrategy
|
|
13
17
|
from tricc_oo.converters.tricc_to_xls_form import get_export_name
|
|
14
18
|
from tricc_oo.converters.utils import clean_name, remove_html
|
|
@@ -17,377 +21,519 @@ from tricc_oo.visitors.xform_pd import make_breakpoints, get_task_js
|
|
|
17
21
|
langs = SingletonLangClass()
|
|
18
22
|
logger = logging.getLogger("default")
|
|
19
23
|
|
|
24
|
+
|
|
20
25
|
class XLSFormCHTStrategy(XLSFormCDSSStrategy):
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def process_export(self, start_pages, **kwargs):
|
|
26
|
+
def process_export(self, start_pages, **kwargs):
|
|
24
27
|
diags = []
|
|
25
28
|
self.activity_export(start_pages[self.processes[0]], **kwargs)
|
|
26
|
-
#self.add_tab_breaks_choice()
|
|
29
|
+
# self.add_tab_breaks_choice()
|
|
27
30
|
cht_header = pd.DataFrame(columns=SURVEY_MAP.keys())
|
|
28
|
-
cht_input_df = self.get_cht_input(
|
|
29
|
-
self.df_survey= self.df_survey[
|
|
31
|
+
cht_input_df = self.get_cht_input(start_pages, **kwargs)
|
|
32
|
+
self.df_survey = self.df_survey[
|
|
33
|
+
~self.df_survey["name"].isin(cht_input_df["name"])
|
|
34
|
+
]
|
|
30
35
|
self.df_survey.reset_index(drop=True, inplace=True)
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
self.df_survey = pd.concat(
|
|
38
|
+
[cht_input_df, self.df_survey, self.get_cht_summary()], ignore_index=True
|
|
39
|
+
)
|
|
40
|
+
|
|
35
41
|
def get_cht_input(self, start_pages, **kwargs):
|
|
36
|
-
empty = langs.get_trads(
|
|
42
|
+
empty = langs.get_trads("", force_dict=True)
|
|
37
43
|
df_input = pd.DataFrame(columns=SURVEY_MAP.keys())
|
|
38
|
-
|
|
39
|
-
df_input.loc[len(df_input)] = [
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
# [ #type, '',#name ''#label, '',#hint '',#help '',#default '',#'appearance', '',#'constraint', '',#'constraint_message' '',#'relevance' '',#'disabled' '',#'required' '',#'required message' '',#'read only' '',#'expression' '',#'repeat_count' ''#'image' ],
|
|
45
|
+
df_input.loc[len(df_input)] = [
|
|
46
|
+
"begin_group",
|
|
47
|
+
"inputs",
|
|
48
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
42
49
|
*list(empty.values()),
|
|
43
50
|
*list(empty.values()),
|
|
44
|
-
|
|
51
|
+
"",
|
|
52
|
+
"field-list",
|
|
53
|
+
"",
|
|
45
54
|
*list(empty.values()),
|
|
46
|
-
'./source = "user"',
|
|
47
|
-
|
|
48
|
-
,
|
|
55
|
+
'./source = "user"',
|
|
56
|
+
"",
|
|
57
|
+
"",
|
|
58
|
+
*list(empty.values()),
|
|
59
|
+
"",
|
|
60
|
+
"",
|
|
61
|
+
"",
|
|
62
|
+
"",
|
|
63
|
+
"",
|
|
49
64
|
]
|
|
50
|
-
df_input.loc[len(df_input)] = [
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
df_input.loc[len(df_input)] = [
|
|
66
|
+
"hidden",
|
|
67
|
+
"source",
|
|
68
|
+
*list(langs.get_trads("Source", force_dict=True).values()),
|
|
53
69
|
*list(empty.values()),
|
|
54
70
|
*list(empty.values()),
|
|
55
|
-
|
|
71
|
+
"user",
|
|
72
|
+
"hidden",
|
|
73
|
+
"",
|
|
56
74
|
*list(empty.values()),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
,
|
|
75
|
+
"",
|
|
76
|
+
"",
|
|
77
|
+
"",
|
|
78
|
+
*list(empty.values()),
|
|
79
|
+
"",
|
|
80
|
+
"",
|
|
81
|
+
"",
|
|
82
|
+
"",
|
|
83
|
+
"",
|
|
60
84
|
]
|
|
61
|
-
df_input.loc[len(df_input)] = [
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
df_input.loc[len(df_input)] = [
|
|
86
|
+
"hidden",
|
|
87
|
+
"source_id",
|
|
88
|
+
*list(langs.get_trads("Source ID", force_dict=True).values()),
|
|
64
89
|
*list(empty.values()),
|
|
65
90
|
*list(empty.values()),
|
|
66
|
-
|
|
91
|
+
"",
|
|
92
|
+
"hidden",
|
|
93
|
+
"",
|
|
67
94
|
*list(empty.values()),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
,
|
|
95
|
+
"",
|
|
96
|
+
"",
|
|
97
|
+
"",
|
|
98
|
+
*list(empty.values()),
|
|
99
|
+
"",
|
|
100
|
+
"",
|
|
101
|
+
"",
|
|
102
|
+
"",
|
|
103
|
+
"",
|
|
71
104
|
]
|
|
72
|
-
|
|
73
105
|
|
|
74
|
-
df_input.loc[len(df_input)] = [
|
|
75
|
-
|
|
76
|
-
|
|
106
|
+
df_input.loc[len(df_input)] = [
|
|
107
|
+
"begin_group",
|
|
108
|
+
"user",
|
|
109
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
77
110
|
*list(empty.values()),
|
|
78
111
|
*list(empty.values()),
|
|
79
|
-
|
|
112
|
+
"",
|
|
113
|
+
"field-list",
|
|
114
|
+
"",
|
|
80
115
|
*list(empty.values()),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
,
|
|
116
|
+
"",
|
|
117
|
+
"",
|
|
118
|
+
"",
|
|
119
|
+
*list(empty.values()),
|
|
120
|
+
"",
|
|
121
|
+
"",
|
|
122
|
+
"",
|
|
123
|
+
"",
|
|
124
|
+
"",
|
|
84
125
|
]
|
|
85
|
-
df_input.loc[len(df_input)] = [
|
|
86
|
-
|
|
87
|
-
|
|
126
|
+
df_input.loc[len(df_input)] = [
|
|
127
|
+
"string",
|
|
128
|
+
"contact_id",
|
|
129
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
88
130
|
*list(empty.values()),
|
|
89
131
|
*list(empty.values()),
|
|
90
|
-
|
|
132
|
+
"",
|
|
133
|
+
"hidden",
|
|
134
|
+
"",
|
|
91
135
|
*list(empty.values()),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
,
|
|
136
|
+
"",
|
|
137
|
+
"",
|
|
138
|
+
"",
|
|
139
|
+
*list(empty.values()),
|
|
140
|
+
"",
|
|
141
|
+
"",
|
|
142
|
+
"",
|
|
143
|
+
"",
|
|
144
|
+
"",
|
|
95
145
|
]
|
|
96
|
-
df_input.loc[len(df_input)] = [
|
|
97
|
-
|
|
98
|
-
|
|
146
|
+
df_input.loc[len(df_input)] = [
|
|
147
|
+
"string",
|
|
148
|
+
"facility_id",
|
|
149
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
150
|
+
*list(empty.values()),
|
|
99
151
|
*list(empty.values()),
|
|
152
|
+
"",
|
|
153
|
+
"hidden",
|
|
154
|
+
"",
|
|
100
155
|
*list(empty.values()),
|
|
101
|
-
|
|
156
|
+
"",
|
|
157
|
+
"",
|
|
158
|
+
"",
|
|
102
159
|
*list(empty.values()),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
,
|
|
160
|
+
"",
|
|
161
|
+
"",
|
|
162
|
+
"",
|
|
163
|
+
"",
|
|
164
|
+
"",
|
|
106
165
|
]
|
|
107
|
-
df_input.loc[len(df_input)] = [
|
|
108
|
-
|
|
109
|
-
|
|
166
|
+
df_input.loc[len(df_input)] = [
|
|
167
|
+
"string",
|
|
168
|
+
"name",
|
|
169
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
170
|
+
*list(empty.values()),
|
|
110
171
|
*list(empty.values()),
|
|
172
|
+
"",
|
|
173
|
+
"hidden",
|
|
174
|
+
"",
|
|
111
175
|
*list(empty.values()),
|
|
112
|
-
|
|
176
|
+
"",
|
|
177
|
+
"",
|
|
178
|
+
"",
|
|
113
179
|
*list(empty.values()),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
,
|
|
180
|
+
"",
|
|
181
|
+
"",
|
|
182
|
+
"",
|
|
183
|
+
"",
|
|
184
|
+
"",
|
|
117
185
|
]
|
|
118
186
|
df_input.loc[len(df_input)] = [
|
|
119
|
-
|
|
187
|
+
"end_group",
|
|
188
|
+
"user end",
|
|
120
189
|
*list(empty.values()),
|
|
121
190
|
*list(empty.values()),
|
|
122
191
|
*list(empty.values()),
|
|
123
|
-
|
|
192
|
+
"",
|
|
193
|
+
"",
|
|
194
|
+
"",
|
|
124
195
|
*list(empty.values()),
|
|
125
|
-
|
|
196
|
+
"",
|
|
197
|
+
"",
|
|
198
|
+
"",
|
|
126
199
|
*list(empty.values()),
|
|
127
|
-
|
|
200
|
+
"",
|
|
201
|
+
"",
|
|
202
|
+
"",
|
|
203
|
+
"",
|
|
204
|
+
"",
|
|
128
205
|
]
|
|
129
|
-
df_input.loc[len(df_input)] = [
|
|
130
|
-
|
|
131
|
-
|
|
206
|
+
df_input.loc[len(df_input)] = [
|
|
207
|
+
"begin_group",
|
|
208
|
+
"contact",
|
|
209
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
210
|
+
*list(empty.values()),
|
|
132
211
|
*list(empty.values()),
|
|
212
|
+
"",
|
|
213
|
+
"field-list",
|
|
214
|
+
"",
|
|
133
215
|
*list(empty.values()),
|
|
134
|
-
|
|
216
|
+
"",
|
|
217
|
+
"",
|
|
218
|
+
"",
|
|
135
219
|
*list(empty.values()),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
,
|
|
220
|
+
"",
|
|
221
|
+
"",
|
|
222
|
+
"",
|
|
223
|
+
"",
|
|
224
|
+
"",
|
|
139
225
|
]
|
|
140
226
|
self.get_contact_inputs(df_input)
|
|
141
|
-
inputs = self.export_inputs(
|
|
227
|
+
inputs = self.export_inputs(start_pages[self.processes[0]], **kwargs)
|
|
142
228
|
for input in inputs:
|
|
143
229
|
df_input.loc[len(df_input)] = get_input_line(input)
|
|
144
|
-
df_input.loc[len(df_input)] = [
|
|
145
|
-
|
|
146
|
-
|
|
230
|
+
df_input.loc[len(df_input)] = [
|
|
231
|
+
"hidden",
|
|
232
|
+
"external_id",
|
|
233
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
234
|
+
*list(empty.values()),
|
|
147
235
|
*list(empty.values()),
|
|
236
|
+
"",
|
|
237
|
+
"hidden",
|
|
238
|
+
"",
|
|
148
239
|
*list(empty.values()),
|
|
149
|
-
|
|
240
|
+
"",
|
|
241
|
+
"",
|
|
242
|
+
"",
|
|
150
243
|
*list(empty.values()),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
,
|
|
244
|
+
"",
|
|
245
|
+
"",
|
|
246
|
+
"",
|
|
247
|
+
"",
|
|
248
|
+
"",
|
|
154
249
|
]
|
|
155
|
-
|
|
156
|
-
df_input.loc[len(df_input)] = [
|
|
157
|
-
|
|
158
|
-
|
|
250
|
+
|
|
251
|
+
df_input.loc[len(df_input)] = [
|
|
252
|
+
"string",
|
|
253
|
+
"_id",
|
|
254
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
159
255
|
*list(empty.values()),
|
|
160
256
|
*list(empty.values()),
|
|
161
|
-
|
|
257
|
+
"",
|
|
258
|
+
"hidden",
|
|
259
|
+
"",
|
|
162
260
|
*list(empty.values()),
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
,
|
|
166
|
-
|
|
167
|
-
|
|
261
|
+
"",
|
|
262
|
+
"",
|
|
263
|
+
"",
|
|
264
|
+
*list(empty.values()),
|
|
265
|
+
"",
|
|
266
|
+
"",
|
|
267
|
+
"",
|
|
268
|
+
"",
|
|
269
|
+
"",
|
|
270
|
+
]
|
|
271
|
+
|
|
168
272
|
df_input.loc[len(df_input)] = [
|
|
169
|
-
|
|
273
|
+
"end_group",
|
|
274
|
+
"contact end",
|
|
170
275
|
*list(empty.values()),
|
|
171
276
|
*list(empty.values()),
|
|
172
277
|
*list(empty.values()),
|
|
173
|
-
|
|
278
|
+
"",
|
|
279
|
+
"",
|
|
280
|
+
"",
|
|
174
281
|
*list(empty.values()),
|
|
175
|
-
|
|
282
|
+
"",
|
|
283
|
+
"",
|
|
284
|
+
"",
|
|
176
285
|
*list(empty.values()),
|
|
177
|
-
|
|
286
|
+
"",
|
|
287
|
+
"",
|
|
288
|
+
"",
|
|
289
|
+
"",
|
|
290
|
+
"",
|
|
178
291
|
]
|
|
179
|
-
|
|
292
|
+
|
|
180
293
|
df_input.loc[len(df_input)] = [
|
|
181
|
-
|
|
294
|
+
"end_group",
|
|
295
|
+
"input end",
|
|
182
296
|
*list(empty.values()),
|
|
183
297
|
*list(empty.values()),
|
|
184
298
|
*list(empty.values()),
|
|
185
|
-
|
|
299
|
+
"",
|
|
300
|
+
"",
|
|
301
|
+
"",
|
|
186
302
|
*list(empty.values()),
|
|
187
|
-
|
|
303
|
+
"",
|
|
304
|
+
"",
|
|
305
|
+
"",
|
|
188
306
|
*list(empty.values()),
|
|
189
|
-
|
|
307
|
+
"",
|
|
308
|
+
"",
|
|
309
|
+
"",
|
|
310
|
+
"",
|
|
311
|
+
"",
|
|
190
312
|
]
|
|
191
313
|
df_input.loc[len(df_input)] = [
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
*list(empty.values())
|
|
195
|
-
*list(empty.values())
|
|
196
|
-
*list(empty.values())
|
|
197
|
-
|
|
198
|
-
'
|
|
199
|
-
'
|
|
200
|
-
*list(empty.values())
|
|
201
|
-
'
|
|
202
|
-
'
|
|
203
|
-
'
|
|
204
|
-
*list(empty.values())
|
|
205
|
-
'
|
|
206
|
-
|
|
207
|
-
'
|
|
208
|
-
'
|
|
209
|
-
|
|
210
|
-
]
|
|
314
|
+
"calculate",
|
|
315
|
+
"created_by_person_uuid",
|
|
316
|
+
*list(empty.values()),
|
|
317
|
+
*list(empty.values()), # hint
|
|
318
|
+
*list(empty.values()), # help
|
|
319
|
+
"", # default
|
|
320
|
+
"", #'appearance', clean_name
|
|
321
|
+
"", #'constraint',
|
|
322
|
+
*list(empty.values()), #'constraint_message'
|
|
323
|
+
"", #'relevance'
|
|
324
|
+
"", #'disabled'
|
|
325
|
+
"", #'required'
|
|
326
|
+
*list(empty.values()), #'required message'
|
|
327
|
+
"", #'read only'
|
|
328
|
+
"../inputs/user/contact_id", #'expression'
|
|
329
|
+
"", #'repeat_count'
|
|
330
|
+
"", #'image'
|
|
331
|
+
"", # choice filter
|
|
332
|
+
]
|
|
211
333
|
df_input.loc[len(df_input)] = [
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
*list(empty.values())
|
|
215
|
-
*list(empty.values())
|
|
216
|
-
*list(empty.values())
|
|
217
|
-
|
|
218
|
-
'
|
|
219
|
-
'
|
|
220
|
-
*list(empty.values())
|
|
221
|
-
'
|
|
222
|
-
'
|
|
223
|
-
'
|
|
224
|
-
*list(empty.values())
|
|
225
|
-
'
|
|
226
|
-
|
|
227
|
-
'
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
]
|
|
334
|
+
"calculate",
|
|
335
|
+
"created_by_place_uuid_user",
|
|
336
|
+
*list(empty.values()),
|
|
337
|
+
*list(empty.values()), # hint
|
|
338
|
+
*list(empty.values()), # help
|
|
339
|
+
"", # default
|
|
340
|
+
"", #'appearance', clean_name
|
|
341
|
+
"", #'constraint',
|
|
342
|
+
*list(empty.values()), #'constraint_message'
|
|
343
|
+
"", #'relevance'
|
|
344
|
+
"", #'disabled'
|
|
345
|
+
"", #'required'
|
|
346
|
+
*list(empty.values()), #'required message'
|
|
347
|
+
"", #'read only'
|
|
348
|
+
"../inputs/user/facility_id", #'expression'
|
|
349
|
+
"", #'repeat_count'
|
|
350
|
+
"", #'image'
|
|
351
|
+
"", # choice filter
|
|
352
|
+
]
|
|
231
353
|
df_input.loc[len(df_input)] = [
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
*list(empty.values())
|
|
235
|
-
*list(empty.values())
|
|
236
|
-
*list(empty.values())
|
|
237
|
-
|
|
238
|
-
'
|
|
239
|
-
'
|
|
240
|
-
*list(empty.values())
|
|
241
|
-
'
|
|
242
|
-
'
|
|
243
|
-
'
|
|
244
|
-
*list(empty.values())
|
|
245
|
-
'
|
|
246
|
-
|
|
247
|
-
'
|
|
248
|
-
'
|
|
249
|
-
|
|
250
|
-
]
|
|
354
|
+
"calculate",
|
|
355
|
+
"created_by",
|
|
356
|
+
*list(empty.values()),
|
|
357
|
+
*list(empty.values()), # hint
|
|
358
|
+
*list(empty.values()), # help
|
|
359
|
+
"", # default
|
|
360
|
+
"", #'appearance', clean_name
|
|
361
|
+
"", #'constraint',
|
|
362
|
+
*list(empty.values()), #'constraint_message'
|
|
363
|
+
"", #'relevance'
|
|
364
|
+
"", #'disabled'
|
|
365
|
+
"", #'required'
|
|
366
|
+
*list(empty.values()), #'required message'
|
|
367
|
+
"", #'read only'
|
|
368
|
+
"../inputs/user/name", #'expression'
|
|
369
|
+
"", #'repeat_count'
|
|
370
|
+
"", #'image'
|
|
371
|
+
"", # choice filter
|
|
372
|
+
]
|
|
251
373
|
df_input.loc[len(df_input)] = [
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
*list(empty.values())
|
|
255
|
-
*list(empty.values())
|
|
256
|
-
*list(empty.values())
|
|
257
|
-
|
|
258
|
-
'
|
|
259
|
-
'
|
|
260
|
-
*list(empty.values())
|
|
261
|
-
'
|
|
262
|
-
'
|
|
263
|
-
'
|
|
264
|
-
*list(empty.values())
|
|
265
|
-
'
|
|
266
|
-
|
|
267
|
-
'
|
|
268
|
-
'
|
|
269
|
-
|
|
270
|
-
]
|
|
374
|
+
"calculate",
|
|
375
|
+
"created_by_place_uuid",
|
|
376
|
+
*list(empty.values()),
|
|
377
|
+
*list(empty.values()), # hint
|
|
378
|
+
*list(empty.values()), # help
|
|
379
|
+
"", # default
|
|
380
|
+
"", #'appearance', clean_name
|
|
381
|
+
"", #'constraint',
|
|
382
|
+
*list(empty.values()), #'constraint_message'
|
|
383
|
+
"", #'relevance'
|
|
384
|
+
"", #'disabled'
|
|
385
|
+
"", #'required'
|
|
386
|
+
*list(empty.values()), #'required message'
|
|
387
|
+
"", #'read only'
|
|
388
|
+
"../inputs/contact/_id", #'expression'
|
|
389
|
+
"", #'repeat_count'
|
|
390
|
+
"", #'image'
|
|
391
|
+
"", # choice filter
|
|
392
|
+
]
|
|
271
393
|
|
|
272
394
|
df_input.loc[len(df_input)] = [
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*list(empty.values())
|
|
276
|
-
*list(empty.values())
|
|
277
|
-
*list(empty.values())
|
|
278
|
-
|
|
279
|
-
'
|
|
280
|
-
'
|
|
281
|
-
*list(empty.values())
|
|
282
|
-
'
|
|
283
|
-
'
|
|
284
|
-
'
|
|
285
|
-
*list(empty.values())
|
|
286
|
-
'
|
|
287
|
-
|
|
288
|
-
'
|
|
289
|
-
'
|
|
290
|
-
|
|
291
|
-
]
|
|
395
|
+
"calculate",
|
|
396
|
+
"source_id",
|
|
397
|
+
*list(empty.values()),
|
|
398
|
+
*list(empty.values()), # hint
|
|
399
|
+
*list(empty.values()), # help
|
|
400
|
+
"", # default
|
|
401
|
+
"", #'appearance', clean_name
|
|
402
|
+
"", #'constraint',
|
|
403
|
+
*list(empty.values()), #'constraint_message'
|
|
404
|
+
"", #'relevance'
|
|
405
|
+
"", #'disabled'
|
|
406
|
+
"", #'required'
|
|
407
|
+
*list(empty.values()), #'required message'
|
|
408
|
+
"", #'read only'
|
|
409
|
+
"../inputs/source_id", #'expression'
|
|
410
|
+
"", #'repeat_count'
|
|
411
|
+
"", #'image'
|
|
412
|
+
"", # choice filter
|
|
413
|
+
]
|
|
414
|
+
df_input.loc[len(df_input)] = [
|
|
415
|
+
"calculate",
|
|
416
|
+
"patient_uuid",
|
|
417
|
+
*list(empty.values()),
|
|
418
|
+
*list(empty.values()), # hint
|
|
419
|
+
*list(empty.values()), # help
|
|
420
|
+
"", # default
|
|
421
|
+
"", #'appearance', clean_name
|
|
422
|
+
"", #'constraint',
|
|
423
|
+
*list(empty.values()), #'constraint_message'
|
|
424
|
+
"", #'relevance'
|
|
425
|
+
"", #'disabled'
|
|
426
|
+
"", #'required'
|
|
427
|
+
*list(empty.values()), #'required message'
|
|
428
|
+
"", #'read only'
|
|
429
|
+
"../inputs/user/facility_id", #'expression'
|
|
430
|
+
"", #'repeat_count'
|
|
431
|
+
"", #'image'
|
|
432
|
+
"", # choice filter
|
|
433
|
+
]
|
|
292
434
|
df_input.loc[len(df_input)] = [
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
*list(
|
|
296
|
-
*list(empty.values())
|
|
297
|
-
*list(empty.values())
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
*list(empty.values())
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
*list(empty.values())
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
]
|
|
312
|
-
|
|
313
|
-
'string', 'data_load',
|
|
314
|
-
*list(langs.get_trads('NO_LABEL', force_dict = True).values()),
|
|
315
|
-
*list(empty.values()),
|
|
316
|
-
*list(empty.values()),
|
|
317
|
-
'', 'hidden', '',
|
|
318
|
-
*list(empty.values()),
|
|
319
|
-
'', '','',
|
|
320
|
-
*list(empty.values())
|
|
321
|
-
,'', '', '', '' ,''
|
|
322
|
-
]
|
|
323
|
-
|
|
435
|
+
"hidden",
|
|
436
|
+
"data_load",
|
|
437
|
+
*list(langs.get_trads("NO_LABEL", force_dict=True).values()),
|
|
438
|
+
*list(empty.values()),
|
|
439
|
+
*list(empty.values()),
|
|
440
|
+
"",
|
|
441
|
+
"hidden",
|
|
442
|
+
"",
|
|
443
|
+
*list(empty.values()),
|
|
444
|
+
"",
|
|
445
|
+
"",
|
|
446
|
+
"",
|
|
447
|
+
*list(empty.values()),
|
|
448
|
+
"",
|
|
449
|
+
"",
|
|
450
|
+
"",
|
|
451
|
+
"",
|
|
452
|
+
"",
|
|
453
|
+
]
|
|
454
|
+
|
|
324
455
|
for input in inputs:
|
|
325
|
-
df_input.loc[len(df_input)] = get_input_calc_line(input)
|
|
456
|
+
df_input.loc[len(df_input)] = get_input_calc_line(input)
|
|
326
457
|
|
|
327
|
-
|
|
328
|
-
|
|
329
458
|
return df_input
|
|
330
|
-
|
|
331
|
-
def get_contact_inputs(self, df_input):
|
|
332
|
-
empty = langs.get_trads('', force_dict =True)
|
|
333
459
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
460
|
+
def get_contact_inputs(self, df_input):
|
|
461
|
+
empty = langs.get_trads("", force_dict=True)
|
|
462
|
+
|
|
463
|
+
df_input.loc[len(df_input)] = [
|
|
464
|
+
"calculate",
|
|
465
|
+
"patient_sex",
|
|
466
|
+
*list(langs.get_trads("Sex", force_dict=True).values()),
|
|
337
467
|
*list(empty.values()),
|
|
338
468
|
*list(empty.values()),
|
|
339
|
-
|
|
469
|
+
"",
|
|
470
|
+
"hidden",
|
|
471
|
+
"",
|
|
472
|
+
*list(empty.values()),
|
|
473
|
+
"",
|
|
474
|
+
"",
|
|
475
|
+
"",
|
|
476
|
+
*list(empty.values()),
|
|
477
|
+
"",
|
|
478
|
+
"../inputs/contact/sex",
|
|
479
|
+
"",
|
|
480
|
+
"",
|
|
481
|
+
"",
|
|
482
|
+
]
|
|
483
|
+
df_input.loc[len(df_input)] = [
|
|
484
|
+
"calculate",
|
|
485
|
+
"patient_dob",
|
|
486
|
+
*list(langs.get_trads("Date of birth", force_dict=True).values()),
|
|
340
487
|
*list(empty.values()),
|
|
341
|
-
'', '','',
|
|
342
|
-
*list(empty.values())
|
|
343
|
-
,'', '../inputs/contact/sex', '', '' ,''
|
|
344
|
-
]
|
|
345
|
-
df_input.loc[len(df_input)] = [
|
|
346
|
-
'calculate', 'patient_dob',
|
|
347
|
-
*list(langs.get_trads('Date of birth', force_dict = True).values()),
|
|
348
488
|
*list(empty.values()),
|
|
489
|
+
"",
|
|
490
|
+
"hidden",
|
|
491
|
+
"",
|
|
349
492
|
*list(empty.values()),
|
|
350
|
-
|
|
493
|
+
"",
|
|
494
|
+
"",
|
|
495
|
+
"",
|
|
351
496
|
*list(empty.values()),
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
,
|
|
355
|
-
|
|
356
|
-
|
|
497
|
+
"",
|
|
498
|
+
"date(../inputs/contact/date_of_birth)",
|
|
499
|
+
"",
|
|
500
|
+
"",
|
|
501
|
+
"",
|
|
502
|
+
]
|
|
503
|
+
|
|
357
504
|
return df_input
|
|
358
|
-
|
|
505
|
+
|
|
359
506
|
def get_cht_summary(self):
|
|
360
|
-
|
|
361
507
|
df_summary = pd.DataFrame(columns=SURVEY_MAP.keys())
|
|
362
|
-
|
|
363
|
-
#df_summary.loc[len(df_summary)] = [ 'begin group', 'group_summary' , 'Summary', '', '', '', 'field-list summary', '', '', '', '', '', '', '', '', '', '' ]
|
|
364
|
-
#df_summary.loc[len(df_summary)] = [ 'note', 'r_patient_info', '**${patient_name}** ID: ${patient_id}', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ]
|
|
365
|
-
#df_summary.loc[len(df_summary)] = [ 'note', 'r_followup', 'Follow Up <i class=“fa fa-flag”></i>', '', '', '', '', '', '','', '', '', '', '', '', '', '' ]
|
|
366
|
-
#df_summary.loc[len(df_summary)] = [ 'note', 'r_followup_note' ,'FOLLOWUP instruction', '', '', '', '', '', '', '','', '', '', '', '', '', '' ]
|
|
367
|
-
#df_summary.loc[len(df_summary)] = [ 'end group', '' ,'', '', '', '', '', '', '', '', '', '', '', '', '','', '' ]
|
|
508
|
+
# [ #type, '',#name ''#label, '',#hint '',#help '',#default '',#'appearance', '',#'constraint', '',#'constraint_message' '',#'relevance' '',#'disabled' '',#'required' '',#'required message' '',#'read only' '',#'expression' '',#'repeat_count' ''#'image' ],
|
|
509
|
+
# df_summary.loc[len(df_summary)] = [ 'begin group', 'group_summary' , 'Summary', '', '', '', 'field-list summary', '', '', '', '', '', '', '', '', '', '' ]
|
|
510
|
+
# df_summary.loc[len(df_summary)] = [ 'note', 'r_patient_info', '**${patient_name}** ID: ${patient_id}', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ]
|
|
511
|
+
# df_summary.loc[len(df_summary)] = [ 'note', 'r_followup', 'Follow Up <i class=“fa fa-flag”></i>', '', '', '', '', '', '','', '', '', '', '', '', '', '' ]
|
|
512
|
+
# df_summary.loc[len(df_summary)] = [ 'note', 'r_followup_note' ,'FOLLOWUP instruction', '', '', '', '', '', '', '','', '', '', '', '', '', '' ]
|
|
513
|
+
# df_summary.loc[len(df_summary)] = [ 'end group', '' ,'', '', '', '', '', '', '', '', '', '', '', '', '','', '' ]
|
|
368
514
|
return df_summary
|
|
369
|
-
|
|
515
|
+
|
|
370
516
|
def get_last_prev_index(self, df, e, depth=0):
|
|
371
517
|
latest = None
|
|
372
518
|
for p in e.prev_nodes:
|
|
373
519
|
if issubclass(p.__class__, (TriccNodeDisplayModel)):
|
|
374
|
-
if hasattr(p,
|
|
520
|
+
if hasattr(p, "select"):
|
|
375
521
|
p = latest.select
|
|
376
|
-
index = df.index[df[
|
|
377
|
-
|
|
378
|
-
if not latest or (
|
|
522
|
+
index = df.index[df["name"] == get_export_name(p)].tolist()
|
|
523
|
+
|
|
524
|
+
if not latest or (index and index[-1] > latest):
|
|
379
525
|
latest = index[-1]
|
|
380
526
|
if latest is None and depth > 5:
|
|
381
527
|
for p in e.prev_nodes:
|
|
382
|
-
index = get_last_prev_index(df, e, depth+1)
|
|
383
|
-
if not latest and index and index > latest
|
|
528
|
+
index = get_last_prev_index(df, e, depth + 1)
|
|
529
|
+
if not latest and index and index > latest:
|
|
384
530
|
latest = index
|
|
385
531
|
return latest
|
|
386
|
-
|
|
532
|
+
|
|
387
533
|
def export(self, start_pages, version, **kwargs):
|
|
388
534
|
form_id = None
|
|
389
535
|
if start_pages[self.processes[0]].root.form_id is not None:
|
|
390
|
-
form_id= str(start_pages[self.processes[0]].root.form_id
|
|
536
|
+
form_id = str(start_pages[self.processes[0]].root.form_id)
|
|
391
537
|
else:
|
|
392
538
|
logger.critical("form id required in the first start node")
|
|
393
539
|
exit(1)
|
|
@@ -395,62 +541,88 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
|
|
|
395
541
|
file_name = form_id + ".xlsx"
|
|
396
542
|
# make a 'settings' tab
|
|
397
543
|
now = datetime.datetime.now()
|
|
398
|
-
version=now.strftime(
|
|
399
|
-
indx=[[1]]
|
|
544
|
+
version = now.strftime("%Y%m%d%H%M")
|
|
545
|
+
indx = [[1]]
|
|
400
546
|
# CHT FORCE file name to be equal to id
|
|
401
|
-
|
|
547
|
+
|
|
402
548
|
newfilename = form_id + ".xlsx"
|
|
403
549
|
newpath = os.path.join(self.output_path, newfilename)
|
|
404
550
|
media_path = os.path.join(self.output_path, form_id + "-media")
|
|
405
551
|
|
|
406
|
-
settings={
|
|
407
|
-
|
|
552
|
+
settings = {
|
|
553
|
+
"form_title": title,
|
|
554
|
+
"form_id": form_id,
|
|
555
|
+
"version": version,
|
|
556
|
+
"default_language": "English (en)",
|
|
557
|
+
"style": "pages",
|
|
558
|
+
}
|
|
559
|
+
df_settings = pd.DataFrame(settings, index=indx)
|
|
408
560
|
df_settings.head()
|
|
409
|
-
if len(self.df_survey[self.df_survey[
|
|
410
|
-
self.df_survey.loc[
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
561
|
+
if len(self.df_survey[self.df_survey["name"] == "version"]):
|
|
562
|
+
self.df_survey.loc[self.df_survey["name"] == "version", "label"] = (
|
|
563
|
+
f"v{version}"
|
|
564
|
+
)
|
|
565
|
+
# create a Pandas Excel writer using XlsxWriter as the engine
|
|
566
|
+
writer = pd.ExcelWriter(newpath, engine="xlsxwriter")
|
|
567
|
+
self.df_survey.to_excel(writer, sheet_name="survey", index=False)
|
|
568
|
+
self.df_choice.to_excel(writer, sheet_name="choices", index=False)
|
|
569
|
+
df_settings.to_excel(writer, sheet_name="settings", index=False)
|
|
416
570
|
writer.close()
|
|
417
571
|
# pause
|
|
418
572
|
ends = []
|
|
419
573
|
for p in self.project.pages.values():
|
|
420
|
-
p_ends = list(
|
|
574
|
+
p_ends = list(
|
|
575
|
+
filter(
|
|
576
|
+
lambda x: issubclass(x.__class__, TriccNodeEnd)
|
|
577
|
+
and getattr(x, "process", "") == "pause",
|
|
578
|
+
p.nodes.values(),
|
|
579
|
+
)
|
|
580
|
+
)
|
|
421
581
|
if p_ends:
|
|
422
582
|
ends += p_ends
|
|
423
583
|
if ends:
|
|
424
584
|
ends_prev = []
|
|
425
585
|
for e in ends:
|
|
426
|
-
|
|
427
586
|
latest = self.get_last_prev_index(self.df_survey, e)
|
|
428
|
-
if latest:
|
|
587
|
+
if latest:
|
|
429
588
|
ends_prev.append(
|
|
430
|
-
(
|
|
589
|
+
(
|
|
590
|
+
int(latest),
|
|
591
|
+
e,
|
|
592
|
+
)
|
|
431
593
|
)
|
|
432
594
|
else:
|
|
433
|
-
logger.critical(
|
|
595
|
+
logger.critical(
|
|
596
|
+
f"impossible to get last index before pause: {e.get_name()}"
|
|
597
|
+
)
|
|
434
598
|
forms = [form_id]
|
|
435
599
|
for i, e in ends_prev:
|
|
436
600
|
new_form_id = f"{form_id}_{clean_name(e.name)}"
|
|
437
601
|
newfilename = f"{new_form_id}.xlsx"
|
|
438
602
|
newpath = os.path.join(self.output_path, newfilename)
|
|
439
|
-
settings={
|
|
440
|
-
|
|
603
|
+
settings = {
|
|
604
|
+
"form_title": title,
|
|
605
|
+
"form_id": f"{new_form_id}",
|
|
606
|
+
"version": version,
|
|
607
|
+
"default_language": "English (en)",
|
|
608
|
+
"style": "pages",
|
|
609
|
+
}
|
|
610
|
+
df_settings = pd.DataFrame(settings, index=indx)
|
|
441
611
|
df_settings.head()
|
|
442
|
-
task_df, hidden_names = make_breakpoints(
|
|
612
|
+
task_df, hidden_names = make_breakpoints(
|
|
613
|
+
self.df_survey, i, e.name, replace_dots=True
|
|
614
|
+
)
|
|
443
615
|
# deactivate the end node
|
|
444
|
-
task_df.loc[task_df[
|
|
445
|
-
#print fileds
|
|
446
|
-
writer = pd.ExcelWriter(newpath, engine=
|
|
447
|
-
task_df.to_excel(writer, sheet_name=
|
|
448
|
-
self.df_choice.to_excel(writer, sheet_name=
|
|
449
|
-
df_settings.to_excel(writer, sheet_name=
|
|
616
|
+
task_df.loc[task_df["name"] == get_export_name(e), "calculation"] = 0
|
|
617
|
+
# print fileds
|
|
618
|
+
writer = pd.ExcelWriter(newpath, engine="xlsxwriter")
|
|
619
|
+
task_df.to_excel(writer, sheet_name="survey", index=False)
|
|
620
|
+
self.df_choice.to_excel(writer, sheet_name="choices", index=False)
|
|
621
|
+
df_settings.to_excel(writer, sheet_name="settings", index=False)
|
|
450
622
|
writer.close()
|
|
451
623
|
newfilename = f"{new_form_id}.js"
|
|
452
624
|
newpath = os.path.join(self.output_path, newfilename)
|
|
453
|
-
with open(newpath,
|
|
625
|
+
with open(newpath, "w") as f:
|
|
454
626
|
f.write(
|
|
455
627
|
get_task_js(
|
|
456
628
|
new_form_id,
|
|
@@ -460,21 +632,21 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
|
|
|
460
632
|
hidden_names,
|
|
461
633
|
self.df_survey,
|
|
462
634
|
repalce_dots=False,
|
|
463
|
-
task_title=e.hint
|
|
635
|
+
task_title=e.hint,
|
|
464
636
|
)
|
|
465
637
|
)
|
|
466
638
|
f.close()
|
|
467
639
|
forms.append(new_form_id)
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
640
|
+
|
|
641
|
+
media_path_tmp = os.path.join(self.output_path, "media-tmp")
|
|
642
|
+
if os.path.isdir(media_path_tmp):
|
|
643
|
+
if os.path.isdir(
|
|
644
|
+
media_path
|
|
645
|
+
): # check if it exists, because if it does, error will be raised
|
|
474
646
|
shutil.rmtree(media_path)
|
|
475
647
|
# (later change to make folder complaint to CHT)
|
|
476
648
|
os.mkdir(media_path)
|
|
477
|
-
|
|
649
|
+
|
|
478
650
|
file_names = os.listdir(media_path_tmp)
|
|
479
651
|
for file_name in file_names:
|
|
480
652
|
shutil.move(os.path.join(media_path_tmp, file_name), media_path)
|
|
@@ -484,15 +656,15 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
|
|
|
484
656
|
y, ll, m, s = self.get_zscore_params(ref_expressions)
|
|
485
657
|
# return ((Math.pow((y / m), l) - 1) / (s * l));
|
|
486
658
|
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])})"
|
|
487
|
-
|
|
488
|
-
|
|
659
|
+
|
|
489
660
|
def tricc_operation_izscore(self, ref_expressions):
|
|
490
661
|
z, ll, m, s = self.get_zscore_params(ref_expressions)
|
|
491
662
|
# return (m * (z*s*l-1)^(1/l));
|
|
492
663
|
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)"
|
|
493
|
-
|
|
664
|
+
|
|
494
665
|
def tricc_operation_drug_dosage(self, ref_expressions):
|
|
495
666
|
# drug name
|
|
496
667
|
# age
|
|
497
|
-
#weight
|
|
498
|
-
return f"cht:extension-lib('drugs.js',{','.join(map(self.clean_coalesce, ref_expressions))})"
|
|
668
|
+
# weight
|
|
669
|
+
return f"cht:extension-lib('drugs.js',{','.join(map(self.clean_coalesce, ref_expressions))})"
|
|
670
|
+
|