Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable the Bed List of Already occupied Beds (back-end change) #2116

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions care/facility/api/viewsets/bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from care.facility.models.bed import AssetBed, Bed, ConsultationBed
from care.facility.models.patient_base import BedTypeChoices
from care.users.models import User
from care.utils.assetintegration.asset_classes import AssetClasses
from care.utils.cache.cache_allowed_facilities import get_accessible_facilities
from care.utils.filters.choicefilter import CareChoiceFilter, inverse_choices

Expand All @@ -38,6 +39,21 @@ class BedFilter(filters.FilterSet):
facility = filters.UUIDFilter(field_name="facility__external_id")
location = filters.UUIDFilter(field_name="location__external_id")
bed_type = CareChoiceFilter(choice_dict=inverse_bed_type)
not_occupied_by_hl7_monitor = filters.BooleanFilter(
method="filter_bed_is_not_occupied_by_hl7_monitor"
)

def filter_bed_is_not_occupied_by_hl7_monitor(self, queryset, name, value):
if value:
return queryset.exclude(
id__in=Subquery(
AssetBed.objects.filter(
bed__id=OuterRef("id"),
asset__asset_class=AssetClasses.HL7MONITOR.name,
).values("bed__id")
)
)
return queryset


class BedViewSet(
Expand Down