def load_appointments(self, doctor_timezone): """ Load all of today's appointments for the logged in doctor """ access_token = self.get_token() api = AppointmentEndpoint(access_token) today = datetime.datetime.now() today = today.strftime('%Y-%m-%d') appointments = api.list(date=today) for a in appointments: patient = self.get_patient(a['patient']) patient_name = patient['first_name'] + ' ' + patient['last_name'] check_in_time = None seen_time = None print(a['status']) if a['status'] in ['In Session', 'Complete']: seen_time = datetime.datetime.now() elif a['status'] in ['Arrived', 'Checked In', 'In Room']: check_in_time = datetime.datetime.now() print('CHECKED IN') appointment = Appointment( drchrono_id=a['id'], doctor=a['doctor'], patient_name=patient_name, patient_id=a['patient'], scheduled_time=datetime.datetime.strptime( a['scheduled_time'], '%Y-%m-%dT%H:%M:%S'), duration=a['duration'], status=a['status'], check_in_time=check_in_time, seen_time=seen_time) appointment.save()
def addapp(request): fff = True teacherlist = Teacher.objects.all() c = Context({"teacherlist":teacherlist}) u=User.objects.all() for mu in u: mu1=mu if "seleted_teacher" in request.POST: tea=Teacher.objects.get(id=request.POST["seleted_teacher"]) apps = Appointment.objects.filter(tea_name = tea.Username) for t in apps: if t.app_time == request.POST["requestdate"]: fff = False if fff == True: new_appointment = Appointment( stu_name = mu1.Username, tea_name = tea.Username, app_time = request.POST["requestdate"], flag = "no") new_appointment.save() u=User.objects.all() for mu in u: mu1=mu applist=Appointment.objects.filter(stu_name=mu1.Username) c = Context({"applist":applist,}) return render_to_response("requestm.html",c) else: return HttpResponse("Time interrupt!") else: return render_to_response("request.html",c)
def new_appointment(app_id, fname, lname): appointment = Appointment() now = datetime.now() appointment.app_id = app_id appointment.time_of_arrival = now appointment.first_name = fname appointment.last_name = lname appointment.save()
def process_iden_conversation(msg, created=True, conv=None): resp = VoiceResponse() app.logger.info('customer is registered') conversation = new_conversation() if created: input_msg='' else: input_msg=request.form['SpeechResult'] if 'SpeechResult' in request.form else 'donno' app.logger.info('input_message [%s] created [%s]', input_msg, created) #conv.log_json() watson_response = new_conversation_msg(conversation, context=conv.context, input_msg=input_msg, first=False) conv.store_context() # check if watson identified the customer twilio_resp, watson_dialog = create_response(watson_response, conv, twilio_voice=resp) app.logger.info('output_message [%s] ', watson_dialog) if 'action' in conv.context: if conv.context['action'] == 'register_customer': cust=Customer.create( name=str(conv.context['name']).lower(), business=conv.business, phone=conv.call_number ) conv.customer = cust elif conv.context['action'] == 'create_app': app_date = conv.context['app_date'] app_time = conv.context['app_time'] start = datetime.strptime(f"{app_date} {app_time}", '%Y-%m-%d %H:%M:%S') end = start+timedelta(hours=float(conv.context['app_duration'])) appoint = Appointment( customer=conv.customer, note='tutoring', start=start, end=end ) app.logger.info(f"created a new appointment {start} to {end}") appoint.save() conv.context['success'] = 'true' elif conv.context['action'] == 'end': twilio_resp.hangup() conv.context.pop('action', None) conv.save() return str(resp)
def save_appointments(appointments): """ :param appointments: Saves Appointment """ for appt in appointments: appointment = Appointment( id=appt['id'], duration=appt['duration'], doctor=Doctor.objects.get(pk=appt['doctor']), patient=Patient.objects.get(pk=appt['patient']), office=Office.objects.get(pk=appt['office']), exam_room=appt['exam_room'], reason=appt['reason'], status=appt['status'], deleted_flag=appt['deleted_flag'], scheduled_time=appt['scheduled_time'], in_room_time=appt['scheduled_time'], ) print appointment appointment.save()
def create_appt(request): u = request.user if request.POST: d = request.POST['id'] t = date.today() + timedelta(days=1) doc = Usr.objects.filter(user_id=d, user_type='doctor') ptnt = Usr.objects.filter(user_id=u, user_type='patient') #Only 10 appointments can be made for a doctor in a day tx = date.today() + timedelta(days=3) x = Appointment.objects.filter(doctor=d, user_id=u, time__gte=date.today(), time__lte=tx, active=True) y = Appointment.objects.filter(time=t, doctor=d) t2 = date.today() + timedelta(days=2) y2 = Appointment.objects.filter(time=t2, doctor=d) t3 = date.today() + timedelta(days=3) y3 = Appointment.objects.filter(time=t3, doctor=d) if len(x) > 0: return render_to_response('appt_user_failure.html') else: if len(y) < 10: a = Appointment(a_id=uuid.uuid4(), user_id=u, patient_name=ptnt[0].name, doctor=d, doc_name=doc[0].name, dept=doc[0].extra, time=t, active=True, token=len(y) + 1) a.save() return render_to_response('appt_success.html', { 'date': t, 'token': len(y) + 1 }) elif len(y2) < 10: a = Appointment(a_id=uuid.uuid4(), user_id=u, patient_name=ptnt[0].name, doctor=d, doc_name=doc[0].name, dept=doc[0].extra, time=t2, active=True, token=len(y2) + 1) a.save() return render_to_response('appt_success.html', { 'date': t2, 'token': len(y2) + 1 }) elif len(y3) < 10: a = Appointment(a_id=uuid.uuid4(), user_id=u, patient_name=ptnt[0].name, doctor=d, doc_name=doc[0].name, dept=doc[0].extra, time=t3, active=True, token=len(y3) + 1) a.save() return render_to_response('appt_success.html', { 'date': t3, 'token': len(y3) + 1 }) else: return render_to_response('appt_failure.html')