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)
def get_next_patient(): """ Get next patient :return: None """ global is_arrived global appointment global office_no try: ds = DoctorService() res, data = ds.getDoctorByEmail(email) doctor_id = data['data']['id'] res, next_patient = ds.getNextPatientByDoctorId(doctor_id) if next_patient['code'] == 1: # send to another rasppi appointment = next_patient['data'] patient = next_patient['data']['patient']['name'] text = 'Your next patient is {}, I have already helped you notify the frent desk. Please wait for a moment.'.format( next_patient['data']['patient']['name']) aiy.audio.say(text) res = grpc_run(patient, office_no) is_arrived = res else: aiy.audio.say('You do not have any appointments yet!') except Exception as e: aiy.audio.say('You do not have any appointments yet!')
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)
def doctorsCalendar(): """ get doctor calendar :return: render page """ ds = DoctorService() res, doctors = ds.getAll() data = doctors['data'] return render_template('clerk/doctors_calendar.html', **clerkSetting(), doctors=data)
def doctorsList(): """ get doctor list :return:render page """ ds = DoctorService() res, doctors = ds.getAll() data = doctors['data'] return render_template('clerk/doctors.html', **clerkSetting(), doctors=data)
def patients(): """ get all patients :return: render page """ ds = DoctorService() doctorId = session['User']['id'] res, data = ds.getAllPatients(doctorId) return render_template('doctor/patients.html', **doctorSetting(), patients=data['data'])
def history(patient_id): """ get all history by patient id :param patient_id: patient id :return: render page """ ds = DoctorService() his, data = ds.getAppointmentsByPatientId(patient_id) return render_template('doctor/history.html', **doctorSetting(), history=data['data'])
def makeAppointment(): """ make an appointment :return: render page """ ds = DoctorService() res, doctors = ds.getAll() data = doctors['data'] return render_template('patient/calendar.html', **patientSetting(), doctors=data)
def edit_notes(notes): """ Edit notes for patient :param notes: notes :return: None """ global is_arrived global appointment ds = DoctorService() if is_arrived == '1': ds.editNotes(appointment['id'], notes) aiy.audio.say('Successfully added!') elif is_arrived == '2': aiy.audio.say('Please wait for patient to arrive first!')
def deleteFreeTime(): """ delete free time :return: json """ calendarId = session['User']['calendar_id'] freeId = request.form.getlist('freeid')[0] ds = DoctorService() 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)
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)
def editDiagnoses(appointment_id): """ edit diagnoses :param appointment_id: app id :return: render page """ ds = DoctorService() form = DiagnoseForm(request.form) res, data = ds.getAppointmentById(appointment_id) if request.method == 'POST' and form.validate(): res = ds.editDiags(appointment_id, form.description.data) else: form.description.data = data['data']['diagnoses'] return render_template( 'doctor/edit_diagnoses.html', **doctorSetting(), form=form, address='/doctor/edit_diagnoses/{}'.format(appointment_id))
def addDoctor(): """ add a doctor :return: render page or redirect """ form = AddDoctorForm(request.form) if request.method == 'POST' and form.validate(): # pass the validation, request API ds = DoctorService() dd = form.data dd['created_at'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) payload = {'doctor': dd} res, data = ds.register(payload) if res: return redirect(url_for('clerk.doctorsList')) return render_template('clerk/add_doctor.html', **clerkSetting(), form=form)
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)