Blood Bank Management System
Blood Bank Management System
SECTION:- K21YK
DATE:- 08-11-2022
lOMoARcPSD|18807539
lOMoARcPSD|18807539
Contents
1.Introduction…………………………………………………………………………….1
1.1 Objectives…………………………………………………………………………...2
1.2 Features……………………………………………………………………………...2
1.3 Problem Statements…………………………………………………………………2
2. Problem Description....................................................................................................3
3. Conceptual Model........................................................................................................3
3.1. Relational Entity Diagram.....................................................................................4
4. Logic Model.................................................................................................................5
5. Normalization..............................................................................................................5
6. Data Dictionary............................................................................................................7
7. List of Queries...........................................................................................................13
7.1. Relational Algebra...............................................................................................14
7.2. SQL Queries.........................................................................................................15
8. Triggers and Stored Procedures.................................................................................16
9. Database Creation.......................................................................................................25
1
lOMoARcPSD|18807539
1. Introduction
Blood Bank Management System is a browser based solution that is designed to
store, process, retrieve and analyze information concerned with the administrative,
inventory management and clinical aspects of providing services within a blood
bank.
Donor Registration: The application allows the users to store the donor details in
the application itself. As soon as a donor is registered, a unique identification
number is assigned to him/her automatically which remains same throughout the
life time of donor. Any subsequent donations made by the same donor
automatically got linked up with the same identification number.
Donor physical and medical details: System allows the user to store physical and
medical details of the donor at the time of the registration which could later on be
edited during the time of subsequent donations. Application also allows the users to
check the eligibility criteria of the donors for making donations, depending on which
a track of the deferred donors can be kept for the future referrals.
TTI screening and Inventory management: The Application provides its users to
organize and manage the inventory (Blood bags, blood component etc.) for their
blood bank. User can store the records for blood bags present in the bank, the
blood components created and imported in the bank. Every single unit/component
will be assigned with a unique ID for which Bar code can be generated and can be
pasted on the bags itself for later on identification. The end user is able to store the
blood in quarantine till the time it has passed the TTI screening as per specified
standards issued by NACO. After which the blood which has passed the tests will be
moved to inventory with their unique identification numbers and the rejected blood
will be processed to the discard samples for which the reports can be generated any
time later on.
Blood requisition and Cross matching: The Application allows the user to request for
blood and blood transfusion for which the cross matching using the appropriate
technique can be carried out and the results can further be processed and analyzed
by the experts to issue the blood. Also various reports for blood requisition and the
cross matching can be generated at run time.
Secured environment and login facility: System provides the users a secured
environment to work inside the application by accepting the log in ID’s and
passwords from the users.
Report generation: Various comprehensive reports can be generated any time by the
end user to measure the performance parameters in the blood bank and also to
analyses the inventory and other aspects in blood bank. Blood is an important factor that
is very essential in the life of every organisms . Nowadays, we see that people lose their
precious life without getting the blood at the right time due to improper contact of the blood
donors .The software system is an online blood bank management system that helps in
managing various blood bank operations effectively.
2
lOMoARcPSD|18807539
1.1. OBJECTIVES
To create awareness and solve all these problems this online blood bank app can be of great
help as it provides required info in no time and also helps in quicker decision making .This
also helps to motivate people for Blood Donation easily.
1.2. FEATURES
User can send blood request and they can check donor’s list.
Management can organize Blood Donation Camps.
Blood donors can register through online.
Management can manage donor’s database by recording their physical and medical
statistics.
Medically qualified management in blood bank for storage and issuance of blood.
Blood request from one branch to another.
Displays information about expired blood.
3
lOMoARcPSD|18807539
2. Problem Description
A Blood Bank is a place where blood is collected and stored for use by others who need
it due to health emergencies or a lack of blood. So, it is necessary to develop a data
management system to minimize the cost and time of manual labour to access blood
bank information.
• The donor will be the person who donates the blood; it will contain information
such as: name, age, gender, contact, blood group, address, disease;
• The patient will be the person who will receive the blood; this will have the
following attributes: ID, name, gender, blood group, contact, address;
• The blood bank is managed by a manager, who has a name, an ID and location;
• The donor can only make the donation once a month; at each donation, the
donated blood will be analysed by a clinical analyst, to find out if he suffers
from any blood-borne disease or not. If you have a disease and you are younger
than 18 or older than 60, will not be able to donate;
• An ID and blood group will be tagged (to the blood);
• Donors and patients are registered by a registration team. A registration team
can register multiple donors and patients, however, a donor or patient can only
be registered by one team member;
• Both registry team and clinical analyst have with attributes: ID and name;
• Hospitals and patients order blood from the blood bank through the manager, as
this is the one who handles the blood bags;
• Hospital will have the following attributes: ID, name, location;
• The date of registration for each patient and donor is important to the context.
3. Conceptual Model
3.1. Relational Entity Diagram
4
lOMoARcPSD|18807539
4. Logic Model
5. Normalization
Manager Table
Manager (IdManager, nameM, IdBloodBank, nameBloodBank, locationBloodBank)
1NF
Manager (IdManager, nameM, surnameG)
BloodBank (IdManager, IdBloodBank, name, avenue_street, number, neighborhood)
2NF / 3NF
Manager (IdManager, nameM, surnameG)
Manager_BloodBank(IdManager, IdBloodBank)
BloodBank (IdBloodBank, nameBB, avenue_street, number, neighborhood)
5
lOMoARcPSD|18807539
Registration_Team Table
Registration_Team(IdRT, nameRT, IdBloodBank)
1NF / 2NF / 3NF
Registration_Team(IdRT, nameRT, IdBloodBank)
Technical_Analyst Table
Technical_Analyst (IdTA, nameTA, IdBloodBank)
TechnicalAnalyst_Blood Table
Blood Table
Blood (IdBlood, bloodGroupBlood, IdManager)
1NF / 2NF / 3NF
Blood (IdBlood, bloodGroupBlood, IdManager)
Blood_Patient Table
Patient Table
6
lOMoARcPSD|18807539
2NF / 3NF
Patient (IdPatient, nameP, surnameP, gender, bloodGroup, contact, avenue_street,
number, neighborhood, IdManager, IdRT, dateRegisters)
Patient_Requests (IdPatient, IdRequests)
Requests (IdRequests, bloodGroupRequests, amountOfBloodRequests)
Donor Table
Donor (IdDonor, nameD, gender, bloodGroup, contact, address, age, disease, IdRT,
IdBlood, bloodGroupBlood, dateRegisters)
1NF / 2NF / 3NF
Donor (IdDonor, nameD, gender, bloodGroup, contact, avenue_street, number,
neighborhood, age, disease, IdRT, idBlood, bloodGroupBlood, dateRegisters)
Hospital Table
Hospital (IdHospital, nameH, location, idManager,
bloodGroupRequests, amountOfBloodRequests)
1NF
Hospital (IdHospital, nameH, avenue_street, number, neighborhood, idManager)
Requests (IdHospital, bloodGroupRequests, amountOfBloodRequests)
2NF / 3NF
Hospital (IdHospital, nomeH, avenue_street, number, neighborhood, IdManager)
Hospital_Requests (IdHospital, IdRequests)
Requests (IdRequests, bloodGroupRequests, amountOfBloodRequests)
6. Data Dictionary
7
lOMoARcPSD|18807539
Table Manager
Description Will contain manager information
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdManager Manager Code SMALLINT 4 PK
nameM Manager’s First Name VARCHAR 30 NOT NULL
surnameM Manager’s Surname VARCHAR 30 NOT NULL
Table Manager_BloodBank
Description Will contain Blood Bank and Manager ID information
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdManager Manager Code SMALLINT 4 PK
IdBloodBank Blood Bank Code SMALLINT 4 PK
Table BloodBank
Description Will contain Blood Bank information
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdBloodBank Blood Bank Code SMALLINT 4 PK
nameBB Blood Bank Name VARCHAR 30 NOT NULL
Avenue or Street
avenue_street where the Blood VARCHAR 30 NOT NULL
Bank is located
Blood Bank building
number INTEGER 4 NOT NULL
number
Neighborhood where
neighborhood the Blood Bank is VARCHAR 30
located
Table Registration_Team
8
lOMoARcPSD|18807539
Table Technical_Analyst
Description Will contain Technical Analyst information
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
Technical Analyst
IdTA INTEGER 10 PK
Code
Technical Analyst
nameTA VARCHAR 30 NOT NULL
First Name
Technical Analyst
surnameTA VARCHAR 30 NOT NULL
Surname
IdBloodBank Blood Bank Code SMALLINT 4 FK
9
lOMoARcPSD|18807539
Table Blood
Description Will contain information on donated blood
Comments
Type
Comments
Name Description Tipo Size
(PK / FK )
Donated Blood
IdBlood INTEGER 10 PK
Code
Blood Group of
bloodGroup VARCHAR 3 PK
donated blood
IdManager Manager Code SMALLINT 4 FK
Table Blood_Patient
Description Will contain information on the blood received by a patient
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
Donated Blood
IdBlood INTEGER 10 PK
Code
Blood Group of
bloodGroup blood received by a VARCHAR 3 PK
Patient
Code of the Patient
IdPatient who reciveid the INTEGER 10 PK
blood
Table Patient
Description Will contain Patient information
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdPatient Patient Code INTEGER 10 PK
nameP Patient’s First Name VARCHAR 30 NOT NULL
surnameP Patient’s Surname VARCHAR 30 NOT NULL
gender Patient’s Gender CHAR 1 DEFAULT
10
lOMoARcPSD|18807539
‘M’
Patient’s Blood
bloodGroup VARCHAR 3 NOT NULL
Group
contacto Patient Contact VARCHAR 9 NOT NULL
Patient’s Avenue or
avenue_street VARCHAR 30 NOT NULL
Street
number House Number INTEGER 4 NOT NULL
Neighborhood
neighborhood where the Patient VARCHAR 30 NOT NULL
lives
Registration Team
IdRT INTEGER 10 FK
member code
IdManager Manager Code SMALLINT 4 FK
Date the patient was
dateRegisters DATE NOT NULL
registered
Table Patient_Requests
Description Will contain information on patients who requested blood
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdPatient Patient Code INTEGER 10 PK
IdRequests Blood Request Code INTEGER 10 PK
Table Donor
Description Will contain Donor information
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdDonor Donor Code INTEGER 10 PK
nameD Donor First Name VARCHAR 30 NOT NULL
surnameD Donor Surname VARCHAR 30 NOT NULL
DEFAULT
gender Donor Gender CHAR 1
‘M’
Donor Blood Group
bloodGroup VARCHAR 3 NOT NULL
contacto Donor Contact VARCHAR 9 NOT NULL
avenue_street Donor Avenue or VARCHAR 30 NOT NULL
11
lOMoARcPSD|18807539
Street
number House Number INTEGER 4 NOT NULL
Neighborhood
neighborhood where the Donor VARCHAR 30 NOT NULL
lives
age Donor Age INTEGER 3 NOT NULL
Indicates whether
the donor has any
disease or not.
disease Have disease = 1 INTEGER 1 DEFAULT 0
There is no disease
=0
Donated Blood
IdBlood INTEGER 10 NULL
Code
Blood Group of
bloodGroupBlood VARCHAR 3 NULL
donated blood
Registration Team
IdRT INTEGER 10 FK
member code
Date the donor was
dateRegisters DATE NOT NULL
registered
Table Hospital
Description Will contain Hospital information
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdHospital Hospital Code INTEGER 10 PK
nameH Hospital Nome VARCHAR 30 NOT NULL
Avenue or Street
avenue_street where the Hospital is VARCHAR 30 NOT NULL
located
Hospital building
number INTEGER 4 NOT NULL
number
Neighborhood where
neighborhood VARCHAR 30 NOT NULL
the hospital is located
IdManager Manager Code SMALLINT 4 FK
Table Hospital_Requests
Description Will contain information from hospitals that requested blood
Comments
12
lOMoARcPSD|18807539
Fields
Comments
Name Description Type Size
(PK / FK )
IdHospital Hospital Code INTEGER 10 PK
IdRequests Blood Request Code INTEGER 10 PK
Table Requests
Description Will contain information on blood requests made
Comments
Fields
Comments
Name Description Type Size
(PK / FK )
IdRequests Request Code INTEGER 10 PK
Required Blood
bloodGroup VARCHAR 3 NOT NULL
Group
Amount of Blood
amountBlood requested (number INTEGER 10 NOT NULL
of bags)
7. List of Queries
1. List the names of the donors next to their address, who belong to the AB+ blood
group and are female.
2. List the names of tegistered donors who donated blood aged 18-28 years, and older
male and female donors who also donated blood.
3. List the registered donors who donated blood and who belong to the blood group
considered universal donor, as well as the patients who belong to the blood group
considered universal recipient.
4. List the names of workers who work in the same blood bank as technical analyst
‘Junaid’.
5. List registered donors who cannot donate (who have some illness).
6. The percentage of male donors without any disease, where the percentage of donors
without any disease is approximately 69.23%.
7. List the hospital and patient with the highest number of requested bags.
13
lOMoARcPSD|18807539
2.
A < - πIdDonor, nameD, surnameD, gender, age(σage ≥ 18 (σage ≤ 28 (σdisease=0 (donor))))
Result < - A U B U C
3.
A < - πIdDonor, nameD, surnameD, bloodGroup(σbloodGroup='O-' (σdisease=0 (donor)))
4.
(σ
A <- πIdBloodBank name ='Junaid'(technical_analyst)) E <- πidManager
(manager_bloodBank))
B <- πnameM, surnameM, IdBloodBank (πIdManager(Manager) |X|IdManager = IdManager
E
C <- πnameRT, surnameRT (πIdBloodBank |X| IdBloodBank = IdBloodBank A)
5.
Result < - πIdDonor, nameD, surnameD (σdisease != 0 (donor))
6.
14
lOMoARcPSD|18807539
7.
A <- πIdHospital, nameH, IdRequisita(hospital h
2.
SELECT IdDonor, nameD, surnameD, gender, age
FROM donor d, blood s
WHERE d. IdBlood = s. IdBlood AND bloodGroupBlood = s.bloodGroup
AND age >=18 AND age <=28
UNION
SELECT IdDonor, nameD, surnameD, gender, max(age)
FROM donor d, blood s
WHERE d.IdBlood = s. IdBlood AND bloodGroupBlood = s. bloodGroup
AND gender = 'M'
UNION
SELECT IdDonor, nameD, surnameD, gender, max(age)
FROM donor d, blood s
15
lOMoARcPSD|18807539
3.
SELECT IdDonor AS 'iD', nameD, surnameD, d. bloodGroup
FROM donor d, blood s
WHERE d. IdBlood = s. IdBlood
AND bloodGroupBlood = s. bloodGroup
AND d. bloodGroup = 'O-'
UNION
SELECT IdPatient, nameP, surnameP, bloodGroup
FROM patient
WHERE bloodGroup = 'AB+';
4.
SELECT nameM AS 'Name', surnameM AS 'Surname'
FROM manager m, manager_bloodbank mb
WHERE g.IdManager = gb.IdManager
AND gb.IdBloodBank = (SELECT IdBloodBank
FROM technical_analyst
WHERE nameTA = 'Junaid')
UNION
SELECT nameRT, surnameRT
FROM registration_team RT
WHERE RT. IdBloodBank = (SELECT IdBloodBank
FROM technical_analyst
WHERE nameAT = 'Junaid')
UNION
SELECT nameTA, surnameTA
FROM technical_analyst TA
WHERE TA.IdBloodBank = (SELECT IdBloodBank
FROM technical_analyst
WHERE nameTA = 'Junaid');
5.
SELECT IdDonor, nameD, surnameD
FROM donor
WHERE disease != 0;
6.
SELECT ((count(nameD)*100)/18) AS ‘Disease Free Male Donors (%)’
FROM donor
WHERE gender = 'M'
16
lOMoARcPSD|18807539
AND disease = 0;
7.
SELECT h.IdHospital AS ‘ID’, CONCAT(nameH, ' (hospital)') AS 'Name',
r.amountBlood AS ‘Amount of Blood’
FROM hospital h, requests r, hospital_requests hr
WHERE h.IdHospital = hr.IdHospital
AND hr.IdRequests = r.IdRequests
AND r.amountBlood = (SELECT max(amountBlood) FROM
requests re, hospital_requests hre
WHERE hre.IdRequests = re.IdRequests)
UNION ALL
SELECT p.IdPatient, CONCAT(nameP,' ',surnameP, ' (patient)'), r.amountBlood
FROM patient p, requests r, patient_requests pr
WHERE p.IdPatient = pr.IdPatient
AND pr.IdRequests = r.IdRequests
AND r.amountBlood = (SELECT max(amountBlood) FROM
requests re, patient_requests pre
WHERE pre.IdRequests = re.IdRequests);
17
lOMoARcPSD|18807539
END IF;
END//
DELIMITER ;
2. Trigger for donor data entry, where it checks if the donor has any disease and if the
donor has an age between 18-60. If it does not contain it and has the age in the range
above, the donor proceeds with the donation, and the record od the donated blood is
inserted in the blood table; if not, no record will be inserted in the blood table, and in the
donor table, the id and blood group of the donated blood will be canceled.
DELIMITER //
CREATE TRIGGER tr_donor_update BEFORE UPDATE
ON donor FOR EACH ROW
BEGIN
DECLARE id INT;
IF ( ((NEW.age >= 18) AND (NEW.age <= 60)) AND (NEW.disease = 0) ) THEN
INSERT INTO blood ( bloodGroup, IdManager) VALUES ( NEW.bloodGroup,
(SELECT mb.IdManager FROM manager_bloodbank mb, registration_team rt
WHERE rt.IdRT = NEW.IdRT AND rt. IdBloodBank = mb. IdBloodBank));
3. Trigger for entering patinent data, where the manager’s ID (in the patient table)
will match the manager’s ID that generates the Blood Bank, on which the registration
team member, who registered the patient works.
DELIMITER //
CREATE TRIGGER tr_patient BEFORE INSERT
ON patient FOR EACH ROW
BEGIN
SET new.IdManager = (SELECT mb.IdManager
FROM manager_bloodbank gb, registration_team rt
WHERE rt.IdRT = new.IdRT
AND rt.IdBloodBank = mb.IdBloodBank);
END//
DELIMITER ;
18
lOMoARcPSD|18807539
4. It counts the donors, after insertion, by their gender and by the fact that they
contain or not any disease.
DELIMITER //
CREATE TRIGGER count_donor BEFORE INSERT
ON donor FOR EACH ROW
BEGIN
DECLARE total_D, cont INT;
END//
DELIMITER ;
5. It counts the donors, after the removal of any donor record, by their gender and by the
fact that they contain or not any disease.
DELIMITER //
CREATE TRIGGER contar_donor_delete BEFORE DELETE
19
lOMoARcPSD|18807539
END//
DELIMITER ;
6. It counts the donors, after updating a donor’s record, by their gender and by whether
or not they contain any disease.
DELIMITER //
CREATE TRIGGER contar_donor_update AFTER UPDATE
ON donor FOR EACH ROW
BEGIN
DECLARE total_D, cont INT;
20
lOMoARcPSD|18807539
END//
DELIMITER ;
7. It counts the donors, after changing a donor’s register, by their gender and by the fact
that they contain or not any disease.
DELIMITER //
CREATE TRIGGER contar_donor_update2 BEFORE UPDATE
ON donor FOR EACH ROW
BEGIN
DECLARE cont INT;
21
lOMoARcPSD|18807539
END//
DELIMITER ;
Stored Procedures
1. Stored Procedure that prints the groups to which a certain blood type (passed by
parameter), you can donate.
DELIMITER ||
CREATE PROCEDURE bloodType (v_type varchar(3)) BEGIN
DECLARE info varchar(45);
IF (v_type = 'A+') THEN SET
info = 'A+, AB+';
SELECT info AS 'Groups to which you can donate';
END IF;
22
lOMoARcPSD|18807539
2. Stored Procedure that lists donor belonging to a blood group and who can donate
blood.
DELIMITER //
CREEATE PROCEDURE donors (v_type varchar (3)) BEGIN
SELECT IdDonor, nameD, surnameD, gender, bloodGroup FROM donor WHERE
v_type = bloodGroup AND disease = 0;
END//
DELIMITER;
DELIMITER ||
CREATE PROCEDURE insert_donor (name varchar(30), surname varchar(30), gender
char(1), group varchar(3), contact varchar(9), avenue varchar(30), nr int,
hood varchar(30), age int, disease int(1), RT int, dateRegisters date)
BEGIN
INSERT INSERT donor (nameD, surnameD, gender, bloodGroup, contact, avenida_rua,
number, neighborhood, age, disease, IdRT, dateRegisters) VALUES (name, surname,
gender, group, contact, avenue, nr, hood, age, disease, RT, dateRegisters);
23
lOMoARcPSD|18807539
END||
DELIMITER;
DELIMITER ||
CREATE PROCEDURE insert_patient (name varchar(30), surname varchar(30), gender
char(1), group varchar(3), contact varchar(9), avenue varchar(30), nr
int, hood varchar(30), RT int, dateRegisters date)
BEGIN
INSERT INSERT patient (nameP, surnameP, gender, bloodGroup, contact,
avenida_rua, number, neighborhood, dateRegisters, idRT) VALUES
(name, surname, gender, group, contact, avenue, nr, hood, RT, dateRegisters);
END||
DELIMITER;
5. Stored Procedure for making a new donation from an already registered donor
(through your ID), if it has the necessary requirements for this.
DELIMITER //
CREATE PROCEDURE donation (ID int)
BEGIN
DECLARE group varchar(3);
DECLARE age, disease_d, rt_resgistration int;
IF (EXISTS (SELECT IdDonor FROM donor where IdDonor = ID)) THEN
SET group = (SELECT bloodGroup FROM donor WHERE IdDonor = ID);
SET age_a = (SELECT age FROM donor WHERE IdDonor = ID);
SET disease_d = (SELECT disease FROM donor WHERE IdDonor = ID);
SET rt_resgistration = (SELECT IdRT FROM donor WHERE IdDonor = ID);
IF ( ((age >= 18) AND (age <= 60)) AND (disease = 0) ) THEN
INSERT INTO blood ( bloodGroup, IdManager) VALUES (group, (SELECT
mb.IdManager FROM manager_bloodbank mb, registration_team rt
WHERE rt.IdRT = rt_resgistration
AND rt.IdBloodBank = mb.IdBloodBank));
ELSE
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'The donor doesn't have the minimum requirements to make
the donation';
END IF;
ELSE
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'There's no registered donor with the referenced ID';
END IF;
24
lOMoARcPSD|18807539
END//
DELIMITER ;
DELIMITER //
CREATE PROCEDURE stock()
BEGIN
CREATE TEMPORARY TABLE stock_blood ( ID
int PRIMARY KEY AUTO_INCREMENT, quantity
int,
group varchar(3));
9. Database Creation
CREATE DATABASE blood_bank;
25
lOMoARcPSD|18807539
26
lOMoARcPSD|18807539
27
lOMoARcPSD|18807539
28
lOMoARcPSD|18807539
29