Skip to main content
PATCH
/
patients
/
:id
Update patient
curl --request PATCH \
  --url https://api.example.com/patients/:id \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "surname": "<string>",
  "dni": "<string>",
  "birthdate": "<string>",
  "gender": "<string>",
  "address": "<string>",
  "phone": "<string>",
  "email": "<string>",
  "socialWorkId": 123,
  "state": "<string>"
}
'
{
  "patient": {
    "id": 123,
    "name": "<string>",
    "surname": "<string>",
    "dni": 123,
    "birthdate": "<string>",
    "gender": "<string>",
    "address": "<string>",
    "phone": "<string>",
    "email": "<string>",
    "socialWorkId": 123,
    "state": "<string>"
  }
}

Authentication

This endpoint requires a valid JWT token and administrator privileges.
Authorization
string
required
Bearer token for authentication. Include as Bearer <token>.
This endpoint requires administrator role. Users without admin privileges will receive a 403 Forbidden error.

Path Parameters

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

Request Body

name
string
required
Patient’s first name. Cannot be empty.
surname
string
required
Patient’s last name. Cannot be empty.
dni
string
required
Patient’s national identification number (DNI).
  • Minimum 7 characters
  • Must be unique or belong to the current patient
birthdate
string
required
Patient’s date of birth. Should be in ISO 8601 format (YYYY-MM-DD).
gender
string
required
Patient’s gender.
address
string
required
Patient’s residential address. Cannot be empty.
phone
string
required
Patient’s phone number.
  • Must be between 10 and 20 characters
  • Can only contain numbers, spaces, hyphens, or plus signs
  • Pattern: /^[0-9\s\-\+]*$/
email
string
required
Patient’s email address. Must be a valid email format.
socialWorkId
number
required
ID of the patient’s social work. Must reference a valid social work that exists in the system.
state
string
required
Patient’s current state. Possible values:
  • Activo/a - Active patient
  • Inactivo/a - Inactive patient

Response

patient
object
The updated patient object.

Example Request

curl -X PATCH https://api.clinica-vitalis.com/patients/1 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "María",
    "surname": "González",
    "dni": "12345678",
    "birthdate": "1985-03-15",
    "gender": "Femenino",
    "address": "Av. Corrientes 5678, CABA",
    "phone": "11-4567-8901",
    "email": "[email protected]",
    "socialWorkId": 1,
    "state": "Activo/a"
  }'

Example Response

{
  "patient": {
    "id": 1,
    "name": "María",
    "surname": "González",
    "dni": 12345678,
    "birthdate": "1985-03-15T00:00:00.000Z",
    "gender": "Femenino",
    "address": "Av. Corrientes 5678, CABA",
    "phone": "11-4567-8901",
    "email": "[email protected]",
    "socialWorkId": 1,
    "state": "Activo/a"
  }
}

Error Responses

400 Bad Request

Returned when the ID is missing or not numeric.
{
  "msg": "Debe enviar un ID y debe ser numérico"
}
Also returned when validation fails for any field:
{
  "errors": [
    {
      "msg": "El nombre es obligatorio",
      "param": "name"
    }
  ]
}
Common validation errors:
  • El nombre es obligatorio - Name is required
  • El apellido es obligatorio - Surname is required
  • El DNI es obligatorio - DNI is required
  • DNI no válido - DNI must be at least 7 characters
  • El DNI ya está registrado en otro paciente - DNI belongs to another patient
  • La fecha de nacimiento es obligatoria - Birthdate is required
  • El genero es obligatorio - Gender is required
  • La dirección es obligatoria - Address is required
  • El teléfono es obligatorio - Phone is required
  • El teléfono debe tener entre 10 y 20 caracteres - Phone must be 10-20 characters
  • El teléfono solo puede contener números, guiones o espacios - Invalid phone format
  • El email es obligatorio - Email is required
  • El email no es válido - Invalid email format
  • La obra social es obligatoria - Social work ID is required
  • La obra social no existe - Social work ID does not exist
  • El estado es obligatorio - State is required

401 Unauthorized

Returned when the JWT token is missing or invalid.
{
  "msg": "Token inválido"
}

403 Forbidden

Returned when the user does not have administrator privileges.
{
  "msg": "No tienes permisos de administrador"
}

404 Not Found

Returned when the patient with the specified ID is not found.
{
  "msg": "El paciente no está cargado en el sistema"
}

500 Internal Server Error

Returned when a server error occurs.
{
  "msg": "Error del servidor"
}

Build docs developers (and LLMs) love