|
| 1 | +const fs = require('fs'); |
1 | 2 | const path = require('path');
|
2 | 3 | const program = require('commander');
|
3 | 4 | const { MCODEClient } = require('../client/MCODEClient');
|
@@ -26,7 +27,21 @@ const allEntries = !entriesFilter;
|
26 | 27 |
|
27 | 28 | async function runApp() {
|
28 | 29 | try {
|
29 |
| - await mcodeApp(MCODEClient, fromDate, toDate, configFilepath, runLogFilepath, debug, allEntries); |
| 30 | + const extractedData = await mcodeApp(MCODEClient, fromDate, toDate, configFilepath, runLogFilepath, debug, allEntries); |
| 31 | + |
| 32 | + // Finally, save the data to disk |
| 33 | + const outputPath = './output'; |
| 34 | + if (!fs.existsSync(outputPath)) { |
| 35 | + logger.info(`Creating directory ${outputPath}`); |
| 36 | + fs.mkdirSync(outputPath); |
| 37 | + } |
| 38 | + // For each bundle in our extractedData, write it to our output directory |
| 39 | + extractedData.forEach((bundle, i) => { |
| 40 | + const outputFile = path.join(outputPath, `mcode-extraction-patient-${i + 1}.json`); |
| 41 | + logger.debug(`Logging mCODE output to ${outputFile}`); |
| 42 | + fs.writeFileSync(outputFile, JSON.stringify(bundle), 'utf8'); |
| 43 | + }); |
| 44 | + logger.info(`Successfully logged ${extractedData.length} mCODE bundle(s) to ${outputPath}`); |
30 | 45 | } catch (e) {
|
31 | 46 | if (debug) logger.level = 'debug';
|
32 | 47 | logger.error(e.message);
|
|
0 commit comments