Initial commit
This commit is contained in:
0
hospitalmanagement/hospital/__init__.py
Normal file
0
hospitalmanagement/hospital/__init__.py
Normal file
18
hospitalmanagement/hospital/admin.py
Normal file
18
hospitalmanagement/hospital/admin.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.contrib import admin
|
||||
from .models import Doctor,Patient,Appointment,PatientDischargeDetails
|
||||
# Register your models here.
|
||||
class DoctorAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
admin.site.register(Doctor, DoctorAdmin)
|
||||
|
||||
class PatientAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
admin.site.register(Patient, PatientAdmin)
|
||||
|
||||
class AppointmentAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
admin.site.register(Appointment, AppointmentAdmin)
|
||||
|
||||
class PatientDischargeDetailsAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
admin.site.register(PatientDischargeDetails, PatientDischargeDetailsAdmin)
|
||||
5
hospitalmanagement/hospital/apps.py
Normal file
5
hospitalmanagement/hospital/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class HospitalConfig(AppConfig):
|
||||
name = 'hospital'
|
||||
76
hospitalmanagement/hospital/forms.py
Normal file
76
hospitalmanagement/hospital/forms.py
Normal file
@@ -0,0 +1,76 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from . import models
|
||||
|
||||
|
||||
|
||||
#for admin signup
|
||||
class AdminSigupForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model=User
|
||||
fields=['first_name','last_name','username','password']
|
||||
widgets = {
|
||||
'password': forms.PasswordInput()
|
||||
}
|
||||
|
||||
|
||||
#for student related form
|
||||
class DoctorUserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model=User
|
||||
fields=['first_name','last_name','username','password']
|
||||
widgets = {
|
||||
'password': forms.PasswordInput()
|
||||
}
|
||||
class DoctorForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model=models.Doctor
|
||||
fields=['address','mobile','department','status','profile_pic']
|
||||
|
||||
|
||||
|
||||
#for teacher related form
|
||||
class PatientUserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model=User
|
||||
fields=['first_name','last_name','username','password']
|
||||
widgets = {
|
||||
'password': forms.PasswordInput()
|
||||
}
|
||||
class PatientForm(forms.ModelForm):
|
||||
#this is the extrafield for linking patient and their assigend doctor
|
||||
#this will show dropdown __str__ method doctor model is shown on html so override it
|
||||
#to_field_name this will fetch corresponding value user_id present in Doctor model and return it
|
||||
assignedDoctorId=forms.ModelChoiceField(queryset=models.Doctor.objects.all().filter(status=True),empty_label="Name and Department", to_field_name="user_id")
|
||||
class Meta:
|
||||
model=models.Patient
|
||||
fields=['address','mobile','status','symptoms','profile_pic']
|
||||
|
||||
|
||||
|
||||
class AppointmentForm(forms.ModelForm):
|
||||
doctorId=forms.ModelChoiceField(queryset=models.Doctor.objects.all().filter(status=True),empty_label="Doctor Name and Department", to_field_name="user_id")
|
||||
patientId=forms.ModelChoiceField(queryset=models.Patient.objects.all().filter(status=True),empty_label="Patient Name and Symptoms", to_field_name="user_id")
|
||||
class Meta:
|
||||
model=models.Appointment
|
||||
fields=['description','status']
|
||||
|
||||
|
||||
class PatientAppointmentForm(forms.ModelForm):
|
||||
doctorId=forms.ModelChoiceField(queryset=models.Doctor.objects.all().filter(status=True),empty_label="Doctor Name and Department", to_field_name="user_id")
|
||||
class Meta:
|
||||
model=models.Appointment
|
||||
fields=['description','status']
|
||||
|
||||
|
||||
#for contact us page
|
||||
class ContactusForm(forms.Form):
|
||||
Name = forms.CharField(max_length=30)
|
||||
Email = forms.EmailField()
|
||||
Message = forms.CharField(max_length=500,widget=forms.Textarea(attrs={'rows': 3, 'cols': 30}))
|
||||
|
||||
|
||||
|
||||
#Developed By : sumit kumar
|
||||
#facebook : fb.com/sumit.luv
|
||||
#Youtube :youtube.com/lazycoders
|
||||
51
hospitalmanagement/hospital/migrations/0001_initial.py
Normal file
51
hospitalmanagement/hospital/migrations/0001_initial.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-15 04:45
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='TeacherExtra',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('salary', models.PositiveIntegerField()),
|
||||
('joindate', models.DateField(auto_now_add=True)),
|
||||
('mobile', models.CharField(max_length=40)),
|
||||
('status', models.BooleanField(default=False)),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Patient',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('address', models.CharField(max_length=40)),
|
||||
('mobile', models.CharField(max_length=40, null=True)),
|
||||
('symptoms', models.CharField(max_length=100, null=True)),
|
||||
('assignedDoctorId', models.PositiveIntegerField()),
|
||||
('status', models.BooleanField(default=False)),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Doctor',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('address', models.CharField(max_length=40)),
|
||||
('mobile', models.CharField(max_length=40, null=True)),
|
||||
('department', models.CharField(choices=[('Cardiologist', 'Cardiologist'), ('Dermatologists', 'Dermatologists'), ('Emergency Medicine Specialists', 'Emergency Medicine Specialists'), ('Allergists/Immunologists', 'Allergists/Immunologists'), ('Anesthesiologists', 'Anesthesiologists'), ('Colon and Rectal Surgeons', 'Colon and Rectal Surgeons')], default='Cardiologist', max_length=50)),
|
||||
('status', models.BooleanField(default=False)),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-15 04:46
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.DeleteModel(
|
||||
name='TeacherExtra',
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-18 03:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0002_delete_teacherextra'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='patient',
|
||||
name='admitDate',
|
||||
field=models.DateField(auto_now=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-18 08:47
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0003_patient_admitdate'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PatientDischargeDetails',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('patientId', models.PositiveIntegerField()),
|
||||
('patientName', models.CharField(max_length=40)),
|
||||
('assignedDoctorName', models.CharField(max_length=40)),
|
||||
('address', models.CharField(max_length=40)),
|
||||
('mobile', models.CharField(max_length=40, null=True)),
|
||||
('symptoms', models.CharField(max_length=100, null=True)),
|
||||
('admitDate', models.DateField()),
|
||||
('releaseDate', models.DateField()),
|
||||
('daySpent', models.PositiveIntegerField()),
|
||||
('roomCharge', models.PositiveIntegerField()),
|
||||
('medicineCost', models.PositiveIntegerField()),
|
||||
('doctorFee', models.PositiveIntegerField()),
|
||||
('OtherCharge', models.PositiveIntegerField()),
|
||||
('total', models.PositiveIntegerField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
23
hospitalmanagement/hospital/migrations/0005_appointment.py
Normal file
23
hospitalmanagement/hospital/migrations/0005_appointment.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-20 02:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0004_patientdischargedetails'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Appointment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('patientId', models.PositiveIntegerField()),
|
||||
('doctorId', models.PositiveIntegerField()),
|
||||
('appointmentDate', models.DateField(auto_now=True)),
|
||||
('description', models.TextField(max_length=500)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-20 03:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0005_appointment'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='appointment',
|
||||
name='status',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-20 04:53
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0006_appointment_status'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='appointment',
|
||||
name='doctorName',
|
||||
field=models.CharField(max_length=40, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='appointment',
|
||||
name='patientName',
|
||||
field=models.CharField(max_length=40, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patient',
|
||||
name='mobile',
|
||||
field=models.CharField(max_length=40),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patient',
|
||||
name='symptoms',
|
||||
field=models.CharField(max_length=100),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-20 05:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0007_auto_20200520_1023'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='doctor',
|
||||
name='profile_pic',
|
||||
field=models.ImageField(null=True, upload_to='DoctorProfilePic/'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-23 05:48
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0008_doctor_profile_pic'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='doctor',
|
||||
name='profile_pic',
|
||||
field=models.ImageField(blank=True, null=True, upload_to=''),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-23 05:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0009_auto_20200523_1118'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='doctor',
|
||||
name='profile_pic',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='static/DoctorProfilePic/'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-23 07:55
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0010_auto_20200523_1122'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='doctor',
|
||||
name='profile_pic',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='DoctorProfilePic/'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-23 08:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0011_auto_20200523_1325'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='doctor',
|
||||
name='profile_pic',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='profile_pic/DoctorProfilePic/'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-23 09:54
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0012_auto_20200523_1336'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='patient',
|
||||
name='profile_pic',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='profile_pic/PatientProfilePic/'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-26 09:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0013_patient_profile_pic'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='patientdischargedetails',
|
||||
name='mobile',
|
||||
field=models.CharField(max_length=10, null=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.0.5 on 2020-05-26 09:31
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0014_auto_20200526_1455'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='doctor',
|
||||
name='mobile',
|
||||
field=models.CharField(max_length=10, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patient',
|
||||
name='mobile',
|
||||
field=models.CharField(max_length=10),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
# Generated by Django 3.0.5 on 2020-06-22 18:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0015_auto_20200526_1501'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='doctor',
|
||||
name='mobile',
|
||||
field=models.CharField(max_length=20, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patient',
|
||||
name='mobile',
|
||||
field=models.CharField(max_length=20),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patientdischargedetails',
|
||||
name='mobile',
|
||||
field=models.CharField(max_length=20, null=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 3.0.5 on 2020-06-22 18:35
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0016_auto_20200622_1830'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='appointment',
|
||||
name='doctorId',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='hospital.Doctor'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='appointment',
|
||||
name='patientId',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='hospital.Patient'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patient',
|
||||
name='assignedDoctorId',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='hospital.Doctor'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patientdischargedetails',
|
||||
name='patientId',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='hospital.Patient'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 3.0.5 on 2020-10-15 15:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hospital', '0017_auto_20200622_1835'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='appointment',
|
||||
name='doctorId',
|
||||
field=models.PositiveIntegerField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='appointment',
|
||||
name='patientId',
|
||||
field=models.PositiveIntegerField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patient',
|
||||
name='assignedDoctorId',
|
||||
field=models.PositiveIntegerField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='patientdischargedetails',
|
||||
name='patientId',
|
||||
field=models.PositiveIntegerField(null=True),
|
||||
),
|
||||
]
|
||||
0
hospitalmanagement/hospital/migrations/__init__.py
Normal file
0
hospitalmanagement/hospital/migrations/__init__.py
Normal file
82
hospitalmanagement/hospital/models.py
Normal file
82
hospitalmanagement/hospital/models.py
Normal file
@@ -0,0 +1,82 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
|
||||
departments=[('Cardiologist','Cardiologist'),
|
||||
('Dermatologists','Dermatologists'),
|
||||
('Emergency Medicine Specialists','Emergency Medicine Specialists'),
|
||||
('Allergists/Immunologists','Allergists/Immunologists'),
|
||||
('Anesthesiologists','Anesthesiologists'),
|
||||
('Colon and Rectal Surgeons','Colon and Rectal Surgeons')
|
||||
]
|
||||
class Doctor(models.Model):
|
||||
user=models.OneToOneField(User,on_delete=models.CASCADE)
|
||||
profile_pic= models.ImageField(upload_to='profile_pic/DoctorProfilePic/',null=True,blank=True)
|
||||
address = models.CharField(max_length=40)
|
||||
mobile = models.CharField(max_length=20,null=True)
|
||||
department= models.CharField(max_length=50,choices=departments,default='Cardiologist')
|
||||
status=models.BooleanField(default=False)
|
||||
@property
|
||||
def get_name(self):
|
||||
return self.user.first_name+" "+self.user.last_name
|
||||
@property
|
||||
def get_id(self):
|
||||
return self.user.id
|
||||
def __str__(self):
|
||||
return "{} ({})".format(self.user.first_name,self.department)
|
||||
|
||||
|
||||
|
||||
class Patient(models.Model):
|
||||
user=models.OneToOneField(User,on_delete=models.CASCADE)
|
||||
profile_pic= models.ImageField(upload_to='profile_pic/PatientProfilePic/',null=True,blank=True)
|
||||
address = models.CharField(max_length=40)
|
||||
mobile = models.CharField(max_length=20,null=False)
|
||||
symptoms = models.CharField(max_length=100,null=False)
|
||||
assignedDoctorId = models.PositiveIntegerField(null=True)
|
||||
admitDate=models.DateField(auto_now=True)
|
||||
status=models.BooleanField(default=False)
|
||||
@property
|
||||
def get_name(self):
|
||||
return self.user.first_name+" "+self.user.last_name
|
||||
@property
|
||||
def get_id(self):
|
||||
return self.user.id
|
||||
def __str__(self):
|
||||
return self.user.first_name+" ("+self.symptoms+")"
|
||||
|
||||
|
||||
class Appointment(models.Model):
|
||||
patientId=models.PositiveIntegerField(null=True)
|
||||
doctorId=models.PositiveIntegerField(null=True)
|
||||
patientName=models.CharField(max_length=40,null=True)
|
||||
doctorName=models.CharField(max_length=40,null=True)
|
||||
appointmentDate=models.DateField(auto_now=True)
|
||||
description=models.TextField(max_length=500)
|
||||
status=models.BooleanField(default=False)
|
||||
|
||||
|
||||
|
||||
class PatientDischargeDetails(models.Model):
|
||||
patientId=models.PositiveIntegerField(null=True)
|
||||
patientName=models.CharField(max_length=40)
|
||||
assignedDoctorName=models.CharField(max_length=40)
|
||||
address = models.CharField(max_length=40)
|
||||
mobile = models.CharField(max_length=20,null=True)
|
||||
symptoms = models.CharField(max_length=100,null=True)
|
||||
|
||||
admitDate=models.DateField(null=False)
|
||||
releaseDate=models.DateField(null=False)
|
||||
daySpent=models.PositiveIntegerField(null=False)
|
||||
|
||||
roomCharge=models.PositiveIntegerField(null=False)
|
||||
medicineCost=models.PositiveIntegerField(null=False)
|
||||
doctorFee=models.PositiveIntegerField(null=False)
|
||||
OtherCharge=models.PositiveIntegerField(null=False)
|
||||
total=models.PositiveIntegerField(null=False)
|
||||
|
||||
|
||||
#Developed By : sumit kumar
|
||||
#facebook : fb.com/sumit.luv
|
||||
#Youtube :youtube.com/lazycoders
|
||||
833
hospitalmanagement/hospital/views.py
Normal file
833
hospitalmanagement/hospital/views.py
Normal file
@@ -0,0 +1,833 @@
|
||||
from django.shortcuts import render,redirect,reverse
|
||||
from . import forms,models
|
||||
from django.db.models import Sum
|
||||
from django.contrib.auth.models import Group
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.core.mail import send_mail
|
||||
from django.contrib.auth.decorators import login_required,user_passes_test
|
||||
from datetime import datetime,timedelta,date
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
|
||||
# Create your views here.
|
||||
def home_view(request):
|
||||
if request.user.is_authenticated:
|
||||
return HttpResponseRedirect('afterlogin')
|
||||
return render(request,'hospital/index.html')
|
||||
|
||||
|
||||
#for showing signup/login button for admin(by sumit)
|
||||
def adminclick_view(request):
|
||||
if request.user.is_authenticated:
|
||||
return HttpResponseRedirect('afterlogin')
|
||||
return render(request,'hospital/adminclick.html')
|
||||
|
||||
|
||||
#for showing signup/login button for doctor(by sumit)
|
||||
def doctorclick_view(request):
|
||||
if request.user.is_authenticated:
|
||||
return HttpResponseRedirect('afterlogin')
|
||||
return render(request,'hospital/doctorclick.html')
|
||||
|
||||
|
||||
#for showing signup/login button for patient(by sumit)
|
||||
def patientclick_view(request):
|
||||
if request.user.is_authenticated:
|
||||
return HttpResponseRedirect('afterlogin')
|
||||
return render(request,'hospital/patientclick.html')
|
||||
|
||||
|
||||
|
||||
|
||||
def admin_signup_view(request):
|
||||
form=forms.AdminSigupForm()
|
||||
if request.method=='POST':
|
||||
form=forms.AdminSigupForm(request.POST)
|
||||
if form.is_valid():
|
||||
user=form.save()
|
||||
user.set_password(user.password)
|
||||
user.save()
|
||||
my_admin_group = Group.objects.get_or_create(name='ADMIN')
|
||||
my_admin_group[0].user_set.add(user)
|
||||
return HttpResponseRedirect('adminlogin')
|
||||
return render(request,'hospital/adminsignup.html',{'form':form})
|
||||
|
||||
|
||||
|
||||
|
||||
def doctor_signup_view(request):
|
||||
userForm=forms.DoctorUserForm()
|
||||
doctorForm=forms.DoctorForm()
|
||||
mydict={'userForm':userForm,'doctorForm':doctorForm}
|
||||
if request.method=='POST':
|
||||
userForm=forms.DoctorUserForm(request.POST)
|
||||
doctorForm=forms.DoctorForm(request.POST,request.FILES)
|
||||
if userForm.is_valid() and doctorForm.is_valid():
|
||||
user=userForm.save()
|
||||
user.set_password(user.password)
|
||||
user.save()
|
||||
doctor=doctorForm.save(commit=False)
|
||||
doctor.user=user
|
||||
doctor=doctor.save()
|
||||
my_doctor_group = Group.objects.get_or_create(name='DOCTOR')
|
||||
my_doctor_group[0].user_set.add(user)
|
||||
return HttpResponseRedirect('doctorlogin')
|
||||
return render(request,'hospital/doctorsignup.html',context=mydict)
|
||||
|
||||
|
||||
def patient_signup_view(request):
|
||||
userForm=forms.PatientUserForm()
|
||||
patientForm=forms.PatientForm()
|
||||
mydict={'userForm':userForm,'patientForm':patientForm}
|
||||
if request.method=='POST':
|
||||
userForm=forms.PatientUserForm(request.POST)
|
||||
patientForm=forms.PatientForm(request.POST,request.FILES)
|
||||
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.assignedDoctorId=request.POST.get('assignedDoctorId')
|
||||
patient=patient.save()
|
||||
my_patient_group = Group.objects.get_or_create(name='PATIENT')
|
||||
my_patient_group[0].user_set.add(user)
|
||||
return HttpResponseRedirect('patientlogin')
|
||||
return render(request,'hospital/patientsignup.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------for checking user is doctor , patient or admin(by sumit)
|
||||
def is_admin(user):
|
||||
return user.groups.filter(name='ADMIN').exists()
|
||||
def is_doctor(user):
|
||||
return user.groups.filter(name='DOCTOR').exists()
|
||||
def is_patient(user):
|
||||
return user.groups.filter(name='PATIENT').exists()
|
||||
|
||||
|
||||
#---------AFTER ENTERING CREDENTIALS WE CHECK WHETHER USERNAME AND PASSWORD IS OF ADMIN,DOCTOR OR PATIENT
|
||||
def afterlogin_view(request):
|
||||
if is_admin(request.user):
|
||||
return redirect('admin-dashboard')
|
||||
elif is_doctor(request.user):
|
||||
accountapproval=models.Doctor.objects.all().filter(user_id=request.user.id,status=True)
|
||||
if accountapproval:
|
||||
return redirect('doctor-dashboard')
|
||||
else:
|
||||
return render(request,'hospital/doctor_wait_for_approval.html')
|
||||
elif is_patient(request.user):
|
||||
accountapproval=models.Patient.objects.all().filter(user_id=request.user.id,status=True)
|
||||
if accountapproval:
|
||||
return redirect('patient-dashboard')
|
||||
else:
|
||||
return render(request,'hospital/patient_wait_for_approval.html')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#------------------------ ADMIN RELATED VIEWS START ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_dashboard_view(request):
|
||||
#for both table in admin dashboard
|
||||
doctors=models.Doctor.objects.all().order_by('-id')
|
||||
patients=models.Patient.objects.all().order_by('-id')
|
||||
#for three cards
|
||||
doctorcount=models.Doctor.objects.all().filter(status=True).count()
|
||||
pendingdoctorcount=models.Doctor.objects.all().filter(status=False).count()
|
||||
|
||||
patientcount=models.Patient.objects.all().filter(status=True).count()
|
||||
pendingpatientcount=models.Patient.objects.all().filter(status=False).count()
|
||||
|
||||
appointmentcount=models.Appointment.objects.all().filter(status=True).count()
|
||||
pendingappointmentcount=models.Appointment.objects.all().filter(status=False).count()
|
||||
mydict={
|
||||
'doctors':doctors,
|
||||
'patients':patients,
|
||||
'doctorcount':doctorcount,
|
||||
'pendingdoctorcount':pendingdoctorcount,
|
||||
'patientcount':patientcount,
|
||||
'pendingpatientcount':pendingpatientcount,
|
||||
'appointmentcount':appointmentcount,
|
||||
'pendingappointmentcount':pendingappointmentcount,
|
||||
}
|
||||
return render(request,'hospital/admin_dashboard.html',context=mydict)
|
||||
|
||||
|
||||
# this view for sidebar click on admin page
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_doctor_view(request):
|
||||
return render(request,'hospital/admin_doctor.html')
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_view_doctor_view(request):
|
||||
doctors=models.Doctor.objects.all().filter(status=True)
|
||||
return render(request,'hospital/admin_view_doctor.html',{'doctors':doctors})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def delete_doctor_from_hospital_view(request,pk):
|
||||
doctor=models.Doctor.objects.get(id=pk)
|
||||
user=models.User.objects.get(id=doctor.user_id)
|
||||
user.delete()
|
||||
doctor.delete()
|
||||
return redirect('admin-view-doctor')
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def update_doctor_view(request,pk):
|
||||
doctor=models.Doctor.objects.get(id=pk)
|
||||
user=models.User.objects.get(id=doctor.user_id)
|
||||
|
||||
userForm=forms.DoctorUserForm(instance=user)
|
||||
doctorForm=forms.DoctorForm(request.FILES,instance=doctor)
|
||||
mydict={'userForm':userForm,'doctorForm':doctorForm}
|
||||
if request.method=='POST':
|
||||
userForm=forms.DoctorUserForm(request.POST,instance=user)
|
||||
doctorForm=forms.DoctorForm(request.POST,request.FILES,instance=doctor)
|
||||
if userForm.is_valid() and doctorForm.is_valid():
|
||||
user=userForm.save()
|
||||
user.set_password(user.password)
|
||||
user.save()
|
||||
doctor=doctorForm.save(commit=False)
|
||||
doctor.status=True
|
||||
doctor.save()
|
||||
return redirect('admin-view-doctor')
|
||||
return render(request,'hospital/admin_update_doctor.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_add_doctor_view(request):
|
||||
userForm=forms.DoctorUserForm()
|
||||
doctorForm=forms.DoctorForm()
|
||||
mydict={'userForm':userForm,'doctorForm':doctorForm}
|
||||
if request.method=='POST':
|
||||
userForm=forms.DoctorUserForm(request.POST)
|
||||
doctorForm=forms.DoctorForm(request.POST, request.FILES)
|
||||
if userForm.is_valid() and doctorForm.is_valid():
|
||||
user=userForm.save()
|
||||
user.set_password(user.password)
|
||||
user.save()
|
||||
|
||||
doctor=doctorForm.save(commit=False)
|
||||
doctor.user=user
|
||||
doctor.status=True
|
||||
doctor.save()
|
||||
|
||||
my_doctor_group = Group.objects.get_or_create(name='DOCTOR')
|
||||
my_doctor_group[0].user_set.add(user)
|
||||
|
||||
return HttpResponseRedirect('admin-view-doctor')
|
||||
return render(request,'hospital/admin_add_doctor.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_approve_doctor_view(request):
|
||||
#those whose approval are needed
|
||||
doctors=models.Doctor.objects.all().filter(status=False)
|
||||
return render(request,'hospital/admin_approve_doctor.html',{'doctors':doctors})
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def approve_doctor_view(request,pk):
|
||||
doctor=models.Doctor.objects.get(id=pk)
|
||||
doctor.status=True
|
||||
doctor.save()
|
||||
return redirect(reverse('admin-approve-doctor'))
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def reject_doctor_view(request,pk):
|
||||
doctor=models.Doctor.objects.get(id=pk)
|
||||
user=models.User.objects.get(id=doctor.user_id)
|
||||
user.delete()
|
||||
doctor.delete()
|
||||
return redirect('admin-approve-doctor')
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_view_doctor_specialisation_view(request):
|
||||
doctors=models.Doctor.objects.all().filter(status=True)
|
||||
return render(request,'hospital/admin_view_doctor_specialisation.html',{'doctors':doctors})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_patient_view(request):
|
||||
return render(request,'hospital/admin_patient.html')
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_view_patient_view(request):
|
||||
patients=models.Patient.objects.all().filter(status=True)
|
||||
return render(request,'hospital/admin_view_patient.html',{'patients':patients})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def delete_patient_from_hospital_view(request,pk):
|
||||
patient=models.Patient.objects.get(id=pk)
|
||||
user=models.User.objects.get(id=patient.user_id)
|
||||
user.delete()
|
||||
patient.delete()
|
||||
return redirect('admin-view-patient')
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def update_patient_view(request,pk):
|
||||
patient=models.Patient.objects.get(id=pk)
|
||||
user=models.User.objects.get(id=patient.user_id)
|
||||
|
||||
userForm=forms.PatientUserForm(instance=user)
|
||||
patientForm=forms.PatientForm(request.FILES,instance=patient)
|
||||
mydict={'userForm':userForm,'patientForm':patientForm}
|
||||
if request.method=='POST':
|
||||
userForm=forms.PatientUserForm(request.POST,instance=user)
|
||||
patientForm=forms.PatientForm(request.POST,request.FILES,instance=patient)
|
||||
if userForm.is_valid() and patientForm.is_valid():
|
||||
user=userForm.save()
|
||||
user.set_password(user.password)
|
||||
user.save()
|
||||
patient=patientForm.save(commit=False)
|
||||
patient.status=True
|
||||
patient.assignedDoctorId=request.POST.get('assignedDoctorId')
|
||||
patient.save()
|
||||
return redirect('admin-view-patient')
|
||||
return render(request,'hospital/admin_update_patient.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_add_patient_view(request):
|
||||
userForm=forms.PatientUserForm()
|
||||
patientForm=forms.PatientForm()
|
||||
mydict={'userForm':userForm,'patientForm':patientForm}
|
||||
if request.method=='POST':
|
||||
userForm=forms.PatientUserForm(request.POST)
|
||||
patientForm=forms.PatientForm(request.POST,request.FILES)
|
||||
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.status=True
|
||||
patient.assignedDoctorId=request.POST.get('assignedDoctorId')
|
||||
patient.save()
|
||||
|
||||
my_patient_group = Group.objects.get_or_create(name='PATIENT')
|
||||
my_patient_group[0].user_set.add(user)
|
||||
|
||||
return HttpResponseRedirect('admin-view-patient')
|
||||
return render(request,'hospital/admin_add_patient.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
#------------------FOR APPROVING PATIENT BY ADMIN----------------------
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_approve_patient_view(request):
|
||||
#those whose approval are needed
|
||||
patients=models.Patient.objects.all().filter(status=False)
|
||||
return render(request,'hospital/admin_approve_patient.html',{'patients':patients})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def approve_patient_view(request,pk):
|
||||
patient=models.Patient.objects.get(id=pk)
|
||||
patient.status=True
|
||||
patient.save()
|
||||
return redirect(reverse('admin-approve-patient'))
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def reject_patient_view(request,pk):
|
||||
patient=models.Patient.objects.get(id=pk)
|
||||
user=models.User.objects.get(id=patient.user_id)
|
||||
user.delete()
|
||||
patient.delete()
|
||||
return redirect('admin-approve-patient')
|
||||
|
||||
|
||||
|
||||
#--------------------- FOR DISCHARGING PATIENT BY ADMIN START-------------------------
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_discharge_patient_view(request):
|
||||
patients=models.Patient.objects.all().filter(status=True)
|
||||
return render(request,'hospital/admin_discharge_patient.html',{'patients':patients})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def discharge_patient_view(request,pk):
|
||||
patient=models.Patient.objects.get(id=pk)
|
||||
days=(date.today()-patient.admitDate) #2 days, 0:00:00
|
||||
assignedDoctor=models.User.objects.all().filter(id=patient.assignedDoctorId)
|
||||
d=days.days # only how many day that is 2
|
||||
patientDict={
|
||||
'patientId':pk,
|
||||
'name':patient.get_name,
|
||||
'mobile':patient.mobile,
|
||||
'address':patient.address,
|
||||
'symptoms':patient.symptoms,
|
||||
'admitDate':patient.admitDate,
|
||||
'todayDate':date.today(),
|
||||
'day':d,
|
||||
'assignedDoctorName':assignedDoctor[0].first_name,
|
||||
}
|
||||
if request.method == 'POST':
|
||||
feeDict ={
|
||||
'roomCharge':int(request.POST['roomCharge'])*int(d),
|
||||
'doctorFee':request.POST['doctorFee'],
|
||||
'medicineCost' : request.POST['medicineCost'],
|
||||
'OtherCharge' : request.POST['OtherCharge'],
|
||||
'total':(int(request.POST['roomCharge'])*int(d))+int(request.POST['doctorFee'])+int(request.POST['medicineCost'])+int(request.POST['OtherCharge'])
|
||||
}
|
||||
patientDict.update(feeDict)
|
||||
#for updating to database patientDischargeDetails (pDD)
|
||||
pDD=models.PatientDischargeDetails()
|
||||
pDD.patientId=pk
|
||||
pDD.patientName=patient.get_name
|
||||
pDD.assignedDoctorName=assignedDoctor[0].first_name
|
||||
pDD.address=patient.address
|
||||
pDD.mobile=patient.mobile
|
||||
pDD.symptoms=patient.symptoms
|
||||
pDD.admitDate=patient.admitDate
|
||||
pDD.releaseDate=date.today()
|
||||
pDD.daySpent=int(d)
|
||||
pDD.medicineCost=int(request.POST['medicineCost'])
|
||||
pDD.roomCharge=int(request.POST['roomCharge'])*int(d)
|
||||
pDD.doctorFee=int(request.POST['doctorFee'])
|
||||
pDD.OtherCharge=int(request.POST['OtherCharge'])
|
||||
pDD.total=(int(request.POST['roomCharge'])*int(d))+int(request.POST['doctorFee'])+int(request.POST['medicineCost'])+int(request.POST['OtherCharge'])
|
||||
pDD.save()
|
||||
return render(request,'hospital/patient_final_bill.html',context=patientDict)
|
||||
return render(request,'hospital/patient_generate_bill.html',context=patientDict)
|
||||
|
||||
|
||||
|
||||
# PDF generation via xhtml2pdf has been disabled to avoid freetype/reportlab runtime errors.
|
||||
# Fallback: render the bill template as regular HTML so users can view/print it from the browser.
|
||||
def download_pdf_view(request, pk):
|
||||
dischargeDetails = models.PatientDischargeDetails.objects.all().filter(patientId=pk).order_by('-id')[:1]
|
||||
if not dischargeDetails:
|
||||
return render(request, 'hospital/download_bill.html', {})
|
||||
context = {
|
||||
'patientName': dischargeDetails[0].patientName,
|
||||
'assignedDoctorName': dischargeDetails[0].assignedDoctorName,
|
||||
'address': dischargeDetails[0].address,
|
||||
'mobile': dischargeDetails[0].mobile,
|
||||
'symptoms': dischargeDetails[0].symptoms,
|
||||
'admitDate': dischargeDetails[0].admitDate,
|
||||
'releaseDate': dischargeDetails[0].releaseDate,
|
||||
'daySpent': dischargeDetails[0].daySpent,
|
||||
'medicineCost': dischargeDetails[0].medicineCost,
|
||||
'roomCharge': dischargeDetails[0].roomCharge,
|
||||
'doctorFee': dischargeDetails[0].doctorFee,
|
||||
'OtherCharge': dischargeDetails[0].OtherCharge,
|
||||
'total': dischargeDetails[0].total,
|
||||
}
|
||||
return render(request, 'hospital/download_bill.html', context)
|
||||
|
||||
|
||||
|
||||
#-----------------APPOINTMENT START--------------------------------------------------------------------
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_appointment_view(request):
|
||||
return render(request,'hospital/admin_appointment.html')
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_view_appointment_view(request):
|
||||
appointments=models.Appointment.objects.all().filter(status=True)
|
||||
return render(request,'hospital/admin_view_appointment.html',{'appointments':appointments})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_add_appointment_view(request):
|
||||
appointmentForm=forms.AppointmentForm()
|
||||
mydict={'appointmentForm':appointmentForm,}
|
||||
if request.method=='POST':
|
||||
appointmentForm=forms.AppointmentForm(request.POST)
|
||||
if appointmentForm.is_valid():
|
||||
appointment=appointmentForm.save(commit=False)
|
||||
appointment.doctorId=request.POST.get('doctorId')
|
||||
appointment.patientId=request.POST.get('patientId')
|
||||
appointment.doctorName=models.User.objects.get(id=request.POST.get('doctorId')).first_name
|
||||
appointment.patientName=models.User.objects.get(id=request.POST.get('patientId')).first_name
|
||||
appointment.status=True
|
||||
appointment.save()
|
||||
return HttpResponseRedirect('admin-view-appointment')
|
||||
return render(request,'hospital/admin_add_appointment.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def admin_approve_appointment_view(request):
|
||||
#those whose approval are needed
|
||||
appointments=models.Appointment.objects.all().filter(status=False)
|
||||
return render(request,'hospital/admin_approve_appointment.html',{'appointments':appointments})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def approve_appointment_view(request,pk):
|
||||
appointment=models.Appointment.objects.get(id=pk)
|
||||
appointment.status=True
|
||||
appointment.save()
|
||||
return redirect(reverse('admin-approve-appointment'))
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='adminlogin')
|
||||
@user_passes_test(is_admin)
|
||||
def reject_appointment_view(request,pk):
|
||||
appointment=models.Appointment.objects.get(id=pk)
|
||||
appointment.delete()
|
||||
return redirect('admin-approve-appointment')
|
||||
#---------------------------------------------------------------------------------
|
||||
#------------------------ ADMIN RELATED VIEWS END ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#------------------------ DOCTOR RELATED VIEWS START ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def doctor_dashboard_view(request):
|
||||
#for three cards
|
||||
patientcount=models.Patient.objects.all().filter(status=True,assignedDoctorId=request.user.id).count()
|
||||
appointmentcount=models.Appointment.objects.all().filter(status=True,doctorId=request.user.id).count()
|
||||
patientdischarged=models.PatientDischargeDetails.objects.all().distinct().filter(assignedDoctorName=request.user.first_name).count()
|
||||
|
||||
#for table in doctor dashboard
|
||||
appointments=models.Appointment.objects.all().filter(status=True,doctorId=request.user.id).order_by('-id')
|
||||
patientid=[]
|
||||
for a in appointments:
|
||||
patientid.append(a.patientId)
|
||||
patients=models.Patient.objects.all().filter(status=True,user_id__in=patientid).order_by('-id')
|
||||
appointments=zip(appointments,patients)
|
||||
mydict={
|
||||
'patientcount':patientcount,
|
||||
'appointmentcount':appointmentcount,
|
||||
'patientdischarged':patientdischarged,
|
||||
'appointments':appointments,
|
||||
'doctor':models.Doctor.objects.get(user_id=request.user.id), #for profile picture of doctor in sidebar
|
||||
}
|
||||
return render(request,'hospital/doctor_dashboard.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def doctor_patient_view(request):
|
||||
mydict={
|
||||
'doctor':models.Doctor.objects.get(user_id=request.user.id), #for profile picture of doctor in sidebar
|
||||
}
|
||||
return render(request,'hospital/doctor_patient.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def doctor_view_patient_view(request):
|
||||
patients=models.Patient.objects.all().filter(status=True,assignedDoctorId=request.user.id)
|
||||
doctor=models.Doctor.objects.get(user_id=request.user.id) #for profile picture of doctor in sidebar
|
||||
return render(request,'hospital/doctor_view_patient.html',{'patients':patients,'doctor':doctor})
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def search_view(request):
|
||||
doctor=models.Doctor.objects.get(user_id=request.user.id) #for profile picture of doctor in sidebar
|
||||
# whatever user write in search box we get in query
|
||||
query = request.GET['query']
|
||||
patients=models.Patient.objects.all().filter(status=True,assignedDoctorId=request.user.id).filter(Q(symptoms__icontains=query)|Q(user__first_name__icontains=query))
|
||||
return render(request,'hospital/doctor_view_patient.html',{'patients':patients,'doctor':doctor})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def doctor_view_discharge_patient_view(request):
|
||||
dischargedpatients=models.PatientDischargeDetails.objects.all().distinct().filter(assignedDoctorName=request.user.first_name)
|
||||
doctor=models.Doctor.objects.get(user_id=request.user.id) #for profile picture of doctor in sidebar
|
||||
return render(request,'hospital/doctor_view_discharge_patient.html',{'dischargedpatients':dischargedpatients,'doctor':doctor})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def doctor_appointment_view(request):
|
||||
doctor=models.Doctor.objects.get(user_id=request.user.id) #for profile picture of doctor in sidebar
|
||||
return render(request,'hospital/doctor_appointment.html',{'doctor':doctor})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def doctor_view_appointment_view(request):
|
||||
doctor=models.Doctor.objects.get(user_id=request.user.id) #for profile picture of doctor in sidebar
|
||||
appointments=models.Appointment.objects.all().filter(status=True,doctorId=request.user.id)
|
||||
patientid=[]
|
||||
for a in appointments:
|
||||
patientid.append(a.patientId)
|
||||
patients=models.Patient.objects.all().filter(status=True,user_id__in=patientid)
|
||||
appointments=zip(appointments,patients)
|
||||
return render(request,'hospital/doctor_view_appointment.html',{'appointments':appointments,'doctor':doctor})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def doctor_delete_appointment_view(request):
|
||||
doctor=models.Doctor.objects.get(user_id=request.user.id) #for profile picture of doctor in sidebar
|
||||
appointments=models.Appointment.objects.all().filter(status=True,doctorId=request.user.id)
|
||||
patientid=[]
|
||||
for a in appointments:
|
||||
patientid.append(a.patientId)
|
||||
patients=models.Patient.objects.all().filter(status=True,user_id__in=patientid)
|
||||
appointments=zip(appointments,patients)
|
||||
return render(request,'hospital/doctor_delete_appointment.html',{'appointments':appointments,'doctor':doctor})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='doctorlogin')
|
||||
@user_passes_test(is_doctor)
|
||||
def delete_appointment_view(request,pk):
|
||||
appointment=models.Appointment.objects.get(id=pk)
|
||||
appointment.delete()
|
||||
doctor=models.Doctor.objects.get(user_id=request.user.id) #for profile picture of doctor in sidebar
|
||||
appointments=models.Appointment.objects.all().filter(status=True,doctorId=request.user.id)
|
||||
patientid=[]
|
||||
for a in appointments:
|
||||
patientid.append(a.patientId)
|
||||
patients=models.Patient.objects.all().filter(status=True,user_id__in=patientid)
|
||||
appointments=zip(appointments,patients)
|
||||
return render(request,'hospital/doctor_delete_appointment.html',{'appointments':appointments,'doctor':doctor})
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#------------------------ DOCTOR RELATED VIEWS END ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#------------------------ PATIENT RELATED VIEWS START ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
@login_required(login_url='patientlogin')
|
||||
@user_passes_test(is_patient)
|
||||
def patient_dashboard_view(request):
|
||||
patient=models.Patient.objects.get(user_id=request.user.id)
|
||||
doctor=models.Doctor.objects.get(user_id=patient.assignedDoctorId)
|
||||
mydict={
|
||||
'patient':patient,
|
||||
'doctorName':doctor.get_name,
|
||||
'doctorMobile':doctor.mobile,
|
||||
'doctorAddress':doctor.address,
|
||||
'symptoms':patient.symptoms,
|
||||
'doctorDepartment':doctor.department,
|
||||
'admitDate':patient.admitDate,
|
||||
}
|
||||
return render(request,'hospital/patient_dashboard.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='patientlogin')
|
||||
@user_passes_test(is_patient)
|
||||
def patient_appointment_view(request):
|
||||
patient=models.Patient.objects.get(user_id=request.user.id) #for profile picture of patient in sidebar
|
||||
return render(request,'hospital/patient_appointment.html',{'patient':patient})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='patientlogin')
|
||||
@user_passes_test(is_patient)
|
||||
def patient_book_appointment_view(request):
|
||||
appointmentForm=forms.PatientAppointmentForm()
|
||||
patient=models.Patient.objects.get(user_id=request.user.id) #for profile picture of patient in sidebar
|
||||
message=None
|
||||
mydict={'appointmentForm':appointmentForm,'patient':patient,'message':message}
|
||||
if request.method=='POST':
|
||||
appointmentForm=forms.PatientAppointmentForm(request.POST)
|
||||
if appointmentForm.is_valid():
|
||||
print(request.POST.get('doctorId'))
|
||||
desc=request.POST.get('description')
|
||||
|
||||
doctor=models.Doctor.objects.get(user_id=request.POST.get('doctorId'))
|
||||
|
||||
appointment=appointmentForm.save(commit=False)
|
||||
appointment.doctorId=request.POST.get('doctorId')
|
||||
appointment.patientId=request.user.id #----user can choose any patient but only their info will be stored
|
||||
appointment.doctorName=models.User.objects.get(id=request.POST.get('doctorId')).first_name
|
||||
appointment.patientName=request.user.first_name #----user can choose any patient but only their info will be stored
|
||||
appointment.status=False
|
||||
appointment.save()
|
||||
return HttpResponseRedirect('patient-view-appointment')
|
||||
return render(request,'hospital/patient_book_appointment.html',context=mydict)
|
||||
|
||||
|
||||
|
||||
def patient_view_doctor_view(request):
|
||||
doctors=models.Doctor.objects.all().filter(status=True)
|
||||
patient=models.Patient.objects.get(user_id=request.user.id) #for profile picture of patient in sidebar
|
||||
return render(request,'hospital/patient_view_doctor.html',{'patient':patient,'doctors':doctors})
|
||||
|
||||
|
||||
|
||||
def search_doctor_view(request):
|
||||
patient=models.Patient.objects.get(user_id=request.user.id) #for profile picture of patient in sidebar
|
||||
|
||||
# whatever user write in search box we get in query
|
||||
query = request.GET['query']
|
||||
doctors=models.Doctor.objects.all().filter(status=True).filter(Q(department__icontains=query)| Q(user__first_name__icontains=query))
|
||||
return render(request,'hospital/patient_view_doctor.html',{'patient':patient,'doctors':doctors})
|
||||
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='patientlogin')
|
||||
@user_passes_test(is_patient)
|
||||
def patient_view_appointment_view(request):
|
||||
patient=models.Patient.objects.get(user_id=request.user.id) #for profile picture of patient in sidebar
|
||||
appointments=models.Appointment.objects.all().filter(patientId=request.user.id)
|
||||
return render(request,'hospital/patient_view_appointment.html',{'appointments':appointments,'patient':patient})
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='patientlogin')
|
||||
@user_passes_test(is_patient)
|
||||
def patient_discharge_view(request):
|
||||
patient=models.Patient.objects.get(user_id=request.user.id) #for profile picture of patient in sidebar
|
||||
dischargeDetails=models.PatientDischargeDetails.objects.all().filter(patientId=patient.id).order_by('-id')[:1]
|
||||
patientDict=None
|
||||
if dischargeDetails:
|
||||
patientDict ={
|
||||
'is_discharged':True,
|
||||
'patient':patient,
|
||||
'patientId':patient.id,
|
||||
'patientName':patient.get_name,
|
||||
'assignedDoctorName':dischargeDetails[0].assignedDoctorName,
|
||||
'address':patient.address,
|
||||
'mobile':patient.mobile,
|
||||
'symptoms':patient.symptoms,
|
||||
'admitDate':patient.admitDate,
|
||||
'releaseDate':dischargeDetails[0].releaseDate,
|
||||
'daySpent':dischargeDetails[0].daySpent,
|
||||
'medicineCost':dischargeDetails[0].medicineCost,
|
||||
'roomCharge':dischargeDetails[0].roomCharge,
|
||||
'doctorFee':dischargeDetails[0].doctorFee,
|
||||
'OtherCharge':dischargeDetails[0].OtherCharge,
|
||||
'total':dischargeDetails[0].total,
|
||||
}
|
||||
print(patientDict)
|
||||
else:
|
||||
patientDict={
|
||||
'is_discharged':False,
|
||||
'patient':patient,
|
||||
'patientId':request.user.id,
|
||||
}
|
||||
return render(request,'hospital/patient_discharge.html',context=patientDict)
|
||||
|
||||
|
||||
#------------------------ PATIENT RELATED VIEWS END ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#------------------------ ABOUT US AND CONTACT US VIEWS START ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
def aboutus_view(request):
|
||||
return render(request,'hospital/aboutus.html')
|
||||
|
||||
def contactus_view(request):
|
||||
sub = forms.ContactusForm()
|
||||
if request.method == 'POST':
|
||||
sub = forms.ContactusForm(request.POST)
|
||||
if sub.is_valid():
|
||||
email = sub.cleaned_data['Email']
|
||||
name=sub.cleaned_data['Name']
|
||||
message = sub.cleaned_data['Message']
|
||||
send_mail(str(name)+' || '+str(email),message,settings.EMAIL_HOST_USER, settings.EMAIL_RECEIVING_USER, fail_silently = False)
|
||||
return render(request, 'hospital/contactussuccess.html')
|
||||
return render(request, 'hospital/contactus.html', {'form':sub})
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#------------------------ ADMIN RELATED VIEWS END ------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#Developed By : sumit kumar
|
||||
#facebook : fb.com/sumit.luv
|
||||
#Youtube :youtube.com/lazycoders
|
||||
Reference in New Issue
Block a user