def updateRatings(name, typeUser): if typeUser == 'centre': centre = centreManager.searchHealthCentresByName(name)[0] centre.updateRating(current_user.get_id(), int(request.form['updateRatingBox'])) saveData(centreManager, userManager, appointmentManager) return redirect(url_for('profile', loggedInUser=current_user.get_id(), typeUser=typeUser, name=name), code=307) elif typeUser == 'provider': if appointmentManager.appointmentCompleted(current_user, name) == True: provider = userManager.getID(name) provider.updateRating(current_user.get_id(), int(request.form['updateRatingBox'])) saveData(centreManager, userManager, appointmentManager) return redirect(url_for('profile', loggedInUser=current_user.get_id(), typeUser=typeUser, name=name), code=307) else: provider = userManager.searchID(name) return render_template( "profile.html", loggedInUser=current_user.get_id(), option="provider", provider=provider[0], error= "No History with this provider! No Rating can be provided.")
def successfulUpdate(): if request.method == 'POST': date = request.form['date'] time = request.form['time'] user = userManager.getID(request.form['patient']) appointment = appointmentManager.getAppointmentUsingDate( user, date, time) currentDate = request.form['currentDate'] currentTime = request.form['currentTime'] currentPatient = userManager.getID(request.form['currentPatient']) currentAppointment = appointmentManager.getAppointmentUsingDate( currentPatient, currentDate, currentTime) #the appointment that the edit is happening from addedNotes = str(request.form['addedNotes']) addedMedicine = str(request.form['addedMedicine']) appointmentManager.updateAppointment(appointment, addedNotes, addedMedicine) currentAppointment.accessed = True currentAppointment.notes = appointment.notes currentAppointment.prescribedMedicine = appointment.prescribedMedicine saveData(centreManager, userManager, appointmentManager) return render_template('appointmentDetails.html', loggedInUser=current_user.get_id(), appointment=appointment) return render_template('index.html', loggedInUser=current_user.get_id())
def showBookings(): if request.method == 'POST': appointmentIndex = int(request.form['appointmentIndex']) appointmentNotes = str(request.form['notes']) appointmentPrescribedMedicine = str(request.form['prescribedMedicine']) currentAppointment = current_user.getSpecificAppointment( appointmentIndex) currentAppointment.notes = appointmentNotes currentAppointment.prescribedMedicine = appointmentPrescribedMedicine currentAppointment.accessed = True patient = userManager.getID(currentAppointment.patient) #if a referral was made, we want to store the patient in the list of referrals for the specialist chosen if current_user.getProfession() == "GP": newReferral = str(request.form['radioRefer']) if newReferral != "NoRefer": patient.addReferral(newReferral) saveData(centreManager, userManager, appointmentManager) return render_template('index.html', loggedInUser=current_user.get_id(), updated=True) # sorted function converts the date attribute in the appointment to a "datetime" object, # which then can be used to compare two dates # the sorted function returns the new sorted list, and the lambda function is used to get the date attribute return render_template( 'appointments.html', loggedInUser=current_user.get_id(), appointments=appointmentManager.getAppointments(current_user))
def bookAppointment(email): # find provider and add the appointment # find current user logged in and add the appointment # def addAppointment(provider_email, patient_email, date, time): # addAppointment(request.form['email']) if request.form['date'] == "": # empty date field times = getTimes(email) return render_template('book.html', loggedInUser=current_user.get_id(), times=times, name=email, error="Error: Enter a date!") success = appointmentManager.addAppointment(userManager, email, current_user.get_id(), str(request.form['time']), request.form["date"], request.form['bookReason']) if success == "Time Slot Taken": # no time slots available times = getTimes(email) return render_template('book.html', loggedInUser=current_user.get_id(), times=times, name=email, error="Error: Time slot taken!") elif success == "Date in the past": times = getTimes(email) return render_template('book.html', loggedInUser=current_user.get_id(), times=times, name=email, error="Error: Date in the past!") elif success == "Provider making appointment": times = getTimes(email) return render_template( 'book.html', loggedInUser=current_user.get_id(), times=times, name=email, error="Error: Provider cannot make appointment with provider") saveData(centreManager, userManager, appointmentManager) return render_template('index.html', loggedInUser=current_user.get_id(), booked=True)
def checkout(session, basket, db): # getting current user current_user = session.get("user") # getting list with masters and categories masters = session.get("masters") # getting items in current_user`s basket itemsInBasket = basket.query.filter_by(owner=current_user).all() # getting total price of items in basket total = getTotal(itemsInBasket) # saving data into txt file named after today`s date saveData(itemsInBasket, total, current_user, masters) # deleting items in basket deleteAllModel(itemsInBasket, db) # deleting masters names session["masters"] = None
def accessedAppointment(): if request.method == 'POST': appointmentIndex = (int(request.form['appointment']) - 1) # Get patient appointments patient_id = current_user.getSpecificAppointment( appointmentIndex).patient patient = userManager.getID(patient_id) appointments = appointmentManager.getAppointments(patient) specialists = userManager.searchExpertise("") saveData(centreManager, userManager, appointmentManager) return render_template( 'accessedAppointment.html', loggedInUser=current_user.get_id(), appointment=current_user.getSpecificAppointment(appointmentIndex), appointmentIndex=appointmentIndex, appointments=appointments, specialists=specialists) return render_template('accessedAppointment.html', loggedInUser=current_user.get_id())
def update_profile(name): if request.method == "POST": new_firstName = request.form["new_firstName"] if new_firstName != "": current_user.set_FirstName(new_firstName) new_lastName = request.form["new_lastName"] if new_lastName != "": current_user.set_LastName(new_lastName) new_phone = request.form["new_phone"] if new_phone != "": current_user.set_phone(new_phone) new_password = request.form["new_password"] if new_password != "": current_user.set_password(new_password) if current_user.isPatient() == True: new_medicare = request.form["new_medicare"] if new_medicare != "": current_user.set_medicare(new_medicare) else: new_profession = request.form["new_profession"] if new_profession != "": current_user.set_profession(new_profession) new_providerNum = request.form["new_providerNum"] if new_providerNum != "": current_user.set_providerNum(new_providerNum) new_expertise = request.form["new_expertise"] if new_expertise != "": current_user.set_expertise(new_expertise) # write all data to files saveData(centreManager, userManager, appointmentManager) return render_template("profile.html", loggedInUser=current_user.get_id(), option="self") return render_template("update_profile.html", loggedInUser=current_user.get_id())