|
1 |
| -const { getConditionEntriesFromContext, getConditionsFromContext, getEncountersFromContext, getPatientFromContext } = require('../../src/helpers/contextUtils'); |
2 |
| - |
3 |
| -const MOCK_PATIENT_MRN = '123'; |
| 1 | +const { |
| 2 | + getConditionEntriesFromContext, |
| 3 | + getConditionsFromContext, |
| 4 | + getEncountersFromContext, |
| 5 | + getPatientFromContext, |
| 6 | + getResearchStudiesFromContext, |
| 7 | +} = require('../../src/helpers/contextUtils'); |
4 | 8 |
|
5 | 9 | describe('getPatientFromContext', () => {
|
6 | 10 | const patientResource = {
|
@@ -124,7 +128,39 @@ describe('getEncountersFromContext', () => {
|
124 | 128 | });
|
125 | 129 |
|
126 | 130 | test('Should throw an error if there are no encounters in context', () => {
|
127 |
| - expect(() => getEncountersFromContext(MOCK_PATIENT_MRN, {})) |
| 131 | + expect(() => getEncountersFromContext({})) |
128 | 132 | .toThrow('Could not find any encounter resources in context; ensure that an EncounterExtractor is used earlier in your extraction configuration');
|
129 | 133 | });
|
130 | 134 | });
|
| 135 | + |
| 136 | +describe('getResearchStudyFromContext', () => { |
| 137 | + const researchStudyResource = { |
| 138 | + resourceType: 'ResearchStudy', |
| 139 | + id: 'ResearchStudyExample01', |
| 140 | + }; |
| 141 | + const researchStudyContext = { |
| 142 | + resourceType: 'Bundle', |
| 143 | + type: 'collection', |
| 144 | + entry: [ |
| 145 | + { |
| 146 | + fullUrl: 'context-url-1', |
| 147 | + resource: researchStudyResource, |
| 148 | + }, |
| 149 | + { |
| 150 | + fullUrl: 'context-url-2', |
| 151 | + resource: { ...researchStudyResource, id: 'ResearchStudyExample02' }, |
| 152 | + }, |
| 153 | + ], |
| 154 | + }; |
| 155 | + |
| 156 | + test('Should return all ResearchStudy resources in context', () => { |
| 157 | + const researchStudyResources = getResearchStudiesFromContext(researchStudyContext); |
| 158 | + expect(researchStudyResources).toHaveLength(2); |
| 159 | + expect(researchStudyResources[0]).toEqual(researchStudyResource); |
| 160 | + }); |
| 161 | + |
| 162 | + test('Should throw an error if there are no research studies in context', () => { |
| 163 | + expect(() => getResearchStudiesFromContext({})) |
| 164 | + .toThrow('Could not find any ResearchStudy resources in context; ensure that a ClinicalTrialInformationExtractor or ResearchStudyExtractor is used earlier in your extraction configuration'); |
| 165 | + }); |
| 166 | +}); |
0 commit comments