PredictSpeciality
The PredictSpeciality
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: (Array of SubCategory?) - A list of related subcategories for the predicted specialty.
Example Usage
Using Predicted Specialty to Retrieve Related Information Using getArticlesList Function
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 getArticlesList
and print the title and body of the first article.
// 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) {
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)")
}
}
}
// Example of handling a predicted specialty and fetching related articles
let predictedSpecialty = PredictSpecialty(specialtyID: 2, subCategories: [])
handlePredictedSpecialty(predictedSpecialty: predictedSpecialty)