Skip to content

Commit a4691f8

Browse files
committed
Added comments, removed MRN from fn call
1 parent d160326 commit a4691f8

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

src/helpers/contextUtils.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ const _ = require('lodash');
22
const logger = require('./logger');
33
const { getBundleEntriesByResourceType, getBundleResourcesByType } = require('./fhirUtils');
44

5-
6-
function getConditionsFromContext(mrn, context) {
7-
logger.debug('Getting conditions from context');
8-
const conditionsInContext = getBundleResourcesByType(context, 'Condition', {}, false);
9-
if (_.isEmpty(conditionsInContext)) {
10-
throw Error('Could not find conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
11-
}
12-
logger.debug('Condition resources found in context.');
13-
return conditionsInContext;
14-
}
15-
165
function getPatientFromContext(mrn, context) {
176
logger.debug('Getting patient from context');
187
const patientInContext = getBundleResourcesByType(context, 'Patient', {}, true);
@@ -23,14 +12,34 @@ function getPatientFromContext(mrn, context) {
2312
return patientInContext;
2413
}
2514

26-
function getConditionEntriesFromContext(mrn, context) {
15+
/**
16+
* Parses context for Condition entries, which themselves contain resources
17+
* @param {Object} context - Context object consisting of a FHIR Bundle
18+
* @return {Array} All the conditions entries found in context
19+
*/
20+
function getConditionEntriesFromContext(context) {
2721
logger.debug('Getting conditions from context');
28-
const conditionsInContext = getBundleEntriesByResourceType(context, 'Condition', {}, false);
29-
if (conditionsInContext.length === 0) {
22+
const conditionEntriesInContext = getBundleEntriesByResourceType(context, 'Condition', {}, false);
23+
if (conditionEntriesInContext.length === 0) {
3024
throw Error('Could not find any conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
3125
}
32-
logger.debug(`Condition resources found in context. Found ${conditionsInContext.length} condition resources.`);
33-
return conditionsInContext;
26+
logger.debug(`Condition resources found in context. Found ${conditionEntriesInContext.length} condition resources.`);
27+
return conditionEntriesInContext;
28+
}
29+
30+
/**
31+
* Parses context for Condition resources
32+
* @param {Object} context - Context object consisting of a FHIR Bundle
33+
* @return {Array} All the conditions resources found in context
34+
*/
35+
function getConditionsFromContext(context) {
36+
logger.debug('Getting conditions from context');
37+
const conditionsResourcesInContext = getBundleResourcesByType(context, 'Condition', {}, false);
38+
if (_.isEmpty(conditionsResourcesInContext)) {
39+
throw Error('Could not find conditions in context; ensure that a ConditionExtractor is used earlier in your extraction configuration');
40+
}
41+
logger.debug('Condition resources found in context.');
42+
return conditionsResourcesInContext;
3443
}
3544

3645
/**

0 commit comments

Comments
 (0)