Skip to main content

Predict Speciality

The PredictSpecialty struct represents specialties predicted based on the analysis of a consultation using a machine learning model. It includes a specialtyID and its related subCategories.

Fields

  • specialtyID: (Int?) - The ID of the predicted specialty.
  • subCategories: ([SubCategory]?) - A list of related subcategories for the predicted specialty.

Example Usage

Once a specialty has been predicted from a consultation analysis, the specialtyID can be passed to other functions to fetch related data getArticlesList, such as articles corresponding to the predicted specialty.

Here’s an example showing how to use the predicted specialtyID to fetch related articles using ApiService.getArticlesList and print the title and body of the first article.

import AltibbiTelehealth

// Function to handle a predicted specialty and fetch related articles
func handlePredictedSpecialty(predictedSpecialty: PredictSpecialty) {
guard let specialtyID = predictedSpecialty.specialtyID else {
print("No specialty predicted")
return
}

// Fetch articles based on the predicted specialty ID
fetchArticlesForSpecialty(specialtyID: specialtyID)
}

// Function to fetch articles using the specialtyID
func fetchArticlesForSpecialty(specialtyID: Int) {
ApiService.getArticlesList(subcategoryIds: [specialtyID], page: 1, perPage: 10) { articles, data, error in
if let articles = articles, !articles.isEmpty {
let firstArticle = articles[0]
print("Title: \(firstArticle.title)")
print("Body: \(firstArticle.body)")
} else if let error = error {
print("Error fetching articles: \(error.localizedDescription)")
}
}
}