Skip to content

Commit

Permalink
Add filters in resource request
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed Jan 26, 2025
1 parent fff6497 commit f71f10b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions care/emr/api/viewsets/resource_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db.models import Q
from django_filters import rest_framework as filters
from rest_framework.generics import get_object_or_404

from care.emr.api.viewsets.base import (
Expand All @@ -21,11 +22,22 @@
)


class ResourceRequestFilters(filters.FilterSet):
origin_facility = filters.UUIDFilter(field_name="origin_facility__external_id")
approving_facility = filters.UUIDFilter(
field_name="approving_facility__external_id"
)
assigned_facility = filters.UUIDFilter(field_name="assigned_facility__external_id")
related_patient = filters.UUIDFilter(field_name="related_patient__external_id")


class ResourceRequestViewSet(EMRModelViewSet):
database_model = ResourceRequest
pydantic_model = ResourceRequestCreateSpec
pydantic_read_model = ResourceRequestListSpec
pydantic_retrieve_model = ResourceRequestRetrieveSpec
filterset_class = ResourceRequestFilters
filter_backends = [filters.DjangoFilterBackend]

@classmethod
def build_queryset(cls, queryset, user):
Expand Down

0 comments on commit f71f10b

Please sign in to comment.