Spaces:
Running
Running
| """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)} | |