# Entidades - Farmácia

Esta página apresenta todas as informações **para o recebimento dos dados de farmácia no SAGRES Captura 2.0**.

  
<span>⚠️ Páginas com a tag </span>**\[WIP\]** ainda estão em revisão pelo TCE e/ou não foram implementadas, podendo sofrer alterações.

# Estoque Farmácia

# Estoque Farmácia | 2025 -

##### **Tipo Envio: Balancete - Farmácia**

---

##### **Chave Unicidade**

 \[ Exercício - Mês - Código Unidade Gestora - Código Farmácia - Código Produto \]

---

##### **Objeto Raiz**

<figure class="wp-block-table is-style-stripes" id="bkmrk-campo-informacoes"><table class="has-fixed-layout" style="width: 100%;"><thead><tr><td style="width: 12.1549%;">**Campo**</td><td style="width: 87.8451%;">**Informações**</td></tr></thead><tbody><tr><td style="width: 12.1549%;">`timestamp`</td><td style="width: 87.8451%;">Campo utilizado para **ordenar** a validação das informações enviadas. Caso sejam enviados **múltiplos payloads** do mesmo tipo, a ordenação ocorrerá da **<span style="color: rgb(186, 55, 42);">data mais antiga para a mais recente</span>**</td></tr><tr><td style="width: 12.1549%;">`elementos`</td><td style="width: 87.8451%;">–</td></tr></tbody></table>

</figure>---

##### **Item**  


<figure class="wp-block-table is-style-stripes" id="bkmrk-campo-chave-informacoes"><table class="has-fixed-layout"><thead><tr><td>**Campo**</td><td class="has-text-align-left align-center" data-align="left">**Chave**</td><td>**Informações**</td></tr></thead><tbody><tr><td>`codigoFarmacia`</td><td class="has-text-align-left align-center" data-align="left">✅</td><td>–</td></tr><tr><td>`codigoProduto`</td><td class="has-text-align-left align-center" data-align="left">✅</td><td>–</td></tr><tr><td>`descricaoProduto`</td><td class="has-text-align-left align-center" data-align="left">–</td><td>–</td></tr><tr><td>`unidadeMedida`</td><td class="has-text-align-left align-center" data-align="left">–</td><td>–</td></tr><tr><td>`quantidade`</td><td class="has-text-align-left align-center" data-align="left">–</td><td>–</td></tr><tr><td>`action`</td><td class="has-text-align-left align-center" data-align="left">–</td><td>Define a operação a ser realizada com a informação, seja ela **criação, atualização ou exclusão**</td></tr></tbody></table>

</figure>---

##### **Schema**

```
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Lista de Estoques Farmácia",
  "description": "Lista de objetos representando a entidade Estoque Farmácia",
  "type": "object",
  "properties": {
    "timestamp": {
      "type": "string",
      "pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])T([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d)\\.\\d{3,6}$",
      "examples": ["2025-09-11T15:30:00.123456"]
    },
    "elementos": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "title": "Estoque Farmácia",
        "description": "Representação do schema para envio da entidade Estoque Farmácia",
        "type": "object",
        "properties": {
          "codigoFarmacia": {
            "type": "string",
            "minLength": 7,
            "maxLength": 7,
            "pattern": "^[A-Z0-9]+$"
          },
          "codigoProduto": {
            "type": "string",
            "minLength": 14,
            "maxLength": 14,
            "pattern": "^[A-Z0-9]+$"
          },
          "descricaoProduto": {
            "type": "string",
            "minLength": 10,
            "maxLength": 60
          },
          "unidadeMedida": {
            "type": "string",
            "minLength": 1,
            "maxLength": 10
          },
          "quantidade": {
            "type": "number",
            "minimum": 0
          },
          "action": {
            "type": "string",
            "enum": [
              "CREATE",
              "UPDATE",
              "DELETE"
            ]
          }
        },
        "required": [
          "codigoFarmacia",
          "codigoProduto",
          "descricaoProduto",
          "unidadeMedida",
          "quantidade",
          "action"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "timestamp",
    "elementos"
  ],
  "additionalProperties": false
}

```

---

##### **Exemplo de Payload**

```
{
  "timestamp": "2025-09-11T15:30:00.123456",
  "elementos": [
    {
      "codigoFarmacia": "0000001",
      "codigoProduto": "00000000000001",
      "descricaoProduto": "Dipirona 500mg Comprimido Para dor e febre",
      "unidadeMedida": "comprimido",
      "quantidade": 1500.50,
      "action": "CREATE"
    },
    {
      "codigoFarmacia": "0000002",
      "codigoProduto": "00000000000002",
      "descricaoProduto": "Amóxicilina 500mg Cápsula Antibiótico",
      "unidadeMedida": "cápsula",
      "quantidade": 2500.00,
      "action": "UPDATE"
    }
  ]
}

```

---

### Regras

<table id="bkmrk-regra-estoque" style="width: 100%; height: 76.3907px;"><thead><tr style="height: 29.7969px;"><td style="width: 46.4784%; height: 29.7969px;">ID</td><td style="width: 53.5216%; height: 29.7969px;">Regra</td></tr></thead><tbody><tr style="height: 46.5938px;"><td style="width: 46.4784%; height: 46.5938px;">**ESTOQUE\_FARMACIA\_DUPLICIDADE\_NAO\_PERMITIDA**</td><td style="width: 53.5216%; height: 46.5938px;">Não é permitido cadastrar registros duplicados pela chave de unicidade</td></tr><tr><td style="width: 46.4784%;">**ESTOQUE\_FARMACIA\_FARMACIA\_CADASTRADA**</td><td style="width: 53.5216%;">A farmácia deve ter sido cadastrada para unidade gestora no exercício</td></tr></tbody></table>

# Farmácia

# Farmácia | 2025 -

##### **Tipo Envio: Balancete - Farmácia**

---

##### **Chave Unicidade**

 \[ Exercício - Código Unidade Gestora - Código Farmácia - Descrição - Tipo Logradouro - Número Logradouro - Complemento Logradouro - CEP Logradouro - Nome Responsável - CPF Responsável - CRF Responsável \]

---

##### **Objeto Raiz**

<figure class="wp-block-table is-style-stripes" id="bkmrk-campo-informacoes"><table class="has-fixed-layout" style="width: 100%;"><thead><tr><td style="width: 12.1549%;">**Campo**</td><td style="width: 87.8451%;">**Informações**</td></tr></thead><tbody><tr><td style="width: 12.1549%;">`timestamp`</td><td style="width: 87.8451%;">Campo utilizado para **ordenar** a validação das informações enviadas. Caso sejam enviados **múltiplos payloads** do mesmo tipo, a ordenação ocorrerá da **<span style="color: rgb(186, 55, 42);">data mais antiga para a mais recente</span>**</td></tr><tr><td style="width: 12.1549%;">`elementos`</td><td style="width: 87.8451%;">–</td></tr></tbody></table>

</figure>---

##### **Item**  


<figure class="wp-block-table is-style-stripes" id="bkmrk-campo-chave-informacoes"><table class="has-fixed-layout" style="width: 99.4048%; height: 316.328px;"><thead><tr style="height: 29.7969px;"><td style="width: 22.0624%; height: 29.7969px;">**Campo**</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 29.7969px;">**Chave**</td><td style="width: 70.5036%; height: 29.7969px;">**Informações**</td></tr></thead><tbody><tr style="height: 30.1094px;"><td style="width: 22.0624%; height: 30.1094px;">`codigoFarmacia`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 30.1094px;">✅</td><td style="width: 70.5036%; height: 30.1094px;">–</td></tr><tr style="height: 30.1094px;"><td style="width: 22.0624%; height: 30.1094px;">`descricao`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 30.1094px;">–</td><td style="width: 70.5036%; height: 30.1094px;">–</td></tr><tr style="height: 29.7969px;"><td style="width: 22.0624%; height: 29.7969px;">`tipoLogradouro`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 29.7969px;">–</td><td style="width: 70.5036%; height: 29.7969px;">–</td></tr><tr><td style="width: 22.0624%;">`numeroLogradouro`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 29.7969px;">–</td><td style="width: 70.5036%; height: 29.7969px;">–</td></tr><tr style="height: 29.7969px;"><td style="width: 22.0624%; height: 29.7969px;">`complementoLogradouro`</td><td class="align-center" style="width: 7.43405%; height: 29.7969px;">–</td><td class="align-left" style="width: 70.5036%; height: 29.7969px;">–</td></tr><tr style="height: 29.7969px;"><td style="width: 22.0624%; height: 29.7969px;">`cepLogradouro`</td><td class="align-center" style="width: 7.43405%; height: 29.7969px;">–</td><td class="align-left" style="width: 70.5036%; height: 29.7969px;">–</td></tr><tr style="height: 30.1094px;"><td style="width: 22.0624%; height: 30.1094px;">`nomeResponsavel`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 30.1094px;">–</td><td style="width: 70.5036%; height: 30.1094px;">–</td></tr><tr style="height: 30.1094px;"><td style="width: 22.0624%; height: 30.1094px;">`cpfResponsavel`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 30.1094px;">–</td><td style="width: 70.5036%; height: 30.1094px;">–</td></tr><tr style="height: 30.1094px;"><td style="width: 22.0624%; height: 30.1094px;">`crfResponsavel`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 30.1094px;">–</td><td style="width: 70.5036%; height: 30.1094px;">–</td></tr><tr style="height: 46.5938px;"><td style="width: 22.0624%; height: 46.5938px;">`action`</td><td class="has-text-align-left align-center" data-align="left" style="width: 7.43405%; height: 46.5938px;">–</td><td style="width: 70.5036%; height: 46.5938px;">Define a operação a ser realizada com a informação, seja ela **criação, atualização ou exclusão**</td></tr></tbody></table>

</figure>---

##### **Schema**

```
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Lista de Farmácias",
  "description": "Lista de objetos representando a entidade Farmácia",
  "type": "object",
  "properties": {
    "timestamp": {
      "type": "string",
      "pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])T([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d)\\.\\d{3,6}$",
      "examples": ["2025-09-11T15:30:00.123456"]
    },
    "elementos": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "title": "Farmácia",
        "description": "Representação do schema para envio da entidade Farmácia",
        "type": "object",
        "properties": {
          "codigoFarmacia": {
            "type": "string",
            "minLength": 7,
            "maxLength": 7,
            "pattern": "^[A-Z0-9]+$"
          },
          "descricao": {
            "type": "string",
            "minLength": 10,
            "maxLength": 100
          },
          "tipoLogradouro": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "numeroLogradouro": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50
          },
          "cepLogradouro": {
            "type": "string",
            "minLength": 1,
            "maxLength": 30
          },
          "complementoLogradouro": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "nomeResponsavel": {
            "type": "string",
            "minLength": 10,
            "maxLength": 150
          },
          "cpfResponsavel": {
            "type": "string",
            "minLength": 11,
            "maxLength": 11,
            "pattern": "^[0-9]+$"
          },
          "crfResponsavel": {
            "type": "string",
            "minLength": 10,
            "maxLength": 10
          },
          "action": {
            "type": "string",
            "enum": [
              "CREATE",
              "UPDATE",
              "DELETE"
            ]
          }
        },
        "required": [
          "codigoFarmacia",
          "descricao",
          "numeroLogradouro",
          "cepLogradouro",
          "tipoLogradouro",
          "complementoLogradouro",
          "nomeResponsavel",
          "cpfResponsavel",
          "crfResponsavel",
          "action"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "timestamp",
    "elementos"
  ],
  "additionalProperties": false
}

```

---

##### **Exemplo de Payload**

```
{
  "timestamp": "2025-09-11T15:30:00.123456",
  "elementos": [
    {
      "codigoFarmacia": "1234567",
      "descricao": "Farmácia Central da Cidade",
      "tipoLogradouro": "Rua",
      "numeroLogradouro": "123",
      "cepLogradouro": "58000000",
      "complementoLogradouro": "Próximo ao mercado central",
      "nomeResponsavel": "João da Silva Santos",
      "cpfResponsavel": "12345678901",
      "crfResponsavel": "1234567890",
      "action": "CREATE"
    },
    {
      "codigoFarmacia": "7654321",
      "descricao": "Farmácia Popular Bairro Norte",
      "tipoLogradouro": "Avenida",
      "numeroLogradouro": "456",
      "cepLogradouro": "58010000",
      "complementoLogradouro": "Sala 02, ao lado da padaria",
      "nomeResponsavel": "Maria Oliveira Souza",
      "cpfResponsavel": "10987654321",
      "crfResponsavel": "0987654321",
      "action": "UPDATE"
    }
  ]
}
```

---

### Regras

<table id="bkmrk-regra-farmacia" style="width: 100%; height: 59.5938px;"><thead><tr style="height: 29.7969px;"><td style="width: 37.4255%; height: 29.7969px;">ID</td><td style="width: 62.5745%; height: 29.7969px;">Regra</td></tr></thead><tbody><tr style="height: 29.7969px;"><td style="width: 37.4255%; height: 29.7969px;">**FARMACIA\_DUPLICIDADE\_NAO\_PERMITIDA**</td><td style="width: 62.5745%; height: 29.7969px;">Não é permitido cadastrar registros duplicados pela chave de unicidade</td></tr><tr><td style="width: 37.4255%;">**FARMACIA\_RESPONSAVEL\_NOME\_INVALIDO**</td><td style="width: 62.5745%;">O nome do responsável deve ser correspondente ao cadastrado na Receita Federal</td></tr></tbody></table>