Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RubenDarioGuerreroNeira/Ecosistema-IA-Colombia/llms.txt

Use this file to discover all available pages before exploring further.

Salud IA Bot can respond to data queries not just with text, but with chart images sent directly into the Telegram conversation. The visualization pipeline is built on ChartService, which constructs a Chart.js configuration object, serializes it, and generates a QuickChart URL. The bot then calls ctx.replyWithPhoto(url) to deliver the PNG image inline — no file upload, no external app required.
Chart images are generated on-the-fly by QuickChart’s public API. Default dimensions are 500x300 pixels in PNG format. The horizontal bar chart helper overrides these to 600x350 to accommodate longer category labels.

How the chart system works

ChartService acts as a thin adapter between the bot’s analytics services and the QuickChart rendering API. It exposes one core method and four chart-type helpers:
generateChartUrl(
  config: any,
  options: { width?: number; height?: number; format?: string } = {},
): string

generateBarChart(labels: string[], data: number[], title: string): string
generatePieChart(labels: string[], data: number[], title: string): string
generateHorizontalBarChart(labels: string[], data: number[], title: string): string
generateLineChart(labels: string[], data: number[], title: string): string
generateChartUrl accepts any valid Chart.js config object, serializes it with JSON.stringify, encodes it with encodeURIComponent, and appends it to the QuickChart base URL alongside the width, height, and format parameters:
https://quickchart.io/chart?w=500&h=300&f=png&c=<encoded-config>
The four chart-type helpers build the Chart.js config internally and delegate to generateChartUrl. The generateHorizontalBarChart helper overrides the default dimensions to w=600&h=350.

Supported chart types

Bar chart

Vertical bar chart (type: 'bar') with data labels above each bar. Used for rankings, event counts, and vaccination coverage comparisons. Fill color: rgba(54, 162, 235, 0.5).

Doughnut chart

Doughnut chart (type: 'doughnut') with percentage labels inside each segment. Uses a six-color palette. Used for gender distribution and proportional breakdowns. Called via generatePieChart.

Horizontal bar chart

Horizontal bars (type: 'horizontalBar') with percentage suffixes on axis ticks and data labels. Supports up to 18 distinct colors. Rendered at 600x350. Used for vaccination coverage by department.

Line chart

Line chart (type: 'line') with tension: 0.1 for smooth curves. Used for disease trends and time-series visualization.

Air quality charts

Air quality data is drawn from the AirQualityService and covers municipalities across Colombia including Medellin, Cali, Bogota, Andes, and others in Antioquia and Valle del Cauca.
"Graficar calidad del aire en Medellín"
-> Bar chart of air quality indicators (PM2.5, PM10, CO, NO2, O3, etc.) for Medellin

"Muéstrame la calidad del aire en Andes"
-> Bar chart showing all monitored pollutants for the municipality of Andes
Each chart label corresponds to an environmental indicator; the data values reflect the most recent readings available in the local database.

Mental health charts

Mental health charts visualize the CIE-10 diagnostic distribution loaded from Salud_Mental.xml.
"Graficar diagnósticos de salud mental"
-> Bar chart of top mental health diagnoses by total case count

"Muéstrame un gráfico de depresión y ansiedad"
-> Comparative chart showing case totals for DEPRESION and ANSIEDAD side by side
MentalHealthService.getTopDiagnoses(limit) provides the labels and values; ChartService.generateBarChart renders the image.

SIVIGILA / public health charts

Three chart variants are available for public health data:
"Graficar eventos de salud pública"
"Muéstrame las enfermedades más frecuentes en el país"
-> Bar chart of the top SIVIGILA events by total case count
Gender charts use SaludPublicaService.compararSexo(evento) to get the femenino/masculino split, then pass the two values and percentage labels to generatePieChart (which renders a doughnut).

Vaccination charts

"Graficar vacunas en Antioquia"
-> Horizontal bar chart of PAI vaccination coverage (%) by vaccine type
   for the department of Antioquia
VaccinationService.getCoverageByDepartment(departamento) returns the coverage records. The horizontal bar chart format is used because vaccine names can be long and benefit from the extra width.

Cali services chart

"Muéstrame un gráfico de los servicios en Cali"
"Graficar servicios de salud en Cali"
-> Bar chart of the top service categories offered by providers
   in the Red de Salud del Centro ESE
CaliHealthService.getStatsByCategory() returns label/data pairs for the top six service groups by provider count, which are then passed to ChartService.generateBarChart.

Full chart generation flow

1

Intent detection

BotUpdate.onText detects chart-related keywords from GRAPHIC_KEYWORDS: graficar, grafico, graficar, visualizar, dibujar, mostrar grafico, puedes graficar, and similar variants.
2

Data retrieval

The appropriate analytics service is called to obtain labels and numeric values (e.g. event names + case counts, indicator names + pollutant levels).
3

Chart config assembly

A Chart.js config object is assembled by the relevant ChartService helper (generateBarChart, generatePieChart, generateHorizontalBarChart, or generateLineChart) with title, dataset colors, and plugin options for data labels.
4

URL generation

generateChartUrl(config, options) serializes and URL-encodes the config, producing a https://quickchart.io/chart?w=...&h=...&f=...&c=... URL.
5

Image delivery

ctx.replyWithPhoto({ url: chartUrl }) sends the PNG image directly into the Telegram chat. No image is stored on the server.

Build docs developers (and LLMs) love