Search in sources :

Example 1 with TransitionMetrics

use of org.mitre.synthea.helpers.TransitionMetrics in project synthea by synthetichealth.

the class Generator method init.

private void init() {
    if (options.state == null) {
        options.state = DEFAULT_STATE;
    }
    int stateIndex = Location.getIndex(options.state);
    if (Config.getAsBoolean("exporter.cdw.export")) {
        CDWExporter.getInstance().setKeyStart((stateIndex * 1_000_000) + 1);
    }
    this.populationRandom = new DefaultRandomNumberGenerator(options.seed);
    this.clinicianRandom = new DefaultRandomNumberGenerator(options.clinicianSeed);
    this.timestep = Long.parseLong(Config.get("generate.timestep"));
    this.stop = options.endTime;
    this.referenceTime = options.referenceTime;
    this.location = new Location(options.state, options.city);
    this.logLevel = Config.get("generate.log_patients.detail", "simple");
    this.onlyDeadPatients = Config.getAsBoolean("generate.only_dead_patients");
    this.onlyAlivePatients = Config.getAsBoolean("generate.only_alive_patients");
    // If both values are set to true, then they are both set back to the default
    if (this.onlyDeadPatients && this.onlyAlivePatients) {
        Config.set("generate.only_dead_patients", "false");
        Config.set("generate.only_alive_patients", "false");
        this.onlyDeadPatients = false;
        this.onlyAlivePatients = false;
    }
    try {
        this.maxAttemptsToKeepPatient = Long.parseLong(Config.get("generate.max_attempts_to_keep_patient", "1000"));
        if (this.maxAttemptsToKeepPatient == 0) {
            // set it to null to make the check more clear
            this.maxAttemptsToKeepPatient = null;
        }
    } catch (Exception e) {
        this.maxAttemptsToKeepPatient = null;
    }
    this.onlyVeterans = Config.getAsBoolean("generate.veteran_population_override");
    this.totalGeneratedPopulation = new AtomicInteger(0);
    this.stats = Collections.synchronizedMap(new HashMap<String, AtomicInteger>());
    this.modulePredicate = getModulePredicate();
    stats.put("alive", new AtomicInteger(0));
    stats.put("dead", new AtomicInteger(0));
    if (Config.getAsBoolean("generate.track_detailed_transition_metrics", false)) {
        this.metrics = new TransitionMetrics();
    }
    // initialize hospitals
    Provider.loadProviders(location, this.clinicianRandom);
    // Initialize Payers
    Payer.loadPayers(location);
    // ensure modules load early
    if (options.localModuleDir != null) {
        Module.addModules(options.localModuleDir);
    }
    List<String> coreModuleNames = getModuleNames(Module.getModules(path -> false));
    List<String> moduleNames = getModuleNames(Module.getModules(modulePredicate));
    if (options.keepPatientsModulePath != null) {
        try {
            Path path = options.keepPatientsModulePath.toPath().toAbsolutePath();
            this.keepPatientsModule = Module.loadFile(path, false, null, true);
        } catch (Exception e) {
            throw new ExceptionInInitializerError(e);
        }
    }
    // ensure cost data loads early
    Costs.loadCostData();
    String locationName;
    if (options.city == null) {
        locationName = options.state;
    } else {
        locationName = options.city + ", " + options.state;
    }
    System.out.println("Running with options:");
    System.out.println(String.format("Population: %d\nSeed: %d\nProvider Seed:%d\nReference Time: %d\nLocation: %s", options.population, options.seed, options.clinicianSeed, options.referenceTime, locationName));
    System.out.println(String.format("Min Age: %d\nMax Age: %d", options.minAge, options.maxAge));
    if (options.gender != null) {
        System.out.println(String.format("Gender: %s", options.gender));
    }
    if (options.enabledModules != null) {
        moduleNames.removeAll(coreModuleNames);
        moduleNames.sort(String::compareToIgnoreCase);
        System.out.println("Modules: " + String.join("\n       & ", moduleNames));
        System.out.println(String.format("       > [%d loaded]", moduleNames.size()));
    }
    if (Config.getAsBoolean("growtherrors", false)) {
        HealthRecordEditors hrm = HealthRecordEditors.getInstance();
        hrm.registerEditor(new GrowthDataErrorsEditor());
    }
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) Location(org.mitre.synthea.world.geography.Location) ObjectInputStream(java.io.ObjectInputStream) Costs(org.mitre.synthea.world.concepts.Costs) StringUtils(org.apache.commons.lang3.StringUtils) Demographics(org.mitre.synthea.world.geography.Demographics) Person(org.mitre.synthea.world.agents.Person) VitalSign(org.mitre.synthea.world.concepts.VitalSign) TransitionMetrics(org.mitre.synthea.helpers.TransitionMetrics) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Gson(com.google.gson.Gson) Map(java.util.Map) Path(java.nio.file.Path) RandomNumberGenerator(org.mitre.synthea.helpers.RandomNumberGenerator) Predicate(java.util.function.Predicate) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) CDWExporter(org.mitre.synthea.export.CDWExporter) FileNotFoundException(java.io.FileNotFoundException) Executors(java.util.concurrent.Executors) Utilities(org.mitre.synthea.helpers.Utilities) HealthInsuranceModule(org.mitre.synthea.modules.HealthInsuranceModule) List(java.util.List) Type(java.lang.reflect.Type) LifecycleModule(org.mitre.synthea.modules.LifecycleModule) FilenameFilter(java.io.FilenameFilter) GrowthDataErrorsEditor(org.mitre.synthea.editors.GrowthDataErrorsEditor) IOCase(org.apache.commons.io.IOCase) DefaultRandomNumberGenerator(org.mitre.synthea.helpers.DefaultRandomNumberGenerator) HashMap(java.util.HashMap) FixedRecordGroup(org.mitre.synthea.input.FixedRecordGroup) ObjectOutputStream(java.io.ObjectOutputStream) LinkedList(java.util.LinkedList) ExecutorService(java.util.concurrent.ExecutorService) Config(org.mitre.synthea.helpers.Config) Iterator(java.util.Iterator) EncounterModule(org.mitre.synthea.modules.EncounterModule) FileOutputStream(java.io.FileOutputStream) FileInputStream(java.io.FileInputStream) Payer(org.mitre.synthea.world.agents.Payer) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) Provider(org.mitre.synthea.world.agents.Provider) Exporter(org.mitre.synthea.export.Exporter) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter) FileReader(java.io.FileReader) DeathModule(org.mitre.synthea.modules.DeathModule) Collections(java.util.Collections) FixedRecord(org.mitre.synthea.input.FixedRecord) Path(java.nio.file.Path) DefaultRandomNumberGenerator(org.mitre.synthea.helpers.DefaultRandomNumberGenerator) HashMap(java.util.HashMap) FileNotFoundException(java.io.FileNotFoundException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TransitionMetrics(org.mitre.synthea.helpers.TransitionMetrics) GrowthDataErrorsEditor(org.mitre.synthea.editors.GrowthDataErrorsEditor) Location(org.mitre.synthea.world.geography.Location)

Aggregations

Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 FileReader (java.io.FileReader)1 FilenameFilter (java.io.FilenameFilter)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Type (java.lang.reflect.Type)1 Path (java.nio.file.Path)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 ExecutorService (java.util.concurrent.ExecutorService)1