Explorar documentación

Slots y Disponibilidad

Gestionar franjas horarias y disponibilidad del prestador

Configurá el cliente de servidor del SDK para usar los ejemplos con esus. Los ejemplos REST usan un token de sesión. Si los ejecutás con la misma clave API que el SDK, enviá X-API-Key en lugar de Authorization.

Crear un Schedule

Creá un recurso Schedule que define el contenedor de disponibilidad. actor[] es el único campo obligatorio; mantiene la forma estándar de referencia FHIR porque un schedule puede apuntar a profesionales, ubicaciones, dispositivos, etc. active vale true por defecto.

REST
curl -X POST https://api.esus.health/fhir/Schedule \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "active": true,
    "serviceCategory": [{
      "coding": [{
        "system": "http://terminology.hl7.org/CodeSystem/service-category",
        "code": "1",
        "display": "General Practice"
      }]
    }],
    "actor": [{
      "reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
      "display": "Dra. Sara Johnson"
    }],
    "planningHorizon": {
      "start": "2026-04-21T08:00:00Z",
      "end": "2026-04-21T17:00:00Z"
    }
  }'
SDK
const created = await esus.fhir.create("Schedule", {
  "active": true,
  "serviceCategory": [
    {
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/service-category",
          "code": "1",
          "display": "General Practice"
        }
      ]
    }
  ],
  "actor": [
    {
      "reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
      "display": "Dra. Sara Johnson"
    }
  ],
  "planningHorizon": {
    "start": "2026-04-21T08:00:00Z",
    "end": "2026-04-21T17:00:00Z"
  }
});

Otros campos opcionales: identifier[], serviceType[], specialty[], comment.

Encontrar el Schedule de un Profesional

La búsqueda de Schedule soporta actor, active, service-type, specialty y date. Todos salvo active son coincidencias parciales de texto: actor acepta Practitioner/<id> o el id solo, y date busca el texto dentro de planningHorizon (sin semántica de rango: un prefijo ge/le se descarta y la fecha se compara como texto, y solo se usa el primer valor de date).

REST
curl "https://api.esus.health/fhir/Schedule?actor=Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789&active=true" \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("Schedule", {
  "actor": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789",
  "active": true
});

Crear Slots

Cada slot referencia a su schedule padre con el campo plano scheduleId (no un objeto de referencia FHIR), que tiene que ser el id de un Schedule existente. scheduleId, start y end son obligatorios; status vale free por defecto y overbooked, false.

REST
curl -X POST https://api.esus.health/fhir/Slot \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900",
    "status": "free",
    "start": "2026-04-21T09:00:00Z",
    "end": "2026-04-21T09:30:00Z",
    "comment": "Disponible para chequeo general"
  }'
SDK
const created = await esus.fhir.create("Slot", {
  "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900",
  "status": "free",
  "start": "2026-04-21T09:00:00Z",
  "end": "2026-04-21T09:30:00Z",
  "comment": "Disponible para chequeo general"
});

Las respuestas devuelven la forma FHIR estándar, "schedule": { "reference": "Schedule/aa11bb22-..." }, aunque las escrituras reciban scheduleId.

Valores de Status del Slot

StatusSignificado
freeEl slot está disponible
busyEl slot está reservado
busy-unavailableEl slot existe pero no está disponible
busy-tentativeEl slot está reservado tentativamente
entered-in-errorRegistrado por error

El status del Slot no tiene máquina de estados: cualquier valor se puede fijar con PUT/PATCH. El único cambio automático es $book pasándolo de free → busy. Cancelar un turno no libera su slot; hacelo vos:

curl -X PATCH https://api.esus.health/fhir/Slot/c1a2e3d4-5b6f-7890-abcd-ef1234567890 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{ "status": "free" }'

Buscar Slots Disponibles

La búsqueda de Slot soporta solo estos parámetros:

ParámetroCoincidencia
scheduleId exacto del Schedule (<uuid> o Schedule/<uuid>; sin encadenamiento schedule.actor)
statusExacta
startMismo día calendario que la fecha dada; sin prefijos ge/le
service-typeCoincidencia parcial de texto

No hay parámetro date ni _sort en Slot, y los resultados no vienen en un orden garantizado: ordenalos por start del lado del cliente. Para encontrar los slots de un profesional, primero resolvé el id de su Schedule (ver arriba) y después filtrá los Slots por ese id.

REST
# Todos los slots libres de un schedule en un día puntual
curl "https://api.esus.health/fhir/Slot?schedule=aa11bb22-cc33-dd44-ee55-ff6677889900&status=free&start=2026-04-21" \
  -H "Authorization: Bearer YOUR_TOKEN"
SDK
const { resources, total } = await esus.fhir.search("Slot", {
  "schedule": "aa11bb22-cc33-dd44-ee55-ff6677889900",
  "status": "free",
  "start": "2026-04-21"
});

Crear Muchos Slots

No hay operación $bulk-create. Podés iterar POST /fhir/Slot, o mandar un Bundle batch a POST /fhir (hasta 50 entries; cada una se procesa de forma independiente, no atómica). Los Bundles transaction se rechazan con 422.

curl -X POST https://api.esus.health/fhir \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "resourceType": "Bundle",
    "type": "batch",
    "entry": [
      {
        "request": { "method": "POST", "url": "Slot" },
        "resource": { "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900", "start": "2026-04-21T09:00:00Z", "end": "2026-04-21T09:30:00Z" }
      },
      {
        "request": { "method": "POST", "url": "Slot" },
        "resource": { "scheduleId": "aa11bb22-cc33-dd44-ee55-ff6677889900", "start": "2026-04-21T09:30:00Z", "end": "2026-04-21T10:00:00Z" }
      }
    ]
  }'

La respuesta es un Bundle batch-response con un status por entry; revisá cada uno.