diff --git a/package-lock.json b/package-lock.json index fe0f642..f2988f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "dependencies": { "@headlessui/react": "^2.2.7", "@heroicons/react": "^2.2.0", + "@supabase/supabase-js": "^2.75.0", "date-fns": "^4.1.0", "react-big-calendar": "^1.19.4", "react-signature-canvas": "^1.1.0-alpha.2" @@ -222,6 +223,80 @@ "react": ">=16.8.0" } }, + "node_modules/@supabase/auth-js": { + "version": "2.75.0", + "resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.75.0.tgz", + "integrity": "sha512-J8TkeqCOMCV4KwGKVoxmEBuDdHRwoInML2vJilthOo7awVCro2SM+tOcpljORwuBQ1vHUtV62Leit+5wlxrNtw==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15" + } + }, + "node_modules/@supabase/functions-js": { + "version": "2.75.0", + "resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.75.0.tgz", + "integrity": "sha512-18yk07Moj/xtQ28zkqswxDavXC3vbOwt1hDuYM3/7xPnwwpKnsmPyZ7bQ5th4uqiJzQ135t74La9tuaxBR6e7w==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15" + } + }, + "node_modules/@supabase/node-fetch": { + "version": "2.6.15", + "resolved": "https://registry.npmjs.org/@supabase/node-fetch/-/node-fetch-2.6.15.tgz", + "integrity": "sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + } + }, + "node_modules/@supabase/postgrest-js": { + "version": "2.75.0", + "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-2.75.0.tgz", + "integrity": "sha512-YfBz4W/z7eYCFyuvHhfjOTTzRrQIvsMG2bVwJAKEVVUqGdzqfvyidXssLBG0Fqlql1zJFgtsPpK1n4meHrI7tg==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15" + } + }, + "node_modules/@supabase/realtime-js": { + "version": "2.75.0", + "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.75.0.tgz", + "integrity": "sha512-B4Xxsf2NHd5cEnM6MGswOSPSsZKljkYXpvzKKmNxoUmNQOfB7D8HOa6NwHcUBSlxcjV+vIrYKcYXtavGJqeGrw==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15", + "@types/phoenix": "^1.6.6", + "@types/ws": "^8.18.1", + "ws": "^8.18.2" + } + }, + "node_modules/@supabase/storage-js": { + "version": "2.75.0", + "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.75.0.tgz", + "integrity": "sha512-wpJMYdfFDckDiHQaTpK+Ib14N/O2o0AAWWhguKvmmMurB6Unx17GGmYp5rrrqCTf8S1qq4IfIxTXxS4hzrUySg==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15" + } + }, + "node_modules/@supabase/supabase-js": { + "version": "2.75.0", + "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.75.0.tgz", + "integrity": "sha512-8UN/vATSgS2JFuJlMVr51L3eUDz+j1m7Ww63wlvHLKULzCDaVWYzvacCjBTLW/lX/vedI2LBI4Vg+01G9ufsJQ==", + "license": "MIT", + "dependencies": { + "@supabase/auth-js": "2.75.0", + "@supabase/functions-js": "2.75.0", + "@supabase/node-fetch": "2.6.15", + "@supabase/postgrest-js": "2.75.0", + "@supabase/realtime-js": "2.75.0", + "@supabase/storage-js": "2.75.0" + } + }, "node_modules/@swc/helpers": { "version": "0.5.17", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz", @@ -258,6 +333,21 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, + "node_modules/@types/node": { + "version": "24.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.7.1.tgz", + "integrity": "sha512-CmyhGZanP88uuC5GpWU9q+fI61j2SkhO3UGMUdfYRE6Bcy0ccyzn1Rqj9YAB/ZY4kOXmNf0ocah5GtphmLMP6Q==", + "license": "MIT", + "dependencies": { + "undici-types": "~7.14.0" + } + }, + "node_modules/@types/phoenix": { + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.6.6.tgz", + "integrity": "sha512-PIzZZlEppgrpoT2QgbnDU+MMzuR6BbCjllj0bM70lWoejMeNJAxCchxnv7J3XFkI8MpygtRpzXrIlmWUBclP5A==", + "license": "MIT" + }, "node_modules/@types/react": { "version": "19.1.12", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.12.tgz", @@ -279,6 +369,15 @@ "integrity": "sha512-D1XC7WK8K+zZEveUPY+cf4+kgauk8N4eHr/XIHXGlGYkHLud6hK9lYfZk1ry1TNh798cZUCgb6MqGEG8DkJt6Q==", "license": "MIT" }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/clsx": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", @@ -576,6 +675,12 @@ "integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==", "license": "MIT" }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, "node_modules/trim-canvas": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/trim-canvas/-/trim-canvas-0.1.2.tgz", @@ -603,6 +708,12 @@ "react": ">=15.0.0" } }, + "node_modules/undici-types": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.14.0.tgz", + "integrity": "sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA==", + "license": "MIT" + }, "node_modules/use-sync-external-store": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz", @@ -620,6 +731,43 @@ "dependencies": { "loose-envify": "^1.0.0" } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index e0ec9ff..ef83a44 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "dependencies": { "@headlessui/react": "^2.2.7", "@heroicons/react": "^2.2.0", + "@supabase/supabase-js": "^2.75.0", "date-fns": "^4.1.0", "react-big-calendar": "^1.19.4", "react-signature-canvas": "^1.1.0-alpha.2" diff --git a/susconecta/Documentação API.md b/susconecta/Documentação API.md new file mode 100644 index 0000000..b1b9604 --- /dev/null +++ b/susconecta/Documentação API.md @@ -0,0 +1,2565 @@ +# Listar atribuições de pacientes + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/patient_assignments: + get: + summary: Listar atribuições de pacientes + deprecated: false + description: '' + tags: + - Atribuições + - Atribuições + parameters: + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '' + schema: + type: string + responses: + '200': + description: Lista de atribuições + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PatientAssignment' + headers: {} + x-apidog-name: OK + security: + - bearer: [] + x-apidog-folder: Atribuições + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940525-run +components: + schemas: + PatientAssignment: + type: object + properties: + id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + patient_id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + user_id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + role: + type: string + enum: + - medico + - enfermeiro + examples: + - medico + created_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + created_by: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + x-apidog-orders: + - id + - patient_id + - user_id + - role + - created_at + - created_by + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Criar nova atribuição + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/patient_assignments: + post: + summary: Criar nova atribuição + deprecated: false + description: '' + tags: + - Atribuições + - Atribuições + parameters: + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '' + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatientAssignmentInput' + responses: + '201': + description: Atribuição criada + content: + application/json: + schema: + $ref: '#/components/schemas/PatientAssignment' + headers: {} + x-apidog-name: Created + security: + - bearer: [] + x-apidog-folder: Atribuições + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940526-run +components: + schemas: + PatientAssignmentInput: + type: object + required: + - patient_id + - user_id + - role + properties: + patient_id: + type: string + format: uuid + user_id: + type: string + format: uuid + role: + type: string + enum: + - medico + - enfermeiro + x-apidog-orders: + - patient_id + - user_id + - role + x-apidog-ignore-properties: [] + x-apidog-folder: '' + PatientAssignment: + type: object + properties: + id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + patient_id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + user_id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + role: + type: string + enum: + - medico + - enfermeiro + examples: + - medico + created_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + created_by: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + x-apidog-orders: + - id + - patient_id + - user_id + - role + - created_at + - created_by + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Listar roles de usuários + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/user_roles: + get: + summary: Listar roles de usuários + deprecated: false + description: '' + tags: + - Usuários + - Usuários + parameters: [] + responses: + '200': + description: Lista de roles + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/UserRole' + headers: {} + x-apidog-name: OK + security: + - bearer: [] + x-apidog-folder: Usuários + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940524-run +components: + schemas: + UserRole: + type: object + properties: + id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + user_id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + role: + type: string + enum: + - admin + - gestor + - medico + examples: + - medico + created_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + x-apidog-orders: + - id + - user_id + - role + - created_at + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Obter informações completas do usuário + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /functions/v1/user-info: + get: + summary: Obter informações completas do usuário + deprecated: false + description: >- + Retorna dados consolidados do usuário autenticado, incluindo perfil e + roles para controle de permissões. + tags: + - Usuários + parameters: [] + responses: + '200': + description: Informações do usuário retornadas com sucesso + content: + application/json: + schema: + $ref: '#/components/schemas/UserInfoResponse' + headers: {} + x-apidog-name: OK + '401': + description: Token inválido ou expirado + content: + application/json: + schema: &ref_0 + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Unauthorized + '500': + description: Erro interno do servidor + content: + application/json: + schema: *ref_0 + headers: {} + x-apidog-name: Internal Server Error + security: [] + x-apidog-folder: Usuários + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21952675-run +components: + schemas: + UserInfoResponse: + type: object + properties: + user: + $ref: '#/components/schemas/User' + profile: + $ref: '#/components/schemas/Profile' + roles: + type: array + items: + type: string + enum: + - admin + - gestor + - medico + - secretaria + - user + examples: + - - medico + - admin + permissions: + $ref: '#/components/schemas/Permissions' + x-apidog-orders: + - user + - profile + - roles + - permissions + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Permissions: + type: object + properties: + isAdmin: + type: boolean + description: Se o usuário tem role de admin + examples: + - true + isManager: + type: boolean + description: Se o usuário tem role de gestor + examples: + - false + isDoctor: + type: boolean + description: Se o usuário tem role de médico + examples: + - true + isSecretary: + type: boolean + description: Se o usuário tem role de secretária + examples: + - false + isAdminOrManager: + type: boolean + description: Se o usuário é admin ou gestor (para controle de permissões) + examples: + - true + x-apidog-orders: + - isAdmin + - isManager + - isDoctor + - isSecretary + - isAdminOrManager + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Profile: + type: object + properties: + id: + type: string + format: uuid + full_name: + type: string + examples: + - Dr. João Silva + nullable: true + email: + type: string + format: email + nullable: true + phone: + type: string + examples: + - '+5511999999999' + nullable: true + avatar_url: + type: string + format: uri + nullable: true + disabled: + type: boolean + examples: + - false + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + x-apidog-orders: + - id + - full_name + - email + - phone + - avatar_url + - disabled + - created_at + - updated_at + x-apidog-ignore-properties: [] + nullable: true + x-apidog-folder: '' + User: + type: object + properties: + id: + type: string + format: uuid + examples: + - 550e8400-e29b-41d4-a716-446655440000 + email: + type: string + format: email + examples: + - usuario@exemplo.com + email_confirmed_at: + type: string + format: date-time + examples: + - '2024-01-01T10:00:00Z' + nullable: true + created_at: + type: string + format: date-time + examples: + - '2024-01-01T00:00:00Z' + last_sign_in_at: + type: string + format: date-time + examples: + - '2024-01-15T09:30:00Z' + nullable: true + x-apidog-orders: + - id + - email + - email_confirmed_at + - created_at + - last_sign_in_at + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Criar novo usuário + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /functions/v1/create-user: + post: + summary: Criar novo usuário + deprecated: false + description: >- + Cria um novo usuário no sistema com papel específico. Apenas usuários + com papel de admin, gestor ou secretaria podem criar novos usuários. + operationId: createUser + tags: + - Usuários + - Usuários + parameters: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateUserRequest' + examples: + admin_user: + value: + email: admin@mediconnect.com + password: senha123! + full_name: João Silva + phone: (11) 99999-9999 + role: admin + summary: Criar administrador + doctor_user: + value: + email: dr.maria@mediconnect.com + password: senha123! + full_name: Dra. Maria Santos + phone: (11) 98888-8888 + role: medico + summary: Criar médico + secretary_user: + value: + email: secretaria@mediconnect.com + password: senha123! + full_name: Ana Costa + phone: (11) 97777-7777 + role: secretaria + summary: Criar secretária + responses: + '200': + description: Usuário criado com sucesso + content: + application/json: + schema: + $ref: '#/components/schemas/CreateUserResponse' + example: + success: true + user: + id: 123e4567-e89b-12d3-a456-426614174000 + email: novo.usuario@mediconnect.com + full_name: Novo Usuário + phone: (11) 99999-9999 + role: medico + headers: {} + x-apidog-name: OK + '400': + description: Dados inválidos ou erro de validação + content: + application/json: + schema: + type: object + properties: {} + x-apidog-ignore-properties: [] + x-apidog-orders: [] + examples: + '2': + summary: Campos obrigatórios faltando + value: + error: 'Missing required fields: email, password, full_name, role' + '3': + summary: Papel inválido + value: + error: Invalid role + '4': + summary: Email já existe + value: + error: User with this email already registered + headers: {} + x-apidog-name: Bad Request + '401': + description: Token de autenticação inválido ou ausente + content: + application/json: + schema: + type: object + properties: {} + x-apidog-ignore-properties: [] + x-apidog-orders: [] + example: + error: Unauthorized + headers: {} + x-apidog-name: Unauthorized + '403': + description: Permissões insuficientes + content: + application/json: + schema: + type: object + properties: {} + x-apidog-ignore-properties: [] + x-apidog-orders: [] + example: + error: Insufficient permissions + headers: {} + x-apidog-name: Forbidden + '500': + description: Erro interno do servidor + content: + application/json: + schema: + type: object + properties: {} + x-apidog-ignore-properties: [] + x-apidog-orders: [] + example: + error: Internal server error + headers: {} + x-apidog-name: Internal Server Error + security: [] + x-apidog-folder: Usuários + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21953135-run +components: + schemas: + CreateUserRequest: + type: object + required: + - email + - password + - full_name + - role + properties: + email: + type: string + format: email + description: Email do usuário (deve ser único) + examples: + - usuario@mediconnect.com + password: + type: string + minLength: 6 + description: Senha temporária para o usuário + examples: + - senha123! + full_name: + type: string + minLength: 1 + description: Nome completo do usuário + examples: + - João da Silva + phone: + type: string + description: Telefone do usuário (opcional) + examples: + - (11) 99999-9999 + nullable: true + role: + type: string + enum: + - admin + - gestor + - medico + - secretaria + - user + description: Papel do usuário no sistema + examples: + - medico + x-apidog-orders: + - email + - password + - full_name + - phone + - role + x-apidog-ignore-properties: [] + x-apidog-folder: '' + CreateUserResponse: + type: object + properties: + success: + type: boolean + description: Indica se a operação foi bem-sucedida + examples: + - true + user: + type: object + properties: + id: + type: string + format: uuid + description: ID único do usuário criado + examples: + - 123e4567-e89b-12d3-a456-426614174000 + email: + type: string + format: email + description: Email do usuário + examples: + - usuario@mediconnect.com + full_name: + type: string + description: Nome completo do usuário + examples: + - João da Silva + phone: + type: string + description: Telefone do usuário + examples: + - (11) 99999-9999 + nullable: true + role: + type: string + description: Papel atribuído ao usuário + examples: + - medico + x-apidog-orders: + - id + - email + - full_name + - phone + - role + x-apidog-ignore-properties: [] + x-apidog-orders: + - success + - user + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Obter dados do usuário atual + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /auth/v1/user: + get: + summary: Obter dados do usuário atual + deprecated: false + description: Retorna informações do usuário autenticado + tags: + - Usuários + - Authentication + parameters: [] + responses: + '200': + description: Dados do usuário + content: + application/json: + schema: + $ref: '#/components/schemas/User' + headers: {} + x-apidog-name: OK + '401': + description: Token inválido + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Unauthorized + security: + - bearer: [] + x-apidog-folder: Usuários + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940512-run +components: + schemas: + User: + type: object + properties: + id: + type: string + format: uuid + examples: + - 550e8400-e29b-41d4-a716-446655440000 + email: + type: string + format: email + examples: + - usuario@exemplo.com + email_confirmed_at: + type: string + format: date-time + examples: + - '2024-01-01T10:00:00Z' + nullable: true + created_at: + type: string + format: date-time + examples: + - '2024-01-01T00:00:00Z' + last_sign_in_at: + type: string + format: date-time + examples: + - '2024-01-15T09:30:00Z' + nullable: true + x-apidog-orders: + - id + - email + - email_confirmed_at + - created_at + - last_sign_in_at + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` +# Fazer login e obter token JWT + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /auth/v1/token: + post: + summary: Fazer login e obter token JWT + deprecated: false + description: >- + Autentica o usuário e retorna um token JWT para usar em outras + requisições. + tags: + - Authentication + parameters: + - name: grant_type + in: query + description: '' + required: true + schema: + type: string + enum: + - password + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/LoginRequest' + examples: {} + responses: + '200': + description: Login realizado com sucesso + content: + application/json: + schema: + $ref: '#/components/schemas/LoginResponse' + headers: {} + x-apidog-name: OK + '400': + description: Credenciais inválidas + content: + application/json: + schema: &ref_0 + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Bad Request + '401': + description: Email ou senha incorretos + content: + application/json: + schema: *ref_0 + headers: {} + x-apidog-name: Unauthorized + security: + - bearer: [] + x-apidog-folder: Authentication + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940510-run +components: + schemas: + LoginRequest: + type: object + required: + - email + - password + properties: + email: + type: string + format: email + examples: + - usuario@exemplo.com + password: + type: string + minLength: 6 + examples: + - senha123 + x-apidog-orders: + - email + - password + x-apidog-ignore-properties: [] + x-apidog-folder: '' + LoginResponse: + type: object + properties: + access_token: + type: string + description: Token JWT para autenticação + examples: + - eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... + token_type: + type: string + examples: + - bearer + expires_in: + type: integer + description: Tempo de expiração do token em segundos + examples: + - 3600 + refresh_token: + type: string + description: Token para renovar o access_token + user: + $ref: '#/components/schemas/AuthUser' + x-apidog-orders: + - access_token + - token_type + - expires_in + - refresh_token + - user + x-apidog-ignore-properties: [] + x-apidog-folder: '' + AuthUser: + type: object + properties: + id: + type: string + format: uuid + email: + type: string + format: email + email_confirmed_at: + type: string + format: date-time + nullable: true + created_at: + type: string + format: date-time + x-apidog-orders: + - id + - email + - email_confirmed_at + - created_at + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Logout do usuário + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /auth/v1/logout: + post: + summary: Logout do usuário + deprecated: false + description: Encerrar sessão do usuário + tags: + - Authentication + - Authentication + parameters: [] + responses: + '204': + description: Logout realizado com sucesso + headers: {} + x-apidog-name: No Content + '401': + description: Token inválido + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Unauthorized + security: + - bearer: [] + x-apidog-folder: Authentication + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940511-run +components: + schemas: + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Listar perfis de usuários + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/profiles: + get: + summary: Listar perfis de usuários + deprecated: false + description: '' + tags: + - Perfis + - Perfis + parameters: + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '' + schema: + type: string + responses: + '200': + description: Lista de perfis + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Profile' + headers: {} + x-apidog-name: OK + security: + - bearer: [] + x-apidog-folder: Perfis + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940522-run +components: + schemas: + Profile: + type: object + properties: + id: + type: string + format: uuid + full_name: + type: string + examples: + - Dr. João Silva + nullable: true + email: + type: string + format: email + nullable: true + phone: + type: string + examples: + - '+5511999999999' + nullable: true + avatar_url: + type: string + format: uri + nullable: true + disabled: + type: boolean + examples: + - false + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + x-apidog-orders: + - id + - full_name + - email + - phone + - avatar_url + - disabled + - created_at + - updated_at + x-apidog-ignore-properties: [] + nullable: true + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Atualizar perfil do usuário + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/profiles: + patch: + summary: Atualizar perfil do usuário + deprecated: false + description: '' + tags: + - Perfis + - Perfis + parameters: + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '' + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProfileInput' + responses: + '200': + description: Perfil atualizado + content: + application/json: + schema: + $ref: '#/components/schemas/Profile' + headers: {} + x-apidog-name: OK + security: + - bearer: [] + x-apidog-folder: Perfis + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940523-run +components: + schemas: + ProfileInput: + type: object + properties: + full_name: + type: string + avatar_url: + type: string + phone: + type: string + x-apidog-orders: + - full_name + - avatar_url + - phone + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Profile: + type: object + properties: + id: + type: string + format: uuid + full_name: + type: string + examples: + - Dr. João Silva + nullable: true + email: + type: string + format: email + nullable: true + phone: + type: string + examples: + - '+5511999999999' + nullable: true + avatar_url: + type: string + format: uri + nullable: true + disabled: + type: boolean + examples: + - false + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + x-apidog-orders: + - id + - full_name + - email + - phone + - avatar_url + - disabled + - created_at + - updated_at + x-apidog-ignore-properties: [] + nullable: true + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Obter paciente por ID + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/patients/{id}: + get: + summary: Obter paciente por ID + deprecated: false + description: Retorna dados de um paciente específico + tags: + - Pacientes + - Pacientes + parameters: + - name: id + in: path + description: ID do paciente + required: true + example: '' + schema: + type: string + format: uuid + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '' + schema: + type: string + responses: + '200': + description: Dados do paciente + content: + application/json: + schema: + $ref: '#/components/schemas/Patient' + headers: {} + x-apidog-name: OK + '401': + description: Não autorizado + content: + application/json: + schema: &ref_0 + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Unauthorized + '404': + description: Paciente não encontrado + content: + application/json: + schema: *ref_0 + headers: {} + x-apidog-name: Not Found + security: + - bearer: [] + x-apidog-folder: Pacientes + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940515-run +components: + schemas: + Patient: + type: object + properties: + id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + full_name: + type: string + examples: + - Maria Santos Silva + cpf: + type: string + examples: + - '12345678901' + email: + type: string + format: email + examples: + - maria@email.com + phone_mobile: + type: string + examples: + - (11) 99999-9999 + birth_date: + type: string + format: date + examples: + - '1980-01-15' + social_name: + type: string + examples: + - Maria Santos + sex: + type: string + examples: + - F + blood_type: + type: string + examples: + - A+ + weight_kg: + type: number + examples: + - 65.5 + height_m: + type: number + examples: + - 1.65 + bmi: + type: number + examples: + - 24.1 + street: + type: string + examples: + - Rua das Flores, 123 + number: + type: string + examples: + - '123' + complement: + type: string + examples: + - Apt 45 + neighborhood: + type: string + examples: + - Centro + city: + type: string + examples: + - São Paulo + state: + type: string + examples: + - SP + cep: + type: string + examples: + - 01234-567 + created_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + updated_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + created_by: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + x-apidog-orders: + - id + - full_name + - cpf + - email + - phone_mobile + - birth_date + - social_name + - sex + - blood_type + - weight_kg + - height_m + - bmi + - street + - number + - complement + - neighborhood + - city + - state + - cep + - created_at + - updated_at + - created_by + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Atualizar paciente + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/patients/{id}: + patch: + summary: Atualizar paciente + deprecated: false + description: Atualizar dados de um paciente existente + tags: + - Pacientes + - Pacientes + parameters: + - name: id + in: path + description: ID do paciente + required: true + example: '' + schema: + type: string + format: uuid + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '' + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatientInput' + responses: + '200': + description: Paciente atualizado com sucesso + content: + application/json: + schema: + $ref: '#/components/schemas/Patient' + headers: {} + x-apidog-name: OK + '401': + description: Não autorizado + content: + application/json: + schema: &ref_0 + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Unauthorized + '404': + description: Paciente não encontrado + content: + application/json: + schema: *ref_0 + headers: {} + x-apidog-name: Not Found + security: + - bearer: [] + x-apidog-folder: Pacientes + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940516-run +components: + schemas: + PatientInput: + type: object + required: + - full_name + - cpf + - email + - phone_mobile + properties: + full_name: + type: string + examples: + - Maria Santos Silva + cpf: + type: string + examples: + - '12345678901' + email: + type: string + format: email + examples: + - maria@email.com + phone_mobile: + type: string + examples: + - (11) 99999-9999 + birth_date: + type: string + format: date + examples: + - '1980-01-15' + social_name: + type: string + sex: + type: string + examples: + - F + blood_type: + type: string + weight_kg: + type: number + height_m: + type: number + street: + type: string + number: + type: string + complement: + type: string + neighborhood: + type: string + city: + type: string + state: + type: string + cep: + type: string + x-apidog-orders: + - full_name + - cpf + - email + - phone_mobile + - birth_date + - social_name + - sex + - blood_type + - weight_kg + - height_m + - street + - number + - complement + - neighborhood + - city + - state + - cep + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Patient: + type: object + properties: + id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + full_name: + type: string + examples: + - Maria Santos Silva + cpf: + type: string + examples: + - '12345678901' + email: + type: string + format: email + examples: + - maria@email.com + phone_mobile: + type: string + examples: + - (11) 99999-9999 + birth_date: + type: string + format: date + examples: + - '1980-01-15' + social_name: + type: string + examples: + - Maria Santos + sex: + type: string + examples: + - F + blood_type: + type: string + examples: + - A+ + weight_kg: + type: number + examples: + - 65.5 + height_m: + type: number + examples: + - 1.65 + bmi: + type: number + examples: + - 24.1 + street: + type: string + examples: + - Rua das Flores, 123 + number: + type: string + examples: + - '123' + complement: + type: string + examples: + - Apt 45 + neighborhood: + type: string + examples: + - Centro + city: + type: string + examples: + - São Paulo + state: + type: string + examples: + - SP + cep: + type: string + examples: + - 01234-567 + created_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + updated_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + created_by: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + x-apidog-orders: + - id + - full_name + - cpf + - email + - phone_mobile + - birth_date + - social_name + - sex + - blood_type + - weight_kg + - height_m + - bmi + - street + - number + - complement + - neighborhood + - city + - state + - cep + - created_at + - updated_at + - created_by + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Deletar paciente + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/patients/{id}: + delete: + summary: Deletar paciente + deprecated: false + description: Remover um paciente do sistema (apenas admins/gestores) + tags: + - Pacientes + - Pacientes + parameters: + - name: id + in: path + description: ID do paciente + required: true + example: '' + schema: + type: string + format: uuid + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '' + schema: + type: string + responses: + '204': + description: Paciente deletado com sucesso + headers: {} + x-apidog-name: No Content + '401': + description: Não autorizado + content: + application/json: + schema: &ref_0 + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Unauthorized + '403': + description: Sem permissão + content: + application/json: + schema: *ref_0 + headers: {} + x-apidog-name: Forbidden + '404': + description: Paciente não encontrado + content: + application/json: + schema: *ref_0 + headers: {} + x-apidog-name: Not Found + security: + - bearer: [] + x-apidog-folder: Pacientes + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940517-run +components: + schemas: + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Criar novo paciente + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/patients: + post: + summary: Criar novo paciente + deprecated: false + description: Cadastrar um novo paciente no sistema + tags: + - Pacientes + - Pacientes + parameters: + - name: apikey + in: header + description: Chave da API Supabase + required: true + example: '{{API_KEY}}' + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatientInput' + example: + full_name: Maria Santos + cpf: '12345678901' + email: maria@email.com + phone_mobile: (11) 99999-9999 + birth_date: '1980-01-15' + responses: + '201': + description: Paciente criado com sucesso + content: + application/json: + schema: + $ref: '#/components/schemas/Patient' + headers: {} + x-apidog-name: Created + '400': + description: Dados inválidos + content: + application/json: + schema: &ref_0 + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Bad Request + '401': + description: Não autorizado + content: + application/json: + schema: *ref_0 + headers: {} + x-apidog-name: Unauthorized + security: + - bearer: [] + x-apidog-folder: Pacientes + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940514-run +components: + schemas: + PatientInput: + type: object + required: + - full_name + - cpf + - email + - phone_mobile + properties: + full_name: + type: string + examples: + - Maria Santos Silva + cpf: + type: string + examples: + - '12345678901' + email: + type: string + format: email + examples: + - maria@email.com + phone_mobile: + type: string + examples: + - (11) 99999-9999 + birth_date: + type: string + format: date + examples: + - '1980-01-15' + social_name: + type: string + sex: + type: string + examples: + - F + blood_type: + type: string + weight_kg: + type: number + height_m: + type: number + street: + type: string + number: + type: string + complement: + type: string + neighborhood: + type: string + city: + type: string + state: + type: string + cep: + type: string + x-apidog-orders: + - full_name + - cpf + - email + - phone_mobile + - birth_date + - social_name + - sex + - blood_type + - weight_kg + - height_m + - street + - number + - complement + - neighborhood + - city + - state + - cep + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Patient: + type: object + properties: + id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + full_name: + type: string + examples: + - Maria Santos Silva + cpf: + type: string + examples: + - '12345678901' + email: + type: string + format: email + examples: + - maria@email.com + phone_mobile: + type: string + examples: + - (11) 99999-9999 + birth_date: + type: string + format: date + examples: + - '1980-01-15' + social_name: + type: string + examples: + - Maria Santos + sex: + type: string + examples: + - F + blood_type: + type: string + examples: + - A+ + weight_kg: + type: number + examples: + - 65.5 + height_m: + type: number + examples: + - 1.65 + bmi: + type: number + examples: + - 24.1 + street: + type: string + examples: + - Rua das Flores, 123 + number: + type: string + examples: + - '123' + complement: + type: string + examples: + - Apt 45 + neighborhood: + type: string + examples: + - Centro + city: + type: string + examples: + - São Paulo + state: + type: string + examples: + - SP + cep: + type: string + examples: + - 01234-567 + created_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + updated_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + created_by: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + x-apidog-orders: + - id + - full_name + - cpf + - email + - phone_mobile + - birth_date + - social_name + - sex + - blood_type + - weight_kg + - height_m + - bmi + - street + - number + - complement + - neighborhood + - city + - state + - cep + - created_at + - updated_at + - created_by + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` + +# Listar pacientes + +## OpenAPI Specification + +```yaml +openapi: 3.0.1 +info: + title: '' + description: '' + version: 1.0.0 +paths: + /rest/v1/patients: + get: + summary: Listar pacientes + deprecated: false + description: Retorna lista de pacientes com base nas permissões do usuário + tags: + - Pacientes + - Pacientes + parameters: + - name: apikey + in: header + description: '' + required: false + example: '{{apikey}}' + schema: + type: string + responses: + '200': + description: Lista de pacientes + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Patient' + headers: {} + x-apidog-name: OK + '401': + description: Não autorizado + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + headers: {} + x-apidog-name: Unauthorized + security: + - bearer: [] + x-apidog-folder: Pacientes + x-apidog-status: released + x-run-in-apidog: https://app.apidog.com/web/project/1053378/apis/api-21940513-run +components: + schemas: + Patient: + type: object + properties: + id: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + full_name: + type: string + examples: + - Maria Santos Silva + cpf: + type: string + examples: + - '12345678901' + email: + type: string + format: email + examples: + - maria@email.com + phone_mobile: + type: string + examples: + - (11) 99999-9999 + birth_date: + type: string + format: date + examples: + - '1980-01-15' + social_name: + type: string + examples: + - Maria Santos + sex: + type: string + examples: + - F + blood_type: + type: string + examples: + - A+ + weight_kg: + type: number + examples: + - 65.5 + height_m: + type: number + examples: + - 1.65 + bmi: + type: number + examples: + - 24.1 + street: + type: string + examples: + - Rua das Flores, 123 + number: + type: string + examples: + - '123' + complement: + type: string + examples: + - Apt 45 + neighborhood: + type: string + examples: + - Centro + city: + type: string + examples: + - São Paulo + state: + type: string + examples: + - SP + cep: + type: string + examples: + - 01234-567 + created_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + updated_at: + type: string + format: date-time + examples: + - '2024-01-15T10:30:00Z' + created_by: + type: string + format: uuid + examples: + - 12345678-1234-1234-1234-123456789012 + x-apidog-orders: + - id + - full_name + - cpf + - email + - phone_mobile + - birth_date + - social_name + - sex + - blood_type + - weight_kg + - height_m + - bmi + - street + - number + - complement + - neighborhood + - city + - state + - cep + - created_at + - updated_at + - created_by + x-apidog-ignore-properties: [] + x-apidog-folder: '' + Error: + type: object + properties: + error: + type: string + message: + type: string + code: + type: string + x-apidog-orders: + - error + - message + - code + x-apidog-ignore-properties: [] + x-apidog-folder: '' + securitySchemes: + bearerAuth: + type: jwt + scheme: bearer + bearerFormat: JWT + description: Token JWT obtido no login + bearer: + type: http + scheme: bearer +servers: + - url: https://yuanqfswhberkoevtmfr.supabase.co + description: Prod Env + - url: '' + description: Cloud Mock +security: + - bearer: [] + +``` diff --git a/susconecta/app/(main-routes)/doutores/page.tsx b/susconecta/app/(main-routes)/doutores/page.tsx index 64fcf5e..50612db 100644 --- a/susconecta/app/(main-routes)/doutores/page.tsx +++ b/susconecta/app/(main-routes)/doutores/page.tsx @@ -7,12 +7,13 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; import { Label } from "@/components/ui/label"; -import { MoreHorizontal, Plus, Search, Edit, Trash2, ArrowLeft, Eye } from "lucide-react"; +import { MoreHorizontal, Plus, Search, Edit, Trash2, ArrowLeft, Eye, Users } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { DoctorRegistrationForm } from "@/components/forms/doctor-registration-form"; -import { listarMedicos, excluirMedico, buscarMedicos, buscarMedicoPorId, Medico } from "@/lib/api"; +import { listarMedicos, excluirMedico, buscarMedicos, buscarMedicoPorId, buscarPacientesPorIds, Medico } from "@/lib/api"; +import { listAssignmentsForUser } from '@/lib/assignment'; function normalizeMedico(m: any): Medico { return { @@ -64,6 +65,10 @@ export default function DoutoresPage() { const [showForm, setShowForm] = useState(false); const [editingId, setEditingId] = useState(null); const [viewingDoctor, setViewingDoctor] = useState(null); + const [assignedDialogOpen, setAssignedDialogOpen] = useState(false); + const [assignedPatients, setAssignedPatients] = useState([]); + const [assignedLoading, setAssignedLoading] = useState(false); + const [assignedDoctor, setAssignedDoctor] = useState(null); const [searchResults, setSearchResults] = useState([]); const [searchMode, setSearchMode] = useState(false); const [searchTimeout, setSearchTimeout] = useState(null); @@ -179,7 +184,7 @@ export default function DoutoresPage() { // Handler para o botão de busca function handleClickBuscar() { - handleBuscarServidor(); + void handleBuscarServidor(); } useEffect(() => { @@ -253,6 +258,28 @@ export default function DoutoresPage() { setViewingDoctor(doctor); } + async function handleViewAssignedPatients(doctor: Medico) { + setAssignedDoctor(doctor); + setAssignedLoading(true); + setAssignedPatients([]); + try { + const assigns = await listAssignmentsForUser(String(doctor.user_id ?? doctor.id)); + const patientIds = Array.isArray(assigns) ? assigns.map((a:any) => String(a.patient_id)).filter(Boolean) : []; + if (patientIds.length) { + const patients = await buscarPacientesPorIds(patientIds); + setAssignedPatients(patients || []); + } else { + setAssignedPatients([]); + } + } catch (e) { + console.warn('[DoutoresPage] erro ao carregar pacientes atribuídos:', e); + setAssignedPatients([]); + } finally { + setAssignedLoading(false); + setAssignedDialogOpen(true); + } + } + async function handleDelete(id: string) { if (!confirm("Excluir este médico?")) return; @@ -326,9 +353,9 @@ export default function DoutoresPage() { onKeyDown={handleSearchKeyDown} /> - - + handleView(doctor)}> Ver + + {/* Ver pacientes atribuídos ao médico */} + handleViewAssignedPatients(doctor)}> + + Ver pacientes atribuídos + + handleEdit(String(doctor.id))}> Editar @@ -466,6 +500,36 @@ export default function DoutoresPage() {
Mostrando {displayedDoctors.length} {searchMode ? 'resultado(s) da busca' : `de ${doctors.length}`}
+ {/* Dialog para pacientes atribuídos */} + { if (!open) { setAssignedDialogOpen(false); setAssignedPatients([]); setAssignedDoctor(null); } }}> + + + Pacientes atribuídos{assignedDoctor ? ` - ${assignedDoctor.full_name}` : ''} + + Lista de pacientes atribuídos a este médico. + + +
+ {assignedLoading ? ( +
Carregando pacientes...
+ ) : assignedPatients && assignedPatients.length ? ( +
+ {assignedPatients.map((p:any) => ( +
+
{p.full_name ?? p.nome ?? p.name ?? '(sem nome)'}
+
ID: {p.id} {p.cpf ? `• CPF: ${p.cpf}` : ''}
+
+ ))} +
+ ) : ( +
Nenhum paciente atribuído encontrado.
+ )} +
+ + + +
+
); } diff --git a/susconecta/app/(main-routes)/pacientes/page.tsx b/susconecta/app/(main-routes)/pacientes/page.tsx index 6b8193a..0442b83 100644 --- a/susconecta/app/(main-routes)/pacientes/page.tsx +++ b/susconecta/app/(main-routes)/pacientes/page.tsx @@ -12,6 +12,7 @@ import { MoreHorizontal, Plus, Search, Eye, Edit, Trash2, ArrowLeft } from "luci import { Paciente, Endereco, listarPacientes, buscarPacientes, buscarPacientePorId, excluirPaciente } from "@/lib/api"; import { PatientRegistrationForm } from "@/components/forms/patient-registration-form"; +import AssignmentForm from "@/components/admin/AssignmentForm"; function normalizePaciente(p: any): Paciente { @@ -46,6 +47,8 @@ export default function PacientesPage() { const [showForm, setShowForm] = useState(false); const [editingId, setEditingId] = useState(null); const [viewingPatient, setViewingPatient] = useState(null); + const [assignDialogOpen, setAssignDialogOpen] = useState(false); + const [assignPatientId, setAssignPatientId] = useState(null); async function loadAll() { try { @@ -204,7 +207,7 @@ export default function PacientesPage() { onKeyDown={(e) => e.key === "Enter" && handleBuscarServidor()} /> - + - +
{todayEvents.length} consulta{todayEvents.length !== 1 ? 's' : ''} agendada{todayEvents.length !== 1 ? 's' : ''} @@ -799,7 +553,7 @@ const ProfissionalPage = () => {
{paciente && (
- CPF: {paciente.cpf} • {paciente.idade} anos + CPF: {getPatientCpf(paciente)} • {getPatientAge(paciente)} anos
)} @@ -818,20 +572,6 @@ const ProfissionalPage = () => {
-
Ver informações do paciente
@@ -850,963 +590,7 @@ const ProfissionalPage = () => { }; - function PacientesSection({ - handleAbrirProntuario, - setActiveSection, - }: { - handleAbrirProntuario: (paciente: any) => void; - setActiveSection: (section: string) => void; - }) { - return ( -
-

Gerenciamento de Pacientes

- - - - {/* Tabela de pacientes padrão */} -
-

Pacientes Recentes

- - - - Paciente - CPF - Idade - Status do laudo - Ações - - - - {pacientes.map((paciente) => ( - - {paciente.nome} - {paciente.cpf} - {paciente.idade} - {paciente.statusLaudo} - -
-
- -
- Ver informações do paciente -
-
-
- -
-
-
- ))} -
-
-
-
- ); - }; - - const renderProntuarioSection = () => ( -
-
-

Prontuário do Paciente

- - {/* Informações do Paciente Selecionado */} - {pacienteSelecionado && ( -
-
-

Dados do Paciente

-
- - -
-
-
-
- Nome: -

{pacienteSelecionado.nome}

-
-
- CPF: -

{pacienteSelecionado.cpf}

-
-
- Idade: -

{pacienteSelecionado.idade} anos

-
-
-
- )} - - {/* Seletor de Paciente */} - {!pacienteSelecionado && ( -
-
-
- -

Selecionar Paciente

-

Escolha um paciente para visualizar o prontuário completo

-
- -
- - -
-
- - {/* Cards de pacientes para seleção rápida */} -
-

Ou selecione rapidamente:

-
- {pacientes.map((paciente) => ( -
setPacienteSelecionado(paciente)} - className="border rounded-lg p-4 hover:shadow-md hover:border-primary transition-all cursor-pointer group" - > -
-
- -
-
-

{paciente.nome}

-

CPF: {paciente.cpf}

-

{paciente.idade} anos

-
-
-
- - {paciente.statusLaudo} - - -
-
- ))} -
-
-
- )} - - {/* Tabs de Navegação do Prontuário */} - {pacienteSelecionado && ( -
- -
- )} - - {/* Conteúdo das Abas */} - {pacienteSelecionado && ( -
- {abaProntuarioAtiva === 'nova-consulta' && renderNovaConsultaTab()} - {abaProntuarioAtiva === 'consultas' && renderConsultasTab()} - {abaProntuarioAtiva === 'historico' && renderHistoricoTab()} - {abaProntuarioAtiva === 'prescricoes' && renderPrescricoesTab()} - {abaProntuarioAtiva === 'exames' && renderExamesTab()} - {abaProntuarioAtiva === 'diagnosticos' && renderDiagnosticosTab()} - {abaProntuarioAtiva === 'evolucao' && renderEvolucaoTab()} - {abaProntuarioAtiva === 'anexos' && renderAnexosTab()} -
- )} -
-
- ); - - // Função para alterar campos da consulta atual - const handleConsultaChange = (field: string, value: string) => { - setConsultaAtual(prev => ({ - ...prev, - [field]: value - })); - }; - - // Função para salvar a consulta - const handleSalvarConsulta = () => { - if (!consultaAtual.anamnese || !consultaAtual.exameFisico) { - alert('Por favor, preencha os campos que são obrigatórios.'); - return; - } - - const novaConsulta = { - ...consultaAtual, - id: Date.now(), - paciente: pacienteSelecionado?.nome, - dataCriacao: new Date().toLocaleString(), - profissional: medico.nome - }; - - setConsultasRegistradas(prev => [novaConsulta, ...prev]); - - setConsultaAtual({ - dataConsulta: new Date().toISOString().split('T')[0], - anamnese: "", - exameFisico: "", - hipotesesDiagnosticas: "", - condutaMedica: "", - prescricoes: "", - retornoAgendado: "", - cid10: "" - }); - - alert('Consulta registrada com sucesso!'); - }; - - // Funções para renderizar cada aba do prontuário - const renderNovaConsultaTab = () => ( -
-
-

Registrar Nova Consulta

-
- - -
-
- -
- {/* Data da Consulta */} -
-
- - handleConsultaChange('dataConsulta', e.target.value)} - className="w-full" - /> -
- -
- - handleConsultaChange('cid10', e.target.value)} - placeholder="Ex: I10, E11, etc." - className="w-full" - /> -
-
- - {/* Anamnese */} -
- -