Exemple #1
0
class RecapPassageFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = ANDFilter([
        ORFilter(
            [FormPropertyFilter(xmlns=OPERATEUR_XMLNSES[0]), FormPropertyFilter(xmlns=OPERATEUR_XMLNSES[1])]
        ),
        ORFilter([
            IsExistFormPropertyFilter(xmlns=OPERATEUR_XMLNSES[0], property_path="form", property_value='PPS_name'),
            IsExistFormPropertyFilter(xmlns=OPERATEUR_XMLNSES[1], property_path="form", property_value='PPS_name')
        ])

    ])

    domains = INTRAHEALTH_DOMAINS
    deleted_types = IH_DELETED_TYPES
    group_by = (fluff.AttributeGetter('product_name', lambda f: get_products(f, 'product_name')),
                fluff.AttributeGetter('product_id', lambda f: get_products_id(f, 'product_name')))

    location_id = flat_field(get_location_id)
    region_id = flat_field(lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(lambda f: get_location_id_by_type(form=f, type='district'))
    real_date_repeat = flat_field(get_real_date)
    PPS_name = flat_field(lambda f: f.form['PPS_name'])

    product = report_calcs.RecapPassage()
Exemple #2
0
class IntraHealthFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = ANDFilter([
        FormPropertyFilter(xmlns=OPERATEUR_XMLNSES[0]),
        IsExistFormPropertyFilter(xmlns=OPERATEUR_XMLNSES[0],
                                  property_path="form",
                                  property_value='district_name'),
        IsExistFormPropertyFilter(xmlns=OPERATEUR_XMLNSES[0],
                                  property_path="form",
                                  property_value='PPS_name')
    ])
    domains = INTRAHEALTH_DOMAINS
    save_direct_to_sql = True
    group_by = (fluff.AttributeGetter(
        'product_name', lambda f: get_products(f, 'product_name')), )

    region_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type='district'))
    PPS_name = flat_field(lambda f: f.form['PPS_name'])
    district_name = flat_field(lambda f: f.form['district_name'])
    location_id = flat_field(get_location_id)

    actual_consumption = report_calcs.PPSConsumption()
    billed_consumption = report_calcs.PPSConsumption(
        field='billed_consumption')
    stock = report_calcs.PPSConsumption('old_stock_total')
    quantity = report_calcs.PPSConsumption('display_total_stock')
    cmm = report_calcs.PPSConsumption('default_consumption')
Exemple #3
0
class TauxDeRuptureFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = ANDFilter([
        FormPropertyFilter(xmlns=RAPTURE_XMLNSES[0]),
        IsExistFormPropertyFilter(xmlns=RAPTURE_XMLNSES[0],
                                  property_path="form",
                                  property_value='district')
    ])
    domains = INTRAHEALTH_DOMAINS
    deleted_types = IH_DELETED_TYPES
    save_direct_to_sql = True
    group_by = (fluff.AttributeGetter('product_name',
                                      lambda f: get_rupture_products(f)),
                fluff.AttributeGetter('product_code',
                                      lambda f: get_rupture_products_code(f)))

    region_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type='district'))
    district_name = flat_field(lambda f: f.form['district'])
    PPS_name = flat_field(
        lambda f: CommCareCase.get(f.form['case']['@case_id']).name)

    total_stock = report_calcs.RupturesDeStocks('pps_stocked_out')
Exemple #4
0
class TauxDeSatisfactionFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = ORFilter([
        FormPropertyFilter(xmlns=COMMANDE_XMLNSES[0]),
        FormPropertyFilter(xmlns=COMMANDE_XMLNSES[1]),
        FormPropertyFilter(xmlns=COMMANDE_XMLNSES[2])
    ])
    deleted_types = IH_DELETED_TYPES

    domains = INTRAHEALTH_DOMAINS
    group_by = (fluff.AttributeGetter('product_name', lambda f: get_products(f, 'productName')),
                fluff.AttributeGetter('product_id', lambda f: get_products_id(f, 'productName')))

    region_id = flat_field(lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(lambda f: get_location_id_by_type(form=f, type='district'))
    commandes = report_calcs.TauxCalculator(property_name='amountOrdered')
    recus = report_calcs.TauxCalculator(property_name='amountReceived')
Exemple #5
0
class TauxDeSatisfactionFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = ORFilter([
        FormPropertyFilter(xmlns=COMMANDE_XMLNSES[0]),
        FormPropertyFilter(xmlns=COMMANDE_XMLNSES[1])
    ])

    domains = INTRAHEALTH_DOMAINS
    group_by = (fluff.AttributeGetter(
        'product_name', lambda f: get_products(f, 'productName')), )
    save_direct_to_sql = True

    region_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type='district'))
    commandes = report_calcs.Commandes()
    recus = report_calcs.Recus()
Exemple #6
0
class CouvertureFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = ORFilter([
        FormPropertyFilter(xmlns=OPERATEUR_XMLNSES[0]),
        FormPropertyFilter(xmlns=OPERATEUR_XMLNSES[1]),
    ])

    domains = INTRAHEALTH_DOMAINS
    group_by = ('domain', fluff.AttributeGetter('location_id', get_location_id))
    deleted_types = IH_DELETED_TYPES

    location_id = flat_field(get_location_id)
    region_id = flat_field(lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(lambda f: get_location_id_by_type(form=f, type='district'))
    pps_name = flat_field(lambda f: get_pps_name(f))
    district_name = flat_field(lambda f: get_district_name(f))
    month = flat_field(lambda f: get_month(f, 'real_date'))
    real_date_repeat = flat_field(get_real_date)
    registered = report_calcs.PPSRegistered()
    planned = report_calcs.PPSPlaned()
Exemple #7
0
def _filtered_calc_alias(xmlns=None, property_path=None, property_value=None,
                         operator=xcalculators.EQUAL, indicator_calculator=None,
                         window=timedelta(days=1)):
    filter = FormPropertyFilter(xmlns=xmlns, property_path=property_path,
                                property_value=property_value,
                                operator=operator)

    return SimpleCalculator(
        date_provider=xcalculators.default_date,
        filter=filter,
        indicator_calculator=indicator_calculator,
        window=window
    )
Exemple #8
0
class LivraisonFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = FormPropertyFilter(xmlns=LIVRAISON_XMLNSES[0])

    domains = INTRAHEALTH_DOMAINS
    group_by = ('domain', )
    deleted_types = IH_DELETED_TYPES

    month = flat_field(lambda f: get_month(f, 'mois_visite'))
    duree_moyenne_livraison = report_calcs.DureeMoyenneLivraison()

    region_id = flat_field(lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(lambda f: CommCareCase.get(f.form['case']['@case_id']).location_id)
    district_name = flat_field(lambda f: CommCareCase.get(f.form['case']['@case_id']).name)
Exemple #9
0
class CouvertureFluff(fluff.IndicatorDocument):
    document_class = XFormInstance
    document_filter = FormPropertyFilter(xmlns=OPERATEUR_XMLNSES[0])

    domains = INTRAHEALTH_DOMAINS
    group_by = ('domain', fluff.AttributeGetter('location_id',
                                                get_location_id))
    save_direct_to_sql = True

    location_id = flat_field(get_location_id)
    region_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type=u'r\xe9gion'))
    district_id = flat_field(
        lambda f: get_location_id_by_type(form=f, type='district'))
    real_date_repeat = flat_field(get_real_date)
    registered = report_calcs.PPSRegistered()
    planned = report_calcs.PPSPlaned()
Exemple #10
0
def _get_all_forms():
    form_filters = []
    for xmlns in OPERATEUR_XMLNSES:
        form_filters.append(FormPropertyFilter(xmlns=xmlns))
    return form_filters
Exemple #11
0
def _get_all_m4change_forms():
    form_filters = []
    for xmlns in ALL_M4CHANGE_FORMS:
        form_filters.append(FormPropertyFilter(xmlns=xmlns))
    return form_filters