/** * sessionStore — localStorage-based session DB for the Pathora colposcopy assistant. * Every examination page writes here; ReportPage reads the full record for AI generation. * * Data schema: * patientInfo — registry id, name, exam date * patientHistory — PatientHistoryForm (demographics, symptoms, screening, risks) * nativeFindings — ImagingObservations for the native (untreated) step * aceticFindings — AceticFindingsForm category+feature checkboxes for the acetic acid step * stepFindings — generic per-step observations bucket (kept for backwards compat) * biopsyMarkings — lesion marks with clock hours + Swede score from BiopsyMarking * reportFormData — all free-text / select fields on ReportPage * sessionStarted — ISO timestamp */ // ── Patient history form (PatientHistoryForm.tsx) ───────────────────────────── export interface PatientHistory { name: string; age: string; bloodGroup: string; parity: string; pregnancyStatus: string; gestationalAgeWeeks: string; monthsSinceLastDelivery: string; monthsSinceAbortion: string; menstrualStatus: string; sexualHistory: string; hpvStatus: string; hpvVaccination: string; patientProfileNotes: string; postCoitalBleeding: boolean; interMenstrualBleeding: boolean; persistentDischarge: boolean; symptomsNotes: string; papSmearResult: string; hpvDnaTypes: string; pastProcedures: { biopsy: boolean; leep: boolean; cryotherapy: boolean; none: boolean }; screeningNotes: string; smoking: string; immunosuppression: { hiv: boolean; steroids: boolean; none: boolean }; riskFactorsNotes: string; } // ── Native step visual observations (ImagingObservations.tsx, native layout) ── export interface NativeFindings { cervixFullyVisible: 'Yes' | 'No' | null; obscuredBy: { blood: boolean; inflammation: boolean; discharge: boolean; scarring: boolean }; adequacyNotes: string; scjVisibility: string; scjNotes: string; tzType: string; suspiciousAtNativeView: boolean; obviousGrowths: boolean; contactBleeding: boolean; irregularSurface: boolean; other: boolean; additionalNotes: string; } // ── Acetic acid clinical findings (AceticFindingsForm.tsx) ──────────────────── export interface AceticFindings { /** Top-level categories that were checked */ selectedCategories: Record; /** Individual features within each category that were checked */ selectedFindings: Record; additionalNotes: string; } // ── Biopsy marking (BiopsyMarking.tsx) ──────────────────────────────────────── export interface BiopsyMarkings { lesionMarks: Array<{ type: string; typeCode: string; clockHour: number; color: string }>; swedeScores: { acetoUptake: number | null; marginsAndSurface: number | null; vessels: number | null; lesionSize: number | null; iodineStaining: number | null; }; totalSwedeScore: number; marksByType: Record; } // ── Full session record ──────────────────────────────────────────────────────── export interface PatientSession { /** Basic registry info set when a patient is selected */ patientInfo?: { id: string; name: string; examDate?: string }; /** Full patient history / intake form */ patientHistory?: Partial; /** Native (untreated) examination visual observations */ nativeFindings?: Partial; /** Acetic acid clinical findings checkboxes */ aceticFindings?: Partial; /** Generic per-step observation bucket (backwards compat / future steps) */ stepFindings?: Record; /** Lesion marks and Swede score from BiopsyMarking */ biopsyMarkings?: BiopsyMarkings; /** All text/select fields from the ReportPage form */ reportFormData?: Record; /** ISO timestamp when this session was started */ sessionStarted?: string; } const KEY = 'pathora_colpo_session'; export const sessionStore = { /** Read the full session from localStorage. Returns {} on error. */ get(): PatientSession { try { return JSON.parse(localStorage.getItem(KEY) ?? '{}') as PatientSession; } catch { return {}; } }, /** Shallow-merge a partial update into the stored session. */ merge(partial: Partial): void { const current = sessionStore.get(); localStorage.setItem(KEY, JSON.stringify({ ...current, ...partial })); }, /** Wipe the session (call when starting a new patient). */ clear(): void { localStorage.removeItem(KEY); }, /** Return the full session as pretty-printed JSON (for download / debugging). */ export(): string { return JSON.stringify(sessionStore.get(), null, 2); }, };