Skip to content

Commit

Permalink
Merge pull request #39 from onemedical/CHIRP-930/fix-gender-sex
Browse files Browse the repository at this point in the history
CHIRP-930 fix birthsex value
  • Loading branch information
vburzynski-onemedical authored Aug 20, 2024
2 parents dd08945 + 58d9bbc commit 91eca1d
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 100 deletions.
Binary file removed .DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
158 changes: 80 additions & 78 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
.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
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.19.3
14.21.3
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"tabWidth": 4
}
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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": [
"<node_internals>/**"
],
"type": "node"
}
]
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [[email protected]](mailto:[email protected]) with any additional questions or comments.

## M2 Macs

```shell
arch -x86_64 zsh
nodenv install 14.21.3
```
4 changes: 4 additions & 0 deletions src/convert-xml-to-fhir-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
57 changes: 39 additions & 18 deletions src/lib/handlebars-converter/handlebars-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/templates/cda/Resources/Patient.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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":{
Expand Down

0 comments on commit 91eca1d

Please sign in to comment.