58 lines
1.6 KiB
Markdown
58 lines
1.6 KiB
Markdown
# SPEC — Resident profile status flags + audit
|
|
|
|
**Produto:** Rently / RentCharge
|
|
**Data:** 2026-09-19
|
|
**Status:** implemented (prod + test)
|
|
**Versão:** 007.2026
|
|
**Operador:** Roger
|
|
|
|
**UI:** `/residents/{id}` Setup · Settings → Edit resident
|
|
|
|
---
|
|
|
|
## Flags (boolean on `residents`)
|
|
|
|
| UI label | Column |
|
|
|----------|--------|
|
|
| Temporary | `is_temporary` |
|
|
| Deceased | `is_deceased` |
|
|
| In custody | `is_in_custody` |
|
|
| In treatment | `is_in_treatment` |
|
|
|
|
(`is_active` remains a separate system flag; not part of this audit log.)
|
|
|
|
## Audit log
|
|
|
|
Table `resident_status_events` (append-only):
|
|
|
|
| Column | Meaning |
|
|
|--------|---------|
|
|
| `resident_id` | FK |
|
|
| `flag` | e.g. `is_temporary` |
|
|
| `value` | `true` = checked / On · `false` = unchecked / Off |
|
|
| `changed_at` | UTC store |
|
|
| `changed_by_user_id` / `changed_by_username` | actor |
|
|
|
|
**History is never deleted** when a box is unchecked — a new Off event is appended.
|
|
|
|
## Display
|
|
|
|
Beside each of the four checkboxes:
|
|
|
|
- Latest event: `On|Off dd/mm/yyyy HH:mm · username` (formatted **Europe/Dublin**)
|
|
- Full recent history in the **tooltip** (`title`)
|
|
|
|
Helper: `frontend/src/lib/statusFlags.ts`.
|
|
|
|
## API
|
|
|
|
- `ResidentOut.status_flags`: map flag → `{ last, history }` on get/create/update when `include_status_flags=True`.
|
|
- `GET /api/residents/{id}/status-history` — same map.
|
|
- Create/update log diffs for the four flags with the authenticated user.
|
|
|
|
## Acceptance
|
|
|
|
1. Check Temporary → stamp + user appear beside the box after save.
|
|
2. Uncheck → Off event logged; history still available on hover.
|
|
3. Settings edit shows the same stamps (loads full resident via `getResident`).
|
|
4. Prod + test.
|