Exemplo n.º 1
0
def unfpa_dead_pregnant_woman(message, args, sub_cmd, **kwargs):
    """  Incomming:
            fnuap dpw profile reccord_date reporting_location_code
                      name age_or_dob dod_text death_location_code
                      living_children_text dead_children_text pregnant_text
                      pregnancy_weeks_text pregnancy_related_death_text
            exemple: 'fnuap dpw f 20120524 bana kona_diarra 20120524 20120524
                       bana 1 0 0 - 0 m'

         Outgoing:
            [SUCCES] Le rapport de deces name a ete enregistre.
            or [ERREUR] message """

    try:
        profile, reccord_date, reporting_location_code, name, age_or_dob, \
        dod_text, death_location_code, living_children_text, \
        dead_children_text, pregnant_text, pregnancy_weeks_text, \
        pregnancy_related_death_text, cause_of_death_text = args.split()
    except:
        return resp_error(message, u"le rapport")

    # Entity code
    try:
        reporting_location = Entity.objects.get(slug=reporting_location_code)
    except Entity.DoesNotExist:
        return resp_error_reporting_location(message, reporting_location_code)

    # DOB (YYYY-MM-DD) or age (11y/11m)
    try:
        dob, dob_auto = parse_age_dob(age_or_dob)
    except:
        return resp_error_dob(message)

    # reccord date
    try:
        reccord_date, _reccord_date = parse_age_dob(reccord_date)
    except:
        return resp_error_date(message)

    try:
        date_is_old(reccord_date)
    except ValueError, e:
        message.respond(u"[ERREUR] %s" % e)
        return True
Exemplo n.º 2
0
def unfpa_pregnancy(message, args, sub_cmd, **kwargs):
    """  Incomming:
            fnuap gpw profile reporting_location householder_name reccord_date
            mother_name dob pregnancy_age expected_delivery_date
            pregnancy_result delivery_date
        example:
           'fnuap gpw f wolo alou_dolo 20120109 fola_keita 45a 9 20110509 0
            20120109'
        Outgoing:
            [SUCCES] Le rapport de name a ete enregistre.
            or [ERREUR] message """

    try:
        profile, reporting_location, householder_name, reccord_date, \
        mother_name, dob, pregnancy_age, expected_delivery_date, \
        pregnancy_result, delivery_date = args.split()
    except:
        return resp_error(message, u"l'enregistrement de la grossesse.")

    # Entity code
    try:
        entity = Entity.objects.get(slug=reporting_location)
    except Entity.DoesNotExist:
        message.respond(u"Le code %s n'existe pas" % reporting_location)
        return True

    # DOB (YYYY-MM-DD) or age (11a/11m)
    try:
        dob, dob_auto = parse_age_dob(dob)
    except:
        return resp_error_dob(message)

    # reccord date
    try:
        reccord_date, _reccord_date = parse_age_dob(reccord_date)
    except:
        return resp_error_date(message)

    try:
        date_is_old(reccord_date)
    except ValueError, e:
        message.respond(u"[ERREUR] %s" % e)
        return True
Exemplo n.º 3
0
def unfpa_dead_children_under5(message, args, sub_cmd, **kwargs):
    """  Incomming:
            fnuap du5 profile reccord_date reporting_location_code name sex
            age_or_dob dod_text death_location_code place_death
         exemple: 'fnuap du5 f 20120502 wolo nom F 20100502 20120502 wolo D o'

         Outgoing:
            [SUCCES] Le rapport de deces name a ete enregistre.
            or [ERREUR] message """

    try:
        profile, reccord_date, reporting_location_code, name, sex, \
        age_or_dob, dod_text, death_location_code, \
        place_death, cause_of_death_text = args.split()
    except:
        return resp_error(message, u"l'enregistrement de rapport "
                                   u" des moins de 5ans")

    # Entity code
    try:
        reporting_location = Entity.objects.get(slug=reporting_location_code)
    except Entity.DoesNotExist:
        return resp_error_reporting_location(message, reporting_location_code)

    # DOB (YYYY-MM-DD) or age (11a/11m)
    try:
        dob, dob_auto = parse_age_dob(age_or_dob)
    except:
        return resp_error_dob(message)

    # reccord date
    try:
        reccord_date, _reccord_date = parse_age_dob(reccord_date)
    except:
        return resp_error_date(message)

    try:
        date_is_old(reccord_date)
    except ValueError, e:
        message.respond(u"[ERREUR] %s" % e)
        return True
Exemplo n.º 4
0
def unfpa_monthly_product_stockouts(message, args, sub_cmd, **kwargs):
    """  Incomming:
            fnuap mps family_planning delivery_services male_condom
            female_condom oral_pills injectable iud implants
            female_sterilization male_sterilization
            amoxicillin_ij amoxicillin_cap_gel
            amoxicillin_suspension azithromycine_tab
            azithromycine_suspension benzathine_penicillin cefexime
            clotrimazole ergometrine_tab ergometrine_vials iron
            folate iron_folate magnesium_sulfate metronidazole
            oxytocine ceftriaxone_500 ceftriaxone_1000 comment
        example:
           'fnuap mps 2012 05 wolo 0 0 20 - - - - - 0 0 - - - - - - - - - - - -
             - - - - - - -'
        Outgoing:
            [SUCCES] Le rapport de name a ete enregistre.
            or [ERREUR] message """

    try:
        # -1 represente le non disponible
        args = args.replace("-", "-1")
        reporting_year, reporting_month, location_of_sdp, family_planning, \
        delivery_services, male_condom, female_condom,\
        oral_pills, injectable, iud, implants, female_sterilization, \
        male_sterilization, amoxicillin_ij, amoxicillin_cap_gel, \
        amoxicillin_suspension, azithromycine_tab, azithromycine_suspension, \
        benzathine_penicillin, cefexime, clotrimazole, ergometrine_tab, \
        ergometrine_vials, iron, folate, iron_folate, magnesium_sulfate, \
        metronidazole, oxytocine, ceftriaxone_500, ceftriaxone_1000, \
        comment = args.split()
    except:
        return resp_error(message, u"le rapport")

    try:
        period = MonthPeriod.find_create_from(year=int(reporting_year),
                                              month=int(reporting_month))
    except:
        message.respond(u"La periode (%s %s) n'est pas valide" %
                        (reporting_month, reporting_year))
        return True

    if period != current_period().previous():
        message.respond(u"La periode (%s %s) n'est pas valide, "
                        u"elle doit etre %s" % (reporting_month,
                                                reporting_year,
                                                current_period().previous()))
        return True

    # Entity code
    try:
        entity = Entity.objects.get(slug=location_of_sdp)
    except Entity.DoesNotExist:
        message.respond(u"Le code %s n'existe pas" % location_of_sdp)
        return True

    def check_int(val):
        try:
            return int(val)
        except:
            return -1

    try:
        comment = comment.replace(u"_", u" ")
    except:
        comment = u""

    contact = contact_for(message.identity)

    report = RHCommoditiesReport()

    if contact:
        report.created_by = contact
    else:
        return resp_error_provider(message)

    report.type = 0
    report.period = period
    report.entity = entity
    report.family_planning = check_int(family_planning)
    report.delivery_services = check_int(delivery_services)
    report.male_condom = check_int(male_condom)
    report.female_condom = check_int(female_condom)
    report.oral_pills = check_int(oral_pills)
    report.injectable = check_int(injectable)
    report.iud = check_int(iud)
    report.implants = check_int(implants)
    report.female_sterilization = YESNOAVAIL.get(female_sterilization,
                                    RHCommoditiesReport.SUPPLIES_NOT_PROVIDED)
    report.male_sterilization = YESNOAVAIL.get(male_sterilization,
                                    RHCommoditiesReport.SUPPLIES_NOT_PROVIDED)
    report.amoxicillin_ij = check_int(amoxicillin_ij)
    report.amoxicillin_cap_gel = check_int(amoxicillin_cap_gel)
    report.amoxicillin_suspension = check_int(amoxicillin_suspension)
    report.azithromycine_tab = check_int(azithromycine_tab)
    report.azithromycine_suspension = check_int(azithromycine_suspension)
    report.benzathine_penicillin = check_int(benzathine_penicillin)
    report.cefexime = check_int(cefexime)
    report.clotrimazole = check_int(clotrimazole)
    report.ergometrine_tab = check_int(ergometrine_tab)
    report.ergometrine_vials = check_int(ergometrine_vials)
    report.iron = check_int(iron)
    report.folate = check_int(folate)
    report.iron_folate = check_int(iron_folate)
    report.magnesium_sulfate = check_int(magnesium_sulfate)
    report.metronidazole = check_int(metronidazole)
    report.oxytocine = check_int(oxytocine)

    report.ceftriaxone_500 = check_int(ceftriaxone_500)
    report.ceftriaxone_1000 = check_int(ceftriaxone_1000)
    report.comment = check_int(comment)
    report._status = report.STATUS_VALIDATED

    try:
        report.save()
        message.respond(u"[SUCCES] Le rapport de %(cscom)s pour %(period)s "
                        u"a ete enregistre. "
                        u"Le No de recu est #%(receipt)s."
                        % {'cscom': report.entity.display_full_name(),
                           'period': report.period,
                           'receipt': report.receipt})
    except IntegrityError:
        message.respond(u"[ERREUR] il ya deja un rapport pour cette periode")
    except:
        message.respond(u"[ERREUR] Le rapport n est pas enregiste")

    return True
Exemplo n.º 5
0
    try:
        dod = parse_age_dob(dod_text, True)
    except:
        return resp_error_dod(message)

    # Place of death, entity code
    try:
        death_location = Entity.objects.get(slug=death_location_code)
    except Entity.DoesNotExist:
        return resp_error_death_location(message, death_location_code)

    # Nb of living children
    try:
        living_children = int(living_children_text)
    except:
        return resp_error(message, u"le nombre d'enfants vivant du defunt")

    # Nb of dead children
    try:
        dead_children = int(dead_children_text)
    except:
        return resp_error(message, u"le nombre d'enfants morts de la"
                                   u" personne decedee")

    # was she pregnant (0/1)
    pregnant = bool(int(pregnant_text))

    # Nb of weeks of pregnancy (or 0)
    try:
        pregnancy_weeks = int(pregnancy_weeks_text)
    except: