Skip to content

Commit c771fef

Browse files
committed
value[x] based approach
1 parent 44af405 commit c771fef

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

src/extractors/CSVCancerDiseaseStatusExtractor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ class CSVCancerDiseaseStatusExtractor {
1616
logger.debug('Reformatting disease status data from CSV into template format');
1717
// Check the shape of the data
1818
arrOfDiseaseStatusData.forEach((record) => {
19-
if (!record.mrn || !record.conditionId || (!record.diseaseStatusCode && record.observationStatus !== 'not evaluated') || !record.dateOfObservation) {
19+
if (!record.mrn || !record.conditionId || !record.diseaseStatusCode || !record.dateOfObservation) {
2020
throw new Error('DiseaseStatusData missing an expected property: mrn, conditionId, diseaseStatusCode, and dateOfObservation are required.');
2121
}
2222
});
2323
const evidenceDelimiter = '|';
2424
return arrOfDiseaseStatusData.map((record) => ({
2525
status: record.observationStatus || 'final',
26-
// If the Disease Status was not evaluated, there will be no value to make a record of and this property will be null
27-
value: record.observationStatus === 'not evaluated' ? null : {
26+
value: {
2827
code: record.diseaseStatusCode,
2928
system: 'http://snomed.info/sct',
3029
display: record.diseaseStatusText ? record.diseaseStatusText : getDiseaseStatusDisplay(record.diseaseStatusCode, this.implementation),

src/templates/CancerDiseaseStatusTemplate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function subjectTemplate({ subject }) {
2929
};
3030
}
3131

32-
function valueTemplate(valueObj) {
33-
if (valueObj === null) return { valueCodeableConcept: extensionArr(dataAbsentReasonExtension('not-asked')) };
34-
return valueX(valueObj, 'valueCodeableConcept');
32+
function valueTemplate({ code, display, system }) {
33+
if (code === '709137006') return { valueCodeableConcept: extensionArr(dataAbsentReasonExtension('not-asked')) };
34+
return valueX({ code, display, system }, 'valueCodeableConcept');
3535
}
3636

3737
function cancerDiseaseStatusTemplate({
@@ -43,7 +43,7 @@ function cancerDiseaseStatusTemplate({
4343
value,
4444
evidence,
4545
}) {
46-
if (!id || !status || !effectiveDateTime || !condition || !subject || (!value && status !== 'not evaluated')) {
46+
if (!id || !status || !effectiveDateTime || !condition || !subject || !value) {
4747
throw Error('Trying to render a CancerDiseaseStatusTemplate, but a required argument is missing; ensure that id, status, effectiveDateTime, condition, subject, and value are all present');
4848
}
4949

@@ -56,7 +56,7 @@ function cancerDiseaseStatusTemplate({
5656
],
5757
},
5858
...extensionArr(...evidenceTemplate({ evidence })),
59-
status: status === 'not evaluated' ? 'final' : status,
59+
status,
6060
category: [
6161
{
6262
coding: [

test/extractors/CSVCancerDiseaseStatusExtractor.test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ describe('CSVCancerDiseaseStatusExtractor', () => {
3636
// Only including required properties is valid
3737
expect(csvCancerDiseaseStatusExtractor.joinAndReformatData(localData)).toEqual(expect.anything());
3838

39-
// Excluding diseaseStatusCode with an obseervationStatus of 'not evaluated' should be valid
40-
localData[0].observationStatus = 'not evaluated';
41-
localData[0].diseaseStatusCode = '';
42-
expect(csvCancerDiseaseStatusExtractor.joinAndReformatData(localData)).toEqual(expect.anything());
43-
44-
localData[0].observationStatus = '';
45-
4639
const requiredProperties = ['mrn', 'conditionId', 'diseaseStatusCode', 'dateOfObservation'];
4740

4841
// Removing each required property should throw an error

test/templates/cancerDiseaseStatus.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ describe('test CancerDiseaseStatus template', () => {
4444
const MINIMAL_DATA = {
4545
// Minimal amount of data to be accepted, evidence is excluded
4646
id: 'CancerDiseaseStatus-fixture',
47-
status: 'not evaluated',
48-
value: null,
47+
status: 'final',
48+
value: {
49+
code: '709137006',
50+
system: 'http://snomed.info/sct',
51+
display: 'not evaluated',
52+
},
4953
subject: {
5054
id: '123-example-patient',
5155
name: 'Mr. Patient Example',

0 commit comments

Comments
 (0)