false, 'error' => 'Please enter symptoms first to get a diagnosis suggestion.']); exit; } $userPrompt = "Based on the following symptoms, suggest a list of potential differential diagnoses. Provide the response in a clear HTML list format.\n\nSymptoms:\n" . strip_tags($symptoms); break; case 'treatment_plan': default: if (empty($symptoms) && empty($diagnosis)) { echo json_encode(['success' => false, 'error' => 'No symptoms or diagnosis provided.']); exit; } $userPrompt = "Based on the following symptoms and diagnosis, please generate a concise treatment plan and medical report for the patient.\n\n"; if (!empty($symptoms)) { $userPrompt .= "Symptoms:\n" . strip_tags($symptoms) . "\n\n"; } if (!empty($diagnosis)) { $userPrompt .= "Diagnosis:\n" . strip_tags($diagnosis) . "\n\n"; } $userPrompt .= "Please provide the report in a clear, professional format using HTML tags (like