Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow negative values for Doctor Count for facility #1505

Merged
merged 12 commits into from
Dec 7, 2023
24 changes: 24 additions & 0 deletions care/facility/migrations/0393_alter_hospitaldoctors_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.2 on 2023-10-20 10:15

from django.db import migrations, models
from django.db.models import F


def convert_negative_to_positive(apps, schema_editor):
HospitalDoctors = apps.get_model("care", "HospitalDoctors")
HospitalDoctors.objects.filter(count__lt=0).update(count=F("count") * -1)


class Migration(migrations.Migration):
dependencies = [
("facility", "0392_alter_dailyround_consciousness_level"),
]

operations = [
migrations.RunPython(convert_negative_to_positive),
migrations.AlterField(
model_name="hospitaldoctors",
name="count",
field=models.PositiveIntegerField(),
),
]
2 changes: 1 addition & 1 deletion care/facility/models/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class HospitalDoctors(FacilityBaseModel, FacilityRelatedPermissionMixin):
"Facility", on_delete=models.CASCADE, null=False, blank=False
)
area = models.IntegerField(choices=DOCTOR_TYPES)
count = models.IntegerField()
count = models.PositiveIntegerField()

def __str__(self):
return str(self.facility) + str(self.count)
Expand Down
Loading