Exemplo n.º 1
0
class __AffectedUnmodeledCauses(NamedTuple):
    # Keys that will be loaded into the artifact. must have a colon type declaration
    URI_CSMR: TargetString = TargetString(
        'cause.upper_respiratory_infections.cause_specific_mortality_rate')
    OTITIS_MEDIA_CSMR: TargetString = TargetString(
        'cause.otitis_media.cause_specific_mortality_rate')
    MENINGITIS_CSMR: TargetString = TargetString(
        'cause.meningitis.cause_specific_mortality_rate')
    ENCEPHALITIS_CSMR: TargetString = TargetString(
        'cause.encephalitis.cause_specific_mortality_rate')
    NEONATAL_PRETERM_BIRTH_CSMR: TargetString = TargetString(
        'cause.neonatal_preterm_birth.cause_specific_mortality_rate')
    NEONATAL_ENCEPHALOPATHY_CSMR: TargetString = TargetString(
        'cause.neonatal_encephalopathy_due_to_birth_asphyxia_and_trauma.cause_specific_mortality_rate'
    )
    NEONATAL_SEPSIS_CSMR: TargetString = TargetString(
        'cause.neonatal_sepsis_and_other_neonatal_infections.cause_specific_mortality_rate'
    )
    NEONATAL_JAUNDICE_CSMR: TargetString = TargetString(
        'cause.hemolytic_disease_and_other_neonatal_jaundice.cause_specific_mortality_rate'
    )
    OTHER_NEONATAL_DISORDERS_CSMR: TargetString = TargetString(
        'cause.other_neonatal_disorders.cause_specific_mortality_rate')
    SIDS_CSMR: TargetString = TargetString(
        'cause.sudden_infant_death_syndrome.cause_specific_mortality_rate')

    # Useful keys not for the artifact - distinguished by not using the colon type declaration

    @property
    def name(self):
        return 'affected_unmodeled_causes'

    @property
    def log_name(self):
        return 'affected unmodeled causes'
Exemplo n.º 2
0
class __SomeDisease(NamedTuple):

    # Keys that will be loaded into the artifact. must have a colon type declaration
    SOME_DISEASE_PREVALENCE: TargetString = TargetString(
        'cause.some_disease.prevalence')
    SOME_DISEASE_INCIDENCE_RATE: TargetString = TargetString(
        'cause.some_disease.incidence_rate')
    SOME_DISEASE_REMISSION_RATE: TargetString = TargetString(
        'cause.some_disease.remission_rate')
    DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.some_disease.disability_weight')
    EMR: TargetString = TargetString(
        'cause.some_disease.excess_mortality_rate')
    CSMR: TargetString = TargetString(
        'cause.some_disease.cause_specific_mortality_rate')
    RESTRICTIONS: TargetString = TargetString(
        'cause.some_disease.restrictions')

    # Useful keys not for the artifact - distinguished by not using the colon type declaration
    RAW_DISEASE_PREVALENCE = TargetString('sequela.raw_disease.prevalence')
    RAW_DISEASE_INCIDENCE_RATE = TargetString(
        'sequela.raw_disease.incidence_rate')

    @property
    def name(self):
        return 'some_disease'

    @property
    def log_name(self):
        return 'some disease'
Exemplo n.º 3
0
def _get_additive_risk_keys(treatment_type: str) -> __AdditiveRisk:
    return __AdditiveRisk(
        EXPOSURE=TargetString(f'risk_factor.{treatment_type}.exposure'),
        DISTRIBUTION=TargetString(
            f'risk_factor.{treatment_type}.distribution'),
        CATEGORIES=TargetString(f'risk_factor.{treatment_type}.categories'),
        EXCESS_SHIFT=TargetString(
            f'risk_factor.{treatment_type}.excess_shift'),
        RISK_SPECIFIC_SHIFT=TargetString(
            f'risk_factor.{treatment_type}.risk_specific_shift'),
    )
Exemplo n.º 4
0
def _get_wasting_treatment_keys(treatment_type: str) -> __WastingTreatment:
    return __WastingTreatment(
        EXPOSURE=TargetString(f'risk_factor.{treatment_type}.exposure'),
        DISTRIBUTION=TargetString(
            f'risk_factor.{treatment_type}.distribution'),
        CATEGORIES=TargetString(f'risk_factor.{treatment_type}.categories'),
        RELATIVE_RISK=TargetString(
            f'risk_factor.{treatment_type}.relative_risk'),
        PAF=TargetString(
            f'risk_factor.{treatment_type}.population_attributable_fraction'),
    )
Exemplo n.º 5
0
class __LowerRespiratoryInfections(NamedTuple):

    # Keys that will be loaded into the artifact. must have a colon type declaration
    DURATION: TargetString = TargetString(
        'cause.lower_respiratory_infections.duration')
    PREVALENCE: TargetString = TargetString(
        'cause.lower_respiratory_infections.prevalence')
    INCIDENCE_RATE: TargetString = TargetString(
        'cause.lower_respiratory_infections.incidence_rate')
    REMISSION_RATE: TargetString = TargetString(
        'cause.lower_respiratory_infections.remission_rate')
    DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.lower_respiratory_infections.disability_weight')
    EMR: TargetString = TargetString(
        'cause.lower_respiratory_infections.excess_mortality_rate')
    CSMR: TargetString = TargetString(
        'cause.lower_respiratory_infections.cause_specific_mortality_rate')
    RESTRICTIONS: TargetString = TargetString(
        'cause.lower_respiratory_infections.restrictions')

    # Useful keys not for the artifact - distinguished by not using the colon type declaration

    @property
    def name(self):
        return 'lower_respiratory_infections'

    @property
    def log_name(self):
        return 'lower respiratory infections'
 def __init__(self, intervention_name: str, target: str):
     self.intervention_name = intervention_name
     self.target = TargetString(target)
     self.configuration_defaults = {"interventions": {
         f"{self.intervention_name}_intervention": {
             f'effect_on_{self.target.name}':
                 InterventionEffect.configuration_defaults['interventions']['specific_intervention']['effect']}}}
Exemplo n.º 7
0
 def load_relative_risk_data(self, builder):
     if self.target.measure == 'incidence_rate':
         return super().load_relative_risk_data(builder)
     elif self.target.measure == 'relapse_rate':
         hacked_target = TargetString(
             f'{self.target.type}.{self.target.name}.incidence_rate')
         return get_relative_risk_data(builder, self.risk, hacked_target,
                                       self.randomness)
Exemplo n.º 8
0
 def __init__(self, target: str):
     """
     Parameters
     ----------
     target :
         Type, name, and target rate of entity to be affected by risk factor,
         supplied in the form "entity_type.entity_name.measure"
         where entity_type should be singular (e.g., cause instead of causes).
     """
     self.risk = EntityString(
         f'risk_factor.low_birth_weight_and_short_gestation')
     self.target = TargetString(target)
Exemplo n.º 9
0
class __ProteinEnergyMalnutrition(NamedTuple):

    # Keys that will be loaded into the artifact. must have a colon type declaration
    MAM_DISABILITY_WEIGHT: TargetString = TargetString(
        'sequela.moderate_acute_malnutrition.disability_weight')
    SAM_DISABILITY_WEIGHT: TargetString = TargetString(
        'sequela.severe_acute_malnutrition.disability_weight')
    EMR: TargetString = TargetString(
        'cause.protein_energy_malnutrition.excess_mortality_rate')
    CSMR: TargetString = TargetString(
        'cause.protein_energy_malnutrition.cause_specific_mortality_rate')
    RESTRICTIONS: TargetString = TargetString(
        'cause.protein_energy_malnutrition.restrictions')

    # Useful keys not for the artifact - distinguished by not using the colon type declaration

    @property
    def name(self):
        return 'protein_energy_malnutrition'

    @property
    def log_name(self):
        return 'protein energy malnutrition'
 def __init__(self, target: str):
     """
     Parameters
     ----------
     target :
         Type, name, and target rate of entity to be affected by risk factor,
         supplied in the form "entity_type.entity_name.measure"
         where entity_type should be singular (e.g., cause instead of causes).
     """
     self.risk = EntityString(
         'risk_factor.low_birth_weight_and_short_gestation')
     self.target = TargetString(target)
     self.configuration_defaults = {
         f'effect_of_{self.risk.name}_on_{self.target.name}': {
             self.target.measure:
             RiskEffect.configuration_defaults['effect_of_risk_on_target']
             ['measure']
         }
     }
Exemplo n.º 11
0
 def __init__(self, risk: str, target: str):
     """
     Parameters
     ----------
     risk :
         Type and name of risk factor, supplied in the form
         "risk_type.risk_name" where risk_type should be singular (e.g.,
         risk_factor instead of risk_factors).
     target :
         Type, name, and target rate of entity to be affected by risk factor,
         supplied in the form "entity_type.entity_name.measure"
         where entity_type should be singular (e.g., cause instead of causes).
     """
     self.risk = EntityString(risk)
     self.target = TargetString(target)
     self.configuration_defaults = {
         f'effect_of_{self.risk.name}_on_{self.target.name}': {
             self.target.measure: RiskEffect.configuration_defaults['effect_of_risk_on_target']['measure']
         }
     }
Exemplo n.º 12
0
    def setup(self, builder: 'Builder'):
        self.randomness_key = self.get_randomness_key(builder)
        self.randomness = builder.randomness.get_stream(self.name)
        self.correlation = self.load_correlation_data(builder)
        columns_created = project_globals.CORRELATED_PROPENSITY_COLUMNS
        self.population_view = builder.population.get_view(columns_created + ['age'])
        builder.population.initializes_simulants(self.on_initialize_simulants,
                                                 creates_columns=columns_created,
                                                 requires_columns=['age'],
                                                 requires_streams=[self.name])

        for target, rate in project_globals.RATE_TARGET_MAP.items():
            population_attributable_fraction_data = self.load_population_attributable_fraction_data(builder, rate)
            population_attributable_fraction = builder.lookup.build_table(population_attributable_fraction_data,
                                                                          key_columns=['sex'],
                                                                          parameter_columns=['age', 'year'])
            target = TargetString(target)
            builder.value.register_value_modifier(f'{target.name}.{target.measure}.paf',
                                                  modifier=population_attributable_fraction,
                                                  requires_columns=['age', 'sex'])
Exemplo n.º 13
0
class __LowBirthWeightShortGestation(NamedTuple):
    # Keys that will be loaded into the artifact. must have a colon type declaration
    EXPOSURE: TargetString = 'risk_factor.low_birth_weight_and_short_gestation.exposure'
    DISTRIBUTION: TargetString = 'risk_factor.low_birth_weight_and_short_gestation.distribution'
    CATEGORIES: TargetString = 'risk_factor.low_birth_weight_and_short_gestation.categories'
    RELATIVE_RISK: TargetString = 'risk_factor.low_birth_weight_and_short_gestation.relative_risk'
    RELATIVE_RISK_INTERPOLATOR: TargetString = 'risk_factor.low_birth_weight_and_short_gestation.relative_risk_interpolator'

    PAF: TargetString = 'risk_factor.low_birth_weight_and_short_gestation.population_attributable_fraction'

    # Useful keys not for the artifact - distinguished by not using the colon type declaration
    BIRTH_WEIGHT_EXPOSURE = TargetString(
        'risk_factor.low_birth_weight.birth_exposure')

    @property
    def name(self):
        return 'low_birth_weight_and_short_gestation'

    @property
    def log_name(self):
        return 'low birth weight and short gestation'
Exemplo n.º 14
0
class __Measles(NamedTuple):

    # Keys that will be loaded into the artifact. must have a colon type declaration
    PREVALENCE: TargetString = TargetString('cause.measles.prevalence')
    INCIDENCE_RATE: TargetString = TargetString('cause.measles.incidence_rate')
    DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.measles.disability_weight')
    EMR: TargetString = TargetString('cause.measles.excess_mortality_rate')
    CSMR: TargetString = TargetString(
        'cause.measles.cause_specific_mortality_rate')
    RESTRICTIONS: TargetString = TargetString('cause.measles.restrictions')

    # Useful keys not for the artifact - distinguished by not using the colon type declaration

    @property
    def name(self):
        return 'measles'

    @property
    def log_name(self):
        return 'measles'
Exemplo n.º 15
0
 def __init__(self, target):
     self.target = TargetString(target)
     self.configuration_defaults = {
         f'intervention_on_{self.target.name}':
         AbsoluteShift.configuration_defaults['intervention']
     }
Exemplo n.º 16
0
def test_TargetString_pass(s):
    target_type, target_name, target_measure = s.split('.')
    t = TargetString(s)
    assert t.type == target_type
    assert t.name == target_name
    assert t.measure == target_measure
Exemplo n.º 17
0
    @property
    def disability_weights(self):
        return [
            self.CAT_1_DISABILITY_WEIGHT,
            self.CAT_2_DISABILITY_WEIGHT,
            self.CAT_3_DISABILITY_WEIGHT,
            self.CAT_4_DISABILITY_WEIGHT,
        ]


IKF = __ImpairedKidneyFunction()

RATE_TARGET_MAP = {
    'sequela.acute_myocardial_infarction.incidence_rate':
    TargetString(IHD.ACUTE_MI_INCIDENCE_RATE),
    'sequela.post_myocardial_infarction_to_acute_myocardial_infarction.transition_rate':
    TargetString(IHD.ACUTE_MI_INCIDENCE_RATE),
    'sequela.acute_ischemic_stroke.incidence_rate':
    TargetString(ISCHEMIC_STROKE.ACUTE_STROKE_INCIDENCE_RATE),
    'sequela.post_ischemic_stroke_to_acute_ischemic_stroke.transition_rate':
    TargetString(ISCHEMIC_STROKE.ACUTE_STROKE_INCIDENCE_RATE),
}

MAKE_ARTIFACT_KEY_GROUPS = [
    POPULATION,
    IHD,
    ISCHEMIC_STROKE,
    DIABETES_MELLITUS,
    LDL_C,
    SBP,
Exemplo n.º 18
0
class __MultipleMyeloma(NamedTuple):

    # Keys that will be loaded into the artifact. must have a colon type declaration
    PREVALENCE: TargetString = TargetString(
        'cause.multiple_myeloma.prevalence')
    INCIDENCE_RATE: TargetString = TargetString(
        'cause.multiple_myeloma.incidence_rate')
    DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.multiple_myeloma.disability_weight')
    CSMR: TargetString = TargetString(
        'cause.multiple_myeloma.cause_specific_mortality_rate')
    RESTRICTIONS: TargetString = TargetString(
        'cause.multiple_myeloma.restrictions')

    LINE_1_PREVALENCE: TargetString = TargetString(
        'cause.multiple_myeloma_1.prevalence')
    LINE_1_DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.multiple_myeloma_1.disability_weight')
    LINE_1_EMR: TargetString = TargetString(
        'cause.multiple_myeloma_1.excess_mortality_rate')

    LINE_2_PREVALENCE: TargetString = TargetString(
        'cause.multiple_myeloma_2.prevalence')
    LINE_2_DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.multiple_myeloma_2.disability_weight')
    LINE_2_EMR: TargetString = TargetString(
        'cause.multiple_myeloma_2.excess_mortality_rate')

    LINE_3_PREVALENCE: TargetString = TargetString(
        'cause.multiple_myeloma_3.prevalence')
    LINE_3_DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.multiple_myeloma_3.disability_weight')
    LINE_3_EMR: TargetString = TargetString(
        'cause.multiple_myeloma_3.excess_mortality_rate')

    LINE_4_PREVALENCE: TargetString = TargetString(
        'cause.multiple_myeloma_4.prevalence')
    LINE_4_DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.multiple_myeloma_4.disability_weight')
    LINE_4_EMR: TargetString = TargetString(
        'cause.multiple_myeloma_4.excess_mortality_rate')

    LINE_5_PREVALENCE: TargetString = TargetString(
        'cause.multiple_myeloma_5.prevalence')
    LINE_5_DISABILITY_WEIGHT: TargetString = TargetString(
        'cause.multiple_myeloma_5.disability_weight')
    LINE_5_EMR: TargetString = TargetString(
        'cause.multiple_myeloma_5.excess_mortality_rate')

    GBD_CSMR: TargetString = TargetString(
        'cause.multiple_myeloma_gbd.cause_specific_mortality_rate')
    SUSCEPTIBLE_EMR: TargetString = TargetString(
        'cause.susceptible_to_multiple_myeloma.excess_mortality_rate')

    @property
    def name(self):
        return 'multiple_myeloma'

    @property
    def log_name(self):
        return 'multiple myeloma'
Exemplo n.º 19
0
def test_TargetString_fail(s):
    with pytest.raises(ValueError):
        TargetString(s)