Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/cli/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,7 @@ async function mcodeApp(Client, fromDate, toDate, pathToConfig, pathToRunLogs, d
}
}

// Finally, save the data to disk
const outputPath = './output';
if (!fs.existsSync(outputPath)) {
logger.info(`Creating directory ${outputPath}`);
fs.mkdirSync(outputPath);
}
// For each bundle in our extractedData, write it to our output directory
extractedData.forEach((bundle, i) => {
const outputFile = path.join(outputPath, `mcode-extraction-patient-${i + 1}.json`);
logger.debug(`Logging mCODE output to ${outputFile}`);
fs.writeFileSync(outputFile, JSON.stringify(bundle), 'utf8');
});
logger.info(`Successfully logged ${extractedData.length} mCODE bundle(s) to ${outputPath}`);
return extractedData;
}

module.exports = {
Expand Down
17 changes: 16 additions & 1 deletion src/cli/cli.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs');
const path = require('path');
const program = require('commander');
const { MCODEClient } = require('../client/MCODEClient');
Expand Down Expand Up @@ -26,7 +27,21 @@ const allEntries = !entriesFilter;

async function runApp() {
try {
await mcodeApp(MCODEClient, fromDate, toDate, configFilepath, runLogFilepath, debug, allEntries);
const extractedData = await mcodeApp(MCODEClient, fromDate, toDate, configFilepath, runLogFilepath, debug, allEntries);

// Finally, save the data to disk
const outputPath = './output';
if (!fs.existsSync(outputPath)) {
logger.info(`Creating directory ${outputPath}`);
fs.mkdirSync(outputPath);
}
// For each bundle in our extractedData, write it to our output directory
extractedData.forEach((bundle, i) => {
const outputFile = path.join(outputPath, `mcode-extraction-patient-${i + 1}.json`);
logger.debug(`Logging mCODE output to ${outputFile}`);
fs.writeFileSync(outputFile, JSON.stringify(bundle), 'utf8');
});
logger.info(`Successfully logged ${extractedData.length} mCODE bundle(s) to ${outputPath}`);
} catch (e) {
if (debug) logger.level = 'debug';
logger.error(e.message);
Expand Down