File size: 5,971 Bytes
bab7e89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1c68fe6
 
 
 
bab7e89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1c68fe6
bab7e89
 
 
 
 
 
 
 
 
 
 
 
3454dc0
bab7e89
3454dc0
bab7e89
3454dc0
bab7e89
3454dc0
bab7e89
 
 
 
 
 
 
1c68fe6
bab7e89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { useState } from 'react';
import { PatientHistoryPage } from './pages/PatientHistoryPage';

import HomePage from './pages/HomePage.tsx';
import { PatientRegistry } from './pages/PatientRegistry.tsx';
import { GuidedCapturePage } from './pages/GuidedCapturePage';
import { AcetowhiteExamPage } from './pages/AcetowhiteExamPage';
import { GreenFilterPage } from './pages/GreenFilterPage';
import { LugolExamPage } from './pages/LugolExamPage';
import { BiopsyMarking } from './pages/BiopsyMarking';
import { ReportPage } from './pages/ReportPage';
import { Sidebar } from './components/Sidebar';
import { Header } from './components/Header';
import { Footer } from './components/Footer';
import { ChatBot } from './components/ChatBot';

export function App() {
  const [currentPage, setCurrentPage] = useState<'home' | 'patientinfo' | 'patienthistory' | 'colposcopyimaging' | 'acetowhite' | 'greenfilter' | 'lugol' | 'guidedcapture' | 'biopsymarking' | 'capture' | 'annotation' | 'compare' | 'report' | 'settings'>('home');
  const [currentPatientId, setCurrentPatientId] = useState<string | undefined>(undefined);
  const [isNewPatientFlow, setIsNewPatientFlow] = useState(false);
  const [capturedImages, setCapturedImages] = useState<any[]>([]);
  const [guidanceMode, setGuidanceMode] = useState<'capture' | 'annotation' | 'compare' | 'report'>('capture');

  const goToPatientRegistry = () => {
    setCurrentPatientId(undefined);
    setIsNewPatientFlow(false);
    setCurrentPage('patientinfo');
  };

  const goToPatientHistory = (patientId?: string, isNewPatient: boolean = false) => {
    setCurrentPatientId(patientId);
    setIsNewPatientFlow(isNewPatient);
    setCurrentPage('patienthistory');
  };

  const goToHome = () => {
    setCurrentPatientId(undefined);
    setIsNewPatientFlow(false);
    setCurrentPage('home');
  };

  const goToColposcopyImaging = () => setCurrentPage('colposcopyimaging');
  const goToAcetowhite = () => setCurrentPage('acetowhite');
  const goToGreenFilter = () => setCurrentPage('greenfilter');
  const goToLugol = () => setCurrentPage('lugol');
  const goToGuidedCapture = () => {
    setCurrentPage('capture');
    setGuidanceMode('capture');
  };
  const goToBiopsyMarking = () => setCurrentPage('biopsymarking');
  const goToCapture = () => {
    setCurrentPage('capture');
    setGuidanceMode('capture');
  };
  const goToAnnotation = () => {
    setCurrentPage('annotation');
    setGuidanceMode('annotation');
  };
  const goToCompare = () => {
    setCurrentPage('compare');
    setGuidanceMode('compare');
  };
  const goToReport = () => setCurrentPage('report');

  const renderMain = () => {
    switch (currentPage) {
      case 'home':
        return <HomePage onNavigateToPatients={goToPatientRegistry} onNext={goToPatientRegistry} />;
      case 'patientinfo':
        return <PatientRegistry onNewPatient={(newPatientId) => goToPatientHistory(newPatientId, true)} onSelectExisting={(id: string) => goToPatientHistory(id)} onBackToHome={goToHome} onNext={goToGuidedCapture} />;
      case 'patienthistory':
        return <PatientHistoryPage goToImaging={goToGuidedCapture} goBackToRegistry={goToPatientRegistry} patientID={currentPatientId} goToGuidedCapture={isNewPatientFlow ? goToGuidedCapture : undefined} />;
      
      case 'acetowhite':
        return <AcetowhiteExamPage goBack={goToColposcopyImaging} onNext={goToGreenFilter} />;
      case 'greenfilter':
        return <GreenFilterPage goBack={goToAcetowhite} onNext={goToLugol} />;
      case 'lugol':
        return <LugolExamPage goBack={goToGreenFilter} onNext={goToGuidedCapture} />;
      case 'biopsymarking':
        return <BiopsyMarking onBack={goToGuidedCapture} onNext={goToReport} capturedImages={capturedImages} />;
      case 'capture':
        return <GuidedCapturePage onNext={goToBiopsyMarking} onGoToPatientRecords={goToPatientRegistry} initialMode="capture" onCapturedImagesChange={setCapturedImages} onModeChange={setGuidanceMode} />;
      case 'annotation':
        return <GuidedCapturePage onNext={goToBiopsyMarking} onGoToPatientRecords={goToPatientRegistry} initialMode="annotation" onCapturedImagesChange={setCapturedImages} onModeChange={setGuidanceMode} />;
      case 'compare':
        return <GuidedCapturePage onNext={goToBiopsyMarking} onGoToPatientRecords={goToPatientRegistry} initialMode="compare" onCapturedImagesChange={setCapturedImages} onModeChange={setGuidanceMode} />;
      case 'report':
        return <ReportPage onBack={goToCompare} onNext={goToHome} onGoToPatientRecords={goToPatientRegistry} capturedImages={capturedImages} />;
      default:
        return <div className="p-8">Page "{currentPage}" not implemented yet.</div>;
    }
  };

  // Sidebar is shown on all pages except home
  const showSidebar = currentPage !== 'home';
  const sidebarKey = currentPage === 'patienthistory' ? 'patientinfo' : (currentPage === 'guidedcapture' && guidanceMode === 'report') ? 'report' : ['capture', 'annotation', 'compare', 'guidedcapture'].includes(currentPage) ? guidanceMode : currentPage;

  return (
    <div className="flex flex-col min-h-screen">
      <Header compact={currentPage === 'guidedcapture'} />

      <div className="flex-1 flex min-h-0">
        {showSidebar && <Sidebar current={sidebarKey as 'home' | 'patientinfo' | 'capture' | 'annotation' | 'compare' | 'report' | 'settings'} onNavigate={k => {
          if (k === 'home') goToHome();
          else if (k === 'patientinfo') goToPatientRegistry();
          else if (k === 'capture') goToCapture();
          else if (k === 'annotation') goToAnnotation();
          else if (k === 'compare') goToCompare();
          else if (k === 'report') goToReport();
          else setCurrentPage(k as any);
        }} />}
        <main className="flex-1 bg-white overflow-auto">
          {renderMain()}
        </main>
      </div>

      <Footer compact={currentPage === 'guidedcapture'} />
      <ChatBot />
    </div>
  );
}