示例#1
0
class WorldVisionChildFluff(fluff.IndicatorDocument):

    def case_property(property):
        return flat_field(lambda case: case.get_case_property(property))

    document_class = CommCareCase
    document_filter = CasePropertyFilter(type='ttc_child')
    deleted_types = WV_DELETED_TYPES

    domains = WORLD_VISION_DOMAINS
    group_by = ('domain', 'user_id')

    name = flat_field(lambda case: case.name)
    mother_id = flat_field(lambda case: case.indices[0]['referenced_id'] if case.indices else None)
    lvl_4 = flat_field(partial(referenced_case_attribute, field_name='phc'))
    lvl_3 = flat_field(partial(referenced_case_attribute, field_name='block'))
    lvl_2 = flat_field(partial(referenced_case_attribute, field_name='district'))
    lvl_1 = flat_field(partial(referenced_case_attribute, field_name='state'))

    reason_for_child_closure = case_property('reason_for_child_closure')
    bcg = case_property('bcg')
    opv0 = case_property('opv0')
    hepb0 = case_property('hepb0')
    opv1 = case_property('opv1')
    hepb1 = case_property('hepb1')
    dpt1 = case_property('dpt1')
    opv2 = case_property('opv2')
    hepb2 = case_property('hepb2')
    dpt2 = case_property('dpt2')
    opv3 = case_property('opv3')
    hepb3 = case_property('hepb3')
    dpt3 = case_property('dpt3')
    measles = case_property('measles')
    vita1 = case_property('vita1')
    vita2 = case_property('vita2')
    dpt_opv_booster = case_property('dpt_opv_booster')
    vita3 = case_property('vita3')
    type_of_child_death = case_property('type_of_child_death')
    cause_of_death_child = case_property('cause_of_death_child')
    pneumonia_since_last_visit = case_property('pneumonia_since_last_visit')
    has_diarrhea_since_last_visit = case_property('has_diarrhea_since_last_visit')
    dairrhea_treated_with_ors = case_property('dairrhea_treated_with_ors')
    dairrhea_treated_with_zinc = case_property('dairrhea_treated_with_zinc')
    weight_birth = flat_field(calculate_weight)
    breastfeed_1_hour = case_property('breastfeed_1_hour')
    exclusive_breastfeeding = case_property('exclusive_breastfeeding')
    comp_breastfeeding = case_property('comp_breastfeeding')
    supplementary_feeding_baby = case_property('supplementary_feeding_baby')
    deworm = case_property('deworm')
    ebf_stop_age_month = case_property('ebf_stop_age_month')
    gender = case_property('gender')

    opened_on = flat_field(lambda case: case.opened_on)
    closed_on = flat_field(lambda case: case.closed_on)
    dob = flat_field(lambda case: case.dob)
    date_of_death = case_property('child_date_of_death')
    month_of_death = flat_field(get_datepart)
    year_of_death = flat_field(partial(get_datepart, t='Y'))

    women_registered = user_calcs.ChildRegistered()
示例#2
0
class FarmerRecordFluff(fluff.IndicatorDocument):
    document_class = CommCareCase
    document_filter = CasePropertyFilter(type='farmer_record')
    domains = DOMAINS
    group_by = ('domain',
                fluff.AttributeGetter('value_chain', lambda c: get_mapping(c)),
                fluff.AttributeGetter('domains', lambda c: get_domains(c)),
                fluff.AttributeGetter('practices', lambda c: get_practices(c)))

    lvl_1 = case_property('lvl_1')
    lvl_2 = case_property('lvl_2')
    lvl_3 = case_property('lvl_3')
    lvl_4 = case_property('lvl_4')
    lvl_5 = case_property("lvl_5")
    case_status = flat_field(lambda c: c.get_case_property('case_status'))
    group_id = flat_field(lambda c: c.get_case_property('group_id'))
    group_name = flat_field(lambda c: c.get_case_property('group_name'))
    ppt_year = flat_field(lambda c: get_ppt_year(c))
    owner_id = flat_field(lambda c: c.get_case_property('owner_id'))
    gender = flat_field(lambda c: get_gender(c))
    group_leadership = flat_field(get_group_leadership)
    real_or_test = flat_field(lambda c: c.get_case_property('test_or_real'))
    schedule = flat_field(lambda c: (c.get_case_property(
        'farmer_social_category') or '').lower())
    group_case_id = flat_field(lambda c: c.get_case_property('group_case_id'))
    prop = Property()
示例#3
0
class FarmerRecordFluff(fluff.IndicatorDocument):
    document_class = CommCareCase
    document_filter = CasePropertyFilter(type='farmer_record')
    domains = (
        'pathways-india-mis',
        'pathways-tanzania',
    )
    group_by = ('domain',
                fluff.AttributeGetter('value_chain', lambda c: get_mapping(c)),
                fluff.AttributeGetter('domains', lambda c: get_domains(c)),
                fluff.AttributeGetter('practices', lambda c: get_practices(c)))

    save_direct_to_sql = True
    lvl_1 = case_property('lvl_1')
    lvl_2 = case_property('lvl_2')
    lvl_3 = case_property('lvl_3')
    lvl_4 = case_property('lvl_4')
    lvl_5 = case_property("lvl_5")
    case_status = flat_field(lambda c: c.get_case_property('case_status'))
    group_id = flat_field(lambda c: c.get_case_property('group_id'))
    group_name = flat_field(lambda c: c.get_case_property('group_name'))
    ppt_year = flat_field(lambda c: c.get_case_property('ppt_year'))
    owner_id = flat_field(lambda c: c.get_case_property('owner_id'))
    gender = flat_field(lambda c: get_gender(c))
    group_leadership = flat_field(
        lambda c: c.get_case_property('farmer_is_leader'))
    schedule = flat_field(lambda c: (c.get_case_property(
        'farmer_social_category') or '').lower())
    prop = Property()
示例#4
0
class WorldVisionMotherFluff(fluff.IndicatorDocument):
    def case_property(property):
        return flat_field(lambda case: case.get_case_property(property))

    document_class = CommCareCase
    document_filter = CasePropertyFilter(type='ttc_mother')
    deleted_types = WV_DELETED_TYPES

    domains = WORLD_VISION_DOMAINS
    group_by = ('domain', 'user_id')

    name = flat_field(lambda case: case.name)
    lvl_4 = case_property('phc')
    lvl_3 = case_property('block')
    lvl_2 = case_property('district')
    lvl_1 = case_property('state')
    reason_for_mother_closure = flat_field(
        lambda case: case.reason_for_mother_closure
        if hasattr(case, 'reason_for_mother_closure'
                   ) and case.reason_for_mother_closure else 'unknown')
    mother_state = case_property('mother_state')
    fp_method = case_property('fp_method')

    anc_1 = case_property('anc_1')
    anc_2 = case_property('anc_2')
    anc_3 = case_property('anc_3')
    anc_4 = case_property('anc_4')
    tt_1 = case_property('tt_1')
    tt_2 = case_property('tt_2')
    tt_booster = case_property('tt_booster')
    iron_folic = case_property('iron_folic')
    completed_100_ifa = case_property('completed_100_ifa')
    anemia_signs = case_property('anemia_signs')
    currently_referred = case_property('currently_referred')
    knows_closest_facility = case_property('knows_closest_facility')
    edd = case_property('edd')
    previous_tetanus = case_property('previous_tetanus')
    pp_1_done = case_property('pp_1_done')
    pp_2_done = case_property('pp_2_done')
    pp_3_done = case_property('pp_3_done')
    pp_4_done = case_property('pp_4_done')
    delivery_date = case_property('delivery_date')
    cause_of_death_maternal = case_property('cause_of_death_maternal')
    place_of_birth = case_property('place_of_birth')
    birth_attendant_during_delivery = case_property(
        'birth_attendant_during_delivery')
    type_of_delivery = case_property('type_of_delivery')
    date_of_mother_death = case_property('date_of_mother_death')

    number_of_children = user_calcs.NumberChildren()
    number_of_boys = user_calcs.NumberBoys()
    number_of_girls = user_calcs.NumberGirls()
    number_of_children_born_dead = user_calcs.StillBirth()

    opened_on = flat_field(lambda case: case.opened_on.date()
                           if case.opened_on else None)
    closed_on = flat_field(lambda case: case.closed_on.date()
                           if case.closed_on else None)

    women_registered = user_calcs.MotherRegistered()
示例#5
0
class VhndAvailabilityFluff(fluff.IndicatorDocument):

    document_class = CommCareCase
    domains = ('opm', )
    group_by = ('owner_id', )
    save_direct_to_sql = True
    document_filter = CasePropertyFilter(type='vhnd')

    vhnd = case_calcs.VhndAvailabilityCalc()
示例#6
0
class GeographyFluff(fluff.IndicatorDocument):
    document_class = CommCareCase
    document_filter = CasePropertyFilter(type='farmer_record')
    domains = DOMAINS
    group_by = ('domain', )

    numerator = Numerator()
    lvl_1 = case_property('lvl_1')
    lvl_2 = case_property('lvl_2')
    lvl_3 = case_property('lvl_3')
    lvl_4 = case_property('lvl_4')
    lvl_5 = case_property("lvl_5")
示例#7
0
class GeographyFluff(fluff.IndicatorDocument):
    document_class = CommCareCase
    document_filter = CasePropertyFilter(type='farmer_record')
    domains = (
        'pathways-india-mis',
        'pathways-tanzania',
    )
    group_by = ('domain', )

    save_direct_to_sql = True
    numerator = Numerator()
    lvl_1 = case_property('lvl_1')
    lvl_2 = case_property('lvl_2')
    lvl_3 = case_property('lvl_3')
    lvl_4 = case_property('lvl_4')
    lvl_5 = case_property("lvl_5")
示例#8
0
class RecouvrementFluff(fluff.IndicatorDocument):
    document_class = CommCareCase

    document_filter = ANDFilter([
        CasePropertyFilter(type='payment'),
        CustomFilter(lambda c: hasattr(c, 'district_name'))
    ])

    domains = INTRAHEALTH_DOMAINS
    deleted_types = IH_DELETED_CASE_TYPES
    group_by = ('domain', fluff.AttributeGetter('district_name',
                                                lambda case: case.get_case_property('district_name')))

    region_id = flat_field(lambda c: get_region_id(c))
    district_id = flat_field(lambda c: get_district_id(c))
    district_name = flat_field(lambda c: c['district_name'])

    payments = report_calcs.Recouvrement()