Exemplo n.º 1
0
def medical_staff_id_route(staff_id):
    if request.method == 'GET':
        try:
            params = {
                'medical_type': request.args.get('type'),
                'staff_id': staff_id
            }
            return jsonify(staff.getMedicalStaff(**params))
        except Exception:
            return '', 500
    elif request.method == 'PATCH':
        try:
            params = {'staff_id': staff_id}
            keys = [
                'sex', 'salary', 'mobile_tel', 'home_tel', 'email', 'address',
                'firstname', 'lastname'
            ]
            for key in keys:
                if key in request.form:
                    params[key] = request.form[key]
            staff.edit(**params)
            return '', 200
        except Exception:
            return '', 500
    elif request.method == 'DELETE':
        try:
            staff.delete(staff_id)
            return '', 200
        except Exception:
            return '', 500
Exemplo n.º 2
0
def medical_staff_route():
    try:
        params = {
            'medical_type': request.args.get('type'),
            'staff_id': request.args.get('id')
        }
        return jsonify(staff.getMedicalStaff(**params))
    except Exception:
        return '', 500
Exemplo n.º 3
0
def medical_staff_nurse_route():
    if request.method == 'GET':
        try:
            params = {'medical_type': 'Nurse', 'staff_id': None}
            return jsonify(staff.getMedicalStaff(**params))
        except Exception:
            return '', 500
    elif request.method == 'POST':
        try:
            params = {
                'sex':
                request.form['sex'],
                'salary':
                request.form['salary'],
                'mobile_tel':
                request.form['mobile_tel'],
                'home_tel':
                request.form['home_tel'],
                'email':
                request.form['email'],
                'address':
                request.form['address'],
                'nurse_type':
                request.form['nurse_type'],
                'birthdate':
                parser.parse(request.form['birthdate']).strftime('%Y-%m-%d'),
                'nurse_type':
                request.form['nurse_type'],
                'firstname':
                request.form['firstname'],
                'lastname':
                request.form['lastname']
            }
            staff.insertNurse(**params)
            return '', 200
        except HTTPException:
            return jsonify({'message': 'Arguments are invalid'}), 400
        except Exception as e:
            print(e)
            return '', 500