fullstuckdev commited on
Commit
190e47b
1 Parent(s): 7ce19a5

change page

Browse files
Files changed (1) hide show
  1. src/app/page.tsx +51 -44
src/app/page.tsx CHANGED
@@ -18,25 +18,29 @@ import MedicalInformationIcon from '@mui/icons-material/MedicalInformation'
18
  import HealthAndSafetyIcon from '@mui/icons-material/HealthAndSafety'
19
  import LocalHospitalIcon from '@mui/icons-material/LocalHospital'
20
 
21
- const exampleSymptoms = [
22
- 'Headache',
23
- 'Fever',
24
- 'Cough',
25
- 'Fatigue',
26
- 'Nausea'
 
 
27
  ]
28
 
29
- const exampleHistory = [
30
- 'Hypertension',
31
  'Diabetes',
32
- 'Asthma',
33
- 'Allergies'
 
 
34
  ]
35
 
36
  export default function Home() {
37
- const [symptoms, setSymptoms] = useState('')
38
- const [medicalHistory, setMedicalHistory] = useState('')
39
- const [recommendation, setRecommendation] = useState('')
40
  const [loading, setLoading] = useState(false)
41
 
42
  const handleSubmit = async (e: React.FormEvent) => {
@@ -49,24 +53,27 @@ export default function Home() {
49
  headers: {
50
  'Content-Type': 'application/json',
51
  },
52
- body: JSON.stringify({ symptoms, medicalHistory }),
 
 
 
53
  })
54
 
55
  const data = await response.json()
56
- setRecommendation(data.recommendation)
57
  } catch (error) {
58
- console.error('Failed to get recommendation:', error)
59
  } finally {
60
  setLoading(false)
61
  }
62
  }
63
 
64
- const addExampleSymptom = (symptom: string) => {
65
- setSymptoms(prev => prev ? `${prev}, ${symptom}` : symptom)
66
  }
67
 
68
- const addExampleHistory = (history: string) => {
69
- setMedicalHistory(prev => prev ? `${prev}, ${history}` : history)
70
  }
71
 
72
  return (
@@ -75,12 +82,12 @@ export default function Home() {
75
  <Box display="flex" alignItems="center" gap={2} mb={4}>
76
  <LocalHospitalIcon color="primary" sx={{ fontSize: 40 }} />
77
  <Typography variant="h4" component="h1" fontWeight="bold">
78
- AI Drug Recommendation System
79
  </Typography>
80
  </Box>
81
 
82
  <Alert severity="info" sx={{ mb: 4 }}>
83
- This is an AI-powered tool to assist healthcare professionals. All recommendations should be reviewed by a qualified medical practitioner.
84
  </Alert>
85
 
86
  <form onSubmit={handleSubmit}>
@@ -88,25 +95,25 @@ export default function Home() {
88
  <Box>
89
  <Typography variant="h6" display="flex" alignItems="center" gap={1} mb={2}>
90
  <MedicalInformationIcon />
91
- Symptoms
92
  </Typography>
93
  <TextField
94
  fullWidth
95
  multiline
96
  rows={4}
97
- value={symptoms}
98
- onChange={(e) => setSymptoms(e.target.value)}
99
- placeholder="Enter patient symptoms..."
100
  required
101
  />
102
  <Box mt={2}>
103
- <Typography variant="subtitle2" mb={1}>Example symptoms:</Typography>
104
  <Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
105
- {exampleSymptoms.map((symptom) => (
106
  <Chip
107
- key={symptom}
108
- label={symptom}
109
- onClick={() => addExampleSymptom(symptom)}
110
  clickable
111
  />
112
  ))}
@@ -117,25 +124,25 @@ export default function Home() {
117
  <Box>
118
  <Typography variant="h6" display="flex" alignItems="center" gap={1} mb={2}>
119
  <HealthAndSafetyIcon />
120
- Medical History
121
  </Typography>
122
  <TextField
123
  fullWidth
124
  multiline
125
  rows={4}
126
- value={medicalHistory}
127
- onChange={(e) => setMedicalHistory(e.target.value)}
128
- placeholder="Enter patient medical history..."
129
  required
130
  />
131
  <Box mt={2}>
132
- <Typography variant="subtitle2" mb={1}>Example conditions:</Typography>
133
  <Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
134
- {exampleHistory.map((history) => (
135
  <Chip
136
- key={history}
137
- label={history}
138
- onClick={() => addExampleHistory(history)}
139
  clickable
140
  />
141
  ))}
@@ -150,20 +157,20 @@ export default function Home() {
150
  disabled={loading}
151
  startIcon={loading ? <CircularProgress size={20} /> : null}
152
  >
153
- {loading ? 'Generating Recommendation...' : 'Get Recommendation'}
154
  </Button>
155
  </Stack>
156
  </form>
157
 
158
- {recommendation && (
159
  <Box mt={4}>
160
  <Divider sx={{ my: 4 }} />
161
  <Typography variant="h6" gutterBottom>
162
- Recommendation
163
  </Typography>
164
  <Paper variant="outlined" sx={{ p: 3, bgcolor: 'background.default' }}>
165
  <Typography whiteSpace="pre-wrap">
166
- {recommendation}
167
  </Typography>
168
  </Paper>
169
  </Box>
 
18
  import HealthAndSafetyIcon from '@mui/icons-material/HealthAndSafety'
19
  import LocalHospitalIcon from '@mui/icons-material/LocalHospital'
20
 
21
+ const contohGejala = [
22
+ 'Sakit Kepala',
23
+ 'Demam',
24
+ 'Batuk',
25
+ 'Kelelahan',
26
+ 'Mual',
27
+ 'Pilek',
28
+ 'Nyeri Otot'
29
  ]
30
 
31
+ const contohRiwayat = [
32
+ 'Hipertensi',
33
  'Diabetes',
34
+ 'Asma',
35
+ 'Alergi',
36
+ 'Jantung',
37
+ 'Maag'
38
  ]
39
 
40
  export default function Home() {
41
+ const [gejala, setGejala] = useState('')
42
+ const [riwayatMedis, setRiwayatMedis] = useState('')
43
+ const [rekomendasi, setRekomendasi] = useState('')
44
  const [loading, setLoading] = useState(false)
45
 
46
  const handleSubmit = async (e: React.FormEvent) => {
 
53
  headers: {
54
  'Content-Type': 'application/json',
55
  },
56
+ body: JSON.stringify({
57
+ symptoms: gejala,
58
+ medicalHistory: riwayatMedis
59
+ }),
60
  })
61
 
62
  const data = await response.json()
63
+ setRekomendasi(data.recommendation)
64
  } catch (error) {
65
+ console.error('Gagal mendapatkan rekomendasi:', error)
66
  } finally {
67
  setLoading(false)
68
  }
69
  }
70
 
71
+ const tambahGejala = (gejala: string) => {
72
+ setGejala(prev => prev ? `${prev}, ${gejala}` : gejala)
73
  }
74
 
75
+ const tambahRiwayat = (riwayat: string) => {
76
+ setRiwayatMedis(prev => prev ? `${prev}, ${riwayat}` : riwayat)
77
  }
78
 
79
  return (
 
82
  <Box display="flex" alignItems="center" gap={2} mb={4}>
83
  <LocalHospitalIcon color="primary" sx={{ fontSize: 40 }} />
84
  <Typography variant="h4" component="h1" fontWeight="bold">
85
+ Sistem Rekomendasi Obat
86
  </Typography>
87
  </Box>
88
 
89
  <Alert severity="info" sx={{ mb: 4 }}>
90
+ Ini adalah alat berbasis AI untuk membantu tenaga kesehatan. Semua rekomendasi harus ditinjau oleh praktisi medis yang berkualifikasi.
91
  </Alert>
92
 
93
  <form onSubmit={handleSubmit}>
 
95
  <Box>
96
  <Typography variant="h6" display="flex" alignItems="center" gap={1} mb={2}>
97
  <MedicalInformationIcon />
98
+ Gejala Pasien
99
  </Typography>
100
  <TextField
101
  fullWidth
102
  multiline
103
  rows={4}
104
+ value={gejala}
105
+ onChange={(e) => setGejala(e.target.value)}
106
+ placeholder="Masukkan gejala pasien..."
107
  required
108
  />
109
  <Box mt={2}>
110
+ <Typography variant="subtitle2" mb={1}>Contoh gejala:</Typography>
111
  <Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
112
+ {contohGejala.map((gejala) => (
113
  <Chip
114
+ key={gejala}
115
+ label={gejala}
116
+ onClick={() => tambahGejala(gejala)}
117
  clickable
118
  />
119
  ))}
 
124
  <Box>
125
  <Typography variant="h6" display="flex" alignItems="center" gap={1} mb={2}>
126
  <HealthAndSafetyIcon />
127
+ Riwayat Medis
128
  </Typography>
129
  <TextField
130
  fullWidth
131
  multiline
132
  rows={4}
133
+ value={riwayatMedis}
134
+ onChange={(e) => setRiwayatMedis(e.target.value)}
135
+ placeholder="Masukkan riwayat medis pasien..."
136
  required
137
  />
138
  <Box mt={2}>
139
+ <Typography variant="subtitle2" mb={1}>Contoh kondisi:</Typography>
140
  <Stack direction="row" spacing={1} flexWrap="wrap" gap={1}>
141
+ {contohRiwayat.map((riwayat) => (
142
  <Chip
143
+ key={riwayat}
144
+ label={riwayat}
145
+ onClick={() => tambahRiwayat(riwayat)}
146
  clickable
147
  />
148
  ))}
 
157
  disabled={loading}
158
  startIcon={loading ? <CircularProgress size={20} /> : null}
159
  >
160
+ {loading ? 'Menghasilkan Rekomendasi...' : 'Dapatkan Rekomendasi'}
161
  </Button>
162
  </Stack>
163
  </form>
164
 
165
+ {rekomendasi && (
166
  <Box mt={4}>
167
  <Divider sx={{ my: 4 }} />
168
  <Typography variant="h6" gutterBottom>
169
+ Rekomendasi Pengobatan
170
  </Typography>
171
  <Paper variant="outlined" sx={{ p: 3, bgcolor: 'background.default' }}>
172
  <Typography whiteSpace="pre-wrap">
173
+ {rekomendasi}
174
  </Typography>
175
  </Paper>
176
  </Box>