From b23d5165166c377bcbf39432dbf166a44a2b9e2a Mon Sep 17 00:00:00 2001 From: Dylan Mendelowitz Date: Fri, 3 Feb 2023 14:12:24 -0500 Subject: [PATCH 1/4] Modifying conditions to allow multiple codes --- src/extractors/CSVConditionExtractor.js | 6 +++--- src/templates/ConditionTemplate.js | 5 ++--- test/templates/condition.test.js | 12 ++++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/extractors/CSVConditionExtractor.js b/src/extractors/CSVConditionExtractor.js index 74b8a614..4aeb6694 100644 --- a/src/extractors/CSVConditionExtractor.js +++ b/src/extractors/CSVConditionExtractor.js @@ -32,11 +32,11 @@ function formatData(conditionData, patientId) { subject: { id: patientId, }, - code: { - code, + code: code.split('|').map((c) => ({ + code: c, system: codeSystem, display: displayName, - }, + })), category: category.split('|'), dateOfDiagnosis: !dateOfDiagnosis ? null : formatDateTime(dateOfDiagnosis), clinicalStatus, diff --git a/src/templates/ConditionTemplate.js b/src/templates/ConditionTemplate.js index 1a776793..81cc0ba8 100644 --- a/src/templates/ConditionTemplate.js +++ b/src/templates/ConditionTemplate.js @@ -48,8 +48,7 @@ function categoryArrayTemplate(array) { function codingTemplate({ code }) { return { code: { - coding: [coding(code), - ], + coding: code.map((c) => coding(c)), }, }; } @@ -100,7 +99,7 @@ function subjectTemplate({ subject }) { function conditionTemplate({ subject, id, code, category, dateOfDiagnosis, clinicalStatus, verificationStatus, bodySite, laterality, histology, }) { - if (!(id && subject && code.system && code.code && category)) { + if (!(id && subject && code.every((c) => c.system) && code.every((c) => c.code) && category)) { throw Error('Trying to render a ConditionTemplate, but a required argument is missing; ensure that id, mrn, code, codesystem, and category are all present'); } diff --git a/test/templates/condition.test.js b/test/templates/condition.test.js index 849bbf22..60e0c558 100644 --- a/test/templates/condition.test.js +++ b/test/templates/condition.test.js @@ -9,11 +9,11 @@ const CONDITION_VALID_DATA = { subject: { id: 'example-subject-id', }, - code: { + code: [{ system: 'example-system', code: 'example-code', display: 'exampleDisplayName', - }, + }], category: [ 'example-code', ], @@ -33,10 +33,10 @@ const CONDITION_MINIMAL_DATA = { subject: { id: 'example-subject-id', }, - code: { + code: [{ system: 'example-system', code: 'example-code', - }, + }], category: [ 'example-code', ], @@ -97,11 +97,11 @@ describe('test Condition template', () => { subject: { id: 'example-subject-id', }, - code: { + code: [{ system: 'example-system', code: 'example-code', display: 'exampleDisplayName', - }, + }], category: [ 'example-code', ], From 3739e756f3bce1ef959073091d15296e4042d2fd Mon Sep 17 00:00:00 2001 From: dmendelowitz <79325127+dmendelowitz@users.noreply.github.com> Date: Tue, 7 Feb 2023 12:33:51 -0500 Subject: [PATCH 2/4] Update src/templates/ConditionTemplate.js Co-authored-by: Dylan Phelan --- src/templates/ConditionTemplate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/ConditionTemplate.js b/src/templates/ConditionTemplate.js index 81cc0ba8..fb600b27 100644 --- a/src/templates/ConditionTemplate.js +++ b/src/templates/ConditionTemplate.js @@ -99,7 +99,7 @@ function subjectTemplate({ subject }) { function conditionTemplate({ subject, id, code, category, dateOfDiagnosis, clinicalStatus, verificationStatus, bodySite, laterality, histology, }) { - if (!(id && subject && code.every((c) => c.system) && code.every((c) => c.code) && category)) { + if (!(id && subject && code.every((c) => c.system && c.code) && category)) { throw Error('Trying to render a ConditionTemplate, but a required argument is missing; ensure that id, mrn, code, codesystem, and category are all present'); } From f2487fe796d289d2e814fcdbcef3ffbbc6215557 Mon Sep 17 00:00:00 2001 From: Dylan Mendelowitz Date: Tue, 7 Feb 2023 15:19:46 -0500 Subject: [PATCH 3/4] npm audit fix --- package-lock.json | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index f145a458..74cd3ebb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8230,13 +8230,10 @@ "dev": true }, "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true }, "jsonfile": { "version": "2.4.0", From 8d7c3eb92f6b4500d3b8cf2da1b3764f7a6c0022 Mon Sep 17 00:00:00 2001 From: Dylan Mendelowitz Date: Tue, 7 Feb 2023 15:19:56 -0500 Subject: [PATCH 4/4] 2.2.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 74cd3ebb..f8104098 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mcode-extraction-framework", - "version": "2.1.0", + "version": "2.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 88876bee..47a4c7f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcode-extraction-framework", - "version": "2.1.0", + "version": "2.2.0", "description": "", "contributors": [ "Julia Afeltra ",