From 44b5f0d5b92a2c8624fe22d036edefb8acf5f66f Mon Sep 17 00:00:00 2001 From: Areeb Ahmed Date: Sun, 22 Dec 2024 02:05:47 +0530 Subject: [PATCH 1/5] Remove COVID-specific fields from Patient model and serializers --- care/facility/api/serializers/daily_round.py | 4 -- .../api/serializers/patient_consultation.py | 4 -- care/facility/api/viewsets/patient.py | 6 --- care/facility/models/daily_round.py | 8 ---- care/facility/models/facility.py | 7 ---- care/facility/models/patient.py | 38 ------------------- care/facility/models/patient_base.py | 10 +---- care/facility/models/patient_consultation.py | 13 ------- care/facility/tests/test_patient_api.py | 12 ------ 9 files changed, 1 insertion(+), 101 deletions(-) diff --git a/care/facility/api/serializers/daily_round.py b/care/facility/api/serializers/daily_round.py index bd8f105903..6bcd83b1bd 100644 --- a/care/facility/api/serializers/daily_round.py +++ b/care/facility/api/serializers/daily_round.py @@ -9,7 +9,6 @@ from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, PatientRegistration, ) from care.facility.models.bed import Bed @@ -27,9 +26,6 @@ class DailyRoundSerializer(serializers.ModelSerializer): id = serializers.CharField(source="external_id", read_only=True) - deprecated_covid_category = ChoiceField( - choices=COVID_CATEGORY_CHOICES, required=False - ) # Deprecated patient_category = ChoiceField(choices=CATEGORY_CHOICES, required=False) action = ChoiceField( diff --git a/care/facility/api/serializers/patient_consultation.py b/care/facility/api/serializers/patient_consultation.py index ac2fdf5d00..f5179ad563 100644 --- a/care/facility/api/serializers/patient_consultation.py +++ b/care/facility/api/serializers/patient_consultation.py @@ -25,7 +25,6 @@ from care.facility.api.serializers.facility import FacilityBasicInfoSerializer from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, Facility, PatientRegistration, Prescription, @@ -78,9 +77,6 @@ class PatientConsultationSerializer(serializers.ModelSerializer): source="suggestion", ) - deprecated_covid_category = ChoiceField( - choices=COVID_CATEGORY_CHOICES, required=False - ) category = ChoiceField(choices=CATEGORY_CHOICES, required=True) referred_to_object = FacilityBasicInfoSerializer( diff --git a/care/facility/api/viewsets/patient.py b/care/facility/api/viewsets/patient.py index 7b023c1531..836b5d0a8d 100644 --- a/care/facility/api/viewsets/patient.py +++ b/care/facility/api/viewsets/patient.py @@ -51,7 +51,6 @@ from care.facility.api.viewsets.mixins.history import HistoryMixin from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, DISCHARGE_REASON_CHOICES, FACILITY_TYPES, BedTypeChoices, @@ -122,10 +121,6 @@ class PatientFilterSet(filters.FilterSet): age_max = filters.NumberFilter( field_name="age", lookup_expr="lte", validators=[MinValueValidator(0)] ) - deprecated_covid_category = filters.ChoiceFilter( - field_name=f"{last_consultation_field}__deprecated_covid_category", - choices=COVID_CATEGORY_CHOICES, - ) category = filters.ChoiceFilter( method="filter_by_category", choices=CATEGORY_CHOICES, @@ -234,7 +229,6 @@ def filter_by_bed_type(self, queryset, name, value): ) # Vaccination Filters - covin_id = filters.CharFilter(field_name="covin_id", max_length=15) is_vaccinated = filters.BooleanFilter(field_name="is_vaccinated") number_of_doses = filters.NumberFilter( field_name="number_of_doses", diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index edc11a8954..0f5b76a980 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -7,7 +7,6 @@ from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, PatientBaseModel, ) from care.facility.models.bed import AssetBed @@ -166,13 +165,6 @@ class InsulinIntakeFrequencyType(models.IntegerChoices): max_digits=4, decimal_places=2, blank=True, null=True, default=None ) # Deprecated physical_examination_info = models.TextField(null=True, blank=True) - deprecated_covid_category = models.CharField( - choices=COVID_CATEGORY_CHOICES, - max_length=8, - default=None, - blank=True, - null=True, - ) # Deprecated patient_category = models.CharField( choices=CATEGORY_CHOICES, max_length=13, blank=False, null=True ) diff --git a/care/facility/models/facility.py b/care/facility/models/facility.py index 01c0102b10..0ec32567c7 100644 --- a/care/facility/models/facility.py +++ b/care/facility/models/facility.py @@ -26,10 +26,6 @@ (1, "General Bed"), (10, "ICU"), (20, "Ventilator"), - (30, "Covid Beds"), - (100, "Covid Ventilators"), - (110, "Covid ICU"), - (120, "Covid Oxygen beds"), (150, "Oxygen beds"), ] @@ -111,15 +107,12 @@ class FacilityFeature(models.IntegerChoices): # 950, "Corona Testing Labs" # Change from "Corona Testing Labs" to "Govt Labs" # Use 10xx for Corona Care Center # 1000, "Corona Care Centre" # Change from "Corona Care Centre" to "Other" - (1010, "COVID-19 Domiciliary Care Center"), # Use 11xx for First Line Treatment Centre (1100, "First Line Treatment Centre"), # Use 12xx for Second Line Treatment Center (1200, "Second Line Treatment Center"), # Use 13xx for Shifting Centers (1300, "Shifting Centre"), - # Use 14xx for Covid Management Centers. - (1400, "Covid Management Center"), # Use 15xx for Resource Management Centers. (1500, "Request Approving Center"), (1510, "Request Fulfilment Center"), diff --git a/care/facility/models/patient.py b/care/facility/models/patient.py index 4e8f98c130..b79e2f638e 100644 --- a/care/facility/models/patient.py +++ b/care/facility/models/patient.py @@ -61,7 +61,6 @@ class PatientRegistration(PatientBaseModel, PatientPermissionMixin): class SourceEnum(enum.Enum): CARE = 10 - COVID_TRACKER = 20 STAY = 30 SourceChoices = [(e.value, e.name) for e in SourceEnum] @@ -158,14 +157,6 @@ class TestTypeEnum(enum.Enum): verbose_name="Blood Group of Patient", ) - contact_with_confirmed_carrier = models.BooleanField( - default=False, verbose_name="Confirmed Contact with a Covid19 Carrier" - ) - contact_with_suspected_carrier = models.BooleanField( - default=False, verbose_name="Suspected Contact with a Covid19 Carrier" - ) - estimated_contact_date = models.DateTimeField(null=True, blank=True) - past_travel = models.BooleanField( default=False, verbose_name="Travelled to Any Foreign Countries in the last 28 Days", @@ -199,9 +190,6 @@ class TestTypeEnum(enum.Enum): blank=True, verbose_name="Already pescribed medication if any", ) - has_SARI = models.BooleanField( # noqa: N815 - default=False, verbose_name="Does the Patient Suffer from SARI" - ) is_antenatal = models.BooleanField( default=None, verbose_name="Does the patient require Prenatal Care ?" @@ -366,10 +354,6 @@ class TestTypeEnum(enum.Enum): # IDSP Requirements End # Vaccination Fields - is_vaccinated = models.BooleanField( - default=False, - verbose_name="Is the Patient Vaccinated Against COVID-19", - ) number_of_doses = models.PositiveIntegerField( default=0, null=False, @@ -384,17 +368,6 @@ class TestTypeEnum(enum.Enum): max_length=15, ) - covin_id = models.CharField( - max_length=15, - default=None, - null=True, - blank=True, - verbose_name="COVID-19 Vaccination ID", - ) - last_vaccinated_date = models.DateTimeField( - null=True, blank=True, verbose_name="Date Last Vaccinated" - ) - # Extras cluster_name = models.CharField( max_length=255, @@ -403,17 +376,8 @@ class TestTypeEnum(enum.Enum): null=True, blank=True, ) - is_declared_positive = models.BooleanField( - default=None, - null=True, - verbose_name="Is Patient Declared Positive", - ) - date_declared_positive = models.DateTimeField( - null=True, blank=True, verbose_name="Date Patient is Declared Positive" - ) # Permission Scopes - assigned_to = models.ForeignKey( User, on_delete=models.SET_NULL, @@ -665,8 +629,6 @@ class ModeOfContactEnum(enum.IntEnum): LIVE_IN_SAME_HOUSEHOLD = 4 # Close contact within 3ft (1m) of the confirmed case without precautions. CLOSE_CONTACT_WITHOUT_PRECAUTION = 5 - # Passenger of the aeroplane with a confirmed COVID -19 passenger for more than 6 hours. - CO_PASSENGER_AEROPLANE = 6 # Health care workers and other contacts who had full PPE while handling the +ve case HEALTH_CARE_WITH_PPE = 7 # Shared the same space(same class for school/worked in same room/similar and not having a high risk exposure diff --git a/care/facility/models/patient_base.py b/care/facility/models/patient_base.py index 5ce0b2106f..8e0c54cdce 100644 --- a/care/facility/models/patient_base.py +++ b/care/facility/models/patient_base.py @@ -58,15 +58,8 @@ def reverse_choices(choices): "Cancer": 7, "OTHER": 8, } -DISEASE_CHOICES = [(v, k) for k, v in DISEASE_CHOICES_MAP.items()] -COVID_CATEGORY_CHOICES = [ - ("ASYM", "ASYMPTOMATIC"), - ("Mild", "Category-A"), - ("Moderate", "Category-B"), - ("Severe", "Category-C"), - (None, "UNCLASSIFIED"), -] # Deprecated +DISEASE_CHOICES = [(v, k) for k, v in DISEASE_CHOICES_MAP.items()] CATEGORY_CHOICES = [ ("Comfort", "Comfort Care"), @@ -144,7 +137,6 @@ class BedType(enum.Enum): REVERSE_BLOOD_GROUP_CHOICES = reverse_choices(BLOOD_GROUP_CHOICES) REVERSE_DISEASE_STATUS_CHOICES = reverse_choices(DISEASE_STATUS_CHOICES) -REVERSE_COVID_CATEGORY_CHOICES = reverse_choices(COVID_CATEGORY_CHOICES) # Deprecated REVERSE_CATEGORY_CHOICES = reverse_choices(CATEGORY_CHOICES) REVERSE_BED_TYPE_CHOICES = reverse_choices(BedTypeChoices) REVERSE_ROUTE_TO_FACILITY_CHOICES = reverse_choices(RouteToFacility.choices) diff --git a/care/facility/models/patient_consultation.py b/care/facility/models/patient_consultation.py index f21d4f6a4d..3466c315e7 100644 --- a/care/facility/models/patient_consultation.py +++ b/care/facility/models/patient_consultation.py @@ -6,7 +6,6 @@ from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, PatientBaseModel, ) from care.facility.models.file_upload import FileUpload @@ -17,7 +16,6 @@ DISCHARGE_REASON_CHOICES, NEW_DISCHARGE_REASON_CHOICES, REVERSE_CATEGORY_CHOICES, - REVERSE_COVID_CATEGORY_CHOICES, RouteToFacility, SuggestionChoices, reverse_choices, @@ -65,13 +63,6 @@ class PatientConsultation(PatientBaseModel, ConsultationRelatedPermissionMixin): facility = models.ForeignKey( "Facility", on_delete=models.CASCADE, related_name="consultations" ) - deprecated_covid_category = models.CharField( - choices=COVID_CATEGORY_CHOICES, - max_length=8, - default=None, - blank=True, - null=True, - ) # Deprecated category = models.CharField( choices=CATEGORY_CHOICES, max_length=13, blank=False, null=True ) @@ -231,16 +222,12 @@ def get_related_consultation(self): "encounter_date": "Date of Admission", "deprecated_symptoms_onset_date": "Date of Onset of Symptoms", "deprecated_symptoms": "Symptoms at time of consultation", - "deprecated_covid_category": "Covid Category", "category": "Category", "examination_details": "Examination Details", "suggestion": "Suggestion", } CSV_MAKE_PRETTY = { - "deprecated_covid_category": ( - lambda x: REVERSE_COVID_CATEGORY_CHOICES.get(x, "-") - ), "category": lambda x: REVERSE_CATEGORY_CHOICES.get(x, "-"), "suggestion": ( lambda x: PatientConsultation.REVERSE_SUGGESTION_CHOICES.get(x, "-") diff --git a/care/facility/tests/test_patient_api.py b/care/facility/tests/test_patient_api.py index 6046435ddb..f78a7c2e02 100644 --- a/care/facility/tests/test_patient_api.py +++ b/care/facility/tests/test_patient_api.py @@ -845,18 +845,6 @@ def test_filter_by_invalid_params(self): res.json()["patient_no"], ) - def test_invalid_covin_id_param(self): - self.client.force_authenticate(user=self.user) - - # Test invalid covin_id length > 15 characters - invalid_covin_id = "A" * 16 - res = self.client.get(self.get_base_url() + f"?covin_id={invalid_covin_id}") - self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) - self.assertIn( - "Ensure this value has at most 15 characters (it has 16).", - res.json()["covin_id"], - ) - class DischargePatientFilterTestCase(TestUtils, APITestCase): @classmethod From 6ccd830f45a4697c1dcd8c2e0df7ada54ab05a6c Mon Sep 17 00:00:00 2001 From: Areeb Ahmed Date: Sun, 22 Dec 2024 02:45:41 +0530 Subject: [PATCH 2/5] Migrations --- ...ound_deprecated_covid_category_and_more.py | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py diff --git a/care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py b/care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py new file mode 100644 index 0000000000..01665940ac --- /dev/null +++ b/care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py @@ -0,0 +1,123 @@ +# Generated by Django 5.1.3 on 2024-12-21 21:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('facility', '0468_alter_facilitypatientstatshistory_unique_together_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='dailyround', + name='deprecated_covid_category', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='contact_with_confirmed_carrier', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='contact_with_suspected_carrier', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='covin_id', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='date_declared_positive', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='estimated_contact_date', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='has_SARI', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='is_declared_positive', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='is_vaccinated', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='last_vaccinated_date', + ), + migrations.RemoveField( + model_name='patientconsultation', + name='deprecated_covid_category', + ), + migrations.RemoveField( + model_name='patientregistration', + name='contact_with_confirmed_carrier', + ), + migrations.RemoveField( + model_name='patientregistration', + name='contact_with_suspected_carrier', + ), + migrations.RemoveField( + model_name='patientregistration', + name='covin_id', + ), + migrations.RemoveField( + model_name='patientregistration', + name='date_declared_positive', + ), + migrations.RemoveField( + model_name='patientregistration', + name='estimated_contact_date', + ), + migrations.RemoveField( + model_name='patientregistration', + name='has_SARI', + ), + migrations.RemoveField( + model_name='patientregistration', + name='is_declared_positive', + ), + migrations.RemoveField( + model_name='patientregistration', + name='is_vaccinated', + ), + migrations.RemoveField( + model_name='patientregistration', + name='last_vaccinated_date', + ), + migrations.AlterField( + model_name='facility', + name='facility_type', + field=models.IntegerField(choices=[(1, 'Educational Inst'), (2, 'Private Hospital'), (3, 'Other'), (4, 'Hostel'), (5, 'Hotel'), (6, 'Lodge'), (7, 'TeleMedicine'), (9, 'Govt Labs'), (10, 'Private Labs'), (800, 'Primary Health Centres'), (802, 'Family Health Centres'), (803, 'Community Health Centres'), (830, 'Taluk Hospitals'), (840, 'Women and Child Health Centres'), (860, 'District Hospitals'), (870, 'Govt Medical College Hospitals'), (900, 'Co-operative hospitals'), (910, 'Autonomous healthcare facility'), (1100, 'First Line Treatment Centre'), (1200, 'Second Line Treatment Center'), (1300, 'Shifting Centre'), (1500, 'Request Approving Center'), (1510, 'Request Fulfilment Center'), (1600, 'District War Room')]), + ), + migrations.AlterField( + model_name='historicalpatientregistration', + name='source', + field=models.IntegerField(choices=[(10, 'CARE'), (30, 'STAY')], default=10), + ), + migrations.AlterField( + model_name='patientcontactdetails', + name='mode_of_contact', + field=models.IntegerField(choices=[(1, 'TOUCHED_BODY_FLUIDS'), (2, 'DIRECT_PHYSICAL_CONTACT'), (3, 'CLEANED_USED_ITEMS'), (4, 'LIVE_IN_SAME_HOUSEHOLD'), (5, 'CLOSE_CONTACT_WITHOUT_PRECAUTION'), (7, 'HEALTH_CARE_WITH_PPE'), (8, 'SHARED_SAME_SPACE_WITHOUT_HIGH_EXPOSURE'), (9, 'TRAVELLED_TOGETHER_WITHOUT_HIGH_EXPOSURE')]), + ), + migrations.AlterField( + model_name='patientregistration', + name='source', + field=models.IntegerField(choices=[(10, 'CARE'), (30, 'STAY')], default=10), + ), + migrations.AlterField( + model_name='room', + name='room_type', + field=models.IntegerField(choices=[(0, 'Total'), (2, 'Hostel'), (3, 'Single Room with Attached Bathroom'), (40, 'KASP Beds'), (50, 'KASP ICU beds'), (60, 'KASP Oxygen beds'), (70, 'KASP Ventilator beds'), (1, 'General Bed'), (10, 'ICU'), (20, 'Ventilator'), (150, 'Oxygen beds')]), + ), + migrations.AlterField( + model_name='shiftingrequest', + name='assigned_facility_type', + field=models.IntegerField(blank=True, choices=[(1, 'Educational Inst'), (2, 'Private Hospital'), (3, 'Other'), (4, 'Hostel'), (5, 'Hotel'), (6, 'Lodge'), (7, 'TeleMedicine'), (9, 'Govt Labs'), (10, 'Private Labs'), (800, 'Primary Health Centres'), (802, 'Family Health Centres'), (803, 'Community Health Centres'), (830, 'Taluk Hospitals'), (840, 'Women and Child Health Centres'), (860, 'District Hospitals'), (870, 'Govt Medical College Hospitals'), (900, 'Co-operative hospitals'), (910, 'Autonomous healthcare facility'), (1100, 'First Line Treatment Centre'), (1200, 'Second Line Treatment Center'), (1300, 'Shifting Centre'), (1500, 'Request Approving Center'), (1510, 'Request Fulfilment Center'), (1600, 'District War Room')], default=None, null=True), + ), + ] From 0c97f8e5104a84b9e7bc86b0cfdd8fac417d535a Mon Sep 17 00:00:00 2001 From: Areeb Ahmed Date: Sun, 22 Dec 2024 02:05:47 +0530 Subject: [PATCH 3/5] Remove COVID-specific fields from Patient model and serializers --- care/facility/api/serializers/daily_round.py | 4 -- .../api/serializers/patient_consultation.py | 4 -- care/facility/api/viewsets/patient.py | 6 --- care/facility/models/daily_round.py | 8 ---- care/facility/models/facility.py | 7 ---- care/facility/models/patient.py | 38 ------------------- care/facility/models/patient_base.py | 10 +---- care/facility/models/patient_consultation.py | 13 ------- care/facility/tests/test_patient_api.py | 12 ------ 9 files changed, 1 insertion(+), 101 deletions(-) diff --git a/care/facility/api/serializers/daily_round.py b/care/facility/api/serializers/daily_round.py index bd8f105903..6bcd83b1bd 100644 --- a/care/facility/api/serializers/daily_round.py +++ b/care/facility/api/serializers/daily_round.py @@ -9,7 +9,6 @@ from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, PatientRegistration, ) from care.facility.models.bed import Bed @@ -27,9 +26,6 @@ class DailyRoundSerializer(serializers.ModelSerializer): id = serializers.CharField(source="external_id", read_only=True) - deprecated_covid_category = ChoiceField( - choices=COVID_CATEGORY_CHOICES, required=False - ) # Deprecated patient_category = ChoiceField(choices=CATEGORY_CHOICES, required=False) action = ChoiceField( diff --git a/care/facility/api/serializers/patient_consultation.py b/care/facility/api/serializers/patient_consultation.py index ac2fdf5d00..f5179ad563 100644 --- a/care/facility/api/serializers/patient_consultation.py +++ b/care/facility/api/serializers/patient_consultation.py @@ -25,7 +25,6 @@ from care.facility.api.serializers.facility import FacilityBasicInfoSerializer from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, Facility, PatientRegistration, Prescription, @@ -78,9 +77,6 @@ class PatientConsultationSerializer(serializers.ModelSerializer): source="suggestion", ) - deprecated_covid_category = ChoiceField( - choices=COVID_CATEGORY_CHOICES, required=False - ) category = ChoiceField(choices=CATEGORY_CHOICES, required=True) referred_to_object = FacilityBasicInfoSerializer( diff --git a/care/facility/api/viewsets/patient.py b/care/facility/api/viewsets/patient.py index 7b023c1531..836b5d0a8d 100644 --- a/care/facility/api/viewsets/patient.py +++ b/care/facility/api/viewsets/patient.py @@ -51,7 +51,6 @@ from care.facility.api.viewsets.mixins.history import HistoryMixin from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, DISCHARGE_REASON_CHOICES, FACILITY_TYPES, BedTypeChoices, @@ -122,10 +121,6 @@ class PatientFilterSet(filters.FilterSet): age_max = filters.NumberFilter( field_name="age", lookup_expr="lte", validators=[MinValueValidator(0)] ) - deprecated_covid_category = filters.ChoiceFilter( - field_name=f"{last_consultation_field}__deprecated_covid_category", - choices=COVID_CATEGORY_CHOICES, - ) category = filters.ChoiceFilter( method="filter_by_category", choices=CATEGORY_CHOICES, @@ -234,7 +229,6 @@ def filter_by_bed_type(self, queryset, name, value): ) # Vaccination Filters - covin_id = filters.CharFilter(field_name="covin_id", max_length=15) is_vaccinated = filters.BooleanFilter(field_name="is_vaccinated") number_of_doses = filters.NumberFilter( field_name="number_of_doses", diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index edc11a8954..0f5b76a980 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -7,7 +7,6 @@ from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, PatientBaseModel, ) from care.facility.models.bed import AssetBed @@ -166,13 +165,6 @@ class InsulinIntakeFrequencyType(models.IntegerChoices): max_digits=4, decimal_places=2, blank=True, null=True, default=None ) # Deprecated physical_examination_info = models.TextField(null=True, blank=True) - deprecated_covid_category = models.CharField( - choices=COVID_CATEGORY_CHOICES, - max_length=8, - default=None, - blank=True, - null=True, - ) # Deprecated patient_category = models.CharField( choices=CATEGORY_CHOICES, max_length=13, blank=False, null=True ) diff --git a/care/facility/models/facility.py b/care/facility/models/facility.py index 01c0102b10..0ec32567c7 100644 --- a/care/facility/models/facility.py +++ b/care/facility/models/facility.py @@ -26,10 +26,6 @@ (1, "General Bed"), (10, "ICU"), (20, "Ventilator"), - (30, "Covid Beds"), - (100, "Covid Ventilators"), - (110, "Covid ICU"), - (120, "Covid Oxygen beds"), (150, "Oxygen beds"), ] @@ -111,15 +107,12 @@ class FacilityFeature(models.IntegerChoices): # 950, "Corona Testing Labs" # Change from "Corona Testing Labs" to "Govt Labs" # Use 10xx for Corona Care Center # 1000, "Corona Care Centre" # Change from "Corona Care Centre" to "Other" - (1010, "COVID-19 Domiciliary Care Center"), # Use 11xx for First Line Treatment Centre (1100, "First Line Treatment Centre"), # Use 12xx for Second Line Treatment Center (1200, "Second Line Treatment Center"), # Use 13xx for Shifting Centers (1300, "Shifting Centre"), - # Use 14xx for Covid Management Centers. - (1400, "Covid Management Center"), # Use 15xx for Resource Management Centers. (1500, "Request Approving Center"), (1510, "Request Fulfilment Center"), diff --git a/care/facility/models/patient.py b/care/facility/models/patient.py index 4e8f98c130..b79e2f638e 100644 --- a/care/facility/models/patient.py +++ b/care/facility/models/patient.py @@ -61,7 +61,6 @@ class PatientRegistration(PatientBaseModel, PatientPermissionMixin): class SourceEnum(enum.Enum): CARE = 10 - COVID_TRACKER = 20 STAY = 30 SourceChoices = [(e.value, e.name) for e in SourceEnum] @@ -158,14 +157,6 @@ class TestTypeEnum(enum.Enum): verbose_name="Blood Group of Patient", ) - contact_with_confirmed_carrier = models.BooleanField( - default=False, verbose_name="Confirmed Contact with a Covid19 Carrier" - ) - contact_with_suspected_carrier = models.BooleanField( - default=False, verbose_name="Suspected Contact with a Covid19 Carrier" - ) - estimated_contact_date = models.DateTimeField(null=True, blank=True) - past_travel = models.BooleanField( default=False, verbose_name="Travelled to Any Foreign Countries in the last 28 Days", @@ -199,9 +190,6 @@ class TestTypeEnum(enum.Enum): blank=True, verbose_name="Already pescribed medication if any", ) - has_SARI = models.BooleanField( # noqa: N815 - default=False, verbose_name="Does the Patient Suffer from SARI" - ) is_antenatal = models.BooleanField( default=None, verbose_name="Does the patient require Prenatal Care ?" @@ -366,10 +354,6 @@ class TestTypeEnum(enum.Enum): # IDSP Requirements End # Vaccination Fields - is_vaccinated = models.BooleanField( - default=False, - verbose_name="Is the Patient Vaccinated Against COVID-19", - ) number_of_doses = models.PositiveIntegerField( default=0, null=False, @@ -384,17 +368,6 @@ class TestTypeEnum(enum.Enum): max_length=15, ) - covin_id = models.CharField( - max_length=15, - default=None, - null=True, - blank=True, - verbose_name="COVID-19 Vaccination ID", - ) - last_vaccinated_date = models.DateTimeField( - null=True, blank=True, verbose_name="Date Last Vaccinated" - ) - # Extras cluster_name = models.CharField( max_length=255, @@ -403,17 +376,8 @@ class TestTypeEnum(enum.Enum): null=True, blank=True, ) - is_declared_positive = models.BooleanField( - default=None, - null=True, - verbose_name="Is Patient Declared Positive", - ) - date_declared_positive = models.DateTimeField( - null=True, blank=True, verbose_name="Date Patient is Declared Positive" - ) # Permission Scopes - assigned_to = models.ForeignKey( User, on_delete=models.SET_NULL, @@ -665,8 +629,6 @@ class ModeOfContactEnum(enum.IntEnum): LIVE_IN_SAME_HOUSEHOLD = 4 # Close contact within 3ft (1m) of the confirmed case without precautions. CLOSE_CONTACT_WITHOUT_PRECAUTION = 5 - # Passenger of the aeroplane with a confirmed COVID -19 passenger for more than 6 hours. - CO_PASSENGER_AEROPLANE = 6 # Health care workers and other contacts who had full PPE while handling the +ve case HEALTH_CARE_WITH_PPE = 7 # Shared the same space(same class for school/worked in same room/similar and not having a high risk exposure diff --git a/care/facility/models/patient_base.py b/care/facility/models/patient_base.py index 5ce0b2106f..8e0c54cdce 100644 --- a/care/facility/models/patient_base.py +++ b/care/facility/models/patient_base.py @@ -58,15 +58,8 @@ def reverse_choices(choices): "Cancer": 7, "OTHER": 8, } -DISEASE_CHOICES = [(v, k) for k, v in DISEASE_CHOICES_MAP.items()] -COVID_CATEGORY_CHOICES = [ - ("ASYM", "ASYMPTOMATIC"), - ("Mild", "Category-A"), - ("Moderate", "Category-B"), - ("Severe", "Category-C"), - (None, "UNCLASSIFIED"), -] # Deprecated +DISEASE_CHOICES = [(v, k) for k, v in DISEASE_CHOICES_MAP.items()] CATEGORY_CHOICES = [ ("Comfort", "Comfort Care"), @@ -144,7 +137,6 @@ class BedType(enum.Enum): REVERSE_BLOOD_GROUP_CHOICES = reverse_choices(BLOOD_GROUP_CHOICES) REVERSE_DISEASE_STATUS_CHOICES = reverse_choices(DISEASE_STATUS_CHOICES) -REVERSE_COVID_CATEGORY_CHOICES = reverse_choices(COVID_CATEGORY_CHOICES) # Deprecated REVERSE_CATEGORY_CHOICES = reverse_choices(CATEGORY_CHOICES) REVERSE_BED_TYPE_CHOICES = reverse_choices(BedTypeChoices) REVERSE_ROUTE_TO_FACILITY_CHOICES = reverse_choices(RouteToFacility.choices) diff --git a/care/facility/models/patient_consultation.py b/care/facility/models/patient_consultation.py index f21d4f6a4d..3466c315e7 100644 --- a/care/facility/models/patient_consultation.py +++ b/care/facility/models/patient_consultation.py @@ -6,7 +6,6 @@ from care.facility.models import ( CATEGORY_CHOICES, - COVID_CATEGORY_CHOICES, PatientBaseModel, ) from care.facility.models.file_upload import FileUpload @@ -17,7 +16,6 @@ DISCHARGE_REASON_CHOICES, NEW_DISCHARGE_REASON_CHOICES, REVERSE_CATEGORY_CHOICES, - REVERSE_COVID_CATEGORY_CHOICES, RouteToFacility, SuggestionChoices, reverse_choices, @@ -65,13 +63,6 @@ class PatientConsultation(PatientBaseModel, ConsultationRelatedPermissionMixin): facility = models.ForeignKey( "Facility", on_delete=models.CASCADE, related_name="consultations" ) - deprecated_covid_category = models.CharField( - choices=COVID_CATEGORY_CHOICES, - max_length=8, - default=None, - blank=True, - null=True, - ) # Deprecated category = models.CharField( choices=CATEGORY_CHOICES, max_length=13, blank=False, null=True ) @@ -231,16 +222,12 @@ def get_related_consultation(self): "encounter_date": "Date of Admission", "deprecated_symptoms_onset_date": "Date of Onset of Symptoms", "deprecated_symptoms": "Symptoms at time of consultation", - "deprecated_covid_category": "Covid Category", "category": "Category", "examination_details": "Examination Details", "suggestion": "Suggestion", } CSV_MAKE_PRETTY = { - "deprecated_covid_category": ( - lambda x: REVERSE_COVID_CATEGORY_CHOICES.get(x, "-") - ), "category": lambda x: REVERSE_CATEGORY_CHOICES.get(x, "-"), "suggestion": ( lambda x: PatientConsultation.REVERSE_SUGGESTION_CHOICES.get(x, "-") diff --git a/care/facility/tests/test_patient_api.py b/care/facility/tests/test_patient_api.py index 6046435ddb..f78a7c2e02 100644 --- a/care/facility/tests/test_patient_api.py +++ b/care/facility/tests/test_patient_api.py @@ -845,18 +845,6 @@ def test_filter_by_invalid_params(self): res.json()["patient_no"], ) - def test_invalid_covin_id_param(self): - self.client.force_authenticate(user=self.user) - - # Test invalid covin_id length > 15 characters - invalid_covin_id = "A" * 16 - res = self.client.get(self.get_base_url() + f"?covin_id={invalid_covin_id}") - self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) - self.assertIn( - "Ensure this value has at most 15 characters (it has 16).", - res.json()["covin_id"], - ) - class DischargePatientFilterTestCase(TestUtils, APITestCase): @classmethod From 60c9a28804448e7231548ea7bcd24f8fb4296d6b Mon Sep 17 00:00:00 2001 From: Areeb Ahmed Date: Sun, 22 Dec 2024 02:45:41 +0530 Subject: [PATCH 4/5] Migrations --- ...ound_deprecated_covid_category_and_more.py | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py diff --git a/care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py b/care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py new file mode 100644 index 0000000000..01665940ac --- /dev/null +++ b/care/facility/migrations/0469_remove_dailyround_deprecated_covid_category_and_more.py @@ -0,0 +1,123 @@ +# Generated by Django 5.1.3 on 2024-12-21 21:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('facility', '0468_alter_facilitypatientstatshistory_unique_together_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='dailyround', + name='deprecated_covid_category', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='contact_with_confirmed_carrier', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='contact_with_suspected_carrier', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='covin_id', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='date_declared_positive', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='estimated_contact_date', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='has_SARI', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='is_declared_positive', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='is_vaccinated', + ), + migrations.RemoveField( + model_name='historicalpatientregistration', + name='last_vaccinated_date', + ), + migrations.RemoveField( + model_name='patientconsultation', + name='deprecated_covid_category', + ), + migrations.RemoveField( + model_name='patientregistration', + name='contact_with_confirmed_carrier', + ), + migrations.RemoveField( + model_name='patientregistration', + name='contact_with_suspected_carrier', + ), + migrations.RemoveField( + model_name='patientregistration', + name='covin_id', + ), + migrations.RemoveField( + model_name='patientregistration', + name='date_declared_positive', + ), + migrations.RemoveField( + model_name='patientregistration', + name='estimated_contact_date', + ), + migrations.RemoveField( + model_name='patientregistration', + name='has_SARI', + ), + migrations.RemoveField( + model_name='patientregistration', + name='is_declared_positive', + ), + migrations.RemoveField( + model_name='patientregistration', + name='is_vaccinated', + ), + migrations.RemoveField( + model_name='patientregistration', + name='last_vaccinated_date', + ), + migrations.AlterField( + model_name='facility', + name='facility_type', + field=models.IntegerField(choices=[(1, 'Educational Inst'), (2, 'Private Hospital'), (3, 'Other'), (4, 'Hostel'), (5, 'Hotel'), (6, 'Lodge'), (7, 'TeleMedicine'), (9, 'Govt Labs'), (10, 'Private Labs'), (800, 'Primary Health Centres'), (802, 'Family Health Centres'), (803, 'Community Health Centres'), (830, 'Taluk Hospitals'), (840, 'Women and Child Health Centres'), (860, 'District Hospitals'), (870, 'Govt Medical College Hospitals'), (900, 'Co-operative hospitals'), (910, 'Autonomous healthcare facility'), (1100, 'First Line Treatment Centre'), (1200, 'Second Line Treatment Center'), (1300, 'Shifting Centre'), (1500, 'Request Approving Center'), (1510, 'Request Fulfilment Center'), (1600, 'District War Room')]), + ), + migrations.AlterField( + model_name='historicalpatientregistration', + name='source', + field=models.IntegerField(choices=[(10, 'CARE'), (30, 'STAY')], default=10), + ), + migrations.AlterField( + model_name='patientcontactdetails', + name='mode_of_contact', + field=models.IntegerField(choices=[(1, 'TOUCHED_BODY_FLUIDS'), (2, 'DIRECT_PHYSICAL_CONTACT'), (3, 'CLEANED_USED_ITEMS'), (4, 'LIVE_IN_SAME_HOUSEHOLD'), (5, 'CLOSE_CONTACT_WITHOUT_PRECAUTION'), (7, 'HEALTH_CARE_WITH_PPE'), (8, 'SHARED_SAME_SPACE_WITHOUT_HIGH_EXPOSURE'), (9, 'TRAVELLED_TOGETHER_WITHOUT_HIGH_EXPOSURE')]), + ), + migrations.AlterField( + model_name='patientregistration', + name='source', + field=models.IntegerField(choices=[(10, 'CARE'), (30, 'STAY')], default=10), + ), + migrations.AlterField( + model_name='room', + name='room_type', + field=models.IntegerField(choices=[(0, 'Total'), (2, 'Hostel'), (3, 'Single Room with Attached Bathroom'), (40, 'KASP Beds'), (50, 'KASP ICU beds'), (60, 'KASP Oxygen beds'), (70, 'KASP Ventilator beds'), (1, 'General Bed'), (10, 'ICU'), (20, 'Ventilator'), (150, 'Oxygen beds')]), + ), + migrations.AlterField( + model_name='shiftingrequest', + name='assigned_facility_type', + field=models.IntegerField(blank=True, choices=[(1, 'Educational Inst'), (2, 'Private Hospital'), (3, 'Other'), (4, 'Hostel'), (5, 'Hotel'), (6, 'Lodge'), (7, 'TeleMedicine'), (9, 'Govt Labs'), (10, 'Private Labs'), (800, 'Primary Health Centres'), (802, 'Family Health Centres'), (803, 'Community Health Centres'), (830, 'Taluk Hospitals'), (840, 'Women and Child Health Centres'), (860, 'District Hospitals'), (870, 'Govt Medical College Hospitals'), (900, 'Co-operative hospitals'), (910, 'Autonomous healthcare facility'), (1100, 'First Line Treatment Centre'), (1200, 'Second Line Treatment Center'), (1300, 'Shifting Centre'), (1500, 'Request Approving Center'), (1510, 'Request Fulfilment Center'), (1600, 'District War Room')], default=None, null=True), + ), + ] From 8f74e81d8923cc42540e057f6666bbce455e5a67 Mon Sep 17 00:00:00 2001 From: Areeb Ahmed Date: Tue, 31 Dec 2024 11:49:42 +0530 Subject: [PATCH 5/5] Remove unused fields from test utility data --- care/utils/tests/test_utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/care/utils/tests/test_utils.py b/care/utils/tests/test_utils.py index 99faed645b..9f001172d3 100644 --- a/care/utils/tests/test_utils.py +++ b/care/utils/tests/test_utils.py @@ -286,13 +286,9 @@ def get_patient_data(cls, district, state) -> dict: "disease_status": "SUSPECTED", "phone_number": "+918888888888", "address": "Global citizen", - "contact_with_confirmed_carrier": True, - "contact_with_suspected_carrier": True, - "estimated_contact_date": None, "past_travel": False, "countries_travelled": ["Italy"], "present_health": "Fine", - "has_SARI": False, "is_active": True, "state_id": state.id, "district_id": district.id,