-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding searchParameters to fhir extractor construction args to allow …
…for customizing the searches to servers to scope results. This will allow us to target specific Resources as best we can depending on the fhir server being accessed.
- Loading branch information
Showing
18 changed files
with
50 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,15 @@ | ||
const rewire = require('rewire'); | ||
const { FHIRAllergyIntoleranceExtractor } = require('../../src/extractors/FHIRAllergyIntoleranceExtractor.js'); | ||
|
||
const FHIRAllergyIntoleranceExtractorRewired = rewire('../../src/extractors/FHIRAllergyIntoleranceExtractor.js'); | ||
const MOCK_URL = 'http://example.com'; | ||
const MOCK_HEADERS = {}; | ||
const MOCK_MRN = '123456789'; | ||
const MOCK_CLINICAL_STATUS = 'status1,status2'; | ||
const MOCK_CONTEXT = { | ||
resourceType: 'Bundle', | ||
entry: [ | ||
{ | ||
fullUrl: 'context-url', | ||
resource: { resourceType: 'Patient', id: MOCK_MRN }, | ||
}, | ||
], | ||
}; | ||
|
||
const extractor = new FHIRAllergyIntoleranceExtractor({ baseFhirUrl: MOCK_URL, requestHeaders: MOCK_HEADERS }); | ||
const extractorWithClinicalStatus = new FHIRAllergyIntoleranceExtractor({ baseFhirUrl: MOCK_URL, requestHeaders: MOCK_HEADERS, clinicalStatus: MOCK_CLINICAL_STATUS }); | ||
const baseClinicalStatus = FHIRAllergyIntoleranceExtractorRewired.__get__('BASE_CLINICAL_STATUS'); | ||
|
||
describe('FHIRAllergyIntoleranceExtractor', () => { | ||
describe('Constructor', () => { | ||
test('sets resourceType as AllergyIntolerance', () => { | ||
expect(extractor.resourceType).toEqual('AllergyIntolerance'); | ||
}); | ||
|
||
test('sets clinical status based on BASE_CLINICAL_STATUS', () => { | ||
expect(extractor.clinicalStatus).toEqual(baseClinicalStatus); | ||
}); | ||
|
||
test('sets clinical status if provided', () => { | ||
expect(extractorWithClinicalStatus.clinicalStatus).toEqual(MOCK_CLINICAL_STATUS); | ||
}); | ||
}); | ||
|
||
describe('parametrizeArgsForFHIRModule', () => { | ||
test('should add category to param values', async () => { | ||
const params = await extractor.parametrizeArgsForFHIRModule({ context: MOCK_CONTEXT }); | ||
expect(params).toHaveProperty('clinical-status'); | ||
expect(params['clinical-status']).toEqual(baseClinicalStatus); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,16 @@ | ||
const rewire = require('rewire'); | ||
const { FHIRConditionExtractor } = require('../../src/extractors/FHIRConditionExtractor.js'); | ||
const MOCK_CONTEXT = require('./fixtures/context-with-patient.json'); | ||
|
||
const FHIRConditionExtractorRewired = rewire('../../src/extractors/FHIRConditionExtractor'); | ||
const MOCK_URL = 'http://example.com'; | ||
const MOCK_HEADERS = {}; | ||
const MOCK_CATEGORIES = 'category1,category2'; | ||
|
||
|
||
|
||
const extractor = new FHIRConditionExtractor({ baseFhirUrl: MOCK_URL, requestHeaders: MOCK_HEADERS }); | ||
const extractorWithCategories = new FHIRConditionExtractor({ baseFhirUrl: MOCK_URL, requestHeaders: MOCK_HEADERS, category: MOCK_CATEGORIES }); | ||
const baseCategories = FHIRConditionExtractorRewired.__get__('BASE_CATEGORIES'); | ||
|
||
describe('FHIRConditionExtractor', () => { | ||
describe('Constructor', () => { | ||
test('sets resourceType to Condition', () => { | ||
expect(extractor.resourceType).toEqual('Condition'); | ||
}); | ||
|
||
test('sets category based on BASE_CATEGORIES if not provided', () => { | ||
expect(extractor.category).toEqual(baseCategories); | ||
}); | ||
|
||
test('sets category if provided', () => { | ||
expect(extractorWithCategories.category).toEqual(MOCK_CATEGORIES); | ||
}); | ||
}); | ||
|
||
describe('parametrizeArgsForFHIRModule', () => { | ||
test('should add category to param values', async () => { | ||
const params = await extractor.parametrizeArgsForFHIRModule({ context: MOCK_CONTEXT }); | ||
expect(params).toHaveProperty('category'); | ||
expect(params.category).toEqual(baseCategories); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,14 @@ | ||
const rewire = require('rewire'); | ||
const { FHIRMedicationRequestExtractor } = require('../../src/extractors/FHIRMedicationRequestExtractor.js'); | ||
|
||
const FHIRMedicationRequestExtractorRewired = rewire('../../src/extractors/FHIRMedicationRequestExtractor.js'); | ||
const MOCK_URL = 'http://example.com'; | ||
const MOCK_HEADERS = {}; | ||
const MOCK_MRN = '123456789'; | ||
const MOCK_STATUSES = 'status1,status2'; | ||
const MOCK_CONTEXT = { | ||
resourceType: 'Bundle', | ||
entry: [ | ||
{ | ||
fullUrl: 'context-url', | ||
resource: { resourceType: 'Patient', id: MOCK_MRN }, | ||
}, | ||
], | ||
}; | ||
|
||
// Construct extractor and create spies for mocking responses | ||
const extractor = new FHIRMedicationRequestExtractor({ baseFhirUrl: MOCK_URL, requestHeaders: MOCK_HEADERS }); | ||
const extractorWithStatuses = new FHIRMedicationRequestExtractor({ baseFhirUrl: MOCK_URL, requestHeaders: MOCK_HEADERS, status: MOCK_STATUSES }); | ||
const baseStatuses = FHIRMedicationRequestExtractorRewired.__get__('BASE_STATUSES'); | ||
|
||
describe('FHIRMedicationRequestExtractor', () => { | ||
describe('Constructor', () => { | ||
test('sets resourceType as MedicationRequest', () => { | ||
expect(extractor.resourceType).toEqual('MedicationRequest'); | ||
}); | ||
test('sets status based on BASE_STATUS if not provided', () => { | ||
expect(extractor.status).toEqual(baseStatuses); | ||
}); | ||
test('sets status if provided', () => { | ||
expect(extractorWithStatuses.status).toEqual(MOCK_STATUSES); | ||
}); | ||
}); | ||
|
||
describe('parametrizeArgsForFHIRModule', () => { | ||
test('should not add status when not set to param values', async () => { | ||
const params = await extractor.parametrizeArgsForFHIRModule({ context: MOCK_CONTEXT }); | ||
expect(params).not.toHaveProperty('status'); | ||
}); | ||
|
||
test('should add status when set to param values', async () => { | ||
const params = await extractorWithStatuses.parametrizeArgsForFHIRModule({ context: MOCK_CONTEXT }); | ||
expect(params).toHaveProperty('status'); | ||
expect(params.status).toEqual(extractorWithStatuses.status); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.