Overview
The Social Works Management feature handles insurance providers (obras sociales) in the Clínica Vitalis system. Social works represent health insurance organizations that provide coverage for patients, and each patient must be affiliated with a social work for billing and coverage purposes.Data Model
Social works are structured with comprehensive information:Social Work States
- Activa (Active): Insurance provider is currently accepted by the clinic
- Inactiva (Inactive): Insurance provider is no longer accepted for new patients
Key Features
Create Social Work
Administrators can register new insurance providers:Validate Information
System validates:
- Name uniqueness
- Phone number format (numbers, spaces, dashes only)
- All required fields are present
Social work names must be unique to prevent duplicate insurance provider registrations.
Validation Rules
Strict validation ensures data quality frombackend/routes/socialsWorks.ts:29-43:
Database Constraints
The model enforces important business rules:View Social Works
Social works can be retrieved:- All social works: Complete list including active and inactive providers
- By ID: Specific social work details
- With Patients: When viewing patients, their social work information is included
Update Social Work
Administrators can modify insurance provider information:Validate Changes
System validates name uniqueness (excluding current record) and all required fields.
When updating a social work’s name, the system ensures the new name doesn’t conflict with other social works.
Patient Integration
Social works are directly linked to patients:Assignment
Each patient must be affiliated with a social work:Validation
Before assigning a patient to a social work, the system validates:- Social work exists in the database
- Social work ID is valid
existSocialWorkById custom validator in patient routes.
API Endpoints
GET /api/socialsWorks
Retrieve all social works.
Response:
GET /api/socialsWorks/:id
Retrieve a specific social work by ID.
Response:
POST /api/socialsWorks
Create a new social work (Admin only).
Required Fields:
- name, address, phone, webpage
PATCH /api/socialsWorks/:id
Update a social work (Admin only).
Required Fields:
- name, state, address, phone, webpage
State Management
Inactivating Social Works
When the clinic stops accepting an insurance provider:- Update the social work state to “Inactive”
- Existing patients keep their affiliation
- New patients cannot be registered with inactive social works
- Contact information remains accessible for billing and records
Never delete social works that have patients assigned to them. Use the state field to mark them as inactive.
Reactivating Social Works
If the clinic resumes accepting an insurance provider:- Update the state back to “Active”
- The social work becomes available for new patient registrations
Phone Number Format
Phone numbers must meet specific criteria:- Length: Between 10 and 20 characters
- Allowed characters: Numbers, spaces, dashes (-), and plus sign (+)
- Examples:
- Valid: “+54 11 4567-8900”, “011-4567-8900”, “01145678900”
- Invalid: “123” (too short), “phone” (contains letters)
Use Cases
Adding New Insurance Provider
Updating Contact Information
When an insurance provider changes their contact details:- Locate the social work in the system
- Update the address, phone, or webpage as needed
- Save changes for future reference
Filtering Patients by Insurance
Staff can filter patients by their insurance provider:- Billing purposes
- Insurance-specific reporting
- Coverage verification
Common Social Works (Argentina)
Typical insurance providers in Argentina:- OSDE - Organización de Servicios Directos Empresarios
- Swiss Medical
- OSECAC - Obra Social de Empleados de Comercio
- IOMA - Instituto de Obra Médico Asistencial
- PAMI - Programa de Atención Médica Integral
- Medicus
- Galeno
- OSPE - Obra Social del Personal de la Edificación
- OSDEPYM - Obra Social de Empresarios, Profesionales y Monotributistas
Security
All social work operations require JWT authentication. Create and update operations are restricted to administrators only.
- GET requests: Authenticated users only
- POST/PATCH requests: Administrator role required
Database Relationships
Social works connect to:- Patients (One-to-Many): Each social work can have multiple affiliated patients
- Appointments (Indirectly): Through patients, appointments are linked to insurance providers
Reporting and Billing
Social work information is essential for:- Patient affiliation tracking
- Insurance billing and claims
- Coverage verification
- Patient distribution by insurance provider
- Insurance provider contact for authorizations
Best Practices
- Keep contact information updated for effective communication with insurance providers
- Validate insurance provider exists and is active before registering patients
- Use consistent naming for insurance providers (official names)
- Use state management instead of deleting social works
- Maintain complete contact information including phone and website
- Filter by active state when showing options for new patient registration
- Document insurance agreements and update states when contracts change
- Regularly review inactive social works for potential reactivation
- Keep website URLs current for easy reference to coverage information
