Esempio n. 1
0
def profile(request):
    if 'field' in request.GET:
        field = request.GET['field']
    elif 'field' in request.POST:
        field = request.POST['field']
    else:
        field = 'gestationTerm'
    service = MaternityService()
    results = service.get_authorities()
    keys = []
    data = []
    for r in results:
        key = r[1]['code']
        name = r[1]['name']
        series = []
        rawseries = get_field(r[1]['statistics']['11-12'], field)
        for k, v in rawseries.iteritems():
            series.append((k, v))
        data.append((key, sorted(series)))
        keys.append({
                     'key': key,
                     'name': name
                     })
    context = {
               'chart': BarChart(600, 400, sorted(data)),
               'keys': sorted(keys)
               }
    return render(request, 'maternity/profile.html', context)
Esempio n. 2
0
def simple(request):
    if 'field' in request.GET:
        field = request.GET['field']
    elif 'field' in request.POST:
        field = request.POST['field']
    else:
        field = 'total'
    service = MaternityService()
    results = service.get_authorities()
    keys = []
    data = []
    for r in results:
        key = r[1]['code']
        name = r[1]['name']
        series = []
        for k, v in sorted(r[1]['statistics'].iteritems()):
            series.append((k, get_field(v, field)))
        data.append((key, series))
        keys.append({
                     'key': key,
                     'name': name
                     })
    context = {
               'chart': BarChart(600, 400, sorted(data)),
               'keys': sorted(keys),
               'selected': field,
               'fields': [
                          {'value': 'total', 'text': 'Total'},
                          {'value': 'person.doctor', 'text': 'Delivered by the doctor'},
                          {'value': 'person.midwife', 'text': 'Delivered by the midwife'},
                          {'value': 'delivery.caesarean.elective', 'text': 'Elective C-section'}
                          ]
               }
    return render(request, 'maternity/simple.html', context)