Skip to content

Commit

Permalink
fix patient sorting filters (#2086)
Browse files Browse the repository at this point in the history
Co-authored-by: Vignesh Hari <vichuhari100@gmail.com>
  • Loading branch information
sainak and vigneshhari authored Apr 18, 2024
1 parent eff9687 commit 338b510
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def filter_queryset(self, request, queryset, view):
q_filters = Q(facility__id__in=allowed_facilities)
if view.action == "retrieve":
q_filters |= Q(consultations__facility__id__in=allowed_facilities)
queryset = queryset.distinct("id")
q_filters |= Q(last_consultation__assigned_to=request.user)
q_filters |= Q(assigned_to=request.user)
queryset = queryset.filter(q_filters)
Expand Down Expand Up @@ -340,7 +341,7 @@ def filter_queryset(self, request, queryset, view):
)
).order_by(ordering)

return queryset.distinct(ordering.lstrip("-") if ordering else "id")
return queryset


@extend_schema_view(history=extend_schema(tags=["patient"]))
Expand Down

0 comments on commit 338b510

Please sign in to comment.