bug fixes
This commit is contained in:
@@ -30,12 +30,27 @@ async def handle_medication(message, session, parsed):
|
||||
unit = parsed.get("unit", "mg")
|
||||
frequency = parsed.get("frequency", "daily")
|
||||
times = parsed.get("times", ["08:00"])
|
||||
days_of_week = parsed.get("days_of_week", [])
|
||||
interval_days = parsed.get("interval_days")
|
||||
|
||||
if not name or not dosage:
|
||||
await message.channel.send("Please provide medication name and dosage.")
|
||||
return
|
||||
|
||||
data = {"name": name, "dosage": dosage, "unit": unit, "frequency": frequency, "times": times}
|
||||
data = {
|
||||
"name": name,
|
||||
"dosage": dosage,
|
||||
"unit": unit,
|
||||
"frequency": frequency,
|
||||
"times": times
|
||||
}
|
||||
|
||||
# Add optional fields if present
|
||||
if days_of_week:
|
||||
data["days_of_week"] = days_of_week
|
||||
if interval_days:
|
||||
data["interval_days"] = interval_days
|
||||
|
||||
resp, status = api_request("post", "/api/medications", token, data)
|
||||
if status == 201:
|
||||
await message.channel.send(f"Added **{name}** to your medications!")
|
||||
|
||||
Reference in New Issue
Block a user