# W2-FE-2 — pick-don't-type everywhere + in-place catalog management (FE)

Read _COMMON.md first. DESIGN (binding): /home/moonui3/public_html/knowledge-base/plans/visit-shell-completion/design/FABLE-inplace-settings.md §B (+ its i18n key list). Review rows: review-C-picker-lookups.md #9 #14 #15 #16 #17 #18(★ formulary) #22(exam key) bugs 2,4,5,6. BE contract: W1-BE-B report /home/moonui3/public_html/knowledge-base/plans/visit-shell-completion/reports/W1-BE-B.md (lookup PATCH/reorder/DELETE/restore, include_inactive/with_usage, perms clinic.lookups.add/manage, ICD favourites type icd10 + chapters).

Shared picker: /home/moonui3/public_html/moon-erp/src/app/shared/components/clinical-picker/ (box + dialog) and features/clinic/services/clinical-lookup.service.ts (find exact paths).

## Tasks
1. **In-place catalog management (Fable §B)** in the shared picker dialog: «✎ إدارة» mode (clinic.lookups.manage), manage strip (إظهار المخفي, ＋ فئة جديدة), per-row drag handle + ↑↓ ✎ 👁 🗑 (⋯ menu on phone), inline rename AR|EN, hide/show, reorder within category, move to category, delete-if-unused (409 → offer hide; tooltip with usage_count), new category, one undo toast (6 s). Add uses clinic.lookups.add (box default canAdd). Inactive values: never dropped from saved answers/chips — render `.chip.off` in old visits; hidden from pick lists unless «إظهار المخفي». The add sends `specialty` (current clinical type) and `parent_id` of the open category.
2. **Cache (bugs 4, 5):** add/★/rename/hide/reorder patch ALL cached `key|*` entries for that lookup_key; a 403 list is cached as forbidden (no refetch loop).
3. **GYN short lists (bug 6):** features/gyn/form/gyn-lookup-field.component.ts — the «＋» that opens the dialog always shows (★ for everyone with view); only add/manage inside are gated.
4. **Exam Select⟷Text rule keyed by region `code` (bug 2):** VS/cards/visit-exam-card.component.ts uses `exam_finding_<region code>` (fallback to the old id key when reading existing rules, for backward compatibility). With the new general seed (W1-BE-B) the exam card shows its regions — check the layout with real data.
5. **Diagnosis on the picker (C #15):** features/clinic/encounter/diagnosis-panel: chips of chosen diagnoses + «＋ اختيار / بحث» opening a picker dialog with search (ICD, 2+ chars), ★ doctor favourites (clinic_favorites type icd10) on top, chapter/group pills (BE chapters endpoint), inline «إضافة كود» (existing magic-add, perm clinic.diagnosis.record), first chosen = primary, primary/secondary toggle on the chip. Respect a field rule `diagnosis.input='text'` (free-text diagnosis row) when the visit is NOT insured (insured → ICD forced); the field rules come later from W3-FE-4 — expose an input `inputMode: 'select'|'text'`, default select.
6. **Lab / rad (C #16 #17):** in the shell, show chosen items as chips + «＋ اختيار» opening the investigation picker dialog in GRID mode (category grid → open one category, prototype screenshot 02/03) with ★ and search; keep the classic screens' current inline layout unchanged (new input on lab-orders/rad-orders e.g. `compact=true` used only by the shell host in visit-shell.component.html — ONE small binding edit there, say so). Add-to-catalog keeps the standalone-mode rule.
7. **Rx ★ in formulary mode (C #18):** prescription drug search shows ★ favourites (clinic_favorites type drug) in `standalone_formulary` mode too, not only `products`.
8. **History card on the catalog (C #14):** the general «التاريخ المرضي» card: answers to lookup-backed questions render as chips + «＋ اختيار» using the shared picker (questions with lookup_key); plain yes/no questions keep today's toggles. Don't rewrite the history panel — add the picker path for lookup questions only.

Run ng build at the end. Do not deploy, do not commit.

## Out of scope
visit-shell.component.* (except the one binding edit), settings popover (W3-FE-4), vitals, nutrition.
