Skip to content

Commit 27f070e

Browse files
committed
Variable renames and comment added for patient function
1 parent 9c8a8eb commit 27f070e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/helpers/contextUtils.js

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

5+
/**
6+
* Parses context a Patient resource
7+
* @param {Object} context - Context object consisting of a FHIR Bundle
8+
* @return {Object} The first Patient resource found in the bundle
9+
*/
510
function getPatientFromContext(mrn, context) {
611
logger.debug('Getting patient from context');
7-
const patientInContext = getBundleResourcesByType(context, 'Patient', {}, true);
8-
if (!patientInContext) {
12+
const patientResourceInContext = getBundleResourcesByType(context, 'Patient', {}, true);
13+
if (!patientResourceInContext) {
914
throw Error('Could not find a patient in context; ensure that a PatientExtractor is used earlier in your extraction configuration');
1015
}
1116
logger.debug('Patient resource found in context.');
12-
return patientInContext;
17+
return patientResourceInContext;
1318
}
1419

1520
/**
@@ -49,12 +54,12 @@ function getConditionsFromContext(context) {
4954
*/
5055
function getEncountersFromContext(context) {
5156
logger.debug('Getting encounter resources from context');
52-
const encountersInContext = getBundleResourcesByType(context, 'Encounter');
53-
if (encountersInContext.length === 0) {
57+
const encounterResourcesInContext = getBundleResourcesByType(context, 'Encounter');
58+
if (encounterResourcesInContext.length === 0) {
5459
throw Error('Could not find any encounter resources in context; ensure that an EncounterExtractor is used earlier in your extraction configuration');
5560
}
56-
logger.debug(`Condition resources found in context. Found ${encountersInContext.length} condition resources.`);
57-
return encountersInContext;
61+
logger.debug(`Condition resources found in context. Found ${encounterResourcesInContext.length} condition resources.`);
62+
return encounterResourcesInContext;
5863
}
5964

6065
module.exports = {

0 commit comments

Comments
 (0)