Fakultas Ilmu Komputer UI

Commit 4eafe7c7 authored by Jonathan Christopher Jakub's avatar Jonathan Christopher Jakub
Browse files

[RED] Add utility to initiate count maps

parent 3d59a9dd
from django.contrib import admin
# Register your models here.
DISTRICTS = (
"Beji",
"Bojongsari",
"Cilodong",
"Cimanggis",
"Cinere",
"Cipayung",
"Limo",
"Pancoran Mas",
"Sawangan",
"Sukmajaya",
"Tapos",
)
DISTRICT = "district"
AGE = "age"
SEX = "sex"
FEMALE = "female"
MALE = "male"
POSITIVE = "positive"
NEGATIVE = "negative"
UNDERTERMINED = "undetermined"
TOTAL = "total_count"
from django.db import models
# Create your models here.
...@@ -6,6 +6,7 @@ from apps.cases.models import CaseSubject ...@@ -6,6 +6,7 @@ from apps.cases.models import CaseSubject
from apps.cases.tests.factories.case_subjects import CaseSubjectFactory from apps.cases.tests.factories.case_subjects import CaseSubjectFactory
from apps.cases.tests.factories.cases import InvestigationCaseFactory from apps.cases.tests.factories.cases import InvestigationCaseFactory
class ExportableViewTest(APITestCase): class ExportableViewTest(APITestCase):
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
......
from apps.exportables.constants import (
DISTRICT,
DISTRICTS,
FEMALE,
MALE,
NEGATIVE,
POSITIVE,
TOTAL,
UNDERTERMINED
)
def generate_initial_counts():
return {
POSITIVE: 0,
NEGATIVE: 0,
UNDERTERMINED: 0,
TOTAL: 0
}
def generate_initial_groups():
age_groups = {}
sex_groups = {
MALE: generate_initial_counts(),
FEMALE: generate_initial_counts(),
}
district_groups = {
district: generate_initial_counts() for district in DISTRICTS
}
return [age_groups, sex_groups, district_groups]
def map_outcome(outcome):
if outcome is None:
return UNDERTERMINED
if outcome:
return POSITIVE
else:
return NEGATIVE
def map_sex(sex):
if sex:
return MALE
return FEMALE
from django.shortcuts import render
# Create your views here.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment