mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 14:40:52 +00:00
Directions such as "30 to 60 minutes before food" had nowhere to go: a medication carried no free text of its own, only the notes on a dose change or a course. The medication now has one note, edited on the last step of the wizard and shown under the name on the detail page, above the dose actions on both card variants, under the picked medication in the log-dose sheet, and per row in the take-all-due list. One MedicationNote component renders it everywhere, in foreground text. The note is sealed at rest in Medication.noteEncrypted (migration 0498_medication_note, lock-bounded), with no plaintext column. Create and update take an optional `note`: trimmed, at most 500 characters, an empty string or null clears it, absent keeps it. The wizard sends it on an edit only when it changed, so an unrelated save never clears it. The list and detail reads strip the ciphertext and answer `note`. Both ends of the data path carry it: the backup (decrypted in a portable file, ciphertext in a disaster-recovery file), the restore, the data export, the key-rotation registry and script, and the MCP medication schedule, resources and fetch, fenced as user text. The doctor report and the FHIR export leave it out: it is the person's own reminder, and the report has no selection for personal prose. The size baselines rise by the one-line wiring of the field in the medication page, detail tabs, cards, log-dose sheet, wizard step and list read; the wizard payload grows by the field's own encode and hydrate.
20 lines
793 B
SQL
20 lines
793 B
SQL
-- A free-text note on a medication (#1371), for directions such as "30 to 60
|
|
-- minutes before food". Shown on the medication and when a dose is logged.
|
|
--
|
|
-- Sealed at rest like every other free-text column (AES-256-GCM, the shared
|
|
-- Bytes codec); there is no plaintext twin and nothing to backfill. Nullable,
|
|
-- no default: every existing medication reads as "no note", and adding the
|
|
-- column rewrites nothing. IF NOT EXISTS keeps a replay on a database that
|
|
-- already ran a build carrying the column harmless. Reversibility: dropping
|
|
-- the column restores the previous schema.
|
|
--
|
|
-- @retry-on-lock-timeout
|
|
|
|
DO $migration$
|
|
BEGIN
|
|
PERFORM set_config('lock_timeout', '5s', true);
|
|
ALTER TABLE "medications"
|
|
ADD COLUMN IF NOT EXISTS "note_encrypted" BYTEA;
|
|
END
|
|
$migration$;
|