diff --git a/care/facility/migrations/0386_alter_historicalpatientregistration_action_and_more.py b/care/facility/migrations/0386_alter_historicalpatientregistration_action_and_more.py new file mode 100644 index 0000000000..54c1700108 --- /dev/null +++ b/care/facility/migrations/0386_alter_historicalpatientregistration_action_and_more.py @@ -0,0 +1,62 @@ +from django.db import migrations, models + + +def update_recommend_discharge(apps, schema_editor): + patient_model = apps.get_model("facility", "PatientRegistration") + patient_model.objects.filter( + last_consultation__last_daily_round__recommend_discharge=True + ).update(action=90) + + +class Migration(migrations.Migration): + dependencies = [ + ("facility", "0385_alter_patientconsultation_verified_by"), + ] + + operations = [ + migrations.AlterField( + model_name="historicalpatientregistration", + name="action", + field=models.IntegerField( + blank=True, + choices=[ + (10, "NO_ACTION"), + (20, "PENDING"), + (30, "SPECIALIST_REQUIRED"), + (40, "PLAN_FOR_HOME_CARE"), + (50, "FOLLOW_UP_NOT_REQUIRED"), + (60, "COMPLETE"), + (70, "REVIEW"), + (80, "NOT_REACHABLE"), + (90, "DISCHARGE_RECOMMENDED"), + ], + default=10, + null=True, + ), + ), + migrations.AlterField( + model_name="patientregistration", + name="action", + field=models.IntegerField( + blank=True, + choices=[ + (10, "NO_ACTION"), + (20, "PENDING"), + (30, "SPECIALIST_REQUIRED"), + (40, "PLAN_FOR_HOME_CARE"), + (50, "FOLLOW_UP_NOT_REQUIRED"), + (60, "COMPLETE"), + (70, "REVIEW"), + (80, "NOT_REACHABLE"), + (90, "DISCHARGE_RECOMMENDED"), + ], + default=10, + null=True, + ), + ), + migrations.RunPython(update_recommend_discharge), + migrations.RemoveField( + model_name="dailyround", + name="recommend_discharge", + ), + ] diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index 89575f5058..83b6f02f18 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -122,7 +122,9 @@ class InsulinIntakeFrequencyType(enum.Enum): ] consultation = models.ForeignKey( - PatientConsultation, on_delete=models.PROTECT, related_name="daily_rounds" + PatientConsultation, + on_delete=models.PROTECT, + related_name="daily_rounds", ) temperature = models.DecimalField( decimal_places=2, @@ -158,9 +160,6 @@ class InsulinIntakeFrequencyType(enum.Enum): current_health = models.IntegerField( default=0, choices=CURRENT_HEALTH_CHOICES, blank=True ) - recommend_discharge = models.BooleanField( - default=False, verbose_name="Recommend Discharging Patient" - ) other_details = models.TextField(null=True, blank=True) medication_given = JSONField(default=dict) # To be Used Later on @@ -168,7 +167,10 @@ class InsulinIntakeFrequencyType(enum.Enum): created_by_telemedicine = models.BooleanField(default=False) created_by = models.ForeignKey( - User, on_delete=models.SET_NULL, null=True, related_name="update_created_user" + User, + on_delete=models.SET_NULL, + null=True, + related_name="update_created_user", ) last_edited_by = models.ForeignKey( @@ -265,7 +267,8 @@ class InsulinIntakeFrequencyType(enum.Enum): rhythm = models.IntegerField(choices=RythmnChoice, default=RythmnType.UNKNOWN.value) rhythm_detail = models.TextField(default=None, null=True, blank=True) ventilator_interface = models.IntegerField( - choices=VentilatorInterfaceChoice, default=VentilatorInterfaceType.UNKNOWN.value + choices=VentilatorInterfaceChoice, + default=VentilatorInterfaceType.UNKNOWN.value, ) ventilator_mode = models.IntegerField( choices=VentilatorModeChoice, default=VentilatorModeType.UNKNOWN.value @@ -339,7 +342,8 @@ class InsulinIntakeFrequencyType(enum.Enum): validators=[MinValueValidator(0), MaxValueValidator(10)], ) pain_scale_enhanced = JSONField( - default=list, validators=[JSONFieldSchemaValidator(PAIN_SCALE_ENHANCED)] + default=list, + validators=[JSONFieldSchemaValidator(PAIN_SCALE_ENHANCED)], ) ph = models.DecimalField( decimal_places=2, @@ -457,9 +461,26 @@ def cztn(self, value): return value def update_pressure_sore(self): - area_interval_points = [0.1, 0.3, 0.7, 1.1, 2.1, 3.1, 4.1, 8.1, 12.1, 25] + area_interval_points = [ + 0.1, + 0.3, + 0.7, + 1.1, + 2.1, + 3.1, + 4.1, + 8.1, + 12.1, + 25, + ] exudate_amounts = ["None", "Light", "Moderate", "Heavy"] - tissue_types = ["Closed", "Epithelial", "Granulation", "Slough", "Necrotic"] + tissue_types = [ + "Closed", + "Epithelial", + "Granulation", + "Slough", + "Necrotic", + ] def cal_push_score(item): push_score = item.get("base_score", 0.0) diff --git a/care/facility/models/patient.py b/care/facility/models/patient.py index 44fe0ee1a6..cd14e5fcfa 100644 --- a/care/facility/models/patient.py +++ b/care/facility/models/patient.py @@ -77,6 +77,7 @@ class ActionEnum(enum.Enum): COMPLETE = 60 REVIEW = 70 NOT_REACHABLE = 80 + DISCHARGE_RECOMMENDED = 90 ActionChoices = [(e.value, e.name) for e in ActionEnum]