/**
 * React Query key factory for the patient-records domain (hierarchical, per the `services/{domain}` pattern).
 *
 * Every key is **patient-scoped** (the record is keyed to the patient, not a booking). The family record,
 * the access check, and each history page key independently so revisiting a tab never refetches. A customer
 * edit invalidates `patient(patientId)`; a nurse note append invalidates the patient's `history` **only** —
 * the append is append-only and does not mutate the family record, so `patient` stays validly cached.
 */
export const recordKeys = {
  all: ['patient_records'] as const,

  patients: () => [...recordKeys.all, 'patient'] as const,
  /** The family-owned medications/routine/tasks record. */
  patient: (patientId: number) => [...recordKeys.patients(), patientId] as const,

  access: (patientId: number) => [...recordKeys.all, 'access', patientId] as const,

  histories: () => [...recordKeys.all, 'history'] as const,
  history: (patientId: number, page: number) => [...recordKeys.histories(), patientId, page] as const,
};
