Skip to main content
PATCH
/
socials_works
/
:id
Update Social Work
curl --request PATCH \
  --url https://api.example.com/socials_works/:id \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "state": "<string>",
  "address": "<string>",
  "phone": "<string>",
  "webpage": "<string>"
}
'
{
  "socialWork": {
    "id": 1,
    "name": "OSDE",
    "state": "Inactiva",
    "address": "Av. Leandro N. Alem 1067, CABA",
    "phone": "+54 11 4310-6666",
    "webpage": "https://www.osde.com.ar"
  }
}
Updates an existing social work (health insurance provider) in the system.

Authentication

Requires a valid JWT token in the Authorization header and admin privileges.
Authorization: Bearer {token}
This endpoint requires admin role. Non-admin users will receive a 403 Forbidden error.

Path Parameters

id
number
required
The unique identifier of the social work to update. Must be a numeric value.

Request Body

name
string
required
Name of the social work (health insurance provider).Validation:
  • Cannot be empty
  • Must be unique (unless it’s the current name of this social work)
Example: "OSDE"
state
string
required
Current operational state of the social work.Validation:
  • Cannot be empty
  • Must be one of the allowed values
Allowed values:
  • "Activa" - Active social work
  • "Inactiva" - Inactive social work
Example: "Activa"
address
string
required
Physical address of the social work office.Validation:
  • Cannot be empty
Example: "Av. Leandro N. Alem 1067, CABA"
phone
string
required
Contact phone number for the social work.Validation:
  • Cannot be empty
  • Must be between 10 and 20 characters
  • Can only contain numbers, spaces, hyphens, and plus signs
  • Pattern: /^[0-9\s\-\+]*$/
Examples:
  • "+54 11 4310-5555"
  • "0800-444-1200"
  • "11 5777 7777"
webpage
string
required
Website URL of the social work.Validation:
  • Cannot be empty
Example: "https://www.osde.com.ar"

Response

socialWork
object
The updated social work object with all current values
{
  "socialWork": {
    "id": 1,
    "name": "OSDE",
    "state": "Inactiva",
    "address": "Av. Leandro N. Alem 1067, CABA",
    "phone": "+54 11 4310-6666",
    "webpage": "https://www.osde.com.ar"
  }
}

Code Examples

const token = 'your-admin-jwt-token';
const socialWorkId = 1;

const updates = {
  name: 'OSDE',
  state: 'Inactiva',
  address: 'Av. Leandro N. Alem 1067, CABA',
  phone: '+54 11 4310-6666',
  webpage: 'https://www.osde.com.ar'
};

const response = await fetch(`https://api.clinicavitalis.com/socials_works/${socialWorkId}`, {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(updates)
});

const data = await response.json();
console.log(data.socialWork);

Validation Rules

ID Validation

  • Must be provided in the URL path
  • Must be a numeric value
  • Must correspond to an existing social work in the database

Name Validation

  • Must be provided (not empty)
  • Must be unique across all social works
  • Exception: Can keep the same name if not changing it
  • Database will enforce uniqueness constraint

State Validation

  • Must be provided (not empty)
  • Must be exactly one of:
    • "Activa" - Social work is active and can be used
    • "Inactiva" - Social work is inactive
  • Case-sensitive validation

Phone Validation

  • Length: Between 10 and 20 characters
  • Format: Can only contain:
    • Numbers (0-9)
    • Spaces
    • Hyphens (-)
    • Plus sign (+)
  • Valid examples:
    • "+54 11 4310-5555"
    • "0800-444-1200"
    • "11 5777 7777"
    • "+54-11-4310-5555"
  • Invalid examples:
    • "123" (too short)
    • "(011) 4310-5555" (parentheses not allowed)
    • "tel:1234567890" (letters not allowed)

Address & Webpage

  • Both fields are required and cannot be empty
  • No format restrictions beyond being non-empty strings

State Management

Unlike the create endpoint, the update endpoint requires the state field:
// Change social work to inactive
const updates = {
  name: 'OSDE',
  state: 'Inactiva',  // Changed from 'Activa'
  address: 'Av. Leandro N. Alem 1067, CABA',
  phone: '+54 11 4310-5555',
  webpage: 'https://www.osde.com.ar'
};
State values:
  • "Activa" - The social work is operational and can be assigned to patients
  • "Inactiva" - The social work is disabled and should not be used for new assignments

Common Use Cases

Update Contact Information

Change phone number or address when the social work updates their contact details:
const updates = {
  name: 'OSDE',
  state: 'Activa',
  address: 'Nueva Dirección 123, CABA',  // Updated
  phone: '+54 11 9999-8888',  // Updated
  webpage: 'https://www.osde.com.ar'
};

Deactivate Social Work

Mark a social work as inactive when they no longer provide services:
const updates = {
  name: 'Old Insurance Co',
  state: 'Inactiva',  // Deactivated
  address: 'Av. Example 456, CABA',
  phone: '+54 11 1234-5678',
  webpage: 'https://www.example.com'
};

Update Website

Change the webpage URL when the social work updates their website:
const updates = {
  name: 'OSDE',
  state: 'Activa',
  address: 'Av. Leandro N. Alem 1067, CABA',
  phone: '+54 11 4310-5555',
  webpage: 'https://www.new-osde-site.com.ar'  // Updated
};

Notes

  • Only administrators can update social works
  • All fields (name, state, address, phone, webpage) are required in the request
  • The ID in the URL must be numeric and exist in the database
  • Name uniqueness is validated, but the current social work’s name is allowed
  • State transitions between “Activa” and “Inactiva” can be made freely
  • Validation errors will return a 400 status with detailed error messages
  • The response includes the complete updated object with all fields

Build docs developers (and LLMs) love