From 1a6a2b48eea1cbc5bd11cf22c5ae4ee7288a95b2 Mon Sep 17 00:00:00 2001 From: Valerie Burzynski Date: Thu, 15 Aug 2024 14:39:05 -0500 Subject: [PATCH 1/7] chore: remove .DS_Store file --- .DS_Store | Bin 8196 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index c2d9b8abf76e001a329ea0dcdb9360c4df10f230..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM&2G~`5dJo?+LD$+IiOq+et|~f4NQJOl^~!tJ#Z@dF=@fADQzXV<&Jm-UIFni zJParJW_Jnp+Bp_gVm8_xdp+Om_?uZ<;{Y(-tJx!<4Pb*^G(C|cO90A<)3))Lb%4dhUM5~HoU~Bdbk&3LP~%Gs!08<(EAqXZU5237?=FXH-ZVSc$DIzj5QAe?D`UWOvEJ6{v2qxmfG$sM9p28p8;l# zm@~Y`DgBz3?Kge|y7$n-3-mF-5#|+mIB1e=% zJgr545729jRZ4F&M(k60rRZUx+oE58e0}GN3 zMGIR*0@R0*xV{=MQ+Deo)>(snC(Jt$$LMhU;6&HB Date: Thu, 15 Aug 2024 14:39:22 -0500 Subject: [PATCH 2/7] feat: ignore .DS_Store files --- .gitignore | 158 +++++++++++++++++++++++++++-------------------------- 1 file changed, 80 insertions(+), 78 deletions(-) diff --git a/.gitignore b/.gitignore index d6b0d3d53..a33312bb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,78 +1,80 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -!/src/**/Coverage - -# nyc test coverage -.nyc_output -.test_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz -!hl7.fhir.r4.core-4.0.1.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# next.js build output -.next - -# test temp data -.temp* - -# app runtime data -service-templates -tmp/ - -# autogen files -src/lib/outputProcessor/autogen/*.interp -src/lib/outputProcessor/autogen/*.tokens - -.idea -*.DS_Store \ No newline at end of file +.DS_Store + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +!/src/**/Coverage + +# nyc test coverage +.nyc_output +.test_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz +!hl7.fhir.r4.core-4.0.1.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next + +# test temp data +.temp* + +# app runtime data +service-templates +tmp/ + +# autogen files +src/lib/outputProcessor/autogen/*.interp +src/lib/outputProcessor/autogen/*.tokens + +.idea +*.DS_Store From 7a2102517bfd1dfdc4c3c4a9fae1db5d3078e0c6 Mon Sep 17 00:00:00 2001 From: Valerie Burzynski Date: Thu, 15 Aug 2024 14:39:51 -0500 Subject: [PATCH 3/7] feat: upgrade to latest node 14.x --- .node-version | 2 +- README.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.node-version b/.node-version index a5f7da7f0..f46d5e394 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -14.19.3 +14.21.3 diff --git a/README.md b/README.md index 50193d57b..5ff00db55 100644 --- a/README.md +++ b/README.md @@ -109,3 +109,10 @@ provided by the bot. You will only need to do this once across all repos using o This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + +## M2 Macs + +```shell +arch -x86_64 zsh +nodenv install 14.21.3 +``` From 19499b9856245391a99d13066a05c1a074186e96 Mon Sep 17 00:00:00 2001 From: Valerie Burzynski Date: Thu, 15 Aug 2024 14:40:33 -0500 Subject: [PATCH 4/7] fix: correct the extraction of the birth sex --- src/convert-xml-to-fhir-resource.js | 4 ++ .../handlebars-helpers.js | 57 +++++++++++++------ src/templates/cda/Resources/Patient.hbs | 6 +- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/convert-xml-to-fhir-resource.js b/src/convert-xml-to-fhir-resource.js index b8b2ee529..f5cb69ea0 100644 --- a/src/convert-xml-to-fhir-resource.js +++ b/src/convert-xml-to-fhir-resource.js @@ -4,10 +4,14 @@ const WorkerPool = require("./lib/workers/workerPool"); function createAndUploadFhirResource() { let filePath, newPath; const generateChirpTestFile = process.argv.slice(2)[0] == '--chirp-test-file'; + const filePathArg = process.argv.slice(2).find(value => /^--filePath=/.test(value)); if (generateChirpTestFile) { filePath = "src/sample-data/cda/Chirp_CCD.cda"; newPath = "test/e2e-test/regression-test/data/cda/ccd.hbs/ccd.hbs-Chirp_CCD.cda.json"; + } else if(filePathArg) { + filePath = filePathArg.split("=")[1].trim(); + newPath = filePath.replace(".xml", "--FHIR-RESOURCE.json"); } else { if ((process.env.npm_config_filepath || '') === '') { console.log("Must specify file path"); diff --git a/src/lib/handlebars-converter/handlebars-helpers.js b/src/lib/handlebars-converter/handlebars-helpers.js index f8f85da8d..fc9cd939c 100644 --- a/src/lib/handlebars-converter/handlebars-helpers.js +++ b/src/lib/handlebars-converter/handlebars-helpers.js @@ -643,35 +643,56 @@ module.exports.external = [ } } }, - { name: 'getBirthSexInfo', description: "Returns first instance of birthSex id e.g. getBirthSexInfo msg '2.16.840.1.113883.10.20.22.2.14'", + // FIXME: (anti-pattern) the arrow pattern here has been slightly improved but is still really bad + // FIXME: (code smell) long method - the function is way too long, but the structure of this file is terrible + // there isn't an obvious way to extract a method without introducing a new pattern and that's not the goal here func: function getBirthSexInfo(msg, templateId) { try { - var birthSexValue ; + var birthSexValue; let structuredBody = msg.ClinicalDocument.component.structuredBody; - if(structuredBody && structuredBody.component) { - for(var i=0; i< structuredBody.component.length; i++) { - let sectionObj = structuredBody.component[i].section; - if(sectionObj && sectionObj.templateId && JSON.stringify(sectionObj.templateId).includes('2.16.840.1.113883.10.20.22.2.17')){ - let entryObjs = sectionObj.entry; - for(var j=0; j < entryObjs.length; j++) { - let entryObj = entryObjs[j]; - if(entryObj){ - let observation = entryObj.observation; - if(observation && observation.templateId && JSON.stringify(observation.templateId).includes(templateId)){ - birthSexValue = observation.value.code; - break; - } - } + + // return undefined when there is no structured body component + if (!structuredBody || !structuredBody.component) return birthSexValue; + + sectionLoop: for (var i = 0; i < structuredBody.component.length; i++) { + let sectionObj = structuredBody.component[i].section; + if (!sectionObj || !sectionObj.templateId) continue; + if (!JSON.stringify(sectionObj.templateId).includes("2.16.840.1.113883.10.20.22.2.17")) continue; + + if (Array.isArray(sectionObj.entry)) { + let entries = sectionObj.entry; + for (var j = 0; j < entries.length; j++) { + let entry = entries[j]; + if (!entry) continue; + + let observation = entry.observation; + if ( + observation && + observation.templateId && + JSON.stringify(observation.templateId).includes(templateId) + ) { + birthSexValue = observation.value.code; + break sectionLoop; } } + } else { + let entry = sectionObj.entry; + if ( + entry && + entry.observation && + entry.observation.templateId && + JSON.stringify(entry.observation.templateId).includes(templateId) + ) { + birthSexValue = entry.observation.value.code; + break sectionLoop; + } } } return birthSexValue; - } - catch (err) { + } catch (err) { throw `helper "getBirthSexInfo" : ${err}`; } } diff --git a/src/templates/cda/Resources/Patient.hbs b/src/templates/cda/Resources/Patient.hbs index be3f70959..03f7d3df7 100644 --- a/src/templates/cda/Resources/Patient.hbs +++ b/src/templates/cda/Resources/Patient.hbs @@ -50,14 +50,14 @@ [ { "system":"urn:ietf:bcp:47", - "code":"{{this.languageCode.code}}", + "code":"{{this.languageCode.code}}", "display":{{>ValueSet/Language.hbs code=this.languageCode.code}}, }, ], - }, + }, "preferred":{{this.preferenceInd.value}}, }, - {{/each}} + {{/each}} ], }, "request":{ From 2c3906f2441cf3ac19ab5ec61f027641f87ea973 Mon Sep 17 00:00:00 2001 From: Valerie Burzynski Date: Thu, 15 Aug 2024 14:40:51 -0500 Subject: [PATCH 5/7] chore: start .prettierrc file --- .prettierrc | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..e8980d15c --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "printWidth": 120, + "tabWidth": 4 +} From edfe06b68bf594567ab94574552be5b171b67866 Mon Sep 17 00:00:00 2001 From: Valerie Burzynski Date: Thu, 15 Aug 2024 14:43:31 -0500 Subject: [PATCH 6/7] feat: add .editorconfig file --- .editorconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..179159f40 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +max_line_length = 120 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{diff,md,mdx}] +trim_trailing_whitespace = false From 58d9bbcb46118a142e79af017546c1b4c3174bfe Mon Sep 17 00:00:00 2001 From: Valerie Burzynski Date: Thu, 15 Aug 2024 14:43:54 -0500 Subject: [PATCH 7/7] feat: add vscode launch.json --- .vscode/launch.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..d7a242768 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Attach", + "port": 9229, + "request": "attach", + "skipFiles": [ + "/**" + ], + "type": "node" + } + ] +}