Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion FusionIIIT/applications/health_center/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ def compounder_view_handler(request):
data = {'thresh': thresh}
return JsonResponse(data)


def student_view_handler(request):
if 'amb_submit' in request.POST:
user_id = ExtraInfo.objects.select_related('user','department').get(user=request.user)
Expand Down Expand Up @@ -422,6 +421,37 @@ def student_view_handler(request):
healthcare_center_notif(request.user, cmp.user, 'appoint_req')

return JsonResponse(data)
elif 'appointment' in request.POST:
print("WE ARE IN")
user_id = ExtraInfo.objects.select_related('user','department').get(user=request.user)
doctor_id = request.POST.get('doctor')

date = request.POST.get('date')
from_time = request.POST.get('from_time')
to_time = request.POST.get('to_time')
from_time_obj = datetime.time(datetime.strptime(from_time, '%H:%M'))
to_time_obj = datetime.time(datetime.strptime(to_time, '%H:%M'))

description = request.POST.get('description')
doctor = Doctor.objects.get(id=doctor_id)
day_on_date_in_integer = datetime.strptime(date, '%Y-%m-%d').weekday()
schedule = Schedule.objects.filter(doctor_id=doctor, day=day_on_date_in_integer, from_time__lte=from_time_obj, to_time__gte=to_time_obj).first()

if(schedule != None):
Appointment.objects.create(
user_id=user_id,
doctor_id=doctor,
description=description,
schedule=schedule,
date=date
)
data = {'status': 1}
healthcare_center_notif(request.user, request.user, 'appoint')
return JsonResponse(data)
else:
data = {'status': 0, 'message': 'Doctor is not available on this date & time. Please refer the Doctor\'s Schedule.'}
return JsonResponse(data)

elif 'doctor' in request.POST:
doctor_id = request.POST.get('doctor')
days = Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id).values('day')
Expand Down
211 changes: 127 additions & 84 deletions FusionIIIT/templates/phcModule/appointment.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{% load static %}
{% block appointment %}
{% comment %}the main tab starts here {% endcomment %}

<div class="ui pointing secondary menu">
<a class="active item" data-tab="doctorappointment">
Doctor Apppointment
</a>

<a class="item" data-tab="ambulancerequest">
Ambulance Request
</a>
Expand All @@ -28,117 +26,165 @@
<div class="field">
<label>Date of Appointment</label>
<!-- on selection of doctor few days should be displayed -->

<input type="date" id="inputdate" name="inputdate">
<script>
$(function(){
var dtToday = new Date();
var month = dtToday.getMonth() + 1;
var day = dtToday.getDate();
var year = dtToday.getFullYear();
if(month < 10)
month = '0' + month.toString();
if(day < 10)
day = '0' + day.toString();
var maxDate = year + '-' + month + '-' + day;
$('#inputdate').attr('min', maxDate);
});
</script>
<input type="date" placeholder="Select" id="date" name="date">
<p id="dte"></p>

<label>From Time</label>
<input type="time" placeholder="Select" id="from_time" name="from_time">
<p id="from_time"></p>
<label>To Time</label>
<input type="time" placeholder="Select" id="to_time" name="to_time">
<p id="to_time"></p>
</div>

<div class="field">
<label>Issues/Symptoms</label><p id="desc"></p>
<label>Issues/Symptoms</label>
<p id="desc"></p>
<div class="ui fluid input">
<textarea id="description" class="ui textarea" rows="2" name="description" required="true"></textarea>
<textarea id="description" class="ui textarea" rows="2" name="description" required="true"></textarea>
</div>
</div>

<div class="field">
<label><br></label>

<div >
<div>
<input type="submit" id="appo" name="Submit" value="Submit" class="ui small right floated primary button" />
</div>

</div>
</form>
<script type="text/javascript" src="{% static 'globals/js/jquery.min.js' %}"></script>
<script type="text/javascript">
function trimfield(str)
{
return str.replace(/^\s+|\s+$/g,'');
function trimfield(str) {
return str.replace(/^\s+|\s+$/g, '');
}
$('#appo').on('click',function(e){
$('#appo').on('click', function (e) {
e.preventDefault();

var tod = new Date(new Date().setHours(0, 0, 0, 0));
var today = new Date(new Date());
var now = today.getHours();

if(trimfield(document.getElementById("description").value) == '')
{
if (trimfield(document.getElementById("description").value) == '') {
$('#desc').html('*Please fill out the Description!');
document.getElementById("description").focus();
}
else{
} else {
$.ajax({
type:'post',
url:'/healthcenter/student/',
type: 'post',
url: '/healthcenter/student/',
data: {
csrfmiddlewaretoken: '{{ csrf_token }}',
doctor:$("#doc").val(),
date:$("#date").val(),
description:$("#description").val(),
appointment:$("#appo").val(),
doctor: $("#doc").val(),
date: $("#date").val(),
from_time: $("#from_time").val(),
to_time: $("#to_time").val(),
description: $("#description").val(),
appointment: $("#appo").val(),
},
success: function(data){
success: function (data) {
var dte = new Date(data.dt);
dte.setHours(0, 0, 0, 0);
alert("Appointment requested.Check history for the status of appointment. ")
document.getElementById("doc").value=""
document.getElementById("date").value=""
document.getElementById("description").value=" "

if (data.status == '1') {
alert("Appointment requested.Check history for the status of appointment. ")
} else if (data.status == '0') {
alert(data.message);
}

document.getElementById("doc").value = ""
document.getElementById("date").value = ""
document.getElementById("description").value = " "
$('#desc').html('');
window.location.reload();
$('#app_dte').html('');
}
});
}
});

</script>

<br>
<br>
</div>
<br>
<div class="extra segment"></div>
</div>

<div class="field">
<label><br></label>

<div>
<input type="submit" id="appo" name="Submit" value="Submit" class="ui small right floated primary button" />
</div>

</div>
</form>
<script type="text/javascript" src="{% static 'globals/js/jquery.min.js' %}"></script>
<script type="text/javascript">
function trimfield(str) {
return str.replace(/^\s+|\s+$/g, '');
}
$('#appo').on('click', function (e) {
e.preventDefault();

var tod = new Date(new Date().setHours(0, 0, 0, 0));
var today = new Date(new Date());
var now = today.getHours();

if (trimfield(document.getElementById("description").value) == '') {
$('#desc').html('*Please fill out the Description!');
document.getElementById("description").focus();
} else {
$.ajax({
type: 'post',
url: '/healthcenter/student/',
data: {
csrfmiddlewaretoken: '{{ csrf_token }}',
doctor: $("#doc").val(),
date: $("#date").val(),
description: $("#description").val(),
appointment: $("#appo").val(),
},
success: function (data) {
var dte = new Date(data.dt);
dte.setHours(0, 0, 0, 0);
alert("Appointment requested.Check history for the status of appointment. ")
document.getElementById("doc").value = ""
document.getElementById("date").value = ""
document.getElementById("description").value = " "
$('#desc').html('');
window.location.reload();
$('#app_dte').html('');
}
});
}
});
</script>
<br>
<br>
</div>
<br>
<div class="extra segment"></div>
</div>
{% comment %}the doctor appointment tab ends here {% endcomment %}

{% comment %}the ambulance appointment tab starts here {% endcomment %}
<div class="ui tab" data-tab="ambulancerequest">
<div class="ui vertical segment">
<form m class="ui form" method="POST" style="padding: 8px; padding-left: 24px; padding-right: 24px;">{% csrf_token %}
<div class="two fields" >
<form m class="ui form" method="POST" style="padding: 8px; padding-left: 24px; padding-right: 24px;">{% csrf_token
%}
<div class="two fields">
<div class="field">
<label>From</label>
<input type="date" id="inputdate1" name="inputdate1">
<script>
$(function(){
$(function () {
var dtToday = new Date();
var month = dtToday.getMonth() + 1;
var day = dtToday.getDate();
var year = dtToday.getFullYear();
if(month < 10)
if (month < 10)
month = '0' + month.toString();
if(day < 10)
if (day < 10)
day = '0' + day.toString();
var maxDate = year + '-' + month + '-' + day;
$('#inputdate1').attr('min', maxDate);
Expand All @@ -150,14 +196,14 @@
<label>To</label>
<input type="date" id="inputdate2" name="inputdate2">
<script>
$(function(){
$(function () {
var dtToday = new Date();
var month = dtToday.getMonth() + 1;
var day = dtToday.getDate();
var year = dtToday.getFullYear();
if(month < 10)
if (month < 10)
month = '0' + month.toString();
if(day < 10)
if (day < 10)
day = '0' + day.toString();
var maxDate = year + '-' + month + '-' + day;
$('#inputdate2').attr('min', maxDate);
Expand All @@ -176,63 +222,59 @@

<div class="field">
<label><br></label>
<div >
<input type="button" id="amb_submit" name="amb_submit" value="Submit"class="ui large right floated primary button" />
</div>
<div>
<input type="button" id="amb_submit" name="amb_submit" value="Submit"
class="ui large right floated primary button" />
</div>
</div>
</form>
<script type="text/javascript">

function trimfield(str)
{
return str.replace(/^\s+|\s+$/g,'');
function trimfield(str) {
return str.replace(/^\s+|\s+$/g, '');
}

$('#amb_submit').click(function(e)
{
$('#amb_submit').click(function (e) {
var startDate = document.getElementById('start_date').value;
var endDate = document.getElementById('end_date').value;
var start = new Date(startDate);
var end=new Date(endDate);
var end = new Date(endDate);
var today = new Date(new Date().setHours(0, 0, 0, 0));


$('#stdt').html('');
$('#endt').html('');
if ( +start < +today ) {

if (+start < +today) {
$('#stdt').html('You cannot enter a date before today!.');
return false;
}
if(endDate!="")
{
if ( +end < +start ) {
$('#endt').html('You cannot enter a date before start date!.');
return false;

if (endDate != "") {
if (+end < +start) {
$('#endt').html('You cannot enter a date before start date!.');
return false;
}
}

if(trimfield(document.getElementById("reason").value) == '')
{
if (trimfield(document.getElementById("reason").value) == '') {
$('#reas').html('*Please fill out the details!');
document.getElementById("reason").focus();
}

else{
} else {
$.ajax({
type:'post',
url:'/healthcenter/student/',
type: 'post',
url: '/healthcenter/student/',
data: {
csrfmiddlewaretoken: '{{ csrf_token }}',
start_date:$("#start_date").val(),
end_date:$("#end_date").val(),
reason:$("#reason").val(),
amb_submit:$("#amb_submit").val()
start_date: $("#start_date").val(),
end_date: $("#end_date").val(),
reason: $("#reason").val(),
amb_submit: $("#amb_submit").val()
},
success: function(data){
success: function (data) {
alert("Ambulance requested.");
document.getElementById("start_date").value="";
document.getElementById("end_date").value="";
document.getElementById("reason").value="";
document.getElementById("start_date").value = "";
document.getElementById("end_date").value = "";
document.getElementById("reason").value = "";
window.location.reload();

$('#reas').html('');
Expand All @@ -243,12 +285,13 @@
});
}
});

</script>
<br>
<br>
</div>
<br>
<div class="extra segment"></div>
</div>
</div>
{% comment %}the ambulance appointment tab ends here {% endcomment %}
{% endblock %}