From a6182d4776e6f20123a5267556f21f6508e5f486 Mon Sep 17 00:00:00 2001 From: ramGopal <129493911+ramG-reddy@users.noreply.github.com> Date: Tue, 8 Oct 2024 01:16:50 +0530 Subject: [PATCH] Health Center Contribution - PR201 (#1625) * All changes of health center module * Redundancy bug fixes * Minor bug fix Patie0tn log form undefined behavior when changing radio field * Guideline Configs * Removed print statements according to guidelines --------- Co-authored-by: ChallaBharadwajReddy --- .gitignore | 2 +- .../applications/health_center/admin.py | 28 +- .../health_center/api/serializers.py | 144 +- .../applications/health_center/api/urls.py | 8 +- .../applications/health_center/api/views.py | 748 ++++---- .../health_center/migrations/0001_initial.py | 2 +- .../migrations/0002_auto_20240710_2356.py | 201 ++ .../migrations/0003_all_medicine_threshold.py | 18 + .../migrations/0004_auto_20240713_1159.py | 32 + ...ribed_medicine_prescription_followup_id.py | 19 + .../migrations/0006_auto_20240717_1943.py | 49 + .../migrations/0007_auto_20240719_0031.py | 26 + .../migrations/0008_required_medicine.py | 23 + .../migrations/0009_auto_20240721_2316.py | 18 + .../migrations/0010_auto_20240727_2352.py | 26 + .../applications/health_center/models.py | 196 +- .../health_center/add_medicine_example.xlsx | Bin 0 -> 8915 bytes .../health_center/add_stock_example.xlsx | Bin 0 -> 8976 bytes .../static/health_center/institute_logo.jpg | Bin 0 -> 3527 bytes FusionIIIT/applications/health_center/urls.py | 8 +- .../applications/health_center/utils.py | 955 ++++++++-- .../applications/health_center/views.py | 268 ++- .../templates/phcModule/manage_stock.html | 1635 ++++++++++++----- .../templates/phcModule/patientlog.html | 530 +++++- .../templates/phcModule/phc_compounder.html | 8 +- .../phc_compounder_view_prescription.html | 970 ++++++++++ requirements.txt | 3 +- 27 files changed, 4577 insertions(+), 1340 deletions(-) create mode 100644 FusionIIIT/applications/health_center/migrations/0002_auto_20240710_2356.py create mode 100644 FusionIIIT/applications/health_center/migrations/0003_all_medicine_threshold.py create mode 100644 FusionIIIT/applications/health_center/migrations/0004_auto_20240713_1159.py create mode 100644 FusionIIIT/applications/health_center/migrations/0005_all_prescribed_medicine_prescription_followup_id.py create mode 100644 FusionIIIT/applications/health_center/migrations/0006_auto_20240717_1943.py create mode 100644 FusionIIIT/applications/health_center/migrations/0007_auto_20240719_0031.py create mode 100644 FusionIIIT/applications/health_center/migrations/0008_required_medicine.py create mode 100644 FusionIIIT/applications/health_center/migrations/0009_auto_20240721_2316.py create mode 100644 FusionIIIT/applications/health_center/migrations/0010_auto_20240727_2352.py create mode 100644 FusionIIIT/applications/health_center/static/health_center/add_medicine_example.xlsx create mode 100644 FusionIIIT/applications/health_center/static/health_center/add_stock_example.xlsx create mode 100644 FusionIIIT/applications/health_center/static/health_center/institute_logo.jpg create mode 100644 FusionIIIT/templates/phcModule/phc_compounder_view_prescription.html diff --git a/.gitignore b/.gitignore index bc7a548db..a88681399 100644 --- a/.gitignore +++ b/.gitignore @@ -75,4 +75,4 @@ package-lock.json .DS_Store - +**/generated.pdf diff --git a/FusionIIIT/applications/health_center/admin.py b/FusionIIIT/applications/health_center/admin.py index 7299eff00..a988d7b5f 100644 --- a/FusionIIIT/applications/health_center/admin.py +++ b/FusionIIIT/applications/health_center/admin.py @@ -3,19 +3,19 @@ from .models import * admin.site.register(Doctor) -admin.site.register(Appointment) -admin.site.register(Ambulance_request) -admin.site.register(Hospital_admit) -admin.site.register(Complaint) -admin.site.register(Stock) -admin.site.register(Counter) -admin.site.register(Expiry) -admin.site.register(Hospital) -admin.site.register(Prescription) -admin.site.register(Medicine) -admin.site.register(Prescribed_medicine) +# admin.site.register(Appointment) +# admin.site.register(Ambulance_request) +# admin.site.register(Hospital_admit) +# admin.site.register(Complaint) +admin.site.register(Present_Stock) +# admin.site.register(Counter) +# admin.site.register(Expiry) +# admin.site.register(Hospital) +admin.site.register(All_Prescription) +admin.site.register(All_Medicine) +admin.site.register(All_Prescribed_medicine) admin.site.register(Doctors_Schedule) admin.site.register(Pathologist_Schedule) -admin.site.register(Announcements) -admin.site.register(SpecialRequest) -admin.site.register(Pathologist) \ No newline at end of file +# admin.site.register(Announcements) +# admin.site.register(SpecialRequest) +admin.site.register(Pathologist) \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/api/serializers.py b/FusionIIIT/applications/health_center/api/serializers.py index 5eb2740b2..edfaa6dc7 100644 --- a/FusionIIIT/applications/health_center/api/serializers.py +++ b/FusionIIIT/applications/health_center/api/serializers.py @@ -1,114 +1,114 @@ -from django.contrib.auth import get_user_model -from rest_framework.authtoken.models import Token -from rest_framework import serializers -from applications.health_center.models import * +# from django.contrib.auth import get_user_model +# from rest_framework.authtoken.models import Token +# from rest_framework import serializers +# from applications.health_center.models import * -class DoctorSerializer(serializers.ModelSerializer): +# class DoctorSerializer(serializers.ModelSerializer): - class Meta: - model=Doctor - fields=('__all__') +# class Meta: +# model=Doctor +# fields=('__all__') -class PathologistSerializer(serializers.ModelSerializer): +# class PathologistSerializer(serializers.ModelSerializer): - class Meta: - model=Pathologist - fields=('__all__') +# class Meta: +# model=Pathologist +# fields=('__all__') -class ComplaintSerializer(serializers.ModelSerializer): +# class ComplaintSerializer(serializers.ModelSerializer): - class Meta: - model=Complaint - fields=('__all__') +# class Meta: +# model=Complaint +# fields=('__all__') -class StockSerializer(serializers.ModelSerializer): +# class StockSerializer(serializers.ModelSerializer): - class Meta: - model=Stock - fields=('__all__') +# class Meta: +# model=Stock +# fields=('__all__') -class MedicineSerializer(serializers.ModelSerializer): +# class MedicineSerializer(serializers.ModelSerializer): - class Meta: - model=Medicine - fields=('__all__') +# class Meta: +# model=Medicine +# fields=('__all__') -class HospitalSerializer(serializers.ModelSerializer): +# class HospitalSerializer(serializers.ModelSerializer): - class Meta: - model=Hospital - fields=('__all__') +# class Meta: +# model=Hospital +# fields=('__all__') -class ExpirySerializer(serializers.ModelSerializer): +# class ExpirySerializer(serializers.ModelSerializer): - class Meta: - model=Expiry - fields=('__all__') +# class Meta: +# model=Expiry +# fields=('__all__') -class DoctorsScheduleSerializer(serializers.ModelSerializer): +# class DoctorsScheduleSerializer(serializers.ModelSerializer): - class Meta: - model=Doctors_Schedule - fields=('__all__') -class PathologistScheduleSerializer(serializers.ModelSerializer): +# class Meta: +# model=Doctors_Schedule +# fields=('__all__') +# class PathologistScheduleSerializer(serializers.ModelSerializer): - class Meta: - model=Pathologist_Schedule - fields=('__all__') +# class Meta: +# model=Pathologist_Schedule +# fields=('__all__') -class AnnouncementSerializer(serializers.ModelSerializer): +# class AnnouncementSerializer(serializers.ModelSerializer): - class Meta: - model=Announcements - fields=('__all__') +# class Meta: +# model=Announcements +# fields=('__all__') -class CounterSerializer(serializers.ModelSerializer): +# class CounterSerializer(serializers.ModelSerializer): - class Meta: - model=Counter - fields=('__all__') +# class Meta: +# model=Counter +# fields=('__all__') -class AppointmentSerializer(serializers.ModelSerializer): +# class AppointmentSerializer(serializers.ModelSerializer): - class Meta: - model=Appointment - fields=('__all__') +# class Meta: +# model=Appointment +# fields=('__all__') -class PrescriptionSerializer(serializers.ModelSerializer): +# class PrescriptionSerializer(serializers.ModelSerializer): - class Meta: - model=Prescription - fields=('__all__') +# class Meta: +# model=Prescription +# fields=('__all__') -class PrescribedMedicineSerializer(serializers.ModelSerializer): +# class PrescribedMedicineSerializer(serializers.ModelSerializer): - class Meta: - model=Prescribed_medicine - fields=('__all__') +# class Meta: +# model=Prescribed_medicine +# fields=('__all__') -class AmbulanceRequestSerializer(serializers.ModelSerializer): +# class AmbulanceRequestSerializer(serializers.ModelSerializer): - class Meta: - model=Ambulance_request - fields=('__all__') +# class Meta: +# model=Ambulance_request +# fields=('__all__') -class HospitalAdmitSerializer(serializers.ModelSerializer): +# class HospitalAdmitSerializer(serializers.ModelSerializer): - class Meta: - model=Hospital_admit - fields=('__all__') +# class Meta: +# model=Hospital_admit +# fields=('__all__') -class MedicalReliefSerializer(serializers.ModelSerializer): +# class MedicalReliefSerializer(serializers.ModelSerializer): - class Meta: - model=medical_relief - fields=('__all__') \ No newline at end of file +# class Meta: +# model=medical_relief +# fields=('__all__') \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/api/urls.py b/FusionIIIT/applications/health_center/api/urls.py index 49fee2d6e..30e998166 100644 --- a/FusionIIIT/applications/health_center/api/urls.py +++ b/FusionIIIT/applications/health_center/api/urls.py @@ -4,8 +4,8 @@ urlpatterns = [ - url(r'^compounder/$', views.compounder_view_api, name='compounder_view_api'), - url(r'^compounder/request$', views.compounder_request_api , name='compounder_request_api'), - url(r'^student/$', views.student_view_api, name='student_view'), - url(r'^student/request$', views.student_request_api, name='student_request_api') + # url(r'^compounder/$', views.compounder_view_api, name='compounder_view_api'), + # url(r'^compounder/request$', views.compounder_request_api , name='compounder_request_api'), + # url(r'^student/$', views.student_view_api, name='student_view'), + # url(r'^student/request$', views.student_request_api, name='student_request_api') ] \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/api/views.py b/FusionIIIT/applications/health_center/api/views.py index a3f8b1c67..d900c1461 100644 --- a/FusionIIIT/applications/health_center/api/views.py +++ b/FusionIIIT/applications/health_center/api/views.py @@ -1,407 +1,407 @@ -from django.contrib.auth import get_user_model -from django.shortcuts import get_object_or_404, redirect -from applications.globals.models import ExtraInfo, HoldsDesignation, Designation, DepartmentInfo -from applications.health_center.models import * -from datetime import datetime, timedelta, time,date -from django.db import transaction -from notification.views import healthcare_center_notif -from rest_framework.permissions import IsAuthenticated -from rest_framework.authentication import TokenAuthentication -from rest_framework import status -from rest_framework.decorators import api_view, permission_classes,authentication_classes -from rest_framework.permissions import AllowAny -from rest_framework.response import Response +# from django.contrib.auth import get_user_model +# from django.shortcuts import get_object_or_404, redirect +# from applications.globals.models import ExtraInfo, HoldsDesignation, Designation, DepartmentInfo +# from applications.health_center.models import * +# from datetime import datetime, timedelta, time,date +# from django.db import transaction +# from notification.views import healthcare_center_notif +# from rest_framework.permissions import IsAuthenticated +# from rest_framework.authentication import TokenAuthentication +# from rest_framework import status +# from rest_framework.decorators import api_view, permission_classes,authentication_classes +# from rest_framework.permissions import AllowAny +# from rest_framework.response import Response -from . import serializers +# from . import serializers -from notifications.models import Notification +# from notifications.models import Notification -User = get_user_model() +# User = get_user_model() -def getDesignation(request): - user = request.user - design = HoldsDesignation.objects.select_related('user','designation').filter(working=user) +# def getDesignation(request): +# user = request.user +# design = HoldsDesignation.objects.select_related('user','designation').filter(working=user) - designation=[] +# designation=[] - if str(user.extrainfo.user_type) == "student": - designation.append(str(user.extrainfo.user_type)) +# if str(user.extrainfo.user_type) == "student": +# designation.append(str(user.extrainfo.user_type)) - for i in design: - if str(i.designation) != str(user.extrainfo.user_type): - # print('-------') - # print(i.designation) - # print(user.extrainfo.user_type) - # print('') - designation.append(str(i.designation)) - # for i in designation: - # print(i) - return designation +# for i in design: +# if str(i.designation) != str(user.extrainfo.user_type): +# # print('-------') +# # print(i.designation) +# # print(user.extrainfo.user_type) +# # print('') +# designation.append(str(i.designation)) +# # for i in designation: +# # print(i) +# return designation -@api_view(['POST','DELETE']) -def student_request_api(request): - # design=request.session['currentDesignationSelected'] - usertype = ExtraInfo.objects.get(user=request.user).user_type - design = getDesignation(request) - if 'student' in design or 'Compounder' not in design: - # if design == 'student' or usertype == 'faculty' or usertype == 'staff': - # if 'ambulancerequest' in request.data and request.method=='POST': - # comp_id = ExtraInfo.objects.filter(user_type='compounder') - # request.data['user_id'] = get_object_or_404(User,username=request.user.username) - # request.data['date_request']=datetime.now() - # serializer = serializers.AmbulanceRequestSerializer(data=request.data) - # if serializer.is_valid(): - # serializer.save() - # healthcare_center_notif(request.user, request.user, 'amb_request') - # for cmp in comp_id: - # healthcare_center_notif(request.user, cmp.user, 'amb_req') - # return Response(serializer.data, status=status.HTTP_201_CREATED) - # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# @api_view(['POST','DELETE']) +# def student_request_api(request): +# # design=request.session['currentDesignationSelected'] +# usertype = ExtraInfo.objects.get(user=request.user).user_type +# design = getDesignation(request) +# if 'student' in design or 'Compounder' not in design: +# # if design == 'student' or usertype == 'faculty' or usertype == 'staff': +# # if 'ambulancerequest' in request.data and request.method=='POST': +# # comp_id = ExtraInfo.objects.filter(user_type='compounder') +# # request.data['user_id'] = get_object_or_404(User,username=request.user.username) +# # request.data['date_request']=datetime.now() +# # serializer = serializers.AmbulanceRequestSerializer(data=request.data) +# # if serializer.is_valid(): +# # serializer.save() +# # healthcare_center_notif(request.user, request.user, 'amb_request') +# # for cmp in comp_id: +# # healthcare_center_notif(request.user, cmp.user, 'amb_req') +# # return Response(serializer.data, status=status.HTTP_201_CREATED) +# # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - # elif 'ambulancecancel' in request.data and request.method == 'DELETE': - # try: - # amb_id=int(request.data['amb_id']) - # except: - # return Response({'message': 'Please enter ambulance id'}, status=status.HTTP_404_NOT_FOUND) - # ambulance = get_object_or_404(Ambulance_request,pk=amb_id) - # ambulance.delete() - # resp = {'message': 'ambulance request is cancelled'} - # return Response(data=resp,status=status.HTTP_200_OK) +# # elif 'ambulancecancel' in request.data and request.method == 'DELETE': +# # try: +# # amb_id=int(request.data['amb_id']) +# # except: +# # return Response({'message': 'Please enter ambulance id'}, status=status.HTTP_404_NOT_FOUND) +# # ambulance = get_object_or_404(Ambulance_request,pk=amb_id) +# # ambulance.delete() +# # resp = {'message': 'ambulance request is cancelled'} +# # return Response(data=resp,status=status.HTTP_200_OK) - # elif 'appointmentadd' in request.data and request.method == 'POST': - # request.data['user_id'] = get_object_or_404(User,username=request.user.username) - # try: - # day = datetime.strptime(request.data['date'], "%Y-%m-%d").weekday() - # except: - # return Response({'message': 'Please enter valid date'}, status=status.HTTP_404_NOT_FOUND) - # try: - # doctor_id = request.data['doctor_id'] - # except: - # return Response({'message': 'Please enter doctor id'}, status=status.HTTP_404_NOT_FOUND) - # request.data['schedule'] =get_object_or_404(Doctors_Schedule,doctor_id=request.data['doctor_id'],day=day).id - # comp_id = ExtraInfo.objects.filter(user_type='compounder') - # serializer = serializers.AppointmentSerializer(data=request.data) - # if serializer.is_valid(): - # serializer.save() - # healthcare_center_notif(request.user, request.user, 'appoint') - # for cmp in comp_id: - # healthcare_center_notif(request.user, cmp.user, 'appoint_req') - # return Response(serializer.data, status=status.HTTP_201_CREATED) - # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# # elif 'appointmentadd' in request.data and request.method == 'POST': +# # request.data['user_id'] = get_object_or_404(User,username=request.user.username) +# # try: +# # day = datetime.strptime(request.data['date'], "%Y-%m-%d").weekday() +# # except: +# # return Response({'message': 'Please enter valid date'}, status=status.HTTP_404_NOT_FOUND) +# # try: +# # doctor_id = request.data['doctor_id'] +# # except: +# # return Response({'message': 'Please enter doctor id'}, status=status.HTTP_404_NOT_FOUND) +# # request.data['schedule'] =get_object_or_404(Doctors_Schedule,doctor_id=request.data['doctor_id'],day=day).id +# # comp_id = ExtraInfo.objects.filter(user_type='compounder') +# # serializer = serializers.AppointmentSerializer(data=request.data) +# # if serializer.is_valid(): +# # serializer.save() +# # healthcare_center_notif(request.user, request.user, 'appoint') +# # for cmp in comp_id: +# # healthcare_center_notif(request.user, cmp.user, 'appoint_req') +# # return Response(serializer.data, status=status.HTTP_201_CREATED) +# # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - # elif 'appointmentdelete' in request.data and request.method == 'DELETE': - # try: - # app_id = request.data['app_id'] - # except: - # return Response({'message': 'Please enter valid appointment id'}, status=status.HTTP_404_NOT_FOUND) - # appointment=get_object_or_404(Appointment,pk=app_id) - # appointment.delete() - # resp = {'message': 'Your appointment is cancelled'} - # return Response(data=resp,status=status.HTTP_200_OK) +# # elif 'appointmentdelete' in request.data and request.method == 'DELETE': +# # try: +# # app_id = request.data['app_id'] +# # except: +# # return Response({'message': 'Please enter valid appointment id'}, status=status.HTTP_404_NOT_FOUND) +# # appointment=get_object_or_404(Appointment,pk=app_id) +# # appointment.delete() +# # resp = {'message': 'Your appointment is cancelled'} +# # return Response(data=resp,status=status.HTTP_200_OK) - if 'complaintadd' in request.data and request.method == 'POST': - request.data['user_id'] = get_object_or_404(User,username=request.user.username) - serializer = serializers.ComplaintSerializer(data=request.data) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - else: - resp = {'message': 'invalid request'} - return Response(data=resp,status=status.HTTP_404_NOT_FOUND) +# if 'complaintadd' in request.data and request.method == 'POST': +# request.data['user_id'] = get_object_or_404(User,username=request.user.username) +# serializer = serializers.ComplaintSerializer(data=request.data) +# if serializer.is_valid(): +# serializer.save() +# return Response(serializer.data, status=status.HTTP_201_CREATED) +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# else: +# resp = {'message': 'invalid request'} +# return Response(data=resp,status=status.HTTP_404_NOT_FOUND) - elif 'Compounder' in design: - return redirect('/healthcenter/api/compounder/request/') - else: - resp = {'message': 'invalid request'} - return Response(data=resp,status=status.HTTP_404_NOT_FOUND) +# elif 'Compounder' in design: +# return redirect('/healthcenter/api/compounder/request/') +# else: +# resp = {'message': 'invalid request'} +# return Response(data=resp,status=status.HTTP_404_NOT_FOUND) -@api_view(['GET']) -@permission_classes([IsAuthenticated]) -@authentication_classes([TokenAuthentication]) -def student_view_api(request): - # student view starts here - # design=request.session['currentDesignationSelected'] - # usertype = ExtraInfo.objects.get(user=request.user).user_type - design = getDesignation(request) - if 'student' in design or 'Compounder' not in design: - # users = ExtraInfo.objects.all() - user_id = ExtraInfo.objects.get(user=request.user) - # hospitals = serializers.HospitalAdmitSerializer(Hospital_admit.objects.filter(user_id=user_id).order_by('-admission_date'),many=True).data - # appointments = serializers.AppointmentSerializer(Appointment.objects.filter(user_id=user_id).order_by('-date'),many=True).data - # ambulances = serializers.AmbulanceRequestSerializer(Ambulance_request.objects.filter(user_id=user_id).order_by('-date_request'),many=True).data - prescription = serializers.PrescriptionSerializer(Prescription.objects.filter(user_id=user_id).order_by('-date'),many=True).data - medicines_presc = serializers.PrescribedMedicineSerializer(Prescribed_medicine.objects.all(),many=True).data - complaints = serializers.ComplaintSerializer(Complaint.objects.filter(user_id=user_id).order_by('-date'),many=True).data - days = Constants.DAYS_OF_WEEK - # schedule=serializers.ScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data - doctor_schedule=serializers.DoctorsScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data - pathologist_schedule=serializers.PathologistScheduleSerializer(Pathologist_Schedule.objects.all().order_by('pathologist_id'), many=True).data - doctors=serializers.DoctorSerializer(Doctor.objects.filter(active=True),many=True).data - pathologists=serializers.PathologistSerializer(Pathologist.objects.filter(active=True),many=True).data - count=Counter.objects.all() - if count: - Counter.objects.all().delete() - Counter.objects.create(count=0,fine=0) - count= serializers.CounterSerializer(Counter.objects.get()).data - resp={ - 'complaints': complaints, - 'medicines_presc': medicines_presc, - # 'ambulances': ambulances, - 'doctors': doctors, - 'pathologists': pathologists, - 'days': days, - 'count':count, - # 'hospitals': hospitals, - # 'appointments': appointments, - 'prescription': prescription, - # 'schedule': schedule - 'doctor_schedule': doctor_schedule, - 'pathologist_schedule': pathologist_schedule, - } - return Response(data=resp,status=status.HTTP_200_OK) - elif 'Compounder' in design: - return redirect('/healthcenter/api/compounder/') - else: - resp = {'message': 'invalid request'} - return Response(data=resp,status=status.HTTP_404_NOT_FOUND) +# @api_view(['GET']) +# @permission_classes([IsAuthenticated]) +# @authentication_classes([TokenAuthentication]) +# def student_view_api(request): +# # student view starts here +# # design=request.session['currentDesignationSelected'] +# # usertype = ExtraInfo.objects.get(user=request.user).user_type +# design = getDesignation(request) +# if 'student' in design or 'Compounder' not in design: +# # users = ExtraInfo.objects.all() +# user_id = ExtraInfo.objects.get(user=request.user) +# # hospitals = serializers.HospitalAdmitSerializer(Hospital_admit.objects.filter(user_id=user_id).order_by('-admission_date'),many=True).data +# # appointments = serializers.AppointmentSerializer(Appointment.objects.filter(user_id=user_id).order_by('-date'),many=True).data +# # ambulances = serializers.AmbulanceRequestSerializer(Ambulance_request.objects.filter(user_id=user_id).order_by('-date_request'),many=True).data +# prescription = serializers.PrescriptionSerializer(Prescription.objects.filter(user_id=user_id).order_by('-date'),many=True).data +# medicines_presc = serializers.PrescribedMedicineSerializer(Prescribed_medicine.objects.all(),many=True).data +# complaints = serializers.ComplaintSerializer(Complaint.objects.filter(user_id=user_id).order_by('-date'),many=True).data +# days = Constants.DAYS_OF_WEEK +# # schedule=serializers.ScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data +# doctor_schedule=serializers.DoctorsScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data +# pathologist_schedule=serializers.PathologistScheduleSerializer(Pathologist_Schedule.objects.all().order_by('pathologist_id'), many=True).data +# doctors=serializers.DoctorSerializer(Doctor.objects.filter(active=True),many=True).data +# pathologists=serializers.PathologistSerializer(Pathologist.objects.filter(active=True),many=True).data +# count=Counter.objects.all() +# if count: +# Counter.objects.all().delete() +# Counter.objects.create(count=0,fine=0) +# count= serializers.CounterSerializer(Counter.objects.get()).data +# resp={ +# 'complaints': complaints, +# 'medicines_presc': medicines_presc, +# # 'ambulances': ambulances, +# 'doctors': doctors, +# 'pathologists': pathologists, +# 'days': days, +# 'count':count, +# # 'hospitals': hospitals, +# # 'appointments': appointments, +# 'prescription': prescription, +# # 'schedule': schedule +# 'doctor_schedule': doctor_schedule, +# 'pathologist_schedule': pathologist_schedule, +# } +# return Response(data=resp,status=status.HTTP_200_OK) +# elif 'Compounder' in design: +# return redirect('/healthcenter/api/compounder/') +# else: +# resp = {'message': 'invalid request'} +# return Response(data=resp,status=status.HTTP_404_NOT_FOUND) -@api_view(['POST','PATCH','DELETE']) -@permission_classes([IsAuthenticated]) -@authentication_classes([TokenAuthentication]) -def compounder_request_api(request): - design = getDesignation(request) - if 'Compounder' in design: - if 'doctoradd' in request.data and request.method == 'POST': - request.data['active']=True - serializer = serializers.DoctorSerializer(data=request.data) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# @api_view(['POST','PATCH','DELETE']) +# @permission_classes([IsAuthenticated]) +# @authentication_classes([TokenAuthentication]) +# def compounder_request_api(request): +# design = getDesignation(request) +# if 'Compounder' in design: +# if 'doctoradd' in request.data and request.method == 'POST': +# request.data['active']=True +# serializer = serializers.DoctorSerializer(data=request.data) +# if serializer.is_valid(): +# serializer.save() +# return Response(serializer.data, status=status.HTTP_201_CREATED) +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - elif 'doctorremove' in request.data and request.method == 'PATCH': - try: - doctor=request.data['id'] - except: - return Response({'message': 'Please enter valid doctor id'}, status=status.HTTP_404_NOT_FOUND) - request.data['active']=False - doctor= get_object_or_404(Doctor,id=doctor) - serializer = serializers.DoctorSerializer(doctor,data=request.data,partial=True) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# elif 'doctorremove' in request.data and request.method == 'PATCH': +# try: +# doctor=request.data['id'] +# except: +# return Response({'message': 'Please enter valid doctor id'}, status=status.HTTP_404_NOT_FOUND) +# request.data['active']=False +# doctor= get_object_or_404(Doctor,id=doctor) +# serializer = serializers.DoctorSerializer(doctor,data=request.data,partial=True) +# if serializer.is_valid(): +# serializer.save() +# return Response(serializer.data, status=status.HTTP_201_CREATED) +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - elif 'doctorscheduleadd' in request.data and request.method == 'POST': - try: - doctor_id = int(request.data['doctor_id']) - except: - return Response({'message': 'Please enter valid doctor id'}, status=status.HTTP_404_NOT_FOUND) - try: - day = request.data['day'] - except: - return Response({'message': 'Please enter valid day'}, status=status.HTTP_404_NOT_FOUND) - sc = Doctor.objects.filter(doctor_id=doctor_id, day=day) - if sc.count() == 0: - serializer = serializers.DoctorsScheduleSerializer(data=request.data) - else: - sc = get_object_or_404(Doctors_Schedule,doctor_id=doctor_id,day=day) - serializer = serializers.DoctorsScheduleSerializer(sc,data=request.data,partial=True) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# elif 'doctorscheduleadd' in request.data and request.method == 'POST': +# try: +# doctor_id = int(request.data['doctor_id']) +# except: +# return Response({'message': 'Please enter valid doctor id'}, status=status.HTTP_404_NOT_FOUND) +# try: +# day = request.data['day'] +# except: +# return Response({'message': 'Please enter valid day'}, status=status.HTTP_404_NOT_FOUND) +# sc = Doctor.objects.filter(doctor_id=doctor_id, day=day) +# if sc.count() == 0: +# serializer = serializers.DoctorsScheduleSerializer(data=request.data) +# else: +# sc = get_object_or_404(Doctors_Schedule,doctor_id=doctor_id,day=day) +# serializer = serializers.DoctorsScheduleSerializer(sc,data=request.data,partial=True) +# if serializer.is_valid(): +# serializer.save() +# return Response(serializer.data, status=status.HTTP_201_CREATED) +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - elif 'doctorscheduleremove' in request.data and request.method == 'DELETE': - try: - doctor_id = request.data['doctor_id'] - except: - return Response({'message': 'Please enter valid doctor id'}, status=status.HTTP_404_NOT_FOUND) - try: - day = request.data['day'] - except: - return Response({'message': 'Please enter valid day'}, status=status.HTTP_404_NOT_FOUND) - sc = get_object_or_404(Doctors_Schedule,doctor_id=doctor_id,day=day) - sc.delete() - resp={'message':'Schedule Deleted successfully'} - return Response(data=resp,status=status.HTTP_200_OK) +# elif 'doctorscheduleremove' in request.data and request.method == 'DELETE': +# try: +# doctor_id = request.data['doctor_id'] +# except: +# return Response({'message': 'Please enter valid doctor id'}, status=status.HTTP_404_NOT_FOUND) +# try: +# day = request.data['day'] +# except: +# return Response({'message': 'Please enter valid day'}, status=status.HTTP_404_NOT_FOUND) +# sc = get_object_or_404(Doctors_Schedule,doctor_id=doctor_id,day=day) +# sc.delete() +# resp={'message':'Schedule Deleted successfully'} +# return Response(data=resp,status=status.HTTP_200_OK) - # elif 'hospitaladmit' in request.data and request.method == 'POST': - # serializer = serializers.HospitalAdmitSerializer(data=request.data) - # if serializer.is_valid(): - # serializer.save() - # return Response(serializer.data, status=status.HTTP_201_CREATED) - # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# # elif 'hospitaladmit' in request.data and request.method == 'POST': +# # serializer = serializers.HospitalAdmitSerializer(data=request.data) +# # if serializer.is_valid(): +# # serializer.save() +# # return Response(serializer.data, status=status.HTTP_201_CREATED) +# # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - # elif 'hospitaldischarge' in request.data and request.method == 'PATCH': - # try: - # pk = request.data['id'] - # except: - # return Response({'message': 'Please enter valid id'}, status=status.HTTP_404_NOT_FOUND) - # request.data['discharge_date']=date.today() - # Ha = get_object_or_404(Hospital_admit,id=pk) - # serializer = serializers.HospitalAdmitSerializer(Ha,data=request.data,partial=True) - # if serializer.is_valid(): - # serializer.save() - # return Response(serializer.data, status=status.HTTP_201_CREATED) - # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# # elif 'hospitaldischarge' in request.data and request.method == 'PATCH': +# # try: +# # pk = request.data['id'] +# # except: +# # return Response({'message': 'Please enter valid id'}, status=status.HTTP_404_NOT_FOUND) +# # request.data['discharge_date']=date.today() +# # Ha = get_object_or_404(Hospital_admit,id=pk) +# # serializer = serializers.HospitalAdmitSerializer(Ha,data=request.data,partial=True) +# # if serializer.is_valid(): +# # serializer.save() +# # return Response(serializer.data, status=status.HTTP_201_CREATED) +# # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - elif 'medicineadd' in request.data and request.method =='POST': - stock = serializers.StockSerializer(data=request.data) - if stock.is_valid(): - stock.save() - else: - return Response(stock.errors,status=status.HTTP_400_BAD_REQUEST) - request.data['medicine_id'] = (Stock.objects.get(medicine_name=request.data['medicine_name'])).id - expiry = serializers.ExpirySerializer(data=request.data) - if expiry.is_valid(): - expiry.save() - else: - return Response(expiry.errors,status=status.HTTP_400_BAD_REQUEST) - return Response(stock.data,status=status.HTTP_201_CREATED) +# elif 'medicineadd' in request.data and request.method =='POST': +# stock = serializers.StockSerializer(data=request.data) +# if stock.is_valid(): +# stock.save() +# else: +# return Response(stock.errors,status=status.HTTP_400_BAD_REQUEST) +# request.data['medicine_id'] = (Stock.objects.get(medicine_name=request.data['medicine_name'])).id +# expiry = serializers.ExpirySerializer(data=request.data) +# if expiry.is_valid(): +# expiry.save() +# else: +# return Response(expiry.errors,status=status.HTTP_400_BAD_REQUEST) +# return Response(stock.data,status=status.HTTP_201_CREATED) - elif 'stockadd' in request.data and request.method == 'POST': - serializer = serializers.ExpirySerializer(data=request.data) - if serializer.is_valid(): - serializer.save() - else: - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - quantity = (Stock.objects.get(id=request.data['medicine_id'])).quantity - quantity = quantity + int(request.data['quantity']) - stock = get_object_or_404(Stock,id=request.data['medicine_id']) - serializer = serializers.StockSerializer(stock,data={'quantity': quantity,'threshold':request.data['threshold']},partial=True) - if serializer.is_valid(): - serializer.save() - else: - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - resp = {'message': 'stock added successfully'} - return Response(data=resp,status=status.HTTP_200_OK) +# elif 'stockadd' in request.data and request.method == 'POST': +# serializer = serializers.ExpirySerializer(data=request.data) +# if serializer.is_valid(): +# serializer.save() +# else: +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# quantity = (Stock.objects.get(id=request.data['medicine_id'])).quantity +# quantity = quantity + int(request.data['quantity']) +# stock = get_object_or_404(Stock,id=request.data['medicine_id']) +# serializer = serializers.StockSerializer(stock,data={'quantity': quantity,'threshold':request.data['threshold']},partial=True) +# if serializer.is_valid(): +# serializer.save() +# else: +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# resp = {'message': 'stock added successfully'} +# return Response(data=resp,status=status.HTTP_200_OK) - elif 'prescriptionsubmit' in request.data and request.method == 'POST': - serializer = serializers.PrescriptionSerializer(data=request.data) - user = ExtraInfo.objects.get(id=request.data['user_id']) - if serializer.is_valid(): - serializer.save() - healthcare_center_notif(request.user, user.user, 'Presc') - return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# elif 'prescriptionsubmit' in request.data and request.method == 'POST': +# serializer = serializers.PrescriptionSerializer(data=request.data) +# user = ExtraInfo.objects.get(id=request.data['user_id']) +# if serializer.is_valid(): +# serializer.save() +# healthcare_center_notif(request.user, user.user, 'Presc') +# return Response(serializer.data, status=status.HTTP_201_CREATED) +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - elif 'prescripmedicineadd' in request.data and request.method == 'POST': - with transaction.atomic(): - medicine_id=request.data['medicine_id'] - quantity = int(request.data['quantity']) - expiry=Expiry.objects.filter(medicine_id=medicine_id,quantity__gt=0,returned=False,expiry_date__gte=date.today()).order_by('expiry_date') - stock=(Stock.objects.get(id=medicine_id)).quantity - if stock>quantity: - for e in expiry: - q=e.quantity - em=e.id - if q>quantity: - q=q-quantity - Expiry.objects.filter(id=em).update(quantity=q) - qty = Stock.objects.get(id=medicine_id).quantity - qty = qty-quantity - Stock.objects.filter(id=medicine_id).update(quantity=qty) - break - else: - quan=Expiry.objects.get(id=em).quantity - Expiry.objects.filter(id=em).update(quantity=0) - qty = Stock.objects.get(id=medicine_id).quantity - qty = qty-quan - Stock.objects.filter(id=medicine_id).update(quantity=qty) - quantity=quantity-quan - serializer = serializers.PrescribedMedicineSerializer(data=request.data) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data,status=status.HTTP_200_OK) - else: - transaction.set_rollback(True) - return Response(serializer.errors,status=status.HTTP_400_BAD_REQUEST) - else: - resp= {'message': 'Required Medicines is not available'} - return Response(data=resp,status=status.HTTP_400_BAD_REQUEST) +# elif 'prescripmedicineadd' in request.data and request.method == 'POST': +# with transaction.atomic(): +# medicine_id=request.data['medicine_id'] +# quantity = int(request.data['quantity']) +# expiry=Expiry.objects.filter(medicine_id=medicine_id,quantity__gt=0,returned=False,expiry_date__gte=date.today()).order_by('expiry_date') +# stock=(Stock.objects.get(id=medicine_id)).quantity +# if stock>quantity: +# for e in expiry: +# q=e.quantity +# em=e.id +# if q>quantity: +# q=q-quantity +# Expiry.objects.filter(id=em).update(quantity=q) +# qty = Stock.objects.get(id=medicine_id).quantity +# qty = qty-quantity +# Stock.objects.filter(id=medicine_id).update(quantity=qty) +# break +# else: +# quan=Expiry.objects.get(id=em).quantity +# Expiry.objects.filter(id=em).update(quantity=0) +# qty = Stock.objects.get(id=medicine_id).quantity +# qty = qty-quan +# Stock.objects.filter(id=medicine_id).update(quantity=qty) +# quantity=quantity-quan +# serializer = serializers.PrescribedMedicineSerializer(data=request.data) +# if serializer.is_valid(): +# serializer.save() +# return Response(serializer.data,status=status.HTTP_200_OK) +# else: +# transaction.set_rollback(True) +# return Response(serializer.errors,status=status.HTTP_400_BAD_REQUEST) +# else: +# resp= {'message': 'Required Medicines is not available'} +# return Response(data=resp,status=status.HTTP_400_BAD_REQUEST) - elif 'complaintresponse' in request.data and request.method == 'PATCH': - try: - pk = request.data['complaint_id'] - except: - return Response({'message': 'Please enter valid complaint id'}, status=status.HTTP_404_NOT_FOUND) - try: - complain = Complaint.objects.get(id = pk) - except Complaint.DoesNotExist: - return Response({'message': 'Complaint does not exist'}, status=status.HTTP_404_NOT_FOUND) - serializer = serializers.ComplaintSerializer(complain,data=request.data,partial=True) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - else: - resp = {'message': 'invalid request'} - return Response(data=resp,status=status.HTTP_404_NOT_FOUND) +# elif 'complaintresponse' in request.data and request.method == 'PATCH': +# try: +# pk = request.data['complaint_id'] +# except: +# return Response({'message': 'Please enter valid complaint id'}, status=status.HTTP_404_NOT_FOUND) +# try: +# complain = Complaint.objects.get(id = pk) +# except Complaint.DoesNotExist: +# return Response({'message': 'Complaint does not exist'}, status=status.HTTP_404_NOT_FOUND) +# serializer = serializers.ComplaintSerializer(complain,data=request.data,partial=True) +# if serializer.is_valid(): +# serializer.save() +# return Response(serializer.data, status=status.HTTP_201_CREATED) +# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) +# else: +# resp = {'message': 'invalid request'} +# return Response(data=resp,status=status.HTTP_404_NOT_FOUND) - else: - resp = {'message': 'invalid request'} - return Response(data=resp,status=status.HTTP_404_NOT_FOUND) +# else: +# resp = {'message': 'invalid request'} +# return Response(data=resp,status=status.HTTP_404_NOT_FOUND) -@api_view(['GET']) -@permission_classes([IsAuthenticated]) -@authentication_classes([TokenAuthentication]) -def compounder_view_api(request): # compounder view starts here - # usertype = ExtraInfo.objects.get(user=request.user).user_type - design = getDesignation(request) - if 'Compounder' in design: - all_complaints = serializers.ComplaintSerializer(Complaint.objects.all(),many=True).data - # all_hospitals = serializers.HospitalAdmitSerializer(Hospital_admit.objects.all().order_by('-admission_date'),many=True).data - # hospitals_list = serializers.HospitalSerializer(Hospital.objects.all().order_by('hospital_name'),many=True).data - # all_ambulances = serializers.AmbulanceRequestSerializer(Ambulance_request.objects.all().order_by('-date_request'),many=True).data - # appointments_today = serializers.AppointmentSerializer(Appointment.objects.filter(date=datetime.now()).order_by('date'),many=True).data - # appointments_future= serializers.AppointmentSerializer(Appointment.objects.filter(date__gt=datetime.now()).order_by('date'),many=True).data - stocks = serializers.StockSerializer(Stock.objects.all(),many=True).data - days = Constants.DAYS_OF_WEEK - # schedule= serializers.ScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data - expired= serializers.ExpirySerializer(Expiry.objects.filter(expiry_date__lt=datetime.now(),returned=False).order_by('expiry_date'),many=True).data - live_meds= serializers.ExpirySerializer(Expiry.objects.filter(returned=False).order_by('quantity'),many=True).data - count= Counter.objects.all() - presc_hist= serializers.PrescriptionSerializer(Prescription.objects.all().order_by('-date'),many=True).data - medicines_presc= serializers.PrescribedMedicineSerializer(Prescribed_medicine.objects.all(),many=True).data +# @api_view(['GET']) +# @permission_classes([IsAuthenticated]) +# @authentication_classes([TokenAuthentication]) +# def compounder_view_api(request): # compounder view starts here +# # usertype = ExtraInfo.objects.get(user=request.user).user_type +# design = getDesignation(request) +# if 'Compounder' in design: +# all_complaints = serializers.ComplaintSerializer(Complaint.objects.all(),many=True).data +# # all_hospitals = serializers.HospitalAdmitSerializer(Hospital_admit.objects.all().order_by('-admission_date'),many=True).data +# # hospitals_list = serializers.HospitalSerializer(Hospital.objects.all().order_by('hospital_name'),many=True).data +# # all_ambulances = serializers.AmbulanceRequestSerializer(Ambulance_request.objects.all().order_by('-date_request'),many=True).data +# # appointments_today = serializers.AppointmentSerializer(Appointment.objects.filter(date=datetime.now()).order_by('date'),many=True).data +# # appointments_future= serializers.AppointmentSerializer(Appointment.objects.filter(date__gt=datetime.now()).order_by('date'),many=True).data +# stocks = serializers.StockSerializer(Stock.objects.all(),many=True).data +# days = Constants.DAYS_OF_WEEK +# # schedule= serializers.ScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data +# expired= serializers.ExpirySerializer(Expiry.objects.filter(expiry_date__lt=datetime.now(),returned=False).order_by('expiry_date'),many=True).data +# live_meds= serializers.ExpirySerializer(Expiry.objects.filter(returned=False).order_by('quantity'),many=True).data +# count= Counter.objects.all() +# presc_hist= serializers.PrescriptionSerializer(Prescription.objects.all().order_by('-date'),many=True).data +# medicines_presc= serializers.PrescribedMedicineSerializer(Prescribed_medicine.objects.all(),many=True).data - if count: - Counter.objects.all().delete() - Counter.objects.create(count=0,fine=0) - count= serializers.CounterSerializer(Counter.objects.get()).data - # hospitals=serializers.HospitalSerializer(Hospital.objects.all(),many=True).data - doctor_schedule=serializers.DoctorsScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data - pathologist_schedule=serializers.PathologistScheduleSerializer(Pathologist_Schedule.objects.all().order_by('pathologist_id'), many=True).data - doctors=serializers.DoctorSerializer(Doctor.objects.filter(active=True),many=True).data - pathologists=serializers.PathologistSerializer(Pathologist.objects.filter(active=True),many=True).data +# if count: +# Counter.objects.all().delete() +# Counter.objects.create(count=0,fine=0) +# count= serializers.CounterSerializer(Counter.objects.get()).data +# # hospitals=serializers.HospitalSerializer(Hospital.objects.all(),many=True).data +# doctor_schedule=serializers.DoctorsScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data +# pathologist_schedule=serializers.PathologistScheduleSerializer(Pathologist_Schedule.objects.all().order_by('pathologist_id'), many=True).data +# doctors=serializers.DoctorSerializer(Doctor.objects.filter(active=True),many=True).data +# pathologists=serializers.PathologistSerializer(Pathologist.objects.filter(active=True),many=True).data - resp= { - 'days': days, - 'count': count, - 'expired':expired, - 'stocks': stocks, - 'all_complaints': all_complaints, - # 'all_hospitals': all_hospitals, - # 'hospitals':hospitals, - # 'all_ambulances': all_ambulances, - # 'appointments_today': appointments_today, - 'doctors': doctors, - # 'appointments_future': appointments_future, - # 'schedule': schedule, - 'doctor_schedule': doctor_schedule, - 'pathologist_schedule': pathologist_schedule, - 'pathologists': pathologists, - 'live_meds': live_meds, - 'presc_hist': presc_hist, - 'medicines_presc': medicines_presc, - # 'hospitals_list': hospitals_list - } - return Response(data=resp,status=status.HTTP_200_OK) +# resp= { +# 'days': days, +# 'count': count, +# 'expired':expired, +# 'stocks': stocks, +# 'all_complaints': all_complaints, +# # 'all_hospitals': all_hospitals, +# # 'hospitals':hospitals, +# # 'all_ambulances': all_ambulances, +# # 'appointments_today': appointments_today, +# 'doctors': doctors, +# # 'appointments_future': appointments_future, +# # 'schedule': schedule, +# 'doctor_schedule': doctor_schedule, +# 'pathologist_schedule': pathologist_schedule, +# 'pathologists': pathologists, +# 'live_meds': live_meds, +# 'presc_hist': presc_hist, +# 'medicines_presc': medicines_presc, +# # 'hospitals_list': hospitals_list +# } +# return Response(data=resp,status=status.HTTP_200_OK) - else: - resp = {'message': 'invalid request'} - return Response(data=resp,status=status.HTTP_404_NOT_FOUND) # compounder view ends \ No newline at end of file +# else: +# resp = {'message': 'invalid request'} +# return Response(data=resp,status=status.HTTP_404_NOT_FOUND) # compounder view ends \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/migrations/0001_initial.py b/FusionIIIT/applications/health_center/migrations/0001_initial.py index 7dfe99418..887666ff8 100644 --- a/FusionIIIT/applications/health_center/migrations/0001_initial.py +++ b/FusionIIIT/applications/health_center/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.5 on 2024-07-16 15:44 +# Generated by Django 3.1.5 on 2024-04-27 23:48 import datetime from django.db import migrations, models diff --git a/FusionIIIT/applications/health_center/migrations/0002_auto_20240710_2356.py b/FusionIIIT/applications/health_center/migrations/0002_auto_20240710_2356.py new file mode 100644 index 000000000..9a50335f6 --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0002_auto_20240710_2356.py @@ -0,0 +1,201 @@ +# Generated by Django 3.1.5 on 2024-07-10 23:56 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='All_Medicine', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('medicine_name', models.CharField(default='NOT_SET', max_length=50)), + ('brand_name', models.CharField(default='NOT_SET', max_length=50)), + ('constituents', models.TextField(default='NOT_SET')), + ('manufacturer_name', models.CharField(default='NOT_SET', max_length=50)), + ('pack_size_label', models.CharField(default='NOT_SET', max_length=50)), + ], + ), + migrations.CreateModel( + name='All_Prescribed_medicine', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.IntegerField(default=0)), + ('days', models.IntegerField(default=0)), + ('times', models.IntegerField(default=0)), + ('revoked', models.BooleanField(default=False)), + ('revoked_date', models.DateField(null=True)), + ('medicine_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.all_medicine')), + ], + ), + migrations.CreateModel( + name='All_Prescription', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('user_id', models.CharField(max_length=15)), + ('details', models.TextField(null=True)), + ('date', models.DateField()), + ('suggestions', models.TextField(null=True)), + ('test', models.CharField(blank=True, max_length=200, null=True)), + ('file_id', models.IntegerField(default=0)), + ('is_dependent', models.BooleanField(default=False)), + ('dependent_name', models.CharField(default='SELF', max_length=30)), + ('dependent_relation', models.CharField(default='SELF', max_length=20)), + ('doctor_id', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor')), + ], + ), + migrations.CreateModel( + name='Prescription_followup', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('details', models.TextField(null=True)), + ('date', models.DateField()), + ('test', models.CharField(blank=True, max_length=200, null=True)), + ('suggestions', models.TextField(null=True)), + ('file_id', models.IntegerField(default=0)), + ('Doctor_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor')), + ('prescription_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.all_prescription')), + ], + ), + migrations.CreateModel( + name='Present_Stock', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.IntegerField(default=0)), + ], + ), + migrations.CreateModel( + name='Stock_entry', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.IntegerField(default=0)), + ('supplier', models.CharField(default='NOT_SET', max_length=50)), + ('Expiry_date', models.DateField()), + ('date', models.DateField(auto_now=True)), + ('medicine_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.all_medicine')), + ], + ), + migrations.RemoveField( + model_name='ambulance_request', + name='user_id', + ), + migrations.RemoveField( + model_name='announcements', + name='anno_id', + ), + migrations.RemoveField( + model_name='appointment', + name='doctor_id', + ), + migrations.RemoveField( + model_name='appointment', + name='schedule', + ), + migrations.RemoveField( + model_name='appointment', + name='user_id', + ), + migrations.RemoveField( + model_name='complaint', + name='user_id', + ), + migrations.DeleteModel( + name='Counter', + ), + migrations.RemoveField( + model_name='expiry', + name='medicine_id', + ), + migrations.RemoveField( + model_name='hospital_admit', + name='doctor_id', + ), + migrations.RemoveField( + model_name='hospital_admit', + name='hospital_name', + ), + migrations.RemoveField( + model_name='hospital_admit', + name='user_id', + ), + migrations.RemoveField( + model_name='medicine', + name='medicine_id', + ), + migrations.RemoveField( + model_name='medicine', + name='patient', + ), + migrations.RemoveField( + model_name='prescribed_medicine', + name='medicine_id', + ), + migrations.RemoveField( + model_name='prescribed_medicine', + name='prescription_id', + ), + migrations.RemoveField( + model_name='prescription', + name='doctor_id', + ), + migrations.RemoveField( + model_name='prescription', + name='user_id', + ), + migrations.RemoveField( + model_name='specialrequest', + name='request_ann_maker', + ), + migrations.DeleteModel( + name='Ambulance_request', + ), + migrations.DeleteModel( + name='Announcements', + ), + migrations.DeleteModel( + name='Appointment', + ), + migrations.DeleteModel( + name='Complaint', + ), + migrations.DeleteModel( + name='Expiry', + ), + migrations.DeleteModel( + name='Hospital', + ), + migrations.DeleteModel( + name='Hospital_admit', + ), + migrations.DeleteModel( + name='Medicine', + ), + migrations.DeleteModel( + name='Prescribed_medicine', + ), + migrations.DeleteModel( + name='Prescription', + ), + migrations.DeleteModel( + name='SpecialRequest', + ), + migrations.DeleteModel( + name='Stock', + ), + migrations.AddField( + model_name='present_stock', + name='stock_id', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.stock_entry'), + ), + migrations.AddField( + model_name='all_prescribed_medicine', + name='prescription_id', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.all_prescription'), + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0003_all_medicine_threshold.py b/FusionIIIT/applications/health_center/migrations/0003_all_medicine_threshold.py new file mode 100644 index 000000000..bfc404d98 --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0003_all_medicine_threshold.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-07-11 15:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0002_auto_20240710_2356'), + ] + + operations = [ + migrations.AddField( + model_name='all_medicine', + name='threshold', + field=models.IntegerField(default=100), + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0004_auto_20240713_1159.py b/FusionIIIT/applications/health_center/migrations/0004_auto_20240713_1159.py new file mode 100644 index 000000000..bed6b2da1 --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0004_auto_20240713_1159.py @@ -0,0 +1,32 @@ +# Generated by Django 3.1.5 on 2024-07-13 11:59 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0003_all_medicine_threshold'), + ] + + operations = [ + migrations.AddField( + model_name='all_prescribed_medicine', + name='stock', + field=models.ForeignKey(default='1', on_delete=django.db.models.deletion.CASCADE, to='health_center.present_stock'), + preserve_default=False, + ), + migrations.AddField( + model_name='present_stock', + name='Expiry_date', + field=models.DateField(default='2024-04-12'), + preserve_default=False, + ), + migrations.AddField( + model_name='present_stock', + name='medicine_id', + field=models.ForeignKey(default='1', on_delete=django.db.models.deletion.CASCADE, to='health_center.all_medicine'), + preserve_default=False, + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0005_all_prescribed_medicine_prescription_followup_id.py b/FusionIIIT/applications/health_center/migrations/0005_all_prescribed_medicine_prescription_followup_id.py new file mode 100644 index 000000000..2619ec86a --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0005_all_prescribed_medicine_prescription_followup_id.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.5 on 2024-07-15 00:19 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0004_auto_20240713_1159'), + ] + + operations = [ + migrations.AddField( + model_name='all_prescribed_medicine', + name='prescription_followup_id', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.prescription_followup'), + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0006_auto_20240717_1943.py b/FusionIIIT/applications/health_center/migrations/0006_auto_20240717_1943.py new file mode 100644 index 000000000..42e9f1974 --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0006_auto_20240717_1943.py @@ -0,0 +1,49 @@ +# Generated by Django 3.1.5 on 2024-07-17 19:43 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0005_all_prescribed_medicine_prescription_followup_id'), + ] + + operations = [ + migrations.AlterField( + model_name='all_medicine', + name='brand_name', + field=models.CharField(default='NOT_SET', max_length=1000, null=True), + ), + migrations.AlterField( + model_name='all_medicine', + name='constituents', + field=models.TextField(default='NOT_SET', null=True), + ), + migrations.AlterField( + model_name='all_medicine', + name='manufacturer_name', + field=models.CharField(default='NOT_SET', max_length=1000, null=True), + ), + migrations.AlterField( + model_name='all_medicine', + name='medicine_name', + field=models.CharField(default='NOT_SET', max_length=1000, null=True), + ), + migrations.AlterField( + model_name='all_medicine', + name='pack_size_label', + field=models.CharField(default='NOT_SET', max_length=1000, null=True), + ), + migrations.AlterField( + model_name='all_medicine', + name='threshold', + field=models.IntegerField(default=0, null=True), + ), + migrations.AlterField( + model_name='prescription_followup', + name='Doctor_id', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.doctor'), + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0007_auto_20240719_0031.py b/FusionIIIT/applications/health_center/migrations/0007_auto_20240719_0031.py new file mode 100644 index 000000000..cbc2ab6fa --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0007_auto_20240719_0031.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.5 on 2024-07-19 00:31 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0006_auto_20240717_1943'), + ] + + operations = [ + migrations.CreateModel( + name='files', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('file_data', models.BinaryField()), + ], + ), + migrations.AddField( + model_name='all_prescribed_medicine', + name='revoked_priscription', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='revoked_priscription', to='health_center.prescription_followup'), + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0008_required_medicine.py b/FusionIIIT/applications/health_center/migrations/0008_required_medicine.py new file mode 100644 index 000000000..a21ca45da --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0008_required_medicine.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.5 on 2024-07-21 11:09 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0007_auto_20240719_0031'), + ] + + operations = [ + migrations.CreateModel( + name='Required_medicine', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.IntegerField()), + ('threshold', models.IntegerField()), + ('medicine_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_center.all_medicine')), + ], + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0009_auto_20240721_2316.py b/FusionIIIT/applications/health_center/migrations/0009_auto_20240721_2316.py new file mode 100644 index 000000000..1c604c5c3 --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0009_auto_20240721_2316.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-07-21 23:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0008_required_medicine'), + ] + + operations = [ + migrations.RenameField( + model_name='all_prescribed_medicine', + old_name='revoked_priscription', + new_name='revoked_prescription', + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0010_auto_20240727_2352.py b/FusionIIIT/applications/health_center/migrations/0010_auto_20240727_2352.py new file mode 100644 index 000000000..ad10be188 --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0010_auto_20240727_2352.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.5 on 2024-07-27 23:52 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0009_auto_20240721_2316'), + ] + + operations = [ + migrations.CreateModel( + name='Required_tabel_last_updated', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateField()), + ], + ), + migrations.AlterField( + model_name='all_prescribed_medicine', + name='stock', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='health_center.present_stock'), + ), + ] diff --git a/FusionIIIT/applications/health_center/models.py b/FusionIIIT/applications/health_center/models.py index 534abb438..7f46307f0 100644 --- a/FusionIIIT/applications/health_center/models.py +++ b/FusionIIIT/applications/health_center/models.py @@ -4,11 +4,10 @@ from django.contrib.auth.models import User from applications.globals.models import ExtraInfo - +from applications.hr2.models import EmpDependents # Create your models here. - class Constants: DAYS_OF_WEEK = ( (0, 'Monday'), @@ -50,52 +49,51 @@ class Pathologist(models.Model): def __str__(self): return self.pathologist_name +# class Complaint(models.Model): +# user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) +# feedback = models.CharField(max_length=100, null=True, blank=False) #This is the feedback given by the compounder +# complaint = models.CharField(max_length=100, null=True, blank=False) #Here Complaint given by user cannot be NULL! +# date = models.DateField(auto_now=True) -class Complaint(models.Model): - user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) - feedback = models.CharField(max_length=100, null=True, blank=False) #This is the feedback given by the compounder - complaint = models.CharField(max_length=100, null=True, blank=False) #Here Complaint given by user cannot be NULL! - date = models.DateField(auto_now=True) - +class All_Medicine(models.Model): + medicine_name = models.CharField(max_length=1000,default="NOT_SET", null=True) + brand_name = models.CharField(max_length=1000,default="NOT_SET", null=True) + constituents = models.TextField(default="NOT_SET", null=True) + manufacturer_name = models.CharField(max_length=1000,default="NOT_SET", null=True) + threshold = models.IntegerField(default=0, null=True) + pack_size_label = models.CharField(max_length=1000,default="NOT_SET", null=True) -class Stock(models.Model): - medicine_name = models.CharField(max_length=100) + def __str__(self): + return self.brand_name + +class Stock_entry(models.Model): + medicine_id = models.ForeignKey(All_Medicine, on_delete=models.CASCADE) quantity = models.IntegerField(default=0) - threshold = models.IntegerField(default=10) + supplier = models.CharField(max_length=50,default="NOT_SET") + Expiry_date = models.DateField() + date = models.DateField(auto_now=True) # generic_name = models.CharField(max_length=80) - def __str__(self): - return self.medicine_name + return self.medicine_id.medicine_name + +class Required_medicine(models.Model): + medicine_id = models.ForeignKey(All_Medicine,on_delete = models.CASCADE) + quantity = models.IntegerField() + threshold = models.IntegerField() -class Medicine(models.Model): - patient = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) - medicine_id = models.ForeignKey(Stock,on_delete=models.CASCADE) +class Present_Stock(models.Model): quantity = models.IntegerField(default=0) - days = models.IntegerField(default=0) - times = models.IntegerField(default=0) + stock_id = models.ForeignKey(Stock_entry,on_delete=models.CASCADE) + medicine_id = models.ForeignKey(All_Medicine, on_delete=models.CASCADE) + Expiry_date =models.DateField() - def __str__(self): - return self.medicine_id - -class Hospital(models.Model): - hospital_name=models.CharField(max_length=100) - phone=models.CharField(max_length=10) - def __str__(self): - return self.hospital_name + # generic_name = models.CharField(max_length=80) -class Expiry(models.Model): - medicine_id=models.ForeignKey(Stock,on_delete=models.CASCADE) - quantity = models.IntegerField(default=0) - supplier=models.CharField(max_length=50) - expiry_date=models.DateField() - returned=models.BooleanField(default=False) - return_date=models.DateField(null=True,blank=True) - date=models.DateField(auto_now=True) def __str__(self): - return self.medicine_id.medicine_name + return str(self.Expiry_date) class Doctors_Schedule(models.Model): doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE) @@ -115,117 +113,48 @@ class Pathologist_Schedule(models.Model): room = models.IntegerField() date = models.DateField(auto_now=True) - -class Counter(models.Model): - count=models.IntegerField(default=0) - fine=models.IntegerField(default=0) - doc_count=models.IntegerField(default=0) - patho_count=models.IntegerField(default=0) - - def doctor_count(self): - self.doc_count+=1 - return "" - def pathologist_count(self): - self.doc_count+=1 - return "" - def increment(self): - self.count+=1 - return "" - def increment_fine(self): - self.fine+=1 - return "" - def range_count(self): - if self.count==0: - dif=0 - elif self.count<=4: - dif=self.doc_count-self.count - elif self.count<=4: - dif=self.count-self.doc_count - elif self.count<=4: - dif=self.patho_count-self.count - else: - dif=self.count-self.patho_count - return range(dif) - def empty_fine(self): - self.count=0 - self.fine=0 - return "" - def empty_count(self): - self.count=0 - return "" - -class Appointment(models.Model): - user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) - doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE) - description = models.CharField(max_length=50) - schedule = models.ForeignKey(Doctors_Schedule, on_delete=models.CASCADE,null=True, blank=True) - date = models.DateField() - - def __str__(self): - return self.description - - -class Prescription(models.Model): - user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) +class All_Prescription(models.Model): + user_id = models.CharField(max_length=15) doctor_id = models.ForeignKey(Doctor, on_delete=models.CASCADE,null=True, blank=True) - details = models.CharField(max_length=100) + details = models.TextField(null=True) date = models.DateField() + suggestions = models.TextField(null=True) test = models.CharField(max_length=200, null=True, blank=True) file_id=models.IntegerField(default=0) + is_dependent = models.BooleanField(default=False) + dependent_name = models.CharField(max_length=30,default="SELF") + dependent_relation = models.CharField(max_length=20,default="SELF") # appointment = models.ForeignKey(Appointment, on_delete=models.CASCADE,null=True, blank=True) def __str__(self): - return self.details + return self.user_id - -class Prescribed_medicine(models.Model): - prescription_id = models.ForeignKey(Prescription,on_delete=models.CASCADE) - medicine_id = models.ForeignKey(Stock,on_delete=models.CASCADE) +class Prescription_followup(models.Model): + prescription_id=models.ForeignKey(All_Prescription,on_delete=models.CASCADE) + details = models.TextField(null=True) + date = models.DateField() + test = models.CharField(max_length=200, null=True, blank=True) + suggestions = models.TextField(null=True) + Doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE, null=True, blank=True) + file_id=models.IntegerField(default=0) +class All_Prescribed_medicine(models.Model): + prescription_id = models.ForeignKey(All_Prescription,on_delete=models.CASCADE) + medicine_id = models.ForeignKey(All_Medicine,on_delete=models.CASCADE) + stock = models.ForeignKey(Present_Stock,on_delete=models.CASCADE,null=True) + prescription_followup_id = models.ForeignKey(Prescription_followup,on_delete=models.CASCADE,null=True) quantity = models.IntegerField(default=0) days = models.IntegerField(default=0) times = models.IntegerField(default=0) + revoked = models.BooleanField(default=False) + revoked_date = models.DateField(null=True) + revoked_prescription = models.ForeignKey(Prescription_followup,on_delete=models.CASCADE,null=True,related_name="revoked_priscription") def __str__(self): return self.medicine_id.medicine_name - - -class Ambulance_request(models.Model): - user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) - date_request = models.DateTimeField() - start_date = models.DateField() - end_date = models.DateField(null=True, blank=True) - reason = models.CharField(max_length=50) - -class Hospital_admit(models.Model): - user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) - doctor_id = models.ForeignKey(Doctor, on_delete=models.CASCADE,null=True, blank=True) - hospital_doctor = models.CharField(max_length=100) - hospital_name = models.ForeignKey(Hospital,on_delete=models.CASCADE) - admission_date = models.DateField() - discharge_date = models.DateField(null=True, blank=True) - reason = models.CharField(max_length=50) - -class Announcements(models.Model): - anno_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='announcements_made') - ann_date = models.DateTimeField(default="04-04-2021") - message = models.CharField(max_length=200) - upload_announcement = models.FileField(upload_to='health_center/upload_announcement', null=True, default=" ") - def __str__(self): - return str(self.anno_id.user.username) - - -class SpecialRequest(models.Model): - request_ann_maker = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='special_requests_made') - request_date = models.DateTimeField(default=date.today) - brief = models.CharField(max_length=20, default='--') - request_details = models.CharField(max_length=200) - upload_request = models.FileField(blank=True) - status = models.CharField(max_length=50,default='Pending') - remarks = models.CharField(max_length=300, default="--") - request_receiver = models.CharField(max_length=30, default="--") - - def __str__(self): - return str(self.request_ann_maker.user.username) +class Required_tabel_last_updated(models.Model): + date=models.DateField() +class files(models.Model): + file_data = models.BinaryField() class medical_relief(models.Model): description = models.CharField(max_length=200) @@ -256,4 +185,5 @@ class MedicalProfile(models.Model): ] blood_type = models.CharField(max_length=3, choices=blood_type_choices) height = models.DecimalField(max_digits=5, decimal_places=2) - weight = models.DecimalField(max_digits=5, decimal_places=2) \ No newline at end of file + weight = models.DecimalField(max_digits=5, decimal_places=2) + diff --git a/FusionIIIT/applications/health_center/static/health_center/add_medicine_example.xlsx b/FusionIIIT/applications/health_center/static/health_center/add_medicine_example.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..a1a53eae29307614361e8df5ff1470ffebfd028f GIT binary patch literal 8915 zcmeHtg;$hY_y5q{F-S;vccY{l}DAEl|H%RjxeeeBw zulN4`g7-bM);Vj|dOmxd=bX=H?|t@pKq^Sc!~j$PIsgEm1z7FnJD4E=07=LI01*Hk z(OA~q4PxsCG1u|+umziP`MA2!JVQogDFPtEpZ{O`FJ6JFv?29w9(?)lir2DhoXT@` z577m8!}G^O76r1n-=8y7e_-W9}L;mZ`0I0@Ghj?Ve>9S%Fxxw$rmMfbL7VaJ8` zzt=UR5a#~Sx5L;0yqDr-WVl~MO!1KSp1FB~T`nNY^KG}5fZVdQauvA)38_@bYW_^0 z9>HR76Ly7BxoH1v=aRbK0)fcj%TM^LFrv>+j;#J>$E%!5$Z>T3bEHtSG7znSHmj9Z zlh>U9n0e&4UPvcHN zm(4;X4(6Q31rI}M!^WooAm_Mx(rP}p(ZHSuBqgdt2VFGtSB%RnY2i}Ri*VwhD3~+l6Lt8_ZKffbBBiL*{elLSR@Sc_-Flu+H ze^cClXKdX#eD5%0Gnnrd6#%%qLjr*QCd&q09{LkF*Hq!E!-C7w+{@Ml%+2+q|DPQH zi#7O{SFcJ@)9B{Gj@(zgj_UtDF`tAlqv9>C*g~rl6rwbT*N{-cKr!FJOo^{U9**=V zxGm^yTiH*)3g~yCJ-r~;)pihdtg$Na5~K4qw{dxYESK9sbQ8d- zp4YEM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zwaFVg0?`CxZn1Xeh2@x@cj!40PsEi z3I2b|;J@4Xy&C$_PFFXLiO#}e^O;vw~|1|{u8Qx6tC-@%$QCSWavbq4k PQ^?N`BHSKiKmPq6kg|tj literal 0 HcmV?d00001 diff --git a/FusionIIIT/applications/health_center/static/health_center/institute_logo.jpg b/FusionIIIT/applications/health_center/static/health_center/institute_logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..20c7be439ced7351281a509c7ab33905745a057c GIT binary patch literal 3527 zcmbW3cUV))w!kL@2u(Sm38KV8k&Y-JT}43fSm;fN1*92}gGfL~j-V6^9Hc2#5EP|E z5eYpa2r421(xQ-rA{`Qt7$9Na&AIR0`+e`PckkLW-(GuW)_m)?*PgXDGzihbZ?;x8 zRsaEu20{Y>hyhMn;{7iHaPlNj0{{pCK7<57!Wsg;K)gTT|62z@8NLI+_lWO*M-V2D zkpI^Io(0f1U;*!d*lhnJNCD)g2=enI1yF)0)MghF78Mo}5)ne7M7D^Ch>F3265cAl zMQrP)zPZV!`KA@z#Dq{nn=Ae^f!+YL5HJEpNW>n%hejaL2&ffcU@n18dISvjPeJe@ z`2_@FmqbM21+RaD-A5w%U}pvRVRS?^JP-KM0usCT9}$$aJCE8EBBgsHr9f!!(U;BA z_T5ay0~h{?5f+izCM&mHNm*r|s@g$4eS<@WMi$2`t*npR*g7~mIlH*JxnK15x#a8T z9}s#q>{>WJA~N>ot+@Dv#M}2%)6z3CA3V$|d|Xug(ii^d7Lidr$WUT!qWw+w z{{xHpugLxd_HQmK5JMv1;33h#9Pk7n5EDymw$dbQcbzo|_flq|;-bV0XO{6npD|(y z4y_8tedS-}2Orfu&>iw;C(Vit2tB!!b3CDY&Mt(7fUUpaPeyW8ISt=|8^s?ZBN!YS zhg}*`<<|1lp5|#yd|vBDW_pGe&0rMd>NZ(6_Io?sq}=nv(6d2$al8fk857+YN|Ug zXvJLh-tXV^Kb6|O?Z2mY^2n@!@p1*uFtyUdKX74Tp=&ahy}>KcTcoa!X=RTF^K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applications/health_center/urls.py index 2580313f9..982564fa2 100644 --- a/FusionIIIT/applications/health_center/urls.py +++ b/FusionIIIT/applications/health_center/urls.py @@ -7,10 +7,12 @@ urlpatterns = [ - #health_center home page + # health_center home page url(r'^$', healthcenter, name='healthcenter'), #views + url(r'^compounder/view_prescription/(?P[0-9]+)/$',compounder_view_prescription,name='view_prescription'), + url(r'^compounder/view_file/(?P[\w-]+)/$',view_file, name='view_file'), url(r'^compounder/$', compounder_view, name='compounder_view'), url(r'^student/$', student_view, name='student_view'), url(r'announcement/', announcement, name='announcement'), @@ -21,6 +23,6 @@ url(r'^doctor_entry', doctor_entry, name='doctor_entry'), url(r'^compounder_entry', compounder_entry, name='compounder_entry'), - #api - url(r'^api/',include('applications.health_center.api.urls')) + # #api + # url(r'^api/',include('applications.health_center.api.urls')) ] \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/utils.py b/FusionIIIT/applications/health_center/utils.py index 2b20c555d..220efea76 100644 --- a/FusionIIIT/applications/health_center/utils.py +++ b/FusionIIIT/applications/health_center/utils.py @@ -1,4 +1,7 @@ import json +import os +import pandas as pd +from django.db import transaction from datetime import datetime, timedelta,date from applications.globals.models import ExtraInfo from django.core import serializers @@ -6,13 +9,16 @@ from applications.globals.models import ExtraInfo, HoldsDesignation, Designation, DepartmentInfo from django.http import HttpResponse, JsonResponse from notification.views import healthcare_center_notif -from .models import (Ambulance_request, Appointment, Complaint, Doctor, - Expiry, Hospital, Hospital_admit, Medicine, - Prescribed_medicine, Prescription, Doctors_Schedule,Pathologist_Schedule, - Stock, Announcements, SpecialRequest, Pathologist, medical_relief, MedicalProfile) +from .models import ( Doctor, Stock_entry,Present_Stock,All_Medicine, + Doctors_Schedule,Pathologist_Schedule, + Pathologist, medical_relief, MedicalProfile,All_Prescription,All_Prescribed_medicine, + Prescription_followup,files,Required_medicine) from applications.filetracking.sdk.methods import * from django.core.exceptions import ObjectDoesNotExist from django.shortcuts import get_object_or_404 +from django.db.models import Q +from applications.globals.models import ExtraInfo +from applications.hr2.models import EmpDependents def datetime_handler(date): ''' @@ -27,9 +33,8 @@ def compounder_view_handler(request): ''' handles rendering of pages for compounder view ''' - # compounder response to patients feedback - if 'feed_com' in request.POST: + if 'feed_com' in request.POST: pk = request.POST.get('com_id') feedback = request.POST.get('feed') comp_id = ExtraInfo.objects.select_related('user','department').filter(user_type='compounder') @@ -117,26 +122,75 @@ def compounder_view_handler(request): return JsonResponse(data) elif 'add_stock' in request.POST: - medicine = request.POST.get('medicine_id') - threshold_a = request.POST.get('threshold_a') - medicine_name = Stock.objects.get(id=medicine) - qty = int(request.POST.get('quantity')) - supplier=request.POST.get('supplier') - expiry=request.POST.get('expiry_date') - Expiry.objects.create( - medicine_id=medicine_name, - quantity=qty, - supplier=supplier, - expiry_date=expiry, - date=datetime.now(), - ) - quantity = (Stock.objects.get(id=medicine)).quantity - quantity = quantity + qty - Stock.objects.filter(id=medicine).update(quantity=quantity) - Stock.objects.filter(id=medicine).update(threshold=threshold_a) - data = {'status': 1} - return JsonResponse(data) - + try: + medicine = request.POST.get('medicine_id') + # threshold_a = request.POST.get('threshold_a') + med_brand_name = medicine.split(',')[0] + id = medicine.split(',')[1] + medicine_id = All_Medicine.objects.get(id = id) + qty = int(request.POST.get('quantity')) + supplier=request.POST.get('supplier') + expiry=request.POST.get('expiry_date') + tot_rows = Stock_entry.objects.all().count() + tot_rows1 = Present_Stock.objects.all().count() + stk=Stock_entry.objects.create( + id = tot_rows+1, + quantity=qty, + medicine_id=medicine_id, + supplier=supplier, + Expiry_date=expiry, + date=date.today() + ) + Present_Stock.objects.create( + id = tot_rows1+1, + quantity=qty, + stock_id=stk, + medicine_id=medicine_id, + Expiry_date=expiry + ) + if Required_medicine.objects.filter(medicine_id = medicine_id).exists(): + req=Required_medicine.objects.get(medicine_id = medicine_id) + req.quantity+=qty + if(req.quantity Req.threshold : + Req.delete() + else : Req.save() + else : + medicine_stock = Present_Stock.objects.filter(Q(medicine_id = threshold_med) & Q(Expiry_date__gt = date.today())) + qty=0 + for med in medicine_stock: + qty+=med.quantity + if qty < threshold_med.threshold : + Required_medicine.objects.create( + medicine_id = threshold_med, + quantity = qty, + threshold = threshold_med.threshold + ) + status=1 + except: + status=0 + finally: + data={'status':status} + return JsonResponse(data) # edit schedule for doctors elif 'edit_1' in request.POST: doctor = request.POST.get('doctor') @@ -199,27 +253,40 @@ def compounder_view_handler(request): elif 'add_medicine' in request.POST: medicine = request.POST.get('new_medicine') - quantity = request.POST.get('new_quantity') + # quantity = request.POST.get('new_quantity') threshold = request.POST.get('threshold') - new_supplier = request.POST.get('new_supplier') - new_expiry_date = request.POST.get('new_expiry_date') - Stock.objects.create( + brand_name = request.POST.get('brand_name') + constituents = request.POST.get('constituents') + manufacture_name = request.POST.get('manufacture_name') + packsize = request.POST.get('packsize') + # new_supplier = request.POST.get('new_supplier') + # new_expiry_date = request.POST.get('new_expiry_date') + tot_rows = All_Medicine.objects.all().count() + All_Medicine.objects.create( + id = tot_rows+1, medicine_name=medicine, - quantity=quantity, - threshold=threshold + brand_name=brand_name, + constituents=constituents, + threshold=threshold, + manufacturer_name=manufacture_name, + pack_size_label=packsize ) - medicine_id = Stock.objects.get(medicine_name=medicine) - Expiry.objects.create( - medicine_id=medicine_id, - quantity=quantity, - supplier=new_supplier, - expiry_date=new_expiry_date, - returned=False, - return_date=None, - date=datetime.now() - ) - data = {'medicine': medicine, 'quantity': quantity, 'threshold': threshold, - 'new_supplier': new_supplier, 'new_expiry_date': new_expiry_date } + # Stock.objects.create( + # medicine_name=medicine, + # quantity=quantity, + # threshold=threshold + # ) + # medicine_id = Stock.objects.get(medicine_name=medicine) + # Expiry.objects.create( + # medicine_id=medicine_id, + # quantity=quantity, + # supplier=new_supplier, + # expiry_date=new_expiry_date, + # returned=False, + # return_date=None, + # date=datetime.now() + # ) + data = {'medicine': medicine, 'threshold': threshold,} return JsonResponse(data) elif 'admission' in request.POST: @@ -245,63 +312,97 @@ def compounder_view_handler(request): data={'status':1} return JsonResponse(data) - elif 'medicine_name' in request.POST: - app = request.POST.get('user') - user = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').get(id=app).user_id - quantity = int(request.POST.get('quantity')) - days = int(request.POST.get('days')) - times = int(request.POST.get('times')) - medicine_id = request.POST.get('medicine_name') - medicine = Stock.objects.get(id=medicine_id) - Medicine.objects.create( - patient=user, - medicine_id=medicine, - quantity=quantity, - days=days, - times=times - ) - user_medicine = Medicine.objects.filter(patient=user) - list = [] - for med in user_medicine: - list.append({'medicine': med.medicine_id.medicine_name, 'quantity': med.quantity, - 'days': med.days, 'times': med.times}) - sches = json.dumps(list, default=datetime_handler) - return HttpResponse(sches, content_type='json') - + # elif 'medicine_name' in request.POST: + # app = request.POST.get('user') + # user = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').get(id=app).user_id + # quantity = int(request.POST.get('quantity')) + # days = int(request.POST.get('days')) + # times = int(request.POST.get('times')) + # medicine_id = request.POST.get('medicine_name') + # medicine = Stock.objects.get(id=medicine_id) + # Medicine.objects.create( + # patient=user, + # medicine_id=medicine, + # quantity=quantity, + # days=days, + # times=times + # ) + # user_medicine = Medicine.objects.filter(patient=user) + # list = [] + # for med in user_medicine: + # list.append({'medicine': med.medicine_id.medicine_name, 'quantity': med.quantity, + # 'days': med.days, 'times': med.times}) + # sches = json.dumps(list, default=datetime_handler) + # return HttpResponse(sches, content_type='json') + elif 'get_stock' in request.POST: + try: + medicine_name_and_id = request.POST.get('medicine_name_for_stock') + medicine_name = medicine_name_and_id.split(",")[0] + id=0 + if(len(medicine_name_and_id.split(",")) > 1) : + id=medicine_name_and_id.split(",")[1] + if id == 0: + status=1 + similar_name_qs = All_Medicine.objects.filter(brand_name__istartswith=medicine_name)[:10] + else : + status=2 + similar_name_qs = All_Medicine.objects.filter(id=id) + similar_name = list(similar_name_qs.values('id', 'medicine_name','constituents','manufacturer_name','pack_size_label','brand_name','threshold')) + val_to_return = [] + + try: + med = All_Medicine.objects.get(id = id) + stk = Stock_entry.objects.filter(medicine_id=med).order_by('Expiry_date') + for s in stk: + if s.Expiry_date > date.today(): + obj = {} + obj['brand_name'] = s.medicine_id.brand_name + obj['supplier'] = s.supplier + obj['expiry'] = s.Expiry_date + p_s = Present_Stock.objects.get(stock_id=s) + if p_s.quantity > 0: + obj['quantity'] = p_s.quantity + obj['id'] = p_s.id + val_to_return.append(obj) + except All_Medicine.DoesNotExist: + val_to_return = [] + except Present_Stock.DoesNotExist: + val_to_return = [] + except Exception as e: + val_to_return = [] + finally: + return JsonResponse({"val": val_to_return, "sim": similar_name, "status": status}) elif 'medicine_name_b' in request.POST: user_id = request.POST.get('user') - user = ExtraInfo.objects.select_related('user','department').get(id=user_id) + if not User.objects.filter(username__iexact = user_id).exists(): + return JsonResponse({"status":-2}) quantity = int(request.POST.get('quantity')) days = int(request.POST.get('days')) times = int(request.POST.get('times')) medicine_id = request.POST.get('medicine_name_b') - medicine = Stock.objects.get(id=medicine_id) - Medicine.objects.create( - patient=user, - medicine_id=medicine, - quantity=quantity, - days=days, - times=times - ) - schs = Medicine.objects.filter(patient=user) - list = [] - for s in schs: - list.append({'medicine': s.medicine_id.medicine_name, 'quantity': s.quantity, - 'days': s.days, 'times': s.times}) - sches = json.dumps(list, default=datetime_handler) - return HttpResponse(sches, content_type='json') + stock = request.POST.get('stock') + medicine_brand_name = medicine_id.split(",")[0] + id= medicine_id.split(",")[1] + med_name = All_Medicine.objects.get(id=id).brand_name + if(stock == "" or stock == "N/A at moment") : + return JsonResponse({"status":1,"med_name":med_name,"id":id}) + stk=stock.split(",") + qty = int(stk[2]) + status=1 + if quantity>qty : status=0 + return JsonResponse({"status":status,"med_name":med_name,"id":id}) - elif 'doct' in request.POST: - doctor_id = request.POST.get('doct') - schedule = Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id) - list = [] - for s in schedule: - list.append({'room': s.room, 'id': s.id, 'doctor': s.doctor_id.doctor_name, - 'day': s.get_day_display(), 'from_time': s.from_time, - 'to_time': s.to_time}) - - sches = json.dumps(list, default=datetime_handler) - return HttpResponse(sches, content_type='json') + # elif 'doct' in request.POST: + # doctor_id = request.POST.get('doct') + # schedule = Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id) + # list = [] + # for s in schedule: + # list.append({'room': s.room, 'id': s.id, 'doctor': s.doctor_id.doctor_name, + # 'day': s.get_day_display(), 'from_time': s.from_time, + # 'to_time': s.to_time}) + + # sches = json.dumps(list, default=datetime_handler) + # return HttpResponse(sches, content_type='json') elif 'prescribe' in request.POST: app_id = request.POST.get('user') @@ -361,92 +462,354 @@ def compounder_view_handler(request): healthcare_center_notif(request.user, user.user, 'presc','') data = {'status': status, 'stock': stock} return JsonResponse(data) + elif 'user_for_dependents' in request.POST: + user = request.POST.get('user_for_dependents') + if not User.objects.filter(username__iexact = user).exists(): + return JsonResponse({"status":-1}) + user_id = User.objects.get(username__iexact = user) + info = ExtraInfo.objects.get(user = user_id) + dep_info = EmpDependents.objects.filter(extra_info = info) + dep=[] + for d in dep_info: + obj={} + obj['name'] = d.name + obj['relation'] = d.relationship + dep.append(obj) + if(len(dep) == 0) : + return JsonResponse({'status':-2}) + return JsonResponse({'status':1,'dep':dep}) elif 'prescribe_b' in request.POST: user_id = request.POST.get('user') - user = ExtraInfo.objects.select_related('user','department').get(id=user_id) doctor_id = request.POST.get('doctor') - if doctor_id == "": + if not User.objects.filter(username__iexact = user_id).exists(): + return JsonResponse({"status":-1}) + if doctor_id == 'null' : doctor = None else: doctor = Doctor.objects.get(id=doctor_id) - details = request.POST.get('details') - tests = request.POST.get('tests') - # app = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(user_id=user_id,date=datetime.now()) - # if app: - # appointment = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').get(user_id=user_id,date=datetime.now()) - # else: - # appointment = None - designation=request.POST.get('user') - uploaded_file = request.FILES.get('file') - d = HoldsDesignation.objects.get(user__username=designation) - form_object=Prescription( - user_id=user, - doctor_id=doctor, - details=details, - date=datetime.now(), - test=tests, - # appointment=appointment - ) - form_object.save() - request_object = Prescription.objects.get(pk=form_object.pk) - send_file_id = create_file( - uploader=request.user.username, - uploader_designation=request.session['currentDesignationSelected'], - receiver=designation, - receiver_designation=d.designation, - src_module="health_center", - src_object_id=str(request_object.id), - file_extra_JSON={"value": 2}, - attached_file=uploaded_file - ) - request_object.file_id=send_file_id - request_object.save() + - query = Medicine.objects.select_related('patient','patient__user','patient__department').filter(patient=user) - prescribe = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().last() - for medicine in query: - medicine_id = medicine.medicine_id - quantity = medicine.quantity - days = medicine.days - times = medicine.times - Prescribed_medicine.objects.create( - prescription_id=prescribe, - medicine_id=medicine_id, - quantity=quantity, - days=days, - times=times + is_dependent=request.POST.get('is_dependent') + fid=0 + uploaded_file = request.FILES.get('file') + if uploaded_file != None : + f=uploaded_file.read() + new_file=files.objects.create( + file_data=f ) - today=datetime.now() - expiry=Expiry.objects.select_related('medicine_id').filter(medicine_id=medicine_id,quantity__gt=0,returned=False,expiry_date__gte=today).order_by('expiry_date') - stock=Stock.objects.get(medicine_name=medicine_id).quantity - if stock>quantity: - for e in expiry: - q=e.quantity - em=e.id - if q>quantity: - q=q-quantity - Expiry.objects.select_related('medicine_id').filter(id=em).update(quantity=q) - qty = Stock.objects.get(medicine_name=medicine_id).quantity - qty = qty-quantity - Stock.objects.filter(medicine_name=medicine_id).update(quantity=qty) - break - else: - quan=Expiry.objects.select_related('medicine_id').get(id=em).quantity - Expiry.objects.select_related('medicine_id').filter(id=em).update(quantity=0) - qty = Stock.objects.get(medicine_name=medicine_id).quantity - qty = qty-quan - Stock.objects.filter(medicine_name=medicine_id).update(quantity=qty) - quantity=quantity-quan - status = 1 + fid=new_file.id + # with open(uploaded_file.name, 'wb+') as destination: + # destination.write(f) + if is_dependent == "self": + pres=All_Prescription.objects.create( + user_id = user_id, + doctor_id=doctor, + details = request.POST.get('details'), + date=date.today(), + test=request.POST.get('tests'), + file_id=fid + ) + else : + pres=All_Prescription.objects.create( + user_id = user_id, + doctor_id=doctor, + details = request.POST.get('details'), + date=date.today(), + test=request.POST.get('tests'), + is_dependent = True, + dependent_name = request.POST.get('dependent_name'), + dependent_relation = request.POST.get('dependent_relation'), + file_id=fid + ) + # designation=request.POST.get('user') + # d = HoldsDesignation.objects.get(user__username=designation) + # send_file_id = create_file( + # uploader=request.user.username, + # uploader_designation=request.session['currentDesignationSelected'], + # receiver=designation, + # receiver_designation=d.designation, + # src_module="health_center", + # src_object_id=str(pres.id), + # file_extra_JSON={"value": 2}, + # attached_file=uploaded_file + # ) + # pres.file_id=send_file_id + # pres.save() - else: - status = 0 - Medicine.objects.select_related('patient','patient__user','patient__department').all().delete() + pre_medicine = request.POST.get('pre_medicine') + + medicine=eval('('+pre_medicine+')') + + for med in medicine: + med_name = med["brand_name"] + id=med_name.split(",")[1] + quant = int(med['quantity']) + days = med['Days'] + times = med['Times'] + stock = med['stock'] + med_id = All_Medicine.objects.get(id=id) + if(stock == "," or stock == 'N/A at moment,') : + All_Prescribed_medicine.objects.create( + prescription_id = pres, + medicine_id = med_id, + quantity = quant, + days = days, + times=times + ) + else : + stk = stock.split(",") + p_stock = Present_Stock.objects.get(id=int(stk[2])) + All_Prescribed_medicine.objects.create( + prescription_id = pres, + medicine_id = med_id, + stock = p_stock, + quantity = quant, + days = days, + times=times + ) + p_stock.quantity -= quant + p_stock.save() + stock_of_medicine = Present_Stock.objects.filter(Q(medicine_id = med_id) & Q( Expiry_date__gt = date.today())) + qty=0 + for stk in stock_of_medicine : + qty+=stk.quantity + + if qtyquantity: + # for e in expiry: + # q=e.quantity + # em=e.id + # if q>quantity: + # q=q-quantity + # Expiry.objects.select_related('medicine_id').filter(id=em).update(quantity=q) + # qty = Stock.objects.get(medicine_name=medicine_id).quantity + # qty = qty-quantity + # Stock.objects.filter(medicine_name=medicine_id).update(quantity=qty) + # break + # else: + # quan=Expiry.objects.select_related('medicine_id').get(id=em).quantity + # Expiry.objects.select_related('medicine_id').filter(id=em).update(quantity=0) + # qty = Stock.objects.get(medicine_name=medicine_id).quantity + # qty = qty-quan + # Stock.objects.filter(medicine_name=medicine_id).update(quantity=qty) + # quantity=quantity-quan + # status = 1 + + # else: + # status = 0 + # Medicine.objects.select_related('patient','patient__user','patient__department').all().delete() - healthcare_center_notif(request.user, user.user, 'presc','') - data = {'status': status} - return JsonResponse(data) + # healthcare_center_notif(request.user, user.user, 'presc','') + # data = {'status': status} + # return JsonResponse(data) + return JsonResponse({"status":1}) + + elif 'presc_followup' in request.POST: + pre_id=request.POST.get("pre_id") + presc = All_Prescription.objects.get(id=int(pre_id)) + + doctor_id = request.POST.get('doctor') + if doctor_id == "null": + doctor = None + else: + doctor = Doctor.objects.get(id=doctor_id) + + fid=0 + uploaded_file = request.FILES.get('file') + if uploaded_file != None : + f=uploaded_file.read() + new_file=files.objects.create( + file_data=f + ) + fid=new_file.id + + followup = Prescription_followup.objects.create( + prescription_id=presc, + Doctor_id=doctor, + details = request.POST.get('details'), + test = request.POST.get('tests'), + date = date.today(), + file_id = fid + ) + + pre_medicine = request.POST.get('pre_medicine') + + medicine=eval('('+pre_medicine+')') + for med in medicine: + med_name = med["med_name"] + id = med_name.split(',')[1] + quant = int(med['quantity']) + days = med['Days'] + times = med['Times'] + stock = med['stock'] + med_id = All_Medicine.objects.get(id = id) + if(stock == ',' or stock == "N/A at moment,"): + All_Prescribed_medicine.objects.create( + prescription_id = presc, + medicine_id = med_id, + quantity = quant, + days = days, + times=times, + prescription_followup_id = followup + ) + else : + stk = stock.split(",") + p_stock = Present_Stock.objects.get(id=int(stk[2])) + All_Prescribed_medicine.objects.create( + prescription_id = presc, + medicine_id = med_id, + stock = p_stock, + quantity = quant, + days = days, + times=times, + prescription_followup_id = followup + ) + p_stock.quantity -= quant + p_stock.save() + stock_of_medicine = Present_Stock.objects.filter(Q(medicine_id = med_id) & Q(Expiry_date__gt = date.today())) + qty=0 + for stk in stock_of_medicine : + qty+=stk.quantity + + if qty 1, + 'has_next': new_current_page < total_pages, + 'previous_page_number': new_current_page - 1 if new_current_page > 1 else None, + 'next_page_number': new_current_page + 1 if new_current_page < total_pages else None, + }) + elif 'datatype' in request.POST and request.POST['datatype'] == 'manage_stock_view': + search = request.POST.get('search_view_stock') + page_size_stock = 2 + new_current_page_stock = int(request.POST.get('page_stock_view')) + new_offset_stock = (new_current_page_stock - 1) * page_size_stock + new_live_meds = [] + new_live =Stock_entry.objects.filter(Q(Expiry_date__gte=date.today()) & Q( Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).order_by('Expiry_date')[new_offset_stock:new_offset_stock + page_size_stock] + total_pages_stock = ( Stock_entry.objects.filter(Q(Expiry_date__gte=date.today()) & Q( Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).count() + page_size_stock - 1) // page_size_stock + for e in new_live: + obj={} + obj['id']=e.id + obj['medicine_id']=e.medicine_id.brand_name + obj['Expiry_date']=e.Expiry_date + obj['supplier']=e.supplier + try: + qty=Present_Stock.objects.get(stock_id=e).quantity + except: + qty=0 + obj['quantity']=qty + new_live_meds.append(obj) + return JsonResponse({ + 'report_stock_view': new_live_meds, + 'page_stock_view': new_current_page_stock, + 'total_pages_stock_view': total_pages_stock, + 'has_previous': new_current_page_stock > 1, + 'has_next': new_current_page_stock < total_pages_stock, + 'previous_page_number': new_current_page_stock - 1 if new_current_page_stock > 1 else None, + 'next_page_number': new_current_page_stock + 1 if new_current_page_stock < total_pages_stock else None, + }) + elif 'datatype' in request.POST and request.POST['datatype'] == 'manage_stock_expired': + search = request.POST.get('search_view_expired') + new_page_size_stock_expired = 2 + new_current_page_stock_expired = int(request.POST.get('page_stock_expired')) + new_offset_stock_expired = (new_current_page_stock_expired - 1 )* new_page_size_stock_expired + new_expired=[] + new_expiredData=Stock_entry.objects.filter(Q(Expiry_date__lt=date.today())&Q( Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).order_by('Expiry_date')[new_offset_stock_expired:new_offset_stock_expired + new_page_size_stock_expired] + new_total_pages_stock_expired = ( Stock_entry.objects.filter(Q(Expiry_date__lt=date.today())&Q( Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).count() + new_page_size_stock_expired - 1) // new_page_size_stock_expired + for e in new_expiredData: + obj={} + obj['medicine_id']=e.medicine_id.brand_name + obj['Expiry_date']=e.Expiry_date + obj['supplier']=e.supplier + try: + qty=Present_Stock.objects.get(stock_id=e).quantity + except: + qty=0 + obj['quantity']=qty + new_expired.append(obj) + return JsonResponse({ + 'report_stock_expired': new_expired, + 'page_stock_expired': new_current_page_stock_expired, + 'total_pages_stock_view': new_total_pages_stock_expired, + 'has_previous': new_current_page_stock_expired > 1, + 'has_next': new_current_page_stock_expired < new_total_pages_stock_expired, + 'previous_page_number': new_current_page_stock_expired - 1 if new_current_page_stock_expired > 1 else None, + 'next_page_number': new_current_page_stock_expired + 1 if new_current_page_stock_expired < new_total_pages_stock_expired else None, + }) + elif 'datatype' in request.POST and request.POST['datatype'] == 'manage_stock_required': + search = request.POST.get('search_view_required') + new_page_size_stock_required = 2 + new_current_page_stock_required = int(request.POST.get('page_stock_required')) + new_offset_stock_required = (new_current_page_stock_required - 1 )* new_page_size_stock_required + new_required=[] + new_requiredData=Required_medicine.objects.filter( Q(medicine_id__brand_name__icontains = search))[new_offset_stock_required:new_offset_stock_required + new_page_size_stock_required] + new_total_pages_stock_required = (Required_medicine.objects.filter( Q(medicine_id__brand_name__icontains = search)).count() + new_page_size_stock_required - 1) // new_page_size_stock_required + for e in new_requiredData: + obj={} + obj['medicine_id']=e.medicine_id.brand_name + obj['quantity']=e.quantity + obj['threshold']=e.threshold + new_required.append(obj) + return JsonResponse({ + 'report_stock_required': new_required, + 'page_stock_required': new_current_page_stock_required, + 'total_pages_stock_required': new_total_pages_stock_required, + 'has_previous': new_current_page_stock_required > 1, + 'has_next': new_current_page_stock_required < new_total_pages_stock_required, + 'previous_page_number': new_current_page_stock_required - 1 if new_current_page_stock_required > 1 else None, + 'next_page_number': new_current_page_stock_required + 1 if new_current_page_stock_required < new_total_pages_stock_required else None, + }) + + elif 'search_patientlog' in request.POST: + search = request.POST.get('search_patientlog') + current_page = 1 + page_size_prescription = 2 # Default to 2 if not specified + offset = (current_page - 1) * page_size_prescription + prescriptions = All_Prescription.objects.filter(Q(user_id__icontains = search) | Q(details__icontains = search)).order_by('-date', '-id')[offset:offset + page_size_prescription] + + report = [] + for pre in prescriptions: + doc = None + if pre.doctor_id != None : doc=pre.doctor_id.doctor_name + dic = { + 'id': pre.pk, + 'user_id': pre.user_id, + 'doctor_id': doc, + 'date': pre.date, + 'details': pre.details, + 'test': pre.test, + 'file_id': pre.file_id, + # 'file': view_file(file_id=pre.file_id)['upload_file'] if pre.file_id else None + } + report.append(dic) + # Handle total count for pagination context + total_count = All_Prescription.objects.filter(Q(user_id__icontains = search) | Q(details__icontains = search)).count() + # Calculate total number of pages + total_pages = (total_count + page_size_prescription - 1) // page_size_prescription # This ensures rounding up + prescContext = { + 'count': total_pages, + 'page': { + 'object_list': report, + 'number': current_page, + 'has_previous': current_page > 1, + 'has_next': current_page < total_pages, + 'previous_page_number': current_page - 1 if current_page > 1 else None, + 'next_page_number': current_page + 1 if current_page < total_pages else None, + } + } + return JsonResponse({'status':1,"presc_context":prescContext}) + elif 'search_view_stock' in request.POST: + search = request.POST.get('search_view_stock') + current_page_stock = 1 + page_size_stock = 2 + offset_stock = (current_page_stock - 1 )* page_size_stock + live_meds=[] + live=Stock_entry.objects.filter(Q(Expiry_date__gte=date.today()) & Q( Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).order_by('Expiry_date')[offset_stock:offset_stock + page_size_stock] + total_pages_stock = ( Stock_entry.objects.filter(Q(Expiry_date__gte=date.today()) & Q(Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).count() + page_size_stock - 1) // page_size_stock + for e in live: + obj={} + obj['id']=e.id + obj['medicine_id']=e.medicine_id.brand_name + obj['Expiry_date']=e.Expiry_date + obj['supplier']=e.supplier + try: + qty=Present_Stock.objects.get(stock_id=e).quantity + except: + qty=0 + obj['quantity']=qty + live_meds.append(obj) + stockContext = { + 'count_stock_view':total_pages_stock, + 'page_stock_view':{ + 'object_list': live_meds, + 'number': current_page_stock, + 'has_previous': current_page_stock > 1, + 'has_next': current_page_stock < total_pages_stock, + 'previous_page_number': current_page_stock - 1 if current_page_stock > 1 else None, + 'next_page_number': current_page_stock + 1 if current_page_stock < total_pages_stock else None, + } + } + return JsonResponse({'status':1,'stock_context':stockContext}) + elif 'search_view_expired' in request.POST: + search = request.POST.get('search_view_expired') + current_page_stock_expired = 1 + page_size_stock_expired = 2 + offset_stock_expired = (current_page_stock_expired - 1 )* page_size_stock_expired + expired=[] + expiredData=Stock_entry.objects.filter(Q(Expiry_date__lt=date.today())&Q( Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).order_by('Expiry_date')[offset_stock_expired:offset_stock_expired + page_size_stock_expired] + total_pages_stock_expired = ( Stock_entry.objects.filter(Q(Expiry_date__lt=date.today())&Q( Q(medicine_id__brand_name__icontains = search) | Q(supplier__icontains = search))).count() + page_size_stock_expired - 1) // page_size_stock_expired + for e in expiredData: + obj={} + obj['medicine_id']=e.medicine_id.brand_name + obj['Expiry_date']=e.Expiry_date + obj['supplier']=e.supplier + try: + qty=Present_Stock.objects.get(stock_id=e).quantity + except: + qty=0 + obj['quantity']=qty + expired.append(obj) + ExpiredstockContext = { + 'count_stock_expired':total_pages_stock_expired, + 'page_stock_expired':{ + 'object_list': expired, + 'number': current_page_stock_expired, + 'has_previous': current_page_stock_expired > 1, + 'has_next': current_page_stock_expired < total_pages_stock_expired, + 'previous_page_number': current_page_stock_expired - 1 if current_page_stock_expired > 1 else None, + 'next_page_number': current_page_stock_expired + 1 if current_page_stock_expired < total_pages_stock_expired else None, + } + } + return JsonResponse({'status':1,'expired_context':ExpiredstockContext}) + elif 'search_view_required' in request.POST: + search = request.POST.get('search_view_required') + current_required_page = 1 + page_size_required = 2 + offset_stock_required = (current_required_page - 1 )* page_size_required + required_data = Required_medicine.objects.filter( Q(medicine_id__brand_name__icontains = search) )[offset_stock_required:offset_stock_required + page_size_required] + total_pages_stock_required = (Required_medicine.objects.filter( Q(medicine_id__brand_name__icontains = search) ).count() + page_size_required -1) // page_size_required + required=[] + for e in required_data: + obj={} + obj['medicine_id']=e.medicine_id.brand_name + obj['quantity']=e.quantity + obj['threshold'] = e.threshold + required.append(obj) + stocks = { + "count_stock_required" : total_pages_stock_required, + "page_stock_required":{ + "object_list":required, + 'number' : current_required_page, + 'has_previous' : current_required_page > 1 , + 'has_next': current_required_page < total_pages_stock_required, + 'previous_page_number' : current_required_page - 1 if current_required_page > 1 else None, + 'next_page_number' : current_required_page + 1 if current_required_page < total_pages_stock_required else None, + } + } + return JsonResponse({'status':1,'stocks':stocks}) def student_view_handler(request): if 'amb_submit' in request.POST: diff --git a/FusionIIIT/applications/health_center/views.py b/FusionIIIT/applications/health_center/views.py index 4d8881496..a178a9d68 100644 --- a/FusionIIIT/applications/health_center/views.py +++ b/FusionIIIT/applications/health_center/views.py @@ -1,4 +1,6 @@ import json +import pandas as pd +from django.http import FileResponse,Http404 from datetime import date, datetime, timedelta, time import xlrd import os @@ -7,17 +9,18 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.core import serializers -from django.core.paginator import Paginator +from django.core.paginator import EmptyPage from django.http import HttpResponse, HttpResponseRedirect, JsonResponse from django.shortcuts import get_object_or_404, render, redirect from notification.views import healthcare_center_notif -from applications.health_center.api.serializers import MedicalReliefSerializer -from .models import (Ambulance_request, Appointment, Complaint, Constants, - Counter, Doctor,Pathologist, Expiry, Hospital, Hospital_admit, - Medicine, Prescribed_medicine, Prescription, Doctors_Schedule,Pathologist_Schedule, - Stock,SpecialRequest,Announcements,medical_relief,MedicalProfile) +# from applications.health_center.api.serializers import MedicalReliefSerializer +from .models import ( Constants,All_Medicine,All_Prescribed_medicine,All_Prescription,Prescription_followup, + Present_Stock,Doctor,Pathologist, + Doctors_Schedule,Pathologist_Schedule,Stock_entry, + medical_relief,MedicalProfile,Required_medicine,files,Required_tabel_last_updated) from .utils import datetime_handler, compounder_view_handler, student_view_handler from applications.filetracking.sdk.methods import * +from django.db.models import Q @@ -75,52 +78,190 @@ def compounder_view(request): else: notifs = request.user.notifications.all() - all_complaints = Complaint.objects.select_related('user_id','user_id__user','user_id__department').all() - all_hospitals = Hospital_admit.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().order_by('-admission_date') - hospitals_list = Hospital.objects.all().order_by('hospital_name') - all_ambulances = Ambulance_request.objects.select_related('user_id','user_id__user','user_id__department').all().order_by('-date_request') - appointments_today =Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(date=datetime.now()).order_by('date') - appointments_future=Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(date__gt=datetime.now()).order_by('date') + # all_complaints = Complaint.objects.select_related('user_id','user_id__user','user_id__department').all() + # all_hospitals = Hospital_admit.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().order_by('-admission_date') + # hospitals_list = Hospital.objects.all().order_by('hospital_name') + # all_ambulances = Ambulance_request.objects.select_related('user_id','user_id__user','user_id__department').all().order_by('-date_request') + # appointments_today =Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(date=datetime.now()).order_by('date') + # appointments_future=Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(date__gt=datetime.now()).order_by('date') users = ExtraInfo.objects.select_related('user','department').filter(user_type='student') - stocks = Stock.objects.all() - days = Constants.DAYS_OF_WEEK schedule=Doctors_Schedule.objects.select_related('doctor_id').all().order_by('doctor_id') schedule1=Pathologist_Schedule.objects.select_related('pathologist_id').all().order_by('pathologist_id') - expired=Expiry.objects.select_related('medicine_id').filter(expiry_date__lt=datetime.now(),returned=False).order_by('expiry_date') - live_meds=Expiry.objects.select_related('medicine_id').filter(returned=False).order_by('quantity') - count=Counter.objects.all() - announcements_data=Announcements.objects.all().values() + # expired=Expiry.objects.select_related('medicine_id').filter(expiry_date__lt=datetime.now(),returned=False).order_by('expiry_date') + # live_meds=Expiry.objects.select_related('medicine_id').filter(returned=False).order_by('quantity') + page_size=2 + fir=Required_tabel_last_updated.objects.first() + if fir == None: + exp = Stock_entry.objects.filter(Expiry_date__lt = date.today()) + for e in exp: + med=e.medicine_id + p_s = Present_Stock.objects.filter(Q(medicine_id = med) & Q(Expiry_date__gte = date.today())) + qty=0 + for ps in p_s: + qty+=ps.quantity + if Required_medicine.objects.filter(medicine_id=med).exists() : + req=Required_medicine.objects.get(medicine_id=med) + if qty>=med.threshold : req.delete() + else : + req.quantity = qty + req.save() + else : + if qtymed.threshold) : req.delete() + else : + req.quantity = qty + req.save() + else : + if qty 1 , + 'has_next': current_required_page < total_pages_stock_required, + 'previous_page_number' : current_required_page - 1 if current_required_page > 1 else None, + 'next_page_number' : current_required_page + 1 if current_required_page < total_pages_stock_required else None, + } + } + + current_page_stock_expired = 1 + page_size_stock_expired = page_size + offset_stock_expired = (current_page_stock_expired - 1 )* page_size_stock_expired + expired=[] + expiredData=Stock_entry.objects.filter(Expiry_date__lt=date.today()).order_by('Expiry_date')[offset_stock_expired:offset_stock_expired + page_size_stock_expired] + total_pages_stock_expired = ( Stock_entry.objects.filter(Expiry_date__lt=date.today()).count() + page_size_stock_expired - 1) // page_size_stock_expired + for e in expiredData: + obj={} + obj['medicine_id']=e.medicine_id.brand_name + obj['Expiry_date']=e.Expiry_date + obj['supplier']=e.supplier + try: + qty=Present_Stock.objects.get(stock_id=e).quantity + except: + qty=0 + obj['quantity']=qty + expired.append(obj) + ExpiredstockContext = { + 'count_stock_expired':total_pages_stock_expired, + 'page_stock_expired':{ + 'object_list': expired, + 'number': current_page_stock_expired, + 'has_previous': current_page_stock_expired > 1, + 'has_next': current_page_stock_expired < total_pages_stock_expired, + 'previous_page_number': current_page_stock_expired - 1 if current_page_stock_expired > 1 else None, + 'next_page_number': current_page_stock_expired + 1 if current_page_stock_expired < total_pages_stock_expired else None, + } + } + + + current_page_stock = 1 + page_size_stock = page_size + offset_stock = (current_page_stock - 1 )* page_size_stock + live_meds=[] + live=Stock_entry.objects.filter(Expiry_date__gte=date.today()).order_by('Expiry_date')[offset_stock:offset_stock + page_size_stock] + total_pages_stock = ( Stock_entry.objects.filter(Expiry_date__gte=date.today()).count() + page_size_stock - 1) // page_size_stock + for e in live: + obj={} + obj['id']=e.id + obj['medicine_id']=e.medicine_id.brand_name + obj['Expiry_date']=e.Expiry_date + obj['supplier']=e.supplier + try: + qty=Present_Stock.objects.get(stock_id=e).quantity + except: + qty=0 + obj['quantity']=qty + live_meds.append(obj) + stockContext = { + 'count_stock_view':total_pages_stock, + 'page_stock_view':{ + 'object_list': live_meds, + 'number': current_page_stock, + 'has_previous': current_page_stock > 1, + 'has_next': current_page_stock < total_pages_stock, + 'previous_page_number': current_page_stock - 1 if current_page_stock > 1 else None, + 'next_page_number': current_page_stock + 1 if current_page_stock < total_pages_stock else None, + } + } + - medicines_presc=Prescribed_medicine.objects.select_related('prescription_id','prescription_id__user_id','prescription_id__user_id__user','prescription_id__user_id__department','prescription_id__doctor_id').all() - print(medicines_presc) - if count: - Counter.objects.all().delete() - Counter.objects.create(count=0,fine=0) - count=Counter.objects.get() - hospitals=Hospital.objects.all() schedule=Doctors_Schedule.objects.select_related('doctor_id').all().order_by('day','doctor_id') schedule1=Pathologist_Schedule.objects.select_related('pathologist_id').all().order_by('day','pathologist_id') doctors=Doctor.objects.filter(active=True).order_by('id') pathologists=Pathologist.objects.filter(active=True).order_by('id') - prescription= Prescription.objects.all() - report=[] - for pre in prescription: - dic={} - dic['id']=pre.pk - dic['user_id']=pre.user_id_id - dic['doctor_id'] = pre.doctor_id # Use dot notation - dic['date'] = pre.date # Use dot notation - dic['details'] = pre.details # Use dot notation - dic['test'] = pre.test # Use dot notation - if pre.file_id: - dic['file'] = view_file(file_id=pre.file_id)['upload_file'] - else: - dic['file']=None + medicine_presc = All_Prescribed_medicine.objects.all() + + #Logic for the padination and view prescriptions is below , used ajax for pagination + current_page = 1 + page_size_prescription = page_size # Default to 2 if not specified + offset = (current_page - 1) * page_size_prescription + # Fetch the prescriptions with limit and offset + prescriptions = All_Prescription.objects.all().order_by('-date', '-id')[offset:offset + page_size_prescription] + + report = [] + for pre in prescriptions: + dic = { + 'id': pre.pk, + 'user_id': pre.user_id, + 'doctor_id': pre.doctor_id, + 'date': pre.date, + 'details': pre.details, + 'test': pre.test, + 'file_id': pre.file_id, + # 'file': view_file(file_id=pre.file_id)['upload_file'] if pre.file_id else None + } report.append(dic) - + # Handle total count for pagination context + total_count = All_Prescription.objects.count() + # Calculate total number of pages + total_pages = (total_count + page_size_prescription - 1) // page_size_prescription # This ensures rounding up + prescContext = { + 'count': total_pages, + 'page': { + 'object_list': report, + 'number': current_page, + 'has_previous': current_page > 1, + 'has_next': current_page < total_pages, + 'previous_page_number': current_page - 1 if current_page > 1 else None, + 'next_page_number': current_page + 1 if current_page < total_pages else None, + } + } + #adding file tracking inbox part for compounder @@ -136,20 +277,18 @@ def compounder_view(request): dic['uploader']=ib['uploader'] dic['upload_date']=datetime.fromisoformat(ib['upload_date']).date() dic['desc']=mr.description - dic['file']=view_file(file_id=ib['id'])['upload_file'] + # dic['file']=view_file(file_id=ib['id'])['upload_file'] dic['status']=mr.compounder_forward_flag dic['status1']=mr.acc_admin_forward_flag inbox.append(dic) # print(inbox_files) - return render(request, 'phcModule/phc_compounder.html', - {'days': days, 'users': users, 'count': count,'expired':expired, - 'stocks': stocks, 'all_complaints': all_complaints, - 'all_hospitals': all_hospitals, 'hospitals':hospitals, 'all_ambulances': all_ambulances, - 'appointments_today': appointments_today, 'doctors': doctors, 'pathologists':pathologists, - 'appointments_future': appointments_future, 'schedule': schedule, 'schedule1': schedule1, 'live_meds': live_meds, 'presc_hist': report, 'medicines_presc': medicines_presc, 'hospitals_list': hospitals_list,'inbox_files':inbox,'announcements':announcements_data,}) + {'days': days, 'users': users,'expired':ExpiredstockContext, + 'stocks': stocks, + 'doctors': doctors, 'pathologists':pathologists, + 'schedule': schedule, 'schedule1': schedule1, 'live_meds': stockContext, 'presc_hist': prescContext,'inbox_files':inbox,'medicines_presc':medicine_presc}) else: return HttpResponseRedirect("/healthcenter/student") # compounder view ends @@ -632,4 +771,37 @@ def medical_profile(request): return render(request, 'health_center/medical_profile.html', {"user_designation":user_info.user_type, 'medical_profile':medical_profile, "request_to":requests_received - }) \ No newline at end of file + }) + +@login_required +def compounder_view_prescription(request,prescription_id): + prescription = All_Prescription.objects.get(id=prescription_id) + pre_medicine = All_Prescribed_medicine.objects.filter(prescription_id=prescription) + doctors=Doctor.objects.filter(active=True).order_by('id') + follow_presc =Prescription_followup.objects.filter(prescription_id=prescription).order_by('-id') + if request.method == "POST": + print("post") + return render(request, 'phcModule/phc_compounder_view_prescription.html',{'prescription':prescription, + 'pre_medicine':pre_medicine,'doctors':doctors, + "follow_presc":follow_presc}) + +@login_required +def view_file(request,file_id): + file_id_int = int(file_id) + if(file_id_int == -2): + return FileResponse(open('static/health_center/add_stock_example.xlsx', 'rb'), as_attachment=True, filename="example_add_stock.xlsx") + if(file_id_int == -1): + return FileResponse(open('static/health_center/add_medicine_example.xlsx', 'rb'), as_attachment=True, filename="example_add_medicine.xlsx") + filepath = "applications/health_center/static/health_center/generated.pdf" + + file=files.objects.get(id=file_id) + f=file.file_data + + with open("applications/health_center/static/health_center/generated.pdf", 'wb+') as destination: + destination.write(f) + + pdf = open(filepath, 'rb') + response = FileResponse(pdf, content_type="application/pdf") + response['Content-Disposition'] = 'inline; filename="generated.pdf"' + + return response diff --git a/FusionIIIT/templates/phcModule/manage_stock.html b/FusionIIIT/templates/phcModule/manage_stock.html index 5d9bfbe22..23cb89dd1 100644 --- a/FusionIIIT/templates/phcModule/manage_stock.html +++ b/FusionIIIT/templates/phcModule/manage_stock.html @@ -1,339 +1,637 @@ {% load static %} - + -{% block stock %} - {% comment %}the main tab starts here {% endcomment %} - - - {% comment %}the add stock tab starts here{% endcomment %} -
-

-
-
{% csrf_token %} -
- - -
-
- -
- -
-
-
- -
- -
-
-
-

-
- -
-
-
- -
- -
-
-
- - -
- -
- -
-
- -
-
+{% block stock %} {% comment %}the main tab starts here {% endcomment %} + + +{% comment %}the add stock tab starts here{% endcomment %} +
+

+
+
+ {% csrf_token %} +
+ +
+ + +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
-
-
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+

OR

+
+

Insert Data using excel file

- {% comment %}the add stock tab ends here {% endcomment %} - - - {% comment %}the add medicine tab starts here {% endcomment %} -
-

-
-
{% csrf_token %} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- - -
- -
- -
-
- -
-
+
+ {% csrf_token %} +
+ +
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+{% comment %}the add stock tab ends here {% endcomment %} +{% comment %}the addmedicine tab starts here {% endcomment %} +
+

+
+
+ {% csrf_token %} +
+ +
+ +
+
+
+ +
+
-
-
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+

OR

+
+

Insert Data using excel file

- {% comment %}the add medicine tab ends here {% endcomment %} - - - {% comment %}the view stock tab starts here {% endcomment %} -
-
- - - +
+
+
+
+
+
+{% comment %}the add medicine tab ends here {% endcomment %} +{% comment %}the view stock tab starts here {% endcomment %} + +
+
+
+
+ +
+
+
+
+ + + - + + + + -
Medicine
- - - + - + - + + + - + + {% for view in live_meds.page_stock_view.object_list %} + - - - - - {% for view in live_meds %} - - - + - + - +
- Medicine - Supplier - Supplier - Expiry Date - Expiry Date - Quantity
- Quantity -
- {{view.medicine_id}} - + {{view.medicine_id}} + - {{view.supplier}} - {{view.supplier}} - {{view.expiry_date}} - {{view.Expiry_date}} {{view.quantity}} @@ -343,73 +641,114 @@ {% endfor %}
+ +
+ +
+ Page of {{ live_meds.count_stock_view }} +
+ +
{% comment %}the view stock tab ends here {% endcomment %} {% comment %}the view stock tab starts here {% endcomment %}
+
+
+
+ +
+
+
+ + + - - - - +
- Medicine -
+ + + - + - + - + + + - + + {% for view in expired.page_stock_expired.object_list %} + - - + - - {% for view in expired %} - + - + - + - + + {% endfor %} - + - {% if view.returned == False %} - - {% endif %} - - {% endfor %} - - -
+ Medicine + - Quantity - Quantity - Expiry Date - Expiry Date - Supplier - Supplier
- Return -
+ {{view.medicine_id}} +
{{view.quantity}} - {{view.medicine_id}} - {{view.Expiry_date}} - {{view.quantity}} - + {{view.supplier}} + - {{view.expiry_date}} -
- {{view.supplier}} -
- - -
+ +
+ +
+ Page of {{ expired.count_stock_expired }} +
+ +
- - - - - - - - - - - - - - {% for stock in stocks %} - {% if stock.quantity < stock.threshold %} - - - - - - - - {% endif %} - {% endfor %} - -
- Medicine - - Available - - Minimum -
- {{stock.medicine_name}} - - {{stock.quantity}} - - {{stock.threshold}} -
-
+ + + + + + + + + + + + {% for stock in stocks.page_stock_required.object_list %} {% if stock.quantity < stock.threshold %} + + + + + + + {% endif %} {% endfor %} + +
MedicineAvailableMinimum
{{stock.medicine_id.brand_name}}{{stock.quantity}}{{stock.threshold}}
+ +
+ +
+ Page of {{ stocks.count_stock_required }} +
+ +
+ +
+
+{% comment %}the view inventory tab ends here {% endcomment %} +{% comment %}the edit threshold tab starts here{% endcomment %} +
+

+
+
+ {% csrf_token %} +
+ +
+ +
- {% comment %}the view inventory tab ends here {% endcomment %} - -{% endblock %} + +
+
+ +

+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+{% comment %}the edit threshold tab ends here {% endcomment %} {% endblock %} diff --git a/FusionIIIT/templates/phcModule/patientlog.html b/FusionIIIT/templates/phcModule/patientlog.html index 30143d425..5b1f4b9d2 100644 --- a/FusionIIIT/templates/phcModule/patientlog.html +++ b/FusionIIIT/templates/phcModule/patientlog.html @@ -3,7 +3,7 @@ {% block comapproval %}
+
+ + + + +
+
+
+ + +
+
+ + +
+
+ +
- +
-
+
- - - + +
+ + +
+ +
-
- -
- - -
-
+
- -
- - -
+ +
+ +
- -
- + +
+ +
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
-
+
+
+ + +
+
+
+ + +
+
+ + +
+
- - +
- +
+ + @@ -106,6 +164,7 @@
@@ -99,6 +151,12 @@ Times + Stock +
+
@@ -126,13 +185,129 @@
@@ -170,6 +363,20 @@ var user = document.getElementById('patient_b').value; var details = document.getElementById('details_b').value; var tbl = document.getElementById('sched_b'); + var medicine=[] + + for(var i=0,row;row=tbl.rows[i];i++){ + var obj= new Object(); + obj.brand_name=row.cells[0].innerText; + obj.quantity=row.cells[1].innerText; + obj.Days=row.cells[2].innerText; + obj.Times=row.cells[3].innerText; + obj.stock=row.cells[4].innerText+","+row.cells[5].innerText; + medicine[i]=obj; + console.log(obj) + } + + console.log(medicine) // Get the file input element var fileInput = document.getElementById('file'); @@ -178,16 +385,16 @@ var file = fileInput.files[0]; // Create a new FormData object - var formData = new FormData(); if(tbl.rows.length==0){ - $('#usr_b').html("Please prescribe some medicine!"); - return false; - } + $('#usr_b').html("Please prescribe some medicine!"); + return false; + } if(user=="" || details=="") { - $('#usr_b').html("Please enter all the details!"); - return false; + $('#usr_b').html("Please enter all the details!"); + return false; } + var formData = new FormData(); formData.append('csrfmiddlewaretoken', '{{ csrf_token }}') formData.append('file', file); formData.append('user', $("#patient_b").val()); @@ -195,6 +402,17 @@ formData.append('details', $("#details_b").val()); formData.append('tests', $("#tests_b").val()); formData.append('prescribe_b', $("#prescribe_b").val()); + formData.append('is_dependent',$('input[name="is_dependent"]:checked').val()); + if($('input[name="is_dependent"]:checked').val()=="dependent"){ + var dep_name = document.getElementById('dep_name').value + if($('input[name="is_dependent"]:checked').val()=="dependent" && dep_name == "No Dependent"){ + alert("dependent not valid") + return false; + } + formData.append('dependent_name',$("#dep_name").val().split(',')[0]); + formData.append('dependent_relation',$("#dep_rel").val()); + } + formData.append('pre_medicine',JSON.stringify(medicine)); $.ajax({ type:'post', url:'/healthcenter/compounder/', @@ -210,7 +428,9 @@ $('#sched_b').empty(); window.location.reload(); } - + else if(data.status == -1){ + aleart("enter valid patient id") + } else { if(data.status == 0) alert("Prescription failed!, not enough medicine available in stock"); @@ -225,8 +445,16 @@
- + +
+
+ +
+
+ +
+
- - - - - - - - {% for pre in presc_hist %} + + {% for pre in presc_hist.page.object_list %} @@ -289,38 +505,58 @@

{{pre.details}}

- - - - {% endfor %} -
@@ -244,25 +472,13 @@ Details - Test - - Report - - - -
MedicineDT
+ View
@@ -276,7 +492,7 @@

- {{pre.doctor_id}} + {{pre.doctor_id}}
- {{pre.test}} - - {% if pre.file %} - - - - {% endif %} + - - {% for medicine in medicines_presc %} - {% if medicine.prescription_id.id == pre.id %} - - {% endif %} - {% endfor%} -
{{medicine.medicine_id}}{{medicine.days}}{{medicine.times}}
-
+
+
+ + + + + + +
diff --git a/FusionIIIT/templates/phcModule/phc_compounder.html b/FusionIIIT/templates/phcModule/phc_compounder.html index 5acfb337a..575a3ce65 100644 --- a/FusionIIIT/templates/phcModule/phc_compounder.html +++ b/FusionIIIT/templates/phcModule/phc_compounder.html @@ -82,7 +82,7 @@ {% comment %}The left-rail segment ends here!{% endcomment %} {% comment %}The central-rail segment starts here!{% endcomment %} -
+
{% comment %}The complaint/feedback starts here!{% endcomment %}
{% block feedback %} @@ -94,7 +94,7 @@ {% comment %}The ap `pointment approval tab starts here!{% endcomment %}
{% block patientlog %} - {% include 'phcModule/patientlog.html' with all_hospitals=all_hospitals all_ambulances=all_ambulances appointments_today=appointments_today appointments_approve=appointments_approve %} + {% include 'phcModule/patientlog.html' with live_meds=live_meds %} {% endblock %}
{% comment %}The appointment approval tab ends here!{% endcomment %} @@ -109,9 +109,9 @@ {% comment %}The Manage Stocks Form starts here!{% endcomment %} -
+
{% block stock %} - {% include 'phcModule/manage_stock.html' with stocks=stocks inventories=inventories %} + {% include 'phcModule/manage_stock.html' with medicine=medicine stocks=stocks inventories=inventories %} {% endblock %}
{% comment %}The Manage Stocks Form ends here!{% endcomment %} diff --git a/FusionIIIT/templates/phcModule/phc_compounder_view_prescription.html b/FusionIIIT/templates/phcModule/phc_compounder_view_prescription.html new file mode 100644 index 000000000..0b77908ad --- /dev/null +++ b/FusionIIIT/templates/phcModule/phc_compounder_view_prescription.html @@ -0,0 +1,970 @@ +{% extends 'globals/base.html' %} +{% load static %} + +{% block title %} + Home +{% endblock %} + +{% block body %} + + + {% block navBar %} + {% include 'dashboard/navbar.html' %} + {% endblock %} + + {% comment %}The grid starts here!{% endcomment %} +
+ + {% comment %}The left-margin segment!{% endcomment %} +
+ + {% comment %}The left-rail segment starts here!{% endcomment %} +
+ {% comment %}The left-rail segment ends here!{% endcomment %} + + {% comment %}The central-rail segment starts here!{% endcomment %} +
+ + {% comment %}The ap `pointment approval tab starts here!{% endcomment %} +
+ + {% block patientlog %} +
+
+

{{prescription.user_id}}'s Prescription History

+
+
+
+
+ +
+
+ + +
+
+
+
{% csrf_token %} +

+
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + {% for med in pre_medicine %} + {% if med.revoked == False %} + + + + + + + + + + {% endif %} + {% endfor %} + +
+ Medicine id + + Medicine + + Quantity + + Days + + Times + + Expiry Date + + revoke +
+ {{med.id}} + + {{med.medicine_id.brand_name}} + + {{med.quantity}} + + {{med.days}} + + {{med.times}} + + {{med.stock}} + + +
+ +
+
+ +
+ + +
+ + +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+ +
+
+
+ + +
+
+
+
+
+
+ + + + {% for f_pres in follow_presc %} + + {% endfor %} + +
+
+ +
+ + + + {% endblock %} +
+
+ + {% comment %}The central-rail segment ends here!{% endcomment %} + + {% comment %}The right-rail segment starts here!{% endcomment %} +
+ {% comment %}
+ {% block sidepanel %} {% include 'notifications/sidepanel.html' with notifications=notifications %} + {% endblock %} +
{% endcomment %} +
+ {% comment %}The right-rail segment ends here!{% endcomment %} + +
+
+ {% comment %}The right-margin segment!{% endcomment %} +
+ +
+ {% comment %}The grid ends here!{% endcomment %} + + + + +{% endblock %} + +{% block javascript %} + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 9cf0fb09a..4b97f144f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -52,7 +52,7 @@ PyJWT==2.6.0 PyPDF2==1.26.0 pyrsistent==0.17.3 python-bidi==0.4.2 -python-dateutil==2.8.1 +python-dateutil==2.9.0 python3-openid==3.2.0 pytz==2020.5 reportlab==3.5.59 @@ -73,3 +73,4 @@ XlsxWriter==1.3.7 xlwt==1.3.0 django-crontab==0.7.1 zipfile2==0.0.12 +pandas==2.0.3