diff --git a/src/lib/export/family-history-backup-schema.ts b/src/lib/export/family-history-backup-schema.ts index 2ee8f32ff..eca2a52fd 100644 --- a/src/lib/export/family-history-backup-schema.ts +++ b/src/lib/export/family-history-backup-schema.ts @@ -8,7 +8,7 @@ */ import { z } from "zod/v4"; import { FamilyRelationship } from "@/generated/prisma/enums"; -import { isoDateTime } from "@/lib/export/backup-schema-kit"; +import { base64BytesSchema, isoDateTime } from "@/lib/export/backup-schema-kit"; export const familyHistoryBackupSchema = z .object({ @@ -17,7 +17,9 @@ export const familyHistoryBackupSchema = z condition: z.string().min(1), ageAtOnset: z.number().int().nullable().optional(), note: z.string().nullable().optional(), + notesEncrypted: base64BytesSchema.nullable().optional(), createdAt: isoDateTime.optional(), updatedAt: isoDateTime.optional(), + deletedAt: isoDateTime.nullable().optional(), }) .passthrough(); diff --git a/src/lib/export/family-history-backup.ts b/src/lib/export/family-history-backup.ts index d24407eb6..6a597711d 100644 --- a/src/lib/export/family-history-backup.ts +++ b/src/lib/export/family-history-backup.ts @@ -1,26 +1,61 @@ /** * The family history, with both backup ends in one file. */ +import { Buffer } from "node:buffer"; + import type { PrismaClient } from "@/generated/prisma/client"; import { encryptToBytes } from "@/lib/ai/coach/bytes-codec"; import { toFamilyHistoryEntryDTO, type FamilyHistoryEntryDTO, } from "@/lib/records/dto"; -import type { RestoreContext } from "@/lib/export/restore-context"; +import { + decodeEncryptedBytes, + type RestoreContext, +} from "@/lib/export/restore-context"; // ── Export ─────────────────────────────────────────────────────────────────── -/** The family-history slice of the records section. */ +/** + * A family-history entry as the disaster-recovery file carries it: the note + * as the ciphertext at rest, and the deletion. The portable file carries the + * readable DTO of the live entries only. + */ +export type CanonicalFamilyHistoryEntry = FamilyHistoryEntryDTO & { + notesEncrypted?: string | null; + deletedAt?: string | null; +}; + +/** + * The family-history slice of the records section. A disaster-recovery file + * carries deleted entries too, as every other record with a tombstone does: + * a restore from it has to give back the account as it was, deletions + * included, and the file used to drop them. + */ export async function buildFamilyHistoryBackupSlice( prisma: Pick, userId: string, -): Promise<{ familyHistory: FamilyHistoryEntryDTO[] }> { + disasterRecovery: boolean, +): Promise<{ familyHistory: CanonicalFamilyHistoryEntry[] }> { const familyRows = await prisma.familyHistoryEntry.findMany({ - where: { userId, deletedAt: null }, + where: disasterRecovery ? { userId } : { userId, deletedAt: null }, orderBy: { createdAt: "desc" }, }); - const familyHistory = familyRows.map(toFamilyHistoryEntryDTO); + const familyHistory: CanonicalFamilyHistoryEntry[] = disasterRecovery + ? familyRows.map((row) => ({ + id: row.id, + relationship: row.relationship, + condition: row.condition, + ageAtOnset: row.ageAtOnset, + note: null, + notesEncrypted: row.notesEncrypted + ? Buffer.from(row.notesEncrypted).toString("base64") + : null, + createdAt: row.createdAt.toISOString(), + updatedAt: row.updatedAt.toISOString(), + deletedAt: row.deletedAt?.toISOString() ?? null, + })) + : familyRows.map(toFamilyHistoryEntryDTO); return { familyHistory }; } @@ -44,8 +79,19 @@ export async function restoreFamilyHistory(ctx: RestoreContext): Promise { relationship: familyEntry.relationship as never, condition: familyEntry.condition, ageAtOnset: familyEntry.ageAtOnset ?? null, + // The ciphertext verbatim when the file carries it, the readable note + // sealed here otherwise. notesEncrypted: - familyEntry.note == null ? null : encryptToBytes(familyEntry.note), + familyEntry.notesEncrypted !== undefined + ? familyEntry.notesEncrypted === null + ? null + : decodeEncryptedBytes(familyEntry.notesEncrypted) + : familyEntry.note == null + ? null + : encryptToBytes(familyEntry.note), + deletedAt: familyEntry.deletedAt + ? new Date(familyEntry.deletedAt) + : null, ...(familyEntry.createdAt ? { createdAt: new Date(familyEntry.createdAt) } : {}), diff --git a/src/lib/export/records-backup.ts b/src/lib/export/records-backup.ts index 756b89f37..485aa97fe 100644 --- a/src/lib/export/records-backup.ts +++ b/src/lib/export/records-backup.ts @@ -122,7 +122,7 @@ export async function buildRecordsBackupSection( buildLabsBackupSlice(prisma, userId, disasterRecovery), buildIllnessBackupSlice(prisma, userId, disasterRecovery), buildAllergiesBackupSlice(prisma, userId, disasterRecovery), - buildFamilyHistoryBackupSlice(prisma, userId), + buildFamilyHistoryBackupSlice(prisma, userId, disasterRecovery), buildWorkoutsBackupSlice(prisma, userId, disasterRecovery), buildDocumentsBackupSlice( prisma, diff --git a/tests/integration/__golden__/backup-parity/export-disaster-recovery.json b/tests/integration/__golden__/backup-parity/export-disaster-recovery.json index c664c3195..81e8ccae0 100644 --- a/tests/integration/__golden__/backup-parity/export-disaster-recovery.json +++ b/tests/integration/__golden__/backup-parity/export-disaster-recovery.json @@ -1101,17 +1101,30 @@ "familyHistory": [ { "id": "", + "relationship": "FATHER", + "condition": "Hypertension (deleted)", + "ageAtOnset": null, + "note": null, + "notesEncrypted": "", + "createdAt": "2026-05-02T15:46:01.000Z", + "updatedAt": "2026-05-02T15:47:01.000Z", + "deletedAt": "" + }, + { + "id": "", "relationship": "MOTHER", "condition": "Type 2 diabetes", "ageAtOnset": 3, - "note": "rt-FamilyHistoryEntry-notesEncrypted", + "note": null, + "notesEncrypted": "", "createdAt": "2026-05-02T15:46:00.000Z", - "updatedAt": "2026-05-02T15:47:00.000Z" + "updatedAt": "2026-05-02T15:47:00.000Z", + "deletedAt": null } ], "workouts": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T21:58:00.000Z", "updatedAt": "2026-05-03T21:59:00.000Z", "metadata": { @@ -1136,7 +1149,7 @@ ], "documents": [ { - "id": "", + "id": "", "kind": "LAB_RESULT", "title": "June labs", "filename": "june-labs.pdf", @@ -1182,7 +1195,7 @@ } }, "healthProfile": { - "id": "", + "id": "", "aboutMe": null, "conditions": null, "allergies": null, @@ -1212,18 +1225,18 @@ }, "healthProfileFacts": [ { - "id": "", + "id": "", "kind": "SMOKING_STATUS", "value": null, "valueEncrypted": "", "validFrom": "2026-01-01T00:00:00.000Z", "validUntil": "2026-06-30T12:34:56.789Z", "provenance": "USER_CORRECTION", - "supersededByRevisionId": "", + "supersededByRevisionId": "", "createdAt": "2026-05-03T05:08:00.000Z" }, { - "id": "", + "id": "", "kind": "SMOKING_STATUS", "value": null, "valueEncrypted": "", @@ -1236,7 +1249,7 @@ ], "customMetrics": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T15:09:00.000Z", "updatedAt": "2026-05-03T15:10:00.000Z", "deletedAt": null, @@ -1249,7 +1262,7 @@ "correlationEnabled": true, "entries": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T16:48:02.000Z", "deletedAt": "", "noteEncrypted": null, @@ -1259,7 +1272,7 @@ "note": null }, { - "id": "", + "id": "", "createdAt": "2026-05-03T16:48:00.000Z", "deletedAt": null, "noteEncrypted": null, @@ -1269,7 +1282,7 @@ "note": "left hand, after the long ride" }, { - "id": "", + "id": "", "createdAt": "2026-05-03T16:48:01.000Z", "deletedAt": null, "noteEncrypted": "", @@ -1281,7 +1294,7 @@ ] }, { - "id": "", + "id": "", "createdAt": "2026-05-03T15:09:01.000Z", "updatedAt": "2026-05-03T15:10:01.000Z", "deletedAt": "", @@ -1297,7 +1310,7 @@ ], "correlationPatterns": [ { - "id": "", + "id": "", "updatedAt": "2026-05-03T18:39:00.000Z", "createdAt": "2026-05-03T18:38:00.000Z", "canonicalKey": "p1:a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", @@ -1321,7 +1334,7 @@ "decryptFailures": [], "intradayProfiles": [ { - "id": "", + "id": "", "createdAt": "2026-05-01T09:51:00.000Z", "updatedAt": "2026-05-01T09:52:00.000Z", "type": "ACTIVITY_STEPS", @@ -1387,7 +1400,7 @@ ], "healthScoreRecords": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T20:13:00.000Z", "dayKey": "2026-07-01", "timezone": "Europe/Berlin", @@ -1409,7 +1422,7 @@ } ], "onboardingRecord": { - "id": "", + "id": "", "createdAt": "2026-05-06T09:47:00.000Z", "updatedAt": "2026-05-06T09:48:00.000Z", "needs": { @@ -1476,7 +1489,7 @@ }, "practitioners": [ { - "id": "", + "id": "", "name": "Closed practice (deleted)", "specialty": null, "practice": null, @@ -1490,7 +1503,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "name": "Round-trip practice", "specialty": "Internal medicine", "practice": "rt-Practitioner-practice", @@ -1506,26 +1519,26 @@ ], "encounters": [ { - "id": "", + "id": "", "occurredAt": "2026-06-30T08:00:00.000Z", "status": "PLANNED", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": "", "outcomeEncrypted": "", "bodySiteEncrypted": "", "laterality": "LEFT", - "reminderId": "", + "reminderId": "", "createdAt": "2026-05-04T04:31:00.000Z", "updatedAt": "2026-05-04T04:32:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "occurredAt": "2026-04-02T08:00:00.000Z", "status": "DONE", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": null, "outcomeEncrypted": null, "bodySiteEncrypted": null, @@ -1538,28 +1551,28 @@ ], "encounterDocumentLinks": [ { - "encounterId": "", - "targetId": "", + "encounterId": "", + "targetId": "", "createdAt": "2026-05-04T06:04:00.000Z" } ], "encounterLabLinks": [ { - "encounterId": "", + "encounterId": "", "targetId": "", "createdAt": "2026-05-04T07:44:00.000Z" } ], "encounterConditionLinks": [ { - "encounterId": "", + "encounterId": "", "targetId": "", "createdAt": "2026-05-04T09:24:00.000Z" } ], "customVaccines": [ { - "id": "", + "id": "", "name": "Deleted combo", "components": [ "rabies" @@ -1571,7 +1584,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "name": "Round-trip travel combo", "components": [ "typhoid", @@ -1586,7 +1599,7 @@ ], "vaccinations": [ { - "id": "", + "id": "", "occurredAt": "2026-05-14T00:00:00.000Z", "antigenSlug": "tdap", "vaccineName": "Tetanus, diphtheria and pertussis", @@ -1594,17 +1607,17 @@ "seriesDoses": 3, "lotNumber": "RT-4471", "site": "LEFT_ARM", - "practitionerId": "", - "encounterId": "", - "reminderId": "", - "customVaccineId": "", + "practitionerId": "", + "encounterId": "", + "reminderId": "", + "customVaccineId": "", "noteEncrypted": "", "createdAt": "2026-05-04T11:14:00.000Z", "updatedAt": "2026-05-04T11:15:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "occurredAt": "2026-04-14T00:00:00.000Z", "antigenSlug": "influenza", "vaccineName": "Influenza (deleted)", @@ -1624,14 +1637,14 @@ ], "vaccinationDocumentLinks": [ { - "vaccinationId": "", - "targetId": "", + "vaccinationId": "", + "targetId": "", "createdAt": "2026-05-04T12:44:00.000Z" } ], "measurementReminders": [ { - "id": "", + "id": "", "label": "Blutdruck messen", "measurementType": "BLOOD_PRESSURE_SYS", "intervalDays": 7, @@ -1653,7 +1666,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "label": "Gewicht (deleted)", "measurementType": "WEIGHT", "intervalDays": 14, @@ -1677,8 +1690,8 @@ ], "measurementReminderEvents": [ { - "id": "", - "reminderId": "", + "id": "", + "reminderId": "", "kind": "SKIPPED", "occurredAt": "2026-06-24T06:00:00.000Z", "onTime": false, @@ -1686,8 +1699,8 @@ "createdAt": "2026-05-04T17:47:01.000Z" }, { - "id": "", - "reminderId": "", + "id": "", + "reminderId": "", "kind": "SATISFIED", "occurredAt": "2026-07-01T06:05:00.000Z", "onTime": true, @@ -1697,7 +1710,7 @@ ], "coachConversations": [ { - "id": "", + "id": "", "title": "How is my blood pressure trending?", "documentScoped": false, "summaryEncrypted": "", @@ -1707,7 +1720,7 @@ "updatedAt": "2026-05-04T19:25:00.000Z", "messages": [ { - "id": "", + "id": "", "role": "user", "contentEncrypted": "", "metricSourceJson": "rt-CoachMessage-metricSourceJson", @@ -1720,7 +1733,7 @@ "createdAt": "2026-07-20T09:58:00.000Z" }, { - "id": "", + "id": "", "role": "assistant", "contentEncrypted": "", "metricSourceJson": null, @@ -1736,7 +1749,7 @@ "attachments": [] }, { - "id": "", + "id": "", "titleEncrypted": "", "documentScoped": true, "summaryEncrypted": null, @@ -1746,7 +1759,7 @@ "updatedAt": "2026-05-04T19:25:01.000Z", "messages": [ { - "id": "", + "id": "", "role": "user", "contentEncrypted": "", "metricSourceJson": null, @@ -1761,7 +1774,7 @@ ], "attachments": [ { - "documentId": "", + "documentId": "", "addedAt": "2026-07-21T07:59:00.000Z" } ] @@ -1769,25 +1782,25 @@ ], "coachFacts": [ { - "id": "", + "id": "", "factEncrypted": "", "deletedAt": null, "category": "constraint", "confidence": 80, - "sourceConversationId": "", + "sourceConversationId": "", "source": "user", "lastUsedAt": "2026-07-20T10:00:00.000Z", - "sourceMessageId": "", + "sourceMessageId": "", "createdAt": "2026-05-05T00:26:00.000Z", "updatedAt": "2026-05-05T00:27:00.000Z" }, { - "id": "", + "id": "", "factEncrypted": "", "deletedAt": "", "category": "preference", "confidence": 50, - "sourceConversationId": "", + "sourceConversationId": "", "source": "user", "lastUsedAt": null, "sourceMessageId": null, @@ -1797,7 +1810,7 @@ ], "coachPlans": [ { - "id": "", + "id": "", "metric": "BLOOD_PRESSURE", "ifCueEncrypted": "", "thenActionEncrypted": "", @@ -1806,12 +1819,12 @@ "deletedAt": null, "status": "active", "reviewDate": "2026-10-01T00:00:00.000Z", - "sourceConversationId": "", + "sourceConversationId": "", "createdAt": "2026-05-05T02:10:00.000Z", "updatedAt": "2026-05-05T02:11:00.000Z" }, { - "id": "", + "id": "", "metric": "WEIGHT", "ifCueEncrypted": "", "thenActionEncrypted": "", @@ -1827,28 +1840,28 @@ ], "coachReminders": [ { - "id": "", + "id": "", "noteEncrypted": "", "deletedAt": null, "metric": "BLOOD_PRESSURE", - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "rt-CoachReminder-triggerKind", "dueAt": "2026-09-01T07:00:00.000Z", "contextCue": "rt-CoachReminder-contextCue", "status": "rt-CoachReminder-status", "source": "extractor", - "sourceConversationId": "", + "sourceConversationId": "", "lastSurfacedAt": "2026-06-30T12:34:56.789Z", "surfaceCount": 2, "createdAt": "2026-05-05T03:53:00.000Z", "updatedAt": "2026-05-05T03:54:00.000Z" }, { - "id": "", + "id": "", "noteEncrypted": "", "deletedAt": "", "metric": null, - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "date", "dueAt": "2026-09-15T07:00:00.000Z", "contextCue": null, @@ -1863,7 +1876,7 @@ ], "mentalHealthAssessments": [ { - "id": "", + "id": "", "instrument": "GAD7", "locale": "en", "version": "standard", @@ -1882,7 +1895,7 @@ "updatedAt": "2026-05-05T13:57:01.000Z" }, { - "id": "", + "id": "", "instrument": "PHQ9", "locale": "de", "version": "rt-MentalHealthAssessment-version", @@ -1903,7 +1916,7 @@ ], "consentReceipts": [ { - "id": "", + "id": "", "kind": "ai-processing", "artefact": "JVBERi0xLjQKJWZpeHR1cmU=", "signedAt": "2026-06-01T09:00:00.000Z", @@ -1911,7 +1924,7 @@ "createdAt": "2026-05-05T15:26:00.000Z" }, { - "id": "", + "id": "", "kind": "research-sharing", "artefact": "eyJhbGciOiJub25lIn0.e30.", "signedAt": "2026-06-02T09:00:00.000Z", @@ -1921,15 +1934,15 @@ ], "documentConditionLinks": [ { - "documentId": "", + "documentId": "", "episodeId": "", "createdAt": "2026-07-02T09:00:00.000Z" } ], "extractedFacts": [ { - "id": "", - "documentId": "", + "id": "", + "documentId": "", "factType": "OBSERVATION", "status": "APPROVED", "confidence": 0.94, @@ -2114,7 +2127,7 @@ ], "ecgRecordings": [ { - "id": "", + "id": "", "waveformEncrypted": "", "source": "MANUAL", "externalRecordingId": "round-trip-signal-1", @@ -2132,7 +2145,7 @@ ], "symptomDefinitions": [ { - "id": "", + "id": "", "labelEncrypted": "", "icon": "Zap", "sortOrder": 0, @@ -2141,7 +2154,7 @@ "updatedAt": "2026-05-02T22:27:00.000Z", "events": [ { - "id": "", + "id": "", "noteEncrypted": null, "occurredAt": "2026-06-21T09:00:00.000Z", "intensity": 4, @@ -2150,7 +2163,7 @@ "updatedAt": "2026-05-03T00:08:00.000Z" }, { - "id": "", + "id": "", "noteEncrypted": null, "occurredAt": "2026-07-10T18:30:00.000Z", "intensity": 2, @@ -2161,7 +2174,7 @@ ] }, { - "id": "", + "id": "", "labelEncrypted": "", "icon": "Brain", "sortOrder": 1, @@ -2170,7 +2183,7 @@ "updatedAt": "2026-05-02T22:27:01.000Z", "events": [ { - "id": "", + "id": "", "noteEncrypted": "", "occurredAt": "2026-06-21T11:00:00.000Z", "intensity": 8, @@ -2183,7 +2196,7 @@ ], "lifeEvents": [ { - "id": "", + "id": "", "titleEncrypted": "", "noteEncrypted": "", "category": "HOME", @@ -2195,7 +2208,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "titleEncrypted": "", "noteEncrypted": null, "category": "OTHER", @@ -2207,7 +2220,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "titleEncrypted": "", "noteEncrypted": null, "category": "WORK", @@ -2222,28 +2235,28 @@ "labResultDocumentLinks": [ { "labResultId": "", - "documentId": "", + "documentId": "", "createdAt": "2026-05-06T14:44:00.000Z" } ], "encounterMedicationLinks": [ { - "encounterId": "", + "encounterId": "", "medicationId": "", "createdAt": "2026-05-06T16:24:00.000Z" } ], "encounterVaccinationLinks": [ { - "encounterId": "", - "vaccinationId": "", + "encounterId": "", + "vaccinationId": "", "createdAt": "2026-05-06T18:04:00.000Z" } ], "medicationDocumentLinks": [ { "medicationId": "", - "documentId": "", + "documentId": "", "createdAt": "2026-05-06T19:44:00.000Z" } ], @@ -2289,7 +2302,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "healthProfile": 1, @@ -2352,7 +2365,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "healthProfile": 1, @@ -3459,7 +3472,7 @@ ], "symptomDefinitions": [ { - "id": "", + "id": "", "labelEncrypted": "", "icon": "Zap", "sortOrder": 0, @@ -3468,7 +3481,7 @@ "updatedAt": "2026-05-02T22:27:00.000Z", "events": [ { - "id": "", + "id": "", "occurredAt": "2026-06-21T09:00:00.000Z", "intensity": 4, "noteEncrypted": null, @@ -3477,7 +3490,7 @@ "updatedAt": "2026-05-03T00:08:00.000Z" }, { - "id": "", + "id": "", "occurredAt": "2026-07-10T18:30:00.000Z", "intensity": 2, "noteEncrypted": null, @@ -3488,7 +3501,7 @@ ] }, { - "id": "", + "id": "", "labelEncrypted": "", "icon": "Brain", "sortOrder": 1, @@ -3497,7 +3510,7 @@ "updatedAt": "2026-05-02T22:27:01.000Z", "events": [ { - "id": "", + "id": "", "occurredAt": "2026-06-21T11:00:00.000Z", "intensity": 8, "noteEncrypted": "", @@ -3510,7 +3523,7 @@ ], "lifeEvents": [ { - "id": "", + "id": "", "category": "HOME", "startDate": "2023-09-01", "endDate": null, @@ -3522,7 +3535,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "category": "OTHER", "startDate": "2025-12-01", "endDate": null, @@ -3534,7 +3547,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "category": "WORK", "startDate": "2026-03-02", "endDate": "2026-05-29", @@ -3583,17 +3596,30 @@ "familyHistory": [ { "id": "", + "relationship": "FATHER", + "condition": "Hypertension (deleted)", + "ageAtOnset": null, + "note": null, + "notesEncrypted": "", + "createdAt": "2026-05-02T15:46:01.000Z", + "updatedAt": "2026-05-02T15:47:01.000Z", + "deletedAt": "" + }, + { + "id": "", "relationship": "MOTHER", "condition": "Type 2 diabetes", "ageAtOnset": 3, - "note": "rt-FamilyHistoryEntry-notesEncrypted", + "note": null, + "notesEncrypted": "", "createdAt": "2026-05-02T15:46:00.000Z", - "updatedAt": "2026-05-02T15:47:00.000Z" + "updatedAt": "2026-05-02T15:47:00.000Z", + "deletedAt": null } ], "workouts": [ { - "id": "", + "id": "", "sportType": "RUNNING", "startedAt": "2026-06-29T06:00:00.000Z", "endedAt": "2026-06-29T06:30:00.000Z", @@ -3618,7 +3644,7 @@ ], "documents": [ { - "id": "", + "id": "", "kind": "LAB_RESULT", "title": "June labs", "filename": "june-labs.pdf", @@ -3647,15 +3673,15 @@ ], "documentConditionLinks": [ { - "documentId": "", + "documentId": "", "episodeId": "", "createdAt": "2026-07-02T09:00:00.000Z" } ], "extractedFacts": [ { - "id": "", - "documentId": "", + "id": "", + "documentId": "", "factType": "OBSERVATION", "status": "APPROVED", "confidence": 0.94, @@ -3680,7 +3706,7 @@ } ], "healthProfile": { - "id": "", + "id": "", "aboutMe": null, "conditions": null, "allergies": null, @@ -3710,18 +3736,18 @@ }, "healthProfileFacts": [ { - "id": "", + "id": "", "kind": "SMOKING_STATUS", "value": null, "valueEncrypted": "", "validFrom": "2026-01-01T00:00:00.000Z", "validUntil": "2026-06-30T12:34:56.789Z", "provenance": "USER_CORRECTION", - "supersededByRevisionId": "", + "supersededByRevisionId": "", "createdAt": "2026-05-03T05:08:00.000Z" }, { - "id": "", + "id": "", "kind": "SMOKING_STATUS", "value": null, "valueEncrypted": "", @@ -3734,7 +3760,7 @@ ], "customMetrics": [ { - "id": "", + "id": "", "name": "Grip strength", "unit": "kg", "targetLow": 2.5, @@ -3747,7 +3773,7 @@ "deletedAt": null, "entries": [ { - "id": "", + "id": "", "value": 40, "unit": "kg", "measuredAt": "2026-06-28T18:00:00.000Z", @@ -3757,7 +3783,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "value": 44, "unit": "kg", "measuredAt": "2026-07-01T18:00:00.000Z", @@ -3767,7 +3793,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "value": 45, "unit": "kg", "measuredAt": "2026-07-02T18:00:00.000Z", @@ -3779,7 +3805,7 @@ ] }, { - "id": "", + "id": "", "name": "Plank (deleted)", "unit": "s", "targetLow": null, @@ -3795,7 +3821,7 @@ ], "correlationPatterns": [ { - "id": "", + "id": "", "canonicalKey": "p1:a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "family": "sleep", "factorKey": "sleep_duration", @@ -3818,7 +3844,7 @@ ], "intradayProfiles": [ { - "id": "", + "id": "", "type": "ACTIVITY_STEPS", "dateKey": "2026-07-01", "hourlyCumulative": [ @@ -3884,7 +3910,7 @@ ], "healthScoreRecords": [ { - "id": "", + "id": "", "dayKey": "2026-07-01", "timezone": "Europe/Berlin", "composite": 71, @@ -3906,7 +3932,7 @@ } ], "onboardingRecord": { - "id": "", + "id": "", "needs": { "recordTarget": "me", "areas": [ @@ -3973,7 +3999,7 @@ }, "practitioners": [ { - "id": "", + "id": "", "name": "Closed practice (deleted)", "specialty": null, "practice": null, @@ -3987,7 +4013,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "name": "Round-trip practice", "specialty": "Internal medicine", "practice": "rt-Practitioner-practice", @@ -4003,26 +4029,26 @@ ], "encounters": [ { - "id": "", + "id": "", "occurredAt": "2026-06-30T08:00:00.000Z", "status": "PLANNED", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": "", "outcomeEncrypted": "", "bodySiteEncrypted": "", "laterality": "LEFT", - "reminderId": "", + "reminderId": "", "createdAt": "2026-05-04T04:31:00.000Z", "updatedAt": "2026-05-04T04:32:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "occurredAt": "2026-04-02T08:00:00.000Z", "status": "DONE", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": null, "outcomeEncrypted": null, "bodySiteEncrypted": null, @@ -4035,28 +4061,28 @@ ], "encounterDocumentLinks": [ { - "encounterId": "", - "targetId": "", + "encounterId": "", + "targetId": "", "createdAt": "2026-05-04T06:04:00.000Z" } ], "encounterLabLinks": [ { - "encounterId": "", + "encounterId": "", "targetId": "", "createdAt": "2026-05-04T07:44:00.000Z" } ], "encounterConditionLinks": [ { - "encounterId": "", + "encounterId": "", "targetId": "", "createdAt": "2026-05-04T09:24:00.000Z" } ], "customVaccines": [ { - "id": "", + "id": "", "name": "Deleted combo", "components": [ "rabies" @@ -4068,7 +4094,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "name": "Round-trip travel combo", "components": [ "typhoid", @@ -4083,7 +4109,7 @@ ], "vaccinations": [ { - "id": "", + "id": "", "occurredAt": "2026-05-14T00:00:00.000Z", "antigenSlug": "tdap", "vaccineName": "Tetanus, diphtheria and pertussis", @@ -4091,17 +4117,17 @@ "seriesDoses": 3, "lotNumber": "RT-4471", "site": "LEFT_ARM", - "practitionerId": "", - "encounterId": "", - "reminderId": "", - "customVaccineId": "", + "practitionerId": "", + "encounterId": "", + "reminderId": "", + "customVaccineId": "", "noteEncrypted": "", "createdAt": "2026-05-04T11:14:00.000Z", "updatedAt": "2026-05-04T11:15:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "occurredAt": "2026-04-14T00:00:00.000Z", "antigenSlug": "influenza", "vaccineName": "Influenza (deleted)", @@ -4121,36 +4147,36 @@ ], "vaccinationDocumentLinks": [ { - "vaccinationId": "", - "targetId": "", + "vaccinationId": "", + "targetId": "", "createdAt": "2026-05-04T12:44:00.000Z" } ], "labResultDocumentLinks": [ { "labResultId": "", - "documentId": "", + "documentId": "", "createdAt": "2026-05-06T14:44:00.000Z" } ], "encounterMedicationLinks": [ { - "encounterId": "", + "encounterId": "", "medicationId": "", "createdAt": "2026-05-06T16:24:00.000Z" } ], "encounterVaccinationLinks": [ { - "encounterId": "", - "vaccinationId": "", + "encounterId": "", + "vaccinationId": "", "createdAt": "2026-05-06T18:04:00.000Z" } ], "medicationDocumentLinks": [ { "medicationId": "", - "documentId": "", + "documentId": "", "createdAt": "2026-05-06T19:44:00.000Z" } ], @@ -4163,7 +4189,7 @@ ], "coachConversations": [ { - "id": "", + "id": "", "title": "How is my blood pressure trending?", "documentScoped": false, "summaryEncrypted": "", @@ -4173,7 +4199,7 @@ "updatedAt": "2026-05-04T19:25:00.000Z", "messages": [ { - "id": "", + "id": "", "role": "user", "contentEncrypted": "", "metricSourceJson": "rt-CoachMessage-metricSourceJson", @@ -4186,7 +4212,7 @@ "createdAt": "2026-07-20T09:58:00.000Z" }, { - "id": "", + "id": "", "role": "assistant", "contentEncrypted": "", "metricSourceJson": null, @@ -4202,7 +4228,7 @@ "attachments": [] }, { - "id": "", + "id": "", "titleEncrypted": "", "documentScoped": true, "summaryEncrypted": null, @@ -4212,7 +4238,7 @@ "updatedAt": "2026-05-04T19:25:01.000Z", "messages": [ { - "id": "", + "id": "", "role": "user", "contentEncrypted": "", "metricSourceJson": null, @@ -4227,7 +4253,7 @@ ], "attachments": [ { - "documentId": "", + "documentId": "", "addedAt": "2026-07-21T07:59:00.000Z" } ] @@ -4235,7 +4261,7 @@ ], "mentalHealthAssessments": [ { - "id": "", + "id": "", "instrument": "GAD7", "locale": "en", "version": "standard", @@ -4254,7 +4280,7 @@ "updatedAt": "2026-05-05T13:57:01.000Z" }, { - "id": "", + "id": "", "instrument": "PHQ9", "locale": "de", "version": "rt-MentalHealthAssessment-version", @@ -4275,7 +4301,7 @@ ], "consentReceipts": [ { - "id": "", + "id": "", "kind": "ai-processing", "artefact": "JVBERi0xLjQKJWZpeHR1cmU=", "signedAt": "2026-06-01T09:00:00.000Z", @@ -4283,7 +4309,7 @@ "createdAt": "2026-05-05T15:26:00.000Z" }, { - "id": "", + "id": "", "kind": "research-sharing", "artefact": "eyJhbGciOiJub25lIn0.e30.", "signedAt": "2026-06-02T09:00:00.000Z", @@ -4293,24 +4319,24 @@ ], "coachFacts": [ { - "id": "", + "id": "", "factEncrypted": "", "category": "constraint", "confidence": 80, - "sourceConversationId": "", + "sourceConversationId": "", "source": "user", "lastUsedAt": "2026-07-20T10:00:00.000Z", - "sourceMessageId": "", + "sourceMessageId": "", "createdAt": "2026-05-05T00:26:00.000Z", "updatedAt": "2026-05-05T00:27:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "factEncrypted": "", "category": "preference", "confidence": 50, - "sourceConversationId": "", + "sourceConversationId": "", "source": "user", "lastUsedAt": null, "sourceMessageId": null, @@ -4321,7 +4347,7 @@ ], "coachPlans": [ { - "id": "", + "id": "", "metric": "BLOOD_PRESSURE", "ifCueEncrypted": "", "thenActionEncrypted": "", @@ -4329,13 +4355,13 @@ "outcomeEncrypted": "", "status": "active", "reviewDate": "2026-10-01T00:00:00.000Z", - "sourceConversationId": "", + "sourceConversationId": "", "createdAt": "2026-05-05T02:10:00.000Z", "updatedAt": "2026-05-05T02:11:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "metric": "WEIGHT", "ifCueEncrypted": "", "thenActionEncrypted": "", @@ -4351,16 +4377,16 @@ ], "coachReminders": [ { - "id": "", + "id": "", "noteEncrypted": "", "metric": "BLOOD_PRESSURE", - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "rt-CoachReminder-triggerKind", "dueAt": "2026-09-01T07:00:00.000Z", "contextCue": "rt-CoachReminder-contextCue", "status": "rt-CoachReminder-status", "source": "extractor", - "sourceConversationId": "", + "sourceConversationId": "", "lastSurfacedAt": "2026-06-30T12:34:56.789Z", "surfaceCount": 2, "createdAt": "2026-05-05T03:53:00.000Z", @@ -4368,10 +4394,10 @@ "deletedAt": null }, { - "id": "", + "id": "", "noteEncrypted": "", "metric": null, - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "date", "dueAt": "2026-09-15T07:00:00.000Z", "contextCue": null, @@ -4387,7 +4413,7 @@ ], "measurementReminders": [ { - "id": "", + "id": "", "label": "Blutdruck messen", "measurementType": "BLOOD_PRESSURE_SYS", "intervalDays": 7, @@ -4409,7 +4435,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "label": "Gewicht (deleted)", "measurementType": "WEIGHT", "intervalDays": 14, @@ -4433,8 +4459,8 @@ ], "measurementReminderEvents": [ { - "id": "", - "reminderId": "", + "id": "", + "reminderId": "", "kind": "SKIPPED", "occurredAt": "2026-06-24T06:00:00.000Z", "onTime": false, @@ -4442,8 +4468,8 @@ "createdAt": "2026-05-04T17:47:01.000Z" }, { - "id": "", - "reminderId": "", + "id": "", + "reminderId": "", "kind": "SATISFIED", "occurredAt": "2026-07-01T06:05:00.000Z", "onTime": true, @@ -4623,7 +4649,7 @@ ], "ecgRecordings": [ { - "id": "", + "id": "", "source": "MANUAL", "externalRecordingId": "round-trip-signal-1", "recordedAt": "2026-06-15T14:22:00.000Z", @@ -4678,7 +4704,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "documentConditionLinks": 1, @@ -4734,7 +4760,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "documentConditionLinks": 1, diff --git a/tests/integration/__golden__/backup-parity/restore-disaster-recovery-over-live.json b/tests/integration/__golden__/backup-parity/restore-disaster-recovery-over-live.json index 6b196cc9e..77fa33c88 100644 --- a/tests/integration/__golden__/backup-parity/restore-disaster-recovery-over-live.json +++ b/tests/integration/__golden__/backup-parity/restore-disaster-recovery-over-live.json @@ -22,7 +22,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "documentConditionLinks": 1, @@ -78,7 +78,7 @@ "nutrientDays": 1, "illnessEpisodes": 4, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "documentConditionLinks": 0, @@ -294,7 +294,7 @@ "nutrientDays": 1, "illnessEpisodes": 4, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "documentConditionLinks": 0, @@ -350,7 +350,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "healthProfile": 1, diff --git a/tests/integration/__golden__/backup-parity/restore-disaster-recovery.json b/tests/integration/__golden__/backup-parity/restore-disaster-recovery.json index e66469817..852833970 100644 --- a/tests/integration/__golden__/backup-parity/restore-disaster-recovery.json +++ b/tests/integration/__golden__/backup-parity/restore-disaster-recovery.json @@ -22,7 +22,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "documentConditionLinks": 1, @@ -350,7 +350,7 @@ "illnessEpisodes": 4, "illnessDayLogs": 2, "allergies": 2, - "familyHistory": 1, + "familyHistory": 2, "workouts": 1, "documents": 1, "healthProfile": 1, @@ -1031,10 +1031,21 @@ { "id": "", "userId": "round-trip-owner", + "relationship": "FATHER", + "condition": "Hypertension (deleted)", + "ageAtOnset": null, + "notesEncrypted": "", + "createdAt": "2026-05-02T15:46:01.000Z", + "updatedAt": "2026-05-02T15:47:01.000Z", + "deletedAt": "" + }, + { + "id": "", + "userId": "round-trip-owner", "relationship": "MOTHER", "condition": "Type 2 diabetes", "ageAtOnset": 3, - "notesEncrypted": "", + "notesEncrypted": "", "createdAt": "2026-05-02T15:46:00.000Z", "updatedAt": "2026-05-02T15:47:00.000Z", "deletedAt": null @@ -1042,7 +1053,7 @@ ], "IllnessEpisode": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "label": "Cold", "type": "INFECTION", @@ -1058,14 +1069,14 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "label": "Iron deficiency flare", "type": "CHRONIC", "lifecycle": "FLARE", "onsetAt": "2026-06-25T00:00:00.000Z", "resolvedAt": null, - "parentConditionId": "", + "parentConditionId": "", "noteEncrypted": null, "bodySiteEncrypted": null, "laterality": null, @@ -1074,7 +1085,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "label": "Iron deficiency", "type": "CHRONIC", @@ -1090,7 +1101,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "label": "Sprained ankle (deleted)", "type": "INJURY", @@ -1108,9 +1119,9 @@ ], "IllnessDayLog": [ { - "id": "", + "id": "", "userId": "round-trip-owner", - "episodeId": "", + "episodeId": "", "date": "2026-06-21", "functionalImpact": 3, "feverC": 2.5, @@ -1121,9 +1132,9 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", - "episodeId": "", + "episodeId": "", "date": "2026-06-22", "functionalImpact": null, "feverC": null, @@ -1136,15 +1147,15 @@ ], "IllnessSymptomLink": [ { - "dayLogId": "", - "symptomId": "", + "dayLogId": "", + "symptomId": "", "severity": 2, "createdAt": "" } ], "SymptomDefinition": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "labelEncrypted": "", "icon": "Zap", @@ -1154,7 +1165,7 @@ "updatedAt": "2026-05-02T22:27:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "labelEncrypted": "", "icon": "Brain", @@ -1166,20 +1177,20 @@ ], "SymptomEvent": [ { - "id": "", + "id": "", "userId": "round-trip-owner", - "definitionId": "", + "definitionId": "", "occurredAt": "2026-06-21T09:00:00.000Z", "intensity": 4, "noteEncrypted": null, - "episodeId": "", + "episodeId": "", "createdAt": "2026-05-03T00:07:00.000Z", "updatedAt": "2026-05-03T00:08:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", - "definitionId": "", + "definitionId": "", "occurredAt": "2026-06-21T11:00:00.000Z", "intensity": 8, "noteEncrypted": "", @@ -1188,9 +1199,9 @@ "updatedAt": "2026-05-03T00:08:01.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", - "definitionId": "", + "definitionId": "", "occurredAt": "2026-07-10T18:30:00.000Z", "intensity": 2, "noteEncrypted": null, @@ -1201,7 +1212,7 @@ ], "LifeEvent": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "category": "HOME", "startDate": "2023-09-01", @@ -1214,7 +1225,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "category": "OTHER", "startDate": "2025-12-01", @@ -1227,7 +1238,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "category": "WORK", "startDate": "2026-03-02", @@ -1242,7 +1253,7 @@ ], "UserHealthProfile": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "aboutMeEncrypted": "", "conditionsEncrypted": "", @@ -1267,18 +1278,18 @@ ], "HealthProfileFactRevision": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "kind": "SMOKING_STATUS", "valueEncrypted": "", "validFrom": "2026-01-01T00:00:00.000Z", "validUntil": "2026-06-30T12:34:56.789Z", "provenance": "USER_CORRECTION", - "supersededByRevisionId": "", + "supersededByRevisionId": "", "createdAt": "2026-05-03T05:08:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "kind": "SMOKING_STATUS", "valueEncrypted": "", @@ -1291,7 +1302,7 @@ ], "CycleProfile": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "goal": "AVOID_PREGNANCY", "cycleTrackingEnabled": true, @@ -1309,7 +1320,7 @@ ], "MenstrualCycle": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "startDate": "2026-05-04", "endDate": null, @@ -1326,7 +1337,7 @@ "updatedAt": "2026-05-03T08:34:02.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "startDate": "2026-06-01", "endDate": "rt-MenstrualCycle-endDate", @@ -1343,7 +1354,7 @@ "updatedAt": "2026-05-03T08:34:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "startDate": "2026-06-03", "endDate": null, @@ -1355,17 +1366,17 @@ "tz": null, "syncVersion": 0, "deletedAt": "2026-06-04T07:00:00.000Z", - "absorbedIntoId": "", + "absorbedIntoId": "", "createdAt": "2026-05-03T08:33:01.000Z", "updatedAt": "2026-05-03T08:34:01.000Z" } ], "CycleDayLog": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "date": "2026-06-02", - "cycleId": "", + "cycleId": "", "flow": "HEAVY", "intermenstrualBleeding": true, "basalBodyTempC": 2.5, @@ -1391,10 +1402,10 @@ "updatedAt": "2026-05-03T10:26:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "date": "2026-06-03", - "cycleId": "", + "cycleId": "", "flow": "LIGHT", "intermenstrualBleeding": false, "basalBodyTempC": null, @@ -1422,7 +1433,7 @@ ], "CycleSymptom": [ { - "id": "", + "id": "", "categoryId": "csc_physical", "key": "custom:round-trip-cramps", "labelKey": "cycle.symptom.custom", @@ -1435,15 +1446,15 @@ ], "CycleSymptomLink": [ { - "dayLogId": "", - "symptomId": "", + "dayLogId": "", + "symptomId": "", "severity": 3, "createdAt": "" } ], "CustomMetric": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "name": "Grip strength", "unit": "kg", @@ -1457,7 +1468,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "name": "Plank (deleted)", "unit": "s", @@ -1473,9 +1484,9 @@ ], "CustomMetricEntry": [ { - "id": "", + "id": "", "userId": "round-trip-owner", - "customMetricId": "", + "customMetricId": "", "value": 40, "unit": "kg", "measuredAt": "2026-06-28T18:00:00.000Z", @@ -1485,9 +1496,9 @@ "deletedAt": "" }, { - "id": "", + "id": "", "userId": "round-trip-owner", - "customMetricId": "", + "customMetricId": "", "value": 44, "unit": "kg", "measuredAt": "2026-07-01T18:00:00.000Z", @@ -1497,9 +1508,9 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", - "customMetricId": "", + "customMetricId": "", "value": 45, "unit": "kg", "measuredAt": "2026-07-02T18:00:00.000Z", @@ -1511,7 +1522,7 @@ ], "CorrelationPattern": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "canonicalKey": "p1:a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "family": "sleep", @@ -1535,7 +1546,7 @@ ], "HealthScoreRecord": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "dayKey": "2026-07-01", "timezone": "Europe/Berlin", @@ -1559,7 +1570,7 @@ ], "Workout": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "sportType": "RUNNING", "startedAt": "2026-06-29T06:00:00.000Z", @@ -1598,7 +1609,7 @@ ], "InboundDocument": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "kind": "LAB_RESULT", "title": "June labs", @@ -1629,7 +1640,7 @@ ], "Practitioner": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "name": "Closed practice (deleted)", "specialty": null, @@ -1644,7 +1655,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "name": "Round-trip practice", "specialty": "Internal medicine", @@ -1661,12 +1672,12 @@ ], "Encounter": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "occurredAt": "2026-04-02T08:00:00.000Z", "status": "DONE", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": null, "outcomeEncrypted": null, "bodySiteEncrypted": null, @@ -1677,17 +1688,17 @@ "deletedAt": "" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "occurredAt": "2026-06-30T08:00:00.000Z", "status": "PLANNED", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": "", "outcomeEncrypted": "", "bodySiteEncrypted": "", "laterality": "LEFT", - "reminderId": "", + "reminderId": "", "createdAt": "2026-05-04T04:31:00.000Z", "updatedAt": "2026-05-04T04:32:00.000Z", "deletedAt": null @@ -1695,17 +1706,17 @@ ], "EncounterDocumentLink": [ { - "id": "", - "encounterId": "", - "documentId": "", + "id": "", + "encounterId": "", + "documentId": "", "userId": "round-trip-owner", "createdAt": "2026-05-04T06:04:00.000Z" } ], "EncounterLabLink": [ { - "id": "", - "encounterId": "", + "id": "", + "encounterId": "", "labResultId": "", "userId": "round-trip-owner", "createdAt": "2026-05-04T07:44:00.000Z" @@ -1713,16 +1724,16 @@ ], "EncounterConditionLink": [ { - "id": "", - "encounterId": "", - "episodeId": "", + "id": "", + "encounterId": "", + "episodeId": "", "userId": "round-trip-owner", "createdAt": "2026-05-04T09:24:00.000Z" } ], "VaccinationRecord": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "occurredAt": "2026-04-14T00:00:00.000Z", "antigenSlug": "influenza", @@ -1741,7 +1752,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "occurredAt": "2026-05-14T00:00:00.000Z", "antigenSlug": "tdap", @@ -1750,10 +1761,10 @@ "seriesDoses": 3, "lotNumber": "RT-4471", "site": "LEFT_ARM", - "practitionerId": "", - "encounterId": "", - "reminderId": "", - "customVaccineId": "", + "practitionerId": "", + "encounterId": "", + "reminderId": "", + "customVaccineId": "", "noteEncrypted": "", "createdAt": "2026-05-04T11:14:00.000Z", "updatedAt": "2026-05-04T11:15:00.000Z", @@ -1762,16 +1773,16 @@ ], "VaccinationDocumentLink": [ { - "id": "", - "vaccinationId": "", - "documentId": "", + "id": "", + "vaccinationId": "", + "documentId": "", "userId": "round-trip-owner", "createdAt": "2026-05-04T12:44:00.000Z" } ], "CustomVaccine": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "name": "Deleted combo", "components": [ @@ -1784,7 +1795,7 @@ "updatedAt": "2026-05-04T14:28:01.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "name": "Round-trip travel combo", "components": [ @@ -1800,7 +1811,7 @@ ], "MeasurementReminder": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "label": "Blutdruck messen", "measurementType": "BLOOD_PRESSURE_SYS", @@ -1824,7 +1835,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "label": "Gewicht (deleted)", "measurementType": "WEIGHT", @@ -1850,9 +1861,9 @@ ], "MeasurementReminderEvent": [ { - "id": "", + "id": "", "userId": "round-trip-owner", - "reminderId": "", + "reminderId": "", "kind": "SATISFIED", "occurredAt": "2026-07-01T06:05:00.000Z", "onTime": true, @@ -1860,9 +1871,9 @@ "createdAt": "2026-05-04T17:47:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", - "reminderId": "", + "reminderId": "", "kind": "SKIPPED", "occurredAt": "2026-06-24T06:00:00.000Z", "onTime": false, @@ -1872,7 +1883,7 @@ ], "CoachConversation": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "title": null, "titleEncrypted": "", @@ -1884,7 +1895,7 @@ "documentScoped": true }, { - "id": "", + "id": "", "userId": "round-trip-owner", "title": null, "titleEncrypted": "", @@ -1898,8 +1909,8 @@ ], "CoachMessage": [ { - "id": "", - "conversationId": "", + "id": "", + "conversationId": "", "role": "assistant", "encryptedContent": "", "metricSourceJson": null, @@ -1912,8 +1923,8 @@ "createdAt": "2026-07-20T09:59:00.000Z" }, { - "id": "", - "conversationId": "", + "id": "", + "conversationId": "", "role": "user", "encryptedContent": "", "metricSourceJson": "rt-CoachMessage-metricSourceJson", @@ -1926,8 +1937,8 @@ "createdAt": "2026-07-20T09:58:00.000Z" }, { - "id": "", - "conversationId": "", + "id": "", + "conversationId": "", "role": "user", "encryptedContent": "", "metricSourceJson": null, @@ -1942,19 +1953,19 @@ ], "CoachConversationDocument": [ { - "conversationId": "", - "documentId": "", + "conversationId": "", + "documentId": "", "addedAt": "2026-07-21T07:59:00.000Z" } ], "CoachFact": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "factEncrypted": "", "category": "preference", "confidence": 50, - "sourceConversationId": "", + "sourceConversationId": "", "createdAt": "2026-05-05T00:26:01.000Z", "updatedAt": "2026-05-05T00:27:01.000Z", "deletedAt": "", @@ -1963,23 +1974,23 @@ "sourceMessageId": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "factEncrypted": "", "category": "constraint", "confidence": 80, - "sourceConversationId": "", + "sourceConversationId": "", "createdAt": "2026-05-05T00:26:00.000Z", "updatedAt": "2026-05-05T00:27:00.000Z", "deletedAt": null, "source": "user", "lastUsedAt": "2026-07-20T10:00:00.000Z", - "sourceMessageId": "" + "sourceMessageId": "" } ], "CoachPlan": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "metric": "BLOOD_PRESSURE", "ifCueEncrypted": "", @@ -1988,13 +1999,13 @@ "status": "active", "reviewDate": "2026-10-01T00:00:00.000Z", "outcomeEncrypted": "", - "sourceConversationId": "", + "sourceConversationId": "", "createdAt": "2026-05-05T02:10:00.000Z", "updatedAt": "2026-05-05T02:11:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "userId": "round-trip-owner", "metric": "WEIGHT", "ifCueEncrypted": "", @@ -2011,11 +2022,11 @@ ], "CoachReminder": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "noteEncrypted": "", "metric": null, - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "date", "dueAt": "2026-09-15T07:00:00.000Z", "contextCue": null, @@ -2029,17 +2040,17 @@ "deletedAt": "" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "noteEncrypted": "", "metric": "BLOOD_PRESSURE", - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "rt-CoachReminder-triggerKind", "dueAt": "2026-09-01T07:00:00.000Z", "contextCue": "rt-CoachReminder-contextCue", "status": "rt-CoachReminder-status", "source": "extractor", - "sourceConversationId": "", + "sourceConversationId": "", "lastSurfacedAt": "2026-06-30T12:34:56.789Z", "surfaceCount": 2, "createdAt": "2026-05-05T03:53:00.000Z", @@ -2049,7 +2060,7 @@ ], "MedicationInventoryItem": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "medicationId": "", "state": "ACTIVE", @@ -2068,7 +2079,7 @@ "updatedAt": "2026-05-05T05:36:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "medicationId": "", "state": "USED_UP", @@ -2089,14 +2100,14 @@ ], "MedicationInventoryEvent": [ { - "id": "", + "id": "", "medicationId": "", "delta": -8, "reason": "consumed", "occurredAt": "2026-07-09T07:00:00.000Z" }, { - "id": "", + "id": "", "medicationId": "", "delta": 30, "reason": "purchased", @@ -2124,7 +2135,7 @@ ], "ReminderPhaseConfig": [ { - "id": "", + "id": "", "medicationId": "", "greenValue": 45, "greenMode": "PERCENT", @@ -2138,7 +2149,7 @@ ], "MentalHealthAssessment": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "instrument": "GAD7", "locale": "en", @@ -2158,7 +2169,7 @@ "updatedAt": "2026-05-05T13:57:01.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "instrument": "PHQ9", "locale": "de", @@ -2180,7 +2191,7 @@ ], "ConsentReceipt": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "kind": "ai-processing", "artefact": "JVBERi0xLjQKJWZpeHR1cmU=", @@ -2189,7 +2200,7 @@ "createdAt": "2026-05-05T15:26:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "kind": "research-sharing", "artefact": "eyJhbGciOiJub25lIn0.e30.", @@ -2200,17 +2211,17 @@ ], "DocumentConditionLink": [ { - "id": "", - "documentId": "", - "episodeId": "", + "id": "", + "documentId": "", + "episodeId": "", "userId": "round-trip-owner", "createdAt": "2026-07-02T09:00:00.000Z" } ], "ExtractedFact": [ { - "id": "", - "documentId": "", + "id": "", + "documentId": "", "userId": "round-trip-owner", "factType": "OBSERVATION", "status": "APPROVED", @@ -2226,7 +2237,7 @@ ], "PersonalRecord": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "metricType": "WALKING_RUNNING_DISTANCE", "metricSlot": "running_10km_time", @@ -2240,7 +2251,7 @@ "createdAt": "2026-05-05T20:31:02.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "metricType": "WALKING_RUNNING_DISTANCE", "metricSlot": "running_5km_time", @@ -2254,7 +2265,7 @@ "createdAt": "2026-05-05T20:31:01.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "metricType": "WEIGHT", "metricSlot": null, @@ -2270,14 +2281,14 @@ ], "UserAchievement": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "achievementId": "intake-total-10", "unlockedAt": "2026-02-21T10:15:00.000Z", "createdAt": "2026-05-05T22:04:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "achievementId": "retired-badge-from-an-older-release", "unlockedAt": "2025-11-05T08:00:00.000Z", @@ -2286,7 +2297,7 @@ ], "EnvironmentContext": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "date": "2026-06-15", "locationEncrypted": "", @@ -2330,7 +2341,7 @@ "updatedAt": "2026-05-06T00:21:00.000Z" }, { - "id": "", + "id": "", "userId": "round-trip-owner", "date": "2026-07-01", "locationEncrypted": "", @@ -2376,7 +2387,7 @@ ], "EnvironmentTravelLocation": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "startDate": "2026-06-10", "endDate": "2026-06-20", @@ -2387,7 +2398,7 @@ ], "DawarichDay": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "date": "2026-06-15", "totalDistanceM": 48300, @@ -2404,7 +2415,7 @@ ], "MedicationScheduleRevision": [ { - "id": "", + "id": "", "medicationId": "", "validFrom": "2026-01-01T00:00:00.000Z", "validUntil": "2026-03-01T00:00:00.000Z", @@ -2420,7 +2431,7 @@ "createdAt": "2026-05-06T04:47:00.000Z" }, { - "id": "", + "id": "", "medicationId": "", "validFrom": "2026-02-01T00:00:00.000Z", "validUntil": "2026-03-01T00:00:00.000Z", @@ -2432,11 +2443,11 @@ } ], "source": "ARCHIVED", - "supersededByRevisionId": "", + "supersededByRevisionId": "", "createdAt": "2026-05-06T04:47:02.000Z" }, { - "id": "", + "id": "", "medicationId": "", "validFrom": "2026-03-01T00:00:00.000Z", "validUntil": "2026-05-01T00:00:00.000Z", @@ -2454,7 +2465,7 @@ ], "MedicationEfficacyTarget": [ { - "id": "", + "id": "", "medicationId": "", "measurementType": "WEIGHT", "biomarkerId": "", @@ -2465,7 +2476,7 @@ ], "EcgRecording": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "source": "MANUAL", "externalRecordingId": "round-trip-signal-1", @@ -2484,7 +2495,7 @@ ], "OnboardingRecord": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "needsJson": { "areas": [ @@ -2553,7 +2564,7 @@ ], "BiomarkerAlias": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "biomarkerId": "", "name": "Ferr.", @@ -2564,7 +2575,7 @@ ], "BiomarkerMerge": [ { - "id": "", + "id": "", "userId": "round-trip-owner", "targetBiomarkerId": "", "sourceBiomarkerId": "merged-away-marker", @@ -2575,17 +2586,17 @@ ], "LabResultDocumentLink": [ { - "id": "", + "id": "", "labResultId": "", - "documentId": "", + "documentId": "", "userId": "round-trip-owner", "createdAt": "2026-05-06T14:44:00.000Z" } ], "EncounterMedicationLink": [ { - "id": "", - "encounterId": "", + "id": "", + "encounterId": "", "medicationId": "", "userId": "round-trip-owner", "createdAt": "2026-05-06T16:24:00.000Z" @@ -2593,34 +2604,34 @@ ], "EncounterVaccinationLink": [ { - "id": "", - "encounterId": "", - "vaccinationId": "", + "id": "", + "encounterId": "", + "vaccinationId": "", "userId": "round-trip-owner", "createdAt": "2026-05-06T18:04:00.000Z" } ], "MedicationDocumentLink": [ { - "id": "", + "id": "", "medicationId": "", - "documentId": "", + "documentId": "", "userId": "round-trip-owner", "createdAt": "2026-05-06T19:44:00.000Z" } ], "MedicationConditionLink": [ { - "id": "", + "id": "", "medicationId": "", - "episodeId": "", + "episodeId": "", "userId": "round-trip-owner", "createdAt": "2026-05-06T21:24:00.000Z" } ], "AccountGrant": [ { - "id": "", + "id": "", "grantorId": "round-trip-owner", "granteeId": "parity-delegate", "access": "READ", @@ -3985,17 +3996,30 @@ "familyHistory": [ { "id": "", + "relationship": "FATHER", + "condition": "Hypertension (deleted)", + "ageAtOnset": null, + "note": null, + "notesEncrypted": "", + "createdAt": "2026-05-02T15:46:01.000Z", + "updatedAt": "2026-05-02T15:47:01.000Z", + "deletedAt": "" + }, + { + "id": "", "relationship": "MOTHER", "condition": "Type 2 diabetes", "ageAtOnset": 3, - "note": "rt-FamilyHistoryEntry-notesEncrypted", + "note": null, + "notesEncrypted": "", "createdAt": "2026-05-02T15:46:00.000Z", - "updatedAt": "2026-05-02T15:47:00.000Z" + "updatedAt": "2026-05-02T15:47:00.000Z", + "deletedAt": null } ], "workouts": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T21:58:00.000Z", "updatedAt": "2026-05-03T21:59:00.000Z", "metadata": { @@ -4020,7 +4044,7 @@ ], "documents": [ { - "id": "", + "id": "", "kind": "LAB_RESULT", "title": "June labs", "filename": "june-labs.pdf", @@ -4066,7 +4090,7 @@ } }, "healthProfile": { - "id": "", + "id": "", "aboutMe": null, "conditions": null, "allergies": null, @@ -4096,18 +4120,18 @@ }, "healthProfileFacts": [ { - "id": "", + "id": "", "kind": "SMOKING_STATUS", "value": null, "valueEncrypted": "", "validFrom": "2026-01-01T00:00:00.000Z", "validUntil": "2026-06-30T12:34:56.789Z", "provenance": "USER_CORRECTION", - "supersededByRevisionId": "", + "supersededByRevisionId": "", "createdAt": "2026-05-03T05:08:00.000Z" }, { - "id": "", + "id": "", "kind": "SMOKING_STATUS", "value": null, "valueEncrypted": "", @@ -4120,7 +4144,7 @@ ], "customMetrics": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T15:09:00.000Z", "updatedAt": "2026-05-03T15:10:00.000Z", "deletedAt": null, @@ -4133,7 +4157,7 @@ "correlationEnabled": true, "entries": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T16:48:02.000Z", "deletedAt": "", "noteEncrypted": null, @@ -4143,7 +4167,7 @@ "note": null }, { - "id": "", + "id": "", "createdAt": "2026-05-03T16:48:00.000Z", "deletedAt": null, "noteEncrypted": "", @@ -4153,7 +4177,7 @@ "note": null }, { - "id": "", + "id": "", "createdAt": "2026-05-03T16:48:01.000Z", "deletedAt": null, "noteEncrypted": "", @@ -4165,7 +4189,7 @@ ] }, { - "id": "", + "id": "", "createdAt": "2026-05-03T15:09:01.000Z", "updatedAt": "2026-05-03T15:10:01.000Z", "deletedAt": "", @@ -4181,7 +4205,7 @@ ], "correlationPatterns": [ { - "id": "", + "id": "", "updatedAt": "2026-05-03T18:39:00.000Z", "createdAt": "2026-05-03T18:38:00.000Z", "canonicalKey": "p1:a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", @@ -4205,7 +4229,7 @@ "decryptFailures": [], "intradayProfiles": [ { - "id": "", + "id": "", "createdAt": "2026-05-01T09:51:00.000Z", "updatedAt": "2026-05-01T09:52:00.000Z", "type": "ACTIVITY_STEPS", @@ -4271,7 +4295,7 @@ ], "healthScoreRecords": [ { - "id": "", + "id": "", "createdAt": "2026-05-03T20:13:00.000Z", "dayKey": "2026-07-01", "timezone": "Europe/Berlin", @@ -4293,7 +4317,7 @@ } ], "onboardingRecord": { - "id": "", + "id": "", "createdAt": "2026-05-06T09:47:00.000Z", "updatedAt": "2026-05-06T09:48:00.000Z", "needs": { @@ -4360,7 +4384,7 @@ }, "practitioners": [ { - "id": "", + "id": "", "name": "Closed practice (deleted)", "specialty": null, "practice": null, @@ -4374,7 +4398,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "name": "Round-trip practice", "specialty": "Internal medicine", "practice": "rt-Practitioner-practice", @@ -4390,26 +4414,26 @@ ], "encounters": [ { - "id": "", + "id": "", "occurredAt": "2026-06-30T08:00:00.000Z", "status": "PLANNED", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": "", "outcomeEncrypted": "", "bodySiteEncrypted": "", "laterality": "LEFT", - "reminderId": "", + "reminderId": "", "createdAt": "2026-05-04T04:31:00.000Z", "updatedAt": "2026-05-04T04:32:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "occurredAt": "2026-04-02T08:00:00.000Z", "status": "DONE", "kind": "ROUTINE", - "practitionerId": "", + "practitionerId": "", "reasonEncrypted": null, "outcomeEncrypted": null, "bodySiteEncrypted": null, @@ -4422,28 +4446,28 @@ ], "encounterDocumentLinks": [ { - "encounterId": "", - "targetId": "", + "encounterId": "", + "targetId": "", "createdAt": "2026-05-04T06:04:00.000Z" } ], "encounterLabLinks": [ { - "encounterId": "", + "encounterId": "", "targetId": "", "createdAt": "2026-05-04T07:44:00.000Z" } ], "encounterConditionLinks": [ { - "encounterId": "", + "encounterId": "", "targetId": "", "createdAt": "2026-05-04T09:24:00.000Z" } ], "customVaccines": [ { - "id": "", + "id": "", "name": "Deleted combo", "components": [ "rabies" @@ -4455,7 +4479,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "name": "Round-trip travel combo", "components": [ "typhoid", @@ -4470,7 +4494,7 @@ ], "vaccinations": [ { - "id": "", + "id": "", "occurredAt": "2026-05-14T00:00:00.000Z", "antigenSlug": "tdap", "vaccineName": "Tetanus, diphtheria and pertussis", @@ -4478,17 +4502,17 @@ "seriesDoses": 3, "lotNumber": "RT-4471", "site": "LEFT_ARM", - "practitionerId": "", - "encounterId": "", - "reminderId": "", - "customVaccineId": "", + "practitionerId": "", + "encounterId": "", + "reminderId": "", + "customVaccineId": "", "noteEncrypted": "", "createdAt": "2026-05-04T11:14:00.000Z", "updatedAt": "2026-05-04T11:15:00.000Z", "deletedAt": null }, { - "id": "", + "id": "", "occurredAt": "2026-04-14T00:00:00.000Z", "antigenSlug": "influenza", "vaccineName": "Influenza (deleted)", @@ -4508,14 +4532,14 @@ ], "vaccinationDocumentLinks": [ { - "vaccinationId": "", - "targetId": "", + "vaccinationId": "", + "targetId": "", "createdAt": "2026-05-04T12:44:00.000Z" } ], "measurementReminders": [ { - "id": "", + "id": "", "label": "Blutdruck messen", "measurementType": "BLOOD_PRESSURE_SYS", "intervalDays": 7, @@ -4537,7 +4561,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "label": "Gewicht (deleted)", "measurementType": "WEIGHT", "intervalDays": 14, @@ -4561,8 +4585,8 @@ ], "measurementReminderEvents": [ { - "id": "", - "reminderId": "", + "id": "", + "reminderId": "", "kind": "SKIPPED", "occurredAt": "2026-06-24T06:00:00.000Z", "onTime": false, @@ -4570,8 +4594,8 @@ "createdAt": "2026-05-04T17:47:01.000Z" }, { - "id": "", - "reminderId": "", + "id": "", + "reminderId": "", "kind": "SATISFIED", "occurredAt": "2026-07-01T06:05:00.000Z", "onTime": true, @@ -4581,7 +4605,7 @@ ], "coachConversations": [ { - "id": "", + "id": "", "titleEncrypted": "", "documentScoped": false, "summaryEncrypted": "", @@ -4591,7 +4615,7 @@ "updatedAt": "2026-05-04T19:25:00.000Z", "messages": [ { - "id": "", + "id": "", "role": "user", "contentEncrypted": "", "metricSourceJson": "rt-CoachMessage-metricSourceJson", @@ -4604,7 +4628,7 @@ "createdAt": "2026-07-20T09:58:00.000Z" }, { - "id": "", + "id": "", "role": "assistant", "contentEncrypted": "", "metricSourceJson": null, @@ -4620,7 +4644,7 @@ "attachments": [] }, { - "id": "", + "id": "", "titleEncrypted": "", "documentScoped": true, "summaryEncrypted": null, @@ -4630,7 +4654,7 @@ "updatedAt": "2026-05-04T19:25:01.000Z", "messages": [ { - "id": "", + "id": "", "role": "user", "contentEncrypted": "", "metricSourceJson": null, @@ -4645,7 +4669,7 @@ ], "attachments": [ { - "documentId": "", + "documentId": "", "addedAt": "2026-07-21T07:59:00.000Z" } ] @@ -4653,25 +4677,25 @@ ], "coachFacts": [ { - "id": "", + "id": "", "factEncrypted": "", "deletedAt": null, "category": "constraint", "confidence": 80, - "sourceConversationId": "", + "sourceConversationId": "", "source": "user", "lastUsedAt": "2026-07-20T10:00:00.000Z", - "sourceMessageId": "", + "sourceMessageId": "", "createdAt": "2026-05-05T00:26:00.000Z", "updatedAt": "2026-05-05T00:27:00.000Z" }, { - "id": "", + "id": "", "factEncrypted": "", "deletedAt": "", "category": "preference", "confidence": 50, - "sourceConversationId": "", + "sourceConversationId": "", "source": "user", "lastUsedAt": null, "sourceMessageId": null, @@ -4681,7 +4705,7 @@ ], "coachPlans": [ { - "id": "", + "id": "", "metric": "BLOOD_PRESSURE", "ifCueEncrypted": "", "thenActionEncrypted": "", @@ -4690,12 +4714,12 @@ "deletedAt": null, "status": "active", "reviewDate": "2026-10-01T00:00:00.000Z", - "sourceConversationId": "", + "sourceConversationId": "", "createdAt": "2026-05-05T02:10:00.000Z", "updatedAt": "2026-05-05T02:11:00.000Z" }, { - "id": "", + "id": "", "metric": "WEIGHT", "ifCueEncrypted": "", "thenActionEncrypted": "", @@ -4711,28 +4735,28 @@ ], "coachReminders": [ { - "id": "", + "id": "", "noteEncrypted": "", "deletedAt": null, "metric": "BLOOD_PRESSURE", - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "rt-CoachReminder-triggerKind", "dueAt": "2026-09-01T07:00:00.000Z", "contextCue": "rt-CoachReminder-contextCue", "status": "rt-CoachReminder-status", "source": "extractor", - "sourceConversationId": "", + "sourceConversationId": "", "lastSurfacedAt": "2026-06-30T12:34:56.789Z", "surfaceCount": 2, "createdAt": "2026-05-05T03:53:00.000Z", "updatedAt": "2026-05-05T03:54:00.000Z" }, { - "id": "", + "id": "", "noteEncrypted": "", "deletedAt": "", "metric": null, - "relatedPlanId": "", + "relatedPlanId": "", "triggerKind": "date", "dueAt": "2026-09-15T07:00:00.000Z", "contextCue": null, @@ -4747,7 +4771,7 @@ ], "mentalHealthAssessments": [ { - "id": "", + "id": "", "instrument": "GAD7", "locale": "en", "version": "standard", @@ -4766,7 +4790,7 @@ "updatedAt": "2026-05-05T13:57:01.000Z" }, { - "id": "", + "id": "", "instrument": "PHQ9", "locale": "de", "version": "rt-MentalHealthAssessment-version", @@ -4787,7 +4811,7 @@ ], "consentReceipts": [ { - "id": "", + "id": "", "kind": "ai-processing", "artefact": "JVBERi0xLjQKJWZpeHR1cmU=", "signedAt": "2026-06-01T09:00:00.000Z", @@ -4795,7 +4819,7 @@ "createdAt": "2026-05-05T15:26:00.000Z" }, { - "id": "", + "id": "", "kind": "research-sharing", "artefact": "eyJhbGciOiJub25lIn0.e30.", "signedAt": "2026-06-02T09:00:00.000Z", @@ -4805,15 +4829,15 @@ ], "documentConditionLinks": [ { - "documentId": "", + "documentId": "", "episodeId": "", "createdAt": "2026-07-02T09:00:00.000Z" } ], "extractedFacts": [ { - "id": "", - "documentId": "", + "id": "", + "documentId": "", "factType": "OBSERVATION", "status": "APPROVED", "confidence": 0.94, @@ -4998,7 +5022,7 @@ ], "ecgRecordings": [ { - "id": "", + "id": "", "waveformEncrypted": "", "source": "MANUAL", "externalRecordingId": "round-trip-signal-1", @@ -5016,7 +5040,7 @@ ], "symptomDefinitions": [ { - "id": "", + "id": "", "labelEncrypted": "", "icon": "Zap", "sortOrder": 0, @@ -5025,7 +5049,7 @@ "updatedAt": "2026-05-02T22:27:00.000Z", "events": [ { - "id": "", + "id": "", "noteEncrypted": null, "occurredAt": "2026-06-21T09:00:00.000Z", "intensity": 4, @@ -5034,7 +5058,7 @@ "updatedAt": "2026-05-03T00:08:00.000Z" }, { - "id": "", + "id": "", "noteEncrypted": null, "occurredAt": "2026-07-10T18:30:00.000Z", "intensity": 2, @@ -5045,7 +5069,7 @@ ] }, { - "id": "", + "id": "", "labelEncrypted": "", "icon": "Brain", "sortOrder": 1, @@ -5054,7 +5078,7 @@ "updatedAt": "2026-05-02T22:27:01.000Z", "events": [ { - "id": "", + "id": "", "noteEncrypted": "", "occurredAt": "2026-06-21T11:00:00.000Z", "intensity": 8, @@ -5067,7 +5091,7 @@ ], "lifeEvents": [ { - "id": "", + "id": "", "titleEncrypted": "", "noteEncrypted": "", "category": "HOME", @@ -5079,7 +5103,7 @@ "deletedAt": null }, { - "id": "", + "id": "", "titleEncrypted": "", "noteEncrypted": null, "category": "OTHER", @@ -5091,7 +5115,7 @@ "deletedAt": "" }, { - "id": "", + "id": "", "titleEncrypted": "", "noteEncrypted": null, "category": "WORK", @@ -5106,28 +5130,28 @@ "labResultDocumentLinks": [ { "labResultId": "", - "documentId": "", + "documentId": "", "createdAt": "2026-05-06T14:44:00.000Z" } ], "encounterMedicationLinks": [ { - "encounterId": "", + "encounterId": "", "medicationId": "", "createdAt": "2026-05-06T16:24:00.000Z" } ], "encounterVaccinationLinks": [ { - "encounterId": "", - "vaccinationId": "", + "encounterId": "", + "vaccinationId": "", "createdAt": "2026-05-06T18:04:00.000Z" } ], "medicationDocumentLinks": [ { "medicationId": "", - "documentId": "", + "documentId": "", "createdAt": "2026-05-06T19:44:00.000Z" } ], diff --git a/tests/integration/__golden__/backup-parity/restore-version-1.json b/tests/integration/__golden__/backup-parity/restore-version-1.json index 1223a636a..f079e68ac 100644 --- a/tests/integration/__golden__/backup-parity/restore-version-1.json +++ b/tests/integration/__golden__/backup-parity/restore-version-1.json @@ -1707,9 +1707,11 @@ "relationship": "FATHER", "condition": "Diabetes", "ageAtOnset": 55, - "note": "type 2", + "note": null, + "notesEncrypted": "", "createdAt": "", - "updatedAt": "" + "updatedAt": "", + "deletedAt": null } ], "workouts": [ diff --git a/tests/integration/family-history-backup-tombstones.test.ts b/tests/integration/family-history-backup-tombstones.test.ts new file mode 100644 index 000000000..e83853055 --- /dev/null +++ b/tests/integration/family-history-backup-tombstones.test.ts @@ -0,0 +1,53 @@ +/** + * The disaster-recovery file carries deleted family-history entries, as it + * carries every other record's tombstones, and carries their note as the + * ciphertext at rest. The portable file carries the live entries only, with + * the note readable. The full round trip, the restored tombstone included, is + * pinned by the backup parity golden copies. + */ +import { beforeEach, describe, expect, it } from "vitest"; + +import { encryptToBytes } from "@/lib/ai/coach/bytes-codec"; +import { buildFamilyHistoryBackupSlice } from "@/lib/export/family-history-backup"; + +import { makeUser } from "../kit/factories"; +import { getPrismaClient, truncateAllTables } from "./setup"; + +const prisma = getPrismaClient(); + +beforeEach(() => truncateAllTables(prisma)); + +describe("family history in the backup", () => { + it("keeps a deleted entry in the disaster-recovery file and out of the portable one", async () => { + const user = await makeUser(); + const notes = encryptToBytes("diagnosed at fifty"); + await prisma.familyHistoryEntry.create({ + data: { userId: user.id, relationship: "MOTHER", condition: "Asthma" }, + }); + const deleted = await prisma.familyHistoryEntry.create({ + data: { + userId: user.id, + relationship: "FATHER", + condition: "Hypertension", + notesEncrypted: notes, + deletedAt: new Date("2026-09-30T10:00:00.000Z"), + }, + }); + + const dr = await buildFamilyHistoryBackupSlice(prisma, user.id, true); + expect(dr.familyHistory).toHaveLength(2); + const tombstone = dr.familyHistory.find((e) => e.id === deleted.id); + expect(tombstone?.deletedAt).toBe("2026-09-30T10:00:00.000Z"); + expect(tombstone?.note).toBeNull(); + expect(tombstone?.notesEncrypted).toBe( + Buffer.from(notes).toString("base64"), + ); + + const portable = await buildFamilyHistoryBackupSlice( + prisma, + user.id, + false, + ); + expect(portable.familyHistory.map((e) => e.condition)).toEqual(["Asthma"]); + }); +});