{"openapi":"3.1.0","info":{"title":"Centro Encina API","version":"0.77.0","description":"OpenAPI 0.77.0: CANCEL_KEEP. A patient PATCH /api/appointments/{id} {status: CANCELLED} requires cancelReason (NO_PUEDO, OTRO_HORARIO, CAMBIAR_PROFESIONAL, TEMA_PERSONAL, OTRO). OTRO may include cancelNote. A missing reason is 400 CANCEL_REASON_REQUIRED. Staff cancel omits the list. A succeeded payment on the visit, particular fee or obra-social copago, does not become credit and is not refunded. A succeeded coseguro stays out of credit. GET /api/appointments for staff includes chartCancellations, the latest patient reason per chart, not filtered by from or to. A professional receives only cancellations of their own visits. OpenAPI 0.76.0: COSEGURO_DESK amounts and alcance. The convenio JSON seeds a missing org, copay, and scope. Sync does not overwrite CoverageOrg.coseguroScope or CoverageCopay.amountCents and does not delete copays. quoteCoverage reads CoverageCopay once the row exists. SECRETARY and ADMIN PATCH /api/coverage/orgs/{id} {coseguroScope} and PATCH /api/coverage/orgs/{id}/copay {specialty, amountCents}. One amount per obra and specialty. Visits already booked keep their stored amount. PATCH /api/appointments/{id} {amountCents} corrects an unpaid visit and returns 409 COPAY_ALREADY_PAID when a copago payment succeeded. GET /api/patients/{id}/coseguros includes coverageOrgId, convenio, and ORDER usage (covered, used, remaining). OpenAPI 0.75.0: COSEGURO_DESK. CoverageOrg.coseguroScope is ORDER or SESSION and is not cadence. ORDER is seeded for boreaL, integral, and NOBIS. Every other org is SESSION, including PREVENCION_SALUD. SECRETARY and ADMIN record the paper on POST/PATCH /api/patients/{id}/coseguros (amount as written, session count, paid at the desk). Scope is the org row. GET /api/appointments/{id} includes coseguro, null when there is no separate charge. POST /api/payments with coseguroRecordId is a Mercado Pago charge that is not the visit copago, does not change amountDueCents, and does not become cancel credit. OpenAPI 0.74.0: CHAT_ENTRY landing. POST /api/webchat/booking/book includes passwordEntryPath /entrar/clave, the relative patient-app path the chat opens after a booking so the person creates a password. It is not an absolute URL, not /alta, and not /recuperar. POST /api/auth/recover is unchanged. OpenAPI 0.73.0: CHAT_ENTRY. POST /api/webchat/booking/register stores the same admission facts as the web (name, phone, document, birth date, responsible adult when under 18, consultation reason, coverage) and does not create a password or an Auth user. Book returns 409 CHAT_FACTS_REQUIRED until those facts are on the chart. The chat does not set a time zone. POST /api/auth/recover provisions a confirmed Auth user only for a PATIENT chart with no live login, stores that id on the chart, and sends the existing recovery link to /recuperar/nueva. An existing Auth user, a missing chart, and a staff email are not provisioned. The response does not say whether the address exists. Repeats inside 60 seconds are 429 RATE_LIMITED. OpenAPI 0.72.0: Staff check-in auth override (T14 / CALU-104) — POST /api/appointments/{id}/auth-override with {status: AUTHORIZED|NEEDS_DESK|FAILED, reason} (SECRETARY/ADMIN) updates appointment.authStatus and persists AppointmentAuthOverride audit (actor, from→to, reason). GET lists audit for that visit. Cobros-era PATCH authStatus PENDIENTE/PENDIENTE_AFILIADO/VALIDADO unchanged. No clearing/hub or Calu. OpenAPI 0.71.0: Soft OS quota counters (T9) — GET /api/insurance-rules/{orgId}/quota?patientId= returns used/remaining/atLimit/alert from InsuranceRules.quota (softOnly; never hard-blocks booking). SECRETARY/ADMIN or the patient for their own chart. POST …/quota with {patientId,reason} records a process-local staff override acknowledgment stub. OpenAPI 0.70.0: webchat handoff reasons unified (T13) — token_failed, grupo2_rp, sin_turno alongside booking_unavailable; legacy secretariat/urgency/unanswerable kept. OpenAPI 0.69.0: webchat book OS declarativo — POST /api/webchat/booking/book accepts insuranceOrgId|coverageOrgId (+ optional affiliateNumber), persists coverageOrgId + authStatus=PENDING after claim (no clearing/hub/token). GET /api/webchat/booking/insurance-orgs lists guide orgs for anonymous landing (same booking secret). OpenAPI 0.68.0: InsuranceRules catalog from the Encina OS guide (sep-2026) — GET /api/insurance-rules and GET /api/insurance-rules/{orgId}/ask?moment=book|checkin (session or X-Insurance-Rules-Secret). Encodes group 1|2, quota, book vs check-in fields, auth owner, coseguro/copago, ruleVersion. OpenAPI 0.67.0: POST /api/auth/document still returns 409 DOCUMENT_IN_USE with the masked email only. It does not email a sign-in link and does not return details.sent. OpenAPI 0.66.0: POST /api/auth/document checks a document before a chart is opened. A number already on another chart returns 409 DOCUMENT_IN_USE with a masked email and sends a sign-in link to that chart. OpenAPI 0.65.0: POST /api/auth/signup/abandon deletes an unfinished self-signup (admission_started, no domain user) so going back does not keep the email. A finished chart keeps it. OpenAPI 0.64.0: GET /api/appointments?openings=1 includes unclaimed band hours for staff so the agenda draws each one as Libre. Without that flag, and for a patient, those hours stay out of the list. OpenAPI 0.63.0: a visit stores the patient charge and, when the convenio has that practice, the nomenclator code and the obra social. The amount the obra social pays is not stored and is not returned. GET /api/coverage/orgs lists the seeded obras sociales. GET /api/coverage/sheet is the monthly presentation (22–26) or the match prefill when patientId is set. GET /api/appointments?match=1 filters offered hours. OpenAPI 0.62.0: webchat anonymous booking BFF — POST /api/webchat/booking/{lookup,register,professionals,slots,book}, gated by WEBCHAT_BOOKING_ENABLED (default off → 501) and X-Webchat-Booking-Secret. Lookup by DNI, minimal alta, professionals, morning/afternoon slots (≤3, split 13:00 ART), claim book with claim idempotency. OpenAPI 0.61.0: webchat handoff inbox for secretaría — GET/POST /api/webchat/handoffs*, gated by WEBCHAT_HANDOFF_ENABLED (default off → 501). OpenAPI 0.60.0: PATCH status COMPLETED on an advisor interview may send specialty. That stores the care with no professional. With none on the chart the interview stays open (409 SPECIALTY_REQUIRED), and an hour ending does not record admission until a specialty is there. OpenAPI 0.59.0: a patient holds one care per specialty (patient_cares). Home and the chart return cares. Booking another clinician of a specialty that already has a usual stays 409 USUAL_PROFESSIONAL_REQUIRED. An advisor claim that names a real specialty adds that care and leaves the others. OpenAPI 0.58.0: PATCH /api/appointments/{id} with slotId accepts a free hour of the same professional under another service when it lasts the same; the visit keeps its service and price. OpenAPI 0.57.0: GET /api/admin/feature-flags lists only the options the centre can switch. payments_mock_auto_succeed is internal: it is not listed and PATCH answers FLAG_NOT_FOUND. GET /api/appointments/{id} reads the visit once. OpenAPI 0.56.0: GET /api/appointments returns the agenda card (name, time, status, service, payment status). Notes and the series rule load on GET /api/appointments/{id}. That read does not settle a finished visit, reprice an admission, or apply credit; the 30-second job settles and reprices, and credit is applied when the payment is created. Confirmá y pagá may send the price from before that credit; the charge is the price minus the balance. OpenAPI 0.55.0: GET /api/appointments is the day grid. It does not wait on upkeep, and it omits the series rule. GET /api/appointments/{id} returns that rule. Unclaimed band hours use source BANDA and stay out of the staff agenda. OpenAPI 0.54.0: GET /api/patients is the office directory. A professional receives 403, so the list does not include every chart, the usual professional, or the balance. OpenAPI 0.53.0: GET /api/home is the patient screen. A professional receives 403. Office staff still pass patientId. OpenAPI 0.52.0: GET /api/catalog/professionals/{id} returns the profile a caller may see. A real patient does not browse a test professional, and still opens the one already on the chart. OpenAPI 0.51.0: clinical notes (historia clínica) — free-text ClinicalNote per visit, writable only by the appointment professional; distinct from Appointment.notes; Calu sync stub until clinicHistories write schema is mapped. OpenAPI 0.50.0: users.isTest marks a disposable login. Office sets it on patients and professionals. POST /api/office/test-accounts creates a test admin or secretary and always sets the mark. A real patient does not see a test professional. OpenAPI 0.49.0: cancelling a paid visit keeps the money as credit (home balance creditCents). The next visit's amountDueCents is the price minus that credit. It is not refunded to Mercado Pago. OpenAPI 0.48.0: staff occupying an offered hour skip the usual-professional gate and still store the chart specialty. Moving onto a free slot locks only the patient. An admission charges the catalog service amount. OpenAPI 0.47.0: a patient cannot cancel or reschedule inside 12 hours (409 CHANGE_LOCKED). A second visit on the same hour needs overbook true or the API returns 409 OVERLAP_UNCONFIRMED. A professional claim stores the chart specialty and returns 409 SPECIALTY_REQUIRED when the chart has none. BFF for the patient home, appointments, payments, catalog, patients, and feature flags. Login is Supabase Auth; this API verifies the access token. Mercado Pago checkout is test-only (Credenciales de prueba and the sandbox URL). Errors use { error, details: { code } }. OpenAPI 0.43.0: a work band can repeat weekly, every 15 days, or on one date. OpenAPI 0.42.0: a work band can set slotMinutes; staff bands stay at 60 and a week copied from Calu uses the duration Calu saved. OpenAPI 0.41.0: admission lives on the patient as admissionCompletedAt. Completing an advisor interview sets it; marking that interview absent clears it; deleting the visit does not. Office PATCH /api/patients/{id} can set admissionCompleted. OpenAPI 0.40.0: a completed advisor interview cannot be deleted (409 ADMISSION_KEEP); marking it absent reopens admission. OpenAPI 0.39.0: moving a future booked visit offers the previous hour again and takes an unassigned hour at the new time instead of stacking a second visit. OpenAPI 0.38.0: saved work bands publish virtual 60-minute open hours for 21 days; claiming one can set the visit specialty. OpenAPI 0.37.0: office PATCH /api/patients/{id} can set the login password and keeps Auth email in sync. OpenAPI 0.36.0: home patient includes phone so a chart with no advisor interview can resume admission."},"servers":[{"url":"https://centro-encina-api-production.up.railway.app","description":"Production (Railway)"},{"url":"http://127.0.0.1:43127","description":"Local next dev"}],"tags":[{"name":"meta"},{"name":"auth"},{"name":"home"},{"name":"catalog"},{"name":"patients"},{"name":"appointments"},{"name":"clinical-notes"},{"name":"payments"},{"name":"admin"},{"name":"webchat"},{"name":"insurance-rules"}],"paths":{"/api/health":{"get":{"tags":["meta"],"summary":"Health check","operationId":"getHealth","security":[],"responses":{"200":{"description":"Service is up","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/api/openapi":{"get":{"tags":["meta"],"summary":"This OpenAPI document","operationId":"getOpenApi","security":[],"responses":{"200":{"description":"OpenAPI 3.1 JSON"}}}},"/api/coverage/orgs":{"get":{"tags":["catalog"],"summary":"Seeded obras sociales. The patient charge is the coseguro or zero. The amount the obra social pays is not stored and is not returned.","operationId":"listCoverageOrgs","responses":{"200":{"description":"Org list, or one patient charge when orgId is set"}}}},"/api/coverage/orgs/{id}":{"patch":{"tags":["catalog"],"summary":"Set the obra coseguro alcance","description":"COSEGURO_DESK. SECRETARY and ADMIN. Body is { coseguroScope: ORDER | SESSION }. This changes the obra, not one patient. The pay screen keeps reading the row.","operationId":"setCoverageCoseguroScope","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The stored scope"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/coverage/orgs/{id}/copay":{"patch":{"tags":["catalog"],"summary":"Set the convenio patient charge for one specialty","description":"COSEGURO_DESK. SECRETARY and ADMIN. Body is { specialty, amountCents }. One amount per obra and specialty. It applies to every person of that obra. Visits already booked keep the amount they stored.","operationId":"setCoverageCopay","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The stored amount"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/coverage/sheet":{"get":{"tags":["catalog"],"summary":"Match prefill when patientId is set. Otherwise the monthly presentation between the 22nd and the 26th, with no amounts.","operationId":"coverageSheet","responses":{"200":{"description":"Prefill or presentation rows"},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/insurance-rules":{"get":{"tags":["insurance-rules"],"summary":"Encina OS InsuranceRules catalog (guía sep-2026). Optional group=1|2 and inGuide=1. Auth: Bearer session or X-Insurance-Rules-Secret.","operationId":"listInsuranceRules","security":[{"bearerAuth":[]},{"insuranceRulesSecret":[]}],"parameters":[{"name":"group","in":"query","schema":{"type":"string","enum":["1","2"]}},{"name":"inGuide","in":"query","schema":{"type":"string","enum":["1"]}}],"responses":{"200":{"description":"ruleVersion + items"},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/insurance-rules/{orgId}/ask":{"get":{"tags":["insurance-rules"],"summary":"Qué preguntar for a given OS at book or checkin (dynamic form fields, live-auth flag, notices).","operationId":"askInsuranceRules","security":[{"bearerAuth":[]},{"insuranceRulesSecret":[]}],"parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}},{"name":"moment","in":"query","required":true,"schema":{"type":"string","enum":["book","checkin"]}}],"responses":{"200":{"description":"AskResult"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/insurance-rules/{orgId}/quota":{"get":{"tags":["insurance-rules"],"summary":"Soft OS quota usage for a patient + org (InsuranceRules.quota). Counts SCHEDULED/CHECKED_IN/COMPLETED Encina visits with that coverageOrgId in the clinic-zone window. softOnly — advisory only; does not block booking.","operationId":"getInsuranceQuotaUsage","security":[{"bearerAuth":[]}],"parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}},{"name":"patientId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"PatientOrgQuotaUsage (used, remaining, atLimit, alert, softOnly, window, quota, ruleVersion)"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["insurance-rules"],"summary":"Staff soft-quota override acknowledgment (SECRETARY/ADMIN). Process-local stub; does not change counters or hard-block booking.","operationId":"acknowledgeInsuranceQuotaOverride","security":[{"bearerAuth":[]}],"parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["patientId","reason"],"properties":{"patientId":{"type":"string","format":"uuid"},"reason":{"type":"string","minLength":1,"maxLength":500}}}}}},"responses":{"200":{"description":"softOnly + acknowledgment snapshot"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/auth/session":{"get":{"tags":["auth"],"summary":"Current session. A first sign-in with full_name opens a patient chart when that email has none. Anonymous if no Bearer.","operationId":"getSession","security":[{"bearerAuth":[]},{}],"responses":{"200":{"description":"Session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Session"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["auth"],"summary":"Resolve session from Bearer or body token (email is rejected)","operationId":"createSession","security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSessionRequest"}}}},"responses":{"200":{"description":"Session resolved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Session"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/auth/password":{"post":{"tags":["auth"],"summary":"Replace a provisional staff password","description":"Bearer required. Sets the Auth password and clears mustChangePassword. Refused when that flag is false.","operationId":"replaceProvisionalPassword","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReplacePasswordRequest"}}}},"responses":{"200":{"description":"Session after the password change","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Session"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/auth/signup/abandon":{"post":{"tags":["auth"],"summary":"Release an unfinished patient signup","description":"SIGNUP_BACK. Not a login. Deletes the Auth user only when this email has admission_started and no domain user, so going back from registration does not keep the address. A finished chart returns released false and the email stays taken.","operationId":"abandonSignup","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AbandonSignupRequest"}}}},"responses":{"200":{"description":"Whether the unfinished Auth user was deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AbandonSignupResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/auth/recover":{"post":{"tags":["auth"],"summary":"Send the set-password link","description":"CHAT_ENTRY. Not a session. Body is { email, redirectTo }. redirectTo must be an allowlisted origin plus /recuperar/nueva with no query. When that email is a PATIENT chart with no live Auth user, the API creates a confirmed Auth user (the person never sees a temporary password), stores supabaseAuthId on that chart, and sends the same recovery mail. An Auth user that already exists keeps today's reset. No chart, and a staff email, are not provisioned. 200 { ok: true } does not say whether the address exists. 429 RATE_LIMITED on a repeat inside 60 seconds. Errors are Spanish codes, not raw Auth JSON.","operationId":"recoverAccess","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecoverAccessRequest"}}}},"responses":{"200":{"description":"The same response whether or not the address has a chart","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecoverAccessResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/auth/document":{"post":{"tags":["auth"],"summary":"Check a document before opening a chart","description":"SOCIAL_LOGIN. Bearer required. Does not open a chart. 200 when the document is free or already on this patient's chart. 409 DOCUMENT_IN_USE when another chart has it: details.maskedEmail is the first two letters and the domain. No sign-in link is sent. The raw address is not returned, and details.sent is not returned.","operationId":"checkDocument","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentCheckRequest"}}}},"responses":{"200":{"description":"The document can be saved on this chart","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentCheckResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/home":{"get":{"tags":["home"],"summary":"Patient home sections","description":"Section data for the patient home. Static labels, routes, and resources stay in the frontend. Missing blocks are null. The patient receives their own home. Office staff pass patientId. A professional receives 403.","operationId":"getHome","security":[{"bearerAuth":[]}],"parameters":[{"name":"patientId","in":"query","required":false,"schema":{"type":"string","format":"uuid"},"description":"Required for office staff. Ignored for patients (scoped to self). A professional cannot call this route."}],"responses":{"200":{"description":"Home sections","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Home"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/services":{"get":{"tags":["catalog"],"summary":"List catalog services (public: active; staff: all)","operationId":"listCatalogServices","security":[{"bearerAuth":[]},{}],"responses":{"200":{"description":"Catalog services","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CatalogServiceList"}}}}}},"post":{"tags":["catalog"],"summary":"Create catalog service (staff)","operationId":"createCatalogService","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCatalogServiceRequest"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CatalogService"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/services/{id}":{"patch":{"tags":["catalog"],"summary":"Update catalog service (staff)","operationId":"updateCatalogService","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCatalogServiceRequest"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CatalogService"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/specialties":{"get":{"tags":["catalog"],"summary":"Psychology specialties offered in the professional form","operationId":"listSpecialties","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Closed specialty list","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"type":"string","enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"]}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/professionals":{"get":{"tags":["catalog"],"summary":"List professionals and advisors (public: active; staff: all)","operationId":"listProfessionals","security":[{"bearerAuth":[]},{}],"responses":{"200":{"description":"Professionals","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfessionalList"}}}}}},"post":{"tags":["catalog"],"summary":"Create professional or advisor. Password creates the login immediately.","operationId":"createProfessional","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProfessionalRequest"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Professional"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/professionals/{id}":{"get":{"tags":["catalog"],"summary":"Professional profile the caller may see","description":"Public for an active professional who is not a test account. A signed-in patient also receives the professional already on the chart, including a test professional. Office and a test login receive any active profile.","operationId":"getProfessional","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Professional"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["catalog"],"summary":"Update professional (staff)","operationId":"updateProfessional","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateProfessionalRequest"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Professional"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/professionals/{id}/calu-week":{"post":{"tags":["catalog"],"summary":"Pull the linked Calu week into Encina work bands","description":"Office or the professional themself. Requires CALU_SYNC and a professionals.caluId. Rewrites work bands and Calu absences from the doctorCentre, then republishes band openings. Use when a Calu agenda edit was missed (listener is connected every day 08:00–24:00 Argentina).","operationId":"pullProfessionalCaluWeek","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Bands after the pull","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ProfessionalWorkBand"}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/professionals/{id}/work-bands":{"get":{"tags":["catalog"],"summary":"List weekly work bands for a professional","operationId":"listProfessionalWorkBands","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Bands","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ProfessionalWorkBand"}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"tags":["catalog"],"summary":"Replace all weekly work bands for a professional","description":"Office or the professional themself. Empty bands array clears availability (UI falls back to 08:00–20:00).","operationId":"replaceProfessionalWorkBands","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["bands"],"properties":{"bands":{"type":"array","items":{"type":"object","required":["weekday","startMinute","endMinute"],"properties":{"weekday":{"type":"integer","minimum":1,"maximum":7},"startMinute":{"type":"integer","minimum":0,"maximum":1440},"endMinute":{"type":"integer","minimum":0,"maximum":1440},"serviceIds":{"type":"array","items":{"type":"string","format":"uuid"}},"slotMinutes":{"type":"integer","minimum":5,"maximum":240},"frequency":{"type":"string","enum":["weekly","biweekly","once"]},"anchorDate":{"type":"string","format":"date","nullable":true},"validFrom":{"type":"string","format":"date","nullable":true},"validUntil":{"type":"string","format":"date","nullable":true}}}}}}}}},"responses":{"200":{"description":"Replaced bands","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ProfessionalWorkBand"}}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/professionals/{id}/blocks":{"get":{"tags":["catalog"],"summary":"List calendar blocks for a professional","operationId":"listProfessionalCalendarBlocks","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Blocks","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/CalendarBlock"}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["catalog"],"summary":"Create a calendar block","operationId":"createProfessionalCalendarBlock","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["startsAt","endsAt"],"properties":{"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"allDay":{"type":"boolean"},"reason":{"type":"string","nullable":true,"maxLength":500}}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalendarBlock"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/professionals/{id}/blocks/{blockId}":{"delete":{"tags":["catalog"],"summary":"Delete a calendar block","operationId":"deleteProfessionalCalendarBlock","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"blockId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/calendar-blocks":{"get":{"tags":["catalog"],"summary":"List calendar blocks in a range (staff agenda)","operationId":"listCalendarBlocks","security":[{"bearerAuth":[]}],"parameters":[{"name":"from","in":"query","required":true,"schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","required":true,"schema":{"type":"string","format":"date-time"}},{"name":"professionalId","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Blocks","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/CalendarBlock"}}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/catalog/professionals/{id}/portrait":{"post":{"tags":["catalog"],"summary":"Upload and replace a professional portrait","description":"Office staff may update any portrait. A PROFESSIONAL may update only their own. JPEG, PNG, or WebP; maximum 2 MiB.","operationId":"replaceProfessionalPortrait","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"}}}}}},"responses":{"200":{"description":"Professional with the new public photoUrl","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Professional"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["catalog"],"summary":"Clear a professional portrait","operationId":"clearProfessionalPortrait","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Professional with photoUrl null","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Professional"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients":{"get":{"tags":["patients"],"summary":"List patients. Office lists the directory. A patient receives their own chart. A professional receives 403.","operationId":"listPatients","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Patient list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatientList"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["patients"],"summary":"Create patient (staff). Optional password creates the login immediately.","operationId":"createPatient","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePatientRequest"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Patient"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/care-change-requests":{"get":{"tags":["patients"],"summary":"List open professional care-change requests","description":"SECRETARY and ADMIN. CARE_CHANGE desk queue.","operationId":"listCareChangeRequests","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Open requests","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Patient"}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}/care-change":{"post":{"tags":["patients"],"summary":"Request or close a professional care change","description":"Patient opens a request for one specialty (body { request: true, specialty } when they hold more than one). Office assigns that specialty with { usualProfessionalId, usualSpecialty }; null clears only that specialty. Other cares stay. Option B: desk is emailed on request; professionals only when closed.","operationId":"postPatientCareChange","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"request":{"type":"boolean"},"usualProfessionalId":{"type":"string","format":"uuid","nullable":true},"specialty":{"type":"string","nullable":true,"enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"],"description":"CARE_PER_SPECIALTY. The specialty the patient is asking to change."},"usualSpecialty":{"type":"string","nullable":true,"enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"],"description":"CARE_PER_SPECIALTY. The one specialty office is assigning or clearing."}}}}}},"responses":{"200":{"description":"Updated patient","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Patient"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}/coseguros":{"get":{"tags":["patients"],"summary":"List coseguro papers for a patient","description":"COSEGURO_DESK. SECRETARY and ADMIN. scope is the patient's obra row (ORDER or SESSION), or null when the chart has no obra social. coverageOrgId is that obra. convenio is one stored patient charge per specialty. An ORDER paper includes usage (covered, used, remaining, usedUp). A SESSION paper has usage null. The response does not ask the secretary to choose an insurer.","operationId":"listPatientCoseguros","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Papers and the org scope"},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["patients"],"summary":"Record a coseguro paper","description":"COSEGURO_DESK. Body is the amount as written, the session count, paidAtDesk, kind (ADMISSION or THERAPY), an optional practice code, and an optional appointment id. Scope is not accepted. The org is the patient's obra row.","operationId":"createPatientCoseguro","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"201":{"description":"The patient's papers"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}/coseguros/{recordId}":{"patch":{"tags":["patients"],"summary":"Update a coseguro paper","description":"COSEGURO_DESK. Same body as create. Scope stays on the org row. Cancel of a linked visit clears appointmentId.","operationId":"updatePatientCoseguro","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"recordId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The patient's papers"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}":{"get":{"tags":["patients"],"summary":"Get patient by id","operationId":"getPatient","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Patient","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Patient"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["patients"],"summary":"Update patient (staff; patients may update own profile except email)","operationId":"updatePatient","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePatientRequest"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Patient"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["patients"],"summary":"Delete patient, their login, appointments, and payments (admin)","description":"ADMIN only. Deletes the Supabase login, then this patient's payments, appointments, and the patient. Deletes the linked user only when that user is not also a professional. A shared professional keeps the login. Catalog services and professionals are not deleted.","operationId":"deletePatient","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}/corrections":{"post":{"tags":["patients"],"summary":"Patient asks the center to correct their given name and surname","description":"One pending request at a time. The stored name does not change until office staff resolve it.","operationId":"createDataCorrection","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateDataCorrectionRequest"}}}},"responses":{"201":{"description":"Request stored for the center","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataCorrection"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}/corrections/{correctionId}":{"post":{"tags":["patients"],"summary":"Office staff apply the requested name and close the request","operationId":"resolveDataCorrection","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"correctionId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Resolved. The patient full name is now the requested name.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataCorrection"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}/balance":{"post":{"tags":["patients"],"summary":"Office staff mark the patient's whole open balance as paid","operationId":"settlePatientBalance","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The balance payment. Each included visit then has a recorded payment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/appointments":{"get":{"tags":["appointments"],"summary":"List appointments (patients and clinicians scoped to themselves)","operationId":"listAppointments","security":[{"bearerAuth":[]}],"parameters":[{"name":"patientId","in":"query","description":"Office staff only. Patients see their own. A professional sees only their appointments, and this filter is ignored. Ignored when available=true.","schema":{"type":"string","format":"uuid"}},{"name":"professionalId","in":"query","description":"Office staff may filter any professional. A professional remains scoped to self. For a patient this only narrows their own appointments.","schema":{"type":"string","format":"uuid"}},{"name":"from","in":"query","description":"Overlap lower bound: endsAt must be after this instant.","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","description":"Overlap upper bound: startsAt must be before this instant.","schema":{"type":"string","format":"date-time"}},{"name":"available","in":"query","description":"When true, lists future slots staff published and no patient has taken.","schema":{"type":"boolean"}},{"name":"openings","in":"query","description":"When 1, staff lists include unclaimed band hours (source BANDA) so the agenda can open that existing hour. A patient query ignores it. The directory does not send it.","schema":{"type":"string","enum":["1"]}},{"name":"kind","in":"query","description":"With available=true, limits the list to ADVISOR or PROFESSIONAL.","schema":{"type":"string","enum":["ADVISOR","PROFESSIONAL"]}}],"responses":{"200":{"description":"Appointment list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentList"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["appointments"],"summary":"Create appointment. A virtual visit gets its Meet link from the center Google Calendar.","operationId":"createAppointment","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAppointmentRequest"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Appointment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/appointments/recurring":{"post":{"tags":["appointments"],"summary":"Create a materialized weekly appointment series","description":"Office staff may create free or patient-assigned series. A PROFESSIONAL may publish only their own free PROFESSIONAL series. ADVISOR series cannot have a patient. Recurrence uses ISO weekdays (1=Mon…7=Sun), intervalWeeks, and exactly one of count or until, with optional excludeDates. A partial failure rolls back created visits and attempts to delete their Meet rooms.","operationId":"createRecurringAppointments","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRecurringAppointmentsRequest"}}}},"responses":{"201":{"description":"Materialized series","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentList"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/appointments/{id}/series":{"patch":{"tags":["appointments"],"summary":"Edit or cancel a series occurrence with THIS / FOLLOWING / ALL scope","description":"Office or the visit's professional. Send exactly one of: startsAt+endsAt (time shift), exclude (skip THIS), cancel, or recurrence (rule change for FOLLOWING/ALL). Open statuses only; completed visits are never rewritten. Staff copy maps to Solo este / Este y los siguientes / Toda la serie.","operationId":"patchAppointmentSeries","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchAppointmentSeriesRequest"}}}},"responses":{"200":{"description":"Affected open occurrences after the edit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentList"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/appointments/{id}/auth-override":{"get":{"tags":["appointments"],"summary":"List check-in auth overrides for a visit (SECRETARY/ADMIN)","description":"Audit trail of manual authStatus overrides (T14). Does not call clearing or Calu.","operationId":"listAppointmentAuthOverrides","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Overrides newest first","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/AppointmentAuthOverride"}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["appointments"],"summary":"Override check-in authStatus (SECRETARY/ADMIN)","description":"Sets appointment.authStatus to AUTHORIZED, NEEDS_DESK, or FAILED and writes AppointmentAuthOverride (who, when, from→to, reason). Non-empty reason required. Does not call clearing/hub or Calu. Cobros PATCH VALIDADO path stays separate.","operationId":"overrideAppointmentAuth","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status","reason"],"properties":{"status":{"type":"string","enum":["AUTHORIZED","NEEDS_DESK","FAILED"]},"reason":{"type":"string","minLength":1,"maxLength":500}}}}}},"responses":{"200":{"description":"Updated authStatus + override audit row","content":{"application/json":{"schema":{"type":"object","properties":{"appointmentId":{"type":"string","format":"uuid"},"authStatus":{"type":"string","enum":["AUTHORIZED","NEEDS_DESK","FAILED"]},"override":{"$ref":"#/components/schemas/AppointmentAuthOverride"}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/appointments/{id}/clinical-note":{"get":{"tags":["clinical-notes"],"summary":"Get clinical note for a visit (appointment professional only)","operationId":"getAppointmentClinicalNote","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Note or null","content":{"application/json":{"schema":{"type":"object","properties":{"note":{"oneOf":[{"$ref":"#/components/schemas/ClinicalNote"},{"type":"null"}]}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"tags":["clinical-notes"],"summary":"Create or update free-text clinical note for a visit","description":"Only the professional who owns the appointment may write. Distinct from Appointment.notes (internal ops). Calu remains source of truth; Encina stores the draft until sync.","operationId":"putAppointmentClinicalNote","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["body"],"properties":{"body":{"type":"string","minLength":1,"maxLength":20000}}}}}},"responses":{"200":{"description":"Saved draft","content":{"application/json":{"schema":{"type":"object","properties":{"note":{"$ref":"#/components/schemas/ClinicalNote"}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/clinical-notes/{id}/sync":{"post":{"tags":["clinical-notes"],"summary":"Push clinical note toward Calu","description":"Until clinicHistories write schema is mapped, returns PENDING with a Calu deep-link fallback (CALU_HC_WRITE_UNAVAILABLE).","operationId":"syncClinicalNote","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Updated sync status","content":{"application/json":{"schema":{"type":"object","properties":{"note":{"$ref":"#/components/schemas/ClinicalNote"}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/patients/{id}/clinical-notes":{"get":{"tags":["clinical-notes"],"summary":"List clinical notes the current professional authored for a patient","operationId":"listPatientClinicalNotes","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Notes","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ClinicalNote"}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/appointments/{id}":{"get":{"tags":["appointments"],"summary":"Get appointment by id","operationId":"getAppointment","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Appointment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Appointment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["appointments"],"summary":"Update appointment status (staff; patients may cancel)","operationId":"updateAppointment","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAppointmentRequest"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Appointment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["appointments"],"summary":"Permanently delete appointment and its payments","description":"ADMIN may delete any appointment. A PROFESSIONAL may delete only an appointment on their own agenda. Deletion removes its payments and does not publish the hour again. It does not delete the patient. A completed advisor interview returns 409 ADMISSION_KEEP. A past booked interview is settled to COMPLETED before that check. Marking that interview NO_SHOW reopens admission and then allows delete.","operationId":"deleteAppointment","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/appointments/{id}/claim":{"post":{"tags":["appointments"],"summary":"Patient takes an open slot","description":"Optional specialty is stored when the open hour has none and the visit is with a professional. A staff-published hour keeps its specialty. Admission ignores specialty.","operationId":"claimAppointment","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"specialty":{"type":"string","description":"One of the visit specialties. Required when the open hour has none."}}}}}},"responses":{"200":{"description":"The slot, now scheduled for the patient","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Appointment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/payments":{"post":{"tags":["payments"],"summary":"Create a visit payment, or pay the whole open balance by checkout or alias.","operationId":"createPayment","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePaymentRequest"}}}},"responses":{"201":{"description":"Payment intent created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/payments/{id}":{"get":{"tags":["payments"],"summary":"Get payment by id","operationId":"getPayment","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Payment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/payments/{id}/sync":{"post":{"tags":["payments"],"summary":"Refresh a Mercado Pago test payment from the provider","operationId":"syncPayment","security":[{"bearerAuth":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SyncPaymentRequest"}}}},"responses":{"200":{"description":"Payment, after asking Mercado Pago when the row is still open","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/payments/webhooks/{provider}":{"post":{"tags":["payments"],"summary":"Provider webhook (not called by the frontend)","operationId":"paymentWebhook","security":[],"parameters":[{"name":"provider","in":"path","required":true,"schema":{"type":"string","enum":["mock","mercado_pago","paypal"]}}],"responses":{"200":{"description":"Webhook processed","content":{"application/json":{"schema":{"type":"object","properties":{"payment":{"$ref":"#/components/schemas/Payment"}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/office/test-accounts":{"post":{"tags":["identity"],"summary":"Create a test admin or secretary (TEST_ACCOUNT, always marked)","operationId":"createOfficeTestAccount","responses":{"201":{"description":"Test account"},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/admin/feature-flags":{"get":{"tags":["admin"],"summary":"List the options the centre can switch (ADMIN only)","operationId":"listFeatureFlags","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Flags","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeatureFlagList"}}}}}}},"/api/admin/feature-flags/{key}":{"patch":{"tags":["admin"],"summary":"Update feature flag (ADMIN only)","operationId":"updateFeatureFlag","security":[{"bearerAuth":[]}],"parameters":[{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateFeatureFlagRequest"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeatureFlag"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/handoffs":{"get":{"tags":["webchat"],"summary":"List webchat handoff tickets for SECRETARY/ADMIN. Default: queued+human. Requires WEBCHAT_HANDOFF_ENABLED=1.","operationId":"listWebchatHandoffs","security":[{"bearerAuth":[]}],"parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["queued","human","resolved","closed"]}},{"name":"includeClosed","in":"query","schema":{"type":"string","enum":["1"]},"description":"When 1 and status omitted, include resolved/closed."}],"responses":{"200":{"description":"Inbox list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatHandoffList"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["webchat"],"summary":"Create a handoff ticket (staff Bearer or X-Webchat-Handoff-Secret ingest).","operationId":"createWebchatHandoff","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWebchatHandoffRequest"}}}},"responses":{"201":{"description":"Created ticket","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatHandoffTicket"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/handoffs/{ticketId}":{"get":{"tags":["webchat"],"summary":"Handoff ticket detail + transcript messages","operationId":"getWebchatHandoff","security":[{"bearerAuth":[]}],"parameters":[{"name":"ticketId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Ticket + messages","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatHandoffDetail"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/handoffs/{ticketId}/takeover":{"post":{"tags":["webchat"],"summary":"Staff claims the conversation (status human)","operationId":"takeoverWebchatHandoff","security":[{"bearerAuth":[]}],"parameters":[{"name":"ticketId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Updated ticket","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatHandoffTicket"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/handoffs/{ticketId}/messages":{"post":{"tags":["webchat"],"summary":"Append a staff reply to the handoff transcript","operationId":"appendWebchatHandoffMessage","security":[{"bearerAuth":[]}],"parameters":[{"name":"ticketId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppendWebchatHandoffMessageRequest"}}}},"responses":{"201":{"description":"Created message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatHandoffMessage"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/handoffs/{ticketId}/resolve":{"post":{"tags":["webchat"],"summary":"Resolve a handoff ticket","operationId":"resolveWebchatHandoff","security":[{"bearerAuth":[]}],"parameters":[{"name":"ticketId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Resolved ticket","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatHandoffTicket"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/booking/lookup":{"post":{"tags":["webchat"],"summary":"Lookup Encina chart by document (DNI). Optional Calu enrich when CALU_SYNC=1. Requires WEBCHAT_BOOKING_ENABLED=1 and X-Webchat-Booking-Secret.","operationId":"webchatBookingLookup","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingLookupRequest"}}}},"responses":{"200":{"description":"Lookup result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingLookupResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/booking/register":{"post":{"tags":["webchat"],"summary":"CHAT_ENTRY patient alta. Same admission facts as the web, no password and no Auth user. Machine secret only.","operationId":"webchatBookingRegister","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingRegisterRequest"}}}},"responses":{"201":{"description":"Created chart","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingRegisterResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/booking/professionals":{"post":{"tags":["webchat"],"summary":"List active professionals for booking (advisor or clinical). Usual of specialty sorts first when patientId+specialty given.","operationId":"webchatBookingProfessionals","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingProfessionalsRequest"}}}},"responses":{"200":{"description":"Professionals","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingProfessionalsResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/booking/slots":{"post":{"tags":["webchat"],"summary":"Offered slots for a professional, filtered by morning/afternoon (13:00 ART) and limited (default 3).","operationId":"webchatBookingSlots","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingSlotsRequest"}}}},"responses":{"200":{"description":"Slots","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingSlotsResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/booking/book":{"post":{"tags":["webchat"],"summary":"Claim an OFFERED slot for a chart patient. 409 CHAT_FACTS_REQUIRED when admission facts are missing. Optional insuranceOrgId declares OS (coverageOrgId + authStatus=PENDING; no clearing). Replays when the same slot is already SCHEDULED for that patient. Calu write follows CALU_SYNC. Response passwordEntryPath is the relative path /entrar/clave the chat opens so the person creates a password.","operationId":"webchatBookingBook","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingBookRequest"}}}},"responses":{"200":{"description":"Replayed existing booking","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingBookResponse"}}}},"201":{"description":"Newly claimed booking","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebchatBookingBookResponse"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webchat/booking/insurance-orgs":{"get":{"tags":["webchat"],"summary":"Thin InsuranceRules guide list for anonymous landing (X-Webchat-Booking-Secret).","operationId":"webchatBookingInsuranceOrgs","responses":{"200":{"description":"Guide obras sociales","content":{"application/json":{"schema":{"type":"object","required":["items"],"properties":{"ruleVersion":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","required":["orgId","name","group","ruleVersion"],"properties":{"orgId":{"type":"string"},"name":{"type":"string"},"group":{"type":"integer","enum":[1,2]},"ruleVersion":{"type":"string"}}}}}}}}},"401":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"501":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Supabase Auth access_token from signInWithPassword (or session). Not the anon key."},"insuranceRulesSecret":{"type":"apiKey","in":"header","name":"X-Insurance-Rules-Secret","description":"Machine access when INSURANCE_RULES_SECRET is set (webchat / kiosk BFF). Empty secret closes machine access; Bearer session still works."}},"schemas":{"WebchatHandoffTicket":{"type":"object","required":["id","reason","status","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"reason":{"type":"string","enum":["secretariat","urgency","unanswerable","booking_unavailable","token_failed","grupo2_rp","sin_turno"]},"status":{"type":"string","enum":["queued","human","resolved","closed"]},"priority":{"type":"string","enum":["normal","high"]},"contactHint":{"type":"string","nullable":true},"patientRef":{"type":"string","nullable":true},"patientDisplayName":{"type":"string","nullable":true},"transcriptRef":{"type":"string","nullable":true},"transcriptPreview":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time","nullable":true},"etaBlurb":{"type":"string","nullable":true},"assignedStaffId":{"type":"string","format":"uuid","nullable":true}}},"WebchatHandoffMessage":{"type":"object","required":["id","ticketId","from","body","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"ticketId":{"type":"string","format":"uuid"},"from":{"type":"string","enum":["bot","user","staff"]},"body":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"WebchatHandoffList":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/WebchatHandoffTicket"}}}},"WebchatHandoffDetail":{"type":"object","required":["ticket","messages"],"properties":{"ticket":{"$ref":"#/components/schemas/WebchatHandoffTicket"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/WebchatHandoffMessage"}}}},"CreateWebchatHandoffRequest":{"type":"object","required":["reason"],"properties":{"reason":{"type":"string","enum":["secretariat","urgency","unanswerable","booking_unavailable","token_failed","grupo2_rp","sin_turno"]},"priority":{"type":"string","enum":["normal","high"]},"contactHint":{"type":"string","nullable":true},"patientRef":{"type":"string","nullable":true},"patientDisplayName":{"type":"string","nullable":true},"transcriptRef":{"type":"string","nullable":true},"transcriptPreview":{"type":"string","nullable":true},"etaBlurb":{"type":"string","nullable":true},"messages":{"type":"array","items":{"type":"object","required":["from","body"],"properties":{"from":{"type":"string","enum":["bot","user","staff"]},"body":{"type":"string"}}}}}},"AppendWebchatHandoffMessageRequest":{"type":"object","required":["body"],"properties":{"from":{"type":"string","enum":["staff"]},"body":{"type":"string"}}},"WebchatBookingPatient":{"type":"object","required":["id","fullName","email","admissionRequired","cares"],"properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string","nullable":true},"documentType":{"type":"string","nullable":true},"documentNumber":{"type":"string","nullable":true},"timeZone":{"type":"string"},"birthDate":{"type":"string","format":"date","nullable":true},"responsibleAdult":{"type":"string","nullable":true},"consultationReason":{"type":"string","nullable":true},"consultationReasonNote":{"type":"string","nullable":true},"coverageChosenAt":{"type":"string","format":"date-time","nullable":true},"coverageOrgId":{"type":"string","nullable":true},"affiliateNumber":{"type":"string","nullable":true},"admissionCompletedAt":{"type":"string","format":"date-time","nullable":true},"admissionRequired":{"type":"boolean"},"cares":{"type":"array","items":{"type":"object","required":["specialty","professionalId","professional"],"properties":{"specialty":{"type":"string"},"professionalId":{"type":"string","format":"uuid","nullable":true},"professional":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"}}}}}}}},"WebchatBookingLookupRequest":{"type":"object","required":["documentNumber"],"properties":{"documentType":{"type":"string","enum":["DNI","OTHER"]},"documentNumber":{"type":"string"}}},"WebchatBookingLookupResponse":{"type":"object","required":["found","foundInCalu","patient"],"properties":{"found":{"type":"boolean"},"foundInCalu":{"type":"boolean"},"patient":{"oneOf":[{"$ref":"#/components/schemas/WebchatBookingPatient"},{"type":"null"}]}}},"WebchatBookingRegisterRequest":{"type":"object","required":["documentType","documentNumber","fullName","email","phone","birthDate","consultationReason","coverageOrgId"],"properties":{"documentType":{"type":"string","enum":["DNI","OTHER"]},"documentNumber":{"type":"string"},"fullName":{"type":"string","description":"Given name and family name."},"email":{"type":"string","format":"email"},"phone":{"type":"string","description":"Prefix, a space, and the national number. Example: +54 11 5555 2048."},"birthDate":{"type":"string","format":"date"},"responsibleAdult":{"type":"string","nullable":true,"description":"Required when birthDate is under 18."},"consultationReason":{"type":"string","enum":["animo","pareja","hijo","empezar","medicacion","otro"]},"consultationReasonNote":{"type":"string","nullable":true,"description":"Required when consultationReason is otro."},"coverageOrgId":{"type":"string","nullable":true,"description":"Null chooses particular and sets coverageChosenAt. An id chooses that obra social."},"affiliateNumber":{"type":"string","nullable":true}}},"WebchatBookingRegisterResponse":{"type":"object","required":["patient"],"properties":{"patient":{"$ref":"#/components/schemas/WebchatBookingPatient"}}},"WebchatBookingProfessionalsRequest":{"type":"object","properties":{"kind":{"type":"string","enum":["advisor","clinical"]},"specialty":{"type":"string","nullable":true},"patientId":{"type":"string","format":"uuid","nullable":true}}},"WebchatBookingProfessionalsResponse":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"type":"object","required":["id","fullName","kind"],"properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"},"kind":{"type":"string","enum":["advisor","clinical"]},"specialty":{"type":"string","nullable":true}}}}}},"WebchatBookingSlotsRequest":{"type":"object","required":["professionalId","band"],"properties":{"professionalId":{"type":"string","format":"uuid"},"band":{"type":"string","enum":["morning","afternoon"]},"kind":{"type":"string","enum":["advisor","clinical"]},"limit":{"type":"integer","minimum":1,"maximum":10},"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"}}},"WebchatBookingSlotsResponse":{"type":"object","required":["band","limit","hasMore","items"],"properties":{"band":{"type":"string","enum":["morning","afternoon"]},"limit":{"type":"integer"},"hasMore":{"type":"boolean"},"items":{"type":"array","items":{"$ref":"#/components/schemas/WebchatBookingSlot"}}}},"WebchatBookingSlot":{"type":"object","required":["id","startsAt","endsAt","kind","modality","professional","service"],"properties":{"id":{"type":"string","format":"uuid"},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["advisor","clinical"]},"modality":{"type":"string","enum":["virtual","presencial"]},"professional":{"type":"object","required":["id","fullName"],"properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"}}},"service":{"type":"object","required":["id","name","amountCents","currency"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"amountCents":{"type":"integer"},"currency":{"type":"string"}}}}},"WebchatBookingBookRequest":{"type":"object","required":["patientId","appointmentId"],"properties":{"patientId":{"type":"string","format":"uuid"},"appointmentId":{"type":"string","format":"uuid"},"specialty":{"type":"string","nullable":true},"insuranceOrgId":{"type":"string","nullable":true,"description":"Declared obra social (InsuranceRules.orgId / CoverageOrg.id). Omit for particular."},"coverageOrgId":{"type":"string","nullable":true,"description":"Alias of insuranceOrgId"},"affiliateNumber":{"type":"string","nullable":true,"description":"Optional ficha field when the OS rule asks it at book"},"idempotencyKey":{"type":"string","nullable":true}}},"WebchatBookingBookResponse":{"type":"object","required":["appointment","replayed","passwordEntryPath"],"properties":{"passwordEntryPath":{"type":"string","description":"CHAT_ENTRY. Relative patient-app path /entrar/clave. The chat opens it after book. Not an absolute URL, not /alta, and not /recuperar.","enum":["/entrar/clave"]},"replayed":{"type":"boolean"},"appointment":{"type":"object","required":["id","status","startsAt","endsAt","kind","patientId"],"properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string"},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"kind":{"type":"string","enum":["advisor","clinical"]},"specialty":{"type":"string","nullable":true},"modality":{"type":"string","enum":["virtual","presencial"]},"patientId":{"type":"string","format":"uuid","nullable":true},"professional":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"}}},"service":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"amountCents":{"type":"integer"},"currency":{"type":"string"}}},"amountDueCents":{"type":"integer"},"insuranceOrgId":{"type":"string","nullable":true},"coverageOrgId":{"type":"string","nullable":true},"authStatus":{"type":"string","nullable":true,"description":"PENDING when OS was declared at book"},"ruleVersion":{"type":"string","nullable":true},"notice":{"type":"string","nullable":true,"description":"ES-AR notice (token validated the day of the visit)"}}}}},"Role":{"type":"string","enum":["PATIENT","SECRETARY","PROFESSIONAL","ADVISOR","ADMIN"]},"ErrorCode":{"type":"string","enum":["UNAUTHENTICATED","INVALID_TOKEN","INVALID_AUTH_HEADER","AUTH_EMAIL_NOT_ALLOWED","AUTH_EMAIL_MISSING","AUTH_MISCONFIGURED","USER_NOT_FOUND","AUTH_USER_MISMATCH","FORBIDDEN","PATIENT_PROFILE_REQUIRED","PATIENT_ID_REQUIRED","ADVISOR_REQUIRED","ADVISOR_ALREADY_BOOKED","ADVISOR_ALREADY_COMPLETED","ADMISSION_KEEP","SERVICE_NOT_FOUND","KIND_MISMATCH","PROFESSIONAL_NOT_FOUND","PROFESSIONAL_PROFILE_REQUIRED","PATIENT_NOT_FOUND","INVALID_TIME_RANGE","PROFESSIONAL_OVERLAP","OVERLAP_UNCONFIRMED","CHANGE_LOCKED","SPECIALTY_REQUIRED","SLOT_BLOCKED","SERVICE_NOT_IN_BAND","INVALID_WORK_BAND","BLOCK_NOT_FOUND","EMAIL_IN_USE","WEAK_PASSWORD","PASSWORD_CHANGE_NOT_REQUIRED","AUTH_CREATE_FAILED","SERVICE_CODE_IN_USE","APPOINTMENT_NOT_FOUND","INVALID_STATUS_TRANSITION","PAYMENT_PROVIDER_ERROR","PAYMENT_NOT_FOUND","ALREADY_PAID","AMOUNT_MISMATCH","APPOINTMENT_NOT_PAYABLE","WEBHOOK_INVALID","WEBHOOK_SIGNATURE_INVALID","FLAG_NOT_FOUND","MEET_NOT_CONFIGURED","MEET_UNAVAILABLE","INVALID_PHOTO_URL","INVALID_PORTRAIT_FILE","PORTRAIT_STORAGE_UNAVAILABLE","PORTRAIT_CLEANUP_FAILED","INVALID_RECURRENCE","ADVISOR_RECURRENCE_FORBIDDEN","CALU_UNLINKED","CALU_SYNC_OFF","CALU_NOT_CONFIGURED","CALU_DOCTOR_NOT_FOUND","USUAL_PROFESSIONAL_REQUIRED","USUAL_PROFESSIONAL_MISSING"]},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"details":{"type":"object","additionalProperties":true,"properties":{"code":{"$ref":"#/components/schemas/ErrorCode"}}}}},"Health":{"type":"object","required":["status","service","time"],"properties":{"status":{"type":"string","example":"ok"},"service":{"type":"string","example":"centro-encina-api"},"time":{"type":"string","format":"date-time"}}},"SessionUser":{"type":"object","required":["id","email","fullName","role","professionalId","mustChangePassword"],"properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"fullName":{"type":"string"},"role":{"$ref":"#/components/schemas/Role"},"professionalId":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"description":"Set when this user has a professionals row."},"mustChangePassword":{"type":"boolean","description":"True when staff set a provisional password and this person has not chosen their own yet."}}},"ReplacePasswordRequest":{"type":"object","required":["password"],"properties":{"password":{"type":"string","format":"password","minLength":8,"maxLength":72,"description":"Write-only. The person's own password. Never returned."}}},"Session":{"type":"object","required":["authenticated","user","source"],"properties":{"authenticated":{"type":"boolean"},"user":{"anyOf":[{"$ref":"#/components/schemas/SessionUser"},{"type":"null"}]},"source":{"type":"string","enum":["supabase"]}}},"CreateSessionRequest":{"type":"object","properties":{"supabaseAccessToken":{"type":"string","description":"Optional if Authorization header is set"}}},"AbandonSignupRequest":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"}}},"DocumentCheckRequest":{"type":"object","required":["documentType","documentNumber"],"properties":{"documentType":{"type":"string","enum":["DNI","OTHER"]},"documentNumber":{"type":"string"}}},"DocumentCheckResponse":{"type":"object","required":["available"],"properties":{"available":{"type":"boolean"}}},"AbandonSignupResponse":{"type":"object","required":["released"],"properties":{"released":{"type":"boolean","description":"True when an unfinished signup was deleted and the email can be used again."}}},"RecoverAccessRequest":{"type":"object","required":["email","redirectTo"],"properties":{"email":{"type":"string","format":"email"},"redirectTo":{"type":"string","description":"Allowlisted origin plus /recuperar/nueva. No query and no hash."}}},"RecoverAccessResponse":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean"}}},"CatalogService":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"code":{"type":"string"},"name":{"type":"string"},"kind":{"type":"string","enum":["ADVISOR","PROFESSIONAL"]},"currency":{"type":"string","example":"ARS"},"amountCents":{"type":"integer"},"active":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"CatalogServiceList":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/CatalogService"}}}},"PublicUser":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"fullName":{"type":"string"},"role":{"$ref":"#/components/schemas/Role"}}},"Professional":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"kind":{"type":"string","example":"ADVISOR"},"specialty":{"type":"string","nullable":true},"consultationAmountCents":{"type":"integer","nullable":true,"description":"Null uses the catalog service price. Zero is a free visit."},"caluId":{"type":"string","nullable":true,"description":"Linked Calu doctorCentre id. Null means the week cannot be pulled from Calu."},"bio":{"type":"string","nullable":true},"photoUrl":{"type":"string","format":"uri","nullable":true,"description":"Public https portrait. Null keeps the initials."},"active":{"type":"boolean"},"user":{"$ref":"#/components/schemas/PublicUser"},"workBands":{"type":"array","items":{"$ref":"#/components/schemas/ProfessionalWorkBand"},"description":"Weekly availability bands (ISO weekday). Empty means the UI uses the clinic default 08:00–20:00."}}},"ProfessionalWorkBand":{"type":"object","required":["id","professionalId","weekday","startMinute","endMinute","serviceIds"],"properties":{"id":{"type":"string","format":"uuid"},"professionalId":{"type":"string","format":"uuid"},"weekday":{"type":"integer","minimum":1,"maximum":7,"description":"ISO weekday 1=Mon … 7=Sun in America/Argentina/Buenos_Aires."},"startMinute":{"type":"integer","minimum":0,"maximum":1440},"endMinute":{"type":"integer","minimum":0,"maximum":1440},"serviceIds":{"type":"array","items":{"type":"string","format":"uuid"},"description":"Empty = any service of the professional kind. Non-empty = only these services."},"slotMinutes":{"type":"integer","minimum":5,"maximum":240,"description":"Length of each offered hour cut from this band. Staff bands stay at 60. A Calu week uses the duration Calu saved."},"frequency":{"type":"string","enum":["weekly","biweekly","once"],"description":"weekly repeats that weekday. biweekly repeats every 14 days from anchorDate. once is only anchorDate."},"anchorDate":{"type":"string","format":"date","nullable":true,"description":"Clinic date. Required for biweekly (first day) and once (the only day)."},"validFrom":{"type":"string","format":"date","nullable":true},"validUntil":{"type":"string","format":"date","nullable":true,"description":"Exclusive clinic date. Days on or after this date are not opened."}}},"CalendarBlock":{"type":"object","required":["id","professionalId","startsAt","endsAt","allDay"],"properties":{"id":{"type":"string","format":"uuid"},"professionalId":{"type":"string","format":"uuid"},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"allDay":{"type":"boolean"},"reason":{"type":"string","nullable":true}}},"ProfessionalList":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Professional"}}}},"PatientCare":{"type":"object","required":["specialty"],"properties":{"specialty":{"type":"string","enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"]},"professionalId":{"type":"string","format":"uuid","nullable":true},"careChangeRequestedAt":{"type":"string","format":"date-time","nullable":true},"professional":{"nullable":true,"description":"Usual clinician of this specialty. Home may send only id, fullName, photoUrl.","allOf":[{"$ref":"#/components/schemas/Professional"}]}}},"Patient":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"phone":{"type":"string","nullable":true},"documentType":{"type":"string","enum":["DNI","OTHER"],"nullable":true,"description":"Collected in onboarding. Not sent to Calu until CALU_SYNC is on."},"documentNumber":{"type":"string","nullable":true},"country":{"type":"string"},"timeZone":{"type":"string","description":"IANA zone for displaying visit times. Defaults to America/Argentina/Buenos_Aires."},"newsOptIn":{"type":"boolean","description":"Optional monthly news. Visit reminders stay on."},"admissionCompletedAt":{"type":"string","format":"date-time","nullable":true,"description":"When the advisor interview was completed. Null means admission is still open. Deleting the visit does not clear it."},"cares":{"type":"array","description":"CARE_PER_SPECIALTY. One row per specialty: its usual clinician and an open change request. This is the chart.","items":{"$ref":"#/components/schemas/PatientCare"}},"usualProfessionalId":{"type":"string","format":"uuid","nullable":true,"description":"Mirrors the only care, or the care with an open change request. Null when the patient holds more than one care and none is pending."},"usualSpecialty":{"type":"string","nullable":true,"enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"],"description":"Mirrors the same care as usualProfessionalId."},"careChangeRequestedAt":{"type":"string","format":"date-time","nullable":true,"description":"When that mirrored care asked office for a different professional."},"usualProfessional":{"nullable":true,"allOf":[{"$ref":"#/components/schemas/Professional"}]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"user":{"$ref":"#/components/schemas/PublicUser"},"corrections":{"type":"array","description":"At most the pending name correction.","items":{"$ref":"#/components/schemas/DataCorrection"}}}},"DataCorrection":{"type":"object","required":["id","patientId","givenName","familyName","status","createdAt"],"properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"givenName":{"type":"string"},"familyName":{"type":"string"},"note":{"type":"string","nullable":true},"status":{"type":"string","enum":["PENDING","RESOLVED"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"CreateDataCorrectionRequest":{"type":"object","required":["givenName","familyName"],"properties":{"givenName":{"type":"string"},"familyName":{"type":"string"},"note":{"type":"string"}}},"PatientList":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Patient"}}}},"CreatePatientRequest":{"type":"object","required":["email","fullName"],"properties":{"email":{"type":"string","format":"email"},"fullName":{"type":"string"},"phone":{"type":"string"},"country":{"type":"string","default":"AR"},"password":{"type":"string","format":"password","minLength":8,"maxLength":72,"description":"Write-only. When set, staff creates the Auth login and the patient can sign in. Never returned."}}},"UpdatePatientRequest":{"type":"object","properties":{"email":{"type":"string","format":"email","description":"Staff only"},"fullName":{"type":"string"},"phone":{"type":"string","nullable":true},"country":{"type":"string"},"timeZone":{"type":"string"},"newsOptIn":{"type":"boolean"},"documentType":{"type":"string","enum":["DNI","OTHER"]},"documentNumber":{"type":"string"},"admissionCompleted":{"type":"boolean","description":"Staff only. True records admission now when it was still open and leaves an existing date. False reopens admission."},"usualProfessionalId":{"type":"string","format":"uuid","nullable":true,"description":"Staff only (CARE_PER_SPECIALTY). Sets or clears the usual clinician of usualSpecialty. Other specialties stay."},"usualSpecialty":{"type":"string","nullable":true,"enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"],"description":"Staff only. The specialty this assign writes. Required."},"password":{"type":"string","format":"password","minLength":8,"maxLength":72,"description":"Staff only. Sets or replaces the app login. Omitted leaves the current login. Never returned."}}},"CreateCatalogServiceRequest":{"type":"object","required":["code","name","kind","amountCents"],"properties":{"code":{"type":"string","example":"PSICOLOGIC-CONSULT"},"name":{"type":"string"},"kind":{"type":"string","enum":["ADVISOR","PROFESSIONAL"]},"amountCents":{"type":"integer"},"currency":{"type":"string","default":"ARS"},"active":{"type":"boolean","default":true}}},"UpdateCatalogServiceRequest":{"type":"object","properties":{"name":{"type":"string"},"kind":{"type":"string","enum":["ADVISOR","PROFESSIONAL"]},"amountCents":{"type":"integer"},"currency":{"type":"string"},"active":{"type":"boolean"}}},"CreateProfessionalRequest":{"type":"object","required":["email","fullName","password","kind"],"properties":{"email":{"type":"string","format":"email"},"fullName":{"type":"string"},"password":{"type":"string","format":"password","minLength":8,"maxLength":72,"description":"Write-only. Staff creates the confirmed Auth login and the person can sign in. Never returned."},"kind":{"type":"string","enum":["ADVISOR","CLINICIAN"]},"specialty":{"type":"string","enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"]},"consultationAmountCents":{"type":"integer","minimum":0,"nullable":true,"description":"Null uses the catalog service price. Zero is a free visit."},"bio":{"type":"string","description":"Public bio, max 500 characters"},"photoUrl":{"type":"string","format":"uri","nullable":true,"description":"Public https portrait, max 500 characters. Null or blank clears it."},"active":{"type":"boolean","default":true}}},"UpdateProfessionalRequest":{"type":"object","properties":{"fullName":{"type":"string"},"kind":{"type":"string","enum":["ADVISOR","CLINICIAN"]},"specialty":{"type":"string","enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"],"nullable":true},"consultationAmountCents":{"type":"integer","minimum":0,"nullable":true},"bio":{"type":"string","nullable":true},"photoUrl":{"type":"string","format":"uri","nullable":true,"description":"Public https portrait, max 500 characters. Null or blank clears it."},"active":{"type":"boolean"}}},"Home":{"type":"object","required":["patient","sections"],"properties":{"patient":{"$ref":"#/components/schemas/HomePatient"},"sections":{"type":"array","items":{"$ref":"#/components/schemas/HomeSection"}}}},"HomePatient":{"type":"object","required":["id","fullName","timeZone"],"properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"},"timeZone":{"type":"string"},"phone":{"type":"string","nullable":true},"cares":{"type":"array","items":{"$ref":"#/components/schemas/PatientCare"}},"usualProfessionalId":{"type":"string","format":"uuid","nullable":true},"usualSpecialty":{"type":"string","nullable":true},"careChangeRequestedAt":{"type":"string","format":"date-time","nullable":true}}},"HomeSection":{"oneOf":[{"$ref":"#/components/schemas/HomeNextAppointmentSection"},{"$ref":"#/components/schemas/HomeJourneySection"},{"$ref":"#/components/schemas/HomeProfessionalSection"},{"$ref":"#/components/schemas/HomeBalanceSection"},{"$ref":"#/components/schemas/HomeSituationSection"}],"discriminator":{"propertyName":"type","mapping":{"nextAppointment":"#/components/schemas/HomeNextAppointmentSection","journey":"#/components/schemas/HomeJourneySection","professional":"#/components/schemas/HomeProfessionalSection","balance":"#/components/schemas/HomeBalanceSection","situation":"#/components/schemas/HomeSituationSection"}}},"HomeNextAppointmentSection":{"type":"object","required":["type","appointment"],"properties":{"type":{"const":"nextAppointment"},"appointment":{"oneOf":[{"$ref":"#/components/schemas/HomeAppointment"},{"type":"null"}]}}},"HomeAppointment":{"type":"object","required":["id","kind","status","modality","startsAt","endsAt","createdAt","timezone"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["ADVISOR","PROFESSIONAL"]},"status":{"type":"string","enum":["SCHEDULED","CHECKED_IN"]},"modality":{"type":"string","enum":["PRESENCIAL","VIRTUAL"]},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"timezone":{"type":"string","example":"America/Argentina/Buenos_Aires"}}},"HomeJourneySection":{"type":"object","required":["type","steps","admissionCompletedAt","beforeFirstConsultation"],"properties":{"type":{"const":"journey"},"steps":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/HomeJourneyStep"}},{"type":"null"}]},"admissionCompletedAt":{"oneOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"Start of the completed advisor interview. Null when that interview has not happened."},"beforeFirstConsultation":{"type":"boolean","description":"True after the advisor interview and before any consultation exists. False while a visit is open or after a consultation has already happened."}}},"HomeJourneyStep":{"type":"object","required":["key","status"],"properties":{"key":{"type":"string","enum":["scheduled","before","during","after"]},"status":{"type":"string","enum":["completed","current","upcoming"]}}},"HomeProfessionalSection":{"type":"object","required":["type","professional"],"properties":{"type":{"const":"professional"},"professional":{"oneOf":[{"$ref":"#/components/schemas/HomeProfessional"},{"type":"null"}]}}},"HomeBalanceSection":{"type":"object","required":["type","amountCents","currency"],"properties":{"type":{"const":"balance"},"amountCents":{"type":"integer","description":"Sum of completed visits the patient entered before paying and that still have no recorded payment. Cancelled and absent visits are not included."},"creditCents":{"type":"integer","description":"CANCEL_CREDIT. Succeeded payments on cancelled visits that are not yet used on a later visit. Not an amount the patient owes."},"currency":{"type":"string"}}},"HomeSituationSection":{"type":"object","required":["type","key","paymentId"],"properties":{"type":{"const":"situation"},"key":{"oneOf":[{"type":"string","enum":["confirmed","reserved","paymentPending","paymentDeclined","noAvailability","cancelledByCenter","professionalChanged"]},{"type":"null"}],"description":"confirmed: the visit is free, paid, or staff allowed entry. reserved: a priced visit is still unpaid and checkout has not submitted a charge. paymentPending: Mercado Pago has a charge that is not approved yet. paymentDeclined: the latest charge was rejected or cancelled. noAvailability: there is no upcoming visit and the usual professional has no future open hours. cancelledByCenter: there is no upcoming visit and the latest consultation was cancelled by staff/professional. professionalChanged: there is no upcoming visit and the usual professional is no longer active. null: there is no upcoming visit and booking is still possible, or the patient has no professional yet."},"paymentId":{"type":"string","format":"uuid","nullable":true,"description":"The payment the patient can continue or retry. Null when there is nothing to pay."}}},"HomeProfessional":{"type":"object","required":["id","fullName"],"properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"},"specialty":{"type":"string","nullable":true},"bio":{"type":"string","nullable":true},"photoUrl":{"type":"string","format":"uri","nullable":true}}},"ClinicalNote":{"type":"object","description":"Professional clinical note for one visit. Not Appointment.notes. Sync statuses: DRAFT, PENDING, SYNCED, ERROR, CONFLICT.","properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"appointmentId":{"type":"string","format":"uuid"},"authorProfessionalId":{"type":"string","format":"uuid"},"body":{"type":"string"},"syncStatus":{"type":"string","enum":["DRAFT","PENDING","SYNCED","ERROR","CONFLICT"]},"contentHash":{"type":"string"},"caluExternalId":{"type":"string","nullable":true},"caluDeepLink":{"type":"string","nullable":true},"syncedAt":{"type":"string","format":"date-time","nullable":true},"lastError":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"appointmentStartsAt":{"type":"string","format":"date-time"}}},"AppointmentAuthOverride":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"appointmentId":{"type":"string","format":"uuid"},"fromStatus":{"type":"string","nullable":true,"description":"Previous appointment.authStatus before the override."},"toStatus":{"type":"string","enum":["AUTHORIZED","NEEDS_DESK","FAILED"]},"reason":{"type":"string"},"actorUserId":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"}}},"Appointment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid","nullable":true},"professionalId":{"type":"string","format":"uuid"},"serviceId":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["ADVISOR","PROFESSIONAL"]},"specialty":{"type":"string","nullable":true,"description":"Specialty of this visit. One of the closed list when kind is PROFESSIONAL. Null on admission."},"status":{"type":"string","enum":["DRAFT","SCHEDULED","CHECKED_IN","COMPLETED","CANCELLED","NO_SHOW","OFFERED"]},"modality":{"type":"string","enum":["PRESENCIAL","VIRTUAL"]},"hasMeetingUrl":{"type":"boolean"},"meetingUrl":{"type":"string","nullable":true,"description":"Google Meet link. Returned only for a SCHEDULED or CHECKED_IN virtual visit, from 10 minutes before the start until endsAt. A priced visit stays hidden from the patient until it is paid or staff set entryWithoutPayment. Staff receive it in that same window even if it is unpaid."},"amountCents":{"type":"integer","nullable":true,"description":"Price copied when the visit was published. Null uses the catalog service price. Zero is free."},"amountDueCents":{"type":"integer","description":"What is still charged for this visit after credit from a cancelled paid visit. Zero when credit covers the price. The copago only. A coseguro payment is not included."},"coseguro":{"type":"object","nullable":true,"description":"COSEGURO_DESK. A separate unpaid charge, or null when the paper was paid at the desk, already paid, or not due on this visit. The org name is not included.","properties":{"id":{"type":"string","format":"uuid"},"amountCents":{"type":"integer"},"pendingPaymentId":{"type":"string","format":"uuid","nullable":true}}},"entryOpensAt":{"type":"string","format":"date-time","nullable":true,"description":"When the enter button turns on. Null for in-person visits."},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"usedAdvisorException":{"type":"boolean"},"entryWithoutPayment":{"type":"boolean","description":"Staff allowed this patient into this visit before a payment was recorded. It is not a payment status."},"exceptionReason":{"type":"string","nullable":true},"cancelReason":{"type":"string","nullable":true,"description":"CANCEL_KEEP. Patient reason id stored on this cancellation. Null when staff cancelled or the visit is open."},"cancelNote":{"type":"string","nullable":true,"description":"Optional note when cancelReason is OTRO."},"cancelMoney":{"type":"object","description":"CANCEL_KEEP. Derived on GET /api/appointments/{id}. visitStays is the visit payment (particular fee or copago). coseguroStays is the only second fact. Neither becomes credit.","properties":{"visitStays":{"type":"boolean"},"coseguroStays":{"type":"boolean"}}},"notes":{"type":"string","nullable":true,"description":"Internal visit notes. Present only for office staff and the visit's professional. Omitted from patient responses."},"recurrenceId":{"type":"string","format":"uuid","nullable":true},"recurrenceIndex":{"type":"integer","nullable":true,"description":"Zero-based occurrence index within the materialized series."},"recurrenceTotal":{"type":"integer","nullable":true},"recurrence":{"type":"object","nullable":true,"description":"Staff-only series summary when the visit belongs to a recurrence.","properties":{"id":{"type":"string","format":"uuid"},"index":{"type":"integer","nullable":true},"total":{"type":"integer","nullable":true},"rule":{"$ref":"#/components/schemas/WeeklyRecurrenceRule"}}},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"service":{"$ref":"#/components/schemas/CatalogService"},"professional":{"$ref":"#/components/schemas/Professional"},"patient":{"oneOf":[{"$ref":"#/components/schemas/Patient"},{"type":"null"}]},"payments":{"type":"array","items":{"$ref":"#/components/schemas/AppointmentPayment"}}}},"AppointmentPayment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["PENDING","SUCCEEDED","FAILED","REFUNDED","CANCELLED"]},"amountCents":{"type":"integer"},"currency":{"type":"string"},"provider":{"type":"string","enum":["MOCK","MERCADO_PAGO","PAYPAL"]},"createdAt":{"type":"string","format":"date-time"}}},"AppointmentList":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Appointment"}},"chartCancellations":{"type":"array","description":"CANCEL_KEEP. Staff lists only. Latest patient cancel reason per chart. Not filtered by from or to. A professional sees only their own visits. The ficha reads this record.","items":{"type":"object","required":["appointmentId","patientId","professionalId","reason","label","startsAt"],"properties":{"appointmentId":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"professionalId":{"type":"string","format":"uuid"},"reason":{"type":"string"},"label":{"type":"string"},"note":{"type":"string","nullable":true},"startsAt":{"type":"string","format":"date-time"}}}}}},"CreateAppointmentRequest":{"type":"object","required":["professionalId","serviceId","kind","startsAt","endsAt"],"properties":{"patientId":{"type":"string","format":"uuid","description":"Omit to publish an open slot. Office staff may omit it for any professional. A professional may omit it only for their own professional session."},"professionalId":{"type":"string","format":"uuid"},"serviceId":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["ADVISOR","PROFESSIONAL"]},"specialty":{"type":"string","enum":["Psicología","Psiquiatría","Nutrición","Fonoaudiología","Psicopedagogía","Neuropsicología","Terapia de familia"],"description":"Required for a professional visit. Omit on admission. Every clinician can give every specialty."},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"modality":{"type":"string","enum":["PRESENCIAL","VIRTUAL"],"description":"Virtual visits receive a Meet link from Google Calendar. Do not send a URL."},"exceptionReason":{"type":"string"},"notes":{"type":"string","maxLength":2000,"description":"Internal notes. Stored on the visit; patients never receive this field."},"overbook":{"type":"boolean","description":"Staff only. Required to place this visit on top of another occupied hour. Without it the API returns 409 OVERLAP_UNCONFIRMED. A patient cannot set it. Calendar blocks still return 409 SLOT_BLOCKED."}}},"WeeklyRecurrenceRule":{"type":"object","required":["intervalWeeks","byWeekday","excludeDates"],"description":"Weekly series in America/Argentina/Buenos_Aires. byWeekday uses ISO 1=Mon…7=Sun. Exactly one of count or until.","properties":{"intervalWeeks":{"type":"integer","minimum":1,"maximum":12},"byWeekday":{"type":"array","minItems":1,"maxItems":7,"items":{"type":"integer","minimum":1,"maximum":7}},"count":{"type":"integer","minimum":2,"maximum":52},"until":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"Inclusive end date YYYY-MM-DD in the clinic zone."},"excludeDates":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}}}},"CreateRecurringAppointmentsRequest":{"allOf":[{"$ref":"#/components/schemas/CreateAppointmentRequest"},{"type":"object","required":["recurrence"],"properties":{"recurrence":{"type":"object","required":["intervalWeeks"],"description":"Omit byWeekday to repeat on the weekday of startsAt. Send exactly one of count or until.","properties":{"intervalWeeks":{"type":"integer","minimum":1,"maximum":12},"byWeekday":{"type":"array","minItems":1,"maxItems":7,"items":{"type":"integer","minimum":1,"maximum":7}},"count":{"type":"integer","minimum":2,"maximum":52},"until":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"excludeDates":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}}}}}}]},"PatchAppointmentSeriesRequest":{"type":"object","required":["scope"],"description":"Exactly one action: startsAt+endsAt, exclude, cancel, or recurrence. exclude is THIS only. Rule changes need FOLLOWING or ALL.","properties":{"scope":{"type":"string","enum":["THIS","FOLLOWING","ALL"]},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"overbook":{"type":"boolean","description":"Staff confirmation that the new times may sit on top of another visit. Without it, overlap returns 409 OVERLAP_UNCONFIRMED."},"exclude":{"type":"boolean","description":"Skip THIS occurrence and add its clinic date to excludeDates."},"cancel":{"type":"boolean","description":"Cancel open occurrences in scope (OFFERED rows are deleted)."},"recurrence":{"type":"object","description":"Partial rule update for FOLLOWING or ALL; regenerates open rows in scope.","properties":{"intervalWeeks":{"type":"integer","minimum":1,"maximum":12},"byWeekday":{"type":"array","minItems":1,"maxItems":7,"items":{"type":"integer","minimum":1,"maximum":7}},"count":{"type":"integer","minimum":2,"maximum":52},"until":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"excludeDates":{"type":"array","items":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}}}}}},"UpdateAppointmentRequest":{"type":"object","description":"Send status (an advisor COMPLETED may include specialty), both startsAt and endsAt, slotId, entryWithoutPayment, patientId, notes, or amountCents alone. amountCents is SECRETARY or ADMIN and corrects the stored charge of an unpaid visit. A succeeded copago payment returns 409 COPAY_ALREADY_PAID. A succeeded coseguro charge does not. patientId is office or the slot's professional and atomically occupies an existing OFFERED slot through the same advisor gates as patient claim, without creating another row. notes is office or the visit's professional; patients never receive notes. Patients may set CANCELLED from DRAFT or SCHEDULED. Cancelling any future booked visit—by the patient, office, or its professional—puts that hour back on offer and keeps the Meet room; the payment stays on the cancelled row. Permanent DELETE never republishes the hour. A completed advisor interview cannot be deleted (409 ADMISSION_KEEP); NO_SHOW on that interview reopens admission. Changing startsAt and endsAt on a future booked visit offers the previous hour again when the new range does not overlap it, and removes an unassigned hour that already covers the new time so the visit does not sit beside it. slotId moves the same appointment onto a free slot of the same professional and service; the vacated time is offered again. Payments stay on the row. Office staff may follow the status machine, and may set NO_SHOW on a COMPLETED visit. A professional may set CHECKED_IN, COMPLETED, NO_SHOW, or CANCELLED on their own booked visit, assign a patient onto their own open hour, and write notes on their own visits. The professional of the visit and office staff may set entryWithoutPayment so the patient can open the Meet link before paying. A SCHEDULED or CHECKED_IN visit with a patient becomes COMPLETED on the next read after endsAt. An unclaimed slot becomes CANCELLED on the next read after endsAt.","properties":{"patientId":{"type":"string","format":"uuid","description":"Office or the slot's professional. Claims this existing OFFERED row for the patient."},"notes":{"type":"string","nullable":true,"maxLength":2000,"description":"Internal notes. Office and the visit's professional may set them. Empty or null clears the field. Patients never receive notes."},"slotId":{"type":"string","format":"uuid","description":"An OFFERED slot of the same professional and kind that carries the same service or lasts the same. Otherwise SLOT_MISMATCH."},"overbook":{"type":"boolean","description":"With startsAt and endsAt. Staff confirmation of a sobreturno. Ignored for a patient."},"status":{"type":"string","enum":["DRAFT","SCHEDULED","CHECKED_IN","COMPLETED","CANCELLED","NO_SHOW"]},"specialty":{"type":"string","maxLength":80,"description":"With status COMPLETED on an advisor interview. Stores that specialty on the chart with no professional. Omit it when the chart already has a specialty."},"cancelReason":{"type":"string","maxLength":40,"description":"CANCEL_KEEP. Required when a patient sets status CANCELLED. One of NO_PUEDO, OTRO_HORARIO, CAMBIAR_PROFESIONAL, TEMA_PERSONAL, OTRO. Staff omit it."},"cancelNote":{"type":"string","maxLength":280,"description":"Optional. Kept only when cancelReason is OTRO."},"startsAt":{"type":"string","format":"date-time"},"endsAt":{"type":"string","format":"date-time"},"entryWithoutPayment":{"type":"boolean","description":"When true, the patient may open the Meet link before payment. Completing the visit adds its unpaid amount to the patient balance. Only office and the visit's professional may set this (authorization of PAY_AFTER_VISIT)."},"payAfterRequestedAt":{"type":"string","format":"date-time","nullable":true,"description":"When set, the patient asked to pay after the visit. Staff/professional authorize with entryWithoutPayment."},"payAfterRequested":{"type":"boolean","description":"Patient (or staff clearing the request) sets this on PATCH. true records payAfterRequestedAt; false clears it. Does not grant entry."},"amountCents":{"type":"integer","minimum":0,"description":"Alone. SECRETARY or ADMIN correct the stored charge of a visit that has no succeeded copago payment. Visits already booked are unchanged until this is sent."}}},"Payment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"appointmentId":{"type":"string","format":"uuid","nullable":true},"provider":{"type":"string","enum":["MOCK","MERCADO_PAGO","PAYPAL"]},"status":{"type":"string","enum":["PENDING","SUCCEEDED","FAILED","REFUNDED","CANCELLED"]},"amountCents":{"type":"integer"},"currency":{"type":"string"},"externalId":{"type":"string","nullable":true},"checkoutUrl":{"type":"string","nullable":true,"description":"Sandbox Checkout Pro URL. Present for a pending MERCADO_PAGO test payment. Live init_point is never returned."},"metadata":{"type":"object","additionalProperties":true,"nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"SyncPaymentRequest":{"type":"object","properties":{"providerPaymentId":{"type":"string","pattern":"^[0-9]{1,20}$","description":"Mercado Pago payment id from the patient return URL (payment_id or collection_id). The API reads that test payment when its external_reference is this row. An empty body still searches by external_reference."}}},"CreatePaymentRequest":{"type":"object","required":["patientId"],"description":"A visit payment sends amountCents and currency. A balance payment sends balance true and method CHECKOUT or ALIAS. A coseguro payment sends coseguroRecordId and appointmentId and no amount: the charge is the paper total, through the same Mercado Pago checkout, and is not added to the visit. The API sums completed visits that were entered before payment and still have no recorded payment. CHECKOUT returns a sandbox checkoutUrl. ALIAS returns the alias, CVU, amount, and concept. A transfer is recorded only when Mercado Pago reports that concept and the same amount.","properties":{"patientId":{"type":"string","format":"uuid"},"appointmentId":{"type":"string","format":"uuid"},"coseguroRecordId":{"type":"string","format":"uuid","description":"COSEGURO_DESK. With appointmentId, starts the separate coseguro checkout."},"amountCents":{"type":"integer"},"currency":{"type":"string"},"balance":{"type":"boolean"},"method":{"type":"string","enum":["CHECKOUT","ALIAS"]},"provider":{"type":"string","enum":["MOCK","MERCADO_PAGO","PAYPAL"],"default":"MOCK","description":"MERCADO_PAGO requires appointmentId and the catalog amount. It returns checkoutUrl for the sandbox. Use the Access Token from Credenciales de prueba."}}},"FeatureFlag":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"key":{"type":"string"},"description":{"type":"string","nullable":true},"enabled":{"type":"boolean"},"updatedBy":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"FeatureFlagList":{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/FeatureFlag"}}}},"UpdateFeatureFlagRequest":{"type":"object","required":["enabled"],"properties":{"enabled":{"type":"boolean"}}}}}}