Search in sources :

Example 96 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class CardiovascularDiseaseModule method endEmergency.

private static void endEmergency(Person person, long time) {
    if (person.attributes.containsKey(CVD_ENCOUNTER)) {
        Encounter encounter = (Encounter) person.attributes.get(CVD_ENCOUNTER);
        EncounterType type = EncounterType.fromString(encounter.type);
        if (type == EncounterType.EMERGENCY) {
            person.record.encounterEnd(time, type);
        }
        person.attributes.remove(CVD_ENCOUNTER);
    }
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType)

Example 97 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class DeathModule method process.

// NOTE: if new codes are added, be sure to update getAllCodes below
/**
 * Process the death of a person at a given time.
 * @param person - the person who has died.
 * @param time - the time of the death exam and certification.
 */
public static void process(Person person, long time) {
    if (!person.alive(time) && person.attributes.containsKey(Person.CAUSE_OF_DEATH)) {
        // create an encounter, diagnostic report, and observation
        Code causeOfDeath = (Code) person.attributes.get(Person.CAUSE_OF_DEATH);
        Encounter encounter = EncounterModule.createEncounter(person, time, EncounterType.WELLNESS, ClinicianSpecialty.GENERAL_PRACTICE, DEATH_CERTIFICATION);
        encounter.reason = causeOfDeath;
        Observation codObs = person.record.observation(time, CAUSE_OF_DEATH_CODE.code, causeOfDeath);
        codObs.codes.add(CAUSE_OF_DEATH_CODE);
        codObs.category = "exam";
        Report deathCert = person.record.report(time, DEATH_CERTIFICATE.code, 1);
        deathCert.codes.add(DEATH_CERTIFICATE);
    }
}
Also used : Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code)

Example 98 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class EncounterModule method createEncounter.

/**
 * Create an Encounter that is coded, with a provider organzation, and a clinician.
 * @param person The patient.
 * @param time The time of the encounter.
 * @param type The type of encounter (e.g. emergency).
 * @param specialty The clinician specialty (e.g. "General Practice")
 * @param code The code to assign to the encounter.
 * @return The encounter.
 */
public static Encounter createEncounter(Person person, long time, EncounterType type, String specialty, Code code) {
    // what year is it?
    int year = Utilities.getYear(time);
    // create the encounter
    Encounter encounter = person.encounterStart(time, type);
    if (code != null) {
        encounter.codes.add(code);
    }
    // assign a provider organization
    Provider prov = person.getProvider(type, time);
    prov.incrementEncounters(type, year);
    encounter.provider = prov;
    // assign a clinician
    encounter.clinician = prov.chooseClinicianList(specialty, person);
    return encounter;
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Provider(org.mitre.synthea.world.agents.Provider)

Example 99 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class QualityOfLifeModule method calculate.

/**
 * Calculate the HALYs for this person, at the given time. HALYs include QALY
 * and DALY.
 *
 * @param person Person to calculate
 * @param stop   current timestamp
 * @return array of [daly (cumulative), qaly (cumulative), current disability
 *         weight]
 */
public static double[] calculate(Person person, long stop) {
    // Disability-Adjusted Life Year = DALY = YLL + YLD
    // Years of Life Lost = YLL = (1) * (standard life expectancy at age of death in
    // years)
    // Years Lost due to Disability = YLD = (disability weight) * (average duration
    // of case)
    // from http://www.who.int/healthinfo/global_burden_disease/metrics_daly/en/
    double yll = 0.0;
    double yld = 0.0;
    int age = person.ageInYears(stop);
    long birthdate = (long) person.attributes.get(Person.BIRTHDATE);
    if (!person.alive(stop)) {
        // life expectancy equation derived from IHME GBD 2015 Reference Life Table
        // 6E-5x^3 - 0.0054x^2 - 0.8502x + 86.16
        // R^2 = 0.99978
        double l = ((0.00006 * Math.pow(age, 3)) - (0.0054 * Math.pow(age, 2)) - (0.8502 * age) + 86.16);
        yll = l;
    }
    // Get counts of covered healthcare.
    List<Entry> allConditions = new ArrayList<Entry>();
    int coveredMedicationCount = 0;
    int coveredProcedureCount = 0;
    int coveredImmunizationCount = 0;
    int coveredEncounterCount = 0;
    for (Encounter encounter : person.defaultRecord.encounters) {
        for (Entry condition : encounter.conditions) {
            allConditions.add(condition);
        }
        coveredMedicationCount += encounter.medications.size();
        coveredProcedureCount += encounter.procedures.size();
        coveredImmunizationCount += encounter.immunizations.size();
        coveredEncounterCount++;
    }
    int coveredEntries = coveredEncounterCount + coveredMedicationCount + coveredProcedureCount + coveredImmunizationCount;
    // Get counts of uncovered healthcare.
    int uncoveredEntries;
    if (person.lossOfCareEnabled) {
        List<Entry> allLossOfCareConditions = new ArrayList<Entry>();
        int uncoveredMedicationCount = 0;
        int uncoveredProcedureCount = 0;
        int uncoveredImmunizationCount = 0;
        int uncoveredEncounterCount = 0;
        for (Encounter encounter : person.lossOfCareRecord.encounters) {
            for (Entry condition : encounter.conditions) {
                allLossOfCareConditions.add(condition);
            }
            uncoveredMedicationCount += encounter.medications.size();
            uncoveredProcedureCount += encounter.procedures.size();
            uncoveredImmunizationCount += encounter.immunizations.size();
            uncoveredEncounterCount++;
        }
        uncoveredEntries = uncoveredEncounterCount + uncoveredMedicationCount + uncoveredProcedureCount + uncoveredImmunizationCount;
        allConditions.addAll(allLossOfCareConditions);
    } else {
        uncoveredEntries = 0;
    }
    // NOTE: This percentageOfCoveredCare is based on entire life, not just current year.
    if (coveredEntries < 1) {
        coveredEntries = 1;
    }
    double percentageOfCoveredCare = coveredEntries / (coveredEntries + uncoveredEntries);
    double disabilityWeight = 0.0;
    // calculate yld with yearly timestep
    for (int i = 0; i < age + 1; i++) {
        long yearStart = birthdate + TimeUnit.DAYS.toMillis((long) (365.25 * i));
        long yearEnd = birthdate + (TimeUnit.DAYS.toMillis((long) (365.25 * (i + 1) - 1)));
        List<Entry> conditionsInYear = conditionsInYear(allConditions, yearStart, yearEnd);
        disabilityWeight = 0.0;
        for (Entry condition : conditionsInYear) {
            // Get the disability weight for this condition based on the percentageOfCoveredCare.
            disabilityWeight += (double) disabilityWeights.get(condition.codes.get(0).code).getWeight(percentageOfCoveredCare);
        }
        disabilityWeight = Math.min(1.0, weight(disabilityWeight, i + 1));
        yld += disabilityWeight;
    }
    double daly = yll + yld;
    double qaly = age - yld;
    return new double[] { daly, qaly, 1 - disabilityWeight };
}
Also used : Entry(org.mitre.synthea.world.concepts.HealthRecord.Entry) ArrayList(java.util.ArrayList) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter)

Aggregations

Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)99 Test (org.junit.Test)54 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)51 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)29 Person (org.mitre.synthea.world.agents.Person)28 ProviderTest (org.mitre.synthea.world.agents.ProviderTest)22 DeathModule (org.mitre.synthea.modules.DeathModule)17 QualityOfLifeModule (org.mitre.synthea.modules.QualityOfLifeModule)17 ArrayList (java.util.ArrayList)16 CardiovascularDiseaseModule (org.mitre.synthea.modules.CardiovascularDiseaseModule)16 EncounterModule (org.mitre.synthea.modules.EncounterModule)16 LifecycleModule (org.mitre.synthea.modules.LifecycleModule)16 WeightLossModule (org.mitre.synthea.modules.WeightLossModule)16 Provider (org.mitre.synthea.world.agents.Provider)16 Medication (org.mitre.synthea.world.concepts.HealthRecord.Medication)16 Observation (org.mitre.synthea.world.concepts.HealthRecord.Observation)16 Procedure (org.mitre.synthea.world.concepts.HealthRecord.Procedure)16 Report (org.mitre.synthea.world.concepts.HealthRecord.Report)14 Date (java.util.Date)13 Claim (org.mitre.synthea.world.concepts.Claim)12