Skip to main content

Process Quick Survey

Submit a quick employee wellness survey that evaluates mood, workload, team support, and job satisfaction. The system automatically calculates risk scores, awards gamification points, and generates alerts when high-risk patterns are detected.
Employees earn 5 points for completing each survey. Completing surveys builds streaks and unlocks badges.
POST /api/diagnostic/survey/quick

Authentication

Requires authentication via JWT token in the Authorization header.

Request Body

employeeId
string
required
The unique identifier of the employee completing the survey
responses
object
required
Survey responses object containing wellness metrics

Request Example

{
  "employeeId": "507f1f77bcf86cd799439011",
  "responses": {
    "moodToday": "bien",
    "workloadLevel": 4,
    "teamSupport": 3,
    "jobSatisfaction": 7,
    "freeText": "La carga de trabajo ha aumentado pero el equipo es muy colaborativo"
  }
}

Response

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

Response Example

{
  "success": true,
  "message": "Encuesta procesada exitosamente",
  "data": {
    "survey": {
      "_id": "507f1f77bcf86cd799439012",
      "employeeId": "507f1f77bcf86cd799439011",
      "responses": {
        "moodToday": "bien",
        "workloadLevel": 4,
        "teamSupport": 3,
        "jobSatisfaction": 7,
        "freeText": "La carga de trabajo ha aumentado pero el equipo es muy colaborativo"
      },
      "analysis": {
        "riskScore": 42,
        "riskLevel": "medio",
        "factors": {
          "moodToday": 0.7,
          "workloadLevel": 0.4,
          "teamSupport": 0.6,
          "jobSatisfaction": 0.7
        },
        "adjustments": 1.15
      },
      "pointsEarned": 5,
      "completedAt": "2026-03-05T10:30:00.000Z"
    },
    "pointsEarned": 5,
    "riskLevel": "medio"
  }
}

Risk Score Calculation

The risk score is calculated using a weighted formula that considers multiple factors:

Weighting System

  • Mood (30%): Emotional state impacts overall wellbeing
  • Workload (25%): High workload is a primary burnout indicator
  • Team Support (20%): Social support buffers against stress
  • Job Satisfaction (25%): Overall job satisfaction

Adjustment Factors

Risk scores are adjusted based on employee characteristics in diagnosticService.js:206-239:
  • Tenure: New employees (less than 6 months) have 1.2x risk multiplier
  • Department: High-stress departments (ER, ICU) add 1.15x multiplier
  • Shift: Night shift workers have 1.1x multiplier
  • History: Employees with recent high-risk surveys get 1.2x multiplier

Risk Levels

  • Bajo (Low): Risk score < 30
  • Medio (Medium): Risk score 30-69
  • Alto (High): Risk score ≥ 70
When risk level is alto, the system automatically generates a SmartAlert for supervisor intervention. See diagnosticService.js:392-434.

Automated Actions

When a survey is processed, the system automatically:
  1. Updates Employee Metrics - Refreshes wellnessMetrics on the employee record
  2. Awards Gamification Points - Adds 5 points and updates streaks/levels
  3. Checks for Badges - Awards badges for participation streaks (7, 10, 15, 30 days)
  4. Performs AI Analysis - If freeText is provided, Claude analyzes sentiment and generates recommendations
  5. Generates Alerts - Creates SmartAlerts for high-risk employees or concerning patterns

AI Sentiment Analysis

When free text is provided, Claude (Sonnet 3) analyzes the comment to extract:
  • Sentiment classification (very positive to very negative)
  • Emotional score (-1 to 1)
  • Risk indicators and keywords
  • Turnover risk score (0-100)
  • Personalized recommendations with priority levels
See implementation in diagnosticService.js:62-150.

Build docs developers (and LLMs) love