コード例 #1
0
ファイル: views.py プロジェクト: bmufangt/public_health
def record_detail_review(request):
    record_id = int(request.POST.get('record_id'))
    record = WorkRecord.objects.get(id=record_id)
    if record.status == WorkRecord.SUSPEND:
        if record.app_label == 'old' and record.service_item.alias == 'body_exam_table':
            result = BodyExam.objects.get(id=record.item_id)
            form = BodyExamForm(instance=result)
            return render(
                request, 'ehr/body_exam_form.html', {
                    'form': form,
                    'resident': record.resident,
                    'type_alias': record.app_label
                })
        elif record.app_label == 'psychiatric' and record.service_item.alias == 'body_exam_table':
            result = BodyExam.objects.get(id=record.item_id)
            form = BodyExamForm(instance=result)
            return render(
                request, 'ehr/body_exam_form.html', {
                    'form': form,
                    'resident': record.resident,
                    'type_alias': record.app_label
                })
        elif record.app_label == 'pregnant' and record.service_item.alias == 'aftercare_1':
            result = PregnantAftercare1.objects.get(id=record.item_id)
            form = PregnantAftercare1Form(instance=result)
            return render(request, 'pregnant/antenatal_1_form_content.html', {
                'form': form,
                'resident': record.resident
            })

    elif record.status == WorkRecord.FINISHED or record.status == WorkRecord.SUSPEND_SUBMIT:
        return ehr_record_review(request)
コード例 #2
0
ファイル: views.py プロジェクト: 1330018801/public_health
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
コード例 #3
0
ファイル: views.py プロジェクト: 1330018801/public_health
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')
コード例 #4
0
ファイル: views.py プロジェクト: bmufangt/public_health
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')
コード例 #5
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'
    })
コード例 #6
0
ファイル: views.py プロジェクト: 1330018801/public_health
def body_exam_suspend_submit(request, record):
    form = BodyExamForm(request.POST)
    if form.is_valid():
        submit_data = {field: value for field, value in form.cleaned_data.items() if value}
        result, created = BodyExam.objects.update_or_create(id=record.item_id, defaults=submit_data)
        if created:
            debug.info('create a new record BodyExam !!!')
        body_exam_commit_workrecord(request, record.resident, result)
        record.status = WorkRecord.SUSPEND_SUBMIT
        record.save()
        success = True
    else:
        success = False
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
コード例 #7
0
ファイル: views.py プロジェクト: bmufangt/public_health
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'
    })
コード例 #8
0
def body_exam_suspend_submit(request, record):
    form = BodyExamForm(request.POST)
    if form.is_valid():
        submit_data = {
            field: value
            for field, value in form.cleaned_data.items() if value
        }
        result, created = BodyExam.objects.update_or_create(
            id=record.item_id, defaults=submit_data)
        if created:
            debug.info('create a new record BodyExam !!!')
        body_exam_commit_workrecord(request, record.resident, result)
        record.status = WorkRecord.SUSPEND_SUBMIT
        record.save()
        success = True
    else:
        success = False
    return HttpResponse(simplejson.dumps({'success': success}),
                        content_type='text/html; charset=UTF-8')
コード例 #9
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')
コード例 #10
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
コード例 #11
0
ファイル: views.py プロジェクト: 1330018801/public_health
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')
コード例 #12
0
ファイル: views.py プロジェクト: bmufangt/public_health
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')