├── appointment ├── tests.py ├── apps.py ├── static │ ├── images │ │ ├── picture.png │ │ ├── background.png │ │ └── hospital.jpg │ ├── style.css │ └── appointment │ │ └── js │ │ └── main.js ├── __pycache__ │ ├── admin.cpython-37.pyc │ ├── apps.cpython-37.pyc │ ├── forms.cpython-37.pyc │ ├── models.cpython-37.pyc │ ├── urls.cpython-37.pyc │ ├── views.cpython-37.pyc │ └── __init__.cpython-37.pyc ├── migrations │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── 0001_initial.cpython-37.pyc │ │ ├── 0002_auto_20181013_1923.cpython-37.pyc │ │ ├── 0003_auto_20181013_2238.cpython-37.pyc │ │ ├── 0004_auto_20181013_2239.cpython-37.pyc │ │ ├── 0005_auto_20181013_2339.cpython-37.pyc │ │ ├── 0006_auto_20181014_1331.cpython-37.pyc │ │ ├── 0007_auto_20181016_1414.cpython-37.pyc │ │ ├── 0008_auto_20181025_1502.cpython-37.pyc │ │ └── 0009_auto_20181025_1821.cpython-37.pyc │ ├── 0008_auto_20181025_1502.py │ ├── 0009_auto_20181025_1821.py │ ├── 0005_auto_20181013_2339.py │ ├── 0002_auto_20181013_1923.py │ ├── 0004_auto_20181013_2239.py │ ├── 0003_auto_20181013_2238.py │ ├── 0006_auto_20181014_1331.py │ ├── 0001_initial.py │ └── 0007_auto_20181016_1414.py ├── admin.py ├── templates │ └── appointment │ │ ├── form-template.html │ │ ├── register.html │ │ ├── base_visitor.html │ │ ├── create_appointment.html │ │ ├── login.html │ │ ├── create_consultation.html │ │ ├── consultations.html │ │ ├── base.html │ │ ├── detail.html │ │ └── index.html ├── forms.py ├── models.py ├── urls.py └── views.py ├── db.sqlite3 ├── MediArchive ├── __pycache__ │ ├── urls.cpython-37.pyc │ ├── wsgi.cpython-37.pyc │ ├── __init__.cpython-37.pyc │ └── settings.cpython-37.pyc ├── wsgi.py ├── urls.py └── settings.py ├── README.md └── manage.py /appointment/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /appointment/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AppointmentConfig(AppConfig): 5 | name = 'appointment' 6 | -------------------------------------------------------------------------------- /appointment/static/images/picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/static/images/picture.png -------------------------------------------------------------------------------- /appointment/static/images/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/static/images/background.png -------------------------------------------------------------------------------- /appointment/static/images/hospital.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/static/images/hospital.jpg -------------------------------------------------------------------------------- /MediArchive/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/MediArchive/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /MediArchive/__pycache__/wsgi.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/MediArchive/__pycache__/wsgi.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/__pycache__/admin.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/__pycache__/admin.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/__pycache__/apps.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/__pycache__/apps.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/__pycache__/forms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/__pycache__/forms.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/__pycache__/urls.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/__pycache__/urls.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/__pycache__/views.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/__pycache__/views.cpython-37.pyc -------------------------------------------------------------------------------- /MediArchive/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/MediArchive/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /MediArchive/__pycache__/settings.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/MediArchive/__pycache__/settings.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0001_initial.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0001_initial.cpython-37.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-and-Django-mini-project 2 | I was teaching myself python. So I created a mini django app with python. It is a hospital app that allows a person to book a consultation and appointment. 3 | -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0002_auto_20181013_1923.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0002_auto_20181013_1923.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0003_auto_20181013_2238.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0003_auto_20181013_2238.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0004_auto_20181013_2239.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0004_auto_20181013_2239.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0005_auto_20181013_2339.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0005_auto_20181013_2339.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0006_auto_20181014_1331.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0006_auto_20181014_1331.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0007_auto_20181016_1414.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0007_auto_20181016_1414.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0008_auto_20181025_1502.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0008_auto_20181025_1502.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/migrations/__pycache__/0009_auto_20181025_1821.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kellytimire/Python-and-Django-mini-project/HEAD/appointment/migrations/__pycache__/0009_auto_20181025_1821.cpython-37.pyc -------------------------------------------------------------------------------- /appointment/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Appointment, Consultation 3 | 4 | 5 | # Register your models here. 6 | admin.site.register(Appointment) 7 | admin.site.register(Consultation) 8 | 9 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MediArchive.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /appointment/static/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: white url("images/background.png"); 3 | } 4 | 5 | ul.errorlist { 6 | padding-left: 0; 7 | } 8 | 9 | ul.errorlist > li { 10 | list-style: none; 11 | } 12 | 13 | .navbar { 14 | border-radius: 0; 15 | } 16 | 17 | .navbar-brand { 18 | font-family: 'Satisfy', cursive; 19 | } 20 | -------------------------------------------------------------------------------- /appointment/templates/appointment/form-template.html: -------------------------------------------------------------------------------- 1 | {% for field in form %} 2 |
3 |
4 | {{field.errors }} 5 |
6 | 7 |
{{ field }}
8 |
9 | {%endfor %} 10 | -------------------------------------------------------------------------------- /MediArchive/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for MediArchive project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MediArchive.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /appointment/migrations/0008_auto_20181025_1502.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-25 13:02 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('appointment', '0007_auto_20181016_1414'), 12 | ] 13 | 14 | operations = [ 15 | migrations.RenameField( 16 | model_name='consultation', 17 | old_name='doctor_name', 18 | new_name='doctor', 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /appointment/migrations/0009_auto_20181025_1821.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-25 16:21 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('appointment', '0008_auto_20181025_1502'), 12 | ] 13 | 14 | operations = [ 15 | migrations.RenameField( 16 | model_name='consultation', 17 | old_name='doctor', 18 | new_name='doctor_name', 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /appointment/migrations/0005_auto_20181013_2339.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-13 21:39 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('appointment', '0004_auto_20181013_2239'), 12 | ] 13 | 14 | operations = [ 15 | migrations.RenameField( 16 | model_name='bookappointment', 17 | old_name='is_patient', 18 | new_name='is_doctor', 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /appointment/migrations/0002_auto_20181013_1923.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-13 17:23 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('appointment', '0001_initial'), 12 | ] 13 | 14 | operations = [ 15 | migrations.RenameModel( 16 | old_name='Appointments', 17 | new_name='Appointment', 18 | ), 19 | migrations.RenameModel( 20 | old_name='BookAnAppointment', 21 | new_name='BookAppointment', 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /appointment/forms.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.models import User 2 | from django import forms 3 | 4 | from .models import Appointment, Consultation 5 | 6 | 7 | class AppointmentForm(forms.ModelForm): 8 | 9 | class Meta: 10 | model = Appointment 11 | fields = ['date', 'patient_name', 'doctor', 'time', 'file_number', 'is_doctor'] 12 | 13 | 14 | class ConsultationForm(forms.ModelForm): 15 | 16 | class Meta: 17 | model = Consultation 18 | fields = ['consultation_number', 'doctor_name','patient_name', 'file_number', 'is_doctor'] 19 | 20 | class UserForm(forms.ModelForm): 21 | password = forms.CharField(widget=forms.PasswordInput) 22 | 23 | class Meta: 24 | model = User 25 | fields = ['username', 'email', 'password'] 26 | -------------------------------------------------------------------------------- /appointment/migrations/0004_auto_20181013_2239.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-13 20:39 3 | from __future__ import unicode_literals 4 | 5 | import datetime 6 | from django.db import migrations, models 7 | from django.utils.timezone import utc 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | dependencies = [ 13 | ('appointment', '0003_auto_20181013_2238'), 14 | ] 15 | 16 | operations = [ 17 | migrations.RemoveField( 18 | model_name='appointment', 19 | name='doctor_logo', 20 | ), 21 | migrations.AddField( 22 | model_name='bookappointment', 23 | name='doctor_logo', 24 | field=models.CharField(default=datetime.datetime(2018, 10, 13, 20, 39, 58, 170019, tzinfo=utc), max_length=1000), 25 | preserve_default=False, 26 | ), 27 | ] 28 | -------------------------------------------------------------------------------- /appointment/migrations/0003_auto_20181013_2238.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-13 20:38 3 | from __future__ import unicode_literals 4 | 5 | import datetime 6 | from django.db import migrations, models 7 | from django.utils.timezone import utc 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | dependencies = [ 13 | ('appointment', '0002_auto_20181013_1923'), 14 | ] 15 | 16 | operations = [ 17 | migrations.AddField( 18 | model_name='appointment', 19 | name='doctor_logo', 20 | field=models.CharField(default=datetime.datetime(2018, 10, 13, 20, 38, 36, 349543, tzinfo=utc), max_length=1000), 21 | preserve_default=False, 22 | ), 23 | migrations.AddField( 24 | model_name='bookappointment', 25 | name='is_patient', 26 | field=models.BooleanField(default=False), 27 | ), 28 | ] 29 | -------------------------------------------------------------------------------- /appointment/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import Permission, User 3 | 4 | # Create your models here. 5 | class Appointment(models.Model): 6 | user = models.ForeignKey(User, default=1) 7 | date = models.CharField(max_length=20) 8 | patient_name = models.CharField(max_length=250) 9 | doctor = models.CharField(max_length=250) 10 | time = models.CharField(max_length=250) 11 | file_number = models.CharField(max_length=20) 12 | is_doctor = models.BooleanField(default=False) 13 | 14 | def __str__(self): 15 | return self.doctor + '-' + self.patient_name 16 | 17 | class Consultation(models.Model): 18 | appointment = models.ForeignKey(Appointment, on_delete=models.CASCADE) 19 | consultation_number = models.CharField(max_length=250) 20 | doctor_name = models.CharField(max_length=250) 21 | patient_name = models.CharField(max_length=250) 22 | file_number = models.CharField(max_length=20) 23 | is_doctor = models.BooleanField(default=False) 24 | 25 | def __str__(self): 26 | return self.doctor_name + '-' + self.patient_name 27 | 28 | -------------------------------------------------------------------------------- /appointment/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from . import views 3 | 4 | app_name = 'appointment' 5 | 6 | 7 | urlpatterns = [ 8 | url(r'^$', views.index, name='index'), 9 | url(r'^register/$', views.register, name='register'), 10 | url(r'^login_user/$', views.login_user, name='login_user'), 11 | url(r'^logout_user/$', views.logout_user, name='logout_user'), 12 | url(r'^(?P[0-9]+)/$', views.detail, name='detail'), 13 | url(r'^(?P[0-9]+)/isdoctor/$', views.isdoctor, name='isdoctor'), 14 | url(r'^consultations/(?P[a-zA_Z]+)/$', views.consultations, name='consultations'), 15 | url(r'^create_appointment/$', views.create_appointment, name='create_appointment'), 16 | url(r'^(?P[0-9]+)/create_consultation/$', views.create_consultation, name='create_consultation'), 17 | url(r'^(?P[0-9]+)/delete_consultation/(?P[0-9]+)/$', views.delete_consultation, name='delete_consultation'), 18 | url(r'^(?P[0-9]+)/favorite_appointment/$', views.favorite_appointment, name='favorite_appointment'), 19 | url(r'^(?P[0-9]+)/delete_appointment/$', views.delete_appointment, name='delete_appointment'), 20 | ] 21 | -------------------------------------------------------------------------------- /MediArchive/urls.py: -------------------------------------------------------------------------------- 1 | """MediArchive URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.9/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Add an import: from blog import urls as blog_urls 14 | 2. Import the include() function: from django.conf.urls import url, include 15 | 3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) 16 | """ 17 | from django.conf.urls import include, url 18 | from django.contrib import admin 19 | 20 | urlpatterns = [ 21 | url(r'^admin/', admin.site.urls), 22 | url(r'^appointment/', include('appointment.urls')), 23 | url(r'^', include('appointment.urls')), 24 | url(r'^lab/', include('lab.urls')), 25 | url(r'^', include('lab.urls')), 26 | url(r'^surgery/', include('surgery.urls')), 27 | url(r'^', include('surgery.urls')), 28 | url(r'^doctor/', include('doctor.urls')), 29 | url(r'^', include('doctor.urls')), 30 | 31 | ] 32 | -------------------------------------------------------------------------------- /appointment/static/appointment/js/main.js: -------------------------------------------------------------------------------- 1 | 2 | var AlbumsListPage = { 3 | init: function() { 4 | this.$container = $('.albums-container'); 5 | this.render(); 6 | this.bindEvents(); 7 | }, 8 | 9 | render: function() { 10 | 11 | }, 12 | 13 | bindEvents: function() { 14 | $('.btn-favorite', this.$container).on('click', function(e) { 15 | e.preventDefault(); 16 | 17 | var self = $(this); 18 | var url = $(this).attr('href'); 19 | $.getJSON(url, function(result) { 20 | if (result.success) { 21 | $('.glyphicon-star', self).toggleClass('active'); 22 | } 23 | }); 24 | 25 | return false; 26 | }); 27 | } 28 | }; 29 | 30 | var SongsListPage = { 31 | init: function() { 32 | this.$container = $('.songs-container'); 33 | this.render(); 34 | this.bindEvents(); 35 | }, 36 | 37 | render: function() { 38 | 39 | }, 40 | 41 | bindEvents: function() { 42 | $('.btn-favorite', this.$container).on('click', function(e) { 43 | e.preventDefault(); 44 | 45 | var self = $(this); 46 | var url = $(this).attr('href'); 47 | $.getJSON(url, function(result) { 48 | if (result.success) { 49 | $('.glyphicon-star', self).toggleClass('active'); 50 | } 51 | }); 52 | 53 | return false; 54 | }); 55 | } 56 | }; 57 | 58 | $(document).ready(function() { 59 | AlbumsListPage.init(); 60 | SongsListPage.init(); 61 | }); -------------------------------------------------------------------------------- /appointment/migrations/0006_auto_20181014_1331.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-14 11:31 3 | from __future__ import unicode_literals 4 | 5 | import datetime 6 | from django.db import migrations, models 7 | from django.utils.timezone import utc 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | dependencies = [ 13 | ('appointment', '0005_auto_20181013_2339'), 14 | ] 15 | 16 | operations = [ 17 | migrations.RemoveField( 18 | model_name='bookappointment', 19 | name='appointments', 20 | ), 21 | migrations.AddField( 22 | model_name='appointment', 23 | name='file_number', 24 | field=models.CharField(default=datetime.datetime(2018, 10, 14, 11, 31, 1, 184566, tzinfo=utc), max_length=20), 25 | preserve_default=False, 26 | ), 27 | migrations.AddField( 28 | model_name='appointment', 29 | name='is_doctor', 30 | field=models.BooleanField(default=False), 31 | ), 32 | migrations.AddField( 33 | model_name='appointment', 34 | name='time', 35 | field=models.CharField(default=datetime.datetime(2018, 10, 14, 11, 31, 12, 56458, tzinfo=utc), max_length=250), 36 | preserve_default=False, 37 | ), 38 | migrations.DeleteModel( 39 | name='BookAppointment', 40 | ), 41 | ] 42 | -------------------------------------------------------------------------------- /appointment/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-13 15:49 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | initial = True 12 | 13 | dependencies = [ 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Appointments', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('date', models.CharField(max_length=20)), 22 | ('patient_name', models.CharField(max_length=250)), 23 | ('doctor', models.CharField(max_length=250)), 24 | ], 25 | ), 26 | migrations.CreateModel( 27 | name='BookAnAppointment', 28 | fields=[ 29 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 30 | ('patient_name', models.CharField(max_length=250)), 31 | ('doctor', models.CharField(max_length=250)), 32 | ('time', models.CharField(max_length=250)), 33 | ('file_number', models.CharField(max_length=20)), 34 | ('appointments', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='appointment.Appointments')), 35 | ], 36 | ), 37 | ] 38 | -------------------------------------------------------------------------------- /appointment/templates/appointment/register.html: -------------------------------------------------------------------------------- 1 | {% extends 'appointment/base_visitor.html' %} 2 | {% block title %}Register{% endblock %} 3 | {% block register_active %}active{% endblock %} 4 | 5 | {% block body %} 6 |
7 | 8 |
9 |
10 |
11 |
12 |

Register for an Account

13 | {% if error_message %} 14 |

{{ error_message }}

15 | {% endif %} 16 |
17 | {% csrf_token %} 18 | {% include 'appointment/form-template.html' %} 19 |
20 |
21 | 22 |
23 |
24 |
25 |
26 | 29 |
30 |
31 |
32 | 33 |
34 | {% endblock %} 35 | -------------------------------------------------------------------------------- /appointment/migrations/0007_auto_20181016_1414.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.9 on 2018-10-16 12:14 3 | from __future__ import unicode_literals 4 | 5 | from django.conf import settings 6 | from django.db import migrations, models 7 | import django.db.models.deletion 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | dependencies = [ 13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 14 | ('appointment', '0006_auto_20181014_1331'), 15 | ] 16 | 17 | operations = [ 18 | migrations.CreateModel( 19 | name='Consultation', 20 | fields=[ 21 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 22 | ('consultation_number', models.CharField(max_length=250)), 23 | ('doctor_name', models.CharField(max_length=250)), 24 | ('patient_name', models.CharField(max_length=250)), 25 | ('file_number', models.CharField(max_length=20)), 26 | ('is_doctor', models.BooleanField(default=False)), 27 | ], 28 | ), 29 | migrations.AddField( 30 | model_name='appointment', 31 | name='user', 32 | field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), 33 | ), 34 | migrations.AddField( 35 | model_name='consultation', 36 | name='appointment', 37 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='appointment.Appointment'), 38 | ), 39 | ] 40 | -------------------------------------------------------------------------------- /appointment/templates/appointment/base_visitor.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {% block title %}MediArchive{% endblock %} 6 | {% load staticfiles %} 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 39 | {% block body %} 40 | {% endblock %} 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /appointment/templates/appointment/create_appointment.html: -------------------------------------------------------------------------------- 1 | {% extends 'appointment/base.html' %} 2 | {% block title %}Add a New Appointment{% endblock %} 3 | {% block appointments_active %}active{% endblock %} 4 | 5 | {% block body %} 6 |
7 | 8 |
9 | 10 |
11 |
12 |
13 |

Add a New Appointments

14 | {% if error_message %} 15 |

{{ error_message }}

16 | {% endif %} 17 |
18 | {% csrf_token %} 19 | {% include 'appointment/form-template.html' %} 20 |
21 |
22 | 23 |
24 |
25 |
26 |
27 |
28 |
29 | 30 |
31 |
32 |
33 |

What is Medi-Archive?

34 |

Medi-Archive is an app that allows you receptionist to book an appointment for old and new patients.

35 |

How do I add an appointment?

36 |

First, create a new appointment by filling out the form on this page. Once an appointment is created you will be able to add a doctor's consultation.

37 |
38 |
39 |
40 | 41 |
42 | 43 |
44 | {% endblock %} 45 | 46 | -------------------------------------------------------------------------------- /appointment/templates/appointment/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'appointment/base_visitor.html' %} 2 | {% block title %}Log In{% endblock %} 3 | {% block login_active %}active{% endblock %} 4 | 5 | {% block body %} 6 |
7 | 8 |
9 |
10 |
11 |
12 |

Log In

13 | {% if error_message %} 14 |

{{ error_message }}

15 | {% endif %} 16 |
17 | {% csrf_token %} 18 |
19 | 22 |
23 | 24 |
25 |
26 |
27 | 30 |
31 | 32 |
33 |
34 |
35 |
36 | 37 |
38 |
39 |
40 |
41 | 44 |
45 |
46 |
47 | 48 |
49 | 50 | {% endblock %} 51 | -------------------------------------------------------------------------------- /appointment/templates/appointment/create_consultation.html: -------------------------------------------------------------------------------- 1 | {% extends 'appointment/base.html' %} 2 | {% block title %}Add a New Consultation{% endblock %} 3 | {% block appointments_active %}active{% endblock %} 4 | 5 | {% block body %} 6 |
7 | 8 |
9 | 10 | 11 |
12 |
13 |
14 | 15 | 16 | 17 |

{{ appointment.doctor }} {{ appointment.is_doctor }}

18 |

{{ appointment.patient_name }}

19 |
20 |
21 |
22 | 23 | 24 |
25 | 26 | 30 | 31 |
32 |
33 |

Add a New Consultation

34 | {% if error_message %} 35 |

{{ error_message }}

36 | {% endif %} 37 |
38 | {% csrf_token %} 39 | 40 | {% include 'appointment/form_template.html' %} 41 |
42 |
43 | 44 |
45 |
46 |
47 |
48 |
49 | 50 |
51 | 52 |
53 | 54 |
55 | 56 | {% endblock %} 57 | 58 | 59 | -------------------------------------------------------------------------------- /appointment/templates/appointment/consultations.html: -------------------------------------------------------------------------------- 1 | {% extends 'appointment/base.html' %} 2 | {% block title %}{{ Consultations }}{% endblock %} 3 | {% block consultations_active %}active{% endblock %} 4 | 5 | {% block body %} 6 |
7 | 8 |
9 |
10 | 14 |
15 |
16 | 17 |
18 | 19 |
20 | 21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | {% for consultation in consultation_list %} 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | {% endfor %} 46 | 47 |
Consultation_numberDoctorPatient_nameFile NumberRegular Doctor?
{{ consultation.consultation_number }}{{ consultation.doctor }}{{ consultation.patient_name }}{{ consultation.is_doctor }}{{ consultation.appointment.doctor }}
48 |
49 |
50 | 51 |
52 | 53 |
54 | 55 |
56 | {% endblock %} 57 | -------------------------------------------------------------------------------- /appointment/templates/appointment/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {% block title %}Medi-Archive{% endblock %} 5 | {% load staticfiles %} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 57 | {% block body %} 58 | {% endblock %} 59 | 60 | 61 | -------------------------------------------------------------------------------- /MediArchive/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for MediArchive project. 3 | 4 | Generated by 'django-admin startproject' using Django 1.9. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.9/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '_swfd4%+dh9u8r1z&&f5*)(6pl_dcj)zt4)#!zpsyk0gr1oi+!' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'surgery.apps.SurgeryConfig', 35 | 'doctor.apps.DoctorConfig', 36 | 'lab.apps.LabConfig', 37 | 'appointment.apps.AppointmentConfig', 38 | 'django.contrib.admin', 39 | 'django.contrib.auth', 40 | 'django.contrib.contenttypes', 41 | 'django.contrib.sessions', 42 | 'django.contrib.messages', 43 | 'django.contrib.staticfiles', 44 | ] 45 | 46 | MIDDLEWARE_CLASSES = [ 47 | 'django.middleware.security.SecurityMiddleware', 48 | 'django.contrib.sessions.middleware.SessionMiddleware', 49 | 'django.middleware.common.CommonMiddleware', 50 | 'django.middleware.csrf.CsrfViewMiddleware', 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 52 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 53 | 'django.contrib.messages.middleware.MessageMiddleware', 54 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 55 | ] 56 | 57 | ROOT_URLCONF = 'MediArchive.urls' 58 | 59 | TEMPLATES = [ 60 | { 61 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 62 | 'DIRS': [], 63 | 'APP_DIRS': True, 64 | 'OPTIONS': { 65 | 'context_processors': [ 66 | 'django.template.context_processors.debug', 67 | 'django.template.context_processors.request', 68 | 'django.contrib.auth.context_processors.auth', 69 | 'django.contrib.messages.context_processors.messages', 70 | ], 71 | }, 72 | }, 73 | ] 74 | 75 | WSGI_APPLICATION = 'MediArchive.wsgi.application' 76 | 77 | 78 | # Database 79 | # https://docs.djangoproject.com/en/1.9/ref/settings/#databases 80 | 81 | DATABASES = { 82 | 'default': { 83 | 'ENGINE': 'django.db.backends.sqlite3', 84 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 85 | } 86 | } 87 | 88 | 89 | # Password validation 90 | # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators 91 | 92 | AUTH_PASSWORD_VALIDATORS = [ 93 | { 94 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 95 | }, 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 101 | }, 102 | { 103 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 104 | }, 105 | ] 106 | 107 | 108 | # Internationalization 109 | # https://docs.djangoproject.com/en/1.9/topics/i18n/ 110 | 111 | LANGUAGE_CODE = 'en-us' 112 | 113 | TIME_ZONE = 'UTC' 114 | 115 | USE_I18N = True 116 | 117 | USE_L10N = True 118 | 119 | USE_TZ = True 120 | 121 | 122 | # Static files (CSS, JavaScript, Images) 123 | # https://docs.djangoproject.com/en/1.9/howto/static-files/ 124 | 125 | STATIC_URL = '/static/' 126 | -------------------------------------------------------------------------------- /appointment/templates/appointment/detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'appointment/base.html' %} 2 | {% block title %}{{ Appointment }}{% endblock %} 3 | {% block appointments_active %}active{% endblock %} 4 | 5 | {% block body %} 6 |
7 | 8 |
9 | 10 | 11 |
12 |
13 |
14 | 15 | 16 | 17 |

{{ appointment.doctor }} {{ appointment.is_doctor }}

18 |

{{ appointment.patient_name }}

19 |
20 |
21 |
22 | 23 | 24 |
25 | 26 | 30 | 31 |
32 |
33 | 34 |

All Consultations

35 | 36 | {% if error_message %} 37 |

{{ error_message }}

38 | {% endif %} 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | {% for consultation in appointment.consultation_set.all %} 50 | 51 | 52 | 53 | 54 | 57 | 66 | 67 | {% endfor %} 68 | 69 |
TimeDateFile Number
{{ appointment.time }}{{ appointment.date }}{{ appointment.file_number }} 55 | 56 | 58 |
59 | {% csrf_token %} 60 | 61 | 64 |
65 |
70 | 71 |
72 |
73 | 74 |
75 | 76 |
77 | 78 |
79 | 80 | {% endblock %} 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /appointment/templates/appointment/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'appointment/base.html' %} 2 | {% block title %}All Appointments{% endblock %} 3 | {% block appointments_active %} active {% endblock %} 4 | 5 | {% block body %} 6 |
7 | 8 | 9 |
10 |
11 |

Welcome {{ user.username }}. Here are the appointments for today.

12 |
13 | 14 | {% if appointments %} 15 | {% for appointments in appointment %} 16 |
17 |
18 | 19 | 20 | 21 |
22 |

{{ appointment.doctor }}

23 | 24 | 25 | View Details 26 | 27 | 28 |
29 | 30 | {% csrf_token %} 31 | 32 | 35 |
36 |
37 |
38 |
39 | {% cycle '' '' '' '' '' '
' %} 40 | {% endfor %} 41 | {% else %} 42 | 50 | {% endif %} 51 |
52 | 53 | 54 | {% if consultations %} 55 |
56 |
57 |

Consultation

58 |
59 |
60 |
61 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | {% for consultation in consultations %} 74 | 75 | 76 | 77 | 78 | 79 | 82 | 83 | {% endfor %} 84 | 85 |
Consultation NumberDoctorPatient NameFile numberRegular doctor
{{ consultation.consultation_number }}{{ consultation.appointment.doctor }}{{ consultation.patient_name }}{{ consultation.file_number }} 80 | 81 |
86 |
87 |
88 |
89 |
90 | {% endif %} 91 |
92 | {% endblock %} 93 | 94 | 95 | -------------------------------------------------------------------------------- /appointment/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import authenticate, login 2 | from django.contrib.auth import logout 3 | from django.http import JsonResponse 4 | from django.shortcuts import render, get_object_or_404 5 | from django.db.models import Q 6 | from .forms import AppointmentForm, ConsultationForm, UserForm 7 | from .models import Appointment, Consultation 8 | 9 | 10 | def create_appointment(request): 11 | if not request.user.is_authenticated(): 12 | return render(request, 'appointment/login.html') 13 | else: 14 | form = AppointmentForm(request.POST or None, request.FILES or None) 15 | if form.is_valid(): 16 | appointment = form.save(commit=False) 17 | appointment.user = request.user 18 | appointment.doctor = request.user 19 | if file_type not in IMAGE_FILE_TYPES: 20 | context = { 21 | 'appointment': appointment, 22 | 'form': form, 23 | } 24 | return render(request, 'appointment/create_appointment.html', context) 25 | appointment.save() 26 | return render(request, 'appointment/detail.html', {'appointment': appointment}) 27 | context = { 28 | "form": form, 29 | } 30 | return render(request, 'appointment/create_appointment.html', context) 31 | 32 | 33 | def create_consultation(request, appointment_id): 34 | form = ConsultationForm(request.POST or None, request.FILES or None) 35 | appointment = get_object_or_404(Appointment, pk=appointment_id) 36 | if form.is_valid(): 37 | appointments_consultations = appointment.consultation_set.all() 38 | for c in appointments_consultations: 39 | if c.doctor == form.cleaned_data.get("doctor"): 40 | context = { 41 | 'appointment': appointment, 42 | 'form': form, 43 | 'error_message': 'You already added that appointment', 44 | } 45 | return render(request, 'appointment/create_consultation.html', context) 46 | consultation = form.save(commit=False) 47 | consultation.appointment = appointment 48 | consultation.save() 49 | return render(request, 'appointment/detail.html', {'appointment': appointment}) 50 | context = { 51 | 'appointment': appointment, 52 | 'form': form, 53 | } 54 | return render(request, 'appointment/create_consultation.html', context) 55 | 56 | 57 | def delete_appointment(request, appointment_id): 58 | appointment = Appointment.objects.get(pk=appointment_id) 59 | appointment.delete() 60 | appointment = Appointment.objects.filter(user=request.user) 61 | return render(request, 'appointment/index.html', {'appointment': appointment}) 62 | 63 | 64 | def delete_consultation(request, appointment_id, consultation_id): 65 | appointment = get_object_or_404(Appointment, pk=appointment_id) 66 | consultation = Consultation.objects.get(pk=consultation_id) 67 | consultation.delete() 68 | return render(request, 'appointment/detail.html', {'appointment': appointment}) 69 | 70 | 71 | def detail(request, appointment_id): 72 | if not request.user.is_authenticated(): 73 | return render(request, 'appointment/login.html') 74 | else: 75 | user = request.user 76 | appointment = get_object_or_404(Appointment, pk=appointment_id) 77 | return render(request, 'appointment/detail.html', {'appointment': appointment, 'user': user}) 78 | 79 | 80 | def isdoctor(request, consultation_id): 81 | consultation = get_object_or_404(Consultation, pk=consultation_id) 82 | try: 83 | if consultation.is_doctor: 84 | consultation.is_doctor = False 85 | else: 86 | consultation.is_doctor = True 87 | consultation.save() 88 | except (KeyError, Consultation.DoesNotExist): 89 | return JsonResponse({'success': False}) 90 | else: 91 | return JsonResponse({'success': True}) 92 | 93 | 94 | def favorite_appointment(request, appointment_id): 95 | appointment = get_object_or_404(Appointment, pk=appointment_id) 96 | try: 97 | if appointment.is_doctor: 98 | appointment.is_doctor = False 99 | else: 100 | appointment.is_doctor = True 101 | appointment.save() 102 | except (KeyError, Appointment.DoesNotExist): 103 | return JsonResponse({'success': False}) 104 | else: 105 | return JsonResponse({'success': True}) 106 | 107 | 108 | def index(request): 109 | if not request.user.is_authenticated(): 110 | return render(request, 'appointment/login.html') 111 | else: 112 | appointments = Appointment.objects.filter(user=request.user) 113 | consultation_results = Consultation.objects.all() 114 | query = request.GET.get("q") 115 | if query: 116 | appointments = appointments.filter( 117 | Q(doctor__icontains=query) | 118 | Q(patient_name__icontains=query) 119 | ).distinct() 120 | consultation_results = consultation_results.filter( 121 | Q(doctor__icontains=query) 122 | ).distinct() 123 | return render(request, 'appointment/index.html', { 124 | 'appointments': appointments, 125 | 'consultations': consultation_results, 126 | }) 127 | else: 128 | return render(request, 'appointment/index.html', {'appointments': appointments}) 129 | 130 | 131 | def logout_user(request): 132 | logout(request) 133 | form = UserForm(request.POST or None) 134 | context = { 135 | "form": form, 136 | } 137 | return render(request, 'appointment/login.html', context) 138 | 139 | 140 | def login_user(request): 141 | if request.method == "POST": 142 | username = request.POST['username'] 143 | password = request.POST['password'] 144 | user = authenticate(username=username, password=password) 145 | if user is not None: 146 | if user.is_active: 147 | login(request, user) 148 | appointments = Appointment.objects.filter(user=request.user) 149 | return render(request, 'appointment/index.html', {'appointments': appointments}) 150 | else: 151 | return render(request, 'appointment/login.html', {'error_message': 'Your account has been disabled'}) 152 | else: 153 | return render(request, 'appointment/login.html', {'error_message': 'Invalid login'}) 154 | return render(request, 'appointment/login.html') 155 | 156 | 157 | def register(request): 158 | form = UserForm(request.POST or None) 159 | if form.is_valid(): 160 | user = form.save(commit=False) 161 | username = form.cleaned_data['username'] 162 | password = form.cleaned_data['password'] 163 | user.set_password(password) 164 | user.save() 165 | user = authenticate(username=username, password=password) 166 | if user is not None: 167 | if user.is_active: 168 | login(request, user) 169 | appointments = Appointment.objects.filter(user=request.user) 170 | return render(request, 'appointment/index.html', {'appointments': appointments}) 171 | context = { 172 | "form": form, 173 | } 174 | return render(request, 'appointment/register.html', context) 175 | 176 | 177 | def consultations(request, filter_by): 178 | if not request.user.is_authenticated(): 179 | return render(request, 'appointment/login.html') 180 | else: 181 | try: 182 | consultation_ids = [] 183 | for appointment in Appointment.objects.filter(user=request.user): 184 | for consultation in appointment.consultation_set.all(): 185 | consultation_ids.append(consultation.pk) 186 | users_consultations = Consultation.objects.filter(pk__in=consultation_ids) 187 | if filter_by == 'doctor': 188 | users_consultations = users_consultations.filter(is_favorite=True) 189 | except Appointment.DoesNotExist: 190 | users_consultations = [] 191 | return render(request, 'appointment/consultations.html', { 192 | 'consultation_list': users_consultations, 193 | 'filter_by': filter_by, 194 | }) 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | --------------------------------------------------------------------------------