tricc-oo 1.5.23__tar.gz → 1.5.25__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. {tricc_oo-1.5.23/tricc_oo.egg-info → tricc_oo-1.5.25}/PKG-INFO +125 -84
  2. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/README.md +124 -83
  3. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/pyproject.toml +1 -1
  4. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tests/build.py +12 -11
  5. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tests/test_cql.py +4 -4
  6. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/datadictionnary.py +6 -1
  7. tricc_oo-1.5.25/tricc_oo/converters/tricc_to_xls_form.py +86 -0
  8. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/utils.py +1 -1
  9. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/models/tricc.py +3 -1
  10. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/serializers/xls_form.py +1 -9
  11. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/input/drawio.py +2 -2
  12. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/output/base_output_strategy.py +34 -0
  13. tricc_oo-1.5.25/tricc_oo/strategies/output/fhir_form.py +377 -0
  14. tricc_oo-1.5.25/tricc_oo/strategies/output/html_form.py +224 -0
  15. tricc_oo-1.5.25/tricc_oo/strategies/output/openmrs_form.py +647 -0
  16. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/output/xls_form.py +47 -84
  17. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/output/xlsform_cht.py +2 -2
  18. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/visitors/tricc.py +118 -8
  19. {tricc_oo-1.5.23 → tricc_oo-1.5.25/tricc_oo.egg-info}/PKG-INFO +125 -84
  20. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo.egg-info/SOURCES.txt +3 -0
  21. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo.egg-info/top_level.txt +1 -0
  22. tricc_oo-1.5.23/tricc_oo/converters/tricc_to_xls_form.py +0 -55
  23. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/LICENSE +0 -0
  24. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/setup.cfg +0 -0
  25. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tests/to_ocl.py +0 -0
  26. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/__init__.py +0 -0
  27. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/__init__.py +0 -0
  28. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  29. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  30. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/cql/cqlListener.py +0 -0
  31. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/cql/cqlParser.py +0 -0
  32. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  33. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/cql_to_operation.py +0 -0
  34. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/drawio_type_map.py +0 -0
  35. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/converters/xml_to_tricc.py +0 -0
  36. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/models/__init__.py +0 -0
  37. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/models/base.py +0 -0
  38. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/models/calculate.py +0 -0
  39. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/models/lang.py +0 -0
  40. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/models/ocl.py +0 -0
  41. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/models/ordered_set.py +0 -0
  42. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/parsers/__init__.py +0 -0
  43. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/parsers/xml.py +0 -0
  44. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/serializers/__init__.py +0 -0
  45. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/serializers/planuml.py +0 -0
  46. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/__init__.py +0 -0
  47. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/input/__init__.py +0 -0
  48. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  49. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/output/spice.py +0 -0
  50. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  51. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  52. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/visitors/__init__.py +0 -0
  53. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/visitors/utils.py +0 -0
  54. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo/visitors/xform_pd.py +0 -0
  55. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo.egg-info/dependency_links.txt +0 -0
  56. {tricc_oo-1.5.23 → tricc_oo-1.5.25}/tricc_oo.egg-info/requires.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.5.23
3
+ Version: 1.5.25
4
4
  Summary: Python library that converts CDSS L2 in L3
5
5
  Project-URL: Homepage, https://github.com/SwissTPH/tricc
6
6
  Project-URL: Issues, https://github.com/SwissTPH/tricc/issues
@@ -26,7 +26,130 @@ Requires-Dist: beautifulsoup4
26
26
  Requires-Dist: ocldev
27
27
  Dynamic: license-file
28
28
 
29
- # design rules tricc_oo
29
+ # TRICC-OO
30
+
31
+
32
+ ## Strategy
33
+
34
+ ### XLSFormStrategy
35
+
36
+ to use on OKD and clones,
37
+
38
+ ### XLSFormCDSSStrategy
39
+
40
+ based on XLSFormStrategy
41
+ to use on OKD and clones,
42
+ support the CDSS specific behaviour such as Classification management
43
+
44
+ ### XLSFormCHTStrategy
45
+
46
+ based on XLSFormCDSSStrategy
47
+ to use on medic CHT if the questionnaire is run Patient level
48
+ Support the inputs from patient
49
+ Support the extention libs
50
+
51
+ ### XLSFormCHTHFStrategy
52
+
53
+ based on XLSFormCHTStrategy
54
+ to use on medic CHT if the questionnaire is run on Health facility level without selecting a patient
55
+ Support inputs from HF
56
+
57
+
58
+ ### OpenMRSStrategy
59
+
60
+ (under development)
61
+
62
+ ### FhirStrategy
63
+
64
+ (UNTESTED)
65
+
66
+ ### HTMLStrategy
67
+
68
+ (UNTESTED)
69
+
70
+ ## start nodes
71
+
72
+ ### Main start
73
+
74
+ the flow required at least 1 main start node, but in case of cdss output strategy , several could be used given that they have a 'process' atrribute
75
+
76
+ here is the list of the CPG process, this will be the execution oder too:
77
+ - **registration**,
78
+ - **triage**,
79
+ - **emergency-care**,
80
+ - **local-urgent-care**,
81
+ - **actue-tertiary-care**,
82
+ - **history-and-physical**,
83
+ - **diagnostic-testing**,
84
+ - **determine-diagnosis**,
85
+ - **provide-counseling**,
86
+ - **dispense-medications**,
87
+ - **monitor-and-follow-up-of-patient**,
88
+ - **alerts-reminders-education**,
89
+ - **discharge-referral-of-patient**,
90
+ - **charge-for-service**,
91
+ - **record-and-report**
92
+
93
+
94
+
95
+
96
+ # Note
97
+
98
+ ## generation of the expressions
99
+
100
+ ### add calcualte:
101
+
102
+ - Non or No in an egde will generate a negate node
103
+ - save adds a calcualte
104
+ - a rhombus will generate a calcualte using the reference (can you the label as a test, either with comparaisin or option selected with [option label])
105
+
106
+ ### for calculate
107
+
108
+ Then we calculate based on the previous nodes: [get_prev_node_expression]
109
+ - if a "fake" calculate (Rhombus, exclusion) then get the underlying expression (should not depend of Calcualte = true) [get_calculation_terms]
110
+ - if a Select, manage it as a calculate too (should not depend of Calcualte = true) [get_calculation_terms]
111
+ - else get the expression via [get_calculation_terms] [get_prev_node_expression , calculate = False] -> get_node_expression for the prev node
112
+
113
+ # Running directly
114
+
115
+ `tricc` is technically a python library, but you can run it directly via the [`build.py` script](./tests/build.py).
116
+
117
+ ## Running with Docker
118
+
119
+ Alternatively, if you prefer to build/run the project with Docker, you can do the following.
120
+
121
+ Start by building the Docker image:
122
+
123
+ ```shell
124
+ git clone https://github.com/SwissTPH/tricc.git
125
+ cd tricc
126
+
127
+ docker build -t tricc .
128
+ ```
129
+
130
+ Once you have the image built you can use it to convert local `.drawio` files by mapping the local directory to the `docker run` command. (Note that `--user` is specified to make sure the current host user has write access to the output files.)
131
+
132
+ ```shell
133
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc --help
134
+ ```
135
+
136
+ This command will convert all `.drawio` files in the current directory:
137
+
138
+ ```shell
139
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj
140
+ ```
141
+
142
+ You can also convert a single file:
143
+
144
+ ```shell
145
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj/demo.drawio -o /proj
146
+ ```
147
+
148
+ Use the `-O` flag to specify the output strategy. For example to generate CHT files:
149
+
150
+ ```shell
151
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj -O XLSFormCHTStrategy
152
+ ```
30
153
 
31
154
  ## Nodes
32
155
 
@@ -133,90 +256,8 @@ if not a calculate then relevance will be used unless it is "required" then cond
133
256
  the Rhombus act as an AND between its imputs and its reference BUT it is an OR beween the inputs
134
257
  (input1 OR input2 OR input3) AND reference
135
258
 
136
- ## start nodes
137
-
138
- ### Main start
139
-
140
- the flow required at least 1 main start node, but in case of cdss output strategy , several could be used given that they have a 'process' atrribute
141
-
142
- here is the list of the CPG process, this will be the execution oder too:
143
- - **registration**,
144
- - **triage**,
145
- - **emergency-care**,
146
- - **local-urgent-care**,
147
- - **actue-tertiary-care**,
148
- - **history-and-physical**,
149
- - **diagnostic-testing**,
150
- - **determine-diagnosis**,
151
- - **provide-counseling**,
152
- - **dispense-medications**,
153
- - **monitor-and-follow-up-of-patient**,
154
- - **alerts-reminders-education**,
155
- - **discharge-referral-of-patient**,
156
- - **charge-for-service**,
157
- - **record-and-report**
158
-
159
-
160
259
  # READ Xressource
161
260
  https://jgraph.github.io/drawio-tools/tools/convert.html
162
261
 
163
262
  option can have only incoming edge from images to be placed as option$
164
263
 
165
-
166
- # Note
167
-
168
- ## generation of the expressions
169
-
170
- ### add calcualte:
171
-
172
- - Non or No in an egde will generate a negate node
173
- - save adds a calcualte
174
- - a rhombus will generate a calcualte using the reference (can you the label as a test, either with comparaisin or option selected with [option label])
175
-
176
- ### for calculate
177
-
178
- Then we calculate based on the previous nodes: [get_prev_node_expression]
179
- - if a "fake" calculate (Rhombus, exclusion) then get the underlying expression (should not depend of Calcualte = true) [get_calculation_terms]
180
- - if a Select, manage it as a calculate too (should not depend of Calcualte = true) [get_calculation_terms]
181
- - else get the expression via [get_calculation_terms] [get_prev_node_expression , calculate = False] -> get_node_expression for the prev node
182
-
183
- # Running directly
184
-
185
- `tricc` is technically a python library, but you can run it directly via the [`build.py` script](./tests/build.py).
186
-
187
- ## Running with Docker
188
-
189
- Alternatively, if you prefer to build/run the project with Docker, you can do the following.
190
-
191
- Start by building the Docker image:
192
-
193
- ```shell
194
- git clone https://github.com/SwissTPH/tricc.git
195
- cd tricc
196
-
197
- docker build -t tricc .
198
- ```
199
-
200
- Once you have the image built you can use it to convert local `.drawio` files by mapping the local directory to the `docker run` command. (Note that `--user` is specified to make sure the current host user has write access to the output files.)
201
-
202
- ```shell
203
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc --help
204
- ```
205
-
206
- This command will convert all `.drawio` files in the current directory:
207
-
208
- ```shell
209
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj
210
- ```
211
-
212
- You can also convert a single file:
213
-
214
- ```shell
215
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj/demo.drawio -o /proj
216
- ```
217
-
218
- Use the `-O` flag to specify the output strategy. For example to generate CHT files:
219
-
220
- ```shell
221
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj -O XLSFormCHTStrategy
222
- ```
@@ -1,4 +1,127 @@
1
- # design rules tricc_oo
1
+ # TRICC-OO
2
+
3
+
4
+ ## Strategy
5
+
6
+ ### XLSFormStrategy
7
+
8
+ to use on OKD and clones,
9
+
10
+ ### XLSFormCDSSStrategy
11
+
12
+ based on XLSFormStrategy
13
+ to use on OKD and clones,
14
+ support the CDSS specific behaviour such as Classification management
15
+
16
+ ### XLSFormCHTStrategy
17
+
18
+ based on XLSFormCDSSStrategy
19
+ to use on medic CHT if the questionnaire is run Patient level
20
+ Support the inputs from patient
21
+ Support the extention libs
22
+
23
+ ### XLSFormCHTHFStrategy
24
+
25
+ based on XLSFormCHTStrategy
26
+ to use on medic CHT if the questionnaire is run on Health facility level without selecting a patient
27
+ Support inputs from HF
28
+
29
+
30
+ ### OpenMRSStrategy
31
+
32
+ (under development)
33
+
34
+ ### FhirStrategy
35
+
36
+ (UNTESTED)
37
+
38
+ ### HTMLStrategy
39
+
40
+ (UNTESTED)
41
+
42
+ ## start nodes
43
+
44
+ ### Main start
45
+
46
+ the flow required at least 1 main start node, but in case of cdss output strategy , several could be used given that they have a 'process' atrribute
47
+
48
+ here is the list of the CPG process, this will be the execution oder too:
49
+ - **registration**,
50
+ - **triage**,
51
+ - **emergency-care**,
52
+ - **local-urgent-care**,
53
+ - **actue-tertiary-care**,
54
+ - **history-and-physical**,
55
+ - **diagnostic-testing**,
56
+ - **determine-diagnosis**,
57
+ - **provide-counseling**,
58
+ - **dispense-medications**,
59
+ - **monitor-and-follow-up-of-patient**,
60
+ - **alerts-reminders-education**,
61
+ - **discharge-referral-of-patient**,
62
+ - **charge-for-service**,
63
+ - **record-and-report**
64
+
65
+
66
+
67
+
68
+ # Note
69
+
70
+ ## generation of the expressions
71
+
72
+ ### add calcualte:
73
+
74
+ - Non or No in an egde will generate a negate node
75
+ - save adds a calcualte
76
+ - a rhombus will generate a calcualte using the reference (can you the label as a test, either with comparaisin or option selected with [option label])
77
+
78
+ ### for calculate
79
+
80
+ Then we calculate based on the previous nodes: [get_prev_node_expression]
81
+ - if a "fake" calculate (Rhombus, exclusion) then get the underlying expression (should not depend of Calcualte = true) [get_calculation_terms]
82
+ - if a Select, manage it as a calculate too (should not depend of Calcualte = true) [get_calculation_terms]
83
+ - else get the expression via [get_calculation_terms] [get_prev_node_expression , calculate = False] -> get_node_expression for the prev node
84
+
85
+ # Running directly
86
+
87
+ `tricc` is technically a python library, but you can run it directly via the [`build.py` script](./tests/build.py).
88
+
89
+ ## Running with Docker
90
+
91
+ Alternatively, if you prefer to build/run the project with Docker, you can do the following.
92
+
93
+ Start by building the Docker image:
94
+
95
+ ```shell
96
+ git clone https://github.com/SwissTPH/tricc.git
97
+ cd tricc
98
+
99
+ docker build -t tricc .
100
+ ```
101
+
102
+ Once you have the image built you can use it to convert local `.drawio` files by mapping the local directory to the `docker run` command. (Note that `--user` is specified to make sure the current host user has write access to the output files.)
103
+
104
+ ```shell
105
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc --help
106
+ ```
107
+
108
+ This command will convert all `.drawio` files in the current directory:
109
+
110
+ ```shell
111
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj
112
+ ```
113
+
114
+ You can also convert a single file:
115
+
116
+ ```shell
117
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj/demo.drawio -o /proj
118
+ ```
119
+
120
+ Use the `-O` flag to specify the output strategy. For example to generate CHT files:
121
+
122
+ ```shell
123
+ docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj -O XLSFormCHTStrategy
124
+ ```
2
125
 
3
126
  ## Nodes
4
127
 
@@ -105,90 +228,8 @@ if not a calculate then relevance will be used unless it is "required" then cond
105
228
  the Rhombus act as an AND between its imputs and its reference BUT it is an OR beween the inputs
106
229
  (input1 OR input2 OR input3) AND reference
107
230
 
108
- ## start nodes
109
-
110
- ### Main start
111
-
112
- the flow required at least 1 main start node, but in case of cdss output strategy , several could be used given that they have a 'process' atrribute
113
-
114
- here is the list of the CPG process, this will be the execution oder too:
115
- - **registration**,
116
- - **triage**,
117
- - **emergency-care**,
118
- - **local-urgent-care**,
119
- - **actue-tertiary-care**,
120
- - **history-and-physical**,
121
- - **diagnostic-testing**,
122
- - **determine-diagnosis**,
123
- - **provide-counseling**,
124
- - **dispense-medications**,
125
- - **monitor-and-follow-up-of-patient**,
126
- - **alerts-reminders-education**,
127
- - **discharge-referral-of-patient**,
128
- - **charge-for-service**,
129
- - **record-and-report**
130
-
131
-
132
231
  # READ Xressource
133
232
  https://jgraph.github.io/drawio-tools/tools/convert.html
134
233
 
135
234
  option can have only incoming edge from images to be placed as option$
136
235
 
137
-
138
- # Note
139
-
140
- ## generation of the expressions
141
-
142
- ### add calcualte:
143
-
144
- - Non or No in an egde will generate a negate node
145
- - save adds a calcualte
146
- - a rhombus will generate a calcualte using the reference (can you the label as a test, either with comparaisin or option selected with [option label])
147
-
148
- ### for calculate
149
-
150
- Then we calculate based on the previous nodes: [get_prev_node_expression]
151
- - if a "fake" calculate (Rhombus, exclusion) then get the underlying expression (should not depend of Calcualte = true) [get_calculation_terms]
152
- - if a Select, manage it as a calculate too (should not depend of Calcualte = true) [get_calculation_terms]
153
- - else get the expression via [get_calculation_terms] [get_prev_node_expression , calculate = False] -> get_node_expression for the prev node
154
-
155
- # Running directly
156
-
157
- `tricc` is technically a python library, but you can run it directly via the [`build.py` script](./tests/build.py).
158
-
159
- ## Running with Docker
160
-
161
- Alternatively, if you prefer to build/run the project with Docker, you can do the following.
162
-
163
- Start by building the Docker image:
164
-
165
- ```shell
166
- git clone https://github.com/SwissTPH/tricc.git
167
- cd tricc
168
-
169
- docker build -t tricc .
170
- ```
171
-
172
- Once you have the image built you can use it to convert local `.drawio` files by mapping the local directory to the `docker run` command. (Note that `--user` is specified to make sure the current host user has write access to the output files.)
173
-
174
- ```shell
175
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc --help
176
- ```
177
-
178
- This command will convert all `.drawio` files in the current directory:
179
-
180
- ```shell
181
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj
182
- ```
183
-
184
- You can also convert a single file:
185
-
186
- ```shell
187
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj/demo.drawio -o /proj
188
- ```
189
-
190
- Use the `-O` flag to specify the output strategy. For example to generate CHT files:
191
-
192
- ```shell
193
- docker run --rm -v "$PWD":/proj --user $(id -u):$(id -g) tricc -i /proj -o /proj -O XLSFormCHTStrategy
194
- ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tricc-oo"
7
- version = "1.5.23"
7
+ version = "1.5.25"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,16 +1,17 @@
1
- from tricc_oo.strategies.output.spice import SpiceStrategy
2
- from tricc_oo.strategies.output.xlsform_cht_hf import XLSFormCHTHFStrategy
3
- from tricc_oo.strategies.output.xlsform_cht import XLSFormCHTStrategy
4
- from tricc_oo.strategies.output.xlsform_cdss import XLSFormCDSSStrategy
5
- from tricc_oo.strategies.output.xls_form import XLSFormStrategy
6
- from tricc_oo.strategies.input.drawio import DrawioStrategy
1
+ from tricc_oo.strategies.output.spice import SpiceStrategy # noqa: F401
2
+ from tricc_oo.strategies.output.xlsform_cht_hf import XLSFormCHTHFStrategy # noqa: F401
3
+ from tricc_oo.strategies.output.xlsform_cht import XLSFormCHTStrategy # noqa: F401
4
+ from tricc_oo.strategies.output.xlsform_cdss import XLSFormCDSSStrategy # noqa: F401
5
+ from tricc_oo.strategies.output.xls_form import XLSFormStrategy # noqa: F401
6
+ from tricc_oo.strategies.output.openmrs_form import OpenMRSStrategy # noqa: F401
7
+ from tricc_oo.strategies.output.fhir_form import FHIRStrategy # noqa: F401
8
+ from tricc_oo.strategies.output.html_form import HTMLStrategy # noqa: F401
9
+ from tricc_oo.strategies.input.drawio import DrawioStrategy # noqa: F401
7
10
  import getopt
8
- import gettext
9
11
  import logging
10
12
  import os
11
13
  import sys
12
14
  import gc
13
- import shutil
14
15
  from pathlib import Path
15
16
 
16
17
  # set up logging to file
@@ -39,15 +40,15 @@ def setup_logger(
39
40
  level=logging.INFO,
40
41
  formatting="[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s",
41
42
  ):
42
- l = logging.getLogger(logger_name)
43
+ logger = logging.getLogger(logger_name)
43
44
  formatter = logging.Formatter(formatting)
44
45
  file_handler = logging.FileHandler(log_file, mode="w+")
45
46
  file_handler.setFormatter(formatter)
46
47
  stream_handler = logging.StreamHandler()
47
48
  stream_handler.setFormatter(formatter)
48
49
 
49
- l.setLevel(level)
50
- l.addHandler(file_handler)
50
+ logger.setLevel(level)
51
+ logger.addHandler(file_handler)
51
52
 
52
53
 
53
54
  class ColorFormatter(logging.Formatter):
@@ -53,9 +53,9 @@ class TestCql(unittest.TestCase):
53
53
 
54
54
  def test_case(self):
55
55
  case_cql = """
56
- case AgeInMonths()
57
- when 0 then 'newborn'
58
- when 1 then 'newborn'
56
+ case AgeInMonths()
57
+ when 0 then 'newborn'
58
+ when 1 then 'newborn'
59
59
  else 'child' end
60
60
  """
61
61
  case_operation = transform_cql_to_operation(case_cql)
@@ -72,7 +72,7 @@ class TestCql(unittest.TestCase):
72
72
 
73
73
  def test_ifs(self):
74
74
  case_cql = """
75
- case
75
+ case
76
76
  when AgeInMonths() <= 2 then true
77
77
  when AgeInYears() > 5 then true
78
78
  else false end
@@ -6,9 +6,13 @@ from fhir.resources.codesystem import (
6
6
 
7
7
  from fhir.resources.valueset import ValueSet
8
8
  import logging
9
+ import uuid
9
10
 
10
11
  logger = logging.getLogger("default")
11
12
 
13
+ # Namespace for deterministic UUIDs
14
+ UUID_NAMESPACE = uuid.UUID('12345678-1234-5678-9abc-def012345678')
15
+
12
16
 
13
17
  def lookup_codesystems_code(codesystems, ref):
14
18
  if ref.startswith("final."):
@@ -83,7 +87,8 @@ def check_and_add_concept(code_system: CodeSystem, code: str, display: str, attr
83
87
  new_concept = concept
84
88
  if not new_concept:
85
89
  # Add the new concept if it does not exist
86
- new_concept = CodeSystemConcept.construct(code=code, display=display)
90
+ concept_id = str(uuid.uuid5(UUID_NAMESPACE, display))
91
+ new_concept = CodeSystemConcept.construct(code=code, display=display, id=concept_id)
87
92
  if not hasattr(code_system, "concept"):
88
93
  code_system.concept = []
89
94
  code_system.concept.append(new_concept)
@@ -0,0 +1,86 @@
1
+ import logging
2
+ from tricc_oo.converters.utils import clean_name, clean_str
3
+ from tricc_oo.models.tricc import TriccNodeSelectOption, TRICC_TRUE_VALUE, TRICC_FALSE_VALUE
4
+ from tricc_oo.models.calculate import TriccNodeInput
5
+ from tricc_oo.models.base import TriccNodeBaseModel, TriccStatic, TriccReference
6
+
7
+ # from babel import _
8
+
9
+ # TRICC_SELECT_MULTIPLE_CALC_EXPRESSION = "count-selected(${{{0}}}) - number(selected(${{{0}}},'opt_none'))"
10
+ # TRICC_SELECT_MULTIPLE_CALC_NONE_EXPRESSION = "selected(${{{0}}},'opt_none')"
11
+ # TRICC_CALC_EXPRESSION = "${{{0}}}>0"
12
+ # TRICC_CALC_NOT_EXPRESSION = "${{{0}}}=0"
13
+ # TRICC_EMPTY_EXPRESSION = "coalesce(${{{0}}},'') != ''"
14
+ # TRICC_SELECTED_EXPRESSION = 'selected(${{{0}}}, "{1}")'
15
+ # TRICC_SELECTED_NEGATE_EXPRESSION = 'count-selected(${{{0}}})>0 and not(selected(${{{0}}}, "{1}"))'
16
+ # TRICC_REF_EXPRESSION = "${{{0}}}"
17
+ TRICC_NEGATE = "not({})"
18
+ # TRICC_NUMBER = "number({})"
19
+ # TRICC_AND_EXPRESSION = '{0} and {1}'
20
+ VERSION_SEPARATOR = "_Vv_"
21
+ INSTANCE_SEPARATOR = "_Ii_"
22
+ BOOLEAN_MAP = {
23
+ str(TRICC_TRUE_VALUE): 1,
24
+ str(TRICC_FALSE_VALUE): 0,
25
+ }
26
+
27
+
28
+ logger = logging.getLogger("default")
29
+
30
+ # gettext language dict {'code':gettext}
31
+
32
+
33
+ def get_export_name(node, replace_dots=True):
34
+ if hasattr(node, 'export_name') and node.export_name is not None:
35
+ return node.export_name
36
+ elif isinstance(node, bool):
37
+ return BOOLEAN_MAP[str(TRICC_TRUE_VALUE)] if node else BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
38
+ elif isinstance(node, TriccReference):
39
+ logger.warning(f"Reference {node.value} use in export, bad serialiuation probable")
40
+ return str(node.value)
41
+ elif isinstance(node, (str, TriccStatic, TriccNodeSelectOption)):
42
+ if isinstance(node, TriccNodeSelectOption):
43
+ value = node.name
44
+ elif isinstance(node, TriccStatic):
45
+ value = node.value
46
+ else:
47
+ value = node
48
+ if isinstance(value, bool): # or r.value in ('true', 'false')
49
+ export_name = BOOLEAN_MAP[str(TRICC_TRUE_VALUE)] if value else BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
50
+ elif value == TRICC_TRUE_VALUE:
51
+ export_name = BOOLEAN_MAP[str(TRICC_TRUE_VALUE)]
52
+ elif value == TRICC_FALSE_VALUE:
53
+ export_name = BOOLEAN_MAP[str(TRICC_FALSE_VALUE)]
54
+ elif isinstance(value, str):
55
+ export_name = f"'{clean_str(value, replace_dots=replace_dots)}'"
56
+ else:
57
+ export_name = str(value)
58
+ if hasattr(node, 'export_name'):
59
+ node.export_name = export_name
60
+ return export_name
61
+ elif not hasattr(node, 'export_name'):
62
+ return node
63
+ else:
64
+ node.gen_name()
65
+ if isinstance(node, TriccNodeSelectOption):
66
+ node.export_name = node.name
67
+ elif node.last is False:
68
+ node.export_name = clean_name(
69
+ node.name + VERSION_SEPARATOR + str(node.version),
70
+ replace_dots=replace_dots,
71
+ )
72
+ elif isinstance(node, TriccNodeInput):
73
+ node.export_name = clean_name("load." + node.name, replace_dots=replace_dots)
74
+ else:
75
+ node.export_name = clean_name(node.name, replace_dots=replace_dots)
76
+ return node.export_name
77
+
78
+
79
+ def get_list_names(list):
80
+ names = []
81
+ for elm in list:
82
+ if issubclass(elm.__class__, TriccNodeBaseModel):
83
+ names.append(get_export_name(elm))
84
+ elif isinstance(elm, str):
85
+ names.append(elm)
86
+ return names
@@ -23,7 +23,7 @@ def clean_str(name, replace_dots=False):
23
23
 
24
24
  def clean_name(name, prefix="", replace_dots=False):
25
25
  name = clean_str(name, replace_dots)
26
- if name[0].isdigit():
26
+ if name and name[0].isdigit():
27
27
  name = "id_" + name
28
28
  elif name[0].isdigit() == "_":
29
29
  name = name[1:]
@@ -15,6 +15,8 @@ import logging
15
15
 
16
16
 
17
17
  logger = logging.getLogger(__name__)
18
+ TRICC_TRUE_VALUE = "true"
19
+ TRICC_FALSE_VALUE = "false"
18
20
 
19
21
 
20
22
  class TriccNodeCalculateBase(TriccNodeBaseModel):
@@ -404,7 +406,7 @@ class TriccNodeSelectYesNo(TriccNodeSelectOne):
404
406
  pass
405
407
 
406
408
 
407
- class TriccNodeAcceptDiagnostic(TriccNodeSelectOne):
409
+ class TriccNodeAcceptDiagnostic(TriccNodeSelectYesNo):
408
410
  severity: Optional[str] = None
409
411
  priority: Union[float, int, None] = None
410
412