mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 06:52:04 +00:00
feat(visits): record procedures and surgeries with a body site
A visit can be filed as a procedure or surgery (new EncounterKind PROCEDURE) and carry a body site in the person's own words, encrypted at rest, plus an optional side (LEFT, RIGHT, BOTH). An existing visit switches to the new kind by an ordinary edit, keeping its date, reason, outcome and links. - migration 0349: enum value, laterality type, two nullable columns - GET /api/encounters/procedures: the DONE procedures, newest first, searched after the decrypt over site, side and reason, with body-site choices and a total computed over the whole history - create and edit accept bodySite and laterality on any kind - /checkups gains a Procedures tab with a body-site filter; the visit form offers the site for a procedure and keeps it in view on any visit that carries one - backup and restore carry both fields; the body site is registered as ciphertext and rotates with the key - MCP get_visits narrows by kind and reads the whole record for procedures when no window is named; the Coach visit block names a procedure's site - i18n in all seven locales, OpenAPI regenerated Refs #1025
This commit is contained in:
1 parent
ee23409b77
commit
ad0d50fa28
43 files changed
+2486
-61
No files matched your search
@@ -12,7 +12,12 @@
|
||||
* Writes reach two roots (`encounterDependentKeys`), because renaming a
|
||||
* practice changes the label every visit that names it renders.
|
||||
*/
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
keepPreviousData,
|
||||
useMutation,
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
} from "@tanstack/react-query";
|
||||
|
||||
import { apiDelete, apiGet, apiPatch, apiPost } from "@/lib/api/api-fetch";
|
||||
import { invalidateReminderReads } from "@/hooks/use-measurement-reminders";
|
||||
@@ -21,7 +26,11 @@ import {
|
||||
invalidateKeys,
|
||||
queryKeys,
|
||||
} from "@/lib/query-keys";
|
||||
import type { EncounterDTO, EncounterListDTO } from "@/lib/encounters/dto";
|
||||
import type {
|
||||
EncounterDTO,
|
||||
EncounterListDTO,
|
||||
ProcedureListDTO,
|
||||
} from "@/lib/encounters/dto";
|
||||
import type { EncounterSuggestionResult } from "@/lib/encounters/suggest-window";
|
||||
|
||||
export type Encounter = EncounterDTO;
|
||||
@@ -34,6 +43,8 @@ export interface EncounterWriteBody {
|
||||
practitionerId?: string | null;
|
||||
reason?: string | null;
|
||||
outcome?: string | null;
|
||||
bodySite?: string | null;
|
||||
laterality?: "LEFT" | "RIGHT" | "BOTH" | null;
|
||||
/** The checkup this visit closes, when it was filed from a due one. */
|
||||
reminderId?: string | null;
|
||||
documentIds?: string[];
|
||||
@@ -75,6 +86,35 @@ export function useEncounters(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The procedure and surgery history, searched server-side.
|
||||
*
|
||||
* The body site is ciphertext at rest, so the search runs on the server after
|
||||
* the decrypt, and the query is part of the key. The previous answer stays on
|
||||
* screen while the next one loads, so typing does not flash the list empty;
|
||||
* the body-site choices and the total arrive with every answer, computed over
|
||||
* the whole history.
|
||||
*/
|
||||
export function useProcedures(
|
||||
enabled: boolean,
|
||||
filter: { q: string; laterality: "LEFT" | "RIGHT" | "BOTH" | null },
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.encounterProcedures(filter.q, filter.laterality),
|
||||
queryFn: () => {
|
||||
const sp = new URLSearchParams();
|
||||
if (filter.q.trim()) sp.set("q", filter.q.trim());
|
||||
if (filter.laterality) sp.set("laterality", filter.laterality);
|
||||
const qs = sp.toString();
|
||||
return apiGet<ProcedureListDTO>(
|
||||
qs ? `${BASE}/procedures?${qs}` : `${BASE}/procedures`,
|
||||
);
|
||||
},
|
||||
placeholderData: keepPreviousData,
|
||||
enabled,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* "Does this belong to a visit?" for one anchor date.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user