Skip to content

Commit

Permalink
Merge pull request #181 from mcode/develop
Browse files Browse the repository at this point in the history
v2.0.1
  • Loading branch information
julianxcarter authored May 18, 2022
2 parents 5af5068 + ea88358 commit 458826d
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @jafeltra @mgramigna @julianxcarter @dmendelowitz @dtphelan1
* @julianxcarter @dmendelowitz @dtphelan1
41 changes: 19 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mcode-extraction-framework",
"version": "2.0.0",
"version": "2.0.1",
"description": "",
"contributors": [
"Julia Afeltra <[email protected]>",
Expand Down Expand Up @@ -29,7 +29,7 @@
"fhir-crud-client": "^1.2.2",
"fhirpath": "2.1.5",
"lodash": "^4.17.21",
"moment": "^2.26.0",
"moment": "^2.29.3",
"nodemailer": "^6.7.2",
"winston": "^3.2.1"
},
Expand Down
6 changes: 5 additions & 1 deletion src/extractors/FHIRAdverseEventExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ class FHIRAdverseEventExtractor extends BaseFHIRExtractor {
try {
allResearchStudyResources = getResearchStudiesFromContext(context);
} catch (e) {
logger.error(e.message);
logger.debug(e.message);
logger.debug(e.stack);
if (!this.study) {
logger.error('There is no ResearchStudy id to complete a request for Adverse Event resources; please include a ClinicalTrialInformationExtractor,'
+ ' ResearchStudyExtractor, or "study" constructorArg in your extraction configuration.');
}
}

// The patient is referenced in the 'subject' field of an AdverseEvent
Expand Down
32 changes: 32 additions & 0 deletions src/helpers/contextUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,36 @@ function getConditionsFromContext(context) {
return conditionsResourcesInContext;
}

/**
* Parses context for AdverseEvent resources
* @param {Object} context - Context object consisting of a FHIR Bundle
* @return {Array} All the AdverseEvent resources found in context
*/
function getAdverseEventsFromContext(context) {
logger.debug('Getting adverse event resources from context');
const adverseEventResourcesInContext = getBundleResourcesByType(context, 'AdverseEvent', {}, false);
if (_.isEmpty(adverseEventResourcesInContext)) {
throw Error('Could not find any adverse events in context; ensure that an AdverseEventExtractor is used earlier in your extraction configuration');
}
logger.debug(`AdverseEvent resources found in context. Found ${adverseEventResourcesInContext.length} adverse event resources.`);
return adverseEventResourcesInContext;
}

/**
* Parses context for AdverseEvent entries, which themselves contain resources
* @param {Object} context - Context object consisting of a FHIR Bundle
* @return {Array} All the AdverseEvents entries found in context
*/
function getAdverseEventEntriesFromContext(context) {
logger.debug('Getting adverse event entries from context');
const adverseEventEntriesInContext = getBundleEntriesByResourceType(context, 'AdverseEvent', {}, false);
if (adverseEventEntriesInContext.length === 0) {
throw Error('Could not find any adverse events in context; ensure that an AdverseEventExtractor is used earlier in your extraction configuration');
}
logger.debug(`AdverseEvent entries found in context. Found ${adverseEventEntriesInContext.length} adverse event resources.`);
return adverseEventEntriesInContext;
}

/**
* Parses context for Encounter resources
* @param {Object} context - Context object consisting of a FHIR Bundle
Expand Down Expand Up @@ -78,4 +108,6 @@ module.exports = {
getEncountersFromContext,
getPatientFromContext,
getResearchStudiesFromContext,
getAdverseEventEntriesFromContext,
getAdverseEventsFromContext,
};
13 changes: 12 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ const {
const { getDiseaseStatusCode, getDiseaseStatusEvidenceCode, mEpochToDate } = require('./helpers/diseaseStatusUtils');
const { formatDate, formatDateTime } = require('./helpers/dateUtils');
const { lowercaseLookupQuery, createLowercaseLookup, createInvertedLookup } = require('./helpers/lookupUtils');
const { getConditionEntriesFromContext, getConditionsFromContext, getEncountersFromContext, getPatientFromContext } = require('./helpers/contextUtils');
const {
getConditionEntriesFromContext,
getConditionsFromContext,
getEncountersFromContext,
getPatientFromContext,
getAdverseEventsFromContext,
getAdverseEventEntriesFromContext,
} = require('./helpers/contextUtils');
const { parsePatientIds } = require('./helpers/appUtils');
const { getConfig, validateConfig } = require('./helpers/configUtils');
const configSchema = require('./helpers/schemas/config.schema.json');
const { sortExtractors } = require('./helpers/dependencyUtils');

module.exports = {
// CLI Related utilities
Expand Down Expand Up @@ -143,11 +151,14 @@ module.exports = {
logOperationOutcomeInfo,
lowercaseLookupQuery,
mEpochToDate,
sortExtractors,
// Context operations
getConditionEntriesFromContext,
getConditionsFromContext,
getEncountersFromContext,
getPatientFromContext,
getAdverseEventEntriesFromContext,
getAdverseEventsFromContext,
// Configuration file schema
configSchema,
};

0 comments on commit 458826d

Please sign in to comment.