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());
}
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;
}
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);
}
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);
}
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);
}
Aggregations