diff --git a/package-lock.json b/package-lock.json index f145a458..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": { @@ -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", 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 ", 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..fb600b27 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 && 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', ],