Example #1
0
    def send_data_to_database(self, change, string):

        print("sending data forget")
        email_text_edit = change.main_window.findChild(QLineEdit,
                                                       "ForgetPageLineEdit")
        items = change.main_window.findChildren(QLineEdit)
        flag = True
        for item in items:
            if string in item.objectName():
                if item.text() == "" and "Field" not in item.placeholderText():
                    text = item.placeholderText()
                    item.setPlaceholderText("Fill Field: " + text)
                    item.setStyleSheet("QLineEdit{ "
                                       "border:none;"
                                       "border-radius:5;"
                                       "background-color:#af2b44;}")
                    flag = False

        hospital.execute(
            "select User_Code,user_password from user where `E-Mail`=%s",
            (email_text_edit.text(), ))
        result = hospital.fetchone()
        if not result:
            print("there is no email address registered as you requested!!")
            return
        user_code = result[0]
        user_password = result[1]
        if flag:
            self.email(email_text_edit.text(), user_code, user_password)
Example #2
0
    def get_data_search(self, table, item):

        if item.text() == "":
            item.setStyleSheet("QLineEdit{ "
                               "border:none;"
                               "border-radius:5;"
                               "background-color:#af2b44;}"
                               "QLineEdit:focus {"
                               "border:none;"
                               "border-radius:5;"
                               "background-color:white;}")
            return
        item.setStyleSheet("QLine Edit{ "
                           "border:none;"
                           "border-radius:5;"
                           "background-color:white;}")

        hospital.execute(
            "select DrugName,ExpirationDate,Price from drug where ExpirationDate > %s order by ExpirationDate asc",
            (item.text(), ))
        filters = hospital.fetchall()

        for i in range(table.rowCount() - 1):
            table.removeRow(i)
            print(table.rowCount())
Example #3
0
    def check_authentication(self):
        hospital.execute("select User_Code from user where user.User_Code=%s and user.user_password=%s",
                         (self.usercode, self.password))
        user = hospital.fetchone()
        if user:
            hospital.execute("select Role_Name from user natural join user_role where user_Code = %s", (self.usercode,))
            role = hospital.fetchone()[0]

            if role:
                if role == "admin":
                # go to admin page
                if role == "patient":
                # go to patient page
                elif role == "doctor":
                # go to doctor page
                elif role == "nurse":
                # go to nurse page
                elif role == "receptionist":
                # go to receptionist page
                elif role == "accountant":
                # go to accountant page
                elif role == "pharmacist":
                # go to pharmacist page
                elif role == "Lab_Staff":
                #go to lab staff page
            else:
                print("You are not authorized yet wait for Admin to activate your account!!!")
        else:
            print("Authentication failed!\n Wrong username or password!")
Example #4
0
    def get_data_search(self, table, item):

        if item.text() == "":
            item.setStyleSheet("QLineEdit{ "
                               "border:none;"
                               "border-radius:5;"
                               "background-color:#af2b44;}"
                               "QLineEdit:focus {"
                               "border:none;"
                               "border-radius:5;"
                               "background-color:white;}")
            return
        item.setStyleSheet("QLineEdit{ "
                           "border:none;"
                           "border-radius:5;"
                           "background-color:white;}")

        hospital.execute(
            "select date_appointment,time_appointment,Doctor_UserCode,Username,Patient_UserCode "
            "from appointment, user where appointment.Doctor_UserCode = user.User_Code and User_Code=%s",
            (item.text(), ))
        filters = hospital.fetchall()
        for i in range(table.rowCount() - 1):
            table.removeRow(i)
        print(table.rowCount())

        for i in range(len(filters)):
            table.insertRow(i)

        for i in range(len(filters)):
            for j in range(4):
                text = QTableWidgetItem(str(filters[i][j]))
                table.setItem(i, j, text)
        print("successful")
Example #5
0
    def get_data(self, table):
        hospital.execute("select DrugName,ExpirationDate,Price from drug")
        drugs = hospital.fetchall()
        for i in range(len(drugs)):
            table.insertRow(i)

        for i in range(len(drugs)):
            for j in range(3):
                text = QTableWidgetItem(str(drugs[i][j]))
                table.setItem(i, j, text)
        table.insertRow(table.rowCount())
Example #6
0
    def get_data(self, table):
        hospital.execute(
            "select date_appointment,time_appointment,Doctor_UserCode,Username,Patient_UserCode "
            "from appointment, user where appointment.Doctor_UserCode = user.User_Code"
        )
        appointments = hospital.fetchall()
        for i in range(len(appointments)):
            table.insertRow(i)

        for i in range(len(appointments)):
            for j in range(4):
                text = QTableWidgetItem(str(appointments[i][j]))
                table.setItem(i, j, text)
Example #7
0
    def get_data(self, table):
        hospital.execute(
            "select user.User_Code,Username,Phone_Number,`E-Mail` from user,"
            "user_role where user.User_Code = user_role.user_Code "
            "and user_role.role_ID = 3 and user.isVerified=0;")
        doctors = hospital.fetchall()
        for i in range(len(doctors)):
            table.insertRow(i)

        for i in range(len(doctors)):
            for j in range(4):
                print(i)
                text = QTableWidgetItem(str(doctors[i][j]))
                table.setItem(i, j, text)
Example #8
0
 def delete_cell(self, table, row_selected, column_selected):
     if (column_selected == table.columnCount() - 1):
         data = []
         for i in range(table.columnCount() - 1):
             print("i: ", i)
             text = table.item(row_selected, i).text()
             data.append(text)
             print("\n\n\n")
             print(data[i])
             try:
                 hospital.execute(
                     "delete from drug where DrugName=%s and ExpirationDate=%s and Price=%s" (
                         data[0], data[1], data[3]))
             except Exception as e:
                 print(e)
             mydb.commit()
         table.removeRow(row_selected)
Example #9
0
    def send_nurse_report_logic_page(self, change, usercode):
        submit_button = change.main_window.findChild(
            QPushButton, "NursePageSubmitReportButton")
        submit_button.clicked.connect(lambda: self.send_data_to_database(
            change.main_window, "NursePage"))

        nurse_username = change.main_window.findChild(QLabel,
                                                      "NursePageUsername")

        print("username is:", usercode)
        hospital.execute("select Username from user where User_Code = %s",
                         (usercode, ))
        username = hospital.fetchone()[0]
        nurse_username.setText(username)
        print(nurse_username.text())

        records_button = change.main_window.findChild(
            QPushButton, "NursePageResportsRecordButton")
        records_button.clicked.connect(lambda: change.change_page(change, 5))
Example #10
0
    def add_cell(self, table):
        data = []
        print(table.rowCount())

        for i in range(table.columnCount()):
            print("i: ", i)
            if (table.item(table.rowCount() - 1, i) == None):
                return
            text = table.item(table.rowCount() - 1, i).text()
            data.append(text)
            print(data[i])

        try:
            hospital.execute(
                "insert into appointment(date_appointment,time_appointment,Doctor_UserCode, Patient_UserCode) "
                "values (%s,%s,%s,%s);", (data[0], data[1], data[2], data[4]))
        except Exception as e:
            print(e)
        mydb.commit()
        table.insertRow(table.rowCount())
Example #11
0
    def get_drugs(self, username):
        hospital.execute(
            "select drug.Drug_ID,DrugName "
            "from drug, has_drug, given, prescription where given.Patient_UserCode =%s "
            "and given.PrescriptionID = prescription.PrescriptionID "
            "and prescription.DrugFlag = true "
            "and ExamineFlag = false "
            "and has_drug.Drug_ID = drug.Drug_ID "
            "and has_drug.Prescription_ID = given.PrescriptionID",
            (username, ))

        drugs = hospital.fetchall()
        drug_string = ""

        for i in range(len(drugs)):
            drug_string = drug_string + str(i +
                                            1) + ":" + drugs[i][1] + "(" + str(
                                                drugs[i][0]) + ")" + "\n"

        return drug_string
Example #12
0
    def add_cell(self, table):
        data = []
        print(table.rowCount())

        for i in range(table.columnCount() - 1):
            print("i: ", i)
            if (table.item(table.rowCount() - 1, i) == None):
                return
            text = table.item(table.rowCount() - 1, i).text()
            data.append(text)
            print(data[i])

            try:
                hospital.execute(
                    "insert into drug(DrugName, ExpirationDate, Price) "
                    "values (%s,%s,%s);", (data[0], data[1], data[2]))
            except Exception as e:
                print(e)
            mydb.commit()
        table.insertRow(table.rowCount())
Example #13
0
    def email(self):
        message = """Subject: Your username for login

        Hi {username}, your username for login is {user_code}"""

        name = self.username
        query = "select User_Code form user where 'E-Mail'=%s"
        hospital.execute(query, (self.email,))
        user_code = hospital.fetchone()[0]

        from_address = "*****@*****.**"
        email = self.email
        try:
            server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
            server.ehlo()
            server.login(from_address, "11kahani")
            server.sendmail(from_address, email, message.format(name=name, grade=user_code))
            server.close()
            print('Email sent!')
        except:
            print("Something went wrong :(")
Example #14
0
    def email(self, username, email_address):
        message = """Subject: Your username for login

        Hi {username}, your username for login is {user_code}"""

        name = username
        print(name)
        query = "select last_insert_id()"
        hospital.execute(query)
        user_code = hospital.fetchone()[0]
        email = email_address
        try:
            from_address = "*****@*****.**"
            server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
            server.ehlo()
            server.login(from_address, "11kahani")
            server.sendmail(from_address, email,
                            message.format(username=name, user_code=user_code))
            server.close()
            print('Email sent!')
        except:
            print("something went wrong!!")
Example #15
0
    def send_data_to_database(self, change, string):
        print("sending data registeration")
        username_text_edit = change.main_window.findChild(
            QLineEdit, "RegisterPageUsernameLineEdit")
        password_text_edit = change.main_window.findChild(
            QLineEdit, "RegisterPagePasswordLineEdit")
        password_confirm_text_edit = change.main_window.findChild(
            QLineEdit, "RegisterPageConfirmPasswordLineEdit")
        email_text_edit = change.main_window.findChild(
            QLineEdit, "RegisterPageEmailLineEdit")
        phone_text_edit = change.main_window.findChild(
            QLineEdit, "RegisterPagePhoneNumberLineEdit")

        items = change.main_window.findChildren(QLineEdit)
        combo = change.main_window.findChild(QComboBox, "RegisterPageComboBox")

        flag = True
        for item in items:
            if string in item.objectName():
                if item.text() == "" and "Field" not in item.placeholderText():
                    text = item.placeholderText()
                    item.setPlaceholderText("Fill Field: " + text)
                    item.setStyleSheet("QLineEdit{ "
                                       "border:none;"
                                       "color:white;"
                                       "border-radius:5;"
                                       "background-color:#af2b44;}")
                    flag = False
        if combo.currentText() == "":
            print("you have to choose a role")
            return

        if password_confirm_text_edit.text() != password_text_edit.text():
            print("confirm password does not match")
            return

        if flag:
            try:
                query = "insert into user(Username,user_password,Phone_Number,`E-Mail`,isVerified) values(%s,%s,%s,%s,0)"
                val = (username_text_edit.text(), password_text_edit.text(),
                       phone_text_edit.text(), email_text_edit.text())
                hospital.execute(query, val)
            except Exception as e:
                print(e)
                return
            mydb.commit()
            self.email(username_text_edit.text(), email_text_edit.text())
            print("you are registered! please wait for verification!!!!")
            hospital.execute("select role_ID from role where Role_Name=%s",
                             (combo.currentText(), ))
            role_id = hospital.fetchone()[0]
            hospital.execute(
                " insert into user_role(user_Code, role_ID) values(last_insert_id(),%s)",
                (role_id, ))
            mydb.commit()
            self.registered = True
Example #16
0
 def get_date(self, table, username):
     hospital.execute(
         "select date_appointment,time_appointment,Patient_UserCode,Username "
         "from appointment, user where "
         "appointment.Patient_UserCode = user.User_Code and Doctor_UserCode=%s",
         (username, ))
     appointments = hospital.fetchall()
     for i in range(len(appointments)):
         table.insertRow(i)
     for i in range(len(appointments)):
         for j in range(4):
             if j == 2:
                 button = QPushButton(str(appointments[i][2]))
                 button.setStyleSheet(
                     "QPushButton{"
                     "background-color: rgba(255, 255, 255, 50);"
                     "color:rgb(0,0,0)}")
                 table.setCellWidget(i, 2, button)
                 button.clicked.connect(
                     lambda: self.show_patient_drog_history(appointments[i][
                         2]))
                 continue
             text = QTableWidgetItem(str(appointments[i][j]))
             table.setItem(i, j, text)