Professional Documents
Culture Documents
PROJECT REPORT
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.3 Objectives 7
1.4 Project 8
2.SYSTEM ANALYSIS 9
2.3 Observation 11
6
2.5 Proposed system 12
2.6 Limitation 12
3.SYSTEM DESIGN 13
4.1 Scope 19
5.1 Introduction 24
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.
• 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.
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.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.
3
⮚ Providing tips regarding the necessary measures that are to be taken before the blood
donation.
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
• 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.
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.
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
“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
Search
12
Registration
Blood Donors
Blood
Bank
Search
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
2) System Users:
• 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)
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
3. Blood
Blood Id
Blood Group
Date of collection
Expiry date
• 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
Deliverables:
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
17
• Documentation and Manual
1.Software Requirements
Operating System - Windows7/Linux
Web-framework - Django
2.Hardware Requirements
18
Hard Disk - 80GB
Ram - 2GB
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.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.
19
Test deliverables
Schedule
Personal allocation
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:
class RequestForm(forms.ModelForm):
class Meta:
model=models.BloodRequest
fields=['patient_name','patient_age','reason','bloodgroup','unit']
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
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')
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
),
]
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
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
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.
32
"""
import os
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_URL = '/static/'
STATICFILES_DIRS=[
STATIC_DIR,
]
LOGIN_REDIRECT_URL='/afterlogin'
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
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