mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
feat(backup): carry a lab result's external identity through backup and restore
Both the disaster-recovery and the portable file now carry lab_results.external_id, and a restore writes it back, so a restored account still recognises a Health Records result when it arrives again and a deleted one stays deleted. Older files restore unchanged.
This commit is contained in:
1 parent
376102a71e
commit
72a05ea411
8 files changed
+44
-20
No files matched your search
@@ -44,6 +44,9 @@ export const labResultBackupSchema = z
|
||||
sourceUnit: z.string().nullable().optional(),
|
||||
takenAt: isoDateTime,
|
||||
source: z.string().min(1),
|
||||
// The identity a reading arrived under from Health Records (a digest).
|
||||
// Optional: absent on every file written before the column.
|
||||
externalId: z.string().min(1).max(128).nullable().optional(),
|
||||
biomarkerName: z.string().nullable().optional(),
|
||||
biomarkerId: z.string().nullable().optional(),
|
||||
note: z.string().nullable().optional(),
|
||||
|
||||
@@ -81,6 +81,9 @@ export interface LabResultBackupEntry {
|
||||
sourceUnit?: string | null;
|
||||
takenAt: string;
|
||||
source: string;
|
||||
/** The identity a Health Records reading arrived under (a digest), so a
|
||||
* restored account still recognises it when it arrives again. */
|
||||
externalId?: string | null;
|
||||
/** Human-readable cross-reference into `biomarkers` below, not an id. */
|
||||
/** Stable canonical FK; legacy portable payloads use biomarkerName. */
|
||||
biomarkerId?: string | null;
|
||||
@@ -221,6 +224,7 @@ export async function buildLabsBackupSlice(
|
||||
sourceUnit: r.sourceUnit,
|
||||
takenAt: r.takenAt.toISOString(),
|
||||
source: r.source,
|
||||
externalId: r.externalId,
|
||||
biomarkerName: r.biomarker?.name ?? null,
|
||||
}));
|
||||
|
||||
@@ -464,6 +468,7 @@ export async function restoreLabResults(ctx: RestoreContext): Promise<void> {
|
||||
sourceUnit: lab.sourceUnit ?? null,
|
||||
takenAt: new Date(lab.takenAt),
|
||||
source: lab.source,
|
||||
externalId: lab.externalId ?? null,
|
||||
noteEncrypted:
|
||||
lab.noteEncrypted !== undefined
|
||||
? lab.noteEncrypted === null
|
||||
|
||||
Reference in new issue
Block a user