Skip to content

Commit

Permalink
Merge branch 'develop' into prafful/bugs/patient_phone_number_validator
Browse files Browse the repository at this point in the history
  • Loading branch information
DraKen0009 authored Jan 13, 2025
2 parents 071b4e8 + ce87462 commit 23ac43b
Show file tree
Hide file tree
Showing 473 changed files with 34 additions and 29,078 deletions.
9 changes: 0 additions & 9 deletions care/emr/api/viewsets/encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
email_discharge_summary_task,
generate_discharge_summary_task,
)
from care.facility.api.serializers.patient_consultation import (
EmailDischargeSummarySerializer,
)
from care.facility.models import Facility
from care.security.authorization import AuthorizationController

Expand Down Expand Up @@ -287,12 +284,6 @@ def validate_email(cls, value):
django_validate_email(value)
return value

@extend_schema(
description="Email the discharge summary to the user",
request=EmailDischargeSummarySerializer,
responses={200: "Success"},
tags=["encounter"],
)
@action(detail=True, methods=["POST"])
def email_discharge_summary(self, request, *args, **kwargs):
encounter = self.get_object()
Expand Down
33 changes: 31 additions & 2 deletions care/emr/api/viewsets/facility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.db.models import Q
from django.utils.decorators import method_decorator
from django_filters import CharFilter, FilterSet
from django_filters import CharFilter, FilterSet, NumberFilter
from django_filters import rest_framework as filters
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters as drf_filters
from rest_framework.decorators import action, parser_classes
from rest_framework.exceptions import PermissionDenied
from rest_framework.generics import get_object_or_404
Expand All @@ -24,8 +26,18 @@
from care.utils.file_uploads.cover_image import delete_cover_image


class FacilityFilters(FilterSet):
class GeoOrganizationFilter(filters.UUIDFilter):
def filter(self, qs, value):
if value:
organization = get_object_or_404(Organization, external_id=value)
return qs.filter(geo_organization_cache__overlap=[organization.id])
return qs


class FacilityFilters(filters.FilterSet):
name = CharFilter(field_name="name", lookup_expr="icontains")
facility_type = NumberFilter(field_name="facility_type")
organization = GeoOrganizationFilter()
phone_number = CharFilter(field_name="phone_number", lookup_expr="iexact")


Expand Down Expand Up @@ -124,3 +136,20 @@ def get_queryset(self):
organization__facility__external_id=self.kwargs["facility_external_id"]
).values("user_id")
)


class AllFacilityViewSet(EMRModelReadOnlyViewSet):
permission_classes = ()
authentication_classes = ()

database_model = Facility
pydantic_model = FacilityCreateSpec
pydantic_read_model = FacilityReadSpec
pydantic_retrieve_model = FacilityRetrieveSpec
filterset_class = FacilityFilters
filter_backends = (filters.DjangoFilterBackend, drf_filters.SearchFilter)
lookup_field = "external_id"
search_fields = ["name"]

def get_queryset(self):
return Facility.objects.filter(is_public=True).select_related()
2 changes: 1 addition & 1 deletion care/emr/resources/medication/request/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class DoseAndRate(BaseModel):

class TimingRepeat(BaseModel):
frequency: int | None = None
period: float = 1
period: float | None = None
period_unit: TimingUnit
bounds_duration: DosageQuantity | None = None

Expand Down
Empty file removed care/facility/api/__init__.py
Empty file.
5 changes: 0 additions & 5 deletions care/facility/api/serializers/__init__.py

This file was deleted.

70 changes: 0 additions & 70 deletions care/facility/api/serializers/ambulance.py

This file was deleted.

Loading

0 comments on commit 23ac43b

Please sign in to comment.