> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nextmed.med.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrações Gateway

> Endpoints externos consumidos pela aplicação.

## Integracoes Gateway

Base URL:

```text theme={"system"}
NEXT_PUBLIC_GATEWAY_HOST_WEB
```

Default em desenvolvimento:

```text theme={"system"}
https://api-dev.nextmed.med.br
```

Headers padrao:

```http theme={"system"}
Authorization: Bearer {token}
app-name: nextmed-web
```

## Auth service

| Metodo | Path                                              | Uso                                              |
| ------ | ------------------------------------------------- | ------------------------------------------------ |
| `POST` | `/auth-service/auth`                              | Login `USERPASS`.                                |
| `POST` | `/auth-service/refresh-token`                     | Renovacao de token.                              |
| `POST` | `/auth-service/signup`                            | Cadastro de usuario.                             |
| `POST` | `/auth-service/signup-model`                      | Validacao de dados medicos no cadastro.          |
| `GET`  | `/auth-service/activation-code?ownerRef={userId}` | Novo codigo de ativacao.                         |
| `POST` | `/auth-service/change-phone`                      | Atualizacao de telefone para codigo de ativacao. |

## User service

| Metodo      | Path                                                                          | Uso                                |
| ----------- | ----------------------------------------------------------------------------- | ---------------------------------- |
| `GET`       | `/user-service/users/{userId}`                                                | Buscar dados do usuario.           |
| `PUT`       | `/user-service/users/{userId}`                                                | Atualizar dados pessoais.          |
| `POST`      | `/user-service/users/{userId}/avatar`                                         | Upload de avatar.                  |
| `PATCH/PUT` | `/user-service/users/{userId}/status`                                         | Alternar status do usuario.        |
| `PUT`       | `/user-service/users/{userId}/profiles/{profileId}/specialties/{specialtyId}` | Atualizar especialidade do perfil. |
| `GET`       | `/user-service/users/doctors`                                                 | Buscar medicos.                    |
| `POST`      | `/user-service/users/{userId}/account/change-password`                        | Alterar senha.                     |

## Attendance service

| Metodo | Path                                                                      | Uso                                        |
| ------ | ------------------------------------------------------------------------- | ------------------------------------------ |
| `GET`  | `/attendance-service/referrals{filters}`                                  | Listar encaminhamentos.                    |
| `POST` | `/attendance-service/referrals`                                           | Criar encaminhamento.                      |
| `PUT`  | `/attendance-service/referrals/{referralId}`                              | Atualizar paciente/encaminhamento.         |
| `GET`  | `/attendance-service/referrals/{referralId}`                              | Buscar detalhe no webhook Dyte.            |
| `POST` | `/attendance-service/referrals/{referralId}/exams/upload`                 | Upload de exame.                           |
| `POST` | `/attendance-service/referrals/{referralId}/medical-report`               | Criar relatorio medico.                    |
| `POST` | `/attendance-service/referrals/{referralId}/report/update-viewing-status` | Marcar relatorio como visualizado.         |
| `POST` | `/attendance-service/referrals/{referralId}/meetings`                     | Criar meeting associada ao encaminhamento. |
| `POST` | `/attendance-service/referrals/{referralId}/meetings/{meetingId}/user`    | Atualizar status do usuario na meeting.    |

## Institution service

| Metodo           | Path                                                                       | Uso                                             |
| ---------------- | -------------------------------------------------------------------------- | ----------------------------------------------- |
| `GET`            | `/institution-service/referrals/{referralId}`                              | Buscar contexto do encaminhamento para UI e IA. |
| `GET`            | `/institution-service/institutions/specialties/{institutionId}`            | Listar especialidades por instituicao.          |
| `GET`            | `/institution-service/health-unity/{institutionId}`                        | Listar unidades de saude.                       |
| `POST`           | `/institution-service/health-unity/assign/{institutionId}/{userProfileId}` | Solicitar vinculo com unidades.                 |
| `POST`           | `/institution-service/health-unity`                                        | Criar unidade via camada `@core`.               |
| `GET`            | `/institution-service/coordinator/find-by-institution-id/{institutionId}`  | Buscar coordenadores.                           |
| `GET/PUT/DELETE` | `/institution-service/coordinator/{coordId}`                               | Operacoes de coordenador.                       |
| `GET`            | `/institution-service/coordinator/unities-profiles/{coordId}`              | Perfis/unidades do coordenador.                 |
| `PATCH/POST`     | `/institution-service/coordinator/update-status`                           | Atualizar status de coordenador.                |

## Notification service

| Metodo | Path                                                               | Uso                             |
| ------ | ------------------------------------------------------------------ | ------------------------------- |
| `POST` | `/notification-service/notification`                               | Criar notificacao.              |
| `GET`  | `/notification-service/notification/user/{userId}`                 | Listar notificacoes do usuario. |
| `POST` | `/notification-service/notification/mark-as-seen/{notificationId}` | Marcar notificacao como vista.  |

## AI service legado

| Metodo | Path                             | Uso                           |
| ------ | -------------------------------- | ----------------------------- |
| `POST` | `/ai/v1/generate-anamnesis-form` | Gerar opcoes de anamnese.     |
| `POST` | `/ai/v1/generate-anamnesis`      | Gerar anamnese com perguntas. |

## Servicos externos diretos

| Servico | Endpoint                                            | Uso                                               |
| ------- | --------------------------------------------------- | ------------------------------------------------- |
| Dyte    | `{DYTE_BASE_URL}/meetings`                          | Criar meeting.                                    |
| Dyte    | `{DYTE_BASE_URL}/meetings/{meetingId}/participants` | Criar participante.                               |
| OpenAI  | Chat Completions                                    | Chat medico, acoes rapidas, sugestoes e anamnese. |
| OpenAI  | Audio Transcriptions `whisper-1`                    | Transcricao de audio.                             |
| is.gd   | `https://is.gd/create.php?format=simple&url={url}`  | Encurtamento de URL.                              |
