Search in sources :

Example 1 with ExporterRuntimeOptions

use of org.mitre.synthea.export.Exporter.ExporterRuntimeOptions in project synthea by synthetichealth.

the class CSVExporterTest method testCSVExportExcludes.

@Test
public void testCSVExportExcludes() throws Exception {
    Config.set("exporter.csv.included_files", "");
    Config.set("exporter.csv.excluded_files", "patients.csv, medications, payers, providers");
    CSVExporter.getInstance().init();
    Payer.clear();
    Config.set("generate.payers.insurance_companies.default_file", "generic/payers/test_payers.csv");
    Payer.loadPayers(new Location(Generator.DEFAULT_STATE, null));
    int numberOfPeople = 10;
    ExporterRuntimeOptions exportOpts = new ExporterRuntimeOptions();
    exportOpts.deferExports = true;
    GeneratorOptions generatorOpts = new GeneratorOptions();
    generatorOpts.population = numberOfPeople;
    Generator generator = new Generator(generatorOpts, exportOpts);
    generator.options.overflow = false;
    for (int i = 0; i < numberOfPeople; i++) {
        generator.generatePerson(i);
    }
    // Adding post completion exports to generate organizations and providers CSV files
    Exporter.runPostCompletionExports(generator, exportOpts);
    // if we get here we at least had no exceptions
    File expectedExportFolder = exportDir.toPath().resolve("csv").toFile();
    assertTrue(expectedExportFolder.exists() && expectedExportFolder.isDirectory());
    boolean foundPatients = false;
    boolean foundMedications = false;
    boolean foundPayers = false;
    boolean foundProviders = false;
    int count = 0;
    for (File csvFile : expectedExportFolder.listFiles()) {
        if (!csvFile.getName().endsWith(".csv")) {
            continue;
        }
        switch(csvFile.getName()) {
            case "patients.csv":
                foundPatients = true;
                break;
            case "medications.csv":
                foundMedications = true;
                break;
            case "payers.csv":
                foundPayers = true;
                break;
            case "providers.csv":
                foundProviders = true;
                break;
            default:
        }
        String csvData = new String(Files.readAllBytes(csvFile.toPath()));
        // the CSV exporter doesn't use the SimpleCSV class to write the data,
        // so we can use it here for a level of validation
        SimpleCSV.parse(csvData);
        assertTrue("CSV validation: " + csvFile.getName(), SimpleCSV.isValid(csvData));
        count++;
    }
    int expected = NUMBER_OF_FILES - 4;
    assertEquals("Expected " + expected + " CSV files in the output directory, found " + count, expected, count);
    assertTrue("patients.csv is present but should have been excluded", !foundPatients);
    assertTrue("medications.csv is present but should have been excluded", !foundMedications);
    assertTrue("payers.csv is present but should have been excluded", !foundPayers);
    assertTrue("providers.csv is present but should have been excluded", !foundProviders);
}
Also used : GeneratorOptions(org.mitre.synthea.engine.Generator.GeneratorOptions) File(java.io.File) Location(org.mitre.synthea.world.geography.Location) ExporterRuntimeOptions(org.mitre.synthea.export.Exporter.ExporterRuntimeOptions) Generator(org.mitre.synthea.engine.Generator) Test(org.junit.Test)

Example 2 with ExporterRuntimeOptions

use of org.mitre.synthea.export.Exporter.ExporterRuntimeOptions in project synthea by synthetichealth.

the class CSVExporterTest method testCSVExportIncludes.

@Test
public void testCSVExportIncludes() throws Exception {
    Config.set("exporter.csv.included_files", "patients.csv,medications.csv,procedures.csv");
    Config.set("exporter.csv.excluded_files", "");
    CSVExporter.getInstance().init();
    Payer.clear();
    Config.set("generate.payers.insurance_companies.default_file", "generic/payers/test_payers.csv");
    Payer.loadPayers(new Location(Generator.DEFAULT_STATE, null));
    int numberOfPeople = 10;
    ExporterRuntimeOptions exportOpts = new ExporterRuntimeOptions();
    exportOpts.deferExports = true;
    GeneratorOptions generatorOpts = new GeneratorOptions();
    generatorOpts.population = numberOfPeople;
    Generator generator = new Generator(generatorOpts, exportOpts);
    generator.options.overflow = false;
    for (int i = 0; i < numberOfPeople; i++) {
        generator.generatePerson(i);
    }
    // Adding post completion exports to generate organizations and providers CSV files
    Exporter.runPostCompletionExports(generator, exportOpts);
    // if we get here we at least had no exceptions
    File expectedExportFolder = exportDir.toPath().resolve("csv").toFile();
    assertTrue(expectedExportFolder.exists() && expectedExportFolder.isDirectory());
    boolean foundPatients = false;
    boolean foundMedications = false;
    boolean foundProcedures = false;
    int count = 0;
    for (File csvFile : expectedExportFolder.listFiles()) {
        if (!csvFile.getName().endsWith(".csv")) {
            continue;
        }
        switch(csvFile.getName()) {
            case "patients.csv":
                foundPatients = true;
                break;
            case "medications.csv":
                foundMedications = true;
                break;
            case "procedures.csv":
                foundProcedures = true;
                break;
            default:
        }
        String csvData = new String(Files.readAllBytes(csvFile.toPath()));
        // the CSV exporter doesn't use the SimpleCSV class to write the data,
        // so we can use it here for a level of validation
        SimpleCSV.parse(csvData);
        assertTrue(SimpleCSV.isValid(csvData));
        count++;
    }
    assertEquals("Expected 3 CSV files in the output directory, found " + count, 3, count);
    assertTrue("patients.csv file missing but should have been included", foundPatients);
    assertTrue("medications.csv file missing but should have been included", foundMedications);
    assertTrue("procedures.csv file missing but should have been included", foundProcedures);
}
Also used : GeneratorOptions(org.mitre.synthea.engine.Generator.GeneratorOptions) File(java.io.File) Location(org.mitre.synthea.world.geography.Location) ExporterRuntimeOptions(org.mitre.synthea.export.Exporter.ExporterRuntimeOptions) Generator(org.mitre.synthea.engine.Generator) Test(org.junit.Test)

Example 3 with ExporterRuntimeOptions

use of org.mitre.synthea.export.Exporter.ExporterRuntimeOptions in project synthea by synthetichealth.

the class CSVExporterTest method testDeferredCSVExport.

@Test
public void testDeferredCSVExport() throws Exception {
    Config.set("exporter.csv.included_files", "");
    Config.set("exporter.csv.excluded_files", "");
    CSVExporter.getInstance().init();
    Payer.clear();
    Config.set("generate.payers.insurance_companies.default_file", "generic/payers/test_payers.csv");
    Payer.loadPayers(new Location(Generator.DEFAULT_STATE, null));
    int numberOfPeople = 10;
    ExporterRuntimeOptions exportOpts = new ExporterRuntimeOptions();
    exportOpts.deferExports = true;
    GeneratorOptions generatorOpts = new GeneratorOptions();
    generatorOpts.population = numberOfPeople;
    Generator generator = new Generator(generatorOpts, exportOpts);
    generator.options.overflow = false;
    for (int i = 0; i < numberOfPeople; i++) {
        generator.generatePerson(i);
    }
    // Adding post completion exports to generate organizations and providers CSV files
    Exporter.runPostCompletionExports(generator, exportOpts);
    // if we get here we at least had no exceptions
    File expectedExportFolder = exportDir.toPath().resolve("csv").toFile();
    assertTrue(expectedExportFolder.exists() && expectedExportFolder.isDirectory());
    int count = 0;
    for (File csvFile : expectedExportFolder.listFiles()) {
        if (!csvFile.getName().endsWith(".csv")) {
            continue;
        }
        String csvData = new String(Files.readAllBytes(csvFile.toPath()));
        // the CSV exporter doesn't use the SimpleCSV class to write the data,
        // so we can use it here for a level of validation
        SimpleCSV.parse(csvData);
        assertTrue("CSV Validation: " + csvFile.getName(), SimpleCSV.isValid(csvData));
        count++;
    }
    assertEquals("Expected " + NUMBER_OF_FILES + " CSV files in the output directory, found " + count, NUMBER_OF_FILES, count);
}
Also used : GeneratorOptions(org.mitre.synthea.engine.Generator.GeneratorOptions) File(java.io.File) Location(org.mitre.synthea.world.geography.Location) ExporterRuntimeOptions(org.mitre.synthea.export.Exporter.ExporterRuntimeOptions) Generator(org.mitre.synthea.engine.Generator) Test(org.junit.Test)

Aggregations

File (java.io.File)3 Test (org.junit.Test)3 Generator (org.mitre.synthea.engine.Generator)3 GeneratorOptions (org.mitre.synthea.engine.Generator.GeneratorOptions)3 ExporterRuntimeOptions (org.mitre.synthea.export.Exporter.ExporterRuntimeOptions)3 Location (org.mitre.synthea.world.geography.Location)3