Skip to content

Commit

Permalink
Merge pull request #2653 from areebahmeddd/remove-summarization
Browse files Browse the repository at this point in the history
Remove Summarization Tasks and Related Code
  • Loading branch information
vigneshhari authored Dec 20, 2024
2 parents 7d3d958 + 20cd5cd commit bae3201
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 1,041 deletions.
28 changes: 0 additions & 28 deletions care/facility/api/serializers/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
GENDER_CHOICES,
Disease,
Facility,
FacilityPatientStatsHistory,
PatientContactDetails,
PatientMetaInfo,
PatientNotes,
Expand Down Expand Up @@ -358,33 +357,6 @@ def update(self, instance, validated_data):
return patient


class FacilityPatientStatsHistorySerializer(serializers.ModelSerializer):
id = serializers.CharField(source="external_id", read_only=True)
entry_date = serializers.DateField(default=lambda: now().date())
facility = ExternalIdSerializerField(
queryset=Facility.objects.all(), read_only=True
)

class Meta:
model = FacilityPatientStatsHistory
exclude = (
"deleted",
"external_id",
)
read_only_fields = (
"id",
"facility",
)

def create(self, validated_data):
instance, _ = FacilityPatientStatsHistory.objects.update_or_create(
facility=validated_data["facility"],
entry_date=validated_data["entry_date"],
defaults={**validated_data, "deleted": False},
)
return instance


class PatientSearchSerializer(serializers.ModelSerializer):
gender = ChoiceField(choices=GENDER_CHOICES)
patient_id = serializers.UUIDField(source="external_id", read_only=True)
Expand Down
24 changes: 0 additions & 24 deletions care/facility/api/serializers/summary.py

This file was deleted.

6 changes: 0 additions & 6 deletions care/facility/api/viewsets/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from care.facility.models import (
Facility,
FacilityCapacity,
FacilityPatientStatsHistory,
HospitalDoctors,
)
from care.facility.models.facility import FacilityHubSpoke, FacilityUser
Expand Down Expand Up @@ -134,11 +133,6 @@ def list(self, request, *args, **kwargs):
elif self.FACILITY_DOCTORS_CSV_KEY in request.GET:
mapping.update(HospitalDoctors.CSV_RELATED_MAPPING.copy())
pretty_mapping.update(HospitalDoctors.CSV_MAKE_PRETTY.copy())
elif self.FACILITY_TRIAGE_CSV_KEY in request.GET:
mapping.update(FacilityPatientStatsHistory.CSV_RELATED_MAPPING.copy())
pretty_mapping.update(
FacilityPatientStatsHistory.CSV_MAKE_PRETTY.copy()
)
queryset = self.filter_queryset(self.get_queryset()).values(*mapping.keys())
return render_to_csv_response(
queryset, field_header_map=mapping, field_serializer_map=pretty_mapping
Expand Down
60 changes: 1 addition & 59 deletions care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from drf_spectacular.utils import extend_schema, extend_schema_view
from dry_rest_permissions.generics import DRYPermissionFiltersBase, DRYPermissions
from rest_framework import filters as rest_framework_filters
from rest_framework import mixins, serializers, status, viewsets
from rest_framework import mixins, serializers, status
from rest_framework.decorators import action
from rest_framework.exceptions import ValidationError
from rest_framework.filters import BaseFilterBackend
Expand All @@ -40,7 +40,6 @@
from rest_framework.viewsets import GenericViewSet

from care.facility.api.serializers.patient import (
FacilityPatientStatsHistorySerializer,
PatientDetailSerializer,
PatientListSerializer,
PatientNotesEditSerializer,
Expand All @@ -58,7 +57,6 @@
BedTypeChoices,
DailyRound,
Facility,
FacilityPatientStatsHistory,
PatientNotes,
PatientNoteThreadChoices,
PatientRegistration,
Expand Down Expand Up @@ -730,62 +728,6 @@ def get_queryset(self) -> QuerySet:
)


class FacilityPatientStatsHistoryFilterSet(filters.FilterSet):
entry_date = filters.DateFromToRangeFilter(field_name="entry_date")


class FacilityPatientStatsHistoryViewSet(viewsets.ModelViewSet):
lookup_field = "external_id"
permission_classes = (IsAuthenticated, DRYPermissions)
queryset = FacilityPatientStatsHistory.objects.filter(
facility__deleted=False
).order_by("-entry_date")
serializer_class = FacilityPatientStatsHistorySerializer
filter_backends = (filters.DjangoFilterBackend,)
filterset_class = FacilityPatientStatsHistoryFilterSet
http_method_names = ["get", "post", "delete"]

def get_queryset(self):
user = self.request.user
queryset = self.queryset.filter(
facility__external_id=self.kwargs.get("facility_external_id")
)
if user.is_superuser:
return queryset
if self.request.user.user_type >= User.TYPE_VALUE_MAP["StateLabAdmin"]:
return queryset.filter(facility__state=user.state)
if self.request.user.user_type >= User.TYPE_VALUE_MAP["DistrictLabAdmin"]:
return queryset.filter(facility__district=user.district)
return queryset.filter(facility__users__id__exact=user.id)

def get_object(self):
return get_object_or_404(
self.get_queryset(), external_id=self.kwargs.get("external_id")
)

def get_facility(self):
facility_qs = Facility.objects.filter(
external_id=self.kwargs.get("facility_external_id")
)
if not self.request.user.is_superuser:
facility_qs.filter(users__id__exact=self.request.user.id)
return get_object_or_404(facility_qs)

def perform_create(self, serializer):
return serializer.save(facility=self.get_facility())

def list(self, request, *args, **kwargs):
"""
Patient Stats - List
Available Filters
- entry_date_before: date in YYYY-MM-DD format, inclusive of this date
- entry_date_before: date in YYYY-MM-DD format, inclusive of this date
"""
return super().list(request, *args, **kwargs)


class PatientSearchSetPagination(PageNumberPagination):
page_size = 200

Expand Down
126 changes: 0 additions & 126 deletions care/facility/api/viewsets/summary.py

This file was deleted.

25 changes: 0 additions & 25 deletions care/facility/management/commands/summarize.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 5.1.3 on 2024-12-15 17:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('facility', '0467_alter_hospitaldoctors_area'),
]

operations = [
migrations.AlterUniqueTogether(
name='facilitypatientstatshistory',
unique_together=None,
),
migrations.RemoveField(
model_name='facilitypatientstatshistory',
name='facility',
),
migrations.RemoveField(
model_name='facilityrelatedsummary',
name='facility',
),
migrations.RemoveField(
model_name='localbodyscopedsummary',
name='lsg',
),
migrations.DeleteModel(
name='DistrictScopedSummary',
),
migrations.DeleteModel(
name='FacilityPatientStatsHistory',
),
migrations.DeleteModel(
name='FacilityRelatedSummary',
),
migrations.DeleteModel(
name='LocalBodyScopedSummary',
),
]
1 change: 0 additions & 1 deletion care/facility/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
from .prescription import * # noqa
from .resources import * # noqa
from .shifting import * # noqa
from .summary import * # noqa
Loading

0 comments on commit bae3201

Please sign in to comment.