# W3-BE-D — multi-select link-row mirror; nutrition + dental intake fixes (BE)

Read _COMMON.md first. Review rows: C #3 / top-5 #5 (LEDGER Decision 4); D N16, D12.

## Tasks
1. **Link-row mirror (Decision 4).** JSON in history answers stays the source of truth. Add table `history_answer_values` (id, company_id, patient_id, encounter_id nullable, record_id/episode_id nullable (match the answer's scope columns), question_id, question_code, lookup_key nullable, value_code, lookup_id nullable, created_at) with indexes (company_id, question_code, value_code), (patient_id). Maintain it in `Modules/Clinic/app/Services/HistoryService.php` wherever a multi_select (and single select with lookup_key) answer is created/updated/deleted (~411-418, ~657-664 and the delete paths; derived answers too) — one small private sync method, inside the same transaction. Private (sensitive) fields: mirror them too but the table must be covered by the same privacy read guard as answers (no reader exposes it yet — just make sure nothing new leaks; add a comment). Encryption: if a question is encrypted under SEC3 (MOON_PII_ENCRYPTION), don't mirror its values (skip + comment). Artisan command `clinic:history:mirror-values {--company=}` to backfill (chunked, idempotent), run it on dev. Tests (sync on create/update/delete, backfill idempotent).
2. **Nutrition intake codes (N16).** `Modules/Clinic/app/Clinical/IntakeRegistry.php:~59-67`: the prototype's nutrition intake includes goal, goal weight and activity level. They live in the nutrition patient profile. Make the nutrition intake step show them by reading/writing the nutrition profile fields (find the Nutrition profile model/service) instead of duplicating them as history codes — if the intake wizard can only render history codes, add a typed "profile" field kind for these three, saved to the profile. Test.
3. **Dental intake dedupe (D12).** IntakeRegistry dental pack (~69-75) also asks `dent_anticoagulant` and `dent_allergy_penicillin`, which duplicate the shared step's anticoagulant/allergy questions. Remove them from the dental pack (they're answered in the shared step and feed the same alert/condition store — verify that first). Test.

## Out of scope
FE; VisitLayoutController; lookup files.
