File size: 5,286 Bytes
1c68fe6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | /**
* 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<string, boolean>;
/** Individual features within each category that were checked */
selectedFindings: Record<string, boolean>;
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<string, { type: string; hours: number[] }>;
}
// ββ 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<PatientHistory>;
/** Native (untreated) examination visual observations */
nativeFindings?: Partial<NativeFindings>;
/** Acetic acid clinical findings checkboxes */
aceticFindings?: Partial<AceticFindings>;
/** Generic per-step observation bucket (backwards compat / future steps) */
stepFindings?: Record<string, any>;
/** Lesion marks and Swede score from BiopsyMarking */
biopsyMarkings?: BiopsyMarkings;
/** All text/select fields from the ReportPage form */
reportFormData?: Record<string, string>;
/** 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<PatientSession>): 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);
},
};
|