fhirsmith 0.3.0

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 (277) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/FHIRsmith.png +0 -0
  3. package/README.md +277 -0
  4. package/config-template.json +144 -0
  5. package/library/folder-setup.js +58 -0
  6. package/library/html-server.js +166 -0
  7. package/library/html.js +835 -0
  8. package/library/i18nsupport.js +259 -0
  9. package/library/languages.js +779 -0
  10. package/library/logger-telnet.js +205 -0
  11. package/library/logger.js +279 -0
  12. package/library/package-manager.js +876 -0
  13. package/library/utilities.js +196 -0
  14. package/library/version-utilities.js +1056 -0
  15. package/npmprojector/config-example.json +13 -0
  16. package/npmprojector/indexer.js +394 -0
  17. package/npmprojector/npmprojector.js +395 -0
  18. package/npmprojector/readme.md +174 -0
  19. package/npmprojector/watcher.js +335 -0
  20. package/package.json +119 -0
  21. package/packages/package-crawler.js +846 -0
  22. package/packages/packages-template.html +126 -0
  23. package/packages/packages.js +2838 -0
  24. package/passwords.ini +2 -0
  25. package/publisher/publisher-template.html +208 -0
  26. package/publisher/publisher.js +2167 -0
  27. package/publisher/task-draft.js +458 -0
  28. package/registry/api.js +735 -0
  29. package/registry/crawler.js +637 -0
  30. package/registry/model.js +513 -0
  31. package/registry/readme.md +243 -0
  32. package/registry/registry-data.json +121015 -0
  33. package/registry/registry-template.html +126 -0
  34. package/registry/registry.js +1395 -0
  35. package/registry/test-runner.js +237 -0
  36. package/root-template.html +124 -0
  37. package/server.js +524 -0
  38. package/shl/private-key.pem +5 -0
  39. package/shl/public-key.pem +18 -0
  40. package/shl/shl.js +1125 -0
  41. package/shl/vhl.js +69 -0
  42. package/static/FHIRsmith128.png +0 -0
  43. package/static/FHIRsmith16.png +0 -0
  44. package/static/FHIRsmith32.png +0 -0
  45. package/static/FHIRsmith64.png +0 -0
  46. package/static/assets/css/bootstrap-fhir.css +5302 -0
  47. package/static/assets/css/bootstrap-glyphicons.css +2 -0
  48. package/static/assets/css/bootstrap.css +4097 -0
  49. package/static/assets/css/jquery-ui.css +523 -0
  50. package/static/assets/css/jquery-ui.structure.css +863 -0
  51. package/static/assets/css/jquery-ui.structure.min.css +5 -0
  52. package/static/assets/css/jquery-ui.theme.css +439 -0
  53. package/static/assets/css/jquery-ui.theme.min.css +5 -0
  54. package/static/assets/css/jquery.ui.all.css +7 -0
  55. package/static/assets/css/modules.css +18 -0
  56. package/static/assets/css/project.css +367 -0
  57. package/static/assets/css/pygments-manni.css +66 -0
  58. package/static/assets/css/tags.css +74 -0
  59. package/static/assets/css/xml.css +2 -0
  60. package/static/assets/fonts/glyphiconshalflings-regular.eot +0 -0
  61. package/static/assets/fonts/glyphiconshalflings-regular.otf +0 -0
  62. package/static/assets/fonts/glyphiconshalflings-regular.svg +175 -0
  63. package/static/assets/fonts/glyphiconshalflings-regular.ttf +0 -0
  64. package/static/assets/fonts/glyphiconshalflings-regular.woff +0 -0
  65. package/static/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
  66. package/static/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
  67. package/static/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
  68. package/static/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
  69. package/static/assets/ico/favicon.ico +0 -0
  70. package/static/assets/ico/favicon.png +0 -0
  71. package/static/assets/images/fhir-logo-www.png +0 -0
  72. package/static/assets/images/fhir-logo.png +0 -0
  73. package/static/assets/images/hl7-logo.png +0 -0
  74. package/static/assets/images/logo_ansinew.jpg +0 -0
  75. package/static/assets/images/search.png +0 -0
  76. package/static/assets/images/stripe.png +0 -0
  77. package/static/assets/images/target.png +0 -0
  78. package/static/assets/images/tx-registry-root.gif +0 -0
  79. package/static/assets/images/tx-registry.png +0 -0
  80. package/static/assets/images/tx-server.png +0 -0
  81. package/static/assets/images/tx-version.png +0 -0
  82. package/static/assets/js/bootstrap.min.js +6 -0
  83. package/static/assets/js/fhir-gw.js +259 -0
  84. package/static/assets/js/fhir.js +2 -0
  85. package/static/assets/js/html5shiv.js +8 -0
  86. package/static/assets/js/jcookie.js +96 -0
  87. package/static/assets/js/jquery-ui.min.js +6 -0
  88. package/static/assets/js/jquery.js +10716 -0
  89. package/static/assets/js/jquery.min.js +2 -0
  90. package/static/assets/js/jquery.ui.core.js +314 -0
  91. package/static/assets/js/jquery.ui.draggable.js +825 -0
  92. package/static/assets/js/jquery.ui.mouse.js +162 -0
  93. package/static/assets/js/jquery.ui.resizable.js +842 -0
  94. package/static/assets/js/jquery.ui.widget.js +268 -0
  95. package/static/assets/js/json2.js +487 -0
  96. package/static/assets/js/jtip.js +97 -0
  97. package/static/assets/js/respond.min.js +6 -0
  98. package/static/assets/js/statuspage.js +70 -0
  99. package/static/assets/js/xml.js +2 -0
  100. package/static/dist/js/bootstrap.js +1964 -0
  101. package/static/favicon.png +0 -0
  102. package/static/fhir.css +626 -0
  103. package/static/icon-fhir-16.png +0 -0
  104. package/static/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  105. package/static/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  106. package/static/images/ui-bg_flat_10_000000_40x100.png +0 -0
  107. package/static/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  108. package/static/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  109. package/static/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  110. package/static/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  111. package/static/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  112. package/static/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  113. package/static/images/ui-icons_222222_256x240.png +0 -0
  114. package/static/images/ui-icons_228ef1_256x240.png +0 -0
  115. package/static/images/ui-icons_ef8c08_256x240.png +0 -0
  116. package/static/images/ui-icons_ffd27a_256x240.png +0 -0
  117. package/static/images/ui-icons_ffffff_256x240.png +0 -0
  118. package/static/js/jquery.effects.blind.js +49 -0
  119. package/static/js/jquery.effects.bounce.js +78 -0
  120. package/static/js/jquery.effects.clip.js +54 -0
  121. package/static/js/jquery.effects.core.js +763 -0
  122. package/static/js/jquery.effects.drop.js +50 -0
  123. package/static/js/jquery.effects.explode.js +79 -0
  124. package/static/js/jquery.effects.fade.js +32 -0
  125. package/static/js/jquery.effects.fold.js +56 -0
  126. package/static/js/jquery.effects.highlight.js +50 -0
  127. package/static/js/jquery.effects.pulsate.js +51 -0
  128. package/static/js/jquery.effects.scale.js +178 -0
  129. package/static/js/jquery.effects.shake.js +57 -0
  130. package/static/js/jquery.effects.slide.js +50 -0
  131. package/static/js/jquery.effects.transfer.js +45 -0
  132. package/static/js/jquery.ui.accordion.js +611 -0
  133. package/static/js/jquery.ui.autocomplete.js +612 -0
  134. package/static/js/jquery.ui.button.js +416 -0
  135. package/static/js/jquery.ui.datepicker.js +1823 -0
  136. package/static/js/jquery.ui.dialog.js +878 -0
  137. package/static/js/jquery.ui.droppable.js +296 -0
  138. package/static/js/jquery.ui.position.js +252 -0
  139. package/static/js/jquery.ui.progressbar.js +109 -0
  140. package/static/js/jquery.ui.selectable.js +266 -0
  141. package/static/js/jquery.ui.slider.js +666 -0
  142. package/static/js/jquery.ui.sortable.js +1077 -0
  143. package/static/js/jquery.ui.tabs.js +758 -0
  144. package/stats.js +80 -0
  145. package/test-cache/vsac/vsac-valuesets.db +0 -0
  146. package/token/nginx_passport_setup.md +383 -0
  147. package/token/security_guide.md +294 -0
  148. package/token/token-template.html +330 -0
  149. package/token/token.js +1300 -0
  150. package/translations/Messages.properties +1510 -0
  151. package/translations/Messages_ar.properties +1399 -0
  152. package/translations/Messages_de.properties +836 -0
  153. package/translations/Messages_es.properties +737 -0
  154. package/translations/Messages_fr.properties +1 -0
  155. package/translations/Messages_ja.properties +893 -0
  156. package/translations/Messages_nl.properties +1357 -0
  157. package/translations/Messages_pt.properties +1302 -0
  158. package/translations/Messages_ru.properties +1 -0
  159. package/translations/Messages_uz.properties +1 -0
  160. package/translations/Messages_zh.properties +1 -0
  161. package/translations/rendering-phrases.properties +1128 -0
  162. package/translations/rendering-phrases_ar.properties +1091 -0
  163. package/translations/rendering-phrases_de.properties +6 -0
  164. package/translations/rendering-phrases_es.properties +6 -0
  165. package/translations/rendering-phrases_fr.properties +624 -0
  166. package/translations/rendering-phrases_ja.properties +21 -0
  167. package/translations/rendering-phrases_nl.properties +970 -0
  168. package/translations/rendering-phrases_pt.properties +1020 -0
  169. package/translations/rendering-phrases_ru.properties +1094 -0
  170. package/translations/rendering-phrases_uz.properties +1 -0
  171. package/translations/rendering-phrases_zh.properties +1 -0
  172. package/tx/README.md +418 -0
  173. package/tx/cm/cm-api.js +110 -0
  174. package/tx/cm/cm-database.js +735 -0
  175. package/tx/cm/cm-package.js +325 -0
  176. package/tx/cs/cs-api.js +789 -0
  177. package/tx/cs/cs-areacode.js +615 -0
  178. package/tx/cs/cs-country.js +1110 -0
  179. package/tx/cs/cs-cpt.js +785 -0
  180. package/tx/cs/cs-cs.js +1579 -0
  181. package/tx/cs/cs-currency.js +539 -0
  182. package/tx/cs/cs-db.js +1321 -0
  183. package/tx/cs/cs-hgvs.js +329 -0
  184. package/tx/cs/cs-lang.js +465 -0
  185. package/tx/cs/cs-loinc.js +1485 -0
  186. package/tx/cs/cs-mimetypes.js +238 -0
  187. package/tx/cs/cs-ndc.js +704 -0
  188. package/tx/cs/cs-omop.js +1025 -0
  189. package/tx/cs/cs-provider-api.js +43 -0
  190. package/tx/cs/cs-provider-list.js +37 -0
  191. package/tx/cs/cs-rxnorm.js +808 -0
  192. package/tx/cs/cs-snomed.js +1102 -0
  193. package/tx/cs/cs-ucum.js +514 -0
  194. package/tx/cs/cs-unii.js +271 -0
  195. package/tx/cs/cs-uri.js +218 -0
  196. package/tx/cs/cs-usstates.js +305 -0
  197. package/tx/dev.fhir.org.yml +14 -0
  198. package/tx/fixtures/test-cases-setup.json +18 -0
  199. package/tx/fixtures/test-cases.yml +16 -0
  200. package/tx/html/codesystem-operations.liquid +25 -0
  201. package/tx/html/home-metrics.liquid +247 -0
  202. package/tx/html/operations-form.liquid +148 -0
  203. package/tx/html/search-form.liquid +62 -0
  204. package/tx/html/tx-template.html +133 -0
  205. package/tx/html/valueset-operations.liquid +54 -0
  206. package/tx/importers/atc-to-fhir.js +316 -0
  207. package/tx/importers/import-loinc.module.js +1536 -0
  208. package/tx/importers/import-ndc.module.js +1088 -0
  209. package/tx/importers/import-rxnorm.module.js +898 -0
  210. package/tx/importers/import-sct.module.js +2457 -0
  211. package/tx/importers/import-unii.module.js +601 -0
  212. package/tx/importers/readme.md +453 -0
  213. package/tx/importers/subset-loinc.module.js +1081 -0
  214. package/tx/importers/subset-rxnorm.module.js +938 -0
  215. package/tx/importers/tx-import-base.js +351 -0
  216. package/tx/importers/tx-import-settings.js +310 -0
  217. package/tx/importers/tx-import.js +357 -0
  218. package/tx/library/canonical-resource.js +88 -0
  219. package/tx/library/capabilitystatement.js +292 -0
  220. package/tx/library/codesystem.js +774 -0
  221. package/tx/library/conceptmap.js +568 -0
  222. package/tx/library/designations.js +932 -0
  223. package/tx/library/errors.js +77 -0
  224. package/tx/library/extensions.js +117 -0
  225. package/tx/library/namingsystem.js +322 -0
  226. package/tx/library/operation-outcome.js +127 -0
  227. package/tx/library/parameters.js +105 -0
  228. package/tx/library/renderer.js +1559 -0
  229. package/tx/library/terminologycapabilities.js +418 -0
  230. package/tx/library/ucum-parsers.js +1029 -0
  231. package/tx/library/ucum-service.js +370 -0
  232. package/tx/library/ucum-types.js +1099 -0
  233. package/tx/library/valueset.js +543 -0
  234. package/tx/library.js +676 -0
  235. package/tx/ocl/cm-ocl.js +106 -0
  236. package/tx/ocl/cs-ocl.js +39 -0
  237. package/tx/ocl/vs-ocl.js +105 -0
  238. package/tx/operation-context.js +568 -0
  239. package/tx/params.js +613 -0
  240. package/tx/provider.js +403 -0
  241. package/tx/sct/ecl.js +1560 -0
  242. package/tx/sct/expressions.js +2077 -0
  243. package/tx/sct/structures.js +1396 -0
  244. package/tx/tx-html.js +1063 -0
  245. package/tx/tx.fhir.org.yml +39 -0
  246. package/tx/tx.js +927 -0
  247. package/tx/vs/vs-api.js +112 -0
  248. package/tx/vs/vs-database.js +786 -0
  249. package/tx/vs/vs-package.js +358 -0
  250. package/tx/vs/vs-vsac.js +366 -0
  251. package/tx/workers/batch-validate.js +129 -0
  252. package/tx/workers/batch.js +361 -0
  253. package/tx/workers/closure.js +32 -0
  254. package/tx/workers/expand.js +1845 -0
  255. package/tx/workers/lookup.js +407 -0
  256. package/tx/workers/metadata.js +467 -0
  257. package/tx/workers/operations.js +34 -0
  258. package/tx/workers/read.js +164 -0
  259. package/tx/workers/search.js +384 -0
  260. package/tx/workers/subsumes.js +334 -0
  261. package/tx/workers/translate.js +492 -0
  262. package/tx/workers/validate.js +2504 -0
  263. package/tx/workers/worker.js +904 -0
  264. package/tx/xml/capabilitystatement-xml.js +63 -0
  265. package/tx/xml/codesystem-xml.js +62 -0
  266. package/tx/xml/conceptmap-xml.js +65 -0
  267. package/tx/xml/namingsystem-xml.js +65 -0
  268. package/tx/xml/operationoutcome-xml.js +127 -0
  269. package/tx/xml/parameters-xml.js +312 -0
  270. package/tx/xml/terminologycapabilities-xml.js +64 -0
  271. package/tx/xml/valueset-xml.js +64 -0
  272. package/tx/xml/xml-base.js +603 -0
  273. package/vcl/vcl-parser.js +1098 -0
  274. package/vcl/vcl.js +253 -0
  275. package/windows-install.js +19 -0
  276. package/xig/xig-template.html +124 -0
  277. package/xig/xig.js +3049 -0
@@ -0,0 +1,63 @@
1
+ //
2
+ // CapabilityStatement XML Serialization
3
+ //
4
+
5
+ const { FhirXmlBase } = require('./xml-base');
6
+
7
+ /**
8
+ * XML support for FHIR CapabilityStatement resources
9
+ */
10
+ class CapabilityStatementXML extends FhirXmlBase {
11
+
12
+ /**
13
+ * Element order for CapabilityStatement (FHIR requires specific order)
14
+ */
15
+ static _elementOrder = [
16
+ 'id', 'meta', 'implicitRules', 'language', 'text', 'contained',
17
+ 'extension', 'modifierExtension',
18
+ 'url', 'identifier', 'version', 'versionAlgorithmString', 'versionAlgorithmCoding',
19
+ 'name', 'title', 'status', 'experimental', 'date', 'publisher',
20
+ 'contact', 'description', 'useContext', 'jurisdiction', 'purpose', 'copyright',
21
+ 'copyrightLabel', 'kind', 'instantiates', 'imports',
22
+ 'software', 'implementation', 'fhirVersion', 'format', 'patchFormat',
23
+ 'acceptLanguage', 'implementationGuide', 'rest', 'messaging', 'document'
24
+ ];
25
+
26
+ /**
27
+ * Convert CapabilityStatement JSON to XML string
28
+ * @param {Object} json - CapabilityStatement as JSON
29
+ * @param {number} fhirVersion - FHIR version (3, 4, or 5)
30
+ * @returns {string} XML string
31
+ */
32
+ // eslint-disable-next-line no-unused-vars
33
+ static toXml(json, fhirVersion) {
34
+ const content = this.renderElementsInOrder(json, 1, this._elementOrder);
35
+ return this.wrapInRootElement('CapabilityStatement', content);
36
+ }
37
+
38
+ /**
39
+ * Convert XML string to CapabilityStatement JSON
40
+ * @param {string} xml - XML string
41
+ * @param {number} fhirVersion - FHIR version
42
+ * @returns {Object} JSON object
43
+ */
44
+ static fromXml(xml) {
45
+ const element = this.parseXmlString(xml);
46
+ if (element.name !== 'CapabilityStatement') {
47
+ throw new Error(`Expected CapabilityStatement root element, got ${element.name}`);
48
+ }
49
+ return this.convertElementToFhirJson(element, 'CapabilityStatement');
50
+ }
51
+
52
+ /**
53
+ * Parse from a pre-parsed XML element
54
+ * @param {Object} element - Parsed element with {name, attributes, children}
55
+ * @param {number} fhirVersion - FHIR version
56
+ * @returns {Object} JSON object
57
+ */
58
+ static fromXmlElement(element) {
59
+ return this.convertElementToFhirJson(element, 'CapabilityStatement');
60
+ }
61
+ }
62
+
63
+ module.exports = { CapabilityStatementXML };
@@ -0,0 +1,62 @@
1
+ //
2
+ // CodeSystem XML Serialization
3
+ //
4
+
5
+ const { FhirXmlBase } = require('./xml-base');
6
+
7
+ /**
8
+ * XML support for FHIR CodeSystem resources
9
+ */
10
+ class CodeSystemXML extends FhirXmlBase {
11
+
12
+ /**
13
+ * Element order for CodeSystem (FHIR requires specific order)
14
+ */
15
+ static _elementOrder = [
16
+ 'id', 'meta', 'implicitRules', 'language', 'text', 'contained',
17
+ 'extension', 'modifierExtension',
18
+ 'url', 'identifier', 'version', 'versionAlgorithmString', 'versionAlgorithmCoding',
19
+ 'name', 'title', 'status', 'experimental', 'date', 'publisher',
20
+ 'contact', 'description', 'useContext', 'jurisdiction', 'purpose', 'copyright',
21
+ 'copyrightLabel', 'approvalDate', 'lastReviewDate', 'effectivePeriod',
22
+ 'caseSensitive', 'valueSet', 'hierarchyMeaning', 'compositional', 'versionNeeded',
23
+ 'content', 'supplements', 'count', 'filter', 'property', 'concept'
24
+ ];
25
+
26
+ /**
27
+ * Convert CodeSystem JSON to XML string
28
+ * @param {Object} json - CodeSystem as JSON
29
+ * @param {number} fhirVersion - FHIR version (3, 4, or 5)
30
+ * @returns {string} XML string
31
+ */
32
+ static toXml(json) {
33
+ const content = this.renderElementsInOrder(json, 1, this._elementOrder);
34
+ return this.wrapInRootElement('CodeSystem', content);
35
+ }
36
+
37
+ /**
38
+ * Convert XML string to CodeSystem JSON
39
+ * @param {string} xml - XML string
40
+ * @param {number} fhirVersion - FHIR version
41
+ * @returns {Object} JSON object
42
+ */
43
+ static fromXml(xml) {
44
+ const element = this.parseXmlString(xml);
45
+ if (element.name !== 'CodeSystem') {
46
+ throw new Error(`Expected CodeSystem root element, got ${element.name}`);
47
+ }
48
+ return this.convertElementToFhirJson(element, 'CodeSystem');
49
+ }
50
+
51
+ /**
52
+ * Parse from a pre-parsed XML element
53
+ * @param {Object} element - Parsed element with {name, attributes, children}
54
+ * @param {number} fhirVersion - FHIR version
55
+ * @returns {Object} JSON object
56
+ */
57
+ static fromXmlElement(element) {
58
+ return this.convertElementToFhirJson(element, 'CodeSystem');
59
+ }
60
+ }
61
+
62
+ module.exports = { CodeSystemXML };
@@ -0,0 +1,65 @@
1
+ //
2
+ // ConceptMap XML Serialization
3
+ //
4
+
5
+ const { FhirXmlBase } = require('./xml-base');
6
+
7
+ /**
8
+ * XML support for FHIR ConceptMap resources
9
+ */
10
+ class ConceptMapXML extends FhirXmlBase {
11
+
12
+ /**
13
+ * Element order for ConceptMap (FHIR requires specific order)
14
+ */
15
+ static _elementOrder = [
16
+ 'id', 'meta', 'implicitRules', 'language', 'text', 'contained',
17
+ 'extension', 'modifierExtension',
18
+ 'url', 'identifier', 'version', 'versionAlgorithmString', 'versionAlgorithmCoding',
19
+ 'name', 'title', 'status', 'experimental', 'date', 'publisher',
20
+ 'contact', 'description', 'useContext', 'jurisdiction', 'purpose', 'copyright',
21
+ 'copyrightLabel', 'approvalDate', 'lastReviewDate', 'effectivePeriod',
22
+ 'sourceScopeUri', 'sourceScopeCanonical', 'targetScopeUri', 'targetScopeCanonical',
23
+ 'group'
24
+ ];
25
+
26
+ /**
27
+ * Convert ConceptMap JSON to XML string
28
+ * @param {Object} json - ConceptMap as JSON
29
+ * @param {number} fhirVersion - FHIR version (3, 4, or 5)
30
+ * @returns {string} XML string
31
+ */
32
+ // eslint-disable-next-line no-unused-vars
33
+ static toXml(json, fhirVersion) {
34
+ const content = this.renderElementsInOrder(json, 1, this._elementOrder);
35
+ return this.wrapInRootElement('ConceptMap', content);
36
+ }
37
+
38
+ /**
39
+ * Convert XML string to ConceptMap JSON
40
+ * @param {string} xml - XML string
41
+ * @param {number} fhirVersion - FHIR version
42
+ * @returns {Object} JSON object
43
+ */
44
+ // eslint-disable-next-line no-unused-vars
45
+ static fromXml(xml, fhirVersion) {
46
+ const element = this.parseXmlString(xml);
47
+ if (element.name !== 'ConceptMap') {
48
+ throw new Error(`Expected ConceptMap root element, got ${element.name}`);
49
+ }
50
+ return this.convertElementToFhirJson(element, 'ConceptMap');
51
+ }
52
+
53
+ /**
54
+ * Parse from a pre-parsed XML element
55
+ * @param {Object} element - Parsed element with {name, attributes, children}
56
+ * @param {number} fhirVersion - FHIR version
57
+ * @returns {Object} JSON object
58
+ */
59
+ // eslint-disable-next-line no-unused-vars
60
+ static fromXmlElement(element, fhirVersion) {
61
+ return this.convertElementToFhirJson(element, 'ConceptMap');
62
+ }
63
+ }
64
+
65
+ module.exports = { ConceptMapXML };
@@ -0,0 +1,65 @@
1
+ //
2
+ // NamingSystem XML Serialization
3
+ //
4
+
5
+ const { FhirXmlBase } = require('./xml-base');
6
+
7
+ /**
8
+ * XML support for FHIR NamingSystem resources
9
+ */
10
+ class NamingSystemXML extends FhirXmlBase {
11
+
12
+ /**
13
+ * Element order for NamingSystem (FHIR requires specific order)
14
+ */
15
+ static _elementOrder = [
16
+ 'id', 'meta', 'implicitRules', 'language', 'text', 'contained',
17
+ 'extension', 'modifierExtension',
18
+ 'url', 'identifier', 'version', 'versionAlgorithmString', 'versionAlgorithmCoding',
19
+ 'name', 'title', 'status', 'kind', 'experimental', 'date', 'publisher',
20
+ 'contact', 'responsible', 'type', 'description', 'useContext', 'jurisdiction',
21
+ 'purpose', 'copyright', 'copyrightLabel', 'approvalDate', 'lastReviewDate',
22
+ 'effectivePeriod', 'topic', 'author', 'editor', 'reviewer', 'endorser',
23
+ 'relatedArtifact', 'usage', 'uniqueId'
24
+ ];
25
+
26
+ /**
27
+ * Convert NamingSystem JSON to XML string
28
+ * @param {Object} json - NamingSystem as JSON
29
+ * @param {number} fhirVersion - FHIR version (3, 4, or 5)
30
+ * @returns {string} XML string
31
+ */
32
+ // eslint-disable-next-line no-unused-vars
33
+ static toXml(json, fhirVersion) {
34
+ const content = this.renderElementsInOrder(json, 1, this._elementOrder);
35
+ return this.wrapInRootElement('NamingSystem', content);
36
+ }
37
+
38
+ /**
39
+ * Convert XML string to NamingSystem JSON
40
+ * @param {string} xml - XML string
41
+ * @param {number} fhirVersion - FHIR version
42
+ * @returns {Object} JSON object
43
+ */
44
+ // eslint-disable-next-line no-unused-vars
45
+ static fromXml(xml, fhirVersion) {
46
+ const element = this.parseXmlString(xml);
47
+ if (element.name !== 'NamingSystem') {
48
+ throw new Error(`Expected NamingSystem root element, got ${element.name}`);
49
+ }
50
+ return this.convertElementToFhirJson(element, 'NamingSystem');
51
+ }
52
+
53
+ /**
54
+ * Parse from a pre-parsed XML element
55
+ * @param {Object} element - Parsed element with {name, attributes, children}
56
+ * @param {number} fhirVersion - FHIR version
57
+ * @returns {Object} JSON object
58
+ */
59
+ // eslint-disable-next-line no-unused-vars
60
+ static fromXmlElement(element, fhirVersion) {
61
+ return this.convertElementToFhirJson(element, 'NamingSystem');
62
+ }
63
+ }
64
+
65
+ module.exports = { NamingSystemXML };
@@ -0,0 +1,127 @@
1
+ //
2
+ // OperationOutcome XML Serialization
3
+ //
4
+
5
+ const { FhirXmlBase } = require('./xml-base');
6
+
7
+ /**
8
+ * XML support for FHIR OperationOutcome resources
9
+ */
10
+ class OperationOutcomeXML extends FhirXmlBase {
11
+
12
+ /**
13
+ * Element order for OperationOutcome (FHIR requires specific order)
14
+ */
15
+ static _elementOrder = [
16
+ 'id', 'meta', 'implicitRules', 'language', 'text', 'contained',
17
+ 'extension', 'modifierExtension', 'issue'
18
+ ];
19
+
20
+ /**
21
+ * Element order for issue elements
22
+ */
23
+ static _issueElementOrder = [
24
+ 'severity', 'code', 'details', 'diagnostics', 'location', 'expression'
25
+ ];
26
+
27
+ /**
28
+ * Convert OperationOutcome JSON to XML string
29
+ * @param {Object} json - OperationOutcome as JSON
30
+ * @param {number} fhirVersion - FHIR version (3, 4, or 5)
31
+ * @returns {string} XML string
32
+ */
33
+ // eslint-disable-next-line no-unused-vars
34
+ static toXml(json, fhirVersion) {
35
+ const content = this._renderOperationOutcome(json, 1);
36
+ return this.wrapInRootElement('OperationOutcome', content);
37
+ }
38
+
39
+ /**
40
+ * Render OperationOutcome with special handling for issues
41
+ * @private
42
+ */
43
+ static _renderOperationOutcome(obj, level) {
44
+ let xml = '';
45
+
46
+ // Process elements in order
47
+ for (const key of this._elementOrder) {
48
+ if (Object.hasOwn(obj, key) && key !== 'resourceType') {
49
+ if (key === 'issue') {
50
+ xml += this._renderIssues(obj.issue, level);
51
+ } else {
52
+ xml += this.renderElement(key, obj[key], level);
53
+ }
54
+ }
55
+ }
56
+
57
+ // Process any remaining elements
58
+ for (const key of Object.keys(obj)) {
59
+ if (!this._elementOrder.includes(key) && key !== 'resourceType' && !key.startsWith('_')) {
60
+ xml += this.renderElement(key, obj[key], level);
61
+ }
62
+ }
63
+
64
+ return xml;
65
+ }
66
+
67
+ /**
68
+ * Render issue array with proper element ordering
69
+ * @private
70
+ */
71
+ static _renderIssues(issues, level) {
72
+ let xml = '';
73
+ if (!Array.isArray(issues)) {
74
+ issues = [issues];
75
+ }
76
+
77
+ for (const issue of issues) {
78
+ xml += `${this.indent(level)}<issue>\n`;
79
+
80
+ // Render issue elements in correct order
81
+ for (const key of this._issueElementOrder) {
82
+ if (Object.hasOwn(issue, key)) {
83
+ xml += this.renderElement(key, issue[key], level + 1);
84
+ }
85
+ }
86
+
87
+ // Render any remaining elements
88
+ for (const key of Object.keys(issue)) {
89
+ if (!this._issueElementOrder.includes(key) && !key.startsWith('_')) {
90
+ xml += this.renderElement(key, issue[key], level + 1);
91
+ }
92
+ }
93
+
94
+ xml += `${this.indent(level)}</issue>\n`;
95
+ }
96
+
97
+ return xml;
98
+ }
99
+
100
+ /**
101
+ * Convert XML string to OperationOutcome JSON
102
+ * @param {string} xml - XML string
103
+ * @param {number} fhirVersion - FHIR version
104
+ * @returns {Object} JSON object
105
+ */
106
+ // eslint-disable-next-line no-unused-vars
107
+ static fromXml(xml, fhirVersion) {
108
+ const element = this.parseXmlString(xml);
109
+ if (element.name !== 'OperationOutcome') {
110
+ throw new Error(`Expected OperationOutcome root element, got ${element.name}`);
111
+ }
112
+ return this.convertElementToFhirJson(element, 'OperationOutcome');
113
+ }
114
+
115
+ /**
116
+ * Parse from a pre-parsed XML element
117
+ * @param {Object} element - Parsed element with {name, attributes, children}
118
+ * @param {number} fhirVersion - FHIR version
119
+ * @returns {Object} JSON object
120
+ */
121
+ // eslint-disable-next-line no-unused-vars
122
+ static fromXmlElement(element, fhirVersion) {
123
+ return this.convertElementToFhirJson(element, 'OperationOutcome');
124
+ }
125
+ }
126
+
127
+ module.exports = { OperationOutcomeXML };
@@ -0,0 +1,312 @@
1
+ //
2
+ // Parameters XML Serialization
3
+ //
4
+
5
+ const { FhirXmlBase } = require('./xml-base');
6
+
7
+ // Forward declarations - will be loaded lazily to avoid circular dependencies
8
+ let CodeSystemXML, ValueSetXML, ConceptMapXML, OperationOutcomeXML;
9
+
10
+ /**
11
+ * XML support for FHIR Parameters resources
12
+ */
13
+ class ParametersXML extends FhirXmlBase {
14
+
15
+ /**
16
+ * Element order for Parameters (FHIR requires specific order)
17
+ */
18
+ static _elementOrder = [
19
+ 'id', 'meta', 'implicitRules', 'language', 'parameter'
20
+ ];
21
+
22
+ /**
23
+ * Lazily load resource XML classes to avoid circular dependencies
24
+ */
25
+ static _loadResourceClasses() {
26
+ if (!CodeSystemXML) {
27
+ CodeSystemXML = require('./codesystem-xml').CodeSystemXML;
28
+ ValueSetXML = require('./valueset-xml').ValueSetXML;
29
+ ConceptMapXML = require('./conceptmap-xml').ConceptMapXML;
30
+ OperationOutcomeXML = require('./operationoutcome-xml').OperationOutcomeXML;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Convert Parameters JSON to XML string
36
+ * @param {Object} json - Parameters as JSON
37
+ * @param {number} fhirVersion - FHIR version (3, 4, or 5)
38
+ * @returns {string} XML string
39
+ */
40
+ static toXml(json, fhirVersion) {
41
+ this._loadResourceClasses();
42
+ const content = this._renderParameters(json, 1, fhirVersion);
43
+ return this.wrapInRootElement('Parameters', content);
44
+ }
45
+
46
+ /**
47
+ * Render Parameters with special handling for parameter elements
48
+ * @private
49
+ */
50
+ static _renderParameters(obj, level, fhirVersion) {
51
+ let xml = '';
52
+
53
+ // Process elements in order
54
+ for (const key of this._elementOrder) {
55
+ if (Object.hasOwn(obj, key) && key !== 'resourceType') {
56
+ if (key === 'parameter') {
57
+ xml += this._renderParameterArray(obj.parameter, level, fhirVersion);
58
+ } else {
59
+ xml += this.renderElement(key, obj[key], level);
60
+ }
61
+ }
62
+ }
63
+
64
+ // Process any remaining elements
65
+ for (const key of Object.keys(obj)) {
66
+ if (!this._elementOrder.includes(key) && key !== 'resourceType' && !key.startsWith('_')) {
67
+ xml += this.renderElement(key, obj[key], level);
68
+ }
69
+ }
70
+
71
+ return xml;
72
+ }
73
+
74
+ /**
75
+ * Render parameter array
76
+ * @private
77
+ */
78
+ static _renderParameterArray(parameters, level, fhirVersion) {
79
+ let xml = '';
80
+ if (!Array.isArray(parameters)) {
81
+ parameters = [parameters];
82
+ }
83
+
84
+ for (const param of parameters) {
85
+ xml += `${this.indent(level)}<parameter>\n`;
86
+ xml += this._renderParameter(param, level + 1, fhirVersion);
87
+ xml += `${this.indent(level)}</parameter>\n`;
88
+ }
89
+
90
+ return xml;
91
+ }
92
+
93
+ /**
94
+ * Render a single parameter
95
+ * @private
96
+ */
97
+ static _renderParameter(param, level, fhirVersion) {
98
+ let xml = '';
99
+
100
+ // Parameter element order: name, value[x], resource, part
101
+ if (param.name !== undefined) {
102
+ xml += `${this.indent(level)}<name value="${this.escapeXml(param.name)}"/>\n`;
103
+ }
104
+
105
+ // Handle value[x] - find the value property
106
+ for (const [key, value] of Object.entries(param)) {
107
+ if (key.startsWith('value')) {
108
+ xml += this.renderElement(key, value, level);
109
+ break;
110
+ }
111
+ }
112
+
113
+ // Handle resource
114
+ if (param.resource) {
115
+ xml += `${this.indent(level)}<resource>\n`;
116
+ xml += this._renderResource(param.resource, level + 1, fhirVersion);
117
+ xml += `${this.indent(level)}</resource>\n`;
118
+ }
119
+
120
+ // Handle nested parts
121
+ if (param.part) {
122
+ for (const part of param.part) {
123
+ xml += `${this.indent(level)}<part>\n`;
124
+ xml += this._renderParameter(part, level + 1, fhirVersion);
125
+ xml += `${this.indent(level)}</part>\n`;
126
+ }
127
+ }
128
+
129
+ return xml;
130
+ }
131
+
132
+ /**
133
+ * Render an embedded resource
134
+ * @private
135
+ */
136
+ static _renderResource(resource, level, fhirVersion) {
137
+ const resourceType = resource.resourceType;
138
+ if (!resourceType) {
139
+ return '';
140
+ }
141
+
142
+ // Try to use dedicated XML converter
143
+ let fullXml;
144
+ try {
145
+ switch (resourceType) {
146
+ case 'CodeSystem':
147
+ fullXml = CodeSystemXML.toXml(resource, fhirVersion);
148
+ break;
149
+ case 'ValueSet':
150
+ fullXml = ValueSetXML.toXml(resource, fhirVersion);
151
+ break;
152
+ case 'ConceptMap':
153
+ fullXml = ConceptMapXML.toXml(resource, fhirVersion);
154
+ break;
155
+ case 'OperationOutcome':
156
+ fullXml = OperationOutcomeXML.toXml(resource, fhirVersion);
157
+ break;
158
+ case 'Parameters':
159
+ fullXml = ParametersXML.toXml(resource, fhirVersion);
160
+ break;
161
+ default:
162
+ // Fall back to generic rendering
163
+ return this._renderGenericResource(resource, level);
164
+ }
165
+
166
+ // Remove XML declaration and re-indent
167
+ let fragment = fullXml.replace(/^<\?xml[^?]*\?>\s*\n?/, '');
168
+
169
+ // Add indentation to each line
170
+ const indent = this.indent(level);
171
+ fragment = fragment.split('\n').map(line => line ? indent + line : line).join('\n');
172
+
173
+ return fragment;
174
+ } catch (e) {
175
+ return this._renderGenericResource(resource, level);
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Generic resource rendering fallback
181
+ * @private
182
+ */
183
+ static _renderGenericResource(resource, level) {
184
+ let xml = '';
185
+ const resourceType = resource.resourceType;
186
+ if (resourceType) {
187
+ xml += `${this.indent(level)}<${resourceType} xmlns="${this.getNamespace()}">\n`;
188
+ for (const [key, value] of Object.entries(resource)) {
189
+ if (key !== 'resourceType') {
190
+ xml += this.renderElement(key, value, level + 1);
191
+ }
192
+ }
193
+ xml += `${this.indent(level)}</${resourceType}>\n`;
194
+ }
195
+ return xml;
196
+ }
197
+
198
+ /**
199
+ * Convert XML string to Parameters JSON
200
+ * @param {string} xml - XML string
201
+ * @param {number} fhirVersion - FHIR version
202
+ * @returns {Object} JSON object
203
+ */
204
+ static fromXml(xml, fhirVersion) {
205
+ this._loadResourceClasses();
206
+ const element = this.parseXmlString(xml);
207
+ if (element.name !== 'Parameters') {
208
+ throw new Error(`Expected Parameters root element, got ${element.name}`);
209
+ }
210
+ return this._parseParametersElement(element, fhirVersion);
211
+ }
212
+
213
+ /**
214
+ * Parse from a pre-parsed XML element
215
+ * @param {Object} element - Parsed element with {name, attributes, children}
216
+ * @param {number} fhirVersion - FHIR version
217
+ * @returns {Object} JSON object
218
+ */
219
+ static fromXmlElement(element, fhirVersion) {
220
+ this._loadResourceClasses();
221
+ return this._parseParametersElement(element, fhirVersion);
222
+ }
223
+
224
+ /**
225
+ * Parse Parameters element
226
+ * @private
227
+ */
228
+ static _parseParametersElement(element, fhirVersion) {
229
+ const json = { resourceType: 'Parameters' };
230
+
231
+ for (const child of element.children) {
232
+ if (child.name === 'id') {
233
+ json.id = child.attributes.value;
234
+ } else if (child.name === 'meta') {
235
+ json.meta = this.convertChildElement(child);
236
+ } else if (child.name === 'implicitRules') {
237
+ json.implicitRules = child.attributes.value;
238
+ } else if (child.name === 'language') {
239
+ json.language = child.attributes.value;
240
+ } else if (child.name === 'parameter') {
241
+ if (!json.parameter) {
242
+ json.parameter = [];
243
+ }
244
+ json.parameter.push(this._parseParameter(child, fhirVersion));
245
+ }
246
+ }
247
+
248
+ return json;
249
+ }
250
+
251
+ /**
252
+ * Parse a parameter element
253
+ * @private
254
+ */
255
+ static _parseParameter(element, fhirVersion) {
256
+ const param = {};
257
+
258
+ for (const child of element.children) {
259
+ if (child.name === 'name') {
260
+ param.name = child.attributes.value;
261
+ } else if (child.name.startsWith('value')) {
262
+ const { value, primitiveExt } = this._convertChildElementWithExt(child);
263
+ if (value !== null) {
264
+ param[child.name] = value;
265
+ }
266
+ if (primitiveExt !== null) {
267
+ param['_' + child.name] = primitiveExt;
268
+ }
269
+ } else if (child.name === 'resource') {
270
+ param.resource = this._parseResourceElement(child, fhirVersion);
271
+ } else if (child.name === 'part') {
272
+ if (!param.part) {
273
+ param.part = [];
274
+ }
275
+ param.part.push(this._parseParameter(child, fhirVersion));
276
+ }
277
+ }
278
+
279
+ return param;
280
+ }
281
+
282
+ /**
283
+ * Parse a resource element
284
+ * @private
285
+ */
286
+ static _parseResourceElement(element, fhirVersion) {
287
+ if (element.children.length > 0) {
288
+ const resourceElement = element.children[0];
289
+ const resourceType = resourceElement.name;
290
+
291
+ // Try to use dedicated parser
292
+ switch (resourceType) {
293
+ case 'CodeSystem':
294
+ return CodeSystemXML.fromXmlElement(resourceElement, fhirVersion);
295
+ case 'ValueSet':
296
+ return ValueSetXML.fromXmlElement(resourceElement, fhirVersion);
297
+ case 'ConceptMap':
298
+ return ConceptMapXML.fromXmlElement(resourceElement, fhirVersion);
299
+ case 'OperationOutcome':
300
+ return OperationOutcomeXML.fromXmlElement(resourceElement, fhirVersion);
301
+ case 'Parameters':
302
+ return ParametersXML.fromXmlElement(resourceElement, fhirVersion);
303
+ default:
304
+ // Generic parsing
305
+ return this.convertElementToFhirJson(resourceElement, resourceType);
306
+ }
307
+ }
308
+ return null;
309
+ }
310
+ }
311
+
312
+ module.exports = { ParametersXML };