コード例 #1
0
ファイル: api.py プロジェクト: alexdiao/quantmd
def upload_analysis(request, case_id, admin_id):
    try:
        try:
            case = Case.objects.get(pk=case_id)
        except:
            d = {'code':1, 'error_msg':'No such case'}
            return HttpResponse(json.dumps(d))
        try:
            admin = Profile.objects.get(pk=admin_id, role=0)
        except:
            d = {'code':1, 'error_msg':'No such user or this user is not admin'}
            return HttpResponse(json.dumps(d))
        analysis = Analysis(admin=admin, content='Analysis files uploaded.')
        analysis.save()
        case.status = 3
        case.save()
        d = {'code':0}
        return HttpResponse(json.dumps(d)) 
    except:
        d = {'code':1, 'error_msg':'API system has an error when processing your request.'}
        return HttpResponse(json.dumps(d)) 
コード例 #2
0
ファイル: quantmd.py プロジェクト: alexdiao/quantmd
def process_case_action(request):
    """Store the files in 'analysis' folder and save analysis"""
    analysis = Analysis()
    analysis.admin_id = request.user.pk
    analysis.content = request.POST['analysis']
    analysis.save()
    
    case_id = request.POST['case_id']
    case = Case.objects.get(pk=case_id)
    case.analysis =  analysis
    case.status = 3
    case.save()

    appointment = Appointment.objects.filter(case = case, is_current = True, is_cancelled = False)[0]
    
    title = 'Analysis is available for CASE #' + str(case.id) 
    title = title.upper()
    content = 'Analysis is available for CASE #: ' + str(case.id)
    message = Message.objects.create(receiver = appointment.doctor, case = case, title = title, content = content, type = 5, is_sys = True)
    message.save()
        
    return redirect('main.views.quantmd.process_cases')