Esempio n. 1
0
def getSeriesRiImages(case_id, index_1):
    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_msgessage'] = "logged in user do not have permission to acccess this case"
        return jsonify(result)

    series_result = PatientCases.findSeries(case_id, index_1)

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

    if 't2' not in series_result[
            'series_description'] and 'T2' not in series_result[
                'series_description']:
        result['error']['error'] = True
        result['error'][
            'error_msgessage'] = "The series selected is not a T2 series. Cannot be RI mapped"
        return jsonify(result)

    result['error']['error'] = False
    result['images'] = []

    i = 0
    for image in series_result['images']:
        img = {}
        img['filename'] = image['org_filename']
        img['url'] = BASE_URL + url_for('patient_cases_api.getRiMappedImage',
                                        case_id=case_id,
                                        index_1=index_1,
                                        index_2=i)
        i += 1
        result['images'].append(img)

    return jsonify(result)
Esempio n. 2
0
def getImage(case_id, index_1, index_2):
    # get the case from db
    series = PatientCases.findSeries(case_id, index_1)
    if series == None:
        abort(404)
    elif PatientCases.userHasAuthentication(case_id, session['username']):
        result = {
            'status': 'success',
            'series': series,
            'index_1': index_1,
            'index_2': index_2
        }
    else:
        result = {
            'status': 'error',
            'msg':
            'You do not have sufficient authentication to access the file'
        }
    return render_template('image-view.html', result=result)
Esempio n. 3
0
def getImageCount(case_id, index_1):
    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)

    series_result = PatientCases.findSeries(case_id, index_1)

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

    result['error']['error'] = False
    result['count'] = len(series_result['images'])

    return jsonify(result)