Skip to content

Commit

Permalink
added ability to load a directory of directories of patients
Browse files Browse the repository at this point in the history
  • Loading branch information
hossenlopp committed Aug 15, 2023
1 parent 0b3ec6e commit 939e445
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ async function populatePatientBundles() {
}

if (program.patientsDirectory) {
patientBundles = fs
.readdirSync(program.patientsDirectory)
.map(p => parseBundle(path.join(program.patientsDirectory, p)));
const patientBundlePaths = findPatientBundlePathsInDirectory(program.patientsDirectory);
patientBundles = patientBundlePaths.map(p => parseBundle(path.join(program.patientsDirectory, p)));
} else {
patientBundles = program.patientBundles.map((bundlePath: string) => parseBundle(path.resolve(bundlePath)));
}
Expand All @@ -167,6 +166,24 @@ async function populatePatientBundles() {
return patientBundles;
}

function findPatientBundlePathsInDirectory(patientDir: string): string[] {
const paths: string[] = [];
// iterate over the given directory
fs.readdirSync(patientDir, { withFileTypes: true }).forEach(ent => {
// if this item is a directory, look for .json files under it
if (ent.isDirectory()) {
fs.readdirSync(path.join(patientDir, ent.name), { withFileTypes: true }).forEach(subEnt => {
if (!subEnt.isDirectory() && subEnt.name.endsWith('.json')) {
paths.push(path.join(ent.name, subEnt.name));
}
});
} else if (ent.name.endsWith('.json')) {
paths.push(ent.name);
}
});
return paths;
}

const measureBundle = parseBundle(path.resolve(program.measureBundle));

// Only cache valuesets retreived from service
Expand Down
2 changes: 1 addition & 1 deletion test/unit/queryFilters/interpretIn.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getELMFixture } from '../helpers/testHelpers';
import { DateTime, Interval } from 'cql-execution';
import * as QueryFilter from '../../../src/gaps/QueryFilterParser';
import { ELMIn, ELMIncludedIn } from '../../../src/types/ELMTypes';
import { ELMIn } from '../../../src/types/ELMTypes';
import { DuringFilter } from '../../../src/types/QueryFilterTypes';

// to use as a library parameter for tests
Expand Down

0 comments on commit 939e445

Please sign in to comment.