nusaibah0110's picture
Update application with new features and components
1c68fe6
/**
* 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);
},
};