0% found this document useful (0 votes)
53 views27 pages

Usha Mittal Institute of Technology: Blood Bank Management System

Uploaded by

gargic1606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views27 pages

Usha Mittal Institute of Technology: Blood Bank Management System

Uploaded by

gargic1606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Usha Mittal Institute of Technology

SNDT Women’s University, Mumbai

BLOOD BANK MANAGEMENT SYSTEM

Submitted by:
6 - Saanvi Bijgarnikar
7 - Dipali Budhwat
8 - Gargi Chaudhari
9 - Janhavi Chavan
10 - Amoli Dhuri

Guided by:
Mrs. Iffat Kazi

1
INDEX

INTRODUCTION ........................................................................................................... 3
PROBLEM STATEMENT ................................................................................................4
OBJECTIVE ................................................................................................................... 5
ADVANTAGE ..................................................................................................................5
ER- DIAGRAM ............................................................................................................... 6
TABLES ..........................................................................................................................7
QUERIES ........................................................................................................................8

2
INTRODUCTION

A Blood Bank Management System is a project designed to streamline the


process of managing blood donations, inventories, and requests within
blood banks. This system helps in maintaining accurate records of donors,
patients, blood inventories, and transactions, ensuring that blood is readily
available to patients in need. By using this system, blood banks can
efficiently manage blood stocks, track donations and requests, and improve
the overall coordination between donors and recipients.

This system plays a vital role in healthcare by facilitating the collection of


blood donations, managing inventory, tracking blood types, and monitoring
the usage of blood products in hospitals. With the increasing demand for
blood, especially in emergencies, a well-organized management system is
essential to maintain an adequate supply of safe blood for patients in need.

3
PROBLEM STATEMENT

Blood banks play a crucial role in the healthcare system, but they often face
challenges in managing blood inventories, donor information, and patient
requests. Manual systems for tracking donations, requests, and stock levels can
lead to errors, inefficiencies, and delays.
Blood shortages, expired blood products, and mismatched blood types can also
occur due to poor management. Therefore, there is a need for a comprehensive
system that can address these issues by automating and organizing the blood
bank’s operations.

4
OBJECTIVE

➢ Streamlined Donation Processes: Facilitate easy scheduling and


management of blood donations by donors and blood banks.

➢ Efficient Inventory Tracking: Maintain an up-to-date inventory of blood


units, including tracking expiration dates and blood types.

➢ Improved Data Management: Enable effective management of donor


information, patient requests, and transaction records to enhance
operational efficiency.

➢ Enhanced Reporting and Analytics: Generate reports on blood donations,


inventory status, and usage patterns to aid decision-making and strategic
planning.

ADVANTAGE

➢ Increased Efficiency: Automates various tasks related to blood donation and


inventory management, reducing manual errors and saving time.

➢ Better Inventory Control: Helps prevent wastage by monitoring blood unit


expiration dates and ensuring timely usage or replacement.

➢ Enhanced Communication: Facilitates better communication between


donors, blood banks, and hospitals, ensuring a seamless blood supply chain.

➢ Improved Patient Care: Ensures timely access to safe blood for patients,
particularly in emergencies, thereby improving overall healthcare outcomes.

5
ER- DIAGRAM

6
TABLES

1. DONORS

2. BLOOD BANK

7
3. BLOOD INVENTORY

4. PATIENTS

8
5. BLOOD REQUESTS

6. DONATIONS

9
7. TRANSACTIONS

10
QUERIES

1.Find donors of a specific blood group


Query :
SELECT * FROM Donors WHERE blood_group = 'O-';

2. Get the total quantity of a specific blood group available in a blood bank
Query :
SELECT SUM(quantity) AS total_quantity FROM Blood_Inventory WHERE blood_group
= 'A+' AND blood_bank_id = 1;

3. Find blood donors who donated blood in the last 6 months.


Query :
SELECT * FROM Donors WHERE last_donation_date >= DATE_SUB(CURDATE(), INTERVAL
6 MONTH);

4.Get the details of blood banks in a specific city.


Query :
SELECT * FROM Blood_Banks WHERE location = 'City E';

11
5. Get all blood requests that are still pending.
Query :
SELECT * FROM Blood_Requests WHERE status = 'Pending';

6. Count the number of donations per blood bank.


Query :
SELECT blood_bank_id, COUNT(*) AS total_donations FROM Donations GROUP BY
blood_bank_id;

7. Find donors aged between 18 and 30 years.


Query :
SELECT * FROM Donors WHERE age BETWEEN 18 AND 30;

12
8. Get the total number of blood requests made by a specific patient.
Query :
SELECT COUNT(*) AS total_requests FROM Blood_Requests WHERE patient_id = 402;

9. Get the average age of donors


Query :
SELECT AVG(age) AS average_age FROM Donors;

10. Find the total number of blood requests made in each blood group
Query :
SELECT blood_group, COUNT(*) AS total_requests FROM Blood_Requests GROUP BY
blood_group;

11. Get the total quantity of each blood group requested by patients
Query :
SELECT blood_group, SUM(required_quantity) AS total_requested FROM
Blood_Requests GROUP BY blood_group;

13
12. Find blood that is about to expire in the next 7 days
Query :
SELECT * FROM Blood_Inventory WHERE expiration_date <= DATE_ADD(CURDATE(),
INTERVAL 7 DAY);

13. Find blood inventory records that are expired


Query :
SELECT * FROM Blood_Inventory WHERE expiration_date < CURDATE();

14. Find donors by gender and blood group


Query :
SELECT gender, blood_group, COUNT(*) AS total_donors FROM Donors GROUP BY
gender, blood_group;

14
15. Get the contact details of the manager of a specific blood bank
Query :
SELECT manager_name, contact FROM Blood_Banks WHERE blood_bank_id = 2;

16. Find all patients with blood group O- who have requested blood
Query :
SELECT * FROM Patients p JOIN Blood_Requests br ON p.patient_id =
br.patient_id WHERE p.blood_group = 'O-' AND br.blood_group = 'O-';

17. Find blood donations made by donors above 40 years old


Query :
SELECT * FROM Donations d JOIN Donors don ON d.donor_id = don.donor_id WHERE
don.age > 40;

18. Get the total quantity of blood donated by each donor


Query :

15
SELECT donor_id, SUM(quantity) AS total_quantity FROM Donations GROUP BY
donor_id;

19. Get a summary of total blood donated in each month of the current year
Query :
SELECT MONTH(donation_date) AS month, SUM(quantity) AS total_quantity FROM
Donations WHERE YEAR(donation_date) = YEAR(CURDATE()) GROUP BY month;

20. Get a list of donors who live in a specific city


Query :
SELECT * FROM Donors WHERE address LIKE 'S%';

16
21. Get All Blood Requests with Corresponding Patient Details
Query :
SELECT BR.request_id, P.name AS patient_name, BR.blood_group,
BR.required_quantity, BR.status, BR.request_date
FROM Blood_Requests BR
INNER JOIN Patients P
ON BR.patient_id = P.patient_id;

22. List All Donors with the Blood Bank They Last Donated To, Including Donors
Who Haven't Donated Yet
Query :
SELECT Donors.name AS donor_name, Donations.donation_date, Blood_Banks.name
AS blood_bank_name
FROM Donors
LEFT JOIN Donations ON Donors.donor_id = Donations.donor_id
LEFT JOIN Blood_Banks ON Donations.blood_bank_id = Blood_Banks.blood_bank_id;

23. Show All Blood Banks with Details of Donors Who Have Donated, Including
Blood Banks with No Donations
Query :

17
SELECT Blood_Banks.name AS blood_bank_name, Donors.name AS donor_name,
Donations.donation_date
FROM Donations
RIGHT JOIN Blood_Banks ON Donations.blood_bank_id = Blood_Banks.blood_bank_id
LEFT JOIN Donors ON Donations.donor_id = Donors.donor_id;

24. Find compatible donors for each patient in the Patients table
Query :
SELECT p.patient_id, p.name AS patient_name, p.blood_group AS
patient_blood_group, d.donor_id, d.name AS donor_name, d.blood_group AS
donor_blood_group
FROM Patients p
JOIN Donors d ON (
(p.blood_group = 'O-' AND d.blood_group = 'O-') OR
(p.blood_group = 'O+' AND d.blood_group IN ('O-', 'O+')) OR
(p.blood_group = 'A-' AND d.blood_group IN ('O-', 'A-')) OR
(p.blood_group = 'A+' AND d.blood_group IN ('O-', 'O+', 'A-', 'A+')) OR
(p.blood_group = 'B-' AND d.blood_group IN ('O-', 'B-')) OR
(p.blood_group = 'B+' AND d.blood_group IN ('O-', 'O+', 'B-', 'B+')) OR
(p.blood_group = 'AB-' AND d.blood_group IN ('O-', 'A-', 'B-', 'AB-')) OR
(p.blood_group = 'AB+' AND d.blood_group IN ('O-', 'O+', 'A-', 'A+',
'B-', 'B+', 'AB-', 'AB+'))
)
ORDER BY p.patient_id;

18
19
25. Retrieve the Details of Blood Requests That Are Still Pending
Query :
SELECT Blood_Requests.request_id, Patients.name AS patient_name,
Blood_Requests.blood_group, Blood_Requests.required_quantity,
Blood_Requests.request_date
FROM Blood_Requests
JOIN Patients ON Blood_Requests.patient_id = Patients.patient_id
WHERE Blood_Requests.status = 'Pending';

26. Display the List of Blood Banks and the Total Quantity of Blood They Have
Available
Query :

20
SELECT Blood_Banks.name AS blood_bank_name, SUM(Blood_Inventory.quantity) AS
total_quantity
FROM Blood_Banks
JOIN Blood_Inventory ON Blood_Banks.blood_bank_id =
Blood_Inventory.blood_bank_id
GROUP BY Blood_Banks.blood_bank_id;

27. Total Blood Donations by Each Donor


Query :
SELECT d.donor_id, d.name, d.blood_group, SUM(do.quantity) AS total_donated
FROM Donors d
JOIN Donations do ON d.donor_id = do.donor_id
GROUP BY d.donor_id, d.name, d.blood_group
ORDER BY total_donated DESC;

28. Find Blood Banks in Cities Where a Specific Blood Group is Stored
Query :
SELECT name, location FROM Blood_Banks WHERE blood_bank_id
IN (SELECT blood_bank_id FROM Blood_Inventory WHERE blood_group = 'O+');

21
29. Find Patients Who Have the Same Blood Group as a Donor
Query :
SELECT name, blood_group FROM Patients WHERE blood_group
IN (SELECT blood_group FROM Donors);

30. Find Most Recent Donors and Their Last Donation Date
Query :
SELECT donor_id,name,blood_group, last_donation_date
FROM Donors
ORDER BY last_donation_date DESC;

22
31.List all donors and patients in a combined list with their name, blood group,
and contact information.
Query:
SELECT name, blood_group, contact FROM Donors
UNION
SELECT name, blood_group, contact FROM Patients;

32.List all pending blood requests for patients with blood group 'A-':
Query:
SELECT Patients.name, Blood_Requests.required_quantity,
Blood_Requests.request_date
FROM Blood_Requests
JOIN Patients ON Blood_Requests.patient_id = Patients.patient_id
WHERE Blood_Requests.status = 'Pending' AND Blood_Requests.blood_group =
'A-';

23
33.Query to Get Donors or Patients Who Share the Same Blood Group
Query:
SELECT name, blood_group
FROM Donors
WHERE blood_group IN (SELECT blood_group FROM Patients);

34. Identify blood banks with less than 6 units of 'A+' blood in stock:
Query:
SELECT Blood_Banks.name, Blood_Inventory.quantity
FROM Blood_Inventory
JOIN Blood_Banks ON Blood_Inventory.blood_bank_id = Blood_Banks.blood_bank_id
WHERE Blood_Inventory.blood_group = 'A+' AND Blood_Inventory.quantity < 6;

35. Find the donor who donated the most blood


Query:
SELECT Donors.name, SUM(Donations.quantity) AS total_quantity
FROM Donations
JOIN Donors ON Donations.donor_id = Donors.donor_id
GROUP BY Donors.name
ORDER BY total_quantity DESC
LIMIT 1;

24
36. Retrieve all transactions that occurred in the month of September 2024:
Query:
SELECT Transactions.transaction_id, Blood_Banks.name AS blood_bank,
Blood_Requests.request_id, Transactions.quantity_transferred
FROM Transactions
JOIN Blood_Banks ON Transactions.blood_bank_id = Blood_Banks.blood_bank_id
JOIN Blood_Requests ON Transactions.request_id = Blood_Requests.request_id
WHERE MONTH(Transactions.transaction_date) = 9 AND
YEAR(Transactions.transaction_date) = 2024;

37. Find the blood banks that has fulfilled the most blood requests:
Query:
SELECT Blood_Banks.name, COUNT(Transactions.transaction_id) AS
fulfilled_requests
FROM Transactions
JOIN Blood_Banks ON Transactions.blood_bank_id = Blood_Banks.blood_bank_id
GROUP BY Blood_Banks.name
ORDER BY fulfilled_requests DESC;

38. Update the quantity of blood_inventory_id=306 to 5 using update trigger and


also create a new table
Query:

25
CREATE TABLE Inventory_Update_log (
log_id INT AUTO_INCREMENT PRIMARY KEY,
blood_inventory_id INT,
old_quantity DECIMAL(5, 2),
new_quantity DECIMAL(5, 2)
);
DELIMITER $$
CREATE TRIGGER after_blood_inventory_update
AFTER UPDATE ON Blood_Inventory
FOR EACH ROW
BEGIN
INSERT INTO Inventory_Update_Log (blood_inventory_id, old_quantity,
new_quantity)
VALUES (OLD.blood_inventory_id, OLD.quantity, NEW.quantity);
END $$
DELIMITER ;
update blood_inventory
set quantity=10
where blood_inventory_id=306;
select * from Inventory_Update_log;

39. List all patients who have requested more than 3 units of blood:
Query:
SELECT Patients.name, Blood_Requests.required_quantity
FROM Blood_Requests
JOIN Patients ON Blood_Requests.patient_id = Patients.patient_id
WHERE Blood_Requests.required_quantity > 3;

40. Decreasing order of frequently donated blood group:


Query:
SELECT blood_group, COUNT(donation_id) AS donation_count
FROM Donations

26
JOIN Donors ON Donations.donor_id = Donors.donor_id
GROUP BY blood_group
ORDER BY donation_count DESC;

27

You might also like