diff --git a/FusionIIIT/applications/health_center/migrations/0005_auto_20230416_1755.py b/FusionIIIT/applications/health_center/migrations/0005_auto_20230416_1755.py new file mode 100644 index 000000000..36c4455f1 --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0005_auto_20230416_1755.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.5 on 2023-04-16 17:55 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0004_auto_20230411_1342'), + ] + + operations = [ + migrations.RemoveField( + model_name='doctor', + name='contact_no', + ), + migrations.AlterField( + model_name='doctor', + name='doctor_phone', + field=models.CharField(default='0000000000', max_length=10, validators=[django.core.validators.MinLengthValidator(10)]), + ), + ] diff --git a/FusionIIIT/applications/health_center/migrations/0006_auto_20230416_1822.py b/FusionIIIT/applications/health_center/migrations/0006_auto_20230416_1822.py new file mode 100644 index 000000000..11510987d --- /dev/null +++ b/FusionIIIT/applications/health_center/migrations/0006_auto_20230416_1822.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.5 on 2023-04-16 18:22 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('health_center', '0005_auto_20230416_1755'), + ] + + operations = [ + migrations.RemoveField( + model_name='hospital', + name='phone', + ), + migrations.AddField( + model_name='hospital', + name='hospital_address', + field=models.CharField(default='', max_length=255), + ), + migrations.AddField( + model_name='hospital', + name='hospital_phone', + field=models.CharField(default='0000000000', max_length=10, validators=[django.core.validators.MinLengthValidator(10)]), + ), + ] diff --git a/FusionIIIT/applications/health_center/models.py b/FusionIIIT/applications/health_center/models.py index 63fc3a261..27bbb8d47 100644 --- a/FusionIIIT/applications/health_center/models.py +++ b/FusionIIIT/applications/health_center/models.py @@ -26,10 +26,9 @@ class Constants: class Doctor(models.Model): # doctor_name = models.IntegerField(choices=Constants.NAME_OF_DOCTOR) doctor_name = models.CharField(max_length=200) - doctor_phone = models.CharField(max_length=10) + doctor_phone = models.CharField(max_length=10, validators=[MinLengthValidator(10)], default="0000000000") specialization = models.CharField(max_length=100) active = models.BooleanField(default=True) - contact_no = models.CharField(max_length=10, validators=[MinLengthValidator(10)], default="0000000000") def __str__(self): return self.doctor_name @@ -60,11 +59,12 @@ class Medicine(models.Model): times = models.IntegerField(default=0) def __str__(self): - return self.medicine_id + return self.medicine_id.medicine_name class Hospital(models.Model): hospital_name=models.CharField(max_length=100) - phone=models.CharField(max_length=10) + hospital_address=models.CharField(max_length=255, default="") + hospital_phone=models.CharField(max_length=10, validators=[MinLengthValidator(10)], default="0000000000") def __str__(self): return self.hospital_name diff --git a/FusionIIIT/applications/health_center/utils.py b/FusionIIIT/applications/health_center/utils.py index 86647546d..52b327ba4 100644 --- a/FusionIIIT/applications/health_center/utils.py +++ b/FusionIIIT/applications/health_center/utils.py @@ -253,8 +253,8 @@ def compounder_view_handler(request): test=tests, appointment=appointment ) - query = Medicine.objects.select_related('patient','patient__user','patient__department').objects.filter(patient=user) - prescribe = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').objects.all().last() + 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','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').all().last() for medicine in query: medicine_id = medicine.medicine_id quantity = medicine.quantity @@ -296,6 +296,7 @@ def compounder_view_handler(request): healthcare_center_notif(request.user, user.user, 'presc') data = {'status': status, 'stock': stock} return JsonResponse(data) + elif 'prescribe_b' in request.POST: user_id = request.POST.get('user') user = ExtraInfo.objects.select_related('user','department').get(id=user_id) @@ -363,16 +364,31 @@ def compounder_view_handler(request): healthcare_center_notif(request.user, user.user, 'presc') data = {'status': status} return JsonResponse(data) + elif 'cancel_presc' in request.POST: presc_id = request.POST.get('cancel_presc') Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').filter(pk=presc_id).delete() data = {'status': 1} return JsonResponse(data) + elif 'medicine' in request.POST: med_id = request.POST.get('medicine') thresh = Stock.objects.get(id=med_id).threshold data = {'thresh': thresh} return JsonResponse(data) + + elif 'add_hospital' in request.POST: + hospital_name=request.POST.get('hospital_name') + hospital_address=request.POST.get('hospital_address') + hospital_phone=request.POST.get('hospital_phone') + print(hospital_name,hospital_address,hospital_phone) + Hospital.objects.create( + hospital_name=hospital_name, + hospital_address=hospital_address, + hospital_phone=hospital_phone, + ) + data={'status':1, 'hospital_name':hospital_name, 'hospital_address':hospital_address, 'hospital_phone':hospital_phone} + return JsonResponse(data) 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 5b348787c..a5a1306e4 100644 --- a/FusionIIIT/applications/health_center/views.py +++ b/FusionIIIT/applications/health_center/views.py @@ -80,8 +80,8 @@ def compounder_view(request): stocks = Stock.objects.all() days = Constants.DAYS_OF_WEEK schedule=Schedule.objects.select_related('doctor_id').all().order_by('doctor_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') + 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(expiry_date__gte=datetime.now(), returned=False).order_by('quantity') count=Counter.objects.all() presc_hist=Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').all().order_by('-date') 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','prescription_id__appointment','prescription_id__appointment__user_id','prescription_id__appointment__user_id__user','prescription_id__appointment__user_id__department','prescription_id__appointment__doctor_id','prescription_id__appointment__schedule','prescription_id__appointment__schedule__doctor_id','medicine_id').all() @@ -95,6 +95,7 @@ def compounder_view(request): # doct= ["Dr. G S Sandhu", "Dr. Jyoti Garg", "Dr. Arvind Nath Gupta"] + print(live_meds.values()) return render(request, 'phcModule/phc_compounder.html', {'days': days, 'users': users, 'count': count,'expired':expired, @@ -145,13 +146,6 @@ def student_view(request): doctors=Doctor.objects.filter(active=True) count=Counter.objects.all() - # Snippet to add prescription for an appointment - for pres in prescription: - for appointment in appointments: - if pres.appointment.pk == appointment.pk: - appointment['prescription_on_appointment'] = pres - break - if count: Counter.objects.all().delete() Counter.objects.create(count=0,fine=0) diff --git a/FusionIIIT/templates/phcModule/comp_prescription.html b/FusionIIIT/templates/phcModule/comp_prescription.html index b1b1fa226..89c240029 100755 --- a/FusionIIIT/templates/phcModule/comp_prescription.html +++ b/FusionIIIT/templates/phcModule/comp_prescription.html @@ -4,13 +4,16 @@ {% comment %}the compounder prescription tab starts here {% endcomment %} {% comment %}the prescribe tab starts here {% endcomment %} @@ -22,17 +25,27 @@
{% csrf_token %}

+
- {% for a in appointments_today %} {% endfor %} +
-
- +
+ + +
+
@@ -120,6 +133,7 @@ $('#medicine').click(function(e){ $("#sched tr").remove(); var user = document.getElementById('user').value; + var doctor = document.getElementById('doctor').value; var quantity = document.getElementById('quantity').value; var medicine = document.getElementById('medicine_id').value; var days = document.getElementById('days').value; @@ -135,6 +149,7 @@ data: { csrfmiddlewaretoken: '{{ csrf_token }}', user:$("#user").val(), + doctor:$("#doctor").val(), quantity:$("#quantity").val(), medicine_name:$("#medicine_id").val(), days:$("#days").val(), @@ -142,7 +157,7 @@ }, success: function(data){ - alert("added medicine"); + alert("Added Medicine!"); document.getElementById("quantity").value=""; document.getElementById("medicine_id").value=""; document.getElementById("days").value=""; @@ -185,7 +200,7 @@ }, success: function(data){ if (data.status == 1 ){ - alert("prescribed medicine"); + alert("Prescription Added!"); document.getElementById("details").value=""; document.getElementById("tests").value=""; $('#sched').empty(); @@ -210,13 +225,14 @@ style="padding-left: 3.5%; padding-right: 3.5%;"> - {% csrf_token %} + + {% csrf_token %}

- +
@@ -338,7 +354,7 @@ times:$("#times_b").val() }, success: function(data){ - alert("added medicine"); + alert("Added Medicine!"); document.getElementById("quantity_b").value=""; document.getElementById("medicine_id_b").value=""; document.getElementById("days_b").value=""; @@ -381,7 +397,7 @@ }, success: function(data){ if (data.status == 1){ - alert("prescribed medicine"); + alert("Prescription Added!"); document.getElementById("doctor_b").value=""; document.getElementById("details_b").value=""; document.getElementById("tests_b").value=""; @@ -524,11 +540,97 @@

*Admission details for outside hospitals

}); }); - +

+ +{% comment %}the add hospital tab starts here {% endcomment %} +
+

+
+ + {% csrf_token %} + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+
+
+
+{% comment %}the add doctor tab ends here {% endcomment %} +
diff --git a/FusionIIIT/templates/phcModule/doctors.html b/FusionIIIT/templates/phcModule/doctors.html index df6345dcc..52139e260 100644 --- a/FusionIIIT/templates/phcModule/doctors.html +++ b/FusionIIIT/templates/phcModule/doctors.html @@ -88,7 +88,7 @@ {% comment %}the add doctor tab starts here {% endcomment %}
-

+

{% csrf_token %}
@@ -124,10 +124,14 @@ var new_doctor = document.getElementById('new_doctor').value; var specialization = document.getElementById('specialization').value; var phone = document.getElementById('phone').value; - if ( new_medicine==""||phone==""||specialization=="") { + if (new_medicine=="" || phone=="" || specialization=="") { $('#doc_add').html('Enter valid details'); return false; } + if(phone.toString().length != 10){ + $('#doc_add').html('Enter valid phone number'); + return false; + } $.ajax({ type:'post', @@ -140,7 +144,7 @@ add_doctor:$('#add_doctor').val() }, success: function(data){ - alert("added doctor"); + alert("Added Doctor!"); {% comment %} $('#phc_docs').find('tbody'); $('#phc_docs tbody').append("" + data.doctor + "" + data.specialization + "" + data.phone + ""); diff --git a/FusionIIIT/templates/phcModule/history.html b/FusionIIIT/templates/phcModule/history.html index abd5d6004..3fd66b9ac 100755 --- a/FusionIIIT/templates/phcModule/history.html +++ b/FusionIIIT/templates/phcModule/history.html @@ -351,11 +351,6 @@

Description - - - Prescription - - @@ -373,11 +368,6 @@

{{appointment.description}} - - - {{appointment.prescription_on_appointment}} - - diff --git a/FusionIIIT/templates/phcModule/manage_stock.html b/FusionIIIT/templates/phcModule/manage_stock.html index 5d9bfbe22..f85db5d4e 100644 --- a/FusionIIIT/templates/phcModule/manage_stock.html +++ b/FusionIIIT/templates/phcModule/manage_stock.html @@ -19,7 +19,7 @@ View Stock - Required Medicine + Threshold/Required

@@ -435,41 +435,83 @@ {% comment %}the threshold stock tab starts here {% endcomment %}
-
- - - + + {{stock.quantity}} + + + {{stock.threshold}} + + + + {% endfor %} + + +

Required Stock

+
+ + + +
@@ -507,8 +549,7 @@ {% endif %} {% endfor %} -
-
+
{% comment %}the view inventory tab ends here {% endcomment %} diff --git a/FusionIIIT/templates/phcModule/phc_compounder.html b/FusionIIIT/templates/phcModule/phc_compounder.html index bb0bc3751..2954e8b59 100644 --- a/FusionIIIT/templates/phcModule/phc_compounder.html +++ b/FusionIIIT/templates/phcModule/phc_compounder.html @@ -43,7 +43,7 @@ - Prescribe + Prescribe/Hospital