malac-hd 0.1.1a1__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 (39) hide show
  1. malac-hd-0.1.1a1/LICENSE +165 -0
  2. malac-hd-0.1.1a1/MANIFEST.in +3 -0
  3. malac-hd-0.1.1a1/PKG-INFO +301 -0
  4. malac-hd-0.1.1a1/README.md +116 -0
  5. malac-hd-0.1.1a1/malac/__init__.py +0 -0
  6. malac-hd-0.1.1a1/malac/hd/__init__.py +33 -0
  7. malac-hd-0.1.1a1/malac/hd/__main__.py +98 -0
  8. malac-hd-0.1.1a1/malac/hd/compiler/__init__.py +0 -0
  9. malac-hd-0.1.1a1/malac/hd/compiler/fhir/__init__.py +0 -0
  10. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/__init__.py +0 -0
  11. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/generator/__init__.py +4 -0
  12. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/generator/conceptmap.py +348 -0
  13. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/generator/fhirpath.py +930 -0
  14. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/generator/resource.py +168 -0
  15. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/generator/structuredefinition.py +12 -0
  16. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/generator/structuremap.py +1484 -0
  17. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/__init__.py +0 -0
  18. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpath.g4 +175 -0
  19. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpath.interp +153 -0
  20. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpath.tokens +118 -0
  21. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpathLexer.interp +215 -0
  22. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpathLexer.py +314 -0
  23. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpathLexer.tokens +118 -0
  24. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpathListener.py +381 -0
  25. malac-hd-0.1.1a1/malac/hd/compiler/fhir/r4/parser/fhirpathParser.py +1916 -0
  26. malac-hd-0.1.1a1/malac/hd/compiler/fhir/utils.py +1617 -0
  27. malac-hd-0.1.1a1/malac/models/__init__.py +0 -0
  28. malac-hd-0.1.1a1/malac/models/cda/__init__.py +0 -0
  29. malac-hd-0.1.1a1/malac/models/cda/at_ext.py +67064 -0
  30. malac-hd-0.1.1a1/malac/models/fhir/__init__.py +0 -0
  31. malac-hd-0.1.1a1/malac/models/fhir/r4.py +259191 -0
  32. malac-hd-0.1.1a1/malac_hd.egg-info/PKG-INFO +301 -0
  33. malac-hd-0.1.1a1/malac_hd.egg-info/SOURCES.txt +37 -0
  34. malac-hd-0.1.1a1/malac_hd.egg-info/dependency_links.txt +1 -0
  35. malac-hd-0.1.1a1/malac_hd.egg-info/entry_points.txt +2 -0
  36. malac-hd-0.1.1a1/malac_hd.egg-info/requires.txt +5 -0
  37. malac-hd-0.1.1a1/malac_hd.egg-info/top_level.txt +1 -0
  38. malac-hd-0.1.1a1/pyproject.toml +37 -0
  39. malac-hd-0.1.1a1/setup.cfg +4 -0
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,3 @@
1
+ graft malac
2
+ global-exclude __pycache__
3
+ global-exclude *.py[co]
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.1
2
+ Name: malac-hd
3
+ Version: 0.1.1a1
4
+ Summary: Mapping Language Compiler for Health Data.
5
+ Author-email: cdeHealth-Team <contact-project+cdehealth-malac-hd-52276676-issue-@incoming.gitlab.com>
6
+ License: GNU LESSER GENERAL PUBLIC LICENSE
7
+ Version 3, 29 June 2007
8
+
9
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
10
+ Everyone is permitted to copy and distribute verbatim copies
11
+ of this license document, but changing it is not allowed.
12
+
13
+
14
+ This version of the GNU Lesser General Public License incorporates
15
+ the terms and conditions of version 3 of the GNU General Public
16
+ License, supplemented by the additional permissions listed below.
17
+
18
+ 0. Additional Definitions.
19
+
20
+ As used herein, "this License" refers to version 3 of the GNU Lesser
21
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
22
+ General Public License.
23
+
24
+ "The Library" refers to a covered work governed by this License,
25
+ other than an Application or a Combined Work as defined below.
26
+
27
+ An "Application" is any work that makes use of an interface provided
28
+ by the Library, but which is not otherwise based on the Library.
29
+ Defining a subclass of a class defined by the Library is deemed a mode
30
+ of using an interface provided by the Library.
31
+
32
+ A "Combined Work" is a work produced by combining or linking an
33
+ Application with the Library. The particular version of the Library
34
+ with which the Combined Work was made is also called the "Linked
35
+ Version".
36
+
37
+ The "Minimal Corresponding Source" for a Combined Work means the
38
+ Corresponding Source for the Combined Work, excluding any source code
39
+ for portions of the Combined Work that, considered in isolation, are
40
+ based on the Application, and not on the Linked Version.
41
+
42
+ The "Corresponding Application Code" for a Combined Work means the
43
+ object code and/or source code for the Application, including any data
44
+ and utility programs needed for reproducing the Combined Work from the
45
+ Application, but excluding the System Libraries of the Combined Work.
46
+
47
+ 1. Exception to Section 3 of the GNU GPL.
48
+
49
+ You may convey a covered work under sections 3 and 4 of this License
50
+ without being bound by section 3 of the GNU GPL.
51
+
52
+ 2. Conveying Modified Versions.
53
+
54
+ If you modify a copy of the Library, and, in your modifications, a
55
+ facility refers to a function or data to be supplied by an Application
56
+ that uses the facility (other than as an argument passed when the
57
+ facility is invoked), then you may convey a copy of the modified
58
+ version:
59
+
60
+ a) under this License, provided that you make a good faith effort to
61
+ ensure that, in the event an Application does not supply the
62
+ function or data, the facility still operates, and performs
63
+ whatever part of its purpose remains meaningful, or
64
+
65
+ b) under the GNU GPL, with none of the additional permissions of
66
+ this License applicable to that copy.
67
+
68
+ 3. Object Code Incorporating Material from Library Header Files.
69
+
70
+ The object code form of an Application may incorporate material from
71
+ a header file that is part of the Library. You may convey such object
72
+ code under terms of your choice, provided that, if the incorporated
73
+ material is not limited to numerical parameters, data structure
74
+ layouts and accessors, or small macros, inline functions and templates
75
+ (ten or fewer lines in length), you do both of the following:
76
+
77
+ a) Give prominent notice with each copy of the object code that the
78
+ Library is used in it and that the Library and its use are
79
+ covered by this License.
80
+
81
+ b) Accompany the object code with a copy of the GNU GPL and this license
82
+ document.
83
+
84
+ 4. Combined Works.
85
+
86
+ You may convey a Combined Work under terms of your choice that,
87
+ taken together, effectively do not restrict modification of the
88
+ portions of the Library contained in the Combined Work and reverse
89
+ engineering for debugging such modifications, if you also do each of
90
+ the following:
91
+
92
+ a) Give prominent notice with each copy of the Combined Work that
93
+ the Library is used in it and that the Library and its use are
94
+ covered by this License.
95
+
96
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
97
+ document.
98
+
99
+ c) For a Combined Work that displays copyright notices during
100
+ execution, include the copyright notice for the Library among
101
+ these notices, as well as a reference directing the user to the
102
+ copies of the GNU GPL and this license document.
103
+
104
+ d) Do one of the following:
105
+
106
+ 0) Convey the Minimal Corresponding Source under the terms of this
107
+ License, and the Corresponding Application Code in a form
108
+ suitable for, and under terms that permit, the user to
109
+ recombine or relink the Application with a modified version of
110
+ the Linked Version to produce a modified Combined Work, in the
111
+ manner specified by section 6 of the GNU GPL for conveying
112
+ Corresponding Source.
113
+
114
+ 1) Use a suitable shared library mechanism for linking with the
115
+ Library. A suitable mechanism is one that (a) uses at run time
116
+ a copy of the Library already present on the user's computer
117
+ system, and (b) will operate properly with a modified version
118
+ of the Library that is interface-compatible with the Linked
119
+ Version.
120
+
121
+ e) Provide Installation Information, but only if you would otherwise
122
+ be required to provide such information under section 6 of the
123
+ GNU GPL, and only to the extent that such information is
124
+ necessary to install and execute a modified version of the
125
+ Combined Work produced by recombining or relinking the
126
+ Application with a modified version of the Linked Version. (If
127
+ you use option 4d0, the Installation Information must accompany
128
+ the Minimal Corresponding Source and Corresponding Application
129
+ Code. If you use option 4d1, you must provide the Installation
130
+ Information in the manner specified by section 6 of the GNU GPL
131
+ for conveying Corresponding Source.)
132
+
133
+ 5. Combined Libraries.
134
+
135
+ You may place library facilities that are a work based on the
136
+ Library side by side in a single library together with other library
137
+ facilities that are not Applications and are not covered by this
138
+ License, and convey such a combined library under terms of your
139
+ choice, if you do both of the following:
140
+
141
+ a) Accompany the combined library with a copy of the same work based
142
+ on the Library, uncombined with any other library facilities,
143
+ conveyed under the terms of this License.
144
+
145
+ b) Give prominent notice with the combined library that part of it
146
+ is a work based on the Library, and explaining where to find the
147
+ accompanying uncombined form of the same work.
148
+
149
+ 6. Revised Versions of the GNU Lesser General Public License.
150
+
151
+ The Free Software Foundation may publish revised and/or new versions
152
+ of the GNU Lesser General Public License from time to time. Such new
153
+ versions will be similar in spirit to the present version, but may
154
+ differ in detail to address new problems or concerns.
155
+
156
+ Each version is given a distinguishing version number. If the
157
+ Library as you received it specifies that a certain numbered version
158
+ of the GNU Lesser General Public License "or any later version"
159
+ applies to it, you have the option of following the terms and
160
+ conditions either of that published version or of any later version
161
+ published by the Free Software Foundation. If the Library as you
162
+ received it does not specify a version number of the GNU Lesser
163
+ General Public License, you may choose any version of the GNU Lesser
164
+ General Public License ever published by the Free Software Foundation.
165
+
166
+ If the Library as you received it specifies that a proxy can decide
167
+ whether future versions of the GNU Lesser General Public License shall
168
+ apply, that proxy's public statement of acceptance of any version is
169
+ permanent authorization for you to choose that version for the
170
+ Library.
171
+
172
+ Project-URL: Homepage, https://gitlab.com/cdehealth/malac-hd
173
+ Project-URL: Documentation, https://gitlab.com/cdehealth/malac-hd
174
+ Project-URL: Release notes, https://gitlab.com/cdehealth/malac-hd/-/releases
175
+ Project-URL: Source, https://gitlab.com/cdehealth/malac-hd
176
+ Project-URL: Tracker, https://gitlab.com/cdehealth/malac-hd/-/issues
177
+ Requires-Python: >=3.10
178
+ Description-Content-Type: text/markdown
179
+ License-File: LICENSE
180
+ Requires-Dist: antlr4-python3-runtime>=4.13.0
181
+ Requires-Dist: antlr4-tools>=0.2.1
182
+ Requires-Dist: pytest>=7.0.0
183
+ Requires-Dist: python-dateutil>=2.8.2
184
+ Requires-Dist: lxml>=5.1.0
185
+
186
+ # MaLaC-HD
187
+
188
+ MaLaC-HD (MApping LAnguage Compiler for Health Data) is a tool that you can use to convert mappings between different health data formats to executable code. It can also be used as a library to dynamically execute mappings.
189
+
190
+ ## Why?
191
+
192
+ When having parallel operations of some sort or another, there is one requirement that is challenging in the context of standardized APIs: mapping data, to make it accessible to the different worlds at least.
193
+
194
+ There are many methods to map from one semi-structured data format to another. Most of the times, when a mapping requirement reveals, it is solved by a quick small script. After some time, that script needs technical or rule updates. As the rules are directly coded, they can only be altered by someone having knowledge about the mapping content, the mapping rules and the mapping technology.
195
+
196
+ To divide these concerns, HL7 FHIR created resources for mapping purposes, like the [StructureMap](https://www.hl7.org/fhir/structuremap.html) for [transformation](https://www.hl7.org/fhir/structuremap-operation-transform.html) and [ConceptMap](https://www.hl7.org/fhir/conceptmap.html) for [translation](https://www.hl7.org/fhir/conceptmap-operation-translate.html). Additionally a more human readable metalanguage for creating such StructureMap and ConceptMap resources was created, called [FHIR Mapping Language, or in short FML](https://www.hl7.org/fhir/mapping-language.html). Interestingly enough, FML is not restricted to FHIR as a source or target for the mapping. It could also be used i.e. to map from HL7 CDA to OHDSI OMOP CDM.
197
+
198
+ Current FML or StructureMap/ConceptMap tools are quite slow in the transformation/translation of the content to be mapped, as both steps, the processing of the rules and the transformation/translation itself is done every time. As a gold standard and sparring partner for this project, the Canadian open source project [HAPI](https://github.com/hapifhir) with its Suisse extension [matchbox](https://www.matchbox.health/) has been used. Additionally, we got notice about some Italian project speeding up matchbox, but couldn't find any public references.
199
+
200
+ We can't use current tools to map data synchronously, as nearly all mapping executions need more time than the [dorethy threshold of 0.4 seconds](https://lawsofux.com/doherty-threshold/), resulting in the users perception of "it got stuck". Also the practical, but restricted FHIR mapping language does not offer any possibilities to extend it with further functions, in contrast to the StructureMap and ConceptMap resources themselves, that could be easily extended.
201
+
202
+ ## How?
203
+
204
+ Focusing on but not restricting to the health information technology world, a partnership was created out of the experts in the CDA2FHIR HL7 Austria Working Group, to solve this issue. On one side with expertise in research and on the other side with expertise in EHRs.
205
+
206
+ By applying the MVP concept of build-measure-learn-repeat, first versions were created and tested against already existing FML-mappings in the HL7 community and matchbox as a mapping tool.
207
+
208
+ As the partners are themselves heavy users of the resulting MVPs, using them immediately after release, quick iterations of four months are planned.
209
+
210
+ ## What?
211
+
212
+ MaLaC-HD is intended to focus on transformation speed and easy extensibility after compilation/convertion. This is achieved by seperation of
213
+ * the processing from FML to StructureMap/ConceptMap,
214
+ * the conversion from StructureMap/ConceptMap to python code,
215
+ * the execution of the translation itself from source to target.
216
+ It uses the mappings and requirements of some preliminary projects (i.e. https://github.com/HL7Austria/CDA2FHIR) as testing data.
217
+
218
+ MaLaC-HD is not limited to the use of FML or StructureMap/ConceptMap for the translation, but has already implemented a conversion from StructureMap/ConceptMaps to python code. It can be used to transform/translate different input formats to different output formats, using some conversion/mapping rule language and the XSD or JSON schemas of the input and output format. It also makes it easier to develop new conversion or mapping rule languages, further input formats and/or extensions.
219
+
220
+ ## Pursued Objectives
221
+ The development of MaLaC-HD focuses on the following three main objectives and their respective sub-objectives:
222
+
223
+ - The compilation of the conversion/mapping rules by MaLaC-HD and the resulting mapping of these rules in a common programming language must be easily readable and directly related to the conversion/mapping rules.
224
+ - The conversion/mapping rules must be ballotable so that they can be queried and discussed for completeness and correctness as part of a guideline or even as a standalone part in a community, such as the HL7 community.
225
+ - MaLaC-HD must not be dependent on any conversion rule language in order to be able to easily process conversion/mapping rules that can be mapped in different conversion rule languages.
226
+ - In particular, the limits of the respective conversion rule language require simple narrative extensibility in order to draw attention to the fact that further code must be added manually in the respective generated code by means of placeholders.
227
+ - The result of compiling the conversion/mapping rules must be trimmed for speed and stability so as not to add any obstructive delays.
228
+ - The compiled conversion/mapping rules should be executable as stand-alone program code without MaLaC-HD.
229
+
230
+ ## Getting Started
231
+
232
+ These instructions will get you a copy of the project up and running.
233
+
234
+ ### Installation
235
+
236
+ Install malac-hd and its dependencies via pip:
237
+
238
+ ```
239
+ pip install malac-hd
240
+ ```
241
+
242
+ ... or, if you want to build from source:
243
+
244
+
245
+ ```
246
+ git clone https://gitlab.com/cdehealth/malac-hd.git
247
+ cd malac-hd
248
+ pip install -e .
249
+ ```
250
+
251
+ #### Preparing your FML maps
252
+
253
+ As the direct support of FML will come with the beta version this fall, a workaround has to be done right now in the alpha, by pre-compiling/converting the FML to StructreMaps and ConceptMaps by using the [java-validator](https://www.hl7.org/fhir/validator/), i.e.:
254
+ ```
255
+ java -jar .\validator_cli.jar -ig ./tests/structuremap/aut_lab/cdaToBundle.map -output tests/structuremap/aut_lab/cda-2-bundle-merged-transform.4.fhir.xml -compile http://hl7.at/fhir/HL7ATCoreProfiles/4.0.1/StructureMap/at-cda-to-bundle -version 4.0
256
+ ```
257
+
258
+ ### Using MaLaC-HD
259
+
260
+ with `malac-hd --help` you will get an overview:
261
+
262
+ ```
263
+ ____________________ MaLaC-HD 0.1.1+20240516-alpha started ____________________
264
+ usage: malac-hd [-h] -m MAPPING [-co CONVERT_OUTPUT] [-ti TRANSFORM_INPUT] [-to TRANSFORM_OUTPUT] [-s]
265
+
266
+ This is the MApping LAnguage Compiler for Health Data, short MaLaC-HD. We differentiate between two modes, converting and transforming. The convertion is compiling a given mapping to python code, that itself can be run with its own argument handling for transforming inputs. Additionally, the transformation can
267
+ also be be done by MaLaC-HD directly after convertion, i.e. for direct testing purposes.
268
+
269
+ options:
270
+ -h, --help show this help message and exit
271
+ -m MAPPING, --mapping MAPPING
272
+ the mapping file path, the conversion/mapping rule language is detected by file ending, right now only StructureMaps and ConceptMaps can be given as mappings
273
+ -co CONVERT_OUTPUT, --convert_output CONVERT_OUTPUT
274
+ the conversion python file path, if not given, saved in the working directory with the map-file name
275
+ -ti TRANSFORM_INPUT, --transform_input TRANSFORM_INPUT
276
+ the transformation input file path, the ressource type is detected by its root node inside the xml
277
+ -to TRANSFORM_OUTPUT, --transform_output TRANSFORM_OUTPUT
278
+ the transformation output file path, the ressource type is detected by its root node inside the xml
279
+ -s, --silent do not print the converted python mapping to console
280
+ ```
281
+
282
+ #### Example Usage
283
+
284
+ Usage of an in MaLaC-HD included example:
285
+ ```
286
+ malac-hd -m ./tests/structuremap/aut_lab/cda-2-bundle-merged-transform.4.fhir.xml -co ./tests/structuremap/aut_lab/out/bundle.4.fhir.xml.py -i ./tests/structuremap/aut_lab/Lab_Allgemeiner_Laborbefund.at.cda.xml -to ./tests/structuremap/aut_lab/out/bundle.4.fhir.xml
287
+ ```
288
+
289
+ ## Support
290
+ Please use our gitlab issues for questions or support.
291
+
292
+ ## Authors and acknowledgment
293
+ We want to thank
294
+ - [ELGA GmbH](https://www.elga.gv.at/) with their [CDA2FHIR](https://collab.hl7.at/display/BAL/AG+ELGA+CDA+Laborbefund+zu+FHIR) projects and
295
+ - [AIT Austrian Institute of Technology GmbH](https://www.ait.ac.at/) with their [SmartFOX](https://www.smart-fox.at/) project.
296
+
297
+ Additionally, we want to thank
298
+ - [Dave Kuhlman](https://davekuhlman.org/) with his open source implementation of [generateDS](https://www.davekuhlman.org/generateDS.html), making quick serializations of new data structures from their XSD schemas possible.
299
+
300
+ ## License
301
+ This is a LGPL licensed project, with a small add on that any usage of this project or results of this project should contain a for the consumer visible icon, that will be announced here in the near future.
@@ -0,0 +1,116 @@
1
+ # MaLaC-HD
2
+
3
+ MaLaC-HD (MApping LAnguage Compiler for Health Data) is a tool that you can use to convert mappings between different health data formats to executable code. It can also be used as a library to dynamically execute mappings.
4
+
5
+ ## Why?
6
+
7
+ When having parallel operations of some sort or another, there is one requirement that is challenging in the context of standardized APIs: mapping data, to make it accessible to the different worlds at least.
8
+
9
+ There are many methods to map from one semi-structured data format to another. Most of the times, when a mapping requirement reveals, it is solved by a quick small script. After some time, that script needs technical or rule updates. As the rules are directly coded, they can only be altered by someone having knowledge about the mapping content, the mapping rules and the mapping technology.
10
+
11
+ To divide these concerns, HL7 FHIR created resources for mapping purposes, like the [StructureMap](https://www.hl7.org/fhir/structuremap.html) for [transformation](https://www.hl7.org/fhir/structuremap-operation-transform.html) and [ConceptMap](https://www.hl7.org/fhir/conceptmap.html) for [translation](https://www.hl7.org/fhir/conceptmap-operation-translate.html). Additionally a more human readable metalanguage for creating such StructureMap and ConceptMap resources was created, called [FHIR Mapping Language, or in short FML](https://www.hl7.org/fhir/mapping-language.html). Interestingly enough, FML is not restricted to FHIR as a source or target for the mapping. It could also be used i.e. to map from HL7 CDA to OHDSI OMOP CDM.
12
+
13
+ Current FML or StructureMap/ConceptMap tools are quite slow in the transformation/translation of the content to be mapped, as both steps, the processing of the rules and the transformation/translation itself is done every time. As a gold standard and sparring partner for this project, the Canadian open source project [HAPI](https://github.com/hapifhir) with its Suisse extension [matchbox](https://www.matchbox.health/) has been used. Additionally, we got notice about some Italian project speeding up matchbox, but couldn't find any public references.
14
+
15
+ We can't use current tools to map data synchronously, as nearly all mapping executions need more time than the [dorethy threshold of 0.4 seconds](https://lawsofux.com/doherty-threshold/), resulting in the users perception of "it got stuck". Also the practical, but restricted FHIR mapping language does not offer any possibilities to extend it with further functions, in contrast to the StructureMap and ConceptMap resources themselves, that could be easily extended.
16
+
17
+ ## How?
18
+
19
+ Focusing on but not restricting to the health information technology world, a partnership was created out of the experts in the CDA2FHIR HL7 Austria Working Group, to solve this issue. On one side with expertise in research and on the other side with expertise in EHRs.
20
+
21
+ By applying the MVP concept of build-measure-learn-repeat, first versions were created and tested against already existing FML-mappings in the HL7 community and matchbox as a mapping tool.
22
+
23
+ As the partners are themselves heavy users of the resulting MVPs, using them immediately after release, quick iterations of four months are planned.
24
+
25
+ ## What?
26
+
27
+ MaLaC-HD is intended to focus on transformation speed and easy extensibility after compilation/convertion. This is achieved by seperation of
28
+ * the processing from FML to StructureMap/ConceptMap,
29
+ * the conversion from StructureMap/ConceptMap to python code,
30
+ * the execution of the translation itself from source to target.
31
+ It uses the mappings and requirements of some preliminary projects (i.e. https://github.com/HL7Austria/CDA2FHIR) as testing data.
32
+
33
+ MaLaC-HD is not limited to the use of FML or StructureMap/ConceptMap for the translation, but has already implemented a conversion from StructureMap/ConceptMaps to python code. It can be used to transform/translate different input formats to different output formats, using some conversion/mapping rule language and the XSD or JSON schemas of the input and output format. It also makes it easier to develop new conversion or mapping rule languages, further input formats and/or extensions.
34
+
35
+ ## Pursued Objectives
36
+ The development of MaLaC-HD focuses on the following three main objectives and their respective sub-objectives:
37
+
38
+ - The compilation of the conversion/mapping rules by MaLaC-HD and the resulting mapping of these rules in a common programming language must be easily readable and directly related to the conversion/mapping rules.
39
+ - The conversion/mapping rules must be ballotable so that they can be queried and discussed for completeness and correctness as part of a guideline or even as a standalone part in a community, such as the HL7 community.
40
+ - MaLaC-HD must not be dependent on any conversion rule language in order to be able to easily process conversion/mapping rules that can be mapped in different conversion rule languages.
41
+ - In particular, the limits of the respective conversion rule language require simple narrative extensibility in order to draw attention to the fact that further code must be added manually in the respective generated code by means of placeholders.
42
+ - The result of compiling the conversion/mapping rules must be trimmed for speed and stability so as not to add any obstructive delays.
43
+ - The compiled conversion/mapping rules should be executable as stand-alone program code without MaLaC-HD.
44
+
45
+ ## Getting Started
46
+
47
+ These instructions will get you a copy of the project up and running.
48
+
49
+ ### Installation
50
+
51
+ Install malac-hd and its dependencies via pip:
52
+
53
+ ```
54
+ pip install malac-hd
55
+ ```
56
+
57
+ ... or, if you want to build from source:
58
+
59
+
60
+ ```
61
+ git clone https://gitlab.com/cdehealth/malac-hd.git
62
+ cd malac-hd
63
+ pip install -e .
64
+ ```
65
+
66
+ #### Preparing your FML maps
67
+
68
+ As the direct support of FML will come with the beta version this fall, a workaround has to be done right now in the alpha, by pre-compiling/converting the FML to StructreMaps and ConceptMaps by using the [java-validator](https://www.hl7.org/fhir/validator/), i.e.:
69
+ ```
70
+ java -jar .\validator_cli.jar -ig ./tests/structuremap/aut_lab/cdaToBundle.map -output tests/structuremap/aut_lab/cda-2-bundle-merged-transform.4.fhir.xml -compile http://hl7.at/fhir/HL7ATCoreProfiles/4.0.1/StructureMap/at-cda-to-bundle -version 4.0
71
+ ```
72
+
73
+ ### Using MaLaC-HD
74
+
75
+ with `malac-hd --help` you will get an overview:
76
+
77
+ ```
78
+ ____________________ MaLaC-HD 0.1.1+20240516-alpha started ____________________
79
+ usage: malac-hd [-h] -m MAPPING [-co CONVERT_OUTPUT] [-ti TRANSFORM_INPUT] [-to TRANSFORM_OUTPUT] [-s]
80
+
81
+ This is the MApping LAnguage Compiler for Health Data, short MaLaC-HD. We differentiate between two modes, converting and transforming. The convertion is compiling a given mapping to python code, that itself can be run with its own argument handling for transforming inputs. Additionally, the transformation can
82
+ also be be done by MaLaC-HD directly after convertion, i.e. for direct testing purposes.
83
+
84
+ options:
85
+ -h, --help show this help message and exit
86
+ -m MAPPING, --mapping MAPPING
87
+ the mapping file path, the conversion/mapping rule language is detected by file ending, right now only StructureMaps and ConceptMaps can be given as mappings
88
+ -co CONVERT_OUTPUT, --convert_output CONVERT_OUTPUT
89
+ the conversion python file path, if not given, saved in the working directory with the map-file name
90
+ -ti TRANSFORM_INPUT, --transform_input TRANSFORM_INPUT
91
+ the transformation input file path, the ressource type is detected by its root node inside the xml
92
+ -to TRANSFORM_OUTPUT, --transform_output TRANSFORM_OUTPUT
93
+ the transformation output file path, the ressource type is detected by its root node inside the xml
94
+ -s, --silent do not print the converted python mapping to console
95
+ ```
96
+
97
+ #### Example Usage
98
+
99
+ Usage of an in MaLaC-HD included example:
100
+ ```
101
+ malac-hd -m ./tests/structuremap/aut_lab/cda-2-bundle-merged-transform.4.fhir.xml -co ./tests/structuremap/aut_lab/out/bundle.4.fhir.xml.py -i ./tests/structuremap/aut_lab/Lab_Allgemeiner_Laborbefund.at.cda.xml -to ./tests/structuremap/aut_lab/out/bundle.4.fhir.xml
102
+ ```
103
+
104
+ ## Support
105
+ Please use our gitlab issues for questions or support.
106
+
107
+ ## Authors and acknowledgment
108
+ We want to thank
109
+ - [ELGA GmbH](https://www.elga.gv.at/) with their [CDA2FHIR](https://collab.hl7.at/display/BAL/AG+ELGA+CDA+Laborbefund+zu+FHIR) projects and
110
+ - [AIT Austrian Institute of Technology GmbH](https://www.ait.ac.at/) with their [SmartFOX](https://www.smart-fox.at/) project.
111
+
112
+ Additionally, we want to thank
113
+ - [Dave Kuhlman](https://davekuhlman.org/) with his open source implementation of [generateDS](https://www.davekuhlman.org/generateDS.html), making quick serializations of new data structures from their XSD schemas possible.
114
+
115
+ ## License
116
+ This is a LGPL licensed project, with a small add on that any usage of this project or results of this project should contain a for the consumer visible icon, that will be announced here in the near future.
File without changes
@@ -0,0 +1,33 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+ __version__ = "0.1.1alpha1"
4
+
5
+ class ConvertMaster(ABC):
6
+ @abstractmethod
7
+ def convert(self, input, o_module): # TODO:sbe adapt - this is not what is implemented/needed in base classes
8
+ pass
9
+ # return mapping_as_py
10
+
11
+ # not sure if this class will be needed, it is only unsed inside the into py converted map
12
+
13
+
14
+ class TransformMaster(ABC):
15
+ @abstractmethod
16
+ def transform(self, source_path, target_path):
17
+ pass
18
+
19
+ list_m_modules = { # this are modules that can be fully created for malac_hd or Subclasses extending modules that are fully generated by generateDS
20
+ # for StructureMapSub, in this module are additionally planned
21
+ # ConceptMapSub & StructureDefinitionSub (this one also uses
22
+ # ElementDefinitionSub with the <map> element)
23
+ ".4.fhir.xml": "fhir.r4.generator.resource",
24
+ #".4.fhir.map": "fhir4fml"
25
+ }
26
+
27
+ list_i_o_modules = { # this are modules that are fully generated by generateDS
28
+ "http://hl7.org/fhir/StructureDefinition":"fhir.r4",
29
+ "http://hl7.org/fhir/4.0/StructureDefinition":"fhir.r4",
30
+ #"http://hl7.org/fhir/StructureDefinition":"fhir5",
31
+ "http://hl7.org/fhir/cda/StructureDefinition":"cda.at_ext",
32
+ "http://hl7.org/cda/stds/core/StructureDefinition":"cda.at_ext"
33
+ }