def __create_if_post_method(request, context): if request.method == 'POST': try: doctor = __get_create_attribute_from_request(request) work_service_provider.doctor_management_service().create_doctor(doctor) context['saved'] = True except Exception as e: print(e) context['saved'] = False
def list_doctors(request): doctors = work_service_provider.doctor_management_service().list_doctors() context = { 'title': 'Doctor', 'doctors': doctors, } return render(request, 'doctor/list_doctor.html', context)
def __create_if_post_method(request, context): if request.method == 'POST': try: appointment = __get_create_attribute_from_request(request) doctor_id = appointment.doctor_id doctor = work_service_provider.doctor_management_service( ).get_doctor_number(doctor_id) doctor_number = doctor.doctor_number appointment_date = appointment.appointment_datetime appointment_schedule = work_service_provider.doctor_management_service( ).get_schedule(doctor_number=doctor_number) appointment_schedules = appointment_schedule.appointment_schedule appointments = work_service_provider.appointment_management_service( ).get_appointment_by_date(appointment_date, doctor_id) number_of_appointments = len(appointments) if number_of_appointments < appointment_schedules: work_service_provider.appointment_management_service( ).create_appointment(appointment) context['saved'] = True else: context['saved'] = False except Exception as e: print(e) context['saved'] = False
def create_appointment_for_staff(request): patients = work_service_provider.patient_management_service( ).get_all_for_select_list() doctors = work_service_provider.doctor_management_service( ).get_all_for_select_list_doc() context = { 'appointment_number': str(uuid.uuid4()).replace("-", '')[0:10].upper(), 'appointment_reference': uuid.uuid4(), 'patients': patients, 'doctors': doctors, } __create_if_post_method(request, context) if request.method == ['POST'] and context['saved']: return redirect('patient_home') return render(request, 'staff/appointment_for staff.html', context)
def create_medical_record(request): patient = work_service_provider.patient_management_service( ).get_all_for_select_list() med_id = uuid.uuid4() id = request.user.staff.id doctor = work_service_provider.doctor_management_service().doctor_details( id) med_number = str(uuid.uuid4()).replace("-", '')[0:10].upper() context = { 'patient': patient, 'doctor': doctor, 'med_id': med_id, 'med_number': med_number } __create_if_post_method(request, context) if request.method == 'POST' and context['saved']: return redirect('doctor_home') return render(request, 'medical_record/create_med_red.html', context)
def doctor_home(request): first_name = request.user.first_name last_name = request.user.last_name id = request.user.staff.id doctor = work_service_provider.doctor_management_service().doctor_details(id) appointment_date = datetime.datetime.now().date() doctor_id = doctor.id appointments = work_service_provider.appointment_management_service().get_appointment_for_doctor(appointment_date, doctor_id) length = len(appointments) context = { 'first_name': first_name, 'last_name': last_name, 'doctor': doctor, 'appointments': appointments, 'length': length } return render(request, 'doctor/doctorHome.html', context)
def __get_doctor_details_or_raise_404(doctor_id): try: doctor = work_service_provider.doctor_management_service().doctor_details(doctor_id) except Doctor.DoesNotExist: raise Http404('Appointment does not exits') return doctor