Skip to content

Commit

Permalink
Merge pull request #2290 from coronasafe/rithviknishad/feat/expand-pr…
Browse files Browse the repository at this point in the history
…escription-units-and-routes

Adds additional units and route to prescriptions
  • Loading branch information
vigneshhari authored Jul 8, 2024
2 parents 1912662 + 9f27b7c commit 7d756d6
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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",
},
)
],
),
),
]
1 change: 1 addition & 0 deletions care/facility/models/prescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Routes(enum.Enum):
INTRATHECAL = "intrathecal injection"
TRANSDERMAL = "Transdermal"
RECTAL = "Rectal"
SUBLINGUAL = "Sublingual"


class PrescriptionType(enum.Enum):
Expand Down
4 changes: 2 additions & 2 deletions care/utils/models/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
)

0 comments on commit 7d756d6

Please sign in to comment.