Search in sources :

Example 11 with Location

use of org.mitre.synthea.world.geography.Location in project synthea by synthetichealth.

the class PayerFinderTest method noPayersRandom.

@Test
public void noPayersRandom() {
    Config.set("generate.payers.selection_behavior", "random");
    Payer.clear();
    Payer.loadPayers(new Location((String) person.attributes.get(Person.STATE), null));
    PayerFinderRandom finder = new PayerFinderRandom();
    List<Payer> options = new ArrayList<Payer>();
    Payer payer = finder.find(options, person, null, 0L);
    assertNotNull(payer);
    assertEquals("NO_INSURANCE", payer.getName());
}
Also used : Payer(org.mitre.synthea.world.agents.Payer) ArrayList(java.util.ArrayList) Location(org.mitre.synthea.world.geography.Location) Test(org.junit.Test)

Example 12 with Location

use of org.mitre.synthea.world.geography.Location in project synthea by synthetichealth.

the class LossOfCareHealthRecordTest method setup.

/**
 * Setup for HealthRecord Tests.
 */
@Before
public void setup() throws Exception {
    // Clear any Payers that may have already been statically loaded.
    Payer.clear();
    TestHelper.loadTestProperties();
    String testState = Config.get("test_state.default", "Massachusetts");
    Config.set("generate.payers.insurance_companies.default_file", "generic/payers/test_payers.csv");
    Config.set("generate.payers.loss_of_care", "true");
    Config.set("lifecycle.death_by_loss_of_care", "true");
    // Load in the .csv list of Payers for MA.
    Payer.loadPayers(new Location(testState, null));
    // Load test payers.
    testPrivatePayer = Payer.getPrivatePayers().get(0);
    // Parse out testPrivatePayer's Copay.
    Person person = new Person(0L);
    person.setProvider(EncounterType.WELLNESS, new Provider());
    person.attributes.put(Person.INCOME, 1);
    Encounter encounter = person.encounterStart(time, EncounterType.WELLNESS);
    testPrivatePayerCopay = testPrivatePayer.determineCopay(encounter);
    // Utilities.convertCalendarYearsToTime(1900);
    time = 0L;
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Person(org.mitre.synthea.world.agents.Person) Location(org.mitre.synthea.world.geography.Location) Provider(org.mitre.synthea.world.agents.Provider) Before(org.junit.Before)

Example 13 with Location

use of org.mitre.synthea.world.geography.Location in project synthea by synthetichealth.

the class CPCDSExporterTest method testCPCDSExport.

@Test
public void testCPCDSExport() throws Exception {
    TestHelper.exportOff();
    TestHelper.loadTestProperties();
    Generator.DEFAULT_STATE = Config.get("test_state.default", "Massachusetts");
    Config.set("exporter.cpcds.export", "true");
    Config.set("exporter.csv.folder_per_run", "false");
    File tempOutputFolder = tempFolder.newFolder();
    Config.set("exporter.baseDirectory", tempOutputFolder.toString());
    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;
    Generator generator = new Generator(numberOfPeople);
    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);
    // if we get here we at least had no exceptions
    File expectedExportFolder = tempOutputFolder.toPath().resolve("cpcds").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 CPCDS 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 5 CSV files in the output directory, found " + count, 5, count);
}
Also used : File(java.io.File) Location(org.mitre.synthea.world.geography.Location) Generator(org.mitre.synthea.engine.Generator) Test(org.junit.Test)

Example 14 with Location

use of org.mitre.synthea.world.geography.Location 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)

Example 15 with Location

use of org.mitre.synthea.world.geography.Location 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)

Aggregations

Location (org.mitre.synthea.world.geography.Location)30 Test (org.junit.Test)17 File (java.io.File)9 Person (org.mitre.synthea.world.agents.Person)9 Before (org.junit.Before)6 Payer (org.mitre.synthea.world.agents.Payer)5 FileReader (java.io.FileReader)4 Generator (org.mitre.synthea.engine.Generator)4 DefaultRandomNumberGenerator (org.mitre.synthea.helpers.DefaultRandomNumberGenerator)4 FixedRecord (org.mitre.synthea.input.FixedRecord)4 FixedRecordGroup (org.mitre.synthea.input.FixedRecordGroup)4 FhirContext (ca.uhn.fhir.context.FhirContext)3 FhirValidator (ca.uhn.fhir.validation.FhirValidator)3 SingleValidationMessage (ca.uhn.fhir.validation.SingleValidationMessage)3 ValidationResult (ca.uhn.fhir.validation.ValidationResult)3 BufferedReader (java.io.BufferedReader)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 BeforeClass (org.junit.BeforeClass)3 GeneratorOptions (org.mitre.synthea.engine.Generator.GeneratorOptions)3