Estás integrando la API pública de Telepatia Synapse.
Endpoint: POST /v1/set-consultation-context
Base URL: https://scribe-api.telepatia.ai
Auth: Authorization: Bearer ${SYNAPSE_API_KEY}
Solicitud:
- name [body]: string (opcional, minLength=1, maxLength=500)
- idCountry [body]: string (opcional, enum: 250 values) — Códigos de país ISO 3166-1 alfa-2. Refleja el enum CountryCodes de tanjiro.
- idType [body]: string (opcional, enum: 8 values) — Tipos de documento de identificación del paciente admitidos.
- idValue [body]: string (opcional, minLength=1, maxLength=50)
- patientId [body]: string (opcional, pattern=^sp_[a-z0-9]{16}$) — Id público de un paciente existente (sp_...). Si lo envías, se usa la identidad guardada del paciente y debes omitir los campos de identidad inline (name, idCountry, idType, idValue). Mutuamente excluyente con la identidad inline.
- internalCode [body]: string (opcional, minLength=1, maxLength=128) — Tu propio código de paciente, único por institución. Busca un paciente existente por este código; si ninguno coincide, la identidad inline (name, idCountry, idType, idValue) crea y etiqueta al paciente al iniciar la sesión. Mutuamente excluyente con patientId.
- clinicalContext [body]: object (opcional) — Datos clínicos estructurados del paciente y de la atención: alergias, medicamentos, condiciones, la atención actual y las atenciones anteriores. Consulta /es/scribe-api/consultations#contexto-clínico.
- notes [body]: string (opcional, maxLength=10000)
- pastMedicalHistory [body]: string (opcional, maxLength=10000)
- consultationInternalId [body]: string (opcional, pattern=^[A-Za-z0-9_-]{1,128}$, maxLength=128)
- scribeSessionModality [body]: string (opcional, enum: IN_PERSON, TELEMEDICINE, DICTATION) — Modalidades de sesión de scribe admitidas.
- institutionalBranchId [body]: string (opcional, maxLength=128) — Id de la sede de la institución para esta consulta, que devuelve el endpoint de creación de sedes. Se registra en la sesión de scribe al crearla. Envía el id o el nombre.
- institutionalBranch [body]: string (opcional, maxLength=256) — Nombre de la sede de la institución para esta consulta. Se resuelve cuando no se envía institutionalBranchId. Envía el id o el nombre.
- scribeSessionConfigurationId [body]: string (opcional, maxLength=128) — Id público de una configuración de sesión de scribe (`ssc_` + 16 caracteres `[a-z0-9]`). Mutuamente excluyente con `medicalRecordConfigurationId` y `medicalRecordConfiguration`.
- medicalRecordConfigurationId [body]: string (opcional, maxLength=128) — Id público de una configuración de historia clínica (`mrc_` + 16 caracteres `[a-z0-9]`). Mutuamente excluyente con `scribeSessionConfigurationId` y `medicalRecordConfiguration`.
- medicalRecordConfiguration [body]: object (opcional) — JSON inline de configuración de historia clínica con el nombre de la sección como clave (por ejemplo, 'chiefComplaint'). Se guarda automáticamente y se deduplica por hash de contenido; el id de configuración resuelto se adjunta al buffer de contexto del médico. Mutuamente excluyente con `medicalRecordConfigurationId` y `scribeSessionConfigurationId`.
Éxito 200:
- success: boolean
- consultationInternalId: string
Errores (envoltorio: { error: { type, code, message, param? } }):
- 400: parameter_missing, parameter_invalid, account_invalid
- 401: authentication_required
- 403: permission_denied, permission_denied_role
- 404: resource_not_found
- 409: resource_conflict, resource_not_active
- 413: request_too_large
- 503: service_unavailable
Genera código en el lenguaje del archivo actual. Ese código:
1. Lee SYNAPSE_API_KEY desde el entorno (no la escribas directamente en el código).
2. Llama al endpoint con solicitud y respuesta tipadas.
3. Convierte el envoltorio de errores en excepciones tipadas por código de estado.
4. Agrega una prueba del flujo exitoso usando el token Bearer.
curl -X POST https://scribe-api.telepatia.ai/v1/set-consultation-context \
-H "Authorization: Bearer $SYNAPSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"clinicalContext": {
"allergies": [
{
"code": {
"system": "ATC",
"value": "J01CE01"
},
"id": "ALG-881",
"name": "Penicillin",
"note": "Hives and facial swelling"
}
],
"conditions": [
{
"code": {
"system": "ICD10",
"value": "I10"
},
"id": "CD-120",
"name": "Essential hypertension"
},
{
"code": {
"system": "ICD10",
"value": "E11"
},
"id": "CD-121",
"name": "Type 2 diabetes mellitus"
}
],
"currentEncounter": {
"chiefComplaint": "Severe headache for 2 days, worse in the morning",
"class": "EMERGENCY",
"diagnoses": [
{
"code": {
"system": "ICD10",
"value": "R51"
},
"id": "DG-9001-1",
"name": "Headache"
}
],
"id": "ATD-9001",
"note": "08:50 triage: alert and oriented, no focal deficit. 09:20 ER physician: head CT ordered.",
"procedures": [
{
"id": "PX-9001-1",
"name": "Head CT without contrast"
}
],
"startedAt": "2026-10-15T08:40:00-05:00",
"triagePriority": "Yellow - urgent",
"vitals": {
"diastolicBloodPressure": 102,
"heartRate": 92,
"measuredAt": "2026-10-15T08:55:00-05:00",
"oxygenSaturation": 97,
"painScore": 8,
"respiratoryRate": 18,
"systolicBloodPressure": 168,
"temperature": 36.8
}
},
"medications": [
{
"code": {
"system": "ATC",
"value": "C09CA01"
},
"id": "RX-4410",
"name": "Losartan 50 mg, 1 tablet daily"
},
{
"code": {
"system": "ATC",
"value": "A10BA02"
},
"id": "RX-4411",
"name": "Metformin 850 mg, 1 tablet every 12 hours"
},
{
"code": {
"system": "ATC",
"value": "C07AA05"
},
"id": "RX-4412",
"name": "Propranolol 40 mg, 1 tablet every 12 hours"
},
{
"id": "RX-3982",
"name": "Captopril 25 mg",
"status": "INACTIVE"
}
],
"previousEncounters": [
{
"diagnoses": [
{
"code": {
"system": "ICD10",
"value": "G43.0"
},
"id": "DG-7120-1",
"name": "Migraine without aura"
}
],
"id": "ATD-7120",
"note": "Neurology visit. Started propranolol 40 mg every 12 hours. Follow-up in 3 months.",
"startedAt": "2025-05-02"
},
{
"class": "EMERGENCY",
"diagnoses": [
{
"code": {
"system": "ICD10",
"value": "N39.0"
},
"id": "DG-6044-1",
"name": "Urinary tract infection"
}
],
"id": "ATD-6044",
"note": "Emergency room. Dysuria for 3 days, no fever. Nitrofurantoin for 7 days.",
"startedAt": "2024-11-18"
}
]
},
"consultationInternalId": "CONSULT-12345",
"idCountry": "COLOMBIA",
"idType": "PASSPORT",
"idValue": "A12345678",
"institutionalBranchId": "b1f2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"internalCode": "MRN-000123",
"medicalRecordConfigurationId": "mrc_a1b2c3d4e5f6g7h8",
"name": "John Doe",
"notes": "Patient prefers morning appointments. Allergic to penicillin.",
"pastMedicalHistory": "Hypertension diagnosed 2020. Diabetes Type 2 controlled with metformin.",
"scribeSessionModality": "IN_PERSON"
}'