@@ -83,48 +83,35 @@ const SymptomChecker = () => {
8383
8484 try {
8585 const symptomNames = selectedSymptoms . map ( s => s . name ) ;
86-
8786 const predictions = await predictDisease ( symptomNames ) ;
8887
89- if ( predictions . length > 0 ) {
90- const topDisease = predictions [ 0 ] ;
91-
92- const recommendedDoctors = getDoctorsBySpecialty ( topDisease . specialist || "General Physician" ) ;
93-
94- const precautions = [
95- "Consult with a healthcare professional" ,
96- "Get adequate rest" ,
97- "Stay hydrated" ,
98- "Monitor your symptoms" ,
99- "Follow prescribed medications if any"
100- ] ;
88+ if ( predictions && predictions . length > 0 ) {
89+ const recommendedDoctors = getDoctorsBySpecialty ( predictions [ 0 ] . specialist ) ;
10190
102- const diet = [
103- "Maintain a balanced diet" ,
104- "Include fresh fruits and vegetables" ,
105- "Stay hydrated with water" ,
106- "Avoid processed foods" ,
107- "Consider supplements as recommended by your doctor"
108- ] ;
109-
11091 setResults ( {
11192 diseases : predictions ,
112- precautions,
113- diet,
93+ precautions : [
94+ "Consult with a healthcare professional" ,
95+ "Get adequate rest" ,
96+ "Stay hydrated" ,
97+ "Monitor your symptoms" ,
98+ "Follow prescribed medications if any"
99+ ] ,
100+ diet : [
101+ "Maintain a balanced diet" ,
102+ "Include fresh fruits and vegetables" ,
103+ "Stay hydrated with water" ,
104+ "Avoid processed foods" ,
105+ "Consider supplements as recommended by your doctor"
106+ ] ,
114107 doctors : recommendedDoctors
115108 } ) ;
116- } else {
117- toast ( {
118- title : "Analysis Inconclusive" ,
119- description : "We couldn't determine a likely condition from your symptoms. Please consult a healthcare professional." ,
120- variant : "destructive" ,
121- } ) ;
122109 }
123110 } catch ( error ) {
124- console . error ( ' Error during analysis:' , error ) ;
111+ const errorMessage = error instanceof Error ? error . message : "An error occurred while analyzing your symptoms" ;
125112 toast ( {
126- title : "Error During Analysis" ,
127- description : "An error occurred while analyzing your symptoms. Please try again." ,
113+ title : "Analysis Error " ,
114+ description : errorMessage ,
128115 variant : "destructive" ,
129116 } ) ;
130117 } finally {
0 commit comments