Esempio n. 1
0
def body_exam_submit(request):
    submit_data = request.POST.copy()
    if 'csrfmiddlewaretoken' in submit_data:
        submit_data.pop('csrfmiddlewaretoken')

    if submit_data:
        resident = get_resident(request)
        record = WorkRecord.objects.filter(resident=resident, model_name='BodyExam',
                                           submit_time__gte=new_year_day()).first()
        if record:
            result, created = BodyExam.objects.update_or_create(id=record.item_id, defaults=submit_data)
            success = True
        else:
            form = BodyExamForm(submit_data)
            if form.is_valid():
                result = form.save(commit=False)
                result.resident = resident
                result.save()
                success = True
            else:
                success, message = False, u'数据保存到数据库时失败'
        if success:
            service_item = Service.items.get(alias='physical_examination',
                                             service_type__alias='diabetes')
            WorkRecord.objects.create(provider=request.user, resident=resident, service_item=service_item,
                                      app_label='diabetes', model_name='BodyExam', item_id=result.id,
                                      service_item_alias=service_item.alias)
            message = u'记录保存成功'
    else:
        success, message = False, u'没有提交任何数据结果'

    return HttpResponse(simplejson.dumps({'success': success, 'message': message}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 2
0
def personal_info_page(request):
    resident = get_resident(request)
    form = PsychiatricInfoForm()
    return render(request, 'psychiatric/personal_info.html', {
        'form': form,
        'resident': resident
    })
Esempio n. 3
0
def body_exam_save(request, save_type):
    success = True
    resident = get_resident(request)
    record = WorkRecord.objects.filter(resident=resident, model_name='BodyExam',
                                       submit_time__gte=new_year_day()).first()
    form = BodyExamForm(request.POST)
    if form.is_valid():
        if record:
            submit_data = {field: value for field, value in form.cleaned_data.items() if value or value == 0}
            result, created = BodyExam.objects.update_or_create(id=record.item_id, defaults=submit_data)
            if created:
                debug.info('create a new record BodyExam !!!')
        else:
            result = form.save(commit=False)
            result.resident = resident
            result.save()
        body_exam_commit_workrecord(request, resident, result)
        if save_type == WorkRecord.SUSPEND:
            service_item = Service.objects.get(alias='body_exam_table', service_type__alias='old')
            WorkRecord.objects.create(provider=request.user, resident=resident, service_item=service_item,
                                      app_label='old', model_name='BodyExam', status=save_type,
                                      item_id=result.id, service_item_alias=service_item.alias)
    else:
        success = False
        debug.info(form.errors.as_data())
    return success
Esempio n. 4
0
def personal_info_table(request):
    resident = get_resident(request)
    if resident.psychiatric_info_table:
        form = PsychiatricInfoForm(instance=resident.psychiatric_info_table)
        return render(request, 'psychiatric/psychiatric_info_review_content.html',
                      {'form': form, 'resident': resident})
    else:
        form = PsychiatricInfoForm()
        return render(request, 'psychiatric/psychiatric_info_form_content.html',
                      {'form': form, 'resident': resident})
Esempio n. 5
0
def body_exam_form(request):
    resident = get_resident(request)
    record = WorkRecord.objects.filter(resident=resident, model_name='BodyExam',
                                       submit_time__gte=new_year_day()).first()
    if record:
        result = BodyExam.objects.get(id=record.item_id)
        form = BodyExamForm(instance=result)
    else:
        form = BodyExamForm()
    return render(request, 'ehr/body_exam_form.html',
                  {'form': form, 'resident': resident, 'type_alias': 'psychiatric'})
Esempio n. 6
0
def living_selfcare_appraisal_review(request):
    resident = get_resident(request)
    service_item = Service.items.get(alias='living_selfcare_appraisal')
    try:
        record = WorkRecord.objects.get(resident=resident, service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = LivingSelfcareAppraisalForm()
    else:
        form = LivingSelfcareAppraisal.objects.get(id=record.item_id)

    return render(request, 'old/living_selfcare_appraisal_review_content.html',
                  {'form': form, 'resident': resident})
Esempio n. 7
0
def body_exam_submit(request):
    """
    首先,检查是否提交了数据,如果没有提交数据返回失败
    其次,如果提交了数据,由于有前端js的检查,一般体格检查的所有数据字段都应该存在并符合取值范围
    :param request:
    :return:
    """
    resident = get_resident(request)
    record = WorkRecord.objects.filter(
        resident=resident,
        model_name='BodyExam',
        submit_time__gte=new_year_day()).first()
    if record:
        form = BodyExamForm(request.POST)
        if form.is_valid():
            submit_data = {
                field: value
                for field, value in form.cleaned_data.items()
                if value or value == 0
            }
            result, created = BodyExam.objects.update_or_create(
                id=record.item_id, defaults=submit_data)
            if created:
                debug.info('create a new BodyExam record')
            success, message = True, u'保存数据完成'
        else:
            debug.info(form.errors.as_data())
            success, message = False, u'输入数据有误'
    else:
        form = BodyExamForm(request.POST)
        if form.is_valid():
            result = form.save()
            success, message = True, u'保存数据完成'
        else:
            debug.info(form.errors.as_data())
            success, message = False, u'数据保存到数据库时失败'
    if success:
        service_item = Service.items.get(alias='physical_examination',
                                         service_type__alias='hypertension')
        WorkRecord.objects.create(provider=request.user,
                                  resident=resident,
                                  service_item=service_item,
                                  app_label='hypertension',
                                  model_name='BodyExam',
                                  item_id=result.id,
                                  service_item_alias=service_item.alias)
        message = u'记录保存成功'
    return HttpResponse(simplejson.dumps({
        'success': success,
        'message': message
    }),
                        content_type='text/html; charset=UTF-8')
Esempio n. 8
0
def aftercare_supplement_review(request):
    resident = get_resident(request)
    context = {'aftercare_5': None, 'aftercare_6': None,}
    for aftercare in context:
        service_item = Service.items.get(alias=aftercare, service_type__alias='hypertension')
        try:
            record = WorkRecord.objects.get(resident=resident, service_item=service_item)
        except WorkRecord.DoesNotExist:
            pass
        else:
            context[aftercare] = Aftercare.objects.get(id=record.item_id)
    context['resident'] = resident
    return render(request, 'hypertension/aftercare_supplement_review.html', context)
Esempio n. 9
0
def aftercare_1_table(request):
    resident = get_resident(request)
    service_item = Service.objects.get(alias='aftercare_1', service_type__alias='pregnant')
    try:
        record = WorkRecord.objects.get(resident=resident, service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = Aftercare1Form()
        return render(request, 'pregnant/antenatal_1_form_content.html',
                      {'form': form, 'resident': resident})
    else:
        result = Aftercare1.objects.get(id=record.item_id)
        return render(request, 'pregnant/aftercare_1_review_content.html',
                      {'form': result, 'resident': resident})
Esempio n. 10
0
def personal_info_submit(request):
    form = PsychiatricInfoForm(request.POST)
    if form.is_valid():
        result = form.save()
        resident = get_resident(request)
        resident.psychiatric_info_table = result
        resident.psychiatric = True
        resident.save()
        success = True
    else:
        success = False

    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 11
0
def postpartum_visit_submit(request):
    form = PostpartumVisitForm(request.POST)
    success = False
    if form.is_valid():
        result = form.save()
        resident = get_resident(request)
        service_item = Service.objects.get(alias='postpartum_visit', service_type__alias='pregnant')
        record = WorkRecord(provider=request.user, resident=resident, service_item=service_item,
                            app_label='pregnant', model_name='PostpartumVisit',
                            item_id=result.id, service_item_alias=service_item.alias)
        record.save()
        success = True
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 12
0
def aftercare_review(request):
    resident = get_resident(request)
    aftercare_status = dict()
    for item in range(1, 9):
        aftercare = 'aftercare_' + str(item)
        service_item = Service.items.get(alias=aftercare, service_type__alias='psychiatric')
        try:
            WorkRecord.objects.get(resident=resident, service_item=service_item, submit_time__gte=new_year_day())
        except WorkRecord.DoesNotExist:
            aftercare_status[aftercare] = False
        else:
            aftercare_status[aftercare] = True
    from django.http import JsonResponse
    return JsonResponse(aftercare_status)
Esempio n. 13
0
def personal_info_submit(request):
    form = PsychiatricInfoForm(request.POST)
    if form.is_valid():
        result = form.save()
        resident = get_resident(request)
        resident.psychiatric_info_table = result
        resident.psychiatric = True
        resident.save()
        success = True
    else:
        success = False

    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 14
0
def child_review(request):
    resident = get_resident(request)
    context = {'aftercare_6_month': None, 'aftercare_12_month': None, 'aftercare_18_month': None,
               'aftercare_24_month': None, 'aftercare_30_month': None, 'aftercare_3_year': None}
    for aftercare in context:
        service_item = Service.items.get(alias=aftercare, service_type__alias='tcm')
        try:
            record = WorkRecord.objects.get(resident=resident, service_item=service_item)
        except WorkRecord.DoesNotExist:
            pass
        else:
            context[aftercare] = Aftercare.objects.get(id=record.item_id)
    context['resident'] = resident
    return render(request, 'tcm/child_review.html', context)
Esempio n. 15
0
def postpartum_42day_table(request):
    resident = get_resident(request)
    service_item = Service.objects.get(alias='postpartum_42_day_examination',
                                       service_type__alias='pregnant')
    try:
        record = WorkRecord.objects.get(resident=resident, service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = Postpartum42ExamForm()
        return render(request, 'pregnant/postpartum42_form_content.html',
                      {'form': form, 'resident': resident})
    else:
        form = Postpartum42Exam.objects.get(id=record.item_id)
        return render(request, 'pregnant/postpartum_42_day_examination_review_content.html',
                      {'form': form, 'resident': resident})
Esempio n. 16
0
def old_identify_submit(request):
    resident = get_resident(request)
    result = None

    form = OldIdentifyForm(request.POST)
    if form.is_valid():
        result = form.save()
        success = True
    else:
        debug.info(form.errors.as_data())
        success = False

    if success:
        record = WorkRecord.objects.filter(resident=resident, model_name='BodyExam',
                                           submit_time__gte=new_year_day()).first()

        if record:
            result0 = BodyExam.objects.get(id=record.item_id)
            result0.pinghe = result.yes_trend_pinghe
            result0.qixu = result.yes_trend_qixu
            result0.yangxu = result.yes_trend_yangxu
            result0.yinxu = result.yes_trend_yinxu
            result0.tanshi = result.yes_trend_tanshi
            result0.shire = result.yes_trend_shire
            result0.xueyu = result.yes_trend_xueyu
            result0.qiyu = result.yes_trend_qiyu
            result0.tebing = result.yes_trend_tebing
            result0.save()
            success = True
        else:
            form0 = BodyExamForm({'pinghe': result.yes_trend_pinghe,
                                  'qixu': result.yes_trend_qixu,
                                  'yangxu': result.yes_trend_yangxu,
                                  'yinxu': result.yes_trend_yinxu,
                                  'tanshi': result.yes_trend_tanshi,
                                  'shire': result.yes_trend_shire,
                                  'xueyu': result.yes_trend_xueyu,
                                  'qiyu': result.yes_trend_qiyu,
                                  'tebing': result.yes_trend_tebing})
            if form0.is_valid():
                form0.save()

        service_item = Service.items.get(alias='constitution_identification', service_type__alias='tcm')
        WorkRecord.objects.create(provider=request.user, resident=resident, service_item=service_item,
                                  app_label='tcm', model_name='OldIdentify', item_id=result.id,
                                  service_item_alias=service_item.alias)
        #debug.info(simplejson.dumps({'success': success}))
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 17
0
def body_exam_form(request):
    resident = get_resident(request)
    records = WorkRecord.objects.filter(resident=resident,
                                        model_name='BodyExam',
                                        submit_time__gte=new_year_day())
    if records.count():
        result = BodyExam.objects.get(id=records[0].item_id)
        form = BodyExamForm(instance=result)
    else:
        form = BodyExamForm()
    return render(request, 'ehr/body_exam_form.html', {
        'form': form,
        'resident': resident,
        'type_alias': 'old'
    })
Esempio n. 18
0
def aftercare_1_suspend(request):
    success = True
    resident = get_resident(request)
    form = Aftercare1Form(request.POST)
    if form.is_valid():
        result = form.save()
        service_item = Service.objects.get(alias='aftercare_1', service_type__alias='pregnant')
        WorkRecord.objects.create(provider=request.user, resident=resident, service_item=service_item,
                                  app_label='pregnant', model_name='Aftercare1', status=WorkRecord.SUSPEND,
                                  item_id=result.id, service_item_alias=service_item.alias)
    else:
        debug.info(form.errors.as_data())
        success = False
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 19
0
def child_submit(request):
    success = False
    resident = get_resident(request)
    item_alias = request.POST.get('item_alias')
    service_item = Service.items.get(alias=item_alias, service_type__alias='tcm')
    form = AftercareForm(request.POST)
    if form.is_valid():
        result = form.save()
        record = WorkRecord(provider=request.user, resident=resident, service_item=service_item,
                            app_label='tcm', model_name='Aftercare',
                            item_id=result.id, service_item_alias=service_item.alias)
        record.save()
        success = True
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 20
0
def aftercare_2_5_review(request):
    resident = get_resident(request)
    context = {'aftercare_2': None, 'aftercare_3': None,
               'aftercare_4': None, 'aftercare_5': None}
    for aftercare in context:
        service_item = Service.items.get(alias=aftercare, service_type__alias='pregnant')
        records = WorkRecord.objects.filter(resident=resident, service_item=service_item).order_by('-submit_time')
        if records.count():
            record = records[0]
            try:
                context[aftercare] = Aftercare.objects.get(id=record.item_id)
            except Aftercare.DoesNotExist:
                pass
    context['resident'] = resident
    return render(request, 'pregnant/aftercare_2_5_review.html', context)
Esempio n. 21
0
def aftercare_form(request):
    aftercare = request.POST.get('aftercare')
    form = AftercareForm()
    resident = get_resident(request)
    template = 'diabetes/aftercare_%s_form_content.html' % aftercare

    #因为要算体质指数,所以要把一般体格检查里的身高取得
    record = WorkRecord.objects.filter(resident=resident, model_name='BodyExam',
                                       submit_time__gte=new_year_day()).first()
    if record:
        body_exam = BodyExam.objects.get(id=record.item_id)
        sign_height = body_exam.height
    else:
        sign_height = 0.0
    return render(request, template, {'form': form, 'resident': resident, 'sign_height': sign_height})
Esempio n. 22
0
def old_identify_form(request):
    not_form = True
    resident = get_resident(request)
    records = WorkRecord.objects.filter(resident=resident,
                                        model_name='OldIdentify',
                                        submit_time__gte=new_year_day())
    if records.count():
        result = OldIdentify.objects.get(id=records[0].item_id)
        form = OldIdentifyForm(instance=result)
    else:
        form = OldIdentifyForm()
        not_form = False
        #debug.info(form)
    return render(request, 'tcm/old_identify_form.html', {'form': form, 'resident': resident, 'type_alias': 'tcm',
                                                          'not_form': not_form})
Esempio n. 23
0
def aftercare_review(request):
    resident = get_resident(request)

    context = {'aftercare_1': None, 'aftercare_2': None,
               'aftercare_3': None, 'aftercare_4': None}

    for aftercare in context:
        service_item = Service.items.get(alias=aftercare, service_type__alias='diabetes')
        try:
            record = WorkRecord.objects.get(resident=resident, service_item=service_item)
        except WorkRecord.DoesNotExist:
            pass
        else:
            context[aftercare] = Aftercare.objects.get(id=record.item_id)
    context['resident'] = resident
    return render(request, 'diabetes/aftercare_review.html', context)
Esempio n. 24
0
def living_selfcare_appraisal_submit(request):
    resident = get_resident(request)
    service_item = Service.items.get(alias='living_selfcare_appraisal')
    form = LivingSelfcareAppraisalForm(request.POST)
    if form.is_valid():
        result = form.save()
        record = WorkRecord(provider=request.user, resident=resident, service_item=service_item,
                            app_label='old', model_name='LivingSelfcareAppraisal',
                            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')
Esempio n. 25
0
def living_selfcare_appraisal_review(request):
    resident = get_resident(request)
    service_item = Service.items.get(alias='living_selfcare_appraisal')
    try:
        record = WorkRecord.objects.get(resident=resident,
                                        service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = LivingSelfcareAppraisalForm()
    else:
        form = LivingSelfcareAppraisal.objects.get(id=record.item_id)

    return render(request, 'old/living_selfcare_appraisal_review_content.html',
                  {
                      'form': form,
                      'resident': resident
                  })
Esempio n. 26
0
def postpartum_visit_table(request):
    resident = get_resident(request)
    service_item = Service.objects.get(alias='postpartum_visit', service_type__alias='pregnant')
    try:
        record = WorkRecord.objects.get(resident=resident, service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = PostpartumVisitForm()
        return render(request, 'pregnant/postpartum_form_content.html',
                      {'form': form, 'resident': resident})
    else:
        # result = PostpartumVisit.objects.get(id=record.item_id)
        # form = PostpartumVisitForm(instance=result)
        # return render(request, 'pregnant/postpartum_review_content.html', {'form': form, 'resident': resident})
        form = PostpartumVisit.objects.get(id=record.item_id)
        return render(request, 'pregnant/postpartum_visit_review_content.html',
                      {'form': form, 'resident': resident})
Esempio n. 27
0
def personal_info_table(request):
    resident = get_resident(request)
    if resident.psychiatric_info_table:
        form = PsychiatricInfoForm(instance=resident.psychiatric_info_table)
        return render(request,
                      'psychiatric/psychiatric_info_review_content.html', {
                          'form': form,
                          'resident': resident
                      })
    else:
        form = PsychiatricInfoForm()
        return render(request,
                      'psychiatric/psychiatric_info_form_content.html', {
                          'form': form,
                          'resident': resident
                      })
Esempio n. 28
0
def aftercare_form(request):
    resident = get_resident(request)
    item_alias = request.POST.get('item_alias')
    service_item = Service.objects.get(alias=item_alias, service_type__alias='psychiatric')
    try:
        record = WorkRecord.objects.get(resident=resident,
                                        service_item=service_item,
                                        submit_time__gte=new_year_day())
    except WorkRecord.DoesNotExist:
        form = AftercareForm()
        return render(request, 'psychiatric/psy_visit_form_content.html',
                      {'form': form, 'resident': resident})
    else:
        result = Aftercare.objects.get(id=record.item_id)
        form = AftercareForm(instance=result)
        return render(request, 'psychiatric/aftercare_review.html',
                      {'form': form, 'resident': resident})
Esempio n. 29
0
def aftercare_1_submit(request):
    form = Aftercare1Form(request.POST)
    if form.is_valid():
        result = form.save()
        resident = get_resident(request)
        service_item = Service.objects.get(alias='aftercare_1', service_type__alias='pregnant')
        record = WorkRecord(provider=request.user, resident=resident, service_item=service_item,
                            app_label='pregnant', model_name='Aftercare1',
                            item_id=result.id, service_item_alias=service_item.alias)
        record.save()
        aftercare_1_commit_workrecord(request, resident, result)
        success = True
    else:
        success = False

    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 30
0
def body_exam_form(request):
    resident = get_resident(request)
    record = WorkRecord.objects.filter(
        resident=resident,
        model_name='BodyExam',
        submit_time__gte=new_year_day()).first()
    if record:
        debug.info('find the record of BodyExam')
        result = BodyExam.objects.get(id=record.item_id)
        form = BodyExamForm(instance=result)
    else:
        form = BodyExamForm()
    return render(request, 'ehr/body_exam_form.html', {
        'form': form,
        'resident': resident,
        'type_alias': 'hypertension'
    })
Esempio n. 31
0
def aftercare_review(request):
    resident = get_resident(request)
    aftercare_status = dict()
    for item in range(1, 9):
        aftercare = 'aftercare_' + str(item)
        service_item = Service.items.get(alias=aftercare,
                                         service_type__alias='psychiatric')
        try:
            WorkRecord.objects.get(resident=resident,
                                   service_item=service_item,
                                   submit_time__gte=new_year_day())
        except WorkRecord.DoesNotExist:
            aftercare_status[aftercare] = False
        else:
            aftercare_status[aftercare] = True
    from django.http import JsonResponse
    return JsonResponse(aftercare_status)
Esempio n. 32
0
def aftercare_supplement_review(request):
    resident = get_resident(request)
    context = {'aftercare_5': None, 'aftercare_6': None}
    for aftercare in context:
        service_item = Service.items.get(alias=aftercare,
                                         service_type__alias='diabetes')
        try:
            record = WorkRecord.objects.get(resident=resident,
                                            service_item=service_item)
        except WorkRecord.DoesNotExist:
            pass
        else:
            context[aftercare] = Aftercare.objects.get(id=record.item_id)
    context['resident'] = resident

    return render(request, 'diabetes/aftercare_supplement_review.html',
                  context)
Esempio n. 33
0
def aftercare_1_table(request):
    resident = get_resident(request)
    service_item = Service.objects.get(alias='aftercare_1',
                                       service_type__alias='pregnant')
    try:
        record = WorkRecord.objects.get(resident=resident,
                                        service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = Aftercare1Form()
        return render(request, 'pregnant/antenatal_1_form_content.html', {
            'form': form,
            'resident': resident
        })
    else:
        result = Aftercare1.objects.get(id=record.item_id)
        return render(request, 'pregnant/aftercare_1_review_content.html', {
            'form': result,
            'resident': resident
        })
Esempio n. 34
0
def body_exam_submit(request):
    submit_data = request.POST.copy()
    if 'csrfmiddlewaretoken' in submit_data:
        submit_data.pop('csrfmiddlewaretoken')

    if submit_data:
        resident = get_resident(request)
        record = WorkRecord.objects.filter(
            resident=resident,
            model_name='BodyExam',
            submit_time__gte=new_year_day()).first()
        if record:
            result, created = BodyExam.objects.update_or_create(
                id=record.item_id, defaults=submit_data)
            success = True
        else:
            form = BodyExamForm(submit_data)
            if form.is_valid():
                result = form.save(commit=False)
                result.resident = resident
                result.save()
                success = True
            else:
                success, message = False, u'数据保存到数据库时失败'
        if success:
            service_item = Service.items.get(alias='physical_examination',
                                             service_type__alias='diabetes')
            WorkRecord.objects.create(provider=request.user,
                                      resident=resident,
                                      service_item=service_item,
                                      app_label='diabetes',
                                      model_name='BodyExam',
                                      item_id=result.id,
                                      service_item_alias=service_item.alias)
            message = u'记录保存成功'
    else:
        success, message = False, u'没有提交任何数据结果'

    return HttpResponse(simplejson.dumps({
        'success': success,
        'message': message
    }),
                        content_type='text/html; charset=UTF-8')
Esempio n. 35
0
def postpartum_visit_submit(request):
    form = PostpartumVisitForm(request.POST)
    success = False
    if form.is_valid():
        result = form.save()
        resident = get_resident(request)
        service_item = Service.objects.get(alias='postpartum_visit',
                                           service_type__alias='pregnant')
        record = WorkRecord(provider=request.user,
                            resident=resident,
                            service_item=service_item,
                            app_label='pregnant',
                            model_name='PostpartumVisit',
                            item_id=result.id,
                            service_item_alias=service_item.alias)
        record.save()
        success = True
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 36
0
def living_selfcare_appraisal_submit(request):
    resident = get_resident(request)
    service_item = Service.items.get(alias='living_selfcare_appraisal')
    form = LivingSelfcareAppraisalForm(request.POST)
    if form.is_valid():
        result = form.save()
        record = WorkRecord(provider=request.user,
                            resident=resident,
                            service_item=service_item,
                            app_label='old',
                            model_name='LivingSelfcareAppraisal',
                            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')
Esempio n. 37
0
def aftercare_1_suspend(request):
    success = True
    resident = get_resident(request)
    form = Aftercare1Form(request.POST)
    if form.is_valid():
        result = form.save()
        service_item = Service.objects.get(alias='aftercare_1',
                                           service_type__alias='pregnant')
        WorkRecord.objects.create(provider=request.user,
                                  resident=resident,
                                  service_item=service_item,
                                  app_label='pregnant',
                                  model_name='Aftercare1',
                                  status=WorkRecord.SUSPEND,
                                  item_id=result.id,
                                  service_item_alias=service_item.alias)
    else:
        debug.info(form.errors.as_data())
        success = False
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 38
0
def postpartum_42day_table(request):
    resident = get_resident(request)
    service_item = Service.objects.get(alias='postpartum_42_day_examination',
                                       service_type__alias='pregnant')
    try:
        record = WorkRecord.objects.get(resident=resident,
                                        service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = Postpartum42ExamForm()
        return render(request, 'pregnant/postpartum42_form_content.html', {
            'form': form,
            'resident': resident
        })
    else:
        form = Postpartum42Exam.objects.get(id=record.item_id)
        return render(
            request,
            'pregnant/postpartum_42_day_examination_review_content.html', {
                'form': form,
                'resident': resident
            })
Esempio n. 39
0
def aftercare_form(request):
    aftercare = request.POST.get('aftercare')
    form = AftercareForm()
    resident = get_resident(request)
    template = 'hypertension/aftercare_%s_form_content.html' % aftercare

    #因为要算体质指数,所以要把一般体格检查里的身高取得
    record = WorkRecord.objects.filter(
        resident=resident,
        model_name='BodyExam',
        submit_time__gte=new_year_day()).first()
    if record:
        body_exam = BodyExam.objects.get(id=record.item_id)
        sign_height = body_exam.height
    else:
        sign_height = 0.0
    return render(request, template, {
        'form': form,
        'resident': resident,
        'sign_height': sign_height
    })
Esempio n. 40
0
def aftercare_1_submit(request):
    form = Aftercare1Form(request.POST)
    if form.is_valid():
        result = form.save()
        resident = get_resident(request)
        service_item = Service.objects.get(alias='aftercare_1',
                                           service_type__alias='pregnant')
        record = WorkRecord(provider=request.user,
                            resident=resident,
                            service_item=service_item,
                            app_label='pregnant',
                            model_name='Aftercare1',
                            item_id=result.id,
                            service_item_alias=service_item.alias)
        record.save()
        aftercare_1_commit_workrecord(request, resident, result)
        success = True
    else:
        success = False

    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 41
0
def aftercare_2_5_review(request):
    resident = get_resident(request)
    context = {
        'aftercare_2': None,
        'aftercare_3': None,
        'aftercare_4': None,
        'aftercare_5': None
    }
    for aftercare in context:
        service_item = Service.items.get(alias=aftercare,
                                         service_type__alias='pregnant')
        records = WorkRecord.objects.filter(
            resident=resident,
            service_item=service_item).order_by('-submit_time')
        if records.count():
            record = records[0]
            try:
                context[aftercare] = Aftercare.objects.get(id=record.item_id)
            except Aftercare.DoesNotExist:
                pass
    context['resident'] = resident
    return render(request, 'pregnant/aftercare_2_5_review.html', context)
Esempio n. 42
0
def body_exam_save(request, save_type):
    success = True
    resident = get_resident(request)
    record = WorkRecord.objects.filter(
        resident=resident,
        model_name='BodyExam',
        submit_time__gte=new_year_day()).first()
    form = BodyExamForm(request.POST)
    if form.is_valid():
        if record:
            submit_data = {
                field: value
                for field, value in form.cleaned_data.items()
                if value or value == 0
            }
            result, created = BodyExam.objects.update_or_create(
                id=record.item_id, defaults=submit_data)
            if created:
                debug.info('create a new record BodyExam !!!')
        else:
            result = form.save(commit=False)
            result.resident = resident
            result.save()
        body_exam_commit_workrecord(request, resident, result)
        if save_type == WorkRecord.SUSPEND:
            service_item = Service.objects.get(alias='body_exam_table',
                                               service_type__alias='old')
            WorkRecord.objects.create(provider=request.user,
                                      resident=resident,
                                      service_item=service_item,
                                      app_label='old',
                                      model_name='BodyExam',
                                      status=save_type,
                                      item_id=result.id,
                                      service_item_alias=service_item.alias)
    else:
        success = False
        debug.info(form.errors.as_data())
    return success
Esempio n. 43
0
def aftercare_form(request):
    resident = get_resident(request)
    item_alias = request.POST.get('item_alias')
    service_item = Service.objects.get(alias=item_alias,
                                       service_type__alias='psychiatric')
    try:
        record = WorkRecord.objects.get(resident=resident,
                                        service_item=service_item,
                                        submit_time__gte=new_year_day())
    except WorkRecord.DoesNotExist:
        form = AftercareForm()
        return render(request, 'psychiatric/psy_visit_form_content.html', {
            'form': form,
            'resident': resident
        })
    else:
        result = Aftercare.objects.get(id=record.item_id)
        form = AftercareForm(instance=result)
        return render(request, 'psychiatric/aftercare_review.html', {
            'form': form,
            'resident': resident
        })
Esempio n. 44
0
def body_exam_submit(request):
    """
    首先,检查是否提交了数据,如果没有提交数据返回失败
    其次,如果提交了数据,由于有前端js的检查,一般体格检查的所有数据字段都应该存在并符合取值范围
    :param request:
    :return:
    """
    resident = get_resident(request)
    record = WorkRecord.objects.filter(resident=resident, model_name='BodyExam',
                                       submit_time__gte=new_year_day()).first()
    if record:
        form = BodyExamForm(request.POST)
        if form.is_valid():
            submit_data = {field: value for field, value in form.cleaned_data.items() if value or value == 0}
            result, created = BodyExam.objects.update_or_create(id=record.item_id, defaults=submit_data)
            if created:
                debug.info('create a new BodyExam record')
            success, message = True, u'保存数据完成'
        else:
            debug.info(form.errors.as_data())
            success, message = False, u'输入数据有误'
    else:
        form = BodyExamForm(request.POST)
        if form.is_valid():
            result = form.save()
            success, message = True, u'保存数据完成'
        else:
            debug.info(form.errors.as_data())
            success, message = False, u'数据保存到数据库时失败'
    if success:
        service_item = Service.items.get(alias='physical_examination',
                                         service_type__alias='hypertension')
        WorkRecord.objects.create(provider=request.user, resident=resident, service_item=service_item,
                                  app_label='hypertension', model_name='BodyExam',
                                  item_id=result.id, service_item_alias=service_item.alias)
        message = u'记录保存成功'
    return HttpResponse(simplejson.dumps({'success': success, 'message': message}),
                        content_type='text/html; charset=UTF-8')
Esempio n. 45
0
def postpartum_visit_table(request):
    resident = get_resident(request)
    service_item = Service.objects.get(alias='postpartum_visit',
                                       service_type__alias='pregnant')
    try:
        record = WorkRecord.objects.get(resident=resident,
                                        service_item=service_item)
    except WorkRecord.DoesNotExist:
        form = PostpartumVisitForm()
        return render(request, 'pregnant/postpartum_form_content.html', {
            'form': form,
            'resident': resident
        })
    else:
        # result = PostpartumVisit.objects.get(id=record.item_id)
        # form = PostpartumVisitForm(instance=result)
        # return render(request, 'pregnant/postpartum_review_content.html', {'form': form, 'resident': resident})
        form = PostpartumVisit.objects.get(id=record.item_id)
        return render(request, 'pregnant/postpartum_visit_review_content.html',
                      {
                          'form': form,
                          'resident': resident
                      })
Esempio n. 46
0
def aftercare_2_5_form(request):
    aftercare = request.POST.get('aftercare')
    form = AftercareForm()
    resident = get_resident(request)
    template = 'pregnant/antenatal_%s_form_content.html' % aftercare
    return render(request, template, {'form': form, 'resident': resident})
Esempio n. 47
0
def personal_info_page(request):
    resident = get_resident(request)
    form = PsychiatricInfoForm()
    return render(request, 'psychiatric/personal_info.html',
                  {'form': form, 'resident': resident})
Esempio n. 48
0
def child_form(request):
    item_alias = request.POST.get('item_alias')
    form = AftercareForm()
    resident = get_resident(request)
    template = 'tcm/child_form.html'
    return render(request, template, {'form': form, 'resident': resident, 'item_alias': item_alias})
Esempio n. 49
0
def aftercare_2_5_form(request):
    aftercare = request.POST.get('aftercare')
    form = AftercareForm()
    resident = get_resident(request)
    template = 'pregnant/antenatal_%s_form_content.html' % aftercare
    return render(request, template, {'form': form, 'resident': resident})