Skip to content

Commit

Permalink
Add view and allow for duplicate hostpital numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Feb 14, 2020
1 parent 6f52606 commit faf101f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
6 changes: 5 additions & 1 deletion elcid/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from elcid import api

from elcid import views
from plugins.appointments import views as appointment_views

urlpatterns = [
url('^admin/bulk-create-users$', views.BulkCreateUserView.as_view(), name='bulk-create-users'),
Expand All @@ -22,7 +23,10 @@
r'^elcid/renal_handover',
views.RenalHandover.as_view(),
name="renal_handover"
)
),
url(r'^appointments/tb-clinic-list/',
appointment_views.ClinicListView.as_view(),
name='tb-clinic-list')
]

urlpatterns += opatterns
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def handle(self, *args, **kwargs):
if Patient.objects.filter(demographics__hospital_number=mrn).count() == 0:
patient = self.create_patient_for_mrn(mrn)
else:
patient = Patient.objects.get(demographics__hospital_number=mrn)
try:
patient = Patient.objects.get(demographics__hospital_number=mrn)
except:
patient = Patient.objects.filter(demographics__hospital_number=mrn).first()

our_appointment = Appointment(patient=patient)

Expand Down
30 changes: 30 additions & 0 deletions plugins/appointments/templates/appointments/clinic_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends 'app_layouts/layout_base.html' %}
{% block ngapp %}{% endblock %}
{% block loading %}{% endblock %}

{% block content %}
<div class="row content-offset">
<div class="col-md-10 col-md-offset-1">
<h2 >Upcoming TB Clinic Appointments</h2>
</div>
</div>
{% for appointment in object_list %}
<div class="row">
<div class="col-md-3">
{{ appointment.start_datetime }}
<br />
{{ appointment.duration}}
</div>
<div class="col-md-3">
{{ appointment.derived_appointment_type }}
</div>
<div class="col-md-3">
{{ appointment.patient.demographics.name }}
</div>
<div class="col-md-3">
{{ appointment.patient.demographics.hospital_number }}
{{ appointment.patient.demographics.date_of_birth }}
</div>
</div>
{% endfor %}
{% endblock %}
21 changes: 21 additions & 0 deletions plugins/appointments/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Views for the Appointment plugin
"""
import datetime

from django.views.generic import ListView

from plugins.appointments.models import Appointment


class ClinicListView(ListView):
"""
Show a list of all future appointments
"""
model = Appointment
template_name = 'appointments/clinic_list.html'

def get_queryset(self):
return Appointment.objects.filter(
start_datetime__gte=datetime.date.today()
).exclude(status_code='Canceled')

0 comments on commit faf101f

Please sign in to comment.