Exemplo n.º 1
0
def getAllCaseImages(case_id):
    result = {'error': {}}
    #if username is in session then the call is web call, so use that username
    if 'username' in session and len(session['username']) > 0:
        username = session['username']
    else:
        if 'key' not in request.args or len(request.args['key']) == 0:
            result['error']['error'] = True
            result['error']['error_msgessage'] = "key not specified"
            return jsonify(result)

        auth_result = Auth.checkKeyValidity(request.args['key'])

        if not auth_result['valid']:
            result['error']['error'] = True
            result['error']['error_msgessage'] = "key not valid"
            return jsonify(result)

        username = auth_result['username']

    if not PatientCases.userHasAuthentication(case_id, username):
        result['error']['error'] = True
        result['error'][
            'error_msgessage'] = "logged in user do not have permission to acccess this case"
        return jsonify(result)

    case_result = PatientCases.findCase(case_id)

    if case_result == None:
        result['error']['error'] = True
        result['error']['error_msgessage'] = "Case id not valid"
        return jsonify(result)

    #Now that the authentication is done process the result and respond according to the api refference
    #take the files from the case result
    files = case_result['files']
    result['error']['error'] = False
    result['images'] = []
    i = 0  #to keep track of index_1
    for file in files:
        series = {}
        series['series_description'] = file['series_description']
        series['series_time'] = file['series_time']
        series['images'] = []
        j = 0  #to keep track of index_2
        for image in file['images']:
            img = {}
            img['filename'] = image['org_filename']
            img['url'] = BASE_URL + url_for('patient_cases_api.getImage',
                                            case_id=case_id,
                                            index_1=i,
                                            index_2=j)
            j += 1
            series['images'].append(img)
        i += 1
        result['images'].append(series)

    return jsonify(result)
Exemplo n.º 2
0
def getSeriesCount(case_id):
    result = {'error': {}}
    #if username is in session then the call is web call, so use that username
    if 'username' in session and len(session['username']) > 0:
        username = session['username']
    else:
        if 'key' not in request.args or len(request.args['key']) == 0:
            result['error']['error'] = True
            result['error']['error_msgessage'] = "key not specified"
            return jsonify(result)

        auth_result = Auth.checkKeyValidity(request.args['key'])

        if not auth_result['valid']:
            result['error']['error'] = True
            result['error']['error_msgessage'] = "key not valid"
            return jsonify(result)

        username = auth_result['username']

    if not PatientCases.userHasAuthentication(case_id, username):
        result['error']['error'] = True
        result['error'][
            'error_msgessage'] = "logged in user do not have permission to acccess this case"
        return jsonify(result)

    case_result = PatientCases.findCase(case_id)

    if case_result == None:
        result['error']['error'] = True
        result['error']['error_msgessage'] = "Case id not valid"
        return jsonify(result)

    result['error']['error'] = False
    result['count'] = len(case_result['files'])

    return jsonify(result)
Exemplo n.º 3
0
    cases = PatientCases.find(session['username'])
    return render_template('case-view.html',
                           result={
                               'status': 'success',
                               'cases': cases
                           })


#the page to view all the series in a case
#return 403 if the logged in user is not authorized to access the image
@case_bp.route('/<case_id>/images/', methods=['GET'])
@case_bp.route('/<case_id>/', methods=['GET'])
@login_required
def getCase(case_id):
    # get the case from db
    case = PatientCases.findCase(case_id)
    if case == None:
        abort(404)
    elif PatientCases.userHasAuthentication(case_id, session['username']):
        result = {'status': 'success', 'case': case}
    else:
        result = {
            'status': 'error',
            'msg':
            'You do not have sufficient authentication to access the file'
        }
    return render_template('series-view.html', result=result)


#the page to view all the images in a series
#return 403 if the logged in user is not authorized to access the image