コード例 #1
0
ファイル: dead_persons.py プロジェクト: yeleman/unfpa2012
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
コード例 #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
コード例 #3
0
ファイル: dead_persons.py プロジェクト: yeleman/unfpa2012
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
コード例 #4
0
ファイル: dead_persons.py プロジェクト: yeleman/unfpa2012
        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

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

    # Date of Death, YYYY-MM-DD
    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")
コード例 #5
0
    except:
        return resp_error_date(message)

    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()