Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 47

PROJECT REPORT

ON
SMART BLOOD
PORTAL

DECLARATION

I am KARTHIKEYAN bearing the Roll No. 20220595, doing B.C.A in Nandha Arts & Science College.
I here by declare that the project viz. “ONLINE BLOOD BANK” has been completed by me during the
Third Semester as per partial completion of B.C.A Professional Degree. I have taken up this project
to satisfy my eagerness in exploring the field of Web Designing and after the completion of the
project I have realized that it has come true.

5
Table of Contents
1.INTRODUCTION 6

1.1 System Development 6

1.2 Problem Statement 7

1.3 Objectives 7

1.4 Project 8

2.SYSTEM ANALYSIS 9

2.1 Preliminary Investigation 9

2.2 Feasibility Study 9

2.3 Observation 11

2.4 System Study 11

6
2.5 Proposed system 12

2.6 Limitation 12

3.SYSTEM DESIGN 13

3.1 Introduction E-R Diagram 13

3.2 Data Flow Diagram 15

3.3 Database Design 18

3.4 Data Dictionary 18

4.SYSTEM REQUIREMENTS SPECIFICATION 19

4.1 Scope 19

4.2 Data Analysis 20

4.3 System Processes 21

4.4 Managerial Approach 22

4.5 Software and hardware Requirements 23

5.SYSTEM TESTING AND SCREENSHOTS 24

5.1 Introduction 24

5.2 Test Plan 24

5.3 Test units 24

5.4 Other Testing Strategies 25

5.5 Test deliverables 25

6.CODING 26

6.CONCLUSION 47

7.REFERENCES 48

7
8
SYNOPSIS

The number of persons who are in need of blood are increasing in large number day by day. In
order to help people who are in need of blood, my Online Blood Bank can be used effectively for
getting the details of blood donors having the same blood group and with in the same city. With the
help of my Online Blood Bank people who are having the thought of donating blood gets registered
in my Online Blood Bank giving his total details.
My Online Blood Bank site is available to everyone easily. A person who likes to donate blood gives
his entire details i.e., fill in the registration form and can create a username with a password by
which he can modify his details if at all there are any changes in his information given before.
My site also helps people who are in need of blood by giving the details of the donors by searching,
if at all there are no donors having the same group and with in their own city they will be given the
addresses with phone numbers of some contact persons in major cities who represent a club or an
organization with free of cost. If at all the people find any difficulty in getting blood from the
contact persons we will give them a MobiLink i.e., India’s Largest Paging Service number through
which they can give the message on every ones pagers with the blood group and city they are living
in, such that the donors who view the messages in their pagers having the same blood group and
the in the same city, he contacts the person on phone who are in need of a blood. Such that the
person gets help from us which saves his life.
The present project elucidates the following features.
Registering the Donors
Modification of Donor Information
Searching a Donor
Life Saving Contacts (in major cities)

1
1.INTRODUCTION
Every year our nation requires about 4 Cr. units of blood, out of which only 5 Lakh units of blood
are available. It is not that, people do not want to donate blood. Often they are unaware of the need
and also they do not have a proper facility to enquire about it. As a result, needy people end up
going through a lot of pain. India has many blood banks, all-functioning in a decentralized fashion.
In the current system, individual hospitals have their own blood banks and there is no interaction
between blood banks. The management is ad-hoc with no semblance of organization or standard
operating procedures. Donors cannot access blood from blood banks other than the bank where
they have donated blood. In present system all the blood banks are attached to hospitals and there
is no stand-alone blood bank. Some hospital has its own systems and limitations. Because of low
number of donors and more number of blood banks, the efficiency and quality of blood banks are
low, resulting in wastage of blood and blood components.

1.1 System Development


The process of building systems has always been complex with system becoming larger, the costs
and complexities get multiplied. So the need for better methods for developing systems is widely
recognized to be effective and the applied model should meet a few basic requirements.

• The model should be structured and cover the entire system development process
from feasibility study to programming, testing and implementation.
• The model should utilize established methods and techniques like database designs,
normalizations and structured programming techniques.
• The model should consist of building blocks, which define tasks, results and
interfaces.
• The model should separate the logical system from the physical system.

• Documentation should be a direct result of the development work and should be


concise, precise and as non-redundant as possible.

2
Based on the above requirements of the system model, system study has been made. Various
methodologies have been applied for system study, evolving design documents, data modeling,
input screen design and report design.

1.2 Problem Statement


At present, the public can only know about the blood donation events through conventional media
means such as radio, news paper or television advertisements. There is no information regarding
the blood donation programs available on any of the portal. The current system that is using by the
blood bank is manual system. With the manual system, there are problems in managing the donors'
records. The records of the donor might not be kept safely and there might be missing of donor's
records due to human error or disasters. Besides that, errors might occur when the staff keeps
more than one record for the same donor. There is no centralized database of volunteer donors.
So, it becomes really tedious for a person to search blood in case of emergency. The only option is
to manually search and match donors and then make phone calls to every donor. There is also no
centralized database used to keep the donors' records. Each bank is having their own records of
donors. If a donor makes donation in different hospital, no previous records can be traced except if
the donor brings along the donation certificate. Hence, the donor is considered to be a first-timer if
they make blood donation in a new place. Without an automated management system, there are
also problems in keeping track of the actual amount of each and every blood type in the blood bank.
In addition, there is also no alert available when the blood quantity is below its par level or when
the blood in the bank has expired.

1.3 Objectives

⮚ An easy way to search the nearest blood banks to the accident site with the help of .

city.

⮚ An effective way to find out the availability of the required blood groups in the

blood banks.

⮚ A proficient way to search the volunteer blood donors.

3
⮚ Providing tips regarding the necessary measures that are to be taken before the blood

donation.

⮚ Directly contact to donors.

1.4 Project
The persons who like to donate blood registers in my site as well as he can modify the details if
necessary, giving the Login Id and Password. The persons in need of blood searches for the persons
having the same blood group and with in the city. If he found a donor in his city then he gets the
total details of the donor, if he doesn’t find any donor then he is given the contact numbers and
addresses of the Life Saving Contact Persons for major cities. If he doesn’t have any chance to
contact them then he will be provided with Mobilink Paging Services in order to get the blood.

2.SYSTEM ANALYSIS

2.1 Preliminary Investigation


First in the system development process is preliminary Investigation. Preliminary Investigation is
conducted in the following phases.

• Project clarification

• Feasibility study

• Project appraisal
Project clarification is the process of selecting a project request for further study. When a system
development or modification request is made, the first systems activity, the preliminary

4
investigation, begins the activity has three parts: Request clarification, feasibility study and project
appraisal. Many request from employees and users in organization are not clearly stated.
Therefore before any systems investigation can be considered, the project request must be
examined to determine preciously what the originator wants. This is called Request clarification.
As important outcome of the preliminary investigation is the determination that the system request
in feasible.

2.2 Feasibility Study


The feasibility study is performed to determine whether the proposed system is viable considering
the Technical, Operational and Economical factors. After going through feasibility study we can
have a clear-cut view of the system’s benefits and drawbacks.

Technical Feasibility
The proposed system is developed using Active Server Page, PYTHON Script and html as front-end
tool and Mysql as the back end. The proposed system needs a Personal Web Server to serve the
requests submitted by the users. The Web browser is used to view the web page that is available in
Web Browser. The proposed system will run under cmd windwos environment. As Windows is
very user friendly and GUI OS it is very easy to use. All the required hardware and software are
readily available in the market. Hence the system is technically feasible.
Operational Feasibility
The proposed system is operationally feasible because of the following reasons.

• The customer is benefited more as most of his time is saved. The customer is
serviced at his place of work.
• The cost of the proposed system is almost negligible when compared to the benefits
gained.

Economical Feasibility

As the necessary hardware and software are available in the market at a low cost, the initial
investment is the only cost incurred and does not need any further enhancements. Hence it is
economically feasible.
The system is feasible in all respects and hence it encourages taking up the system design.

5
Gathering Information

The analysis through collection of data plays the wider role in the analysis of the system.
So the data is collected at different levels of management to keep track of full information of the
system.
The collection of data is done from
Top Level Management
Middle Level Management
Low Level Management
Different methods used to collect the data:

Questioners
The data is collected through questioners by filling a set of questions from the different levels of
management. The questions made by questioners are three different types.
They are,
Structured questioners:
Unstructured questioners:
Semi-structured questioners:

Interviews

6
Interviews were conducted to collect the information. The interviews were conducted at two
levels.
Formal Group Interviews: the interviews conducted for formal groups i.e., the hierarchical (official)
groups in the firm.
Informal Group Interviews: the interviews were conducted for informal groups i.e., the groups
formed out side the company.

2.3 Observation

The data is also collected by observation of the firm. The data is collected by observing on the site
at different timings and at different situations like when the firm is busy and when the firm hasn’t
much work to do.
Record Review
To collect the data and to get a clear idea of the firm some of the data is also collected from the past
records of the firm. This information helps very much to get a clear idea of the firm i.e., the different
problems occurred in different seasons and some exception conditions. This very much gives a
clear idea of exceptional conditions.

2.4 System Study


Present system
There are certain features limiting the process of the present system.
The drawbacks of the present system are listed below.
The increase in number of vehicles now a days.
The increase in number of accidents now a days.
The patients cannot get the information of donors easily.

2.5 Proposed system


The proposed system, Online Blood Bank site overcomes the drawbacks of the present system. The
Blood Bank helps the people who are in need of a blood by giving them overall details regarding the
donors with the same blood group and with in their city.
The advantages of the proposed system are listed below.

7
The people in need of blood can search for the donors by giving their blood group and city name.
It is very flexible and user friendly.
The person’s time and work is reduced very much which prevails in the present system.
Easy and Helpful.
The people are not limited to receive or provide services in working hours of the branch only; he is
serviced 24 hours a day, 7 days of week and 365 days of the year.

2.6 Limitation
In this project the searching can be done for donors for majority of cities but not for every city.
In this project the contact person’s details are given for the limited cities only.

3.SYSTEM DESIGN

3.1 Introduction E-R Diagram


The entity-relationship data model is based on a perception of a real world that consists of a
collection of basic objects called entities and of relationships among these objects. An entity is an

“object” in the real world that is distinguishable from other objects. For e.g. each customer is an
entity and rooms can be considered to be entities. Entities are described by a set of attributes. For
e.g. the attributes Room no. and Room type describes a particular Room in a hotel. The set of all
entities of the same type and the set of all relationships of the same type are termed as an entity set
and relationship set respectively.

8
The logical structure of a database can be expressed graphically by an E- R diagram
consists of the following major components:

9
3.2 Data Flow Diagram

Blood
Bank

10
Blood
Blood Donors Blood Seekers
Bank

11
Registration

Blood Donors

Life Saving
Contacts
Blood
Bank

Mobilink Paging Services


Blood Seekers

Search

12
Registration

Blood Donors

Life Saving Contacts

Blood
Bank

Mobilink Paging Services


Blood Seekers

Search

Receive Donor Details


13
3.3 Database Design
Database is an integrated collection of data and provides a centralized access to the data and makes
possible to treat data as a separate resource. Usually centralized data managing software is called a
Relational Database Management System (RDBMS). The most significant different between RDBMS
and other type of Data Management is the separation of data as seen by the program and data as
store of on the direct access storage device. This is the difference between logical and physical
data.

3.4 Data Dictionary


The efficiency of an application developed using RDBMS mainly depend upon the database tables,
the fields in each table and the way the tables are opened using the contents in them to retrieve the
necessary information. Hence a careful selection of tables and their fields are imperative.
The database tables used in this system are created keeping the above points in mind. The tables
used are given below.
Register Table
Description: Used to Register the donor information and helpful for the people in need of blood to
get details regarding the person with matching blood group and city.

4.SYSTEM REQUIREMENTS SPECIFICATION


The system that is going to be developed is Blood Bank Management System (BBMS). This is a web-
based database application system that is to be used by the blood banks or blood centers as a
means to advertise the nation wide blood donation events to the public and at the same time allow
the public to make online reservation and request for the blood.

14
The system keeps the record of all the donors, recipients, blood donation programs, rejected
bloods. For internal works and activities intranet is used and for interaction with public internet is
used.
This system also has the ability to keep track of the donor's donation records and the blood stock in
the blood bank. This project intends to computerize the blood and donor management system in a
blood bank in order to improve the record management efficiency due to the grown size of records
of data.

4.1 Scope
The system is used for maintaining all the process and activities of blood bank management system.
The system can be extended to be used for maintaining records of hospital, organ donation and
other similar sectors. While developing the system, there shall be space for further modification.
There shall be a proper documentation so that further enhancement becomes easy.
As a whole the system is focused to work with blood bank management system and on additional
modification it can be also used as management systems of similar organizations.
A) Stakeholders

1) System Owner: The Blood Bank

2) System Users:

• Administrators: has full privilege on the system's functions

• Staffs of Blood Bank: has privilege on the system's functions as assigned by the
administrator

• Public: can view the blood donation events and donate or can make requests for
donation (Donor and Recipients fall under this category)

4.2 Data Analysis

1. Data about Donor and recipients

 Donor/ Recipient Id

 Name

 Date of Birth

 Sex

 Blood Group

15
 Address

 Contact Number

 Blood Id

2. Donation program

 Organizer

 Event Id

 Date of Donation

 Venue

 Volunteers

 Amount of blood collected

3. Blood

 Blood Id

 Blood Group

 Date of collection

 Expiry date

4.3 System Processes

• Login
The system provides security features through username-password matching where only
authorized user can access the system with different authorization level.
• Advertisements of blood donation event
This function allows the blood bank staff to publicize the blood donation events online. The
public can view the venue and time of the blood donation programs to be held.
• Donor Profile Registration
This allows healthy public to register as volunteer donor.

16
• Online Request for fresh blood
This allows the probable recipients to make online request to the donor. After the request
has been filed donors are matched and the request is sent via SMS with necessary details.
• Blood Stock Management
The blood bank staffs can manage the blood stock starting from the blood collection, to
blood screening, processing, storage, transference and transfusion through this system.
Each process or work-flow can be traced from the database. The system will also raise alert
to the staff whenever the blood quantity is below its par level or when the blood in stock
has expired.

• Donor/Recipient Management
The records of all donors/recipient and their history are kept in one centralized database
and thus reducing duplicate data in the database. The record of donation is maintained by
the system.

• Reporting
The system is able to generate pre-defined reports such as the list of donors, recipients,
staffs, the blood quantity in the bank and charts.
Project Approach

Route:

• Problem Identification

• System Design

• System Building

• Testing and Implementation

Deliverables:

The main deliverables of the projects are as follows:


• Requirement Specification

 Use-Case Model

• Analysis Model will be used to show the realization of all use-cases conceptually

• Design specification will be used to specify the design for the realization of all use-cases
including class diagrams

• Implementation model

 Code and System

17
• Documentation and Manual

4.4 Managerial Approach

• Team Building Consideration:

 Each of the team member will be given a job

 The work division shall be on the basis of expertise

 The progress shall be synchronized on weekly basis

4.5 Software and hardware Requirements

1.Software Requirements
Operating System - Windows7/Linux

Database Management System - Sqlite 3

Programming Language - Python

Web-framework - Django

Browser - Mozilla Firefox, Chromium

2.Hardware Requirements

18
Hard Disk - 80GB

Ram - 2GB

CPU - Dual Core Processor

Meeting Schedules

The meeting of the working team members shall be done on weekly basis. This shall follow an
objective of synchronized working and progress description.

5.SYSTEM TESTING AND SCREENSHOTS

5.1 Introduction
System testing is the stage before system implementation where the system is made error free and
all the needed modifications are made. The system was tested with test data and necessary
corrections to the system were carried out. All the reports were checked by the user and approved.
The system was very user friendly with online help to assist the user wherever necessary.

5.2 Test Plan


A test plan is a general document for the entire project, which defines the scope, approach to be
taken, and schedule of testing, as well as identifying the test item for the entire testing process, and
the personal responsible for the different activities of testing. This document describes the plan for
testing, the knowledge management tool.
Major testing activities are:
Test units
Features to be tested
Approach for testing

19
Test deliverables
Schedule
Personal allocation

5.3 Test units


Test Case specification is major activity in the testing process. In this project, I have
performed two levels of testing.
Unit testing
System testing
The basic units in Unit testing are:
Validating the user request
Validating the input given by the user
Exception handling
The basic units in System testing are:
Integration of all programs is correct or not
Checking whether the entire system after integrating is working as expected.
The system is tested as whole after the unit testing.

5.4 Other Testing Strategies


Alpha Testing
This was done at the developer’s site by a customer. The software is used in a natural
setting with the developer “looking over the shoulder” of the user and recording errors and usage
problems. Alpha tests are conducted in a controlled environment.
Beta Testing
This was conducted at one or more customer sites by the end-user of the software. Unlike
alpha testing, the developer is generally not present. Therefore, the beta test is a “live” application
of the software in an environment that cannot be controlled by the developer. The customer
records all problems that are encountered during beta testing and reports these to the developer at
regular intervals. As a result of problems reported during beta tests, software engineers make
modifications and then prepare for release of the software product to the entire customer base.

5.5 Test deliverables

• The following documents are required besides the test plan


• Unit test report for each unit

20
• Test case specification for system testing
• The report for system testing
• Error report
• The test case specification for system testing has to be submitted for review before
the system testing commences.

CODING:

from django import forms


from . import models
class BloodForm(forms.ModelForm):
class Meta:
model=models.Stock
fields=['bloodgroup','unit']

class RequestForm(forms.ModelForm):
class Meta:
model=models.BloodRequest
fields=['patient_name','patient_age','reason','bloodgroup','unit']

from django.db import models


from patient import models as pmodels
from donor import models as dmodels
class Stock(models.Model):
bloodgroup=models.CharField(max_length=10)
unit=models.PositiveIntegerField(default=0)
def __str__(self):
return self.bloodgroup

class BloodRequest(models.Model):
request_by_patient=models.ForeignKey(pmodels.Patient,null=True,on_delete=models.CASCADE)
request_by_donor=models.ForeignKey(dmodels.Donor,null=True,on_delete=models.CASCADE)
patient_name=models.CharField(max_length=30)

21
patient_age=models.PositiveIntegerField()
reason=models.CharField(max_length=500)
bloodgroup=models.CharField(max_length=10)
unit=models.PositiveIntegerField(default=0)
status=models.CharField(max_length=20,default="Pending")
date=models.DateField(auto_now=True)
def __str__(self):
return self.bloodgroup

from django.shortcuts import render,redirect,reverse


from . import forms,models
from django.db.models import Sum,Q
from django.contrib.auth.models import Group
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required,user_passes_test
from django.conf import settings
from datetime import date, timedelta
from django.core.mail import send_mail
from django.contrib.auth.models import User
from donor import models as dmodels
from patient import models as pmodels
from donor import forms as dforms
from patient import forms as pforms

def home_view(request):
x=models.Stock.objects.all()
print(x)
if len(x)==0:
blood1=models.Stock()
blood1.bloodgroup="A+"
blood1.save()

blood2=models.Stock()
blood2.bloodgroup="A-"
blood2.save()

22
blood3=models.Stock()
blood3.bloodgroup="B+"
blood3.save()

blood4=models.Stock()
blood4.bloodgroup="B-"
blood4.save()

blood5=models.Stock()
blood5.bloodgroup="AB+"
blood5.save()

blood6=models.Stock()
blood6.bloodgroup="AB-"
blood6.save()

blood7=models.Stock()
blood7.bloodgroup="O+"
blood7.save()

blood8=models.Stock()
blood8.bloodgroup="O-"
blood8.save()

if request.user.is_authenticated:
return HttpResponseRedirect('afterlogin')
return render(request,'blood/index.html')

def is_donor(user):
return user.groups.filter(name='DONOR').exists()

def is_patient(user):
return user.groups.filter(name='PATIENT').exists()

23
def afterlogin_view(request):
if is_donor(request.user):
return redirect('donor/donor-dashboard')

elif is_patient(request.user):
return redirect('patient/patient-dashboard')
else:
return redirect('admin-dashboard')

@login_required(login_url='adminlogin')
def admin_dashboard_view(request):
totalunit=models.Stock.objects.aggregate(Sum('unit'))
dict={

'A1':models.Stock.objects.get(bloodgroup="A+"),
'A2':models.Stock.objects.get(bloodgroup="A-"),
'B1':models.Stock.objects.get(bloodgroup="B+"),
'B2':models.Stock.objects.get(bloodgroup="B-"),
'AB1':models.Stock.objects.get(bloodgroup="AB+"),
'AB2':models.Stock.objects.get(bloodgroup="AB-"),
'O1':models.Stock.objects.get(bloodgroup="O+"),
'O2':models.Stock.objects.get(bloodgroup="O-"),
'totaldonors':dmodels.Donor.objects.all().count(),
'totalbloodunit':totalunit['unit__sum'],
'totalrequest':models.BloodRequest.objects.all().count(),
'totalapprovedrequest':models.BloodRequest.objects.all().filter(status='Approved').count()
}
return render(request,'blood/admin_dashboard.html',context=dict)

@login_required(login_url='adminlogin')
def admin_blood_view(request):
dict={
'bloodForm':forms.BloodForm(),
'A1':models.Stock.objects.get(bloodgroup="A+"),

24
'A2':models.Stock.objects.get(bloodgroup="A-"),
'B1':models.Stock.objects.get(bloodgroup="B+"),
'B2':models.Stock.objects.get(bloodgroup="B-"),
'AB1':models.Stock.objects.get(bloodgroup="AB+"),
'AB2':models.Stock.objects.get(bloodgroup="AB-"),
'O1':models.Stock.objects.get(bloodgroup="O+"),
'O2':models.Stock.objects.get(bloodgroup="O-"),
}
if request.method=='POST':
bloodForm=forms.BloodForm(request.POST)
if bloodForm.is_valid() :
bloodgroup=bloodForm.cleaned_data['bloodgroup']
stock=models.Stock.objects.get(bloodgroup=bloodgroup)
stock.unit=bloodForm.cleaned_data['unit']
stock.save()
return HttpResponseRedirect('admin-blood')
return render(request,'blood/admin_blood.html',context=dict)

@login_required(login_url='adminlogin')
def admin_donor_view(request):
donors=dmodels.Donor.objects.all()
return render(request,'blood/admin_donor.html',{'donors':donors})

@login_required(login_url='adminlogin')
def update_donor_view(request,pk):
donor=dmodels.Donor.objects.get(id=pk)
user=dmodels.User.objects.get(id=donor.user_id)
userForm=dforms.DonorUserForm(instance=user)
donorForm=dforms.DonorForm(request.FILES,instance=donor)
mydict={'userForm':userForm,'donorForm':donorForm}
if request.method=='POST':
userForm=dforms.DonorUserForm(request.POST,instance=user)
donorForm=dforms.DonorForm(request.POST,request.FILES,instance=donor)
if userForm.is_valid() and donorForm.is_valid():

25
user=userForm.save()
user.set_password(user.password)
user.save()
donor=donorForm.save(commit=False)
donor.user=user
donor.bloodgroup=donorForm.cleaned_data['bloodgroup']
donor.save()
return redirect('admin-donor')
return render(request,'blood/update_donor.html',context=mydict)

@login_required(login_url='adminlogin')
def delete_donor_view(request,pk):
donor=dmodels.Donor.objects.get(id=pk)
user=User.objects.get(id=donor.user_id)
user.delete()
donor.delete()
return HttpResponseRedirect('/admin-donor')

@login_required(login_url='adminlogin')
def admin_patient_view(request):
patients=pmodels.Patient.objects.all()
return render(request,'blood/admin_patient.html',{'patients':patients})

@login_required(login_url='adminlogin')
def update_patient_view(request,pk):
patient=pmodels.Patient.objects.get(id=pk)
user=pmodels.User.objects.get(id=patient.user_id)
userForm=pforms.PatientUserForm(instance=user)
patientForm=pforms.PatientForm(request.FILES,instance=patient)
mydict={'userForm':userForm,'patientForm':patientForm}
if request.method=='POST':
userForm=pforms.PatientUserForm(request.POST,instance=user)
patientForm=pforms.PatientForm(request.POST,request.FILES,instance=patient)

26
if userForm.is_valid() and patientForm.is_valid():
user=userForm.save()
user.set_password(user.password)
user.save()
patient=patientForm.save(commit=False)
patient.user=user
patient.bloodgroup=patientForm.cleaned_data['bloodgroup']
patient.save()
return redirect('admin-patient')
return render(request,'blood/update_patient.html',context=mydict)

@login_required(login_url='adminlogin')
def delete_patient_view(request,pk):
patient=pmodels.Patient.objects.get(id=pk)
user=User.objects.get(id=patient.user_id)
user.delete()
patient.delete()
return HttpResponseRedirect('/admin-patient')

@login_required(login_url='adminlogin')
def admin_request_view(request):
requests=models.BloodRequest.objects.all().filter(status='Pending')
return render(request,'blood/admin_request.html',{'requests':requests})

@login_required(login_url='adminlogin')
def admin_request_history_view(request):
requests=models.BloodRequest.objects.all().exclude(status='Pending')
return render(request,'blood/admin_request_history.html',{'requests':requests})

@login_required(login_url='adminlogin')
def admin_donation_view(request):
donations=dmodels.BloodDonate.objects.all()
return render(request,'blood/admin_donation.html',{'donations':donations})

27
@login_required(login_url='adminlogin')
def update_approve_status_view(request,pk):
req=models.BloodRequest.objects.get(id=pk)
message=None
bloodgroup=req.bloodgroup
unit=req.unit
stock=models.Stock.objects.get(bloodgroup=bloodgroup)
if stock.unit > unit:
stock.unit=stock.unit-unit
stock.save()
req.status="Approved"

else:
message="Stock Doest Not Have Enough Blood To Approve This Request, Only "+str(stock.unit)
+" Unit Available"
req.save()

requests=models.BloodRequest.objects.all().filter(status='Pending')
return render(request,'blood/admin_request.html',{'requests':requests,'message':message})

@login_required(login_url='adminlogin')
def update_reject_status_view(request,pk):
req=models.BloodRequest.objects.get(id=pk)
req.status="Rejected"
req.save()
return HttpResponseRedirect('/admin-request')

@login_required(login_url='adminlogin')
def approve_donation_view(request,pk):
donation=dmodels.BloodDonate.objects.get(id=pk)
donation_blood_group=donation.bloodgroup
donation_blood_unit=donation.unit

stock=models.Stock.objects.get(bloodgroup=donation_blood_group)
stock.unit=stock.unit+donation_blood_unit

28
stock.save()

donation.status='Approved'
donation.save()
return HttpResponseRedirect('/admin-donation')

@login_required(login_url='adminlogin')
def reject_donation_view(request,pk):
donation=dmodels.BloodDonate.objects.get(id=pk)
donation.status='Rejected'
donation.save()
return HttpResponseRedirect('/admin-donation')

# Generated by Django 3.0.5 on 2021-01-17 13:08

from django.db import migrations, models

class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Stock',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('bloodgroup', models.CharField(max_length=10)),
('unit', models.PositiveIntegerField(default=0)),
],

29
),
]

# Generated by Django 3.0.5 on 2021-01-18 16:17

from django.db import migrations, models

class Migration(migrations.Migration):

dependencies = [
('blood', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='BloodRequest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('name', models.CharField(max_length=30)),
('age', models.PositiveIntegerField()),
('mobile', models.CharField(max_length=20)),
('disease', models.CharField(max_length=100)),
('reason', models.CharField(max_length=500)),
('bloodgroup', models.CharField(max_length=10)),
('unit', models.PositiveIntegerField(default=0)),
('status', models.CharField(default='Pending', max_length=20)),
],
),
]
# Generated by Django 3.0.5 on 2021-02-13 05:23

from django.db import migrations, models


import django.db.models.deletion

30
class Migration(migrations.Migration):

dependencies = [
('patient', '0001_initial'),
('donor', '0001_initial'),
('blood', '0002_bloodrequest'),
]

operations = [
migrations.RenameField(
model_name='bloodrequest',
old_name='age',
new_name='patient_age',
),
migrations.RenameField(
model_name='bloodrequest',
old_name='name',
new_name='patient_name',
),
migrations.RemoveField(
model_name='bloodrequest',
name='disease',
),
migrations.RemoveField(
model_name='bloodrequest',
name='mobile',
),
migrations.AddField(
model_name='bloodrequest',
name='request_by_donor',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE,
to='donor.Donor'),
),

31
migrations.AddField(
model_name='bloodrequest',
name='request_by_patient',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE,
to='patient.Patient'),
),
]
# Generated by Django 3.0.5 on 2021-02-13 06:24

from django.db import migrations, models

class Migration(migrations.Migration):

dependencies = [
('blood', '0003_auto_20210213_1053'),
]

operations = [
migrations.AddField(
model_name='bloodrequest',
name='date',
field=models.DateField(auto_now=True),
),
]
"""
Django settings for bloodbankmanagement project.

Generated by 'django-admin startproject' using Django 3.0.5.

For more information on this file, see


https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see


https://docs.djangoproject.com/en/3.0/ref/settings/

32
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR,'templates')
STATIC_DIR=os.path.join(BASE_DIR,'static')
MEDIA_ROOT=os.path.join(BASE_DIR,'static')

# Quick-start development settings - unsuitable for production


# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!


SECRET_KEY = '+zy!9k=9pql5gz9bkqjore)k6r!%w0atk(@(!(!zvp5e(t2i8n'

# SECURITY WARNING: don't run with debug turned on in production!


DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'widget_tweaks',
'blood',
'donor',
'patient',

33
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
CSRF_COOKIE_SECURE=False
ROOT_URLCONF = 'bloodbankmanagement.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATE_DIR,],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'bloodbankmanagement.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

34
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

35
USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)


# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS=[
STATIC_DIR,
]
LOGIN_REDIRECT_URL='/afterlogin'

#for contact us give your gmail id and password


EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'from@gmail.com' # this email will be used to send emails
EMAIL_HOST_PASSWORD = 'xyz' # host email password required
# now sign in with your host gmail account in your browser
# open following link and turn it ON
# https://myaccount.google.com/lesssecureapps
# otherwise you will get SMTPAuthenticationError at /contactus
# this process is required because google blocks apps authentication by default
EMAIL_RECEIVING_USER = ['to@gmail.com'] # email on which you will receive messages sent
from website

"""bloodbankmanagement URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/

36
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path,include
from django.contrib.auth.views import LogoutView,LoginView
from blood import views
urlpatterns = [
path('admin/', admin.site.urls),

path('donor/',include('donor.urls')),
path('patient/',include('patient.urls')),

path('',views.home_view,name=''),
path('logout', LogoutView.as_view(template_name='blood/logout.html'),name='logout'),

path('afterlogin', views.afterlogin_view,name='afterlogin'),
path('adminlogin',
LoginView.as_view(template_name='blood/adminlogin.html'),name='adminlogin'),
path('admin-dashboard', views.admin_dashboard_view,name='admin-dashboard'),
path('admin-blood', views.admin_blood_view,name='admin-blood'),
path('admin-donor', views.admin_donor_view,name='admin-donor'),
path('admin-patient', views.admin_patient_view,name='admin-patient'),
path('update-donor/<int:pk>', views.update_donor_view,name='update-donor'),
path('delete-donor/<int:pk>', views.delete_donor_view,name='delete-donor'),

37
path('admin-request', views.admin_request_view,name='admin-request'),
path('update-patient/<int:pk>', views.update_patient_view,name='update-patient'),
path('delete-patient/<int:pk>', views.delete_patient_view,name='delete-patient'),
path('admin-donation', views.admin_donation_view,name='admin-donation'),
path('approve-donation/<int:pk>', views.approve_donation_view,name='approve-donation'),
path('reject-donation/<int:pk>', views.reject_donation_view,name='reject-donation'),
path('admin-request-history', views.admin_request_history_view,name='admin-request-
history'),
path('update-approve-status/<int:pk>', views.update_approve_status_view,name='update-
approve-status'),
path('update-reject-status/<int:pk>', views.update_reject_status_view,name='update-reject-
status'),

]
from django.db import models
from django.contrib.auth.models import User

class Donor(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
profile_pic= models.ImageField(upload_to='profile_pic/Donor/',null=True,blank=True)

bloodgroup=models.CharField(max_length=10)

address = models.CharField(max_length=40)
mobile = models.CharField(max_length=20,null=False)

@property
def get_name(self):
return self.user.first_name+" "+self.user.last_name
@property
def get_instance(self):
return self
def __str__(self):

38
return self.user.first_name

class BloodDonate(models.Model):
donor=models.ForeignKey(Donor,on_delete=models.CASCADE)
disease=models.CharField(max_length=100,default="Nothing")
age=models.PositiveIntegerField()
bloodgroup=models.CharField(max_length=10)
unit=models.PositiveIntegerField(default=0)
status=models.CharField(max_length=20,default="Pending")
date=models.DateField(auto_now=True)
def __str__(self):
return self.donor

from django.shortcuts import render,redirect,reverse


from . import forms,models
from django.db.models import Sum,Q
from django.contrib.auth.models import Group
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required,user_passes_test
from django.conf import settings
from datetime import date, timedelta
from django.core.mail import send_mail
from django.contrib.auth.models import User
from blood import forms as bforms
from blood import models as bmodels

def donor_signup_view(request):
userForm=forms.DonorUserForm()
donorForm=forms.DonorForm()
mydict={'userForm':userForm,'donorForm':donorForm}
if request.method=='POST':
userForm=forms.DonorUserForm(request.POST)
donorForm=forms.DonorForm(request.POST,request.FILES)
if userForm.is_valid() and donorForm.is_valid():
user=userForm.save()

39
user.set_password(user.password)
user.save()
donor=donorForm.save(commit=False)
donor.user=user
donor.bloodgroup=donorForm.cleaned_data['bloodgroup']
donor.save()
my_donor_group = Group.objects.get_or_create(name='DONOR')
my_donor_group[0].user_set.add(user)
return HttpResponseRedirect('donorlogin')
return render(request,'donor/donorsignup.html',context=mydict)

def donor_dashboard_view(request):
donor= models.Donor.objects.get(user_id=request.user.id)
dict={
'requestpending':
bmodels.BloodRequest.objects.all().filter(request_by_donor=donor).filter(status='Pending').count(
),
'requestapproved':
bmodels.BloodRequest.objects.all().filter(request_by_donor=donor).filter(status='Approved').count
(),
'requestmade': bmodels.BloodRequest.objects.all().filter(request_by_donor=donor).count(),
'requestrejected':
bmodels.BloodRequest.objects.all().filter(request_by_donor=donor).filter(status='Rejected').count(
),
}
return render(request,'donor/donor_dashboard.html',context=dict)

def donate_blood_view(request):
donation_form=forms.DonationForm()
if request.method=='POST':
donation_form=forms.DonationForm(request.POST)
if donation_form.is_valid():
blood_donate=donation_form.save(commit=False)

40
blood_donate.bloodgroup=donation_form.cleaned_data['bloodgroup']
donor= models.Donor.objects.get(user_id=request.user.id)
blood_donate.donor=donor
blood_donate.save()
return HttpResponseRedirect('donation-history')
return render(request,'donor/donate_blood.html',{'donation_form':donation_form})

def donation_history_view(request):
donor= models.Donor.objects.get(user_id=request.user.id)
donations=models.BloodDonate.objects.all().filter(donor=donor)
return render(request,'donor/donation_history.html',{'donations':donations})

def make_request_view(request):
request_form=bforms.RequestForm()
if request.method=='POST':
request_form=bforms.RequestForm(request.POST)
if request_form.is_valid():
blood_request=request_form.save(commit=False)
blood_request.bloodgroup=request_form.cleaned_data['bloodgroup']
donor= models.Donor.objects.get(user_id=request.user.id)
blood_request.request_by_donor=donor
blood_request.save()
return HttpResponseRedirect('request-history')
return render(request,'donor/makerequest.html',{'request_form':request_form})

def request_history_view(request):
donor= models.Donor.objects.get(user_id=request.user.id)
blood_request=bmodels.BloodRequest.objects.all().filter(request_by_donor=donor)
return render(request,'donor/request_history.html',{'blood_request':blood_request})

41
6.CONCLUSION
This project has given me an ample opportunity to design, code, test and implements an
application. This has helped in putting into practice of various Software Engineering principles and
Database Management concepts like maintaining integrity and consistency of data. Further, this has
helped me to learn more about MYSQL, FLASK, PYTHON, HTML, PYTHON IDE and Personal Web
Server.
I thank my guide for his invaluable contribution in guiding me through out the project. I also thank
my parents and friends who have supported and motivated me to complete this project
successfully.

Extensibility
The other features, which the Blood bank services provide, can also be incorporated into this Blood
Bank. The Encryption standards can also be used to make the transactions more secure. The Socket
Secure Layer protocol can also used in implementing the system, which gives highest security in the
Internet.

Future Enhancement
As there was a little number of contact person’s information given, some people may face
difficulty in getting blood fast. So i like to gather more information regarding the contact persons in
other cities as well as villages and will provide much more services for the people and help
everyone with humanity.

42
7.REFERENCES

• www.google.com
• www.msn.com
• www.bloodzone.com
• www.bloodbankservices.com
• https://projectworlds.in/

43

You might also like