Predict Specialty
The PredictSpecialty class represents specialties predicted based on the analysis of a consultation using a machine learning model. It includes a specialtyId and its related subCategories.
getPredictSpecialty Function
The getPredictSpecialty function fetches a list of predicted specialties for a consultation.
Parameters
- consultationId: (int) - The ID of the consultation.
Returns
Future<List<PredictSpecialty>>: A future that resolves with a list of predicted specialties.
Fields
- specialtyId: (int) - The ID of the predicted specialty.
- subCategories: (List of SubCategory) - A list of related subcategories for the predicted specialty.
Example Usage
Fetching and Using Predicted Specialties
ApiService apiService = ApiService();
Future<void> handleConsultationAI(int consultationId) async {
try {
final specialties = await apiService.getPredictSpecialty(consultationId);
if (specialties.isNotEmpty) {
final firstSpecialty = specialties[0];
print(\"Predicted Specialty ID: ${firstSpecialty.specialtyId}\");
// Fetch articles for these subcategories
final subCategoryIds = firstSpecialty.subCategories.map((s) => s.subCategoryId).toList();
final articles = await apiService.getArticlesList(subcategoryIds: subCategoryIds);
print(\"Found ${articles.length} related articles.\");
}
} catch (e) {
print(\"Error: $e\");
}
}