Ejemplo n.º 1
0
def setFreeTime(doctor_id):
    """
    set free time for doctor
    :param doctor_id: doctor id
    :return: json
    """
    start = request.form.getlist('start')[0]
    end = request.form.getlist('end')[0]
    ds = DoctorService()
    res, data = ds.getDoctorById(doctor_id)
    payload = {
        'doctor_email': data['data']['email'],
        'doctor_id': doctor_id,
        'start': start,
        'end': end
    }
    res, data = ds.setFreeTime(payload)
    if res:
        return make_response(
            jsonify({
                'code': 1,
                'msg': 'Successfully Set!',
                'data': data['data']
            }), 201)
    else:
        return make_response(jsonify({'code': -1, 'msg': 'Failed'}), 400)
Ejemplo n.º 2
0
def getFreeTime(doctor_id):
    """
    get free time
    :param doctor_id: doctor id
    :return: json
    """
    ds = DoctorService()
    res, data = ds.getDoctorById(doctor_id)
    calendarId = data['data']['calendar_id']
    if calendarId is None:
        return make_response(
            jsonify({
                'code': 1,
                'msg': 'Successfully Get!',
                'data': []
            }), 201)

    res, data = ds.getFreeTime(calendarId)
    if res:
        return make_response(
            jsonify({
                'code': 1,
                'msg': 'Successfully Get!',
                'data': data['data']
            }), 201)
    else:
        return make_response(jsonify({'code': -1, 'msg': 'Failed'}), 400)
Ejemplo n.º 3
0
def getDoctor(doctor_id):
    """
    get one doctor
    :param doctor_id: doctor id
    :return: json
    """
    ds = DoctorService()
    res, data = ds.getDoctorById(doctor_id)
    if res:
        return make_response(
            jsonify({
                'code': 1,
                'msg': 'Successfully Fetched!',
                'data': data['data']
            }), 201)
    else:
        return make_response(jsonify({'code': -1, 'msg': 'Failed'}), 400)
Ejemplo n.º 4
0
def deleteFreeTime(doctor_id):
    """
    delete free time
    :param doctor_id: doctor id
    :return: json
    """
    ds = DoctorService()
    res, data = ds.getDoctorById(doctor_id)
    calendarId = data['data']['calendar_id']
    freeId = request.form.getlist('freeid')[0]

    res, data = ds.deleteFreeTime(calendarId, freeId)
    if res:
        return make_response(
            jsonify({
                'code': 1,
                'msg': 'Successfully Deleted!'
            }), 201)
    else:
        return make_response(jsonify({'code': -1, 'msg': 'Failed'}), 400)