Skip to content

Commit

Permalink
Merge pull request #199 from mcode/fhir-mapper-filtering
Browse files Browse the repository at this point in the history
Post-extraction mapper
  • Loading branch information
rdingwell authored Nov 13, 2023
2 parents e642984 + 6a2c6cc commit 939155f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ node_modules/
.DS_Store
output/
logs/
config/*.json
config/*
!config/csv.config.example.json
34 changes: 33 additions & 1 deletion package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"commander": "^6.2.0",
"csv-parse": "^4.8.8",
"fhir-crud-client": "^1.2.2",
"fhir-mapper": "git+https://github.com/standardhealth/fhir-mapper.git",
"fhirpath": "2.1.5",
"lodash": "^4.17.21",
"moment": "^2.29.4",
Expand Down
16 changes: 16 additions & 0 deletions src/application/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const moment = require('moment');
const fs = require('fs');
const path = require('path');
const { AggregateMapper } = require('fhir-mapper');
const logger = require('../helpers/logger');
const { RunInstanceLogger } = require('./tools/RunInstanceLogger');
const { sendEmailNotification, zipErrors } = require('./tools/emailNotifications');
Expand Down Expand Up @@ -43,6 +46,19 @@ async function mcodeApp(Client, fromDate, toDate, config, pathToRunLogs, debug,
logger.info(`Extracting data for ${patientIds.length} patients`);
const { extractedData, successfulExtraction, totalExtractionErrors } = await extractDataForPatients(patientIds, mcodeClient, effectiveFromDate, effectiveToDate);

// Post-extraction mapping
if (fs.existsSync('./config/mapper.js')) {
logger.info('Applying post-extraction mapping');
// eslint-disable-next-line global-require, import/no-dynamic-require
const { resourceMapping, variables } = require(path.resolve('../../config/mapper.js'));
const mapper = new AggregateMapper(resourceMapping, variables);
extractedData.map((bundle) => {
const mappedBundle = bundle;
mappedBundle.entry = mapper.execute(bundle.entry);
return bundle;
});
}

// If we have notification information, send an emailNotification
const { notificationInfo } = config;
if (notificationInfo && Object.keys(notificationInfo).length > 0) {
Expand Down

0 comments on commit 939155f

Please sign in to comment.