From 1fe0b4acbdc301f36ead79e66caca9e6c4c45d05 Mon Sep 17 00:00:00 2001 From: Dylan Mendelowitz Date: Fri, 20 Aug 2021 08:48:09 -0400 Subject: [PATCH 1/2] Updating condition template to STU2 --- src/templates/ConditionTemplate.js | 15 +------- .../fixtures/csv-condition-bundle.json | 8 ----- test/templates/condition.test.js | 17 ---------- .../fixtures/cancer-condition-resource.json | 34 ------------------- 4 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 test/templates/fixtures/cancer-condition-resource.json diff --git a/src/templates/ConditionTemplate.js b/src/templates/ConditionTemplate.js index 6b49e862..3149623b 100644 --- a/src/templates/ConditionTemplate.js +++ b/src/templates/ConditionTemplate.js @@ -1,6 +1,5 @@ const { extensionArr, coding, valueX, reference } = require('./snippets'); const { ifAllArgsObj } = require('../helpers/templateUtils'); -const { isConditionCodeCancer } = require('../helpers/conditionUtils'); function histologyTemplate({ histology }) { return { @@ -41,20 +40,8 @@ function individualCategoryTemplate(category) { }; } -function categoryArrayTemplate(array, code) { +function categoryArrayTemplate(array) { const category = array.map(individualCategoryTemplate); - const codeValue = `${code.code}`; - const codeSystem = `${code.system}`; - if (isConditionCodeCancer(codeValue, codeSystem)) { - // On cancer conditions, include the fixed value for the disease category - category.push({ - coding: [coding({ - system: 'http://snomed.info/sct', - code: '64572001', - }), - ], - }); - } return { category }; } diff --git a/test/extractors/fixtures/csv-condition-bundle.json b/test/extractors/fixtures/csv-condition-bundle.json index c0d2a191..90be1fad 100644 --- a/test/extractors/fixtures/csv-condition-bundle.json +++ b/test/extractors/fixtures/csv-condition-bundle.json @@ -48,14 +48,6 @@ "code": "example-category" } ] - }, - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "64572001" - } - ] } ], "code": { diff --git a/test/templates/condition.test.js b/test/templates/condition.test.js index d8d9b38a..e4f8ff06 100644 --- a/test/templates/condition.test.js +++ b/test/templates/condition.test.js @@ -1,7 +1,6 @@ const { isValidFHIR } = require('../../src/helpers/fhirUtils'); const maximalValidExampleCondition = require('./fixtures/maximal-condition-resource.json'); const minimalValidExampleCondition = require('./fixtures/minimal-condition-resource.json'); -const cancerValidExampleCondition = require('./fixtures/cancer-condition-resource.json'); const { conditionTemplate } = require('../../src/templates/ConditionTemplate'); const { allOptionalKeyCombinationsNotThrow } = require('../utils'); @@ -115,22 +114,6 @@ describe('test Condition template', () => { expect(() => conditionTemplate(CONDITION_INVALID_DATA)).toThrow(Error); }); - test('cancer conditions should include the "disease" category', () => { - const diseaseCategory = { - coding: [ - { - code: '64572001', - system: 'http://snomed.info/sct', - }, - ], - }; - // Use a cancer condition code when generating resource - const cancerConditionData = { ...CONDITION_MINIMAL_DATA, code: { code: 'C02.0', system: 'http://hl7.org/fhir/sid/icd-10-cm' } }; - const generatedCondition = conditionTemplate(cancerConditionData); - expect(generatedCondition.category).toContainEqual(diseaseCategory); - expect(generatedCondition).toEqual(cancerValidExampleCondition); - }); - test('non-cancer conditions should not include the "disease" category', () => { const generatedCondition = conditionTemplate(CONDITION_MINIMAL_DATA); expect(generatedCondition.category).toHaveLength(1); // Only provided category is present diff --git a/test/templates/fixtures/cancer-condition-resource.json b/test/templates/fixtures/cancer-condition-resource.json deleted file mode 100644 index e91969b2..00000000 --- a/test/templates/fixtures/cancer-condition-resource.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "resourceType": "Condition", - "id": "example-id", - "category": [ - { - "coding": [ - { - "system": "http://terminology.hl7.org/CodeSystem/condition-category", - "code": "example-code" - } - ] - }, - { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "64572001" - } - ] - } - ], - "code": { - "coding": [ - { - "system": "http://hl7.org/fhir/sid/icd-10-cm", - "code": "C02.0" - } - ] - }, - "subject": { - "reference": "urn:uuid:example-subject-id", - "type": "Patient" - } -} From ea1ff5ef79a731bb58b6963de8b50c52b6a844e5 Mon Sep 17 00:00:00 2001 From: Dylan Mendelowitz Date: Fri, 20 Aug 2021 11:05:10 -0400 Subject: [PATCH 2/2] Removing unnecessary function arg and test case --- src/templates/ConditionTemplate.js | 2 +- test/templates/condition.test.js | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/templates/ConditionTemplate.js b/src/templates/ConditionTemplate.js index 3149623b..1a776793 100644 --- a/src/templates/ConditionTemplate.js +++ b/src/templates/ConditionTemplate.js @@ -113,7 +113,7 @@ function conditionTemplate({ ), ...ifAllArgsObj(clinicalStatusTemplate)({ clinicalStatus }), ...ifAllArgsObj(verificationStatusTemplate)({ verificationStatus }), - ...categoryArrayTemplate(category, code), + ...categoryArrayTemplate(category), ...codingTemplate({ code }), ...ifAllArgsObj(bodySiteTemplate)({ bodySite, laterality }), ...subjectTemplate({ subject }), diff --git a/test/templates/condition.test.js b/test/templates/condition.test.js index e4f8ff06..849bbf22 100644 --- a/test/templates/condition.test.js +++ b/test/templates/condition.test.js @@ -113,10 +113,4 @@ describe('test Condition template', () => { test('invalid data should throw an error', () => { expect(() => conditionTemplate(CONDITION_INVALID_DATA)).toThrow(Error); }); - - test('non-cancer conditions should not include the "disease" category', () => { - const generatedCondition = conditionTemplate(CONDITION_MINIMAL_DATA); - expect(generatedCondition.category).toHaveLength(1); // Only provided category is present - expect(generatedCondition).toEqual(minimalValidExampleCondition); - }); });