diff --git a/Pipfile b/Pipfile index 6beddc1590..56f0fd7421 100644 --- a/Pipfile +++ b/Pipfile @@ -14,7 +14,6 @@ django-cors-headers = "==4.3.1" django-filter = "==24.2" django-maintenance-mode = "==0.21.1" django-model-utils = "==4.5.1" -django-multiselectfield = "==0.1.12" django-queryset-csv = "==1.1.0" django-ratelimit = "==4.1.0" django-redis = "==5.4.0" diff --git a/Pipfile.lock b/Pipfile.lock index 6cfb4f13d5..a05d26ac90 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "0f478643ec74971469522c09c3e635a7ca9346c16a687ae7c14c7f638335cb1e" + "sha256": "81cab9840716883c05f3a21732b616658bab7dc3d0636e93e5612316c6319acf" }, "pipfile-spec": 6, "requires": { @@ -526,14 +526,6 @@ "markers": "python_version >= '3.8'", "version": "==4.5.1" }, - "django-multiselectfield": { - "hashes": [ - "sha256:c270faa7f80588214c55f2d68cbddb2add525c2aa830c216b8a198de914eb470", - "sha256:d0a4c71568fb2332c71478ffac9f8708e01314a35cf923dfd7a191343452f9f9" - ], - "index": "pypi", - "version": "==0.1.12" - }, "django-queryset-csv": { "hashes": [ "sha256:46b4fd55686d40c81d4ee725155bde73c9ffd201b7f87d9abfea3679cc7a4a86" diff --git a/care/audit_log/helpers.py b/care/audit_log/helpers.py index cd07097ba6..698ebdc5b9 100644 --- a/care/audit_log/helpers.py +++ b/care/audit_log/helpers.py @@ -4,7 +4,6 @@ from typing import List, NamedTuple from django.conf import settings -from multiselectfield.db.fields import MSFList from rest_framework.utils.encoders import JSONEncoder @@ -15,7 +14,7 @@ def remove_non_member_fields(d: dict): def instance_finder(v): return isinstance( v, - (list, dict, set, MSFList), + (list, dict, set), ) diff --git a/care/facility/migrations/0001_initial_squashed.py b/care/facility/migrations/0001_initial_squashed.py index 13c562ae68..9d2ed01273 100644 --- a/care/facility/migrations/0001_initial_squashed.py +++ b/care/facility/migrations/0001_initial_squashed.py @@ -7,7 +7,6 @@ import django.core.validators import django.db.models.deletion import django.utils.timezone -import multiselectfield.db.fields import simple_history.models from django.conf import settings from django.db import migrations, models @@ -1039,7 +1038,7 @@ class Migration(migrations.Migration): ("physical_examination_info", models.TextField(blank=True, null=True)), ( "additional_symptoms", - multiselectfield.db.fields.MultiSelectField( + models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -2052,7 +2051,7 @@ class Migration(migrations.Migration): ("kasp_empanelled", models.BooleanField(default=False)), ( "features", - multiselectfield.db.fields.MultiSelectField( + models.CharField( blank=True, choices=[ (1, "CT Scan Facility"), @@ -2402,7 +2401,7 @@ class Migration(migrations.Migration): ), ( "symptoms", - multiselectfield.db.fields.MultiSelectField( + models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -4330,7 +4329,7 @@ class Migration(migrations.Migration): ), ( "symptoms", - multiselectfield.db.fields.MultiSelectField( + models.CharField( choices=[ (1, "ASYMPTOMATIC"), (2, "FEVER"), diff --git a/care/facility/migrations/0407_alter_dailyround_additional_symptoms_and_more.py b/care/facility/migrations/0407_alter_dailyround_additional_symptoms_and_more.py index 08855c3d29..89f5e3360e 100644 --- a/care/facility/migrations/0407_alter_dailyround_additional_symptoms_and_more.py +++ b/care/facility/migrations/0407_alter_dailyround_additional_symptoms_and_more.py @@ -1,7 +1,6 @@ # Generated by Django 4.2.5 on 2024-01-08 17:26 -import multiselectfield.db.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="dailyround", name="additional_symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -58,7 +57,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -103,7 +102,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientteleconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( choices=[ (1, "ASYMPTOMATIC"), (2, "FEVER"), diff --git a/care/facility/migrations/0455_remove_facility_old_features.py b/care/facility/migrations/0455_remove_facility_old_features.py new file mode 100644 index 0000000000..fca6226ca5 --- /dev/null +++ b/care/facility/migrations/0455_remove_facility_old_features.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.15 on 2024-09-11 13:32 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("facility", "0454_remove_historicalpatientregistration_abha_number_and_more"), + ] + + operations = [ + migrations.RemoveField( + model_name="facility", + name="old_features", + ), + ] diff --git a/care/facility/migrations_old/0022_patientregistration_patientteleconsultation.py b/care/facility/migrations_old/0022_patientregistration_patientteleconsultation.py index 88dfcb3e74..bf2456fd72 100644 --- a/care/facility/migrations_old/0022_patientregistration_patientteleconsultation.py +++ b/care/facility/migrations_old/0022_patientregistration_patientteleconsultation.py @@ -2,7 +2,6 @@ import django.core.validators import django.db.models.deletion -import multiselectfield.db.fields from django.conf import settings from django.db import migrations, models @@ -28,7 +27,7 @@ class Migration(migrations.Migration): ), ( "symptoms", - multiselectfield.db.fields.MultiSelectField( + models.CharField( choices=[ (1, "NO"), (2, "FEVER"), @@ -94,7 +93,7 @@ class Migration(migrations.Migration): ), ( "medical_history", - multiselectfield.db.fields.MultiSelectField( + models.CharField( choices=[ (1, "NO"), (2, "Diabetes"), diff --git a/care/facility/migrations_old/0068_auto_20200402_2149.py b/care/facility/migrations_old/0068_auto_20200402_2149.py index 1e169d0e9c..f447c6f5ff 100644 --- a/care/facility/migrations_old/0068_auto_20200402_2149.py +++ b/care/facility/migrations_old/0068_auto_20200402_2149.py @@ -1,6 +1,5 @@ # Generated by Django 2.2.11 on 2020-04-02 21:49 -import multiselectfield.db.fields from django.db import migrations, models @@ -49,7 +48,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name="patientconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( choices=[ (1, "ASYMPTOMATIC"), (2, "FEVER"), @@ -73,7 +72,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientteleconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( choices=[ (1, "ASYMPTOMATIC"), (2, "FEVER"), diff --git a/care/facility/migrations_old/0069_auto_20200402_2209.py b/care/facility/migrations_old/0069_auto_20200402_2209.py index 68119c6ed5..318c5c53ea 100644 --- a/care/facility/migrations_old/0069_auto_20200402_2209.py +++ b/care/facility/migrations_old/0069_auto_20200402_2209.py @@ -1,7 +1,6 @@ # Generated by Django 2.2.11 on 2020-04-02 22:09 -import multiselectfield.db.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), diff --git a/care/facility/migrations_old/0074_auto_20200404_2352.py b/care/facility/migrations_old/0074_auto_20200404_2352.py index 4af11eaa64..8fe70656a5 100644 --- a/care/facility/migrations_old/0074_auto_20200404_2352.py +++ b/care/facility/migrations_old/0074_auto_20200404_2352.py @@ -1,6 +1,5 @@ # Generated by Django 2.2.11 on 2020-04-04 18:22 -import multiselectfield.db.fields from django.db import migrations, models @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name="dailyround", name="additional_symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), diff --git a/care/facility/migrations_old/0075_auto_20200405_1122.py b/care/facility/migrations_old/0075_auto_20200405_1122.py index e1f2555b81..cecd1a8cf6 100644 --- a/care/facility/migrations_old/0075_auto_20200405_1122.py +++ b/care/facility/migrations_old/0075_auto_20200405_1122.py @@ -1,7 +1,6 @@ # Generated by Django 2.2.11 on 2020-04-05 05:52 -import multiselectfield.db.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="dailyround", name="additional_symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -35,7 +34,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -57,7 +56,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientteleconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( choices=[ (1, "ASYMPTOMATIC"), (2, "FEVER"), diff --git a/care/facility/migrations_old/0077_auto_20200409_0422.py b/care/facility/migrations_old/0077_auto_20200409_0422.py index 4a4fceaa42..3b90fc196c 100644 --- a/care/facility/migrations_old/0077_auto_20200409_0422.py +++ b/care/facility/migrations_old/0077_auto_20200409_0422.py @@ -1,7 +1,6 @@ # Generated by Django 2.2.11 on 2020-04-08 22:52 -import multiselectfield.db.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="dailyround", name="additional_symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -41,7 +40,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -69,7 +68,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientteleconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( choices=[ (1, "ASYMPTOMATIC"), (2, "FEVER"), diff --git a/care/facility/migrations_old/0298_facility_features.py b/care/facility/migrations_old/0298_facility_features.py index 13a84be631..1986e11f25 100644 --- a/care/facility/migrations_old/0298_facility_features.py +++ b/care/facility/migrations_old/0298_facility_features.py @@ -1,7 +1,6 @@ # Generated by Django 2.2.11 on 2022-06-22 13:06 -import multiselectfield.db.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name="facility", name="features", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "CT Scan Facility"), diff --git a/care/facility/migrations_old/0313_auto_20220901_2213.py b/care/facility/migrations_old/0313_auto_20220901_2213.py index 569d170cb7..f0da2f2a2c 100644 --- a/care/facility/migrations_old/0313_auto_20220901_2213.py +++ b/care/facility/migrations_old/0313_auto_20220901_2213.py @@ -1,7 +1,6 @@ # Generated by Django 2.2.11 on 2022-09-01 16:43 -import multiselectfield.db.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="facility", name="features", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "CT Scan Facility"), diff --git a/care/facility/migrations_old/0335_auto_20230207_1914.py b/care/facility/migrations_old/0335_auto_20230207_1914.py index c628eed6e4..2b443ae864 100644 --- a/care/facility/migrations_old/0335_auto_20230207_1914.py +++ b/care/facility/migrations_old/0335_auto_20230207_1914.py @@ -1,7 +1,6 @@ # Generated by Django 2.2.11 on 2023-02-07 13:44 -import multiselectfield.db.fields -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -13,7 +12,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="dailyround", name="additional_symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -48,7 +47,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( blank=True, choices=[ (1, "ASYMPTOMATIC"), @@ -83,7 +82,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="patientteleconsultation", name="symptoms", - field=multiselectfield.db.fields.MultiSelectField( + field=models.CharField( choices=[ (1, "ASYMPTOMATIC"), (2, "FEVER"), diff --git a/care/facility/models/facility.py b/care/facility/models/facility.py index 53bcac81ea..8b231d5a50 100644 --- a/care/facility/models/facility.py +++ b/care/facility/models/facility.py @@ -3,8 +3,6 @@ from django.contrib.postgres.fields import ArrayField from django.core.validators import MinValueValidator from django.db import models -from multiselectfield import MultiSelectField -from multiselectfield.utils import get_max_length from simple_history.models import HistoricalRecords from care.facility.models import FacilityBaseModel, reverse_choices @@ -194,12 +192,6 @@ class Facility(FacilityBaseModel, FacilityPermissionMixin): blank=True, null=True, ) - old_features = MultiSelectField( - choices=FEATURE_CHOICES, - null=True, - blank=True, - max_length=get_max_length(FEATURE_CHOICES, None), - ) longitude = models.DecimalField( max_digits=22, decimal_places=16, null=True, blank=True ) diff --git a/care/utils/event_utils.py b/care/utils/event_utils.py index 12d0dca91a..cb18c22128 100644 --- a/care/utils/event_utils.py +++ b/care/utils/event_utils.py @@ -4,7 +4,6 @@ from django.core.exceptions import FieldDoesNotExist from django.db.models import Field, Model -from multiselectfield.db.fields import MSFList, MultiSelectField logger = getLogger(__name__) @@ -17,12 +16,7 @@ def get_changed_fields(old: Model, new: Model) -> set[str]: changed_fields: set[str] = set() for field in new._meta.fields: field_name = field.name - if isinstance(field, MultiSelectField): - old_val = set(getattr(old, field_name, [])) - new_val = set(map(str, getattr(new, field_name, []))) - if old_val != new_val: - changed_fields.add(field_name) - elif getattr(old, field_name, None) != getattr(new, field_name, None): + if getattr(old, field_name, None) != getattr(new, field_name, None): changed_fields.add(field_name) return changed_fields @@ -59,12 +53,6 @@ def model_diff(old, new): diff = {} for field in new._meta.fields: field_name = field.name - if isinstance(field, MultiSelectField): - old_val = set(getattr(old, field_name, [])) - new_val = set(map(str, getattr(new, field_name, []))) - if old_val != new_val: - diff[field_name] = new_val - continue if getattr(old, field_name, None) != getattr(new, field_name, None): diff[field_name] = getattr(new, field_name, None) @@ -73,8 +61,6 @@ def model_diff(old, new): class CustomJSONEncoder(JSONEncoder): def default(self, o): - if isinstance(o, MSFList): - return list(map(str, o)) if isinstance(o, set): return list(o) if isinstance(o, datetime): diff --git a/pyproject.toml b/pyproject.toml index dee717bcba..930e81fc03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,6 @@ known_third_party = [ "healthy_django", "jsonschema", "jwt", - "multiselectfield", "phonenumber_field", "phonenumbers", "pytz",