File size: 3,401 Bytes
59d87be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**
 * EWAAST React Application
 * 
 * Main app component with state machine for navigation.
 * Adapted from Google's appoint-ready App.js pattern.
 */

import React, { useState } from 'react';
import WelcomePage from './components/WelcomePage/WelcomePage';
import PatientSelector from './components/PatientSelector/PatientSelector';
import SimulationBriefing from './components/SimulationBriefing/SimulationBriefing';
import WoundUpload from './components/WoundUpload/WoundUpload';
import Assessment from './components/Assessment/Assessment';
import './shared/Style.css';

const App = () => {
  const [currentPage, setCurrentPage] = useState('welcome');
  const [selectedPatient, setSelectedPatient] = useState(null);
  const [selectedWound, setSelectedWound] = useState(null);
  const [uploadedImage, setUploadedImage] = useState(null);
  const [patientContext, setPatientContext] = useState('');
  const [assessmentResult, setAssessmentResult] = useState(null);

  const handleStartAssessment = () => {
    setCurrentPage('patientSelector');
  };

  const handlePatientSelected = (patient, wound) => {
    setSelectedPatient(patient);
    setSelectedWound(wound);
    setPatientContext(patient.ehr_summary);
    setCurrentPage('simulationBriefing');
  };

  const handleStartSimulation = () => {
    setCurrentPage('upload');
  };

  const handleImageUploaded = (imageFile, context) => {
    setUploadedImage(imageFile);
    setPatientContext(context);
    setCurrentPage('assessment');
  };

  const handleAssessmentComplete = (result) => {
    setAssessmentResult(result);
  };

  const handleBack = () => {
    if (currentPage === 'patientSelector') {
      setCurrentPage('welcome');
    } else if (currentPage === 'simulationBriefing') {
      setCurrentPage('patientSelector');
    } else if (currentPage === 'upload') {
      setCurrentPage('simulationBriefing');
    } else if (currentPage === 'assessment') {
      setCurrentPage('upload');
      setAssessmentResult(null);
    }
  };

  const handleStartOver = () => {
    setCurrentPage('welcome');
    setSelectedPatient(null);
    setSelectedWound(null);
    setUploadedImage(null);
    setPatientContext('');
    setAssessmentResult(null);
  };

  return (
    <div className="app">
      {currentPage === 'welcome' && (
        <WelcomePage onStart={handleStartAssessment} />
      )}
      {currentPage === 'patientSelector' && (
        <PatientSelector
          onNext={handlePatientSelected}
          onBack={handleBack}
        />
      )}
      {currentPage === 'simulationBriefing' && (
        <SimulationBriefing
          selectedPatient={selectedPatient}
          selectedWound={selectedWound}
          onStart={handleStartSimulation}
          onBack={handleBack}
        />
      )}
      {currentPage === 'upload' && (
        <WoundUpload
          onNext={handleImageUploaded}
          onBack={handleBack}
          selectedPatient={selectedPatient}
          selectedWound={selectedWound}
        />
      )}
      {currentPage === 'assessment' && (
        <Assessment
          imageFile={uploadedImage}
          patientContext={patientContext}
          selectedPatient={selectedPatient}
          selectedWound={selectedWound}
          onComplete={handleAssessmentComplete}
          onBack={handleBack}
          onStartOver={handleStartOver}
        />
      )}
    </div>
  );
};

export default App;