Skip to content
Snippets Groups Projects
Commit fecea1b9 authored by Valentin Groues's avatar Valentin Groues :eyes:
Browse files

Merge branch...

Merge branch '210-email-with-kit-request-contain-double-entries-for-patients-with-two-appointment_types-that-should-be-included-in-it' into 'master'

Resolve "email with kit request contain double entries for patients with two appointment_types that should be included in it"

Closes #210

See merge request NCER-PD/scheduling-system!133
parents ff497715 c00ce9bf
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):
self.assertEqual(appointment1, result['appointments'][1])
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):
item_name = "Test item to be ordered"
item = Item.objects.create(disposable=True, name=item_name)
......
......@@ -45,7 +45,7 @@ def get_kit_requests(user, start_date=None, end_date=None):
datetime_when__gt=start_date,
location__in=get_filter_locations(user),
status=Appointment.APPOINTMENT_STATUS_SCHEDULED,
).order_by('datetime_when')
).distinct().order_by('datetime_when')
if end_date is not None:
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