{ "openapi": "3.0.1", "info": { "title": "MediConnect API (Partial Spec)", "version": "0.1.0-draft", "description": "Spec consolidada a partir dos blocos fornecidos. Contém TODOs para endpoints não formalizados (foto/anexos/CPF/SMS)." }, "servers": [ { "url": "https://yuanqfswhberkoevtmfr.supabase.co", "description": "Prod Env" } ], "tags": [ { "name": "Authentication" }, { "name": "Usuários" }, { "name": "Perfis" }, { "name": "Médicos" }, { "name": "Pacientes" }, { "name": "Relatórios" }, { "name": "Atribuições" }, { "name": "TODO" } ], "paths": { "/auth/v1/token": { "post": { "tags": ["Authentication"], "summary": "Fazer login e obter token JWT", "parameters": [ { "name": "grant_type", "in": "query", "required": true, "schema": { "type": "string", "enum": ["password"] } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginResponse" } } } }, "400": { "description": "Credenciais inválidas" }, "401": { "description": "Email ou senha incorretos" } } } }, "/auth/v1/logout": { "post": { "tags": ["Authentication"], "summary": "Logout do usuário", "responses": { "204": { "description": "Logout realizado" }, "401": { "description": "Token inválido" } } } }, "/auth/v1/user": { "get": { "tags": ["Authentication", "Usuários"], "summary": "Obter dados do usuário atual", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } }, "401": { "description": "Token inválido" } } } }, "/functions/v1/user-info": { "get": { "tags": ["Usuários"], "summary": "Obter informações completas do usuário", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserInfoResponse" } } } }, "401": { "description": "Não autorizado" }, "500": { "description": "Erro interno" } } } }, "/functions/v1/create-user": { "post": { "tags": ["Usuários"], "summary": "Criar novo usuário", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateUserRequest" } } } }, "responses": { "200": { "description": "Criado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateUserResponse" } } } }, "400": { "description": "Dados inválidos" }, "401": { "description": "Não autorizado" }, "403": { "description": "Sem permissão" }, "500": { "description": "Erro interno" } } } }, "/rest/v1/user_roles": { "get": { "tags": ["Usuários"], "summary": "Listar roles de usuários", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/UserRole" } } } } } } } }, "/rest/v1/profiles": { "get": { "tags": ["Perfis"], "summary": "Listar perfis", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Profile" } } } } } } }, "patch": { "tags": ["Perfis"], "summary": "Atualizar perfil (apenas próprio)", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProfileInput" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Profile" } } } } } } }, "/rest/v1/doctors": { "get": { "tags": ["Médicos"], "summary": "Listar médicos", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Doctor" } } } } } } }, "post": { "tags": ["Médicos"], "summary": "Criar médico", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DoctorCreate" } } } }, "responses": { "201": { "description": "Criado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Doctor" } } } } } } }, "/rest/v1/doctors/{id}": { "get": { "tags": ["Médicos"], "summary": "Buscar médico por ID", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Doctor" } } } }, "404": { "description": "Não encontrado" } } }, "patch": { "tags": ["Médicos"], "summary": "Atualizar médico", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DoctorUpdate" } } } }, "responses": { "200": { "description": "OK" }, "404": { "description": "Não encontrado" } } }, "delete": { "tags": ["Médicos"], "summary": "Deletar médico", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "204": { "description": "Removido" }, "404": { "description": "Não encontrado" } } } }, "/rest/v1/patients": { "get": { "tags": ["Pacientes"], "summary": "Listar pacientes", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Patient" } } } } } } }, "post": { "tags": ["Pacientes"], "summary": "Criar paciente", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PatientInput" } } } }, "responses": { "201": { "description": "Criado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Patient" } } } } } } }, "/rest/v1/patients/{id}": { "get": { "tags": ["Pacientes"], "summary": "Obter paciente por ID", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK" }, "404": { "description": "Não encontrado" } } }, "patch": { "tags": ["Pacientes"], "summary": "Atualizar paciente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PatientInput" } } } }, "responses": { "200": { "description": "OK" }, "404": { "description": "Não encontrado" } } }, "delete": { "tags": ["Pacientes"], "summary": "Deletar paciente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "204": { "description": "Removido" }, "404": { "description": "Não encontrado" } } } }, "/rest/v1/reports": { "get": { "tags": ["Relatórios"], "summary": "Listar relatórios", "parameters": [ { "name": "patient_id", "in": "query", "schema": { "type": "string", "format": "uuid" } }, { "name": "status", "in": "query", "schema": { "type": "string", "enum": ["draft", "pending", "completed", "cancelled"] } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Report" } } } } } } }, "post": { "tags": ["Relatórios"], "summary": "Criar relatório", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ReportInput" } } } }, "responses": { "201": { "description": "Criado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Report" } } } } } } }, "/rest/v1/reports/{id}": { "get": { "tags": ["Relatórios"], "summary": "Obter relatório por ID", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK" }, "404": { "description": "Não encontrado" } } }, "patch": { "tags": ["Relatórios"], "summary": "Atualizar relatório", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ReportInput" } } } }, "responses": { "200": { "description": "OK" }, "404": { "description": "Não encontrado" } } } }, "/rest/v1/patient_assignments": { "get": { "tags": ["Atribuições"], "summary": "Listar atribuições", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PatientAssignment" } } } } } } }, "post": { "tags": ["Atribuições"], "summary": "Criar atribuição", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PatientAssignmentInput" } } } }, "responses": { "201": { "description": "Criado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PatientAssignment" } } } } } } }, "/auth/v1/pacientes/{id}/foto": { "post": { "tags": ["Pacientes"], "summary": "Upload foto paciente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "content": { "multipart/form-data": { "schema": { "type": "object", "properties": { "foto": { "type": "string", "format": "binary" } }, "required": ["foto"] } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "foto_url": { "type": "string", "nullable": true }, "thumbnail_url": { "type": "string", "nullable": true } } } } } }, "401": { "description": "Não autorizado" }, "404": { "description": "Paciente não encontrado" } } }, "delete": { "tags": ["Pacientes"], "summary": "Remover foto paciente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "204": { "description": "Removido" }, "401": { "description": "Não autorizado" }, "404": { "description": "Paciente não encontrado" } } } }, "/auth/v1/pacientes/{id}/anexos": { "get": { "tags": ["Pacientes"], "summary": "Listar anexos do paciente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/PacienteAnexo" } } } } }, "401": { "description": "Não autorizado" }, "404": { "description": "Paciente não encontrado" } } }, "post": { "tags": ["Pacientes"], "summary": "Adicionar anexo ao paciente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "content": { "multipart/form-data": { "schema": { "type": "object", "properties": { "arquivo": { "type": "string", "format": "binary" } }, "required": ["arquivo"] } } } }, "responses": { "201": { "description": "Criado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PacienteAnexo" } } } }, "401": { "description": "Não autorizado" }, "404": { "description": "Paciente não encontrado" } } } }, "/auth/v1/pacientes/{id}/anexos/{anexoId}": { "delete": { "tags": ["Pacientes"], "summary": "Remover anexo do paciente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "anexoId", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "204": { "description": "Removido" }, "401": { "description": "Não autorizado" }, "404": { "description": "Não encontrado" } } } }, "/pacientes/validar-cpf": { "post": { "tags": ["Pacientes"], "summary": "Validar CPF de paciente (existência e formato)", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "cpf": { "type": "string" } }, "required": ["cpf"] } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ValidacaoCPF" } } } }, "400": { "description": "CPF inválido" } } } }, "/functions/v1/sms": { "post": { "tags": ["TODO"], "summary": "[FUTURO] Enviar SMS", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "to": { "type": "string" }, "message": { "type": "string" } }, "required": ["to", "message"] } } } }, "responses": { "202": { "description": "Aceito para processamento" }, "400": { "description": "Payload inválido" } } } } }, "components": { "schemas": { "LoginRequest": { "type": "object", "required": ["email", "password"], "properties": { "email": { "type": "string", "format": "email" }, "password": { "type": "string", "minLength": 6 } } }, "AuthUser": { "type": "object", "properties": { "id": { "type": "string" }, "email": { "type": "string", "format": "email" }, "email_confirmed_at": { "type": "string", "format": "date-time", "nullable": true }, "created_at": { "type": "string", "format": "date-time" } } }, "LoginResponse": { "type": "object", "properties": { "access_token": { "type": "string" }, "token_type": { "type": "string" }, "expires_in": { "type": "integer" }, "refresh_token": { "type": "string" }, "user": { "$ref": "#/components/schemas/AuthUser" } } }, "Error": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" } } }, "User": { "type": "object", "properties": { "id": { "type": "string" }, "email": { "type": "string", "format": "email" }, "email_confirmed_at": { "type": "string", "format": "date-time", "nullable": true }, "created_at": { "type": "string", "format": "date-time" }, "last_sign_in_at": { "type": "string", "format": "date-time", "nullable": true } } }, "Profile": { "type": "object", "properties": { "id": { "type": "string" }, "full_name": { "type": "string", "nullable": true }, "email": { "type": "string", "nullable": true }, "phone": { "type": "string", "nullable": true }, "avatar_url": { "type": "string", "nullable": true }, "disabled": { "type": "boolean" }, "created_at": { "type": "string" }, "updated_at": { "type": "string" } } }, "ProfileInput": { "type": "object", "properties": { "full_name": { "type": "string" }, "avatar_url": { "type": "string" }, "phone": { "type": "string" } } }, "DoctorCreate": { "type": "object", "required": ["crm", "crm_uf", "full_name", "cpf", "email"], "properties": { "user_id": { "type": "string", "nullable": true }, "crm": { "type": "string" }, "crm_uf": { "type": "string" }, "specialty": { "type": "string", "nullable": true }, "full_name": { "type": "string" }, "cpf": { "type": "string" }, "email": { "type": "string" }, "phone_mobile": { "type": "string", "nullable": true }, "phone2": { "type": "string", "nullable": true }, "cep": { "type": "string", "nullable": true }, "street": { "type": "string", "nullable": true }, "number": { "type": "string", "nullable": true }, "complement": { "type": "string", "nullable": true }, "neighborhood": { "type": "string", "nullable": true }, "city": { "type": "string", "nullable": true }, "state": { "type": "string", "nullable": true }, "birth_date": { "type": "string", "nullable": true }, "rg": { "type": "string", "nullable": true }, "active": { "type": "boolean" } } }, "DoctorUpdate": { "type": "object", "properties": { "user_id": { "type": "string", "nullable": true }, "crm": { "type": "string" }, "crm_uf": { "type": "string" }, "specialty": { "type": "string", "nullable": true }, "full_name": { "type": "string" }, "cpf": { "type": "string" }, "email": { "type": "string" }, "phone_mobile": { "type": "string", "nullable": true }, "phone2": { "type": "string", "nullable": true }, "cep": { "type": "string", "nullable": true }, "street": { "type": "string", "nullable": true }, "number": { "type": "string", "nullable": true }, "complement": { "type": "string", "nullable": true }, "neighborhood": { "type": "string", "nullable": true }, "city": { "type": "string", "nullable": true }, "state": { "type": "string", "nullable": true }, "birth_date": { "type": "string", "nullable": true }, "rg": { "type": "string", "nullable": true }, "active": { "type": "boolean" } } }, "Doctor": { "type": "object", "properties": { "id": { "type": "string" }, "user_id": { "type": "string", "nullable": true }, "crm": { "type": "string" }, "crm_uf": { "type": "string" }, "specialty": { "type": "string", "nullable": true }, "full_name": { "type": "string" }, "cpf": { "type": "string" }, "email": { "type": "string" }, "phone_mobile": { "type": "string", "nullable": true }, "phone2": { "type": "string", "nullable": true }, "cep": { "type": "string", "nullable": true }, "street": { "type": "string", "nullable": true }, "number": { "type": "string", "nullable": true }, "complement": { "type": "string", "nullable": true }, "neighborhood": { "type": "string", "nullable": true }, "city": { "type": "string", "nullable": true }, "state": { "type": "string", "nullable": true }, "birth_date": { "type": "string", "nullable": true }, "rg": { "type": "string", "nullable": true }, "active": { "type": "boolean" }, "created_at": { "type": "string" }, "updated_at": { "type": "string" }, "created_by": { "type": "string" }, "updated_by": { "type": "string", "nullable": true } } }, "PatientInput": { "type": "object", "required": ["full_name", "cpf", "email", "phone_mobile"], "properties": { "full_name": { "type": "string" }, "cpf": { "type": "string" }, "email": { "type": "string" }, "phone_mobile": { "type": "string" }, "birth_date": { "type": "string", "nullable": true }, "social_name": { "type": "string", "nullable": true }, "sex": { "type": "string", "nullable": true }, "blood_type": { "type": "string", "nullable": true }, "weight_kg": { "type": "number", "nullable": true }, "height_m": { "type": "number", "nullable": true }, "street": { "type": "string", "nullable": true }, "number": { "type": "string", "nullable": true }, "complement": { "type": "string", "nullable": true }, "neighborhood": { "type": "string", "nullable": true }, "city": { "type": "string", "nullable": true }, "state": { "type": "string", "nullable": true }, "cep": { "type": "string", "nullable": true } } }, "Patient": { "type": "object", "properties": { "id": { "type": "string" }, "full_name": { "type": "string" }, "cpf": { "type": "string" }, "email": { "type": "string" }, "phone_mobile": { "type": "string" }, "birth_date": { "type": "string", "nullable": true }, "social_name": { "type": "string", "nullable": true }, "sex": { "type": "string", "nullable": true }, "blood_type": { "type": "string", "nullable": true }, "weight_kg": { "type": "number", "nullable": true }, "height_m": { "type": "number", "nullable": true }, "bmi": { "type": "number", "nullable": true }, "street": { "type": "string", "nullable": true }, "number": { "type": "string", "nullable": true }, "complement": { "type": "string", "nullable": true }, "neighborhood": { "type": "string", "nullable": true }, "city": { "type": "string", "nullable": true }, "state": { "type": "string", "nullable": true }, "cep": { "type": "string", "nullable": true }, "created_at": { "type": "string" }, "updated_at": { "type": "string" }, "created_by": { "type": "string" } } }, "ReportInput": { "type": "object", "required": ["patient_id", "order_number"], "properties": { "patient_id": { "type": "string" }, "order_number": { "type": "string" }, "exam": { "type": "string", "nullable": true }, "diagnosis": { "type": "string", "nullable": true }, "conclusion": { "type": "string", "nullable": true }, "cid_code": { "type": "string", "nullable": true }, "content_html": { "type": "string", "nullable": true }, "content_json": { "type": "object", "nullable": true }, "status": { "type": "string", "enum": ["draft", "pending", "completed", "cancelled"], "nullable": true }, "requested_by": { "type": "string", "nullable": true }, "due_at": { "type": "string", "nullable": true }, "hide_date": { "type": "boolean", "nullable": true }, "hide_signature": { "type": "boolean", "nullable": true } } }, "Report": { "type": "object", "properties": { "id": { "type": "string" }, "patient_id": { "type": "string" }, "order_number": { "type": "string" }, "exam": { "type": "string", "nullable": true }, "diagnosis": { "type": "string", "nullable": true }, "conclusion": { "type": "string", "nullable": true }, "cid_code": { "type": "string", "nullable": true }, "content_html": { "type": "string", "nullable": true }, "content_json": { "type": "object", "nullable": true }, "status": { "type": "string" }, "requested_by": { "type": "string", "nullable": true }, "due_at": { "type": "string", "nullable": true }, "hide_date": { "type": "boolean", "nullable": true }, "hide_signature": { "type": "boolean", "nullable": true }, "created_at": { "type": "string" }, "updated_at": { "type": "string" }, "created_by": { "type": "string" } } }, "PatientAssignmentInput": { "type": "object", "required": ["patient_id", "user_id", "role"], "properties": { "patient_id": { "type": "string" }, "user_id": { "type": "string" }, "role": { "type": "string", "enum": ["medico", "enfermeiro"] } } }, "PatientAssignment": { "type": "object", "properties": { "id": { "type": "string" }, "patient_id": { "type": "string" }, "user_id": { "type": "string" }, "role": { "type": "string" }, "created_at": { "type": "string" }, "created_by": { "type": "string" } } }, "UserRole": { "type": "object", "properties": { "id": { "type": "string" }, "user_id": { "type": "string" }, "role": { "type": "string" }, "created_at": { "type": "string" } } }, "CreateUserRequest": { "type": "object", "required": ["email", "password", "full_name", "role"], "properties": { "email": { "type": "string" }, "password": { "type": "string" }, "full_name": { "type": "string" }, "phone": { "type": "string", "nullable": true }, "role": { "type": "string", "enum": ["admin", "gestor", "medico", "secretaria", "user"] } } }, "CreateUserResponse": { "type": "object", "properties": { "success": { "type": "boolean" }, "user": { "type": "object", "properties": { "id": { "type": "string" }, "email": { "type": "string" }, "full_name": { "type": "string" }, "phone": { "type": "string", "nullable": true }, "role": { "type": "string" } } } } }, "UserInfoResponse": { "type": "object", "properties": { "user": { "$ref": "#/components/schemas/User" }, "profile": { "$ref": "#/components/schemas/Profile" }, "roles": { "type": "array", "items": { "type": "string" } }, "permissions": { "type": "object", "properties": { "isAdmin": { "type": "boolean" }, "isManager": { "type": "boolean" }, "isDoctor": { "type": "boolean" }, "isSecretary": { "type": "boolean" }, "isAdminOrManager": { "type": "boolean" } } } } }, "PacienteAnexo": { "type": "object", "properties": { "id": { "type": "string" }, "nome": { "type": "string" }, "url": { "type": "string", "nullable": true }, "tipo": { "type": "string", "nullable": true }, "tamanho": { "type": "integer", "nullable": true }, "categoria": { "type": "string", "nullable": true }, "uploaded_at": { "type": "string", "nullable": true }, "uploaded_by": { "type": "string", "nullable": true } } }, "ValidacaoCPF": { "type": "object", "properties": { "valido": { "type": "boolean" }, "existe": { "type": "boolean" }, "paciente_id": { "type": "string", "nullable": true } } } }, "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" } } }, "security": [{ "bearerAuth": [] }] }