Skip to main content

PredictSpeciality

The PredictSpeciality class 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: (List of 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 like getArticlesList to fetch related data, 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
fun handlePredictedSpecialty(predictedSpecialty: PredictSpecialty) {
if (predictedSpecialty.specialtyId != null) {
fetchArticlesForSpecialty(predictedSpecialty.specialtyId)
} else {
println("No specialty predicted")
}
}

// Function to fetch articles using the specialtyId
fun fetchArticlesForSpecialty(specialtyId: Int) {
getArticlesList(listOf(specialtyId), 1, 10, object : ApiCallback<List<Article>> {
override fun onSuccess(result: List<Article>) {
if (result.isNotEmpty()) {
val firstArticle = result[0]
println("Title: ${firstArticle.title}")
println("Body: ${firstArticle.body}")
} else {
println("No articles found")
}
}

override fun onRequestError(errorMessage: String?) {
println("Error fetching articles: $errorMessage")
}
})
}

// Example of handling a predicted specialty and fetching related articles
val predictedSpecialty = PredictSpecialty(specialtyId = 2, subCategories = listOf())
handlePredictedSpecialty(predictedSpecialty)