Skip to content

Commit

Permalink
pre-commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-sharmav committed Nov 6, 2024
1 parent 25cf4b4 commit b5f08ed
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions care/facility/api/serializers/prescription.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import contextlib

from django.shortcuts import get_object_or_404
from django.utils import timezone
from rest_framework import serializers
Expand Down Expand Up @@ -142,10 +140,12 @@ def validate(self, attrs):
max_dosage_value = float(max_dosage.split(" ", maxsplit=1)[0])
base_unit = base_dosage.split(" ", maxsplit=1)[1]
max_unit = max_dosage.split(" ", maxsplit=1)[1]

if base_unit != max_unit:
raise serializers.ValidationError(
{"max_dosage": f"Max dosage units ({max_unit}) must match base dosage units ({base_unit})."}
{
"max_dosage": f"Max dosage units ({max_unit}) must match base dosage units ({base_unit})."
}
)

if max_dosage_value < base_dosage_value:
Expand All @@ -156,7 +156,9 @@ def validate(self, attrs):
)
except (ValueError, IndexError) as e:
raise serializers.ValidationError(
{"max_dosage": "Invalid dosage format. Expected format: 'number unit' (e.g., '500 mg')"}
{
"max_dosage": "Invalid dosage format. Expected format: 'number unit' (e.g., '500 mg')"
}
) from e
if attrs.get("dosage_type") == PrescriptionDosageType.PRN:
if not attrs.get("indicator"):
Expand Down

0 comments on commit b5f08ed

Please sign in to comment.