Blood Donation System

Blood Donation System

Evelyn

Evelyn

July 1, 2022

1 min read

#netbeans #healthcare #blood donation #donors

Quick disclaimer: we started with a proposal, which included the introduction, objectives, scope, flowchart, and prototypes. After the presentation, we were given the go-ahead to build the system using NetBeans IDE and Microsoft Access

Introduction

Managing data can be a real headache, especially when time is tight. The Blood Donation System helps to keeps track of everything from donors and patients to blood bank supplies. It’s all about making sure the right info is available quickly to help save lives and do it with less hassle. Efficiency and life-saving, all in one system.

Objectives

  • Manage patient and donor records with ease.
  • Quick access to blood type distribution.
  • Add or remove records effortlessly.
  • Search for specific blood type records.
  • Easily check the amount of available blood.

Scope

  • Create an account with personal details (Name, Email, Phone, etc.).
  • Manage patient records (Name, ID, Blood Group, Disease, etc.).
  • Manage donor records (Name, ID, Blood Group, Medical Report, etc.).
  • Manage blood bank records (Name, Address, Donor names, Contact info).
  • Search and sort blood donation records.
  • View charts from the app’s data.

Flowchart

flowchart.png
The flowchart outlines the entire blood donation process, from user login to managing donations. It gives a clear view of how data moves through the system, the authentication process, and how data in the dashboard is processed.

Database

Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
con = DriverManager.getConnection("jdbc:ucanaccess://C:\\path\\to\\your\\database.accdb");

DriverManager is used to connect to a Microsoft Access database using the Ucanaccess JDBC driver.

Print Screens and Code

1. Authentication

authentication.png
These images showcase the authentication section of the system, including the login and registration pages. Users can either log in if they already have an account or register to create a new one.

2. Dashboard

dashboards.png
Here’s the main dashboard! It gives a quick overview of the system’s activities and key metrics, making it easy for users to navigate to all the important features.

total_blood_chart.png
This chart gives a clear snapshot of the total blood supply, letting users quickly see the current inventory.

tableBloodGUI.java
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
con = DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\MSI-PC\\Desktop\\eve\\Y1S3\\Object Oriented Programming
\\Assignment\\Assignment.accdb");

pst=con.prepareStatement("select count(Blood_Bank) from Donars");
rs = pst.executeQuery();
rs.next();
int count=rs.getInt(1);
int s=count;

pst=con.prepareStatement("select count(Patient) from Donars");
rs = pst.executeQuery();
rs.next();
int count1=rs.getInt(1);
int t=count1;

pst=con.prepareStatement("select count(*) from Donars");
rs = pst.executeQuery();
rs.next();
int count2=rs.getInt(1);
int u=count2;

int totalrest=u-s-t+1;
total3.setText(totalrest+" record(s)");

totalrest is used to calculate the total number of records in the Donars table after excluding those that have values in the Blood_Bank or Patient columns. The result is displayed in the UI element total3.

bloodbank.png
These prototypes show the blood bank section, where users can view and manage blood supplies for each hospital, making sure donations are tracked and up-to-date.

tableBloodGUI.java
public void tableupdate(){
  int c;

  Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  con = DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\MSI-PC\\Desktop\\eve\\Y1S3\\Object Oriented Programming
  \\Assignment\\Assignment.accdb");
  
  pst=con.prepareStatement("select * from Patient");
  rs = pst.executeQuery();
  
  ResultSetMetaData rsd= rs.getMetaData();
  c=rsd.getColumnCount();
  DefaultTableModel dft  = (DefaultTableModel)jTablePatient.getModel();
  dft.setRowCount(0);

  while(rs.next()){
      String id=rs.getString("ID");
      String name=rs.getString("PName");
      String passport=rs.getString("Passport");
      String phonenumber=rs.getString("Phone_Number");
      String date=rs.getString("Date");
      String bloodgroup=rs.getString("Blood_Group");
      String disease=rs.getString("Disease");
      String tbData[]={id,name,passport,phonenumber,date,bloodgroup,disease};
      DefaultTableModel tblModel=(DefaultTableModel)jTablePatient.getModel();
      
      tblModel.addRow(tbData);
  }
}

tableupdate() is used to update the data displayed in a Java GUI table and update associated records from a Microsoft Access database using JDBC (Java Database Connectivity). The code specifically deals with data for Donars, Patients, and BloodBanks every time user updates the table.

3. Add Data

add_data.png
This screen lets users add new data, like donor info or blood inventory, keeping the system fresh and up-to-date.

BloodBankAddPage.java
private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {
  Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  con=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\MSI-PC\\Desktop\\eve\\Y1S3\\
  Object Oriented Programming\\Assignment\\Assignment.accdb");
  
  pst=con.prepareStatement("insert into BloodBank(ID, Company_Name, Address, Contact_Number)values(?,?,?,?)");
  pst.setString(1,id);
  pst.setString(2,company);
  pst.setString(3,address);
  pst.setString(4,ctcnum);
  
  pst.executeUpdate();
  
  pst=con.prepareStatement("UPDATE Donars set Blood_Bank=? where ID=?");
  pst.setString(1,company);
  pst.setString(2,id);
  pst.executeUpdate();
  
  JOptionPane.showMessageDialog(this,"Record Saved");
}

After connected to the database, the addBtnActionPerformedI() code then prepares an INSERT SQL statement to insert the entered data into the BloodBank table which then updates the Donars table.

Conclusion

This project was my first adventure in building a system from scratch using Java, NetBeans IDE, and Microsoft Access as the database. I learned so much along the way and am pretty proud of how it turned out.

Tech Stack

NetBeansNetBeans
JavaJava
Microsoft AccessMicrosoft Access