Skip to content

Commit bf4ef14

Browse files
Dtphelan1jafeltra
authored andcommitted
Fixed CDS Extractor
1 parent 68c5547 commit bf4ef14

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

test/extractors/CSVCancerDiseaseStatusExtractor.test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const path = require('path');
22
const _ = require('lodash');
33
const { CSVCancerDiseaseStatusExtractor } = require('../../src/extractors');
4+
const { getPatientFromContext } = require('../../src/helpers/contextUtils');
45
const exampleCSVDiseaseStatusModuleResponse = require('./fixtures/csv-cancer-disease-status-module-response.json');
56
const exampleCSVDiseaseStatusBundle = require('./fixtures/csv-cancer-disease-status-bundle.json');
7+
const MOCK_CONTEXT = require('./fixtures/context-with-patient.json');
68

79
// Constants for tests
810
const MOCK_PATIENT_MRN = 'pat-mrn-1'; // linked to values in example-module-response above
@@ -25,7 +27,7 @@ const csvModuleSpy = jest.spyOn(csvModule, 'get');
2527
describe('CSVCancerDiseaseStatusExtractor', () => {
2628
describe('joinAndReformatData', () => {
2729
test('should join data appropriately and throw errors when missing required properties', () => {
28-
const expectedErrorString = 'DiseaseStatusData missing an expected property: mrn, conditionId, diseaseStatusCode, and dateOfObservation are required.';
30+
const expectedErrorString = 'DiseaseStatusData missing an expected property: conditionId, diseaseStatusCode, and dateOfObservation are required.';
2931
const localData = _.cloneDeep(exampleCSVDiseaseStatusModuleResponse);
3032
// Test that valid data works fine
3133
expect(csvCancerDiseaseStatusExtractor.joinAndReformatData(exampleCSVDiseaseStatusModuleResponse)).toEqual(expect.anything());
@@ -36,7 +38,7 @@ describe('CSVCancerDiseaseStatusExtractor', () => {
3638
// Only including required properties is valid
3739
expect(csvCancerDiseaseStatusExtractor.joinAndReformatData(localData)).toEqual(expect.anything());
3840

39-
const requiredProperties = ['mrn', 'conditionId', 'diseaseStatusCode', 'dateOfObservation'];
41+
const requiredProperties = ['conditionId', 'diseaseStatusCode', 'dateOfObservation'];
4042

4143
// Removing each required property should throw an error
4244
requiredProperties.forEach((key) => {
@@ -50,7 +52,7 @@ describe('CSVCancerDiseaseStatusExtractor', () => {
5052
describe('get', () => {
5153
test('should return bundle with Observation', async () => {
5254
csvModuleSpy.mockReturnValue(exampleCSVDiseaseStatusModuleResponse);
53-
const data = await csvCancerDiseaseStatusExtractor.get({ mrn: MOCK_PATIENT_MRN });
55+
const data = await csvCancerDiseaseStatusExtractor.get({ mrn: MOCK_PATIENT_MRN, context: MOCK_CONTEXT });
5456
expect(data.resourceType).toEqual('Bundle');
5557
expect(data.type).toEqual('collection');
5658
expect(data.entry).toBeDefined();
@@ -60,7 +62,7 @@ describe('CSVCancerDiseaseStatusExtractor', () => {
6062

6163
test('should return empty bundle when no data available from module', async () => {
6264
csvModuleSpy.mockReturnValue([]);
63-
const data = await csvCancerDiseaseStatusExtractor.get({ mrn: MOCK_PATIENT_MRN });
65+
const data = await csvCancerDiseaseStatusExtractor.get({ mrn: MOCK_PATIENT_MRN, context: MOCK_CONTEXT });
6466
expect(data.resourceType).toEqual('Bundle');
6567
expect(data.type).toEqual('collection');
6668
expect(data.entry).toBeDefined();

test/extractors/fixtures/csv-cancer-disease-status-bundle.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"type": "collection",
44
"entry": [
55
{
6-
"fullUrl": "urn:uuid:d1d13594c371179797ce1a58884f714624d5b1782c4775f0fa303d78e943d64c",
6+
"fullUrl": "urn:uuid:4b9e9b5a8db529782cd9e89b68c6a3fac408d2195f025691a3f2850cab18057f",
77
"resource": {
88
"resourceType": "Observation",
9-
"id": "d1d13594c371179797ce1a58884f714624d5b1782c4775f0fa303d78e943d64c",
9+
"id": "4b9e9b5a8db529782cd9e89b68c6a3fac408d2195f025691a3f2850cab18057f",
1010
"meta": {
1111
"profile": [
1212
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-disease-status"
@@ -40,7 +40,7 @@
4040
}
4141
],
4242
"subject": {
43-
"reference": "urn:uuid:pat-mrn-1",
43+
"reference": "urn:uuid:mrn-1",
4444
"type": "Patient"
4545
},
4646
"effectiveDateTime": "2019-12-02",
@@ -53,25 +53,25 @@
5353
}
5454
]
5555
},
56-
"extension" : [
56+
"extension": [
5757
{
58-
"url" : "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-evidence-type",
59-
"valueCodeableConcept" : {
60-
"coding" : [
58+
"url": "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-evidence-type",
59+
"valueCodeableConcept": {
60+
"coding": [
6161
{
62-
"system" : "http://snomed.info/sct",
62+
"system": "http://snomed.info/sct",
6363
"display": "imaging",
6464
"code": "363679005"
6565
}
6666
]
6767
}
6868
},
6969
{
70-
"url" : "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-evidence-type",
71-
"valueCodeableConcept" : {
72-
"coding" : [
70+
"url": "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-evidence-type",
71+
"valueCodeableConcept": {
72+
"coding": [
7373
{
74-
"system" : "http://snomed.info/sct",
74+
"system": "http://snomed.info/sct",
7575
"display": "pathology",
7676
"code": "252416005"
7777
}

0 commit comments

Comments
 (0)