private void btnPatientLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPatientLoginActionPerformed
        String fullName = jFullName.getText();
        String readMasterKeyPath = jReadMasterKey.getText();
        String readPublicKeyPath = jReadPublicKey.getText();
        String writeMasterKeyPath = jWriteMasterKey.getText();
        String writePublicKeyPath = jWritePublicKey.getText();

        if (fullName.isEmpty() || readMasterKeyPath.isEmpty() || readPublicKeyPath.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Please fill up all fields.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        String readMasterKeyChecksum = CryptoUtil.getFileChecksum(readMasterKeyPath, "SHA1");
        String writeMasterKeyChecksum = CryptoUtil.getFileChecksum(writeMasterKeyPath, "SHA1");

        boolean isUserValid = DatabaseClient.getInstance().validatePatientLogin(fullName, readMasterKeyChecksum, writeMasterKeyChecksum);
        if (isUserValid) {
            Session.getInstance().setPatientName(fullName);
            Session.getInstance().setPatientUserId(DatabaseClient.getInstance().getPatientUserId(fullName));
            JOptionPane.showMessageDialog(null, "Login successful", "Login Successful", JOptionPane.INFORMATION_MESSAGE);

            parent.patientHomePanel.update();
            parent.nextPanel(Main.PATIENT_HOME);

            //check if secret key is present, if not create it for patient  
            int pid= DatabaseClient.getInstance().getPid(fullName);
            String attributes = "type:patient type:doctor type:insurance type:employer type:hospital type:health_club pid:"+pid;
            Cpabe cpabe = new Cpabe();
            try {
                cpabe.keygen(readPublicKeyPath, KeyConfig.getInstance().getPatientReadSecretKeyPath(), readMasterKeyPath, attributes);
                cpabe.keygen(writePublicKeyPath, KeyConfig.getInstance().getPatientWriteSecretKeyPath(), writeMasterKeyPath, attributes);
            } catch (NoSuchAlgorithmException ex) {
                Logger.getLogger(PatientLoginPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(PatientLoginPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Check full name, master key, or public key, and try again", "Login Failure", JOptionPane.ERROR_MESSAGE);
        }


    }//GEN-LAST:event_btnPatientLoginActionPerformed