{"openapi":"3.0.3","info":{"title":"API externa Emergencias Salud","version":"1","description":"API que permite consultar precios, crear y borrar protocolos médicos.   Incluye flujo de creación automática de afiliado cuando no existe.\n"},"servers":[{"description":"SwaggerHub API Auto Mocking","url":"https://virtserver.swaggerhub.com/sirius-45c/emergencias-external-api/1"},{"description":"SwaggerHub API Auto Mocking","url":"https://virtserver.swaggerhub.com/sirius-9c8/emergencias-external-api/1"},{"url":"https://api.example.com/external/v1","description":"Servidor de ejemplo"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-Api-Key"}},"schemas":{"PricingRequest":{"type":"object","description":"Consulta de precios/cobertura. Si `createIfNotFound = true`, se intentará crear un afiliado/beneficiario con `affiliateData` y luego se realizará el pricing.\n","properties":{"medicalServicesCodes":{"type":"array","items":{"type":"string"},"minItems":1},"salesforceBranchId":{"type":"string"},"createIfNotFound":{"type":"boolean","description":"Crear automáticamente un afiliado/beneficiario si no existe."},"creationType":{"type":"string","enum":["AFFILIATE","BENEFICIARY"],"description":"Tipo de entidad a crear si no existe."},"affiliateData":{"type":"object","description":"Datos para creación de afiliado/beneficiario.","properties":{"document":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"birthDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"email":{"type":"string"},"phone":{"type":"string"},"gender":{"type":"string","enum":["M","F","X"]},"address":{"type":"object","properties":{"street":{"type":"string"},"city":{"type":"string"},"province":{"type":"string"},"postalCode":{"type":"string"}},"required":["street","city","province","postalCode"],"additionalProperties":false},"planId":{"type":"string"}},"required":["document","firstName","lastName","birthDate"],"additionalProperties":false}},"required":["medicalServicesCodes"],"additionalProperties":false},"PricingResponse":{"type":"object","properties":{"createdAffiliate":{"type":"object","description":"Presente solo si se creó el afiliado/beneficiario en este request.","properties":{"affiliateId":{"type":"string"},"affiliateNumber":{"type":"string"},"fullName":{"type":"string"},"document":{"type":"string"},"birthDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"planName":{"type":"string"},"coverageId":{"type":"string"},"status":{"type":"string","enum":["ACTIVE","PENDING","INACTIVE"]},"createdAt":{"type":"string","format":"date-time"}},"required":["affiliateId","fullName","document","status","createdAt"],"additionalProperties":false},"coveredByProvider":{"type":"array","items":{"type":"object","properties":{"status":{"type":"string","enum":["COVERED_BY_PLAN","COVERED_BY_SESSION","NOT_COVERED_BY_PLAN","NOT_ENOUGH_DAYS_TO_PAY","NO_MORE_AVAILABLE_SESSIONS"]},"affiliateName":{"type":"string"},"affiliateNumber":{"type":"string"},"document":{"type":"string"},"medicalServiceId":{"type":"string"},"medicalServiceName":{"type":"string"},"medicalServiceCode":{"type":"string"},"medicalServiceCategory":{"type":"string"},"usedSessions":{"type":"number"},"totalSessions":{"type":"number"},"planName":{"type":"string"},"planId":{"type":"string"},"tariff":{"type":"string","enum":["SI",false]},"needsToPay":{"type":"number","minimum":0},"feeStatus":{"type":"string","enum":["ok","feeNeeded"]},"tooltip":{"type":"string"}},"required":["status","affiliateName","affiliateNumber","document","medicalServiceId","medicalServiceName","medicalServiceCode","medicalServiceCategory"],"additionalProperties":true}},"notCoveredByProvider":{"type":"array","items":{"type":"object","properties":{"medicalServiceId":{"type":"string"},"medicalServiceName":{"type":"string"},"medicalServiceDescription":{"type":"string"},"medicalServiceCode":{"type":"string"},"medicalServiceCategory":{"type":"string"},"daysToPay":{"type":"number"}},"required":["medicalServiceId"],"additionalProperties":true}},"flagAmount":{"type":"boolean"}},"additionalProperties":false},"CreateProtocolRequest":{"type":"object","properties":{"document":{"type":"string"},"medicalServicesWithPreferentialFee":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"preferentialFee":{"type":"number","minimum":0}},"required":["code"],"additionalProperties":false},"minItems":1},"salesforceBranchId":{"type":"string"},"paymentMethod":{"type":"string","enum":["EFECTIVO","TRANSFERENCIA","QR","TARJETA DE CREDITO","TARJETA DE DEBITO"]},"paymentMethodType":{"type":"string","enum":["MASTERCARD DEBITO","MAESTRO","CABAL DEBITO","VISA DEBITO","CABAL","MASTERCARD","NARANJA","VISA"]},"operationNumber":{"type":"string"}},"required":["medicalServicesWithPreferentialFee"],"additionalProperties":false},"CreateProtocolResponse":{"type":"object","properties":{"response":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"status":{"type":"string","enum":["COVERED_BY_PLAN","COVERED_BY_SESSION","NOT_COVERED_BY_PLAN","NOT_ENOUGH_DAYS_TO_PAY","NO_MORE_AVAILABLE_SESSIONS"]},"affiliateName":{"type":"string"},"document":{"type":"string"},"affiliateNumber":{"type":"string"},"medicalServiceName":{"type":"string"},"medicalServiceCode":{"type":"string"},"medicalServiceCategory":{"type":"string"},"feeUsed":{"type":"boolean"},"tariff":{"type":"string","enum":["SI",false]},"needsToPay":{"type":"number","minimum":0},"planName":{"type":"string"}},"required":["status","affiliateName","document","affiliateNumber","medicalServiceName","medicalServiceCode","medicalServiceCategory","feeUsed"],"additionalProperties":true},{"type":"object","properties":{"status":{"type":"string","enum":["COVERED_BY_PLAN"]},"affiliateName":{"type":"string"},"document":{"type":"string"},"affiliateNumber":{"type":"string"},"medicalServiceName":{"type":"string"},"medicalServiceCode":{"type":"string"},"medicalServiceCategory":{"type":"string"},"feeUsed":{"type":"boolean"},"affiliateId":{"type":"string"},"amount":{"type":"number","minimum":0}},"required":["status","affiliateName","document","affiliateNumber","medicalServiceName","medicalServiceCode","medicalServiceCategory","feeUsed","affiliateId","amount"],"additionalProperties":true}]}},"message":{"type":"string"},"protocolId":{"type":"string"}},"required":["response","message"],"additionalProperties":false},"DeleteProtocolResponse":{"type":"object","properties":{"result":{"type":"object","properties":{"protocolId":{"type":"string"},"medicalServiceId":{"type":"string"},"branchId":{"type":"string"},"affiliateId":{"type":"string"},"coverageId":{"type":"string"},"amountPaid":{"type":"number"},"observations":{"type":"string"},"createdDate":{"type":"string"}},"required":["protocolId","medicalServiceId","branchId","affiliateId","coverageId","amountPaid","observations","createdDate"],"additionalProperties":true}},"required":["result"],"additionalProperties":false},"ErrorResponse":{"type":"object","properties":{"code":{"type":"string","enum":["AFFILIATE_NOT_FOUND","NOT_COVERED_BY_PROVIDER","VALIDATION_ERROR","UNAUTHORIZED","RATE_LIMITED","CONFLICT","INTERNAL_ERROR"]},"message":{"type":"string"},"context":{"type":"object","additionalProperties":true},"requestId":{"type":"string"}},"required":["code","message"],"additionalProperties":false}}},"paths":{"/pricing":{"post":{"summary":"Consulta de precios","description":"Permite consultar los precios y coberturas para servicios médicos.   Si el afiliado no existe y `createIfNotFound = true`, se creará automáticamente utilizando los datos provistos en `affiliateData`.\n","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PricingRequest"},"example":{"medicalServicesCodes":["a1oPB000006HTN9YAO","a1oPB000006HTNBYA4"],"salesforceBranchId":"a1o2K000002bcbhQAA","createIfNotFound":true,"creationType":"BENEFICIARY","affiliateData":{"document":"32199042","firstName":"Jane","lastName":"Doe","birthDate":"1990-05-20","email":"jane.doe@example.com","phone":"123456789","gender":"F","address":{"street":"Av. Siempre Viva 742","city":"Springfield","province":"Buenos Aires","postalCode":"1000"}}}}}},"responses":{"200":{"description":"Respuesta exitosa con detalle de cobertura.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PricingResponse"},"example":{"coveredByProvider":[{"status":"COVERED_BY_PLAN","affiliateName":"Jane Doe","affiliateNumber":"E610331/002","document":"32199042","medicalServiceId":"a1oPB000006HTN9YAO","medicalServiceName":"Consulta clínica","medicalServiceCode":"CONS-001","medicalServiceCategory":"CONSULTAS","usedSessions":1,"totalSessions":4,"planName":"Plan Oro","planId":"003xx00000covId","tariff":"NO","needsToPay":1500,"feeStatus":"ok","tooltip":"Se aplicó la regla de copago: por cada 4 atenciones se paga 1 copago..."}],"notCoveredByProvider":[{"medicalServiceId":"a1oPB000006HTNBYA4","medicalServiceName":"Estudio X","medicalServiceDescription":"Desc","medicalServiceCode":"EST-123","medicalServiceCategory":"IMAGENES","daysToPay":30}],"flagAmount":false}}}},"201":{"description":"Respuesta exitosa con detalle de cobertura y creación de beneficiario.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PricingResponse"},"example":{"createdAffiliate":{"document":"32199042","firstName":"Jane","lastName":"Doe","birthDate":"1990-05-20","email":"jane.doe@example.com","phone":"123456789","gender":"F","address":{"street":"Av. Siempre Viva 742","city":"Springfield","province":"Buenos Aires","postalCode":"1000"}},"coveredByProvider":[{"status":"COVERED_BY_PLAN","affiliateName":"Jane Doe","affiliateNumber":"E610331/002","document":"32199042","medicalServiceId":"a1oPB000006HTN9YAO","medicalServiceName":"Consulta clínica","medicalServiceCode":"CONS-001","medicalServiceCategory":"CONSULTAS","usedSessions":1,"totalSessions":4,"planName":"Plan Oro","planId":"003xx00000covId","tariff":"NO","needsToPay":1500,"feeStatus":"ok","tooltip":"Se aplicó la regla de copago: por cada 4 atenciones se paga 1 copago..."}],"notCoveredByProvider":[{"medicalServiceId":"a1oPB000006HTNBYA4","medicalServiceName":"Estudio X","medicalServiceDescription":"Desc","medicalServiceCode":"EST-123","medicalServiceCategory":"IMAGENES","daysToPay":30}],"flagAmount":false}}}},"400":{"description":"Error de validación o datos inválidos.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"VALIDATION_ERROR","message":"Invalid request payload"}}}},"401":{"description":"No autorizado (API key inválida o ausente).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"UNAUTHORIZED","message":"Missing or invalid API key"}}}},"404":{"description":"Afiliado/beneficiario no encontrado (cuando no se solicita creación).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"AFFILIATE_NOT_FOUND","message":"No affiliate found for provided identifiers.","context":{"identifiers":{"affiliateNumber":"E610331/002","document":"32199042"}}}}}},"409":{"description":"Conflicto (estado inconsistente para pricing).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"CONFLICT","message":"Pricing conflict"}}}},"429":{"description":"Demasiadas solicitudes.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"RATE_LIMITED","message":"Rate limit exceeded"}}}},"500":{"description":"Error interno del servidor.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"INTERNAL_ERROR","message":"Unexpected error"}}}}}}},"/protocols":{"post":{"summary":"Crear protocolos","description":"Crea una o más atenciones médicas asociadas a un afiliado.","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProtocolRequest"},"example":{"affiliateNumber":"E610331/002","document":"32199042","medicalServicesWithPreferentialFee":[{"code":"a1oPB000006HTN9YAO"},{"code":"a1oPB000006HTNBYA4","preferentialFee":1000}],"salesforceBranchId":"a1o2K000002bcbhQAA","paymentMethod":"TARJETA DE CREDITO","paymentMethodType":"VISA","operationNumber":"OP-123456"}}}},"responses":{"200":{"description":"Protocolo creadas exitosamente.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProtocolResponse"},"example":{"response":[{"status":"COVERED_BY_PLAN","document":"32199042","affiliateNumber":"E610331/002","medicalServiceName":"Consulta clínica","medicalServiceCode":"CONS-001","medicalServiceCategory":"CONSULTAS","feeUsed":false,"tariff":"NO","needsToPay":1500,"planName":"Plan Oro"},{"status":"COVERED_BY_PLAN","affiliateName":"Jane Doe","document":"32199042","affiliateNumber":"E610331/002","medicalServiceName":"Práctica Y","medicalServiceCode":"PRAC-002","medicalServiceCategory":"OTROS","feeUsed":true,"affiliateId":"003xx00000affId","amount":5000}],"message":"The protocol was created successfully","protocolId":"PROT-00000001"}}}},"400":{"description":"Error de validación o datos inválidos.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"VALIDATION_ERROR","message":"Invalid request payload"}}}},"401":{"description":"No autorizado (API key inválida o ausente).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"UNAUTHORIZED","message":"Missing or invalid API key"}}}},"409":{"description":"Prestaciones no cubiertas por el proveedor (no se puede crear el protocolo).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"NOT_COVERED_BY_PROVIDER","message":"Some medical services are not covered by provider","context":{"notCovered":[{"medicalServiceId":"a1oPB000006HTNBYA4"}]}}}}},"500":{"description":"Error interno del servidor.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"INTERNAL_ERROR","message":"Unexpected error"}}}}}}},"/procotols/{protocolId}":{"delete":{"summary":"Borrar protocolo","description":"Elimina un protocolo médico existente.","security":[{"ApiKeyAuth":[]}],"parameters":[{"in":"path","name":"protocolId","required":true,"schema":{"type":"string"},"description":"ID del protocolo a eliminar"}],"responses":{"200":{"description":"Protocolo eliminado correctamente.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteProtocolResponse"},"example":{"result":{"protocolId":"a1t2K00000N0zIoQAJ","medicalServiceId":"a1oPB000006HTN9YAO","branchId":"a1o2K000002bcbhQAA","affiliateId":"003xx00000affId","coverageId":"003xx00000covId","amountPaid":1500,"observations":"manualFee","createdDate":"2025-10-06T10:30:00.000Z"}}}}},"400":{"description":"Error de validación (ID inválido o no cancelable).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"VALIDATION_ERROR","message":"Protocol cannot be deleted or id is invalid"}}}},"401":{"description":"No autorizado (API key inválida o ausente).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"UNAUTHORIZED","message":"Missing or invalid API key"}}}},"500":{"description":"Error interno del servidor.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"code":"INTERNAL_ERROR","message":"Unexpected error"}}}}}}}}}