Skip to content

Commit 6ffe95a

Browse files
committed
system paramater added to isTumorMarker
1 parent 859d1d3 commit 6ffe95a

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/helpers/observationUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const vitalSignsCodeToTextLookup = {
1919
};
2020

2121

22-
function isTumorMarker(code) {
22+
function isTumorMarker(code, system) {
2323
const tumorMarkerTestVSPath = path.resolve(__dirname, 'valueSets', 'ValueSet-mcode-tumor-marker-test-vs.json');
24-
return checkCodeInVs(code, 'http://loinc.org', tumorMarkerTestVSPath);
24+
return checkCodeInVs(code, system, tumorMarkerTestVSPath);
2525
}
2626

2727
function isVitalSign(code) {

src/templates/ObservationTemplate.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { bodySiteTemplate, coding, reference, valueX } = require('./snippets');
22
const { ifSomeArgsObj } = require('../helpers/templateUtils');
33
const { isTumorMarker, isVitalSign, isKarnofskyPerformanceStatus, isECOGPerformanceStatus } = require('../helpers/observationUtils');
44

5-
function categoryTemplate({ code }) {
5+
function categoryTemplate({ code, system }) {
66
if (isVitalSign(code)) {
77
return {
88
category: [
@@ -18,7 +18,7 @@ function categoryTemplate({ code }) {
1818
],
1919
};
2020
}
21-
if (isTumorMarker(code)) {
21+
if (isTumorMarker(code, system)) {
2222
return {
2323
category: [
2424
{
@@ -51,9 +51,9 @@ function subjectTemplate({ subjectId }) {
5151
};
5252
}
5353

54-
function valueTemplate({ code, valueCode, valueCodeSystem }) {
54+
function valueTemplate({ code, system, valueCode, valueCodeSystem }) {
5555
if (!(code && valueCode)) return null;
56-
if (isTumorMarker(code)) return valueX({ code: valueCode, system: valueCodeSystem }, 'valueCodeableConcept');
56+
if (isTumorMarker(code, system)) return valueX({ code: valueCode, system: valueCodeSystem }, 'valueCodeableConcept');
5757
if (isECOGPerformanceStatus(code) || isKarnofskyPerformanceStatus(code)) return valueX(valueCode, 'valueInteger');
5858
return valueX(valueCode); // Vital Sign will be parsed as quantity, others will be parsed as appropriate
5959
}
@@ -70,11 +70,11 @@ function observationTemplate({
7070
resourceType: 'Observation',
7171
id,
7272
status,
73-
...categoryTemplate({ code }),
73+
...categoryTemplate({ code, system }),
7474
...ifSomeArgsObj(codeTemplate)({ code, system, display }),
7575
...subjectTemplate({ subjectId }),
7676
effectiveDateTime,
77-
...ifSomeArgsObj(valueTemplate)({ code, valueCode, valueCodeSystem }),
77+
...ifSomeArgsObj(valueTemplate)({ code, system, valueCode, valueCodeSystem }),
7878
...ifSomeArgsObj(bodySiteTemplate)({ bodySite, laterality }),
7979
};
8080
}

test/helpers/observationUtils.test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ describe('observationUtils', () => {
1414
});
1515
test('isTumorMarker should return true when passed a valid Tumor marker code', () => {
1616
const her2InTissue = '48676-1';
17-
expect(isTumorMarker(her2InTissue)).toEqual(true);
17+
const loincSystem = 'http://loinc.org';
18+
expect(isTumorMarker(her2InTissue, loincSystem)).toEqual(true);
1819
});
1920
test('isTumorMarker should return false when passed a code that does not belong to a Tumor Marker', () => {
2021
const code = '12345';
21-
expect(isTumorMarker(code)).toEqual(false);
22+
const loincSystem = 'http://loinc.org';
23+
expect(isTumorMarker(code, loincSystem)).toEqual(false);
24+
});
25+
test('isTumorMarker should return false when passed a valid Tumor marker code but an invalid code system', () => {
26+
const her2InTissue = '48676-1';
27+
const snomedSystem = 'http://snomed.info/sct';
28+
expect(isTumorMarker(her2InTissue, snomedSystem)).toEqual(false);
2229
});
2330
test('isKarnofskyPerformanceStatus should return true when passed the correct code', () => {
2431
const code = '89243-0';

0 commit comments

Comments
 (0)