Skip to content
Snippets Groups Projects
Commit c00ce9bf authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when filtering appointments that should be included in email request we need to remove duplicates

parent ff497715
No related branches found
No related tags found
1 merge request!133Resolve "email with kit request contain double entries for patients with two appointment_types that should be included in it"
Pipeline #
...@@ -96,6 +96,29 @@ class ViewFunctionsTests(LoggedInTestCase): ...@@ -96,6 +96,29 @@ class ViewFunctionsTests(LoggedInTestCase):
self.assertEqual(appointment1, result['appointments'][1]) self.assertEqual(appointment1, result['appointments'][1])
self.assertEqual(appointment2, result['appointments'][2]) self.assertEqual(appointment2, result['appointments'][2])
def test_kit_requests_for_appointment_with_two_types(self):
item = Item.objects.create(disposable=True, name="item 1")
appointment_type = create_appointment_type()
appointment_type.required_equipment.add(item)
appointment_type.save()
item = Item.objects.create(disposable=True, name="item 2")
appointment_type2 = create_appointment_type()
appointment_type2.required_equipment.add(item)
appointment_type2.save()
visit = create_visit()
appointment1 = create_appointment(visit)
appointment1.datetime_when = get_today_midnight_date() + datetime.timedelta(days=3)
appointment1.save()
AppointmentTypeLink.objects.create(appointment=appointment1, appointment_type=appointment_type)
AppointmentTypeLink.objects.create(appointment=appointment1, appointment_type=appointment_type2)
result = get_kit_requests(self.user)
self.assertEqual(1, len(result["appointments"]))
def test_kit_requests_send_email(self): def test_kit_requests_send_email(self):
item_name = "Test item to be ordered" item_name = "Test item to be ordered"
item = Item.objects.create(disposable=True, name=item_name) item = Item.objects.create(disposable=True, name=item_name)
......
...@@ -45,7 +45,7 @@ def get_kit_requests(user, start_date=None, end_date=None): ...@@ -45,7 +45,7 @@ def get_kit_requests(user, start_date=None, end_date=None):
datetime_when__gt=start_date, datetime_when__gt=start_date,
location__in=get_filter_locations(user), location__in=get_filter_locations(user),
status=Appointment.APPOINTMENT_STATUS_SCHEDULED, status=Appointment.APPOINTMENT_STATUS_SCHEDULED,
).order_by('datetime_when') ).distinct().order_by('datetime_when')
if end_date is not None: if end_date is not None:
appointments = appointments.filter(datetime_when__lt=end_date) appointments = appointments.filter(datetime_when__lt=end_date)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment