Skip to main content

Get Wellness Heatmap

Generate a wellness heatmap for a hospital showing department-level aggregated wellbeing metrics. The heatmap provides visual representation of employee wellness across different departments with color-coded indicators.
GET /api/diagnostic/wellness-heatmap/:hospitalId

Authentication

Requires authentication and admin or user role authorization.

Path Parameters

hospitalId
string
required
Unique identifier of the hospital

Query Parameters

period
string
default:"weekly"
Time period for aggregation. Possible values:
  • daily - Current day
  • weekly - Current week (default)
  • monthly - Current month

Request Example

curl -X GET "https://api.cuido.com/api/diagnostic/wellness-heatmap/hospital_001?period=weekly" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

success
boolean
Indicates if the request was successful
message
string
Response message
data
object
Response data object

Response Example

{
  "success": true,
  "message": "Mapa de calor generado exitosamente",
  "data": {
    "heatmap": {
      "heatmapData": [
        {
          "x": 0,
          "y": 0,
          "value": 72,
          "area": "urgencias",
          "employeeCount": 45,
          "color": "#F59E0B",
          "metrics": {
            "averageMood": 3.6,
            "riskDistribution": {
              "bajo": 18,
              "medio": 22,
              "alto": 5
            }
          }
        },
        {
          "x": 1,
          "y": 0,
          "value": 85,
          "area": "hospitalizacion",
          "employeeCount": 62,
          "color": "#10B981",
          "metrics": {
            "averageMood": 4.2,
            "riskDistribution": {
              "bajo": 48,
              "medio": 12,
              "alto": 2
            }
          }
        },
        {
          "x": 0,
          "y": 1,
          "value": 68,
          "area": "consulta_externa",
          "employeeCount": 28,
          "color": "#F59E0B",
          "metrics": {
            "averageMood": 3.4,
            "riskDistribution": {
              "bajo": 12,
              "medio": 14,
              "alto": 2
            }
          }
        },
        {
          "x": 1,
          "y": 1,
          "value": 91,
          "area": "administracion",
          "employeeCount": 15,
          "color": "#10B981",
          "metrics": {
            "averageMood": 4.5,
            "riskDistribution": {
              "bajo": 14,
              "medio": 1,
              "alto": 0
            }
          }
        }
      ],
      "summary": {
        "totalEmployees": 150,
        "averageWellness": 79,
        "criticalAreas": []
      },
      "generatedAt": "2026-03-05T10:30:00.000Z"
    }
  }
}

How Wellness Value is Calculated

The wellness value (0-100) for each department is calculated based on average employee mood scores:
wellnessValue = (averageMood / 5) * 100
Where averageMood is the average of all employees’ currentMoodScore in that department (scale 1-5). See implementation in diagnosticService.js:304-389.

Color Coding

The heatmap uses a color-coded system for quick visual assessment:
  • Green (#10B981): Wellness ≥ 80 - Healthy department
  • Yellow (#F59E0B): Wellness 60-79 - Moderate attention needed
  • Red (#EF4444): Wellness 40-59 - Requires intervention
  • Dark Red (#DC2626): Wellness < 40 - Critical state
Departments with wellness scores below 40 appear in criticalAreas and should receive immediate attention from hospital administration.

Department Aggregation

The heatmap aggregates data from multiple sources:
  1. Employee Wellness Metrics - Current mood, workload, and satisfaction from employee records
  2. Survey Data - Recent quick survey responses within the specified period
  3. Risk Distribution - Count of employees at each risk level (bajo, medio, alto)
  4. Participation Rates - Percentage of employees who completed recent surveys

Data Persistence

Generated heatmap data is saved to the WellnessMetric collection for historical tracking and trend analysis. This allows administrators to:
  • Compare wellness trends over time
  • Identify seasonal patterns
  • Track the effectiveness of wellness interventions
  • Generate reports for stakeholders
See model definition in models/WellnessMetric.js.

Grid Layout

The heatmap uses a 2x2 grid layout for standard hospital departments:
PositionDepartment
(0,0)urgencias (Emergency)
(1,0)hospitalizacion (Inpatient)
(0,1)consulta_externa (Outpatient)
(1,1)administracion (Administration)
The grid layout can be customized in the frontend to support different hospital structures or additional departments.

Use Cases

  • Executive Dashboards: Quick overview of organizational wellness
  • Department Managers: Identify areas needing support
  • HR Teams: Prioritize wellness interventions
  • Trend Analysis: Track wellness changes over time
  • Resource Allocation: Direct resources to departments with greatest need

Build docs developers (and LLMs) love