Backend + frontend. Resolves the integration gap where the medication list/create
responses were deeply nested (fields inside medicationData.data JSON blob,
camelCase) while the frontend expected flat snake_case fields — so the
MedicationManager couldn't display real data.
Backend (models/medication.rs):
* New MedicationData struct: deserializes the camelCase JSON string stored in
medicationData.data (sideEffects->side_effects, prescribedBy->prescribed_by,
etc.). Tolerates missing keys via #[default].
* New MedicationResponse: flat snake_case, the wire format. From<Medication>
deserializes the data blob, maps fields, synthesizes active=true (TODO: real
active flag), formats timestamps as ISO 8601. Tolerates malformed blobs.
* Fixed MedicationRepository::update: the old dot-notation (medicationData.name)
wrote into phantom paths because the stored shape is medicationData:{data:
'<string>'}. Now loads the doc, deserializes the blob, applies overrides,
re-serializes, and $sets the whole data string. Updates actually persist now.
* 4 new unit tests (MedicationData deser, defaults, MedicationResponse flatten,
malformed-blob tolerance).
Handlers (handlers/medications.rs): create/list/get/update now return
MedicationResponse instead of the raw Medication model.
Frontend (types/api.ts): Medication interface reconciled to match
MedicationResponse (added id, profile_id, route, reason, side_effects,
prescribed_by/date, notes, tags; relaxed user_id to optional).
Verified: backend cargo fmt/build/clippy 0 warnings, 23 unit tests pass (was 19);
frontend npm build clean, 20 vitest tests pass.