diff --git a/care/facility/migrations/0444_alter_medicineadministration_dosage_and_more.py b/care/facility/migrations/0444_alter_medicineadministration_dosage_and_more.py new file mode 100644 index 0000000000..fcc9a96044 --- /dev/null +++ b/care/facility/migrations/0444_alter_medicineadministration_dosage_and_more.py @@ -0,0 +1,143 @@ +# Generated by Django 4.2.8 on 2024-07-05 10:47 + +from django.db import migrations, models + +import care.utils.models.validators + + +class Migration(migrations.Migration): + dependencies = [ + ("facility", "0443_remove_patientconsultation_consent_records_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="medicineadministration", + name="dosage", + field=models.CharField( + blank=True, + max_length=100, + null=True, + validators=[ + care.utils.models.validators.DenominationValidator( + allow_floats=True, + max_amount=5000, + min_amount=0.0001, + precision=4, + units={ + "ampule(s)", + "mg", + "g", + "tsp", + "drop(s)", + "mcg", + "unit(s)", + "ml", + }, + ) + ], + ), + ), + migrations.AlterField( + model_name="prescription", + name="base_dosage", + field=models.CharField( + blank=True, + max_length=100, + null=True, + validators=[ + care.utils.models.validators.DenominationValidator( + allow_floats=True, + max_amount=5000, + min_amount=0.0001, + precision=4, + units={ + "ampule(s)", + "mg", + "g", + "tsp", + "drop(s)", + "mcg", + "unit(s)", + "ml", + }, + ) + ], + ), + ), + migrations.AlterField( + model_name="prescription", + name="max_dosage", + field=models.CharField( + blank=True, + max_length=100, + null=True, + validators=[ + care.utils.models.validators.DenominationValidator( + allow_floats=True, + max_amount=5000, + min_amount=0.0001, + precision=4, + units={ + "ampule(s)", + "mg", + "g", + "tsp", + "drop(s)", + "mcg", + "unit(s)", + "ml", + }, + ) + ], + ), + ), + migrations.AlterField( + model_name="prescription", + name="route", + field=models.CharField( + blank=True, + choices=[ + ("ORAL", "Oral"), + ("IV", "IV"), + ("IM", "IM"), + ("SC", "S/C"), + ("INHALATION", "Inhalation"), + ("NASOGASTRIC", "Nasogastric/Gastrostomy tube"), + ("INTRATHECAL", "intrathecal injection"), + ("TRANSDERMAL", "Transdermal"), + ("RECTAL", "Rectal"), + ("SUBLINGUAL", "Sublingual"), + ], + max_length=100, + null=True, + ), + ), + migrations.AlterField( + model_name="prescription", + name="target_dosage", + field=models.CharField( + blank=True, + max_length=100, + null=True, + validators=[ + care.utils.models.validators.DenominationValidator( + allow_floats=True, + max_amount=5000, + min_amount=0.0001, + precision=4, + units={ + "ampule(s)", + "mg", + "g", + "tsp", + "drop(s)", + "mcg", + "unit(s)", + "ml", + }, + ) + ], + ), + ), + ] diff --git a/care/facility/models/prescription.py b/care/facility/models/prescription.py index 3c9bdedba2..05ecee76fc 100644 --- a/care/facility/models/prescription.py +++ b/care/facility/models/prescription.py @@ -35,6 +35,7 @@ class Routes(enum.Enum): INTRATHECAL = "intrathecal injection" TRANSDERMAL = "Transdermal" RECTAL = "Rectal" + SUBLINGUAL = "Sublingual" class PrescriptionType(enum.Enum): diff --git a/care/utils/models/validators.py b/care/utils/models/validators.py index dbc85faf0c..1ef8dc2625 100644 --- a/care/utils/models/validators.py +++ b/care/utils/models/validators.py @@ -158,7 +158,7 @@ def __call__(self, value: str): if len(amount) != len(str(amount_number)): raise ValidationError( - f"Input amount must be a valid number without leading{ ' or trailing ' if self.allow_floats else ' ' }zeroes" + f"Input amount must be a valid number without leading{' or trailing ' if self.allow_floats else ' '}zeroes" ) if self.min_amount > amount_number or amount_number > self.max_amount: @@ -190,7 +190,7 @@ def __eq__(self, __value: object) -> bool: # pragma: no cover dosage_validator = DenominationValidator( min_amount=0.0001, max_amount=5000, - units={"mg", "g", "ml", "drop(s)", "ampule(s)", "tsp"}, + units={"mg", "g", "ml", "drop(s)", "ampule(s)", "tsp", "mcg", "unit(s)"}, allow_floats=True, precision=4, )