def my_profile():

    if (request.method == "GET"):
        UM = system.get_UserManager()
        patients_list = UM.get_patients()
        doctors_list = UM.get_HCPs()
        return render_template("my_profile.html")
예제 #2
0
def test_provider_multiple_booking_same_time():
    UM = system.get_UserManager()
    patient1 = UM.get_patient("*****@*****.**")
    patient2 = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    booking1 = BM.createBooking("17:00", "2019-02-10", HCP._email,
                                patient1._email, HCC, patient1)
    BM.append_to_user(booking1, HCP, patient1)
    for booking in BM._bookings:
        print(booking._time)
        print(booking._date)

    try:
        booking = BM.createBooking("17:00", "2019-02-10", HCP._email,
                                   patient2._email, HCC, patient2)
        BM.append_to_user(booking, HCP, patient1)
        assert (False)
    except BookingError as e:
        assert (
            e._error_message ==
            "Sorry. The provider is booked at this time. Please select another time or a different provider"
        )
def add_a_note(HCPusername, location, time, date):
    BM = system.get_BookingManager()
    UM = system.get_UserManager()

    if request.method == 'GET':
        HCP = UM.get_HCP(HCPusername)
        return render_template("patient_note.html")

    if request.method == 'POST':
        HCC = location
        HCP = UM.get_HCP(HCPusername)
        time = time
        pNote = request.form['pNote']
        patient = current_user

        if 'confirm' in request.form:
            try:
                new_booking = BM.createBooking(time, date, HCP._email,
                                               current_user._email, location,
                                               current_user)
            except BookingError as e:
                return render_template("booking_error.html",
                                       msg=e._error_message)
            else:
                BM.append_to_user(new_booking, HCP, patient)
                BM.print_bookings_list()
            return render_template('confirmation.html', booking=new_booking)
        elif 'cancel' in request.form:
            return render_template('cancel_booking.html')
        return render_template("patient_note.html")
def book(HCPusername, location):
    UM = system.get_UserManager()
    HCP = UM.get_HCP(HCPusername)
    BM = system.get_BookingManager()

    if not HCP:
        abort(404)

    if request.method == "GET":
        return render_template("booking.html")
    elif request.method == "POST":
        selected_date = request.form.getlist('form')[0]
        showtime = True
        time_intervals = BM.get_available_times(HCP._email, selected_date)
    try:
        BM.test_booking_conditions("", selected_date, HCP._email,
                                   current_user._email, location)
    except BookingError as e:
        return render_template("booking.html", msg=e._error_message)
    else:
        return render_template("booking.html",
                               date=selected_date,
                               showtime=showtime,
                               time_intervals=time_intervals,
                               HCPusername=HCPusername,
                               location=location)
def current_provider_appointments(username):
    UM = system.get_UserManager()
    provider_username = username
    provider = UM.get_HCP(provider_username)
    try:
        provider.can_view_appointments(current_user)
    except UnauthorisedAccess as error:
        message = error.get_message()
        return render_template("UnauthorisedAccess.html", error=message)
    past_bookings = current_user.get_past_bookings()
    future_bookings = current_user.get_future_bookings()
    return render_template("current_provider_bookings.html",
                           past_bookings=past_bookings,
                           future_bookings=future_bookings)
예제 #6
0
def test_valid_date():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    date = "2019-10-10"
    time = "9:30"
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    try:
        booking = BM.createBooking(time, date, HCP._email, patient._email, HCC,
                                   patient)
        assert (True)
    except BookingError as e:
        assert (e is not defined)
예제 #7
0
def test_provider_can_book_as_patient():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()

    try:
        booking = BM.createBooking("17:00", "2019-05-10", HCP._email,
                                   patient._email, HCC, patient)
        BM.append_to_user(booking, HCP, patient)
        assert (True)
    except BookingError as e:
        assert (e is not defined)
예제 #8
0
def test_empty_time():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    date = "2019-10-10"
    time = ""
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    try:
        booking = BM.createBooking(time, date, HCP._email, patient._email, HCC,
                                   patient)
        assert (False)
    except BookingError as e:
        assert (e._error_message == "Please select a valid time")
def search():
    #services = ["GP", "Physio", "chiro"]
    services = system.get_services()
    CM = system.get_CentreManager()
    UM = system.get_UserManager()
    if request.method == 'POST':
        search_type = request.form['action']
        user_input = request.form[search_type]
        search_results = system.search(search_type, user_input)
        #for x in search_results:
        #    print(x)
        return render_template('search_results.html',
                               search_type=search_type,
                               search_results=search_results)

    return render_template('search.html', services=services)
def HCPProfile(HCPusername):
    UM = system.get_UserManager()
    ratings = system.get_ratings()
    HCP = UM.get_HCP(HCPusername)
    if not HCP:
        abort(404)

    if request.method == "POST":
        rating = int(request.form['rating'])
        user = current_user
        system.calculate_rating(user, HCP, rating)

    return render_template('HCP_profile.html',
                           HCP=HCP,
                           ratings=ratings,
                           current_user=current_user)
예제 #11
0
def test_provider_restriction():
    UM = system.get_UserManager()
    HCP = UM.get_HCP("*****@*****.**")
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()

    try:
        booking = BM.createBooking("17:00", "2019-02-10", HCP._email,
                                   HCP._email, HCC, HCP)
        assert (False)
    except BookingError as e:
        assert (
            e._error_message ==
            "A provider is not allowed to make bookings. Please login as a patient to make bookings"
        )
예제 #12
0
def test_provider_multiple_booking_different_time():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    booking1 = BM.createBooking("16:00", "2019-02-10", HCP._email,
                                patient._email, HCC, patient)
    BM.append_to_user(booking1, HCP, patient)

    try:
        booking = BM.createBooking("15:30", "2019-03-10", HCP._email,
                                   patient._email, HCC, patient)
        assert (True)
    except BookingError as e:
        assert (e is not defined)
예제 #13
0
def test_patient_multiple_booking_same_time():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    booking1 = BM.createBooking("15:30", "2019-11-10", HCP._email,
                                patient._email, HCC, patient)
    BM.append_to_user(booking1, HCP, patient)

    try:
        booking = BM.createBooking("15:30", "2019-11-10", HCP._email,
                                   patient._email, HCC, patient)
        assert (False)
    except BookingError as e:
        assert (e._error_message ==
                "Sorry. You cannot book two appointments at the same time")
예제 #14
0
def test_provider_cannot_book_themselves():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()

    try:
        booking = BM.createBooking("18:00", "2019-05-10", HCP._email,
                                   patient._email, HCC, patient)
        BM.append_to_user(booking, HCP, patient)
        assert (False)
    except BookingError as e:
        assert (
            e._error_message ==
            "Sorry. A provider is not able to make an appointment with themselves"
        )
예제 #15
0
def test_patient_multiple_booking_different_times():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    date = "2019-10-10"
    time = "9:30"
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    time2 = "10:30"
    try:
        booking = BM.createBooking(time, date, HCP._email, patient._email, HCC,
                                   patient)
        BM.append_to_user(booking, HCP, patient)
        booking2 = BM.createBooking(time2, date, HCP._email, patient._email,
                                    HCC, patient)
        assert (True)
    except BookingError as e:
        assert (e is not defined)
def test_unauthorised_provider_note():
    # anna cannot make add any notes to do with the appointment between jack and toby

    UM = system.get_UserManager()
    patient = UM.get_patient('*****@*****.**')
    HCP1 = UM.get_HCP('*****@*****.**')
    dateA = "2019-10-15"
    timeA = "9:30"
    locations = HCP1.get_aff_HCC_centers
    HCC_A = locations[0]
    BM = bookingManager()
    booking1 = BM.createBooking(timeA, dateA, HCP1._email, patient._email,
                                HCC_A, patient)

    HCP2 = UM.get_HCP('*****@*****.**')
    dateB = '2019-10-16'
    timeB = '9:30'
    locations = HCP2.get_aff_HCC_centers
    HCC_B = locations[0]
    booking2 = BM.createBooking(timeB, dateB, HCP2._email, patient._email,
                                HCC_B, patient)

    try:
        booking1.can_add_dNote('*****@*****.**')
        assert (False)
    except UnauthorisedAccess as error:
        assert (error.get_message() ==
                "You are not authorised to access this page")

    #toby is authorised to add a note
    try:
        booking1.can_add_dNote('*****@*****.**')
    except UnauthorisedAccess as error:
        assert (False)

    #another patient cannot add a note
    try:
        booking1.can_add_dNote('*****@*****.**')
        assert (False)
    except UnauthorisedAccess as error:
        assert (error.get_message() ==
                "You are not authorised to access this page")
예제 #17
0
def test_date_and_time():
    UM = system.get_UserManager()
    patient = UM.get_patient("*****@*****.**")
    HCP = UM.get_HCP("*****@*****.**")
    date = datetime.now().strftime("%Y-%m-%d")
    print(date)
    future_time = datetime.now() - timedelta(minutes=30)
    time = future_time.strftime('%H:%M')
    print(time)
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    try:
        booking = BM.createBooking(time, date, HCP._email, patient._email, HCC,
                                   patient)
        assert (False)
    except BookingError as e:
        print(e._error_message)
        assert (e._error_message ==
                "Please select a time and date that is not in the past")
def providersNotes(bookingId):
    BM = system.get_BookingManager()
    UM = system.get_UserManager()
    booking = BM.booking_query(int(bookingId))
    HCP_username = booking.getHCP()
    HCP = UM.get_HCP(HCP_username)
    if request.method == "POST":
        try:
            booking.can_add_dNote(current_user.get_username())
        except UnauthorisedAccess as error:
            message = error.get_message()
            return render_template("UnauthorisedAccess.html", error=message)
        dNote = request.form['dNote']
        booking.setdNote(dNote)
        past_bookings = current_user.get_past_bookings()
        future_bookings = current_user.get_future_bookings()
        return render_template("current_provider_bookings.html",
                               past_bookings=past_bookings,
                               future_bookings=future_bookings)

    return render_template("doctor_note.html")
def provider_appointments():
    #no other user can access a providers appointments
    UM = system.get_UserManager()
    HCP = UM.get_HCP('*****@*****.**')
    try:
        HCP.can_view_appointments('*****@*****.**')
        assert (False)
    except UnauthorisedAccess as error:
        assert (error.get_message() ==
                "You are not authorised to access this page")

    #another provider cannot access toby's list of appointments
    try:
        HCP.can_view_appointments('*****@*****.**')
    except UnauthorisedAccess as error:
        assert (error.get_message() ==
                "You are not authorised to access this page")

    #toby is able to view his appointments
    try:
        HCP.can_view_appointments('*****@*****.**')
    except UnauthorisedAccess as error:
        assert (False)
def patient_appointments():

    UM = system.get_UserManager()
    patient = UM.get_patient('*****@*****.**')
    HCP = UM.get_HCP('*****@*****.**')
    date = "2019-10-15"
    time = "9:30"
    locations = HCP.get_aff_HCC_centers
    HCC = locations[0]
    BM = bookingManager()
    booking = BM.createBooking(time, date, HCP._email, patient._email, HCC,
                               patient)
    unauthorised_HCP = UM.get_HCP('*****@*****.**')

    #anna cannot access jack's appointments because jack is not her patient
    try:
        patient.can_view_appointments(unauthorised_HCP)
        assert (False)
    except UnauthorisedAccess as error:
        assert (error.get_message() ==
                "You are not authorised to access this page")

    #HCP toby should be able to access jacks list of past appointments
    try:
        patient.can_view_appointments(HCP)
    except UnauthorisedAccess as error:
        assert (False)

    #another patient cannot access jacks list of past appointments
    hao = UM.get_patient('*****@*****.**')
    try:
        patient.can_view_appointments(hao)
        assert (False)
    except UnauthorisedAccess as error:
        assert (error.get_message() ==
                "You are not authorised to access this page")