{
  "info": {
    "name": "API CPC — DEV FAKE da unidade",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Credenciais vazias; preencher localmente e executar Emitir token. Os exemplos clínicos usam somente identificadores fictícios."
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api-prontuario.cpcbrasil.com"
    },
    {
      "key": "client_id",
      "value": "upa_santoantonio_dev"
    },
    {
      "key": "client_secret",
      "value": ""
    },
    {
      "key": "access_token",
      "value": ""
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{access_token}}",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "Saúde HTTP",
      "request": {
        "method": "GET",
        "auth": {
          "type": "noauth"
        },
        "url": "{{base_url}}/health"
      }
    },
    {
      "name": "Emitir token",
      "request": {
        "method": "POST",
        "auth": {
          "type": "noauth"
        },
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{base_url}}/api/v1/auth/token",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"client_id\": \"{{client_id}}\",\n  \"client_secret\": \"{{client_secret}}\"\n}"
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Token emitido\", () => pm.response.to.have.status(200));",
              "if (pm.response.code === 200) { pm.collectionVariables.set(\"access_token\", pm.response.json().access_token); }"
            ]
          }
        }
      ]
    },
    {
      "name": "Identidade",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/auth/me"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "CPF",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/pacientes/cpf/52998224725"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "CNS",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/pacientes/cns/700000000000000"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Nome e nascimento",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/pacientes/busca?nome=PACIENTE+FICTICIO+SEM+DADOS+REAIS&data_nascimento=1990-01-15"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Número de atendimento",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/atendimentos/910001"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Atendimentos por CNES",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/unidades/0000000/atendimentos"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Internações por CNES",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/unidades/0000000/internacoes"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Atendimentos por data",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/unidades/atendimentos?cnes=0000000&data_atendimento=2026-10-20"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Internações por data",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/unidades/internacoes?cnes=0000000&data_internacao=2026-10-21"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Atendimentos por período",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/unidades/atendimentos?cnes=0000000&data_inicial=2026-10-20&data_final=2026-10-21"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Internações por período",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/unidades/internacoes?cnes=0000000&data_inicial=2026-10-20&data_final=2026-10-21"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Consulta concluída\", () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    }
  ]
}
