Exemple #1
0
def test_login_check():
    uc = login_check.user_check()
    #test1: not exist
    assert (uc.get_user("*****@*****.**") == None)
    #test2: exist patient
    test_patient1 = uc.get_user("*****@*****.**")
    assert (test_patient1.email == "*****@*****.**")
    assert (test_patient1.password == "123456")
    assert (test_patient1.name == "Mark")
    assert (test_patient1.phone == "0456789")
    assert (test_patient1.authority == "patient")
    assert (test_patient1.cardNumber == "1234567")
    #test3: exist provider
    test_provider1 = uc.get_user("*****@*****.**")
    assert (test_provider1.email == "*****@*****.**")
    assert (test_provider1.password == "123456")
    assert (test_provider1.name == "Mark")
    assert (test_provider1.phone == "0456789")
    assert (test_provider1.authority == "provider")
    assert (test_provider1.providerNumber == "1234567")
    assert (test_provider1.type == "GP")
    #test3: check password for not exist user
    assert (uc.check_password("abcd", "123") == False)
    #test4: check exist user with not exist password
    assert (uc.check_password("*****@*****.**", "") == False)
    #test5: check exist user with wrong password
    assert (uc.check_password("*****@*****.**", "6432") == False)
    #test6: check exist user with right password
    test_patient1 = uc.check_password("*****@*****.**", "123456")
    assert (test_patient1.email == "*****@*****.**")
    assert (test_patient1.password == "123456")
    assert (test_patient1.name == "Mark")
    assert (test_patient1.phone == "0456789")
    assert (test_patient1.authority == "patient")
    assert (test_patient1.cardNumber == "1234567")
Exemple #2
0
def test_user_class_check():
    uc = login_check.user_check()
    #test1: edit patient information
    new_patient1 = user_class.Patient("*****@*****.**", "654321",
                                      "MarkGay", "0498765", "7654321")
    new_patient1.update()
    test_patient1 = uc.get_user("*****@*****.**")
    assert (test_patient1.email == "*****@*****.**")
    assert (test_patient1.password == "654321")
    assert (test_patient1.name == "MarkGay")
    assert (test_patient1.phone == "0498765")
    assert (test_patient1.authority == "patient")
    assert (test_patient1.cardNumber == "7654321")
    #test2: edit provider information
    new_provider1 = user_class.Provider("*****@*****.**", "654321",
                                        "MarkGay", "0498765", "7654321", "PG")
    new_provider1.update()
    test_provider1 = uc.get_user("*****@*****.**")
    assert (test_provider1.email == "*****@*****.**")
    assert (test_provider1.password == "654321")
    assert (test_provider1.name == "MarkGay")
    assert (test_provider1.phone == "0498765")
    assert (test_provider1.authority == "provider")
    assert (test_provider1.providerNumber == "7654321")
    assert (test_provider1.type == "PG")
Exemple #3
0
def rating_provider(center):
    if current_user.authority == "provider":
        return redirect(url_for("provider"))
    success = None
    uc = login_check.user_check()
    rm = rating_record.Rating_Management()

    if (uc.get_user(center) == None):
        success = False
    else:
        if request.method == "POST":
            val = request.form["rating"]

            rating = rating_record.Rating(current_user.email,
                                          val,
                                          provider=center)
            if (rm.update_rating(rating)):
                success = True
            else:
                success = False
    return render_template(
        "rating.html",
        current_user=current_user,
        success=success,
        currRating=rating_record.Rating_Management().get_rating(
            current_user.email, centre=center))
Exemple #4
0
 def get_provider_list(self, center):
     cv = csv_manage("provider_health_centre.csv")
     provide_list = cv.search_data([[1, center]])
     result = []
     uc = user_check()
     for line in provide_list:
         result.append(uc.get_user(line[0]))
     return result
Exemple #5
0
def book(name, center):
    if current_user.authority == "provider":
        return redirect(url_for("provider"))
    cm = health_center.Center_management()
    uc = login_check.user_check()
    rm = appointment_record.record_management()
    errorMsg = []
    center_data = cm.get_center(center)
    provider_data = uc.get_user(name)
    if (center_data == None):
        errorMsg.append("Center name not exist!")
    if (provider_data == None):
        errorMsg.append("Provider name not exist!")
    if (provider_data.authority == "patient"):
        errorMsg.append("Wrong authority")
    workingTime = cm.get_workingTime(provider_data, center_data)
    if workingTime == False:
        errorMsg.append("The provider are not working for the center")
    bookingMsg = []

    def check_time(timeVal):
        sec = timeVal.strftime('%S')
        min = timeVal.strftime('%M')
        if (sec != "00"):
            return False
        if (min != "00" and min != "30"):
            return False
        return True

    if request.method == "POST":
        try:
            r = appointment_record.Record(current_user, provider_data,
                                          center_data, request.form["reason"],
                                          request.form["start_time"],
                                          request.form["end_time"], "", "")
            if (check_time(r.start_time) and check_time(r.end_time)):
                checkValue = rm.update_record(r)
                if (checkValue == False):
                    bookingMsg.append(
                        "Can not book appointment - please check your start time and end time"
                    )
                else:
                    bookingMsg.append("Booking success!")
            else:
                bookingMsg.append("time are separate to 30min periods!")
        except:
            bookingMsg.append("You need enter time in correct format")

    return render_template("booking.html",
                           errorMsg=errorMsg,
                           bookingMsg=bookingMsg,
                           center_data=center_data,
                           provider_data=provider_data,
                           workingTime=workingTime)
 def search_edit(self, search_list):
     cv = csv_manage("record.csv")
     uc = user_check()
     cm = Center_management()
     result = cv.search_data(search_list)
     return_list = []
     for line in result:
         return_list.append(
             Record(
                 uc.get_user(line[0]), uc.get_user(line[1]),
                 cm.get_center(line[2]), line[3],
                 datetime.datetime.strptime(line[4], '%d-%m-%Y %H:%M:%S'),
                 datetime.datetime.strptime(line[5], '%d-%m-%Y %H:%M:%S'),
                 line[6], line[7]))
     return return_list
Exemple #7
0
def login():
    if request.method == "GET":
        return render_template('login.html', get=True, success=None)
    else:
        username = request.form["username"]
        password_input = request.form["password"]
        uc = login_check.user_check()
        user = uc.check_password(username, password_input)
        if (user != False):
            login_user(user)
            #return render_template("login.html", success = True)
            if (user.authority == "patient"):
                return redirect(url_for("patient"))
            else:
                return redirect(url_for("provider"))
    return render_template("login.html", success=False)
Exemple #8
0
def providers_list(name):

    cm = health_center.Center_management()
    uc = login_check.user_check()
    provider_data = uc.get_user(name)
    if (provider_data != None):
        center_data = cm.get_center_list(provider_data.email)
    else:
        center_data = []

    return render_template("providers.html",
                           current_user=current_user,
                           c=center_data,
                           p=provider_data,
                           rating=rating_record.Rating_Management(),
                           get_workingTime=cm.get_workingTime)
Exemple #9
0
def search_provider(name):
    provider_data = []
    center_data = []
    f_provider = csv_manage("provider.csv")
    provider_data = f_provider.search_data([[0, name]], 0, 1)

    cm = health_center.Center_management()
    uc = login_check.user_check()
    class_list_provider = []
    class_list_center = []
    for line in provider_data:
        class_list_provider.append(uc.get_user(line[0]))
    for line in center_data:
        class_list_center.append(cm.get_center(line[2]))
    return render_template("search_result.html",
                           provider_data=class_list_provider,
                           center_data=class_list_center,
                           rating=rating_record.Rating_Management(),
                           get_workingTime=cm.get_workingTime)
Exemple #10
0
def test_appointment_record():
    #test: Record class
    ar = appointment_record
    rec = ar.Record
    rm = appointment_record.record_management()
    user = login_check.user_check().get_user
    center = health_center.Center_management().get_center
    #test1: right data
    new_record1 = rec(user("*****@*****.**"),
                      user("*****@*****.**"), center("Hospital1"),
                      "test", ar.strToTime("8-11-2018 05:00:00"),
                      ar.strToTime("8-11-2018 07:00:00"))
    assert (new_record1.check() == True)
    assert (new_record1.write_check() == True)
    if (True):
        #test2: wrong patient name
        new_record2 = rec(user("pd"), user("*****@*****.**"),
                          center("Hospital1"), "test",
                          ar.strToTime("8-11-2018 05:00:00"),
                          ar.strToTime("8-11-2018 07:00:00"))
        assert (new_record2.check() == False)
        assert (new_record2.write_check() == False)
        #test3 wrong provider name
        new_record3 = rec(user("*****@*****.**"), user("com"),
                          center("Hospital1"), "test",
                          ar.strToTime("8-11-2018 05:00:00"),
                          ar.strToTime("8-11-2018 07:00:00"))
        assert (new_record3.check() == False)
        assert (new_record3.write_check() == False)
        #test4 wrong center name
        new_record4 = rec(user("*****@*****.**"),
                          user("*****@*****.**"), center("Ho"), "test",
                          ar.strToTime("8-11-2018 05:00:00"),
                          ar.strToTime("8-11-2018 07:00:00"))
        assert (new_record4.check() == False)
        assert (new_record4.write_check() == False)
        #test5 start time > end time
        new_record5 = rec(user("*****@*****.**"),
                          user("*****@*****.**"), center("Hospital1"),
                          "test", ar.strToTime("8-11-2018 07:00:00"),
                          ar.strToTime("8-11-2018 05:00:00"))
        assert (new_record5.check() == False)
        assert (new_record5.write_check() == False)
        #test6 not same year
        new_record6 = rec(user("*****@*****.**"),
                          user("*****@*****.**"), center("Hospital1"),
                          "test", ar.strToTime("8-11-2018 05:00:00"),
                          ar.strToTime("8-11-2019 07:00:00"))
        assert (new_record6.check() == False)
        assert (new_record6.write_check() == False)
        #test7 not in provider valid time
        new_record7 = rec(user("*****@*****.**"),
                          user("*****@*****.**"), center("Hospital1"),
                          "test", ar.strToTime("8-11-2018 02:00:00"),
                          ar.strToTime("8-11-2018 07:00:00"))
        assert (new_record7.check() == False)
        assert (new_record7.write_check() == False)
        #test10: previous record
        new_record10 = rec(user("*****@*****.**"),
                           user("*****@*****.**"), center("Hospital1"),
                           "test", ar.strToTime("8-11-2017 05:00:00"),
                           ar.strToTime("8-11-2017 07:00:00"))
        assert (new_record10.check() == True)
        assert (new_record10.write_check() == False)
        #test: save valid record
        assert (rm.update_record(new_record1) == True)
        assert (rm.search_edit([[0, "*****@*****.**"],
                                [1, "*****@*****.**"], [2, "Hospital1"]])
                != [])
        #test9 overlap with saved record
        new_record9 = rec(user("*****@*****.**"),
                          user("*****@*****.**"), center("Hospital1"),
                          "test", ar.strToTime("8-11-2018 06:30:00"),
                          ar.strToTime("8-11-2018 07:00:00"))
        assert (new_record9.check() == True)
        assert (new_record9.write_check() == False)
    #test: record_management
    #test: exist record
    #exist
    assert (rm.exist_record(user("*****@*****.**"),
                            user("*****@*****.**")) == True)
    #not exist
    assert (rm.exist_record(user("*****@*****.**"),
                            user("*****@*****.**")) == False)
    assert (rm.exist_record(user("*****@*****.**"),
                            user("*****@*****.**")) == False)
    #test: update sucess
    new_record1 = rec(user("*****@*****.**"),
                      user("*****@*****.**"), center("Hospital1"),
                      "test", ar.strToTime("8-11-2018 05:00:00"),
                      ar.strToTime("8-11-2018 07:00:00"), "some text",
                      "some text")
    assert (rm.update_record(new_record1) == True)
    test_record1 = rm.get_record_by_provider(user("*****@*****.**"))
    assert (test_record1[0].get_list() == new_record1.get_list())

    new_record2 = rec(user("*****@*****.**"),
                      user("*****@*****.**"), center("Hospital1"),
                      "test", ar.strToTime("9-11-2018 05:00:00"),
                      ar.strToTime("9-11-2018 07:00:00"), "some text",
                      "some text")
    assert (rm.update_record(new_record2) == True)
    new_record3 = rec(user("*****@*****.**"),
                      user("*****@*****.**"), center("Hospital1"),
                      "test", ar.strToTime("9-11-2018 06:00:00"),
                      ar.strToTime("9-11-2018 07:00:00"), "some text",
                      "some text")
    assert (rm.update_record(new_record3) == True)
    new_record4 = rec(user("*****@*****.**"),
                      user("*****@*****.**"), center("Hospital2"),
                      "test", ar.strToTime("10-11-2018 09:30:00"),
                      ar.strToTime("10-11-2018 10:00:00"), "some text",
                      "some text")
    print(new_record4.get_list())
    print(new_record4.check())
    print(new_record4.write_check())
    assert (rm.update_record(new_record4) == True)
    new_record1 = rec(user("*****@*****.**"),
                      user("*****@*****.**"), center("Hospital1"),
                      "test", ar.strToTime("8-11-2018 05:00:00"),
                      ar.strToTime("8-11-2018 07:00:00"), "some tsdext",
                      "some adtext")
    assert (rm.update_record(new_record1,
                             user("*****@*****.**")) == True)
    test_record1 = rm.get_record_by_provider(user("*****@*****.**"))
    assert (test_record1[0].get_list() == new_record1.get_list())
    #test: update a record which have different provider (False
    assert (rm.update_record(new_record1,
                             user("*****@*****.**")) == False)
    test_record1 = rm.get_record_by_provider(user("*****@*****.**"))
    assert (test_record1[0].get_list() == new_record1.get_list())
    #test:get_record_by_patient
    #not exist
    assert (rm.get_record_by_patient(user("*****@*****.**")) == [])
    #exist
    test_patient_data = rm.get_record_by_patient(user("*****@*****.**"))
    assert (len(test_patient_data) == 3)
    assert (test_patient_data[0].get_list() == new_record1.get_list())
    assert (test_patient_data[1].get_list() == new_record3.get_list())
    assert (test_patient_data[2].get_list() == new_record4.get_list())
    #test:get_record_by_provider
    #not exist
    assert (rm.get_record_by_provider(user("*****@*****.**")) == [])
    #exist
    test_provider_data = rm.get_record_by_provider(
        user("*****@*****.**"))
    assert (len(test_provider_data) == 3)
    assert (test_provider_data[0].get_list() == new_record1.get_list())
    assert (test_provider_data[1].get_list() == new_record2.get_list())
    assert (test_provider_data[2].get_list() == new_record4.get_list())
    #test:get_record_by_center
    #not exist
    assert (rm.get_record_by_center(center("Sydney Children Hospital")) == [])
    #exist
    test_center_data = rm.get_record_by_center(center("Hospital1"))
    assert (len(test_center_data) == 3)
    assert (test_center_data[0].get_list() == new_record1.get_list())
    assert (test_center_data[1].get_list() == new_record2.get_list())
    assert (test_center_data[2].get_list() == new_record3.get_list())
Exemple #11
0
def load_user(user_id):
    uc = login_check.user_check()
    user = uc.get_user(user_id)
    return user