modules/medication.mdEngineering, modules~1 min read

Module: medication

Part of the Travi AI Agent monolith (app/modules/medication/). Read 00-overview.md §3 (hard rules) before changing anything here.

Purpose The four separate truths about a medication, instruction, transmission, access, use, kept physically separate so they can never be conflated.
Owns (data) medication_plan_item, medication_status_event
Public surface /medications, /medications/{id}/status
Depends on compiler (plan-item publication), episode (med tasks), agents (med-access evidence)
Requirements owned MED-003/005/006/010
Constraining ADRs ADR-009
Key references reference/data-model.md §6.3

Rules that must never break

  1. Dimension separation (MED-003/006). A status event can never mutate a plan item. evidence_class=patient_report serializes verified:false and the UI badge binds to that flag, a self-report must never look like a pharmacy-confirmed dispense.
  2. No autonomous change (MED-010). Plan-item mutations require either a published fact from a source at hierarchy level ≤7, or clinician confirmation with step-up. There is no third path; agents and prompts have no code route to these writers.
  3. Barriers are first-class (MED-005). cannot_do requires a barrier_code (cost, stock, transport, confusion, side_effect, other) and opens the matching automation flow, never free text, never silence.
  4. Evidence states (8): ordered → sent → available → obtained → started → taking | stopped | barrier, each timestamped with evidence class; full history visible to the clinician brief.