Skip to main content

PredictSpeciality

The PredictSpeciality interface represents specialties predicted based on the analysis of a consultation using a machine learning model. It includes a specialty_id and its related subCategories.

Fields

  • specialty_id: (number?) - 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 specialty_id 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 specialty_id 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
function handlePredictedSpecialty(predictedSpecialty: PredictSpeciality) {
if (predictedSpecialty.specialty_id) {
// Fetch articles based on the predicted specialty ID
fetchArticlesForSpecialty(predictedSpecialty.specialty_id);
} else {
console.log("No specialty predicted");
}
}

// Function to fetch articles using the specialty_id
async function fetchArticlesForSpecialty(specialtyID: number) {
const articles = await getArticlesList([specialtyID.toString()]);
if (articles && articles.data.length > 0) {
const firstArticle = articles.data[0];
console.log("Title: " + firstArticle.title);
console.log("Body: " + firstArticle.body);
} else {
console.log("No articles found");
}
}

// Example of handling a predicted specialty and fetching related articles
const predictedSpecialty: PredictSpeciality = {
specialty_id: 2,
subCategories: [],
};
handlePredictedSpecialty(predictedSpecialty);