Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #4
0
    try:
        date_is_old(reccord_date)
    except ValueError, e:
        message.respond(u"[ERREUR] %s" % e)
        return True

    MonthPeriod.find_create_from(year=reccord_date.year,
                                 month=reccord_date.month)

    # expected delivery date
    try:
        expected_delivery_date, _expected_delivery_date = \
                                parse_age_dob(expected_delivery_date)
    except:
        return resp_error_dob(message)

    # delivery date
    try:
        delivery_date, _delivery_date = parse_age_dob(delivery_date)
    except:
        delivery_date = None

    contact = contact_for(message.identity)
    pregnancy_age = conv_str_int(pregnancy_age)
    pregnancy_result = conv_str_int(pregnancy_result)

    report = PregnancyReport()

    report.reporting_location = entity