Example #1
0
def store_nutritional_statuses(request):

    if checkers.validate_fields(request) > 0:
        messages.error(request,
                       'Please fill up all fields or enter valid inputs only')
        return redirect('data-collection:encode-ns')

    current_user = global_user.get_user(request.user.username)
    barangay = current_user.barangay

    opt = OperationTimbang(barangay=barangay)
    opt.save()

    for key, value in request.POST.items():
        if key == 'barangay' or key == 'csrfmiddlewaretoken':
            continue

        splits = key.split('-')

        ns_code = splits[0]
        ag_code = splits[1]
        sex_code = splits[2]

        nutritional_status = NutritionalStatus.objects.get(code=ns_code)
        age_group = AgeGroup.objects.get(code=ag_code, sex=sex_code)
        number = float(value)

        OPTValues.objects.create(opt=opt,
                                 nutritional_status=nutritional_status,
                                 age_group=age_group,
                                 values=number)

    messages.success(request, 'Nutritional statuses successfully encoded!')
    return redirect('data-collection:index')
Example #2
0
def encode_sti_surveillance(request):

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.input_fhsis(request, STISurveillanceForm,
                                 "STI Surveillance", barangay)
Example #3
0
def store_leprosy(request):

    url = 'data-collection:encode-leprosy'

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.fhsis_input(request, url, Leprosy, "Leprosy", barangay)
Example #4
0
def store_malaria(request):

    url = 'data-collection:encode-malaria'

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.fhsis_input(request, url, Malaria, "Malaria", barangay)
Example #5
0
def store_schistosomiasis(request):

    url = 'data-collection:encode-schistosomiasis'

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.fhsis_input(request, url, Schistosomiasis,
                                 "Schistosomiasis", barangay)
Example #6
0
def store_tuberculosis(request):

    url = 'data-collection:encode-tb'

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.fhsis_input(request, url, Tuberculosis, "Tuberculosis",
                                 barangay)
Example #7
0
def store_immunization(request):

    url = 'data-collection:encode-immunization'

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.fhsis_input(request, url, Immunization, "Immmunization",
                                 barangay)
Example #8
0
def store_child_care(request):

    url = 'data-collection:encode-cc'

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.fhsis_input(request, url, ChildCare, "Child Care",
                                 barangay)
Example #9
0
def create_fhsis(request):

    user = global_user.get_user(request.user.username)

    FHSIS.objects.create(barangay=user.barangay)

    month = datetime.datetime.now().strftime("%B")

    messages.success(request, "FHSIS generated for " + str(month))
    return redirect('data-collection:fhsis')
Example #10
0
def fhsis_index(request):

    month = datetime.datetime.now().month
    year = datetime.datetime.now().year
    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    # FHSIS fields

    has_maternal = checkers.check_fhsis(month, year, barangay, Maternal)
    has_immunization = checkers.check_fhsis(month, year, barangay,
                                            Immunization)
    has_malaria = checkers.check_fhsis(month, year, barangay, Malaria)
    has_tb = checkers.check_fhsis(month, year, barangay, Tuberculosis)
    has_schisto = checkers.check_fhsis(month, year, barangay, Schistosomiasis)
    has_flariasis = checkers.check_fhsis(month, year, barangay, Flariasis)
    has_leprosy = checkers.check_fhsis(month, year, barangay, Leprosy)
    has_cc = checkers.check_fhsis(month, year, barangay, ChildCare)
    has_sti = checkers.check_fhsis(month, year, barangay, STISurveillance)

    try:
        FHSIS.objects.get(date__month=month,
                          date__year=year,
                          barangay=barangay)
        has_fhsis = True
    except FHSIS.DoesNotExist:
        has_fhsis = False

    print(has_maternal)

    context = {
        'has_fhsis': has_fhsis,
        'has_maternal': has_maternal,
        'has_immunization': has_immunization,
        'has_malaria': has_malaria,
        'has_tb': has_tb,
        'has_schisto': has_schisto,
        'has_flariasis': has_flariasis,
        'has_leprosy': has_leprosy,
        'has_cc': has_cc,
        'has_sti': has_sti
    }

    return render(request, 'datacollection/fhsis_index.html', context)
Example #11
0
def nutritional_status(request):

    month = datetime.datetime.now().month
    year = datetime.datetime.now().year
    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    try:
        OperationTimbang.objects.get(date__month=month,
                                     date__year=year,
                                     barangay=barangay)
        has_opt = True
    except OperationTimbang.DoesNotExist:
        has_opt = False

    print(has_opt)

    context = {'has_opt': has_opt}

    return render(request, 'datacollection/ns_index.html', context)
Example #12
0
def encode_maternal(request):

    bns = global_user.get_user(request.user.username)
    barangay = bns.barangay

    return functions.input_fhsis(request, MaternalForm, "Maternal", barangay)