Exemplo n.º 1
0
def child_add(request):
    child = Resident()
    child.name = request.POST.get('name')
    child.gender = int(request.POST.get('gender'))
    child.nation = request.POST.get('nation')

    birthday = request.POST.get('birthday')
    child.birthday = datetime.strptime(birthday, '%Y-%m-%d')
    if request.user.userprofile.clinic.region.is_town:
        town = request.user.userprofile.clinic.region
        village = None
    else:
        village = request.user.userprofile.clinic.region
        town = village.town
    child.town = town
    child.village = village

    resident_id = request.session['resident_id']
    resident = Resident.objects.get(id=int(resident_id))

    child.family = resident.family
    child.save()
    return HttpResponse(simplejson.dumps({
        'success': True,
        'message': 'OK'
    }),
                        content_type='text/html; charset=UTF-8')
Exemplo n.º 2
0
def real_read_card(request):
    resident_name = request.POST.get('name')
    birthday = request.POST.get('birthday')
    gender = request.POST.get('gender')
    nation = request.POST.get('nation')
    address = request.POST.get('address')
    identity = request.POST.get('identity')
    try:
        resident = Resident.objects.get(identity=identity)
    except Resident.DoesNotExist:
        resident = Resident()
        resident.name = resident_name
        resident.gender = gender
        if len(birthday) != 8:
            resident.birthday = '1900-01-01'
        else:
            resident.birthday = birthday[0:4] + '-' + birthday[
                4:6] + '-' + birthday[6:8]
        resident.nation = nation
        resident.address = address
        resident.identity = identity
        resident.save()

    request.session['resident_id'] = resident.id
    request.session['resident_name'] = resident.name
    request.session['resident_ehr_no'] = resident.ehr_no
    json_data = model_to_dict(resident, fields=['id', 'name', 'ehr_no'])

    return JsonResponse(json_data)
Exemplo n.º 3
0
def inspection_add(request):
    place_content = request.POST.get('place_content')
    main_problem = request.POST.get('main_problem')
    inspection_date = request.POST.get('inspection_date')
    inspector = request.POST.get('inspector')
    remarks = request.POST.get('remarks')

    inspection = Inspection(institution=Clinic.objects.get(id=1), place_content=place_content,
                            main_problem=main_problem, inspector=inspector, remarks=remarks,
                            inspection_date=datetime.strptime(inspection_date, '%Y-%m-%d').date(),
                            create_by=request.user)
    inspection.save()

    # 保存服务记录,用于统计工作量
    try:
        resident = Resident.objects.get(name='群体')
    except Resident.DoesNotExist:
        resident = Resident(name='群体', gender=2, nation='汉族', birthday=timezone.now().date())
        resident.save()
    service_item = Service.objects.get(service_type__alias='supervision', alias='patrol')
    record = WorkRecord(provider=request.user, resident=resident, service_item=service_item,
                        app_label='supervision', model_name='Inspection',
                        service_item_alias=service_item.alias, item_id=inspection.id)
    record.save()

    return JsonResponse({'success': True})
Exemplo n.º 4
0
def inspection_add(request):
    place_content = request.POST.get('place_content')
    main_problem = request.POST.get('main_problem')
    inspection_date = request.POST.get('inspection_date')
    inspector = request.POST.get('inspector')
    remarks = request.POST.get('remarks')

    inspection = Inspection(institution=Clinic.objects.get(id=1),
                            place_content=place_content,
                            main_problem=main_problem,
                            inspector=inspector,
                            remarks=remarks,
                            inspection_date=datetime.strptime(
                                inspection_date, '%Y-%m-%d').date(),
                            create_by=request.user)
    inspection.save()

    # 保存服务记录,用于统计工作量
    try:
        resident = Resident.objects.get(name='群体')
    except Resident.DoesNotExist:
        resident = Resident(name='群体',
                            gender=2,
                            nation='汉族',
                            birthday=timezone.now().date())
        resident.save()
    service_item = Service.objects.get(service_type__alias='supervision',
                                       alias='patrol')
    record = WorkRecord(provider=request.user,
                        resident=resident,
                        service_item=service_item,
                        app_label='supervision',
                        model_name='Inspection',
                        service_item_alias=service_item.alias,
                        item_id=inspection.id)
    record.save()

    return JsonResponse({'success': True})
Exemplo n.º 5
0
def child_add(request):
    child = Resident()
    child.name = request.POST.get('name')
    child.gender = int(request.POST.get('gender'))
    child.nation = request.POST.get('nation')

    birthday = request.POST.get('birthday')
    child.birthday = datetime.strptime(birthday, '%Y-%m-%d')
    if request.user.userprofile.clinic.region.is_town:
        town = request.user.userprofile.clinic.region
        village = None
    else:
        village = request.user.userprofile.clinic.region
        town = village.town
    child.town = town
    child.village = village

    resident_id = request.session['resident_id']
    resident = Resident.objects.get(id=int(resident_id))

    child.family = resident.family
    child.save()
    return HttpResponse(simplejson.dumps({'success': True, 'message': 'OK'}),
                        content_type='text/html; charset=UTF-8')
Exemplo n.º 6
0
def test_card(request):
    name = request.GET.get('name')
    birthday = request.GET.get('birthday')
    gender = request.GET.get('gender')
    nation = request.GET.get('nation')
    address = request.GET.get('address')
    identity = request.GET.get('identity')

    try:
        resident = Resident.objects.get(identity=identity)
    except Resident.DoesNotExist:
        resident = Resident()
        resident.name = name
        resident.gender = gender
        try:
            year, month, day = int(birthday[:4]), int(birthday[4:6]), int(
                birthday[6:8])
        except Exception:
            pass
        else:
            resident.birthday = date(year, month, day)
        resident.nation = nation
        resident.address = address
        resident.identity = identity
        resident.save()
    finally:
        candidates = list()
        candidates.append(resident)
        if resident.family:
            for member in resident.family.members.all():
                if member is not resident and member.identity is None:
                    candidates.append(member)

        json_candidates = serializers.serialize("json", candidates)
        return HttpResponse(json_candidates,
                            content_type="application/javascript")
Exemplo n.º 7
0
def info_report_add(request):
    discover_time = datetime.strptime(request.POST.get('discover_time'), '%Y-%m-%d %H:%M:%S')
    discover_time = bj_tz.localize(discover_time)
    info_type = request.POST.get('info_type')
    info_content = request.POST.get('info_content', '')
    reporter = request.POST.get('reporter')

    # 保存服务结果的内容
    info_report = InfoReport(institution=Clinic.objects.get(id=1), discover_time=discover_time,
                             info_type=info_type, info_content=info_content, reporter=reporter)
    info_report.save()

    # 保存服务记录,用于统计工作量
    try:
        crowd = Resident.objects.get(name='群体')
    except Resident.DoesNotExist:
        crowd = Resident(name='群体', gender=2, nation='汉族', birthday=date.today())
        crowd.save()
    service_item = Service.objects.get(service_type__alias='supervision', alias='information_report')
    record = WorkRecord(provider=request.user, resident=crowd, service_item=service_item,
                        app_label='supervision', model_name='InfoReport',
                        service_item_alias=service_item.alias, item_id=info_report.id)
    record.save()
    return JsonResponse({'success': True})
Exemplo n.º 8
0
def info_report_add(request):
    discover_time = datetime.strptime(request.POST.get('discover_time'),
                                      '%Y-%m-%d %H:%M:%S')
    discover_time = bj_tz.localize(discover_time)
    info_type = request.POST.get('info_type')
    info_content = request.POST.get('info_content', '')
    reporter = request.POST.get('reporter')

    # 保存服务结果的内容
    info_report = InfoReport(institution=Clinic.objects.get(id=1),
                             discover_time=discover_time,
                             info_type=info_type,
                             info_content=info_content,
                             reporter=reporter)
    info_report.save()

    # 保存服务记录,用于统计工作量
    try:
        crowd = Resident.objects.get(name='群体')
    except Resident.DoesNotExist:
        crowd = Resident(name='群体',
                         gender=2,
                         nation='汉族',
                         birthday=date.today())
        crowd.save()
    service_item = Service.objects.get(service_type__alias='supervision',
                                       alias='information_report')
    record = WorkRecord(provider=request.user,
                        resident=crowd,
                        service_item=service_item,
                        app_label='supervision',
                        model_name='InfoReport',
                        service_item_alias=service_item.alias,
                        item_id=info_report.id)
    record.save()
    return JsonResponse({'success': True})
Exemplo n.º 9
0
def personal_info_submit(request):
    resident_id = request.POST.get('resident_id')
    if resident_id:
        resident_id = int(resident_id)
        resident = Resident.objects.get(id=resident_id)
    else:  # 创建一个新的居民对象
        from services.utils import gender_map

        gender = gender_map().index(request.POST.get('gender'))
        nation = request.POST.get('nation')
        if nation == u'少数民族' and request.POST.get('nation_extra'):
            nation = request.POST.get('nation_extra')
        if request.user.userprofile.clinic.region.is_town:
            town = request.user.userprofile.clinic.region
            village = None
        else:
            village = request.user.userprofile.clinic.region
            town = village.town
        resident = Resident(name=request.POST.get('resident_name'),
                            gender=gender, nation=nation,
                            town=town, village=village,
                            birthday=request.POST.get('birthday'),
                            address=request.POST.get('address'),
                            identity=request.POST.get('identity'),
                            mobile=request.POST.get('phone'),
                            create_by=request.user)
        resident.save()

    form = PersonalInfoForm(request.POST)
    if form.is_valid():
        personal_info = form.save()
        resident.personal_info_table = personal_info
        record = WorkRecord(resident=resident, provider=request.user,
                            service_item_alias='personal_info_table',
                            item_id=personal_info.id)
        record.save()
        '''
        以下是自动生成健康档案编号的方法,但是需求手动设置健康档案编号
        if resident.village:
            village = resident.village
            village.ehr_no += 1
            resident.ehr_no = village.id + '%05d' % village.ehr_no
            village.save()
        else:
            resident.ehr_no = '13108200000000000'
        '''
        if resident.ehr_no is None:
            ehr_village_no = int(request.POST.get('ehr_village_no'))  # 由于是必填项,而且是数字类型,所以在此不必检查类型
            ehr_unique_no = int(request.POST.get('ehr_unique_no'))  # 由于是必填项,而且是数字类型,所以在此不必检查类型
            town_no = request.user.userprofile.clinic.town_clinic.region.id
            resident.ehr_no = town_no + '%03d' % ehr_village_no + '%05d' % ehr_unique_no
            resident.save()

        if resident.identity is None and personal_info.identity is not None:
            resident.identity = personal_info.identity
            resident.save()
        elif resident.identity is not None and personal_info.identity is not None:
            if resident.identity != personal_info.identity:
                resident.identity = personal_info.identity
                resident.save()

        if resident.mobile is None and personal_info.phone is not None:
            resident.mobile = personal_info.phone
            resident.save()
        elif resident.mobile is not None and personal_info.phone is not None:
            if resident.mobile != personal_info.phone:
                resident.mobile = personal_info.phone
                resident.save()

        success = True
    else:
        success = False
    return json_result({'success': success, 'resident_id': resident.id})
Exemplo n.º 10
0
def personal_info_submit(request):
    resident_id = request.POST.get('resident_id')
    if resident_id:
        resident_id = int(resident_id)
        resident = Resident.objects.get(id=resident_id)
    else:  # 创建一个新的居民对象
        from services.utils import gender_map

        gender = gender_map().index(request.POST.get('gender'))
        nation = request.POST.get('nation')
        if nation == u'少数民族' and request.POST.get('nation_extra'):
            nation = request.POST.get('nation_extra')
        if request.user.userprofile.clinic.region.is_town:
            town = request.user.userprofile.clinic.region
            village = None
        else:
            village = request.user.userprofile.clinic.region
            town = village.town
        resident = Resident(name=request.POST.get('resident_name'),
                            gender=gender,
                            nation=nation,
                            town=town,
                            village=village,
                            birthday=request.POST.get('birthday'),
                            address=request.POST.get('address'),
                            identity=request.POST.get('identity'),
                            mobile=request.POST.get('phone'),
                            create_by=request.user)
        resident.save()

    form = PersonalInfoForm(request.POST)
    if form.is_valid():
        personal_info = form.save()
        resident.personal_info_table = personal_info
        record = WorkRecord(resident=resident,
                            provider=request.user,
                            service_item_alias='personal_info_table',
                            item_id=personal_info.id)
        record.save()
        '''
        以下是自动生成健康档案编号的方法,但是需求手动设置健康档案编号
        if resident.village:
            village = resident.village
            village.ehr_no += 1
            resident.ehr_no = village.id + '%05d' % village.ehr_no
            village.save()
        else:
            resident.ehr_no = '13108200000000000'
        '''
        if resident.ehr_no is None:
            ehr_village_no = int(request.POST.get(
                'ehr_village_no'))  # 由于是必填项,而且是数字类型,所以在此不必检查类型
            ehr_unique_no = int(
                request.POST.get('ehr_unique_no'))  # 由于是必填项,而且是数字类型,所以在此不必检查类型
            town_no = request.user.userprofile.clinic.town_clinic.region.id
            resident.ehr_no = town_no + '%03d' % ehr_village_no + '%05d' % ehr_unique_no
            resident.save()

        if resident.identity is None and personal_info.identity is not None:
            resident.identity = personal_info.identity
            resident.save()
        elif resident.identity is not None and personal_info.identity is not None:
            if resident.identity != personal_info.identity:
                resident.identity = personal_info.identity
                resident.save()

        if resident.mobile is None and personal_info.phone is not None:
            resident.mobile = personal_info.phone
            resident.save()
        elif resident.mobile is not None and personal_info.phone is not None:
            if resident.mobile != personal_info.phone:
                resident.mobile = personal_info.phone
                resident.save()

        success = True
    else:
        success = False
    return json_result({'success': success, 'resident_id': resident.id})