예제 #1
0
    def __init__(self):

        super(Time_settings, self).__init__()

        # Carreguem el login.ui
        loadUi(time_settings_ui, self)
        self.setWindowTitle("Ajustaments")
        self.setWindowIcon(QIcon(app_icon))

        self.cancelDialogBox = QMessageBox()
        self.editDialogBox = QMessageBox()
        self.parameterDialogBox = QMessageBox()

        self.sqlite = SQLite_consulter()

        self.return_btn.hide()
        self.edit_btn.setText("Editar")
        self.edit_btn.setEnabled(False)
        self.editMode = False
        self.cancel_btn.setText("Cancelar")
        self.combo_box_refresh_btn.setIcon(QIcon(refresh_icon))
        self.return_btn.setIcon(QIcon(back_icon))

        self.cancel_btn.hide()

        self.edit_btn.pressed.connect(self.edit_patient)
        self.cancel_btn.pressed.connect(self.cancel_edit_patient)
        self.combo_box_refresh_btn.pressed.connect(self.fill_cb_status)
        self.return_btn.pressed.connect(self.back)

        self.fill_cb_status()

        self.text_read_only()
예제 #2
0
    def __init__(self):
        super(Login, self).__init__()
        # Carreguem el login.ui
        loadUi(loginui, self)
        self.setWindowIcon(QIcon(app_icon))

        # Clase per a fer les consultes Sqlite
        self.sqlite = SQLite_consulter()

        self.pushButtonLogin.clicked.connect(self.loginFunction)
        self.showMessageBox = QMessageBox()
예제 #3
0
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        #Carreguem el grafica_pacients.ui
        loadUi(grafica_pacients_ui, self)
        self.setWindowIcon(QIcon(app_icon))

        self.setWindowTitle("Gràfica Pacients")
        self.showMessageBox = QMessageBox()

        # Per a canviar el color de fondo
        self.graphWidget.setBackground("w")

        #Afegim titol i color
        self.graphWidget.setTitle("Gràfica Pacients", color='k', size="15pt")

        #temps (s)
        self.graphWidget.setLabel(
            'left',
            "<span style=\"color:black;fontsize:30px\">Temps (s)</span>")

        #dies
        self.graphWidget.setLabel(
            'bottom', "<span style=\"color:black;fontsize:30px\">Dia</span>")

        #Afegim una cuadrícula a la gràfica
        self.graphWidget.showGrid(x=True, y=True)

        #Afegim el rango de la X i la Y en aquest cas
        self.graphWidget.setXRange(0, 10, padding=0.001)
        self.graphWidget.setYRange(0, 50, padding=0.01)

        #Connecting to class to connect to database
        self.sqlite = SQLite_consulter()

        self.cBPacients.addItem("Selecciona un pacient")
        for patient in self.sqlite.ask_for_patients_to_fill_combo_box():
            patient_name_surname = patient[0] + " " + patient[1]
            self.cBPacients.addItem(patient_name_surname)

        self.cBPacients.currentIndexChanged.connect(
            self.selection_change_patient)

        self.return_btn.setIcon(QIcon(back_icon))
        self.return_btn.pressed.connect(self.back)

        #Mostrem la finestra
        self.show()
예제 #4
0
    def __init__(self):
        super(Alta_usuaris, self).__init__()
        # Carreguem el login.ui
        loadUi(alta_usuaris, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Alta usuaris")
        self.showMessageBox = QMessageBox()
        self.passwdDoesntMatchMessage = QMessageBox()
        self.dniValid = False

        self.pbInserir.clicked.connect(self.inserir_usuaris)
        self.textDni.textChanged.connect(self.comprueba_dni)

        self.pbModificar.clicked.connect(self.modificar_usuaris)
        self.sqlite = SQLite_consulter()

        self.return_btn.setIcon(QIcon(back_icon))
        self.return_btn.pressed.connect(self.back)
    def __init__(self):
        super(Modifica_pacients, self).__init__()

        # Carreguem el login.ui
        loadUi(modificar_pacients_ui, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Modificar pacients")
        self.deleteDialogBox = QMessageBox()
        self.cancelDialogBox = QMessageBox()
        self.editDialogBox = QMessageBox()
        self.showMessageBox = QMessageBox()

        self.sqlite = SQLite_consulter()

        self.editBtn.setText("Editar")
        self.editBtn.setEnabled(False)
        self.editMode = False
        self.cancelBtn.setText("Cancelar")
        self.deleteBtn.setText("Borrar")
        self.deleteBtn.setEnabled(False)
        self.deleteBtn.setStyleSheet("")
        self.refresh_combo_box_btn.setIcon(QIcon(refresh_icon))
        self.backButton.setIcon(QIcon(back_icon))

        self.text_fase_enfermetat = 1
        self.text_genere = "Home"
        self.dniValid = False
        self.textDni.textChanged.connect(self.comprueba_dni)

        self.cancelBtn.hide()

        self.editBtn.pressed.connect(self.edit_patient)
        self.cancelBtn.pressed.connect(self.cancel_edit_patient)
        self.deleteBtn.pressed.connect(self.delete_patient)
        self.refresh_combo_box_btn.pressed.connect(self.fill_cb_patients)
        self.backButton.pressed.connect(self.back)

        self.fill_cb_patients()

        self.block_ui(True)
예제 #6
0
    def __init__(self):
        super(Alta_pacients, self).__init__()
        # Carreguem el login.ui
        loadUi(alta_pacients_ui, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Alta pacients")
        self.showMessageBox = QMessageBox()

        self.pbInserir.clicked.connect(self.inserir_pacient)

        self.pbModificar.clicked.connect(self.modificar_pacient)
        self.sqlite = SQLite_consulter()

        self.textDni.textChanged.connect(self.comprueba_dni)
        self.fill_cb_gender()
        self.fill_cb_phase()
        self.text_fase_enfermetat = 1
        self.text_genere = "Home"
        self.dniValid = False

        self.return_btn.setIcon(QIcon(back_icon))
        self.return_btn.pressed.connect(self.back)
예제 #7
0
    def __init__(self):
        super(Modifica_usuaris, self).__init__()

        # Carreguem el login.ui
        loadUi(modificar_usuaris_ui, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Modificar usuaris")
        self.deleteDialogBox = QMessageBox()
        self.editDialogBox = QMessageBox()
        self.showMessageBox = QMessageBox()

        self.sqlite = SQLite_consulter()

        self.editBtn.setText("Editar")
        self.editBtn.setEnabled(False)
        self.dniValid = False
        self.editMode = False
        self.cancelBtn.setText("Cancelar")
        self.deleteBtn.setText("Borrar")
        self.deleteBtn.setEnabled(False)
        self.deleteBtn.setStyleSheet("")
        self.refresh_combo_box_btn.setIcon(QIcon(refresh_icon))
        self.backButton.setIcon(QIcon(back_icon))

        self.cancelBtn.hide()

        self.editBtn.pressed.connect(self.edit_user)
        self.cancelBtn.pressed.connect(self.cancel_edit_user)
        self.deleteBtn.pressed.connect(self.delete_user)
        self.refresh_combo_box_btn.pressed.connect(self.fill_cb_users)
        self.backButton.pressed.connect(self.back)
        self.lineEditDni.textChanged.connect(self.comprueba_dni)

        self.fill_cb_users()

        self.text_read_only()
예제 #8
0
class Login(QDialog):
    def __init__(self):
        super(Login, self).__init__()
        # Carreguem el login.ui
        loadUi(loginui, self)
        self.setWindowIcon(QIcon(app_icon))

        # Clase per a fer les consultes Sqlite
        self.sqlite = SQLite_consulter()

        self.pushButtonLogin.clicked.connect(self.loginFunction)
        self.showMessageBox = QMessageBox()

    def loginFunction(self):
        line_edit_dni = self.lineEditDni.text()
        line_edit_con = self.lineEditCon.text()
        # Encriptem el password introduit
        h = hashlib.new("sha1", line_edit_con.encode("UTF-8"))
        
        result = self.sqlite.ask_user_to_db(line_edit_dni, line_edit_con)

        # Comprobem si existeix l´usuari
        if(len(result.fetchall()) > 0):
            
            # Si troba l´usuari, canviarà a la finestra següent
            #self.windowCron = cronometro.Window(line_edit_dni)
            self.windowMenu = menu.MainWindow(line_edit_dni)
            self.sqlite.close_connection()
            window.close()
        else:
            
            # Mostrem una finestra informant que l´usuari o contraseña introduit no es correcte

            self.showMessageBox.setIcon(QMessageBox.Critical)
            self.showMessageBox.setText("\n\nUsuari o contrasenya incorrectes")
            self.showMessageBox.exec_()
예제 #9
0
class Modifica_usuaris(QDialog):
    def __init__(self):
        super(Modifica_usuaris, self).__init__()

        # Carreguem el login.ui
        loadUi(modificar_usuaris_ui, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Modificar usuaris")
        self.deleteDialogBox = QMessageBox()
        self.editDialogBox = QMessageBox()
        self.showMessageBox = QMessageBox()

        self.sqlite = SQLite_consulter()

        self.editBtn.setText("Editar")
        self.editBtn.setEnabled(False)
        self.dniValid = False
        self.editMode = False
        self.cancelBtn.setText("Cancelar")
        self.deleteBtn.setText("Borrar")
        self.deleteBtn.setEnabled(False)
        self.deleteBtn.setStyleSheet("")
        self.refresh_combo_box_btn.setIcon(QIcon(refresh_icon))
        self.backButton.setIcon(QIcon(back_icon))

        self.cancelBtn.hide()

        self.editBtn.pressed.connect(self.edit_user)
        self.cancelBtn.pressed.connect(self.cancel_edit_user)
        self.deleteBtn.pressed.connect(self.delete_user)
        self.refresh_combo_box_btn.pressed.connect(self.fill_cb_users)
        self.backButton.pressed.connect(self.back)
        self.lineEditDni.textChanged.connect(self.comprueba_dni)

        self.fill_cb_users()

        self.text_read_only()

        # self.show()

    def fill_cb_users(self):

        self.cbUsers.clear()
        self.cbUsers.addItem("Selecciona un usuari")
        for user in self.sqlite.all_users():
            user_dni = user[0]
            self.cbUsers.addItem(user_dni)

        self.cbUsers.currentIndexChanged.connect(self.selection_change_user)

        self.editBtn.setEnabled(False)
        self.editMode = False
        self.cancelBtn.hide()
        self.deleteBtn.setEnabled(False)
        self.deleteBtn.setStyleSheet("")
        self.editBtn.setText("Editar")
        self.editBtn.setStyleSheet("")
        self.cbUsers.setEnabled(True)

    def selection_change_user(self):

        if (self.cbUsers.currentText() != "Selecciona un usuari"
                and self.cbUsers.currentText() != ""):

            info_user = self.sqlite.get_user_info(self.cbUsers.currentText())

            self.user_dni = info_user[0][0]
            self.user_passwd = info_user[0][1]

            self.lineEditDni.setText(self.user_dni)
            self.lineEditPasswd.setText(self.user_passwd)

            self.deleteBtn.setEnabled(True)
            self.deleteBtn.setStyleSheet("color: red;")
            self.editBtn.setEnabled(True)

        else:

            self.lineEditDni.setText("")
            self.lineEditPasswd.setText("")

            self.editBtn.setEnabled(False)
            self.editMode = False
            self.cancelBtn.hide()
            self.deleteBtn.setEnabled(False)
            self.deleteBtn.setStyleSheet("")
            self.editBtn.setText("Editar")
            self.editBtn.setStyleSheet("")

            self.text_read_only()

    def edit_user(self):
        if (self.editMode):

            self.editDialogBox.setStandardButtons(QMessageBox.Yes
                                                  | QMessageBox.No)
            self.editDialogBox.setDefaultButton(QMessageBox.No)
            self.editDialogBox.setIcon(QMessageBox.Information)
            self.editDialogBox.setText(
                "\n\nEstas segur de que vols guardar la modificacio del usuari "
                + self.user_dni + "?")
            self.editDialogBox.buttonClicked.connect(self.sure_to_save)
            self.contador = 0
            self.editDialogBox.exec_()

        else:
            self.editMode = not self.editMode
            self.editBtn.setText("Guardar")
            self.editBtn.setStyleSheet("color: #008000;")
            self.cancelBtn.show()
            self.cbUsers.setEnabled(False)

            self.user_old_info_dni = self.lineEditDni.text()
            self.user_old_info_passwd = self.lineEditPasswd.text()

            self.text_edit_only()

    def sure_to_save(self, selection):

        self.contador += 1
        if (self.contador == 1):
            if (selection.text() == "&Yes"):

                self.user_new_info_dni = self.lineEditDni.text()
                self.user_new_info_passwd = self.lineEditPasswd.text()

                if (self.user_new_info_passwd != ""):
                    if (len(self.user_new_info_dni) == 9 and self.dniValid):

                        self.sqlite.modify_user(self.user_old_info_dni,
                                                self.user_new_info_dni,
                                                self.user_new_info_passwd)

                        self.editMode = not self.editMode
                        self.editBtn.setText("Editar")
                        self.editBtn.setStyleSheet("")
                        self.cancelBtn.hide()

                        self.text_read_only()
                        self.cbUsers.setEnabled(True)
                        self.fill_cb_users()
                    else:
                        self.showMessageBox.setWindowTitle("Error")
                        self.showMessageBox.setIcon(QMessageBox.Critical)
                        self.showMessageBox.setText(
                            "\n\nusuari no inserit, format del DNI no valid.")
                        self.showMessageBox.exec_()
                else:
                    self.showMessageBox.setWindowTitle("Error")
                    self.showMessageBox.setIcon(QMessageBox.Critical)
                    self.showMessageBox.setText(
                        "\n\nusuari no inserit, completa tots els camps.")
                    self.showMessageBox.exec_()

    def cancel_edit_user(self):

        self.cancelBtn.hide()
        self.editMode = not self.editMode
        self.editBtn.setText("Editar")
        self.editBtn.setStyleSheet("")

        self.text_read_only()
        self.cbUsers.setEnabled(True)
        self.lineEditDni.setText(self.user_old_info_dni)
        self.lineEditPasswd.setText(self.user_old_info_passwd)

    def delete_user(self):

        if (self.cbUsers.currentText() != "Selecciona un usuari"):

            self.deleteDialogBox.setStandardButtons(QMessageBox.Yes
                                                    | QMessageBox.Cancel)
            self.deleteDialogBox.setDefaultButton(QMessageBox.Cancel)
            self.deleteDialogBox.setIcon(QMessageBox.Critical)
            self.deleteDialogBox.setText(
                "\n\nEstas segur de que vols eliminar el usuari " +
                self.user_dni + "?")
            self.deleteDialogBox.buttonClicked.connect(self.sure_to_delete)
            self.contador = 0
            self.deleteDialogBox.exec_()

            # self.sqlite.delete_user(self.user_dni)

    def sure_to_delete(self, selection):

        self.contador += 1
        if (self.contador == 1):
            if (selection.text() == "&Yes"):
                self.sqlite.delete_user(self.user_dni)
                self.fill_cb_users()
                self.editBtn.setEnabled(False)
                self.editMode = False
                self.cancelBtn.hide()
                self.cbUsers.setEnabled(True)

    def text_edit_only(self):

        self.lineEditDni.setReadOnly(False)
        self.lineEditPasswd.setReadOnly(False)

    def text_read_only(self):

        self.lineEditDni.setReadOnly(True)
        self.lineEditPasswd.setReadOnly(True)

    def back(self):
        self.alta_usuaris_window = alta_usuaris.Alta_usuaris()
        self.alta_usuaris_window.show()
        self.close()

    def comprueba_dni(self):
        nif = self.lineEditDni.text()

        if (len(nif) == 9):
            dni = ""
            for i in range(0, 8):
                dni += nif[i]

            palabra = 'TRWAGMYFPDXBNJZSQVHLCKE'
            letra = palabra[int(dni) % 23]
            if (nif[8] == letra):
                self.lineEditDni.setStyleSheet("background-color: green;")
                self.dniValid = True
            else:
                self.lineEditDni.setStyleSheet("background-color: red;")
                self.dniValid = False
        else:
            self.lineEditDni.setStyleSheet("")
            self.dniValid = False
class Modifica_pacients(QDialog):
    def __init__(self):
        super(Modifica_pacients, self).__init__()

        # Carreguem el login.ui
        loadUi(modificar_pacients_ui, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Modificar pacients")
        self.deleteDialogBox = QMessageBox()
        self.cancelDialogBox = QMessageBox()
        self.editDialogBox = QMessageBox()
        self.showMessageBox = QMessageBox()

        self.sqlite = SQLite_consulter()

        self.editBtn.setText("Editar")
        self.editBtn.setEnabled(False)
        self.editMode = False
        self.cancelBtn.setText("Cancelar")
        self.deleteBtn.setText("Borrar")
        self.deleteBtn.setEnabled(False)
        self.deleteBtn.setStyleSheet("")
        self.refresh_combo_box_btn.setIcon(QIcon(refresh_icon))
        self.backButton.setIcon(QIcon(back_icon))

        self.text_fase_enfermetat = 1
        self.text_genere = "Home"
        self.dniValid = False
        self.textDni.textChanged.connect(self.comprueba_dni)

        self.cancelBtn.hide()

        self.editBtn.pressed.connect(self.edit_patient)
        self.cancelBtn.pressed.connect(self.cancel_edit_patient)
        self.deleteBtn.pressed.connect(self.delete_patient)
        self.refresh_combo_box_btn.pressed.connect(self.fill_cb_patients)
        self.backButton.pressed.connect(self.back)

        self.fill_cb_patients()

        self.block_ui(True)

        # self.show()

    def fill_cb_gender(self):
        #self.cbGender.setPlaceHolderText("Selecciona genere")
        self.cbGender.addItem("Home")
        self.cbGender.addItem("Dona")
        self.cbGender.currentIndexChanged.connect(
            self.selection_change_gender)

    def selection_change_gender(self):
        self.text_genere = self.cbGender.currentText()

    def fill_cb_phase(self):
        #self.cbPhaseDisease.setPlaceHolderText("Selecciona fase")
        self.cbPhaseDisease.addItem("Estadio 1")
        self.cbPhaseDisease.addItem("Estadio 1.5")
        self.cbPhaseDisease.addItem("Estadio 2")
        self.cbPhaseDisease.addItem("Estadio 2.5")
        self.cbPhaseDisease.addItem("Estadio 3")
        self.cbPhaseDisease.addItem("Estadio 4")
        self.cbPhaseDisease.addItem("Estadio 5")
        self.cbPhaseDisease.currentIndexChanged.connect(
            self.selection_change_phase)

    def selection_change_phase(self):
        
        self.text_fase_enfermetat = float(self.cbPhaseDisease.currentText().split(" ")[1])

    def fill_cb_patients(self):

        self.cbPatients.clear()
        self.cbPatients.addItem("Selecciona un pacient")
        for patient in self.sqlite.ask_for_patients_to_fill_combo_box():
            patient_name_surname = patient[0] + " " + patient[1]
            self.cbPatients.addItem(patient_name_surname)

        self.cbPatients.currentIndexChanged.connect(
            self.selection_change_patient)

        self.editBtn.setEnabled(False)
        self.editMode = False
        self.cancelBtn.hide()
        self.deleteBtn.setEnabled(False)
        self.deleteBtn.setStyleSheet("")
        self.editBtn.setText("Editar")
        self.editBtn.setStyleSheet("")
        self.cbPatients.setEnabled(True)

    def selection_change_patient(self):

        if(self.cbPatients.currentText() != "Selecciona un pacient" and self.cbPatients.currentText() != ""):

            info_patient = self.sqlite.get_patient_info(
                self.cbPatients.currentText())

            self.patient_dni = info_patient[0]
            self.patient_name = info_patient[1]
            self.patient_surname = info_patient[2]
            self.patient_height = info_patient[3]
            self.patient_weight = info_patient[4]
            self.patient_birth_date = info_patient[5]
            self.patient_diagnose_disease = info_patient[6]
            self.patient_gender = info_patient[7]
            self.patient_address = info_patient[8]
            self.patient_disease_phase = info_patient[9]
            self.patient_imc = info_patient[10]
            self.patient_medication = info_patient[11]
            self.patient_mail = info_patient[12]
            self.patient_pgc = info_patient[13]
            self.patient_phone = info_patient[14]
            self.patient_sip = info_patient[15]

            self.textDni.setText(self.patient_dni)
            self.textName.setText(self.patient_name)
            self.textSurname.setText(self.patient_surname)
            self.textHeight.setText(str(self.patient_height))
            self.textWeight.setText(str(self.patient_weight))
            #self.textBirthDate.setDate(str(self.patient_birth_date))
            #self.textDEDate.setDate(str(self.patient_diagnose_disease))
            self.textAddress.setText(self.patient_address)
            self.textIMC.setText(str(self.patient_imc))
            self.textMP.setText(self.patient_medication)
            self.textMail.setText(self.patient_mail)
            self.textPGC.setText(str(self.patient_pgc))
            self.textPhone.setText(str(self.patient_phone))
            self.textSIP.setText(str(self.patient_sip))

            if(self.patient_gender == "Home"):

                self.cbGender.setCurrentIndex(0)
            else:
                self.cbGender.setCurrentIndex(1)

            if(self.patient_disease_phase == "1"):
                self.cbPhaseDisease.setCurrentIndex(0)
            elif(self.patient_disease_phase == "1.5"):
                self.cbPhaseDisease.setCurrentIndex(1)
            elif(self.patient_disease_phase == "2"):
                self.cbPhaseDisease.setCurrentIndex(2)
            elif(self.patient_disease_phase == "2.5"):
                self.cbPhaseDisease.setCurrentIndex(3)
            elif(self.patient_disease_phase == "3"):
                self.cbPhaseDisease.setCurrentIndex(4)
            elif(self.patient_disease_phase == "4"):
                self.cbPhaseDisease.setCurrentIndex(5)
            elif(self.patient_disease_phase == "5"):
                self.cbPhaseDisease.setCurrentIndex(6) 

            self.deleteBtn.setEnabled(True)
            self.deleteBtn.setStyleSheet("color: red;")
            self.editBtn.setEnabled(True)

        else:

            self.textDni.setText("")
            self.textName.setText("")
            self.textSurname.setText("")
            self.textHeight.setText("")
            self.textWeight.setText("")
            #self.textBirthDate.setText("")
            #self.textDEDate.setText("")
            self.textAddress.setText("")
            self.textIMC.setText("")
            self.textMP.setText("")
            self.textMail.setText("")
            self.textPGC.setText("")
            self.textPhone.setText("")
            self.textSIP.setText("")

            self.cbGender.setCurrentIndex(0)
            self.cbPhaseDisease.setCurrentIndex(0)

            self.editBtn.setEnabled(False)
            self.editMode = False
            self.cancelBtn.hide()
            self.deleteBtn.setEnabled(False)
            self.deleteBtn.setStyleSheet("")
            self.editBtn.setText("Editar")
            self.editBtn.setStyleSheet("")

            self.block_ui(True)

    def edit_patient(self):
        if(self.editMode):

            self.editDialogBox.setStandardButtons(
                QMessageBox.Yes | QMessageBox.No)
            self.editDialogBox.setDefaultButton(QMessageBox.No)
            self.editDialogBox.setIcon(QMessageBox.Information)
            self.editDialogBox.setText("\n\nEstas segur de que vols guardar la modificacio del pacient " +
                                       self.patient_name + " " + self.patient_surname + "?")
            self.editDialogBox.buttonClicked.connect(self.sure_to_save)
            self.contador = 0
            self.editDialogBox.exec_()

        else:
            self.editMode = not self.editMode
            self.editBtn.setText("Guardar")
            self.editBtn.setStyleSheet("color: #008000;")
            self.cancelBtn.show()
            self.cbPatients.setEnabled(False)

            self.patient_old_info_dni = self.textDni.text()
            self.patient_old_info_name = self.textName.text()
            self.patient_old_info_surname = self.textSurname.text()
            self.patient_old_info_height = self.textHeight.text()
            self.patient_old_info_weight = self.textWeight.text()
            self.patient_old_info_birth_date = self.textBirthDate.text()
            self.patient_old_info_diagnose_disease = self.textDEDate.text()
            self.patient_old_info_gender = self.text_genere
            self.patient_old_info_address = self.textAddress.text()
            self.patient_old_info_disease_phase = self.text_fase_enfermetat
            self.patient_old_info_imc = self.textIMC.text()
            self.patient_old_info_medication = self.textMP.text()
            self.patient_old_info_mail = self.textMail.text()
            self.patient_old_info_pgc = self.textPGC.text()
            self.patient_old_info_phone = self.textPhone.text()
            self.patient_old_info_sip = self.textSIP.text()
            
            self.block_ui(False)

    def sure_to_save(self, selection):

        self.contador += 1
        if(self.contador == 1):
            if(selection.text() == "&Yes"):

                self.patient_new_info_dni = self.textDni.text()
                self.patient_new_info_name = self.textName.text()
                self.patient_new_info_surname = self.textSurname.text()
                self.patient_new_info_height = self.textHeight.text()
                self.patient_new_info_weight = self.textWeight.text()
                self.patient_new_info_birth_date = self.textBirthDate.text()
                self.patient_new_info_diagnose_disease = self.textDEDate.text()
                self.patient_new_info_gender = self.text_genere
                self.patient_new_info_address = self.textAddress.text()
                self.patient_new_info_disease_phase = self.text_fase_enfermetat
                self.patient_new_info_imc = self.textIMC.text()
                self.patient_new_info_medication = self.textMP.text()
                self.patient_new_info_mail = self.textMail.text()
                self.patient_new_info_pgc = self.textPGC.text()
                self.patient_new_info_phone = self.textPhone.text()
                self.patient_new_info_sip = self.textSIP.text()

                if(self.patient_new_info_name != "" and self.patient_new_info_surname != ""):
                    if(len(self.patient_new_info_dni) == 9 and self.dniValid):

                        self.sqlite.modify_patient(self.patient_old_info_dni, self.patient_new_info_dni, self.patient_new_info_name,
                                                   self.patient_new_info_surname, float(self.patient_new_info_height), int(self.patient_new_info_weight), self.patient_new_info_birth_date, self.patient_new_info_diagnose_disease, self.patient_new_info_gender, self.patient_new_info_address, self.patient_new_info_disease_phase, self.patient_new_info_imc, self.patient_new_info_medication, self.patient_new_info_mail, self.patient_new_info_pgc, self.patient_new_info_phone, self.patient_new_info_sip)

                        self.editMode = not self.editMode
                        self.editBtn.setText("Editar")
                        self.editBtn.setStyleSheet("")
                        self.cancelBtn.hide()

                        self.block_ui(True)
                        self.cbPatients.setEnabled(True)
                        self.fill_cb_patients()
                    else:
                        self.showMessageBox.setWindowTitle("Error")
                        self.showMessageBox.setIcon(QMessageBox.Critical)
                        self.showMessageBox.setText(
                            "\n\nPacient no inserit, format del DNI no valid.")
                        self.showMessageBox.exec_()
                else:
                    self.showMessageBox.setWindowTitle("Error")
                    self.showMessageBox.setIcon(QMessageBox.Critical)
                    self.showMessageBox.setText(
                        "\n\nPacient no inserit, completa tots els camps.")
                    self.showMessageBox.exec_()

    def cancel_edit_patient(self):

        self.cancelBtn.hide()
        self.editMode = not self.editMode
        self.editBtn.setText("Editar")
        self.editBtn.setStyleSheet("")

        self.block_ui(True)
        self.cbPatients.setEnabled(True)
        self.fill_cb_patients() 

    def delete_patient(self):

        if(self.cbPatients.currentText() != "Selecciona un pacient"):

            self.deleteDialogBox.setStandardButtons(
                QMessageBox.Yes | QMessageBox.Cancel)
            self.deleteDialogBox.setDefaultButton(QMessageBox.Cancel)
            self.deleteDialogBox.setIcon(QMessageBox.Critical)
            self.deleteDialogBox.setText(
                "\n\nEstas segur de que vols eliminar el pacient " + self.patient_name + " " + self.patient_surname + "?")
            self.deleteDialogBox.buttonClicked.connect(self.sure_to_delete)
            self.contador = 0
            self.deleteDialogBox.exec_()

            # self.sqlite.delete_patient(self.patient_dni)

    def sure_to_delete(self, selection):

        self.contador += 1
        if(self.contador == 1):
            if(selection.text() == "&Yes"):
                self.sqlite.delete_patient(self.patient_dni)
                self.fill_cb_patients()
                self.editBtn.setEnabled(False)
                self.editMode = False
                self.cancelBtn.hide()
                self.cbPatients.setEnabled(True)

    def block_ui(self, value):

        self.textDni.setReadOnly(value)
        self.textName.setReadOnly(value)
        self.textSurname.setReadOnly(value)
        self.textHeight.setReadOnly(value)
        self.textWeight.setReadOnly(value)
        self.textBirthDate.setReadOnly(value)
        self.textDEDate.setReadOnly(value)
        self.textAddress.setReadOnly(value)
        self.textIMC.setReadOnly(value)
        self.textMP.setReadOnly(value)
        self.textMail.setReadOnly(value)
        self.textPGC.setReadOnly(value)
        self.textPhone.setReadOnly(value)
        self.textSIP.setReadOnly(value)
        self.cbGender.setEnabled(not value)
        self.cbPhaseDisease.setEnabled(not value)

    def comprueba_dni(self):
        nif = self.textDni.text()

        if (len(nif) == 9):
            dni = ""
            for i in range(0, 8):
                dni += nif[i]
            
            palabra = 'TRWAGMYFPDXBNJZSQVHLCKE'
            letra = palabra[int(dni) % 23]
            if(nif[8] == letra):
                self.textDni.setStyleSheet("background-color: green;")
                self.dniValid = True
            else:                
                self.textDni.setStyleSheet("background-color: red;")
                self.dniValid = False
        else:
            self.textDni.setStyleSheet("")
            self.dniValid = False

    def back(self):
        self.alta_pacients_window = alta_pacients.Alta_pacients()
        self.alta_pacients_window.show()
        self.close()
예제 #11
0
class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        #Carreguem el grafica_pacients.ui
        loadUi(grafica_pacients_ui, self)
        self.setWindowIcon(QIcon(app_icon))

        self.setWindowTitle("Gràfica Pacients")
        self.showMessageBox = QMessageBox()

        # Per a canviar el color de fondo
        self.graphWidget.setBackground("w")

        #Afegim titol i color
        self.graphWidget.setTitle("Gràfica Pacients", color='k', size="15pt")

        #temps (s)
        self.graphWidget.setLabel(
            'left',
            "<span style=\"color:black;fontsize:30px\">Temps (s)</span>")

        #dies
        self.graphWidget.setLabel(
            'bottom', "<span style=\"color:black;fontsize:30px\">Dia</span>")

        #Afegim una cuadrícula a la gràfica
        self.graphWidget.showGrid(x=True, y=True)

        #Afegim el rango de la X i la Y en aquest cas
        self.graphWidget.setXRange(0, 10, padding=0.001)
        self.graphWidget.setYRange(0, 50, padding=0.01)

        #Connecting to class to connect to database
        self.sqlite = SQLite_consulter()

        self.cBPacients.addItem("Selecciona un pacient")
        for patient in self.sqlite.ask_for_patients_to_fill_combo_box():
            patient_name_surname = patient[0] + " " + patient[1]
            self.cBPacients.addItem(patient_name_surname)

        self.cBPacients.currentIndexChanged.connect(
            self.selection_change_patient)

        self.return_btn.setIcon(QIcon(back_icon))
        self.return_btn.pressed.connect(self.back)

        #Mostrem la finestra
        self.show()

    #Funció per a la sel·lecció del pacient
    def selection_change_patient(self):

        self.selected_patient = self.cBPacients.currentText()
        if (self.selected_patient != "Selecciona un pacient"):

            info_patient = self.sqlite.get_patient_info(self.selected_patient)

            self.patient_dni = info_patient[0][0]
            self.patient_name = info_patient[0][1]
            self.patient_surname = info_patient[0][2]

            #Es borra el contigut de la gràfica cada vegada que canviem de pacient
            self.graphWidget.clear()

            #Per a obtenir el temps de la primera volta
            self.lap_one = self.sqlite.get_patient_lap1_info(
                self.selected_patient)
            self.llistaTempsLapUno = []

            for iVolta1 in self.lap_one:
                #self.llistaTempsLapUno.append(iVolta1[0])

                for jVolta1 in iVolta1:
                    self.llistaTempsLapUno.append(jVolta1)

            xVolta1 = range(0, len(self.llistaTempsLapUno))
            lineVolta1 = self.graphWidget.plot(xVolta1,
                                               self.llistaTempsLapUno,
                                               pen='r',
                                               symbol='x',
                                               symbolPen='r',
                                               symbolBrush=0.5,
                                               name='red')

            #Per a obtenir el temps de la segona volta
            self.lap_two = self.sqlite.get_patient_lap2_info(
                self.selected_patient)
            self.llistaTempsLapDos = []

            for iVolta2 in self.lap_two:
                for jVolta2 in iVolta2:
                    self.llistaTempsLapDos.append(jVolta2)

            xVolta2 = range(0, len(self.llistaTempsLapDos))
            lineVolta2 = self.graphWidget.plot(xVolta2,
                                               self.llistaTempsLapDos,
                                               pen='b',
                                               symbol='x',
                                               symbolPen='b',
                                               symbolBrush=0.5,
                                               name='blue')

            #Per a obtenir el temps de la tecera volta
            self.lap_three = self.sqlite.get_patient_lap3_info(
                self.selected_patient)
            self.llistaTempsLapTres = []

            for iVolta3 in self.lap_three:
                for jVolta3 in iVolta3:
                    self.llistaTempsLapTres.append(jVolta3)

            xVolta3 = range(0, len(self.llistaTempsLapTres))
            lineVolta3 = self.graphWidget.plot(xVolta3,
                                               self.llistaTempsLapTres,
                                               pen='m',
                                               symbol='x',
                                               symbolPen='m',
                                               symbolBrush=0.5,
                                               name='magenta')

            #Per a obtenir el temps total de les voltes
            self.lap_total = self.sqlite.get_patient_lap_info(
                self.selected_patient)
            self.llistaTempsTotal = []

            for i in self.lap_total:
                for j in i:
                    self.llistaTempsTotal.append(j)

            x = range(0, len(self.llistaTempsTotal))

            lineTotal = self.graphWidget.plot(x,
                                              self.llistaTempsTotal,
                                              pen='g',
                                              symbol='x',
                                              symbolPen='g',
                                              symbolBrush=0.5,
                                              name='green')

    def back(self):
        self.windowMenu = menu.MainWindow("")
        self.windowMenu.show()
        self.close()
예제 #12
0
class Time_settings(QDialog):
    def __init__(self):

        super(Time_settings, self).__init__()

        # Carreguem el login.ui
        loadUi(time_settings_ui, self)
        self.setWindowTitle("Ajustaments")
        self.setWindowIcon(QIcon(app_icon))

        self.cancelDialogBox = QMessageBox()
        self.editDialogBox = QMessageBox()
        self.parameterDialogBox = QMessageBox()

        self.sqlite = SQLite_consulter()

        self.return_btn.hide()
        self.edit_btn.setText("Editar")
        self.edit_btn.setEnabled(False)
        self.editMode = False
        self.cancel_btn.setText("Cancelar")
        self.combo_box_refresh_btn.setIcon(QIcon(refresh_icon))
        self.return_btn.setIcon(QIcon(back_icon))

        self.cancel_btn.hide()

        self.edit_btn.pressed.connect(self.edit_patient)
        self.cancel_btn.pressed.connect(self.cancel_edit_patient)
        self.combo_box_refresh_btn.pressed.connect(self.fill_cb_status)
        self.return_btn.pressed.connect(self.back)

        self.fill_cb_status()

        self.text_read_only()

    def fill_cb_status(self):

        self.combo_box_status.clear()
        self.combo_box_status.addItem("Selecciona un estat")
        for status in self.sqlite.ask_times_to_fill_combo_box():
            self.status = status[0]
            self.combo_box_status.addItem(self.status)

        self.combo_box_status.currentIndexChanged.connect(
            self.selection_change_status)

        self.edit_btn.setEnabled(False)
        self.editMode = False
        self.cancel_btn.hide()
        self.edit_btn.setText("Editar")
        self.edit_btn.setStyleSheet("")
        self.combo_box_status.setEnabled(True)

    def selection_change_status(self):

        if (self.combo_box_status.currentText() != "Selecciona un estat"
                and self.combo_box_status.currentText() != ""):

            status_info = self.sqlite.get_status_info(
                self.combo_box_status.currentText())

            self.lap1 = status_info[1]
            self.lap2 = status_info[2]
            self.lap3 = status_info[3]
            self.total_lap = status_info[4]

            self.lap1_text_edit.setText(str(self.lap1))
            self.lap2_text_edit.setText(str(self.lap2))
            self.lap3_text_edit.setText(str(self.lap3))
            self.total_lap_text_edit.setText(str(self.total_lap))
            self.status = self.combo_box_status.currentText()

            self.edit_btn.setEnabled(True)

        else:

            self.lap1_text_edit.setText("")
            self.lap2_text_edit.setText("")
            self.lap3_text_edit.setText("")
            self.total_lap_text_edit.setText("")

            self.edit_btn.setEnabled(False)
            self.editMode = False
            self.cancel_btn.hide()
            self.edit_btn.setText("Editar")
            self.edit_btn.setStyleSheet("")

            self.text_read_only()

    def edit_patient(self):
        if (self.editMode):

            self.editDialogBox.setStandardButtons(QMessageBox.Yes
                                                  | QMessageBox.No)
            self.editDialogBox.setDefaultButton(QMessageBox.No)
            self.editDialogBox.setIcon(QMessageBox.Information)
            self.editDialogBox.setText(
                "\n\nEstas segur de que vols guardar la modificacio del estat "
                + self.status + "?")
            self.editDialogBox.buttonClicked.connect(self.sure_to_save)
            self.contador = 0
            self.editDialogBox.exec_()

        else:

            self.editMode = not self.editMode
            self.edit_btn.setText("Guardar")
            self.edit_btn.setStyleSheet("color: #008000;")
            self.cancel_btn.show()
            self.combo_box_status.setEnabled(False)

            self.lap1_old_info = float(self.lap1_text_edit.text())
            self.lap2_old_info = float(self.lap2_text_edit.text())
            self.lap3_old_info = float(self.lap3_text_edit.text())
            self.total_lap_old_info = float(self.total_lap_text_edit.text())

            self.text_edit()

    def sure_to_save(self, selection):

        self.contador += 1
        if (self.contador == 1):
            if (selection.text() == "&Yes"):

                try:
                    self.lap1_new_info = float(self.lap1_text_edit.text())
                except:
                    self.lap1_new_info = self.lap1_text_edit.text()

                try:
                    self.lap2_new_info = float(self.lap2_text_edit.text())
                except:
                    self.lap2_new_info = self.lap2_text_edit.text()
                try:
                    self.lap3_new_info = float(self.lap3_text_edit.text())
                except:
                    self.lap3_new_info = self.lap3_text_edit.text()
                try:
                    self.total_new_old_info = float(
                        self.total_lap_text_edit.text())
                except:
                    self.total_new_old_info = self.total_lap_text_edit.text()

                if (str(self.lap1_new_info) != ""
                        and str(self.lap2_new_info) != ""
                        and str(self.lap3_new_info) != ""):

                    self.editMode = not self.editMode
                    self.edit_btn.setText("Editar")
                    self.edit_btn.setStyleSheet("")
                    self.cancel_btn.hide()

                    self.text_read_only()
                    self.combo_box_status.setEnabled(True)
                    self.sqlite.modify_status(self.status, self.lap1_new_info,
                                              self.lap2_new_info,
                                              self.lap3_new_info,
                                              self.total_new_old_info)
                    self.fill_cb_status()
                else:
                    self.parameterDialogBox.setWindowTitle("Error")
                    self.parameterDialogBox.setIcon(QMessageBox.Critical)
                    self.parameterDialogBox.setText(
                        "\n\nTemps no modificat, no deixes ningun camp buit.")
                    self.parameterDialogBox.exec_()

    def cancel_edit_patient(self):

        self.cancel_btn.hide()
        self.editMode = not self.editMode
        self.edit_btn.setText("Editar")
        self.edit_btn.setStyleSheet("")

        self.text_read_only()
        self.combo_box_status.setEnabled(True)
        self.lap1_text_edit.setText(str(self.lap1_old_info))
        self.lap2_text_edit.setText(str(self.lap2_old_info))
        self.lap3_text_edit.setText(str(self.lap3_old_info))
        self.total_lap_text_edit.setText(str(self.total_lap_old_info))

    def text_edit(self):

        self.lap1_text_edit.setReadOnly(False)
        self.lap2_text_edit.setReadOnly(False)
        self.lap3_text_edit.setReadOnly(False)
        self.total_lap_text_edit.setReadOnly(False)

    def text_read_only(self):

        self.lap1_text_edit.setReadOnly(True)
        self.lap2_text_edit.setReadOnly(True)
        self.lap3_text_edit.setReadOnly(True)
        self.total_lap_text_edit.setReadOnly(True)

    def back(self):

        self.cronometro = cronometro.Chron(self.user)
        self.cronometro.show()
        self.close()
예제 #13
0
class Alta_usuaris(QDialog):
    def __init__(self):
        super(Alta_usuaris, self).__init__()
        # Carreguem el login.ui
        loadUi(alta_usuaris, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Alta usuaris")
        self.showMessageBox = QMessageBox()
        self.passwdDoesntMatchMessage = QMessageBox()
        self.dniValid = False

        self.pbInserir.clicked.connect(self.inserir_usuaris)
        self.textDni.textChanged.connect(self.comprueba_dni)

        self.pbModificar.clicked.connect(self.modificar_usuaris)
        self.sqlite = SQLite_consulter()

        self.return_btn.setIcon(QIcon(back_icon))
        self.return_btn.pressed.connect(self.back)

    def inserir_usuaris(self):

        text_dni = self.textDni.text()
        text_passwd = self.textPasswd.text()
        text_passwd2 = self.textPasswd2.text()
        
        try:

            if(text_passwd != ""):
                if(text_passwd == text_passwd2):

                    if(len(text_dni) == 9 and self.dniValid):

                        result = self.sqlite.insert_user(text_dni, text_passwd)
                        self.showMessageBox.setWindowTitle("Done")
                        self.showMessageBox.setIcon(QMessageBox.Information)
                        self.showMessageBox.setText("\n\nUsuari inserit correctament!")

                        self.textDni.setText("")
                        self.textPasswd.setText("")
                        self.textPasswd2.setText("")
                        

                        self.showMessageBox.exec_()
                    else:
                        self.showMessageBox.setWindowTitle("Error")
                        self.showMessageBox.setIcon(QMessageBox.Critical)
                        self.showMessageBox.setText("\n\nUsuari no inserit, format del DNI no valid.")
                        self.showMessageBox.exec_()
                else:

                    self.passwdDoesntMatchMessage.setWindowTitle("Error")
                    self.passwdDoesntMatchMessage.setIcon(QMessageBox.Critical)
                    self.passwdDoesntMatchMessage.setText("\n\nUsuari no inserit, les contrasenyes no coincideixen.")
                    self.passwdDoesntMatchMessage.exec_()


            else:
                self.showMessageBox.setWindowTitle("Error")
                self.showMessageBox.setIcon(QMessageBox.Critical)
                self.showMessageBox.setText(
                    "\n\nUsuari no inserit, completa tots els camps.")
                self.showMessageBox.exec_()

        except:
            self.showMessageBox.setWindowTitle("Error")
            self.showMessageBox.setIcon(QMessageBox.Critical)
            self.showMessageBox.setText(
                "\n\nError al inserir el usuari en la base de dades. Es posible que ja estiga inserit el DNI del usuari.")
            self.showMessageBox.exec_()

        

    def modificar_usuaris(self):
        self.mod_patients_window = modificar_usuaris.Modifica_usuaris()
        self.mod_patients_window.show()
        self.close()


    def back(self):
        self.pacients_usuaris = pacients_usuaris.Pacients_usuaris()
        self.pacients_usuaris.show()
        self.close()

    def comprueba_dni(self):
        nif = self.textDni.text()

        if (len(nif) == 9):
            dni = ""
            for i in range(0, 8):
                dni += nif[i]
            
            palabra = 'TRWAGMYFPDXBNJZSQVHLCKE'
            letra = palabra[int(dni) % 23]
            if(nif[8] == letra):
                self.textDni.setStyleSheet("background-color: green;")
                self.dniValid = True
            else:                
                self.textDni.setStyleSheet("background-color: red;")
                self.dniValid = False
        else:
            self.textDni.setStyleSheet("")
            self.dniValid = False
예제 #14
0
class Alta_pacients(QDialog):
    def __init__(self):
        super(Alta_pacients, self).__init__()
        # Carreguem el login.ui
        loadUi(alta_pacients_ui, self)
        self.setWindowIcon(QIcon(app_icon))
        self.setWindowTitle("Alta pacients")
        self.showMessageBox = QMessageBox()

        self.pbInserir.clicked.connect(self.inserir_pacient)

        self.pbModificar.clicked.connect(self.modificar_pacient)
        self.sqlite = SQLite_consulter()

        self.textDni.textChanged.connect(self.comprueba_dni)
        self.fill_cb_gender()
        self.fill_cb_phase()
        self.text_fase_enfermetat = 1
        self.text_genere = "Home"
        self.dniValid = False

        self.return_btn.setIcon(QIcon(back_icon))
        self.return_btn.pressed.connect(self.back)

    def fill_cb_gender(self):
        #self.cbGender.setPlaceHolderText("Selecciona genere")
        self.cbGender.addItem("Home")
        self.cbGender.addItem("Dona")
        self.cbGender.currentIndexChanged.connect(
            self.selection_change_gender)

    def selection_change_gender(self):
        self.text_genere = self.cbGender.currentText()

    def fill_cb_phase(self):
        #self.cbPhaseDisease.setPlaceHolderText("Selecciona fase")
        self.cbPhaseDisease.addItem("Estadio 1")
        self.cbPhaseDisease.addItem("Estadio 1.5")
        self.cbPhaseDisease.addItem("Estadio 2")
        self.cbPhaseDisease.addItem("Estadio 2.5")
        self.cbPhaseDisease.addItem("Estadio 3")
        self.cbPhaseDisease.addItem("Estadio 4")
        self.cbPhaseDisease.addItem("Estadio 5")
        self.cbPhaseDisease.currentIndexChanged.connect(
            self.selection_change_phase)

    def selection_change_phase(self):

        self.text_fase_enfermetat = float(
            self.cbPhaseDisease.currentText().split(" ")[1])

    def inserir_pacient(self):

        text_dni = str(self.textDni.text())
        text_nom = str(self.textName.text())
        text_cognom = str(self.textSurname.text())
        text_altura = str(self.textHeight.text())
        text_pes = str(self.textWeight.text())
        text_data_naixement = str(self.textBirthDate.text())
        text_data_diagnostic_enfermetat = str(self.textDEDate.text())

        text_adresa = str(self.textAddress.text())

        text_imc = str(self.textIMC.text())
        text_medicacio = str(self.textMP.text())
        text_mail = str(self.textMail.text())
        text_pgc = str(self.textPGC.text())
        text_phone = str(self.textPhone.text())
        text_sip = str(self.textSIP.text())

        try:

            if(text_nom != "" and text_cognom != ""):
                if(len(text_dni) == 9 and self.dniValid):

                    result = self.sqlite.insert_patients(
                        text_dni, text_nom, text_cognom, text_altura, text_pes, text_data_naixement, text_data_diagnostic_enfermetat, self.text_genere, text_adresa, self.text_fase_enfermetat, text_imc, text_medicacio, text_mail, text_pgc, text_phone, text_sip)
                    self.showMessageBox.setWindowTitle("Done")
                    self.showMessageBox.setIcon(QMessageBox.Information)
                    self.showMessageBox.setText(
                        "\n\nPacient inserit correctament!")

                    self.textDni.setText("")
                    self.textName.setText("")
                    self.textSurname.setText("")
                    self.textHeight.setText("")
                    self.textWeight.setText("")
                    # self.textBirthDate.setText("")
                    # self.textDEDate.setText("")
                    self.textAddress.setText("")
                    self.textIMC.setText("")
                    self.textMP.setText("")
                    self.textMail.setText("")
                    self.textPGC.setText("")
                    self.textPhone.setText("")
                    self.textSIP.setText("")
                    self.cbGender.setCurrentIndex(0)
                    self.cbPhaseDisease.setCurrentIndex(0)

                    self.showMessageBox.exec_()

                else:
                    self.showMessageBox.setWindowTitle("Error")
                    self.showMessageBox.setIcon(QMessageBox.Critical)
                    self.showMessageBox.setText(
                        "\n\nPacient no inserit, DNI no valid.")
                    self.showMessageBox.exec_()
            else:
                self.showMessageBox.setWindowTitle("Error")
                self.showMessageBox.setIcon(QMessageBox.Critical)
                self.showMessageBox.setText(
                    "\n\nPacient no inserit, completa tots els camps.")
                self.showMessageBox.exec_()

        except:
            print("dni: " + str(text_dni) + "\n" +
                  "nom: " + str(text_nom) + "\n" +
                  "cognom: " + str(text_cognom) + "\n" +
                  "altura: " + str(text_altura) +
                  "\npes: " + str(text_pes) +
                  "\nnaiximent: " + str(text_data_naixement) +
                  "\ndiagnostic enf: " + str(text_data_diagnostic_enfermetat) +
                  "\nadressa: " + str(text_adresa) +
                  "\nimc: " + str(text_imc) +
                  "\nmedicacio: " + str(text_medicacio) +
                  "\nmail: " + str(text_mail) +
                  "\npercentGrasaCorp: " + str(text_pgc) +
                  "\nphone: " + str(text_phone) +
                  "\nsip: " + str(text_sip) +
                  "\ngenere: " + str(self.text_genere) +
                  "\nestadio: " + str(self.text_fase_enfermetat))
            self.showMessageBox.setWindowTitle("Error")
            self.showMessageBox.setIcon(QMessageBox.Critical)
            self.showMessageBox.setText(
                "\n\nError al inserir el pacient en la base de dades.")
            self.showMessageBox.exec_()

    def modificar_pacient(self):
        self.mod_patients_window = modificar_pacients.Modifica_pacients()
        self.mod_patients_window.show()
        self.close()

    def back(self):
        self.pacients_usuaris = pacients_usuaris.Pacients_usuaris()
        self.pacients_usuaris.show()
        self.close()

    def comprueba_dni(self):
        nif = self.textDni.text()

        if (len(nif) == 9):
            dni = ""
            for i in range(0, 8):
                dni += nif[i]

            palabra = 'TRWAGMYFPDXBNJZSQVHLCKE'
            letra = palabra[int(dni) % 23]
            if(nif[8] == letra):
                self.textDni.setStyleSheet("background-color: green;")
                self.dniValid = True
            else:
                self.textDni.setStyleSheet("background-color: red;")
                self.dniValid = False
        else:
            self.textDni.setStyleSheet("")
            self.dniValid = False