Spaces:
Running
Running
sachin
commited on
Commit
·
9702c04
1
Parent(s):
eef3ad4
Add User/Doctor Data
Browse files- doctorapp/__init__.py +0 -0
- doctorapp/admin.py +4 -0
- doctorapp/apps.py +6 -0
- doctorapp/migrations/0001_initial.py +25 -0
- doctorapp/migrations/0002_auto_20241119_2054.py +19 -0
- doctorapp/migrations/__init__.py +0 -0
- doctorapp/models.py +9 -0
- doctorapp/serializers.py +7 -0
- doctorapp/tests.py +3 -0
- doctorapp/urls.py +11 -0
- doctorapp/views.py +25 -0
- sanjeevini/settings.py +17 -1
- sanjeevini/urls.py +2 -0
- userapp/admin.py +2 -1
- userapp/migrations/0001_initial.py +25 -0
- userapp/migrations/0002_auto_20241119_0922.py +19 -0
- userapp/models.py +7 -1
- userapp/serializers.py +7 -0
- userapp/urls.py +11 -0
- userapp/views.py +23 -1
doctorapp/__init__.py
ADDED
File without changes
|
doctorapp/admin.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from django.contrib import admin
|
2 |
+
from .models import DoctorApp
|
3 |
+
|
4 |
+
admin.site.register(DoctorApp)
|
doctorapp/apps.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from django.apps import AppConfig
|
2 |
+
|
3 |
+
|
4 |
+
class DoctorappConfig(AppConfig):
|
5 |
+
default_auto_field = 'django.db.models.BigAutoField'
|
6 |
+
name = 'doctorapp'
|
doctorapp/migrations/0001_initial.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 5.1.1 on 2024-11-19 20:53
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
|
8 |
+
initial = True
|
9 |
+
|
10 |
+
dependencies = [
|
11 |
+
]
|
12 |
+
|
13 |
+
operations = [
|
14 |
+
migrations.CreateModel(
|
15 |
+
name='DoctorApp',
|
16 |
+
fields=[
|
17 |
+
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
18 |
+
('appointment_day', models.DateField()),
|
19 |
+
('appointment_time', models.TimeField()),
|
20 |
+
('patient_name', models.CharField(max_length=255)),
|
21 |
+
('status', models.CharField(max_length=255)),
|
22 |
+
('observations', models.TextField()),
|
23 |
+
],
|
24 |
+
),
|
25 |
+
]
|
doctorapp/migrations/0002_auto_20241119_2054.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 5.1.1 on 2024-11-19 09:22
|
2 |
+
|
3 |
+
from django.db import migrations
|
4 |
+
|
5 |
+
def add_default_entries(apps, schema_editor):
|
6 |
+
DoctorApp = apps.get_model('doctorapp', 'DoctorApp')
|
7 |
+
DoctorApp.objects.create(appointment_day='2024-11-19', appointment_time='10:00:00', patient_name='User 001', status='Pending', observations='Follow-up appointment')
|
8 |
+
DoctorApp.objects.create(appointment_day='2024-11-21', appointment_time='14:30:00', patient_name='User 002', status='Confirmed', observations='Routine check-up')
|
9 |
+
DoctorApp.objects.create(appointment_day='2024-12-04', appointment_time='09:00:00', patient_name='User 003', status='Cancelled', observations='Patient unavailable')
|
10 |
+
|
11 |
+
class Migration(migrations.Migration):
|
12 |
+
|
13 |
+
dependencies = [
|
14 |
+
('doctorapp', '0001_initial'),
|
15 |
+
]
|
16 |
+
|
17 |
+
operations = [
|
18 |
+
migrations.RunPython(add_default_entries),
|
19 |
+
]
|
doctorapp/migrations/__init__.py
ADDED
File without changes
|
doctorapp/models.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from django.db import models
|
2 |
+
|
3 |
+
class DoctorApp(models.Model):
|
4 |
+
id = models.BigAutoField(primary_key=True)
|
5 |
+
appointment_day = models.DateField()
|
6 |
+
appointment_time = models.TimeField()
|
7 |
+
patient_name = models.CharField(max_length=255)
|
8 |
+
status = models.CharField(max_length=255)
|
9 |
+
observations = models.TextField()
|
doctorapp/serializers.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from rest_framework import serializers
|
2 |
+
from .models import DoctorApp
|
3 |
+
|
4 |
+
class DoctorAppSerializer(serializers.ModelSerializer):
|
5 |
+
class Meta:
|
6 |
+
model = DoctorApp
|
7 |
+
fields = '__all__'
|
doctorapp/tests.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from django.test import TestCase
|
2 |
+
|
3 |
+
# Create your tests here.
|
doctorapp/urls.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from django.urls import path, include
|
2 |
+
from rest_framework.routers import DefaultRouter
|
3 |
+
from .views import DoctorAppViewSet
|
4 |
+
|
5 |
+
router = DefaultRouter()
|
6 |
+
router.register(r'', DoctorAppViewSet)
|
7 |
+
|
8 |
+
urlpatterns = [
|
9 |
+
# ... other URL patterns
|
10 |
+
path('', include(router.urls)),
|
11 |
+
]
|
doctorapp/views.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from django.shortcuts import render
|
2 |
+
from django.core.files.storage import FileSystemStorage
|
3 |
+
import django_filters
|
4 |
+
from rest_framework import viewsets
|
5 |
+
from rest_framework.decorators import action
|
6 |
+
from rest_framework.response import Response
|
7 |
+
from rest_framework.pagination import LimitOffsetPagination
|
8 |
+
from django.utils import timezone
|
9 |
+
from datetime import datetime, timedelta
|
10 |
+
import requests
|
11 |
+
|
12 |
+
from .models import DoctorApp
|
13 |
+
from .serializers import DoctorAppSerializer
|
14 |
+
|
15 |
+
from rest_framework.pagination import PageNumberPagination
|
16 |
+
|
17 |
+
class DoctorAppPagination(PageNumberPagination):
|
18 |
+
page_size = 10
|
19 |
+
page_size_query_param = 'page_size'
|
20 |
+
max_page_size = 100
|
21 |
+
|
22 |
+
class DoctorAppViewSet(viewsets.ModelViewSet):
|
23 |
+
queryset = DoctorApp.objects.all().order_by('id')
|
24 |
+
serializer_class = DoctorAppSerializer
|
25 |
+
pagination_class = DoctorAppPagination
|
sanjeevini/settings.py
CHANGED
@@ -42,7 +42,9 @@ INSTALLED_APPS = [
|
|
42 |
'csp',
|
43 |
'rest_framework',
|
44 |
'rest_framework.authtoken',
|
45 |
-
'userapp'
|
|
|
|
|
46 |
]
|
47 |
|
48 |
MIDDLEWARE = [
|
@@ -147,3 +149,17 @@ STATIC_URL = 'static/'
|
|
147 |
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
148 |
|
149 |
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
'csp',
|
43 |
'rest_framework',
|
44 |
'rest_framework.authtoken',
|
45 |
+
'userapp',
|
46 |
+
'doctorapp',
|
47 |
+
|
48 |
]
|
49 |
|
50 |
MIDDLEWARE = [
|
|
|
149 |
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
|
150 |
|
151 |
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
152 |
+
|
153 |
+
|
154 |
+
REST_FRAMEWORK = {
|
155 |
+
'DEFAULT_RENDERER_CLASSES': [
|
156 |
+
'rest_framework.renderers.JSONRenderer',
|
157 |
+
],
|
158 |
+
'DEFAULT_AUTHENTICATION_CLASSES': (
|
159 |
+
'rest_framework.authentication.TokenAuthentication',
|
160 |
+
),
|
161 |
+
'DEFAULT_PERMISSION_CLASSES': [
|
162 |
+
# TODO - remove comment after authentication in frontend is enforced
|
163 |
+
# 'rest_framework.permissions.IsAuthenticated',
|
164 |
+
]
|
165 |
+
}
|
sanjeevini/urls.py
CHANGED
@@ -23,4 +23,6 @@ urlpatterns = [
|
|
23 |
path('admin/', admin.site.urls),
|
24 |
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
25 |
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
|
|
|
|
26 |
]
|
|
|
23 |
path('admin/', admin.site.urls),
|
24 |
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
25 |
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
26 |
+
path('api/v1/userapp/', include('userapp.urls')),
|
27 |
+
path('api/v1/doctorapp/', include('doctorapp.urls')),
|
28 |
]
|
userapp/admin.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
from django.contrib import admin
|
|
|
2 |
|
3 |
-
|
|
|
1 |
from django.contrib import admin
|
2 |
+
from .models import UserApp
|
3 |
|
4 |
+
admin.site.register(UserApp)
|
userapp/migrations/0001_initial.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 5.1.1 on 2024-11-19 09:21
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
|
8 |
+
initial = True
|
9 |
+
|
10 |
+
dependencies = [
|
11 |
+
]
|
12 |
+
|
13 |
+
operations = [
|
14 |
+
migrations.CreateModel(
|
15 |
+
name='UserApp',
|
16 |
+
fields=[
|
17 |
+
('id', models.BigAutoField(primary_key=True, serialize=False)),
|
18 |
+
('appointment_day', models.DateField()),
|
19 |
+
('appointment_time', models.TimeField()),
|
20 |
+
('doctor_name', models.CharField(max_length=255)),
|
21 |
+
('status', models.CharField(max_length=255)),
|
22 |
+
('observations', models.TextField()),
|
23 |
+
],
|
24 |
+
),
|
25 |
+
]
|
userapp/migrations/0002_auto_20241119_0922.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 5.1.1 on 2024-11-19 09:22
|
2 |
+
|
3 |
+
from django.db import migrations
|
4 |
+
|
5 |
+
def add_default_entries(apps, schema_editor):
|
6 |
+
UserApp = apps.get_model('userapp', 'UserApp')
|
7 |
+
UserApp.objects.create(appointment_day='2024-11-19', appointment_time='10:00:00', doctor_name='Dr. Kini', status='Pending', observations='Follow-up appointment')
|
8 |
+
UserApp.objects.create(appointment_day='2024-11-21', appointment_time='14:30:00', doctor_name='Dr. Chandan Kamath', status='Confirmed', observations='Routine check-up')
|
9 |
+
UserApp.objects.create(appointment_day='2024-12-04', appointment_time='09:00:00', doctor_name='Dr. Prashan Kumar', status='Cancelled', observations='Patient unavailable')
|
10 |
+
|
11 |
+
class Migration(migrations.Migration):
|
12 |
+
|
13 |
+
dependencies = [
|
14 |
+
('userapp', '0001_initial'),
|
15 |
+
]
|
16 |
+
|
17 |
+
operations = [
|
18 |
+
migrations.RunPython(add_default_entries),
|
19 |
+
]
|
userapp/models.py
CHANGED
@@ -1,3 +1,9 @@
|
|
1 |
from django.db import models
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from django.db import models
|
2 |
|
3 |
+
class UserApp(models.Model):
|
4 |
+
id = models.BigAutoField(primary_key=True)
|
5 |
+
appointment_day = models.DateField()
|
6 |
+
appointment_time = models.TimeField()
|
7 |
+
doctor_name = models.CharField(max_length=255)
|
8 |
+
status = models.CharField(max_length=255)
|
9 |
+
observations = models.TextField()
|
userapp/serializers.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from rest_framework import serializers
|
2 |
+
from .models import UserApp
|
3 |
+
|
4 |
+
class UserAppSerializer(serializers.ModelSerializer):
|
5 |
+
class Meta:
|
6 |
+
model = UserApp
|
7 |
+
fields = '__all__'
|
userapp/urls.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from django.urls import path, include
|
2 |
+
from rest_framework.routers import DefaultRouter
|
3 |
+
from .views import UserAppViewSet
|
4 |
+
|
5 |
+
router = DefaultRouter()
|
6 |
+
router.register(r'', UserAppViewSet)
|
7 |
+
|
8 |
+
urlpatterns = [
|
9 |
+
# ... other URL patterns
|
10 |
+
path('', include(router.urls)),
|
11 |
+
]
|
userapp/views.py
CHANGED
@@ -1,3 +1,25 @@
|
|
1 |
from django.shortcuts import render
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from django.shortcuts import render
|
2 |
+
from django.core.files.storage import FileSystemStorage
|
3 |
+
import django_filters
|
4 |
+
from rest_framework import viewsets
|
5 |
+
from rest_framework.decorators import action
|
6 |
+
from rest_framework.response import Response
|
7 |
+
from rest_framework.pagination import LimitOffsetPagination
|
8 |
+
from django.utils import timezone
|
9 |
+
from datetime import datetime, timedelta
|
10 |
+
import requests
|
11 |
|
12 |
+
from .models import UserApp
|
13 |
+
from .serializers import UserAppSerializer
|
14 |
+
|
15 |
+
from rest_framework.pagination import PageNumberPagination
|
16 |
+
|
17 |
+
class UserAppPagination(PageNumberPagination):
|
18 |
+
page_size = 10
|
19 |
+
page_size_query_param = 'page_size'
|
20 |
+
max_page_size = 100
|
21 |
+
|
22 |
+
class UserAppViewSet(viewsets.ModelViewSet):
|
23 |
+
queryset = UserApp.objects.all().order_by('id')
|
24 |
+
serializer_class = UserAppSerializer
|
25 |
+
pagination_class = UserAppPagination
|