Overview
The Professional Management feature allows administrators to register, update, and manage healthcare professionals in the Clínica Vitalis system. Each professional is associated with a specialty and can have customized work schedules.Data Model
Professionals are stored with the following information:Professional States
Professionals can have one of three states:- Activo/a (Active): Professional is available for appointments
- Inactivo/a (Inactive): Professional is not currently working
- Licencia (On Leave): Professional is temporarily unavailable
Key Features
Create Professional
Administrators can register new professionals in the system with complete validation:Provide Basic Information
Enter the professional’s name, surname, DNI (minimum 7 digits), birthdate, gender, and address.
Add Contact Details
Provide phone number (10-20 characters, numbers/spaces/dashes only) and valid email address.
Assign Specialty
Select an existing specialty from the system. The specialty must exist and be active.
DNI must be unique in the system. The system will reject duplicate DNI numbers.
Validation Rules
The system enforces strict validation rules frombackend/routes/professionals.ts:29-52:
Search and Filter Professionals
The system provides powerful search and filtering capabilities: Search by:- Name (partial match)
- Surname (partial match)
- DNI (partial match)
- Gender
- Specialty ID
- Professional state (active/inactive/license)
View Professional Details
When retrieving professionals, the system includes:- Complete professional information
- Associated specialty name
- Work schedules (days and time ranges)
- Count of active professionals in the system
Update Professional Information
Administrators can update all professional fields including state changes:Validate Changes
The system re-validates all fields including DNI uniqueness (excluding the current professional).
API Endpoints
GET /api/professionals
Retrieve all professionals with optional filters.
Query Parameters:
search- Search term for name, surname, or DNIgender- Filter by genderspecialityID- Filter by specialtystate- Filter by professional state
GET /api/professionals/:id
Retrieve a specific professional by ID.
POST /api/professionals
Create a new professional (Admin only).
Required Fields:
- name, surname, dni, birthdate, gender, address, phone, email, specialityID
PATCH /api/professionals/:id
Update a professional (Admin only).
Required Fields:
- All fields from POST plus
state
Security
All professional management operations require JWT authentication. Create and update operations are restricted to administrators only.
Database Relationships
Professionals are related to:- Specialties (Many-to-One): Each professional belongs to one specialty
- Work Schedules (One-to-Many): Each professional can have multiple work schedules
- Appointments (One-to-Many): Each professional can have multiple appointments
Best Practices
- Always validate specialty exists before assigning it to a professional
- Check DNI uniqueness to prevent duplicate registrations
- Use state management to handle professional availability rather than deleting records
- Include work schedules when displaying professional information to users
- Filter by active state when showing available professionals for appointment booking
