Spaces:
Running
Running
File size: 679 Bytes
877add7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """Medication reconciliation agent."""
from __future__ import annotations
from app.common.types import PolyGuardState
from app.knowledge.drug_catalog import canonicalize_drug_name
class MedRecAgent:
name = "MedRecAgent"
def run(self, state: PolyGuardState) -> dict:
normalized = []
duplicates = set()
seen = set()
for med in state.patient.medications:
med.drug = canonicalize_drug_name(med.drug)
normalized.append(med.drug)
if med.drug in seen:
duplicates.add(med.drug)
seen.add(med.drug)
return {"normalized_meds": normalized, "duplicates": sorted(duplicates)}
|