Skip to main content

PredictSpecialty

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.

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.

import com.altibbi.telehealth.ApiService
import com.altibbi.telehealth.model.PredictSpecialty
import com.altibbi.telehealth.model.Article
import com.altibbi.telehealth.ApiCallback

// Function to handle a predicted specialty and fetch related articles
fun handlePredictedSpecialty(predictedSpecialty: PredictSpecialty) {
fetchArticlesForSpecialty(predictedSpecialty.specialtyId)
}

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

override fun onFailure(error: String?) {
println("Error fetching articles: $error")
}

override fun onRequestError(error: String?) {
println("Request error: $error")
}
}
)
}

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