Exemplo n.º 1
0
def health_0_1_review(request):
    global model
    resident = get_resident(request)
    context = {
        'aftercare_1_month': None,
        'aftercare_3_month': None,
        'aftercare_6_month': None,
        'aftercare_8_month': None
    }
    for item_alias in context:
        service_item = Service.items.get(alias=item_alias,
                                         service_type__alias='child')
        try:
            record = WorkRecord.objects.get(resident=resident,
                                            service_item=service_item)
        except WorkRecord.DoesNotExist:
            pass
        else:
            try:
                model_name = get_model_name(item_alias)
                model = apps.get_model(app_label='child',
                                       model_name=model_name)
                context[item_alias] = model.objects.get(id=record.item_id)
            except model.DoesNotExist:
                pass
    context['resident'] = resident
    return render(request, 'child/health_0_1_review.html', context)
Exemplo n.º 2
0
def health_3_6_submit(request):
    item_alias = request.POST.get("item_alias")
    resident = get_resident(request)
    service_item = Service.items.get(alias=item_alias, service_type__alias="child")
    form_name = get_model_name(item_alias) + "Form"
    form = globals()[form_name](request.POST)
    if form.is_valid():
        result = form.save()
        record = WorkRecord(
            provider=request.user,
            resident=resident,
            service_item=service_item,
            app_label="child",
            model_name=get_model_name(item_alias),
            item_id=result.id,
            service_item_alias=service_item.alias,
        )
        record.save()
        success = True
    else:
        success = False

    return HttpResponse(simplejson.dumps({"success": success}), content_type="text/html; charset=UTF-8")
Exemplo n.º 3
0
def health_3_6_submit(request):
    item_alias = request.POST.get('item_alias')
    resident = get_resident(request)
    service_item = Service.items.get(alias=item_alias,
                                     service_type__alias='child')
    form_name = get_model_name(item_alias) + 'Form'
    form = globals()[form_name](request.POST)
    if form.is_valid():
        result = form.save()
        record = WorkRecord(provider=request.user,
                            resident=resident,
                            service_item=service_item,
                            app_label='child',
                            model_name=get_model_name(item_alias),
                            item_id=result.id,
                            service_item_alias=service_item.alias)
        record.save()
        success = True
    else:
        success = False

    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Exemplo n.º 4
0
def health_0_1_form(request):
    item_alias = request.POST.get("item_alias")
    resident = get_resident(request)
    form_name = get_model_name(item_alias) + "Form"
    form = globals()[form_name]()
    template = "child/" + item_alias + "_form_content.html"

    # 因为要根据性别判断儿童的身高和体重等级,所以要把新生儿家庭访视里的性别取得
    record = WorkRecord.objects.filter(resident=resident, model_name="NewbornFamilyVisit").first()
    if record:
        newborn_family = NewbornFamilyVisit.objects.get(id=record.item_id)
        gender = newborn_family.gender
    else:
        gender = u"男"
    return render(request, template, {"form": form, "resident": resident, "item_alias": item_alias, "gender": gender})
Exemplo n.º 5
0
def health_3_6_review(request):
    global model
    resident = get_resident(request)
    context = {"aftercare_3_year": None, "aftercare_4_year": None, "aftercare_5_year": None, "aftercare_6_year": None}
    for item_alias in context:
        service_item = Service.items.get(alias=item_alias, service_type__alias="child")
        try:
            record = WorkRecord.objects.get(resident=resident, service_item=service_item)
        except WorkRecord.DoesNotExist:
            pass
        else:
            try:
                model_name = get_model_name(item_alias)
                model = apps.get_model(app_label="child", model_name=model_name)
                context[item_alias] = model.objects.get(id=record.item_id)
            except model.DoesNotExist:
                pass
    context["resident"] = resident
    return render(request, "child/health_3_6_review.html", context)
Exemplo n.º 6
0
def health_3_6_form(request):
    item_alias = request.POST.get('item_alias')
    resident = get_resident(request)
    form_name = get_model_name(item_alias) + 'Form'
    form = globals()[form_name]()
    template = 'child/' + item_alias + '_form_content.html'

    #因为要根据性别判断儿童的身高和体重等级,所以要把新生儿家庭访视里的性别取得
    record = WorkRecord.objects.filter(
        resident=resident, model_name='NewbornFamilyVisit').first()
    if record:
        newborn_family = NewbornFamilyVisit.objects.get(id=record.item_id)
        gender = newborn_family.gender
    else:
        gender = u'男'
    return render(
        request, template, {
            'form': form,
            'resident': resident,
            'item_alias': item_alias,
            'gender': gender
        })
Exemplo n.º 7
0
def get_form(item_alias):
    model_name = get_model_name(item_alias)
    return globals()[''.join([model_name, 'Form'])]
Exemplo n.º 8
0
def get_form(item_alias):
    model_name = get_model_name(item_alias)
    return globals()[''.join([model_name, 'Form'])]