This commit is contained in:
21
api/.editorconfig
Normal file
21
api/.editorconfig
Normal file
@@ -0,0 +1,21 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.blade.php]
|
||||
insert_final_newline = false
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[TODO*]
|
||||
indent_size = 2
|
||||
97
api/.env.example
Normal file
97
api/.env.example
Normal file
@@ -0,0 +1,97 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_URL_FRONTEND=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
QUEUE_CONNECTION=database
|
||||
QUEUE_NAME=default
|
||||
QUEUE_DB_HOST=localhost
|
||||
QUEUE_DB_PORT=3306
|
||||
QUEUE_DB_USERNAME=root
|
||||
QUEUE_DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=pusher
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
MEMCACHED_HOST=memcached
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_HOST=redis
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
|
||||
PUSHER_HOST=
|
||||
PUSHER_PORT=
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
# Dados para configuração do JWT.
|
||||
JWT_SECRET=
|
||||
JWT_SECRET_EXTERNAL=
|
||||
JWT_TTL=480
|
||||
|
||||
# Dados para configuração do WKHTMLTOPDF para geração de PDF.
|
||||
WKHTML_PDF_BINARY=
|
||||
|
||||
# Dados para acesso à API de assinatura eletrônica.
|
||||
PKI_ENDPOINT_URL=
|
||||
PKI_ACCESS_TOKEN=
|
||||
|
||||
# Dados para acesso à API de integração.
|
||||
INTEGRACAO_CIDADAO_URL=http://localhost
|
||||
INTEGRACAO_CIDADAO_SENHA=rkm2021
|
||||
|
||||
# Dados para acesso ao histórico do ConectaSUS V1.
|
||||
CONECTASUS_V1_URL=
|
||||
CONECTASUS_V1_URL_PEDERNEIRAS=
|
||||
|
||||
# Dados para envio de notificações via Telegram.
|
||||
TELEGRAM_BOT_TOKEN=
|
||||
TELEGRAM_CHAT_ID=
|
||||
|
||||
# Dados para acesso à integrações externas.
|
||||
BNAFAR_HOMOLOGACAO_URL_API_SERVICO=https://servicoshm.saude.gov.br/bnafar
|
||||
BNAFAR_HOMOLOGACAO_URL_API_TOKEN=http://servicoshm.saude.gov.br/jwtauth/auth
|
||||
BNAFAR_PRODUCAO_URL_API_SERVICO=https://servicos.saude.gov.br/bnafar
|
||||
BNAFAR_PRODUCAO_URL_API_TOKEN=https://servicos.saude.gov.br/jwtauth/auth
|
||||
CNS_HOMOLOGACAO_URL_API_SERVICO=https://servicoshm.saude.gov.br/cadsus/v2/PDQSupplierJWT
|
||||
CNS_HOMOLOGACAO_URL_API_TOKEN=https://ehr-auth-hmg.saude.gov.br/api/osb/token
|
||||
CNS_PRODUCAO_URL_API_SERVICO=https://servicos.saude.gov.br/cadsus/v2/PDQSupplierJWT
|
||||
CNS_PRODUCAO_URL_API_TOKEN=https://ehr-auth.saude.gov.br/api/osb/token
|
||||
RIA_HOMOLOGACAO_URL_API_SERVICO=ehr-services-hmg.saude.gov.br/api
|
||||
RIA_HOMOLOGACAO_URL_API_TOKEN=ehr-auth-hmg.saude.gov.br/api/token
|
||||
RIA_PRODUCAO_URL_API_SERVICO=ehr-services.saude.gov.br/api
|
||||
RIA_PRODUCAO_URL_API_TOKEN=ehr-auth.saude.gov.br/api/token
|
||||
RIRA_HOMOLOGACAO_URL_API_SERVICO=https://ehr-services-hmg.saude.gov.br/api
|
||||
RIRA_HOMOLOGACAO_URL_API_TOKEN=https://ehr-auth-hmg.saude.gov.br/api/token
|
||||
RIRA_PRODUCAO_URL_API_SERVICO=https://uf-ehr-services.saude.gov.br/api
|
||||
RIRA_PRODUCAO_URL_API_TOKEN=https://ehr-auth.saude.gov.br/api/token
|
||||
|
||||
RUN_SCHEDULE=
|
||||
BIN
api/.env.swp
Normal file
BIN
api/.env.swp
Normal file
Binary file not shown.
5
api/.gitattributes
vendored
Normal file
5
api/.gitattributes
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.scss linguist-vendored
|
||||
*.js linguist-vendored
|
||||
CHANGELOG.md export-ignore
|
||||
18
api/.gitignore
vendored
Normal file
18
api/.gitignore
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/logs/mobile
|
||||
/storage/pronto-atendimento/*
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
connections.json
|
||||
routes.txt
|
||||
.idea/
|
||||
TODO*
|
||||
13
api/.styleci.yml
Normal file
13
api/.styleci.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
php:
|
||||
preset: laravel
|
||||
disabled:
|
||||
- no_unused_imports
|
||||
finder:
|
||||
not-name:
|
||||
- index.php
|
||||
- server.php
|
||||
js:
|
||||
finder:
|
||||
not-name:
|
||||
- webpack.mix.js
|
||||
css: true
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Farmacia;
|
||||
|
||||
use App\Enums\Administracao\Modulo;
|
||||
use App\Models\PainelSenha\Fila;
|
||||
use App\Models\PainelSenha\OpcaoEntrada;
|
||||
use App\Services\Administracao\ModuloService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class LimparFilaAtendimentoCommand extends Command
|
||||
{
|
||||
protected $signature = 'farmacia:limpar-fila-atendimento';
|
||||
protected $description = 'Comando para limpeza da fila de atendimento no módulo farmácia.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
$this->getClientes()->each(function($cliente) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
Config::set('database.default', $cliente);
|
||||
|
||||
Fila::where('finalizado', false)
|
||||
->where('evadido', false)
|
||||
->whereIn('opcao_entrada_id', $this->getOpcoesEntrada())
|
||||
->update([
|
||||
'finalizado' => true,
|
||||
'evadido' => true,
|
||||
]);
|
||||
|
||||
Log::channel('farmacia-fila-atendimento')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'LimparFilaAtendimentoCommand',
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
} catch (Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
Log::channel('farmacia-fila-atendimento')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'LimparFilaAtendimentoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Farmácia (' . ($cliente) . '):</strong> (Erro ao executar o comando: LimparFilaAtendimentoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('farmacia-fila-atendimento')->error('Erro ao executar o comando', [
|
||||
'origem' => 'LimparFilaAtendimentoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Farmácia:</strong> (Erro ao executar o comando: LimparFilaAtendimentoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
|
||||
private function getOpcoesEntrada()
|
||||
{
|
||||
return OpcaoEntrada::where('modulo_id', ModuloService::getId(Modulo::FARMACIA))
|
||||
->pluck('id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Bnafar;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\BnafarService;
|
||||
use App\Services\Integracao\Bnafar\PosicaoEstoqueService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarPosicaoEstoqueCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:bnafar-enviar-posicao-estoque';
|
||||
protected $description = 'Comando para envio de posição de estoque ao BNAFAR.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
$ibge = substr($cliente->municipio->ibge, 0, 6);
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = BnafarService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = BnafarService::getToken($parametrizacao->usuario, $parametrizacao->senha);
|
||||
|
||||
if (!is_null($token)) {
|
||||
$token = $token['access_token'];
|
||||
|
||||
PosicaoEstoqueService::store();
|
||||
PosicaoEstoqueService::post($cliente->link, $token, $ibge);
|
||||
|
||||
Log::channel('integracao-bnafar')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarPosicaoEstoqueCommand',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarPosicaoEstoqueCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarPosicaoEstoqueCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarPosicaoEstoqueCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR:</strong> (Erro ao executar o comando: EnviarPosicaoEstoqueCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Bnafar;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\Bnafar\SaidaService;
|
||||
use App\Services\Integracao\BnafarService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarSaidaCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:bnafar-enviar-saida';
|
||||
protected $description = 'Comando para envio de saida ao BNAFAR.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
$ibge = substr($cliente->municipio->ibge, 0, 6);
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = BnafarService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = BnafarService::getToken($parametrizacao->usuario, $parametrizacao->senha);
|
||||
|
||||
if (!is_null($token)) {
|
||||
$token = $token['access_token'];
|
||||
|
||||
SaidaService::store();
|
||||
SaidaService::post($cliente->link, $token, $ibge);
|
||||
|
||||
Log::channel('integracao-bnafar')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarSaidaCommand',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarSaidaCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarSaidaCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarSaidaCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR:</strong> (Erro ao executar o comando: EnviarSaidaCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Bnafar;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\Bnafar\PosicaoEstoqueService;
|
||||
use App\Services\Integracao\BnafarService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class VerificarPosicaoEstoqueCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:bnafar-verificar-posicao-estoque';
|
||||
protected $description = 'Comando para verificação de posição de estoque enviada ao BNAFAR.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
$ibge = substr($cliente->municipio->ibge, 0, 6);
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = BnafarService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = BnafarService::getToken($parametrizacao->usuario, $parametrizacao->senha);
|
||||
|
||||
if (!is_null($token)) {
|
||||
$token = $token['access_token'];
|
||||
|
||||
PosicaoEstoqueService::check($cliente->link, $token, $ibge);
|
||||
|
||||
Log::channel('integracao-bnafar')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'VerificarPosicaoEstoqueCommand',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'VerificarPosicaoEstoqueCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: VerificarPosicaoEstoqueCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'origem' => 'VerificarPosicaoEstoqueCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR:</strong> (Erro ao executar o comando: VerificarPosicaoEstoqueCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Bnafar;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\Bnafar\SaidaService;
|
||||
use App\Services\Integracao\BnafarService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class VerificarSaidaCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:bnafar-verificar-saida';
|
||||
protected $description = 'Comando para verificação de saida enviada ao BNAFAR.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
$ibge = substr($cliente->municipio->ibge, 0, 6);
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = BnafarService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = BnafarService::getToken($parametrizacao->usuario, $parametrizacao->senha);
|
||||
|
||||
if (!is_null($token)) {
|
||||
$token = $token['access_token'];
|
||||
|
||||
SaidaService::check($cliente->link, $token, $ibge);
|
||||
|
||||
Log::channel('integracao-bnafar')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'VerificarSaidaCommand',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'VerificarSaidaCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: VerificarSaidaCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-bnafar')->error('Erro ao executar o comando', [
|
||||
'origem' => 'VerificarSaidaCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração BNAFAR:</strong> (Erro ao executar o comando: VerificarSaidaCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Erpsaude;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Integracao\Erpsaude\Atendimento as ErpsaudeAtendimento;
|
||||
use App\Models\Integracao\Erpsaude\Exame as ErpsaudeExame;
|
||||
use App\Models\Integracao\Erpsaude\Medicamento;
|
||||
use App\Models\Integracao\Erpsaude\Paciente as ErpsaudePaciente;
|
||||
use App\Models\Integracao\Erpsaude\Reavaliacao;
|
||||
use App\Models\Integracao\Erpsaude\TipoAlta;
|
||||
use App\Models\Integracao\Erpsaude\TipoAtendimento as ErpsaudeTipoAtendimento;
|
||||
use App\Models\Integracao\Erpsaude\UnidadeAtendimento;
|
||||
use App\Models\Integracao\Erpsaude\UnidadeEncaminhadora;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BuscarAtendimentosHospitalSantaCasaCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:erpsaude-buscar-atendimentos-hospital-santa-casa';
|
||||
protected $description = 'Comando para buscar os atendimentos realizados no hospital santa casa.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
try {
|
||||
$cliente = Cliente::where('link', 'santarita')
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$token = env('ERPSAUDE_ACCESS_TOKEN');
|
||||
$url = env('ERPSAUDE_ENDPOINT_URL') . "DadosPaciente";
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => "Bearer $token"
|
||||
])->get($url);
|
||||
|
||||
$dados = $response->json();
|
||||
|
||||
if (!is_array($dados)) {
|
||||
Log::channel('integracao-erpsaude')->error('A resposta da API não retornou um array válido', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'BuscarAtendimentosHospitalSantaCasaCommand',
|
||||
'dados' => $dados,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($response->successful()) {
|
||||
foreach ($dados as $item) {
|
||||
|
||||
$cpf = isset($item['cpf']) ? substr(preg_replace('/\D/', '', $item['cpf']), 0, 11) : null;
|
||||
$dataNascimento = Carbon::createFromFormat('d/m/Y', $item['dataNascimento'])->format('Y-m-d');
|
||||
$cns = $item['cartaoNacionalSaude'];
|
||||
$nome = $item['paciente'];
|
||||
|
||||
$paciente = null;
|
||||
|
||||
if ($cpf) {
|
||||
$paciente = ErpsaudePaciente::where('cpf', $cpf)
|
||||
->where('nome', $nome)
|
||||
->where('data_nascimento', $dataNascimento)
|
||||
->first();
|
||||
}
|
||||
|
||||
if (!$paciente) {
|
||||
$paciente = ErpsaudePaciente::where('cns', $cns)
|
||||
->where('nome', $nome)
|
||||
->where('data_nascimento', $dataNascimento)
|
||||
->first();
|
||||
}
|
||||
|
||||
if (!$paciente) {
|
||||
$paciente = ErpsaudePaciente::create([
|
||||
'nome' => $nome,
|
||||
'cpf' => $cpf,
|
||||
'cns' => $cns,
|
||||
'data_nascimento' => $dataNascimento,
|
||||
'sexo' => $item['sexo'],
|
||||
'cep' => isset($item['cep']) ? preg_replace('/\D/', '', $item['cep']) : null,
|
||||
]);
|
||||
} else {
|
||||
|
||||
$paciente->update([
|
||||
'nome' => $nome,
|
||||
'cpf' => $cpf,
|
||||
'cns' => $cns,
|
||||
'data_nascimento' => $dataNascimento,
|
||||
'sexo' => $item['sexo'],
|
||||
'cep' => isset($item['cep']) ? preg_replace('/\D/', '', $item['cep']) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
$tipoAlta = TipoAlta::where('codigo', $item['codTipoAlta'])->first();
|
||||
$tipoAtendimento = ErpsaudeTipoAtendimento::where('codigo', (int) $item['codTipoAtendimento'])->first();
|
||||
$unidadeEncaminhadora = UnidadeEncaminhadora::where('codigo', (int) $item['codUnEncaminhadora'])->first();
|
||||
$unidadeAtendimento = UnidadeAtendimento::where('codigo', (int) $item['codUnAtendimento'])->first();
|
||||
|
||||
$atendimento = ErpsaudeAtendimento::create([
|
||||
'paciente_id' => $paciente->id,
|
||||
'registro_paciente' => $item['registroPaciente'],
|
||||
'data' => Carbon::createFromFormat('d/m/Y', $item['data'])->format('Y-m-d'),
|
||||
'hora' => $item['hora'],
|
||||
'suspeita_maus_tratos' => $item['suspeitaMausTratos'],
|
||||
'hipotese_diagnostica' => $item['hipoteseDiagnostica'],
|
||||
'cid10' => $item['cid10'],
|
||||
'descricao_procedimento' => $item['descricaoProcedimento'],
|
||||
'descricao_exame_clinico' => $item['descricaoExameClinico'],
|
||||
'conduta_medica' => $item['condutaMedica'],
|
||||
'codigo_conta_prof' => $item['codigoContaProf'],
|
||||
'profissional' => $item['profissional'],
|
||||
'conselho' => $item['conselho'],
|
||||
'uf_conselho' => $item['ufConselho'],
|
||||
'convenio' => $item['convenio'],
|
||||
'registro_ans' => $item['registroAns'],
|
||||
'cod_convenio' => $item['codConvenio'],
|
||||
'nome_setor' => $item['nomeSetor'],
|
||||
'codigo_setor' => $item['codigoSetor'],
|
||||
'cod_tipo_encaminhamento' => $item['codTipoEncaminhamento'],
|
||||
'tipo_atendimento_id' => $tipoAtendimento ? $tipoAtendimento->id : null,
|
||||
'cod_grupo_atendimento' => $item['codGrupoAtendimento'],
|
||||
'unidade_encaminhadora_id' => $unidadeEncaminhadora ? $unidadeEncaminhadora->id : null,
|
||||
'unidade_atendimento_id' => $unidadeAtendimento ? $unidadeAtendimento->id : null,
|
||||
'data_atendimento' => Carbon::createFromFormat('d/m/Y', $item['dataAtendimento'])->format('Y-m-d'),
|
||||
'data_alta' => !empty($item['dataAlta']) && preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $item['dataAlta'])
|
||||
? Carbon::createFromFormat('d/m/Y', $item['dataAlta'])->format('Y-m-d')
|
||||
: null,
|
||||
'horario_atendimento' => $item['horarioAtendimento'],
|
||||
'hora_alta' => isset($item['horaAlta']) && trim($item['horaAlta']) !== '' ? $item['horaAlta'] : null,
|
||||
'tipo_alta_id' => $tipoAlta ? $tipoAlta->id : null,
|
||||
'unidade_atendimento' => $item['unAtendimento'],
|
||||
'cnes_un_atendimento' => $item['cnesUnAtendimento'],
|
||||
]);
|
||||
|
||||
if (!empty($item['reavaliacoes'])) {
|
||||
foreach ($item['reavaliacoes'] as $reavaliacao) {
|
||||
|
||||
Reavaliacao::create([
|
||||
'atendimento_id' => $atendimento->id,
|
||||
'reavaliacao' => $reavaliacao['reavalicao'],
|
||||
'profissional' => $reavaliacao['profissional'],
|
||||
'numero_conselho' => $reavaliacao['numConselho'],
|
||||
'uf_conselho' => $reavaliacao['ufConselho'],
|
||||
'data' => Carbon::createFromFormat('d/m/Y', $reavaliacao['dataReavaliacao'])->format('Y-m-d'),
|
||||
'hora' => $reavaliacao['horaReavaliacao'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item['medicamentos'])) {
|
||||
foreach ($item['medicamentos'] as $med) {
|
||||
|
||||
Medicamento::create([
|
||||
'atendimento_id' => $atendimento->id,
|
||||
'medicamento' => $med['medicamento'],
|
||||
'quantidade' => str_replace(',', '.', $med['qtdePresc']),
|
||||
'unidade_medida' => $med['uniMedPresc'],
|
||||
'medicamento_id' => $med['idMedicamento'],
|
||||
'tipo' => $med['tipo'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item['exames'])) {
|
||||
foreach ($item['exames'] as $exame) {
|
||||
|
||||
ErpsaudeExame::create([
|
||||
'atendimento_id' => $atendimento->id,
|
||||
'exame' => $exame['descricao'] ?? '',
|
||||
'tipo' => $exame['tipo'] ?? '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::channel('integracao-erpsaude')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'BuscarAtendimentosHospitalSantaCasaCommand'
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-erpsaude')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'BuscarAtendimentosHospitalSantaCasaCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
151
api/app/Console/Commands/Integracao/Esus/EnviarCommand.php
Normal file
151
api/app/Console/Commands/Integracao/Esus/EnviarCommand.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Esus;
|
||||
|
||||
use App\Models\Integracao\Esus\Parametrizacao;
|
||||
use App\Services\AtencaoBasica\Exportacao\ExportacaoService;
|
||||
use App\Services\Integracao\EsusService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:esus-enviar';
|
||||
protected $description = 'Comando para envio de fichas ao e-SUS.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$currentDatabase = Config::get('database.default');
|
||||
$mesAnoInicial = '072025';
|
||||
|
||||
try {
|
||||
|
||||
self::getClientes()->each(function($cliente) use($mesAnoInicial) {
|
||||
try {
|
||||
|
||||
Config::set('database.default', $cliente);
|
||||
|
||||
$parametrizacao = Parametrizacao::first();
|
||||
|
||||
if (!($parametrizacao->ativo ?? false)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$parametrizacao->url_instalacao = trim($parametrizacao->url_instalacao, '/');
|
||||
|
||||
try {
|
||||
|
||||
EsusService::getAuthorizationCookie($parametrizacao);
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
Log::channel('integracao-esus')->error('Falha na conexão.', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'EnviarCommand',
|
||||
'erro' => 'Exportação não realizada (falha no cookie inicial)',
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (ExportacaoService::gerarExportacoes($mesAnoInicial) as $nomeFicha => $fichas) {
|
||||
|
||||
$parametrizacao->cookie = EsusService::getAuthorizationCookie($parametrizacao);
|
||||
|
||||
try {
|
||||
|
||||
EsusService::deleteInconsistencias($cliente, $nomeFicha);
|
||||
|
||||
foreach ($fichas as $ficha) {
|
||||
|
||||
try {
|
||||
|
||||
EsusService::sendFicha($cliente, $parametrizacao, $nomeFicha, $ficha);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
|
||||
Log::channel('integracao-esus')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'EnviarCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração ESUS (' . $cliente . '):</strong> (Erro ao executar o comando: EnviarCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $error) {
|
||||
|
||||
Log::channel('integracao-esus')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'EnviarCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração ESUS (' . $cliente . '):</strong> (Erro ao executar o comando: EnviarCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::channel('integracao-esus')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'EnviarCommand'
|
||||
]);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
|
||||
Log::channel('integracao-esus')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'EnviarCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração ESUS (' . $cliente . '):</strong> (Erro ao executar o comando: EnviarCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception $error) {
|
||||
|
||||
Log::channel('integracao-esus')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração ESUS:</strong> (Erro ao executar o comando: EnviarCommand).');
|
||||
}
|
||||
}
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')
|
||||
->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])
|
||||
))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Integracao\Ria\DocumentoImunologicoRotina;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarDocumentoAlteradoCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-documento-alterado';
|
||||
protected $description = 'Comando para envio de documentos alterados ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($cliente, $parametrizacao, $parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getDocumentosAlterados()
|
||||
->each(function($documentoAlterado) use ($cliente, $parametrizacao, &$token, $expiresAt) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$documentoAlterado->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$documentoAlterado->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$documentoAlterado->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::sendDocumentoImunologicoRotina($headers, $documentoAlterado, $cliente->municipio->estado->uf);
|
||||
|
||||
if ($response->status() === 201) {
|
||||
$documentoAlterado->identificador_rnds = $response->header('Location') ? $response->header('Location') : null;
|
||||
$documentoAlterado->response = $response->json();
|
||||
$documentoAlterado->alterar = false;
|
||||
$documentoAlterado->atualizado = true;
|
||||
|
||||
DocumentoImunologicoRotinaService::update($documentoAlterado->documento_imunologico_rotina_id, $documentoAlterado);
|
||||
}
|
||||
else {
|
||||
DocumentoImunologicoRotina::where('id', $documentoAlterado->documento_imunologico_rotina_id)->update([
|
||||
'tentou_substituir' => true,
|
||||
]);
|
||||
|
||||
DocumentoImunologicoRotinaService::updateInconsistencias($documentoAlterado->documento_imunologico_rotina_id, $response->json());
|
||||
}
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarDocumentoAlteradoCommand'
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarDocumentoAlteradoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarDocumentoAlteradoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarDocumentoAlteradoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarDocumentoAlteradoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarDocumentoComInconsistenciaCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-documento-com-inconsistencia';
|
||||
protected $description = 'Comando para envio de documentos com inconsistencia ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($cliente, $parametrizacao, $parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getDocumentosComInconsistencia()
|
||||
->each(function($documentoComInconsistencia) use ($cliente, $parametrizacao, &$token, $expiresAt) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$documentoComInconsistencia->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$documentoComInconsistencia->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$documentoComInconsistencia->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::sendDocumentoImunologicoRotina($headers, $documentoComInconsistencia, $cliente->municipio->estado->uf);
|
||||
|
||||
$documentoComInconsistencia->identificador_rnds = $response->header('Location') ? $response->header('Location') : null;
|
||||
$documentoComInconsistencia->response = $response->json();
|
||||
|
||||
DocumentoImunologicoRotinaService::update($documentoComInconsistencia->documento_imunologico_rotina_id, $documentoComInconsistencia);
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarDocumentoComInconsistenciaCommand'
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarDocumentoComInconsistenciaCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarDocumentoComInconsistenciaCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarDocumentoComInconsistenciaCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarDocumentoComInconsistenciaCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarDocumentoComInconsistenciaRetroativoCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-documento-com-inconsistencia-retroativo';
|
||||
protected $description = 'Comando para envio de documentos com inconsistencia retroativos ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getDocumentosComInconsistenciaRetroativos()
|
||||
->each(function($documentoComInconsistenciaRetroativo) use ($cliente, $parametrizacao, &$token, $expiresAt) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$documentoComInconsistenciaRetroativo->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$documentoComInconsistenciaRetroativo->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$documentoComInconsistenciaRetroativo->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::sendDocumentoImunologicoRotina($headers, $documentoComInconsistenciaRetroativo, $cliente->municipio->estado->uf);
|
||||
|
||||
$documentoComInconsistenciaRetroativo->identificador_rnds = $response->header('Location') ? $response->header('Location') : null;
|
||||
$documentoComInconsistenciaRetroativo->response = $response->json();
|
||||
|
||||
DocumentoImunologicoRotinaService::update($documentoComInconsistenciaRetroativo->documento_imunologico_rotina_id, $documentoComInconsistenciaRetroativo);
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarDocumentoComInconsistenciaRetroativoCommand'
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarDocumentoComInconsistenciaRetroativoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarDocumentoComInconsistenciaRetroativoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarDocumentoComInconsistenciaRetroativoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarDocumentoComInconsistenciaRetroativoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Integracao\Ria\DocumentoImunologicoRotina;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarExclusaoDocumentoCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-exclusao-documento';
|
||||
protected $description = 'Comando para envio de exclusão de documentos ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getDocumentosParaExclusao()
|
||||
->each(function($documento) use ($parametrizacao, &$token, $expiresAt) {
|
||||
if (!app()->environment('production') && !str_contains($documento->identificador_rnds, 'ehr-services-hmg.saude.gov.br')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$documento->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$documento->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$documento->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::destroy($headers, $documento->identificador_rnds);
|
||||
|
||||
if ($response->status() === 204) {
|
||||
DocumentoImunologicoRotina::destroy($documento->id);
|
||||
}
|
||||
else {
|
||||
$documento->response = $response->json();
|
||||
|
||||
DocumentoImunologicoRotinaService::update($documento->id, $documento);
|
||||
}
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarExclusaoDocumentoCommand',
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarExclusaoDocumentoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarExclusaoDocumentoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarExclusaoDocumentoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarExclusaoDocumentoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarRegistroAplicacaoCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-registro-aplicacao';
|
||||
protected $description = 'Comando para envio de novos registros de aplicação ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getRegistrosAplicacao()
|
||||
->each(function($registroAplicacao) use ($cliente, $parametrizacao, &$token, $expiresAt) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$registroAplicacao->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$registroAplicacao->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$registroAplicacao->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::sendDocumentoImunologicoRotina($headers, $registroAplicacao, $cliente->municipio->estado->uf);
|
||||
|
||||
$registroAplicacao->identificador_rnds = $response->header('Location') ? $response->header('Location') : null;
|
||||
$registroAplicacao->response = $response->json();
|
||||
|
||||
DocumentoImunologicoRotinaService::store($registroAplicacao);
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarRegistroAplicacaoCommand',
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarRegistroAplicacaoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarRegistroAplicacaoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarRegistroAplicacaoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarRegistroAplicacaoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarRegistroAplicacaoRetroativoCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-registro-aplicacao-retroativo';
|
||||
protected $description = 'Comando para envio de registros de aplicação retroativos ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getRegistrosAplicacaoRetroativos()
|
||||
->each(function($registroAplicacaoRetroativo) use ($cliente, $parametrizacao, &$token, $expiresAt) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$registroAplicacaoRetroativo->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$registroAplicacaoRetroativo->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$registroAplicacaoRetroativo->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::sendDocumentoImunologicoRotina($headers, $registroAplicacaoRetroativo, $cliente->municipio->estado->uf);
|
||||
|
||||
$registroAplicacaoRetroativo->identificador_rnds = $response->header('Location') ? $response->header('Location') : null;
|
||||
$registroAplicacaoRetroativo->response = $response->json();
|
||||
|
||||
DocumentoImunologicoRotinaService::store($registroAplicacaoRetroativo);
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarRegistroAplicacaoRetroativoCommand'
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarRegistroAplicacaoRetroativoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarRegistroAplicacaoRetroativoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarRegistroAplicacaoRetroativoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarRegistroAplicacaoRetroativoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarRegistroAtualizacaoCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-registro-atualizacao';
|
||||
protected $description = 'Comando para envio de novos registros de atulaização ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getRegistrosAtualizacao()
|
||||
->each(function($registroAtualizacao) use ($cliente, $parametrizacao, &$token, $expiresAt) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$registroAtualizacao->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$registroAtualizacao->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$registroAtualizacao->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::sendDocumentoImunologicoRotina($headers, $registroAtualizacao, $cliente->municipio->estado->uf);
|
||||
|
||||
$registroAtualizacao->identificador_rnds = $response->header('Location') ? $response->header('Location') : null;
|
||||
$registroAtualizacao->response = $response->json();
|
||||
|
||||
DocumentoImunologicoRotinaService::store($registroAtualizacao);
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarRegistroAtualizacaoCommand',
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarRegistroAtualizacaoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarRegistroAtualizacaoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarRegistroAtualizacaoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarRegistroAtualizacaoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Ria;
|
||||
|
||||
use App\Enums\Intranet\Sistema;
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\RiaService;
|
||||
use App\Services\Integracao\Ria\DocumentoImunologicoRotinaService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarRegistroAtualizacaoRetroativoCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:ria-enviar-registro-atualizacao-retroativo';
|
||||
protected $description = 'Comando para envio de registros de atualização retroativos ao RIA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
try {
|
||||
$cliente = Cliente::where('link', $cliente)
|
||||
->where('sistema_id', Sistema::CONECTASUS)
|
||||
->firstOrFail();
|
||||
|
||||
Config::set('database.default', $cliente->link);
|
||||
|
||||
$parametrizacao = RiaService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoImunologicoRotinaService::getRegistrosAtualizacaoRetroativos()
|
||||
->each(function($registroAtualizacaoRetroativo) use ($cliente, $parametrizacao, &$token, $expiresAt) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiaService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$registroAtualizacaoRetroativo->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$registroAtualizacaoRetroativo->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$registroAtualizacaoRetroativo->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiaService::sendDocumentoImunologicoRotina($headers, $registroAtualizacaoRetroativo, $cliente->municipio->estado->uf);
|
||||
|
||||
$registroAtualizacaoRetroativo->identificador_rnds = $response->header('Location') ? $response->header('Location') : null;
|
||||
$registroAtualizacaoRetroativo->response = $response->json();
|
||||
|
||||
DocumentoImunologicoRotinaService::store($registroAtualizacaoRetroativo);
|
||||
});
|
||||
|
||||
Log::channel('integracao-ria')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente->link,
|
||||
'origem' => 'EnviarRegistroAtualizacaoRetroativoCommand'
|
||||
]);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente->link ?? $cliente,
|
||||
'origem' => 'EnviarRegistroAtualizacaoRetroativoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA (' . ($cliente->link ?? $cliente) . '):</strong> (Erro ao executar o comando: EnviarRegistroAtualizacaoRetroativoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-ria')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarRegistroAtualizacaoRetroativoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIA:</strong> (Erro ao executar o comando: EnviarRegistroAtualizacaoRetroativoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
107
api/app/Console/Commands/Integracao/Rira/EnviarCommand.php
Normal file
107
api/app/Console/Commands/Integracao/Rira/EnviarCommand.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Integracao\Rira;
|
||||
|
||||
use App\Models\Intranet\Cliente;
|
||||
use App\Services\Integracao\Rira\DocumentoService;
|
||||
use App\Services\Integracao\RiraService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnviarCommand extends Command
|
||||
{
|
||||
protected $signature = 'integracao:rira-enviar';
|
||||
protected $description = 'Comando para envio de solicitações ao RIRA.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
try {
|
||||
self::getClientes()->each(function($cliente) {
|
||||
Config::set('database.default', $cliente);
|
||||
|
||||
$clienteModel = Cliente::where('link', $cliente)->where('sistema_id', 1)->firstOrFail();
|
||||
$parametrizacao = RiraService::getParametrizacao();
|
||||
|
||||
if (!is_null($parametrizacao)) {
|
||||
$token = RiraService::getToken($parametrizacao, $parametrizacao->senha);
|
||||
$expiresAt = Carbon::now()->addMilliseconds($token['expires_in'])->subMinutes(2);
|
||||
|
||||
DocumentoService::getSolicitacoes()
|
||||
->each(function($solicitacao) use ($parametrizacao, &$token, $expiresAt, $clienteModel) {
|
||||
if (Carbon::now() >= $expiresAt) {
|
||||
$token = RiraService::getToken($parametrizacao->senha);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Authorization' => $parametrizacao->cns_solicitante,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Authorization-Server' => "Bearer " . $token['access_token'],
|
||||
];
|
||||
|
||||
$solicitacao->identificador_solicitante = $parametrizacao->identificador_solicitante;
|
||||
$solicitacao->cns_solicitante = $parametrizacao->cns_solicitante;
|
||||
$solicitacao->data_hora_envio = Carbon::now();
|
||||
|
||||
$response = RiraService::send($clienteModel, $headers, $solicitacao);
|
||||
|
||||
$urlRnds = null;
|
||||
$identificadorRnds = null;
|
||||
|
||||
if (!empty($response->header('Location'))) {
|
||||
$urlRnds = $response->header('Location');
|
||||
$urlRndsExploded = explode('/', $urlRnds);
|
||||
$identificadorRnds = $urlRndsExploded[count($urlRndsExploded) - 1];
|
||||
}
|
||||
|
||||
$solicitacao->url_rnds = $urlRnds;
|
||||
$solicitacao->identificador_rnds = $identificadorRnds;
|
||||
$solicitacao->response = $response->json();
|
||||
|
||||
DocumentoService::save($solicitacao);
|
||||
});
|
||||
|
||||
Log::channel('integracao-rira')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'EnviarCommand'
|
||||
]);
|
||||
}
|
||||
});
|
||||
} catch (Exception $error) {
|
||||
Log::channel('integracao-rira')->error('Erro ao executar o comando', [
|
||||
'origem' => 'EnviarCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Integração RIRA:</strong> (Erro ao executar o comando: EnviarCommand).');
|
||||
}
|
||||
}
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')
|
||||
->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])
|
||||
))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\PainelSenha;
|
||||
|
||||
use App\Events\PainelSenha\AvisoEvent;
|
||||
use App\Models\PainelSenha\AvisoAgendamento;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EnvioAvisoAgendadoCommand extends Command
|
||||
{
|
||||
protected $signature = 'painel-senha:envio-aviso-agendado';
|
||||
protected $description = 'Comando para enviar os avisos que estão agendados';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
self::getClientes()->each(function($cliente) {
|
||||
|
||||
Config::set('database.default', $cliente);
|
||||
|
||||
if(!Schema::hasTable('painel_senha_aviso')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$agora = Carbon::now();
|
||||
$toleranciaInicio = $agora->copy()->subSeconds(30);
|
||||
$toleranciaFim = $agora->copy()->addSeconds(30);
|
||||
|
||||
$agendamentos = DB::table('painel_senha_aviso_agendamento')
|
||||
->whereDate('data_hora_agendada', $agora->toDateString())
|
||||
->whereBetween('data_hora_agendada', [$toleranciaInicio, $toleranciaFim])
|
||||
->whereNull('data_hora_executada')
|
||||
->where('painel_senha_aviso.is_ativo', true)
|
||||
->join('painel_senha_aviso', 'painel_senha_aviso.id', 'painel_senha_aviso_agendamento.aviso_id')
|
||||
->get();
|
||||
|
||||
if($agendamentos->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$idsAgendamentos = $agendamentos->pluck("id");
|
||||
$idsAvisos = $agendamentos->pluck("aviso_id");
|
||||
|
||||
AvisoAgendamento::whereIn('id', $idsAgendamentos)
|
||||
->update(['data_hora_executada' => $agora]);
|
||||
|
||||
$avisos = DB::table('painel_senha_aviso')
|
||||
->select(
|
||||
'painel_senha_aviso.id',
|
||||
'painel_senha_aviso.mensagem',
|
||||
DB::raw('GROUP_CONCAT(cadastro_unidade.nome_fantasia) as unidades'),
|
||||
DB::raw('GROUP_CONCAT(cadastro_unidade.id) as ids_unidade'),
|
||||
'painel_senha_aviso.is_ativo',
|
||||
)
|
||||
->join('painel_senha_aviso_unidade', 'painel_senha_aviso_unidade.aviso_id', 'painel_senha_aviso.id')
|
||||
->leftJoin('cadastro_unidade', 'cadastro_unidade.id', 'painel_senha_aviso_unidade.unidade_id')
|
||||
->groupBy('painel_senha_aviso.id', 'painel_senha_aviso.mensagem', 'painel_senha_aviso.is_ativo')
|
||||
->whereIn('painel_senha_aviso.id', $idsAvisos)
|
||||
->get();
|
||||
|
||||
$avisos->map(function($aviso) {
|
||||
AvisoEvent::dispatch($aviso->id, $aviso);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
Log::info("Não foi possível enviar aviso {$th}");
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\PainelSenha;
|
||||
|
||||
use App\Enums\Administracao\Modulo;
|
||||
use App\Models\PainelSenha\Fila;
|
||||
use App\Models\PainelSenha\OpcaoEntrada;
|
||||
use App\Services\Administracao\ModuloService;
|
||||
use App\Services\Telegram\TelegramService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class LimparFilaAtendimentoCommand extends Command
|
||||
{
|
||||
protected $signature = 'painel-senha:limpar-fila-atendimento';
|
||||
protected $description = 'Comando para limpesa da fila de atendimento no módulo painel de senha.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$currentDatabase = Config::get('database.default');
|
||||
|
||||
$this->getClientes()->each(function($cliente) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
Config::set('database.default', $cliente);
|
||||
|
||||
Fila::where('finalizado', false)
|
||||
->where('evadido', false)
|
||||
->whereIn('opcao_entrada_id', $this->getOpcoesEntrada())
|
||||
->update([
|
||||
'finalizado' => true,
|
||||
'evadido' => true,
|
||||
]);
|
||||
|
||||
Log::channel('painel-senha-fila-atendimento')->info('Comando executado com sucesso.', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'LimparFilaAtendimentoCommand',
|
||||
]);
|
||||
} catch (Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
Log::channel('painel-senha-fila-atendimento')->error('Erro ao executar o comando', [
|
||||
'cliente' => $cliente,
|
||||
'origem' => 'LimparFilaAtendimentoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Farmácia (' . ($cliente) . '):</strong> (Erro ao executar o comando: LimparFilaAtendimentoCommand).');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Config::set('database.default', $currentDatabase);
|
||||
} catch (Exception $error) {
|
||||
Log::channel('painel-senha-fila-atendimento')->error('Erro ao executar o comando', [
|
||||
'origem' => 'LimparFilaAtendimentoCommand',
|
||||
'erro' => $error->getMessage(),
|
||||
]);
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
TelegramService::send('<strong>Painel de senha:</strong> (Erro ao executar o comando: LimparFilaAtendimentoCommand).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getClientes()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => empty(DB::connection('schema')->select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", [$config['database']])))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
|
||||
private function getOpcoesEntrada()
|
||||
{
|
||||
return OpcaoEntrada::where('modulo_id', ModuloService::getId(Modulo::PAINEL_SENHA))
|
||||
->pluck('id');
|
||||
}
|
||||
}
|
||||
74
api/app/Console/Commands/PublishCommand.php
Normal file
74
api/app/Console/Commands/PublishCommand.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PublishCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'publish';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Run migrations and seeders';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->getCustomers()->each(function ($customer, $i) {
|
||||
|
||||
if ($i > 0) {
|
||||
$this->getOutput()->writeln("\n");
|
||||
}
|
||||
|
||||
$this->getOutput()->writeln("<question>{$customer}</question>");
|
||||
|
||||
$this->call('migrate', ['--database' => $customer, '--force' => true]);
|
||||
$this->call('db:seed', ['--database' => $customer, '--force' => true]);
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getCustomers()
|
||||
{
|
||||
return collect(json_decode(file_get_contents(base_path('connections.json')), true))
|
||||
->filter(fn ($config) => isset($config['database']) && Str::startsWith($config['database'], 'conectasus'))
|
||||
->reject(fn ($config) => !$this->databaseExists($config['database']))
|
||||
->map(fn ($config, $customer) => $customer)
|
||||
->sort()
|
||||
->values();
|
||||
}
|
||||
|
||||
private function databaseExists($databaseName)
|
||||
{
|
||||
return !empty(DB::connection('schema')->select(
|
||||
"SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?",
|
||||
[$databaseName]
|
||||
));
|
||||
}
|
||||
}
|
||||
280
api/app/Console/Commands/SeedCommand.php
Normal file
280
api/app/Console/Commands/SeedCommand.php
Normal file
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\ConfirmableTrait;
|
||||
use Illuminate\Database\ConnectionResolverInterface as Resolver;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class SeedCommand extends Command
|
||||
{
|
||||
use ConfirmableTrait;
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'db:seed';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Seed the database with records';
|
||||
|
||||
/**
|
||||
* The connection resolver instance.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionResolverInterface
|
||||
*/
|
||||
protected $resolver;
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* Create a new database seed command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Resolver $resolver)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->resolver = $resolver;
|
||||
$this->files = new Filesystem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (! $this->confirmToProceed()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$previousConnection = $this->resolver->getDefaultConnection();
|
||||
|
||||
$this->resolver->setDefaultConnection($this->getDatabase());
|
||||
|
||||
Schema::disableForeignKeyConstraints();
|
||||
|
||||
self::getSeedersClasses()->each(function ($class) {
|
||||
Model::unguarded(function () use ($class) {
|
||||
|
||||
$this->getOutput()->writeln("<comment>Seeding:</comment> {$class['file_name']}");
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
$this->getSeeder(class_basename($class['instance']))->__invoke();
|
||||
|
||||
$runTime = number_format((microtime(true) - $startTime) * 1000, 2);
|
||||
|
||||
$this->getOutput()->writeln("<info>Seeded:</info> {$class['file_name']} ({$runTime}ms)");
|
||||
|
||||
DB::connection($this->getDatabase())->table('seeders')->insert(['seeder' => $class['file_name']]);
|
||||
});
|
||||
});
|
||||
|
||||
Schema::enableForeignKeyConstraints();
|
||||
|
||||
if ($previousConnection) {
|
||||
$this->resolver->setDefaultConnection($previousConnection);
|
||||
}
|
||||
|
||||
$this->info('Database seeding completed successfully.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getSeedersClasses()
|
||||
{
|
||||
$ran = DB::connection($this->getDatabase())->table('seeders')->select('seeder')->pluck('seeder')->all();
|
||||
$files = $this->getSeederFiles();
|
||||
|
||||
$this->requireFiles($seeders = $this->pendingSeeders(
|
||||
$files, $ran
|
||||
));
|
||||
|
||||
$classes = collect();
|
||||
|
||||
foreach ($seeders as $file) {
|
||||
|
||||
$fileName = $this->getSeederName($file);
|
||||
|
||||
$classes->push([
|
||||
'file_name' => $fileName,
|
||||
'instance' => $this->resolve($fileName)
|
||||
]);
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the seeder files.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSeederFiles()
|
||||
{
|
||||
return Collection::make(self::getSeederPaths())->flatMap(function ($path) {
|
||||
return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php');
|
||||
})->filter()->values()->keyBy(function ($file) {
|
||||
return $this->getSeederName($file);
|
||||
})->sortBy(function ($file, $key) {
|
||||
return $key;
|
||||
})->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get seeder path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getSeederPaths()
|
||||
{
|
||||
$invalidContents = ['.', '..', '.gitkeep', 'base'];
|
||||
$seedersDir = database_path() . '/seeders/';
|
||||
|
||||
return $this->getSeederFilesPaths(
|
||||
$invalidContents,
|
||||
$seedersDir
|
||||
);
|
||||
}
|
||||
|
||||
private function getSeederFilesPaths($invalidContents, $currentDirectory, $paths = [])
|
||||
{
|
||||
$contents = opendir($currentDirectory);
|
||||
|
||||
while ($content = readdir($contents)) {
|
||||
|
||||
if (!in_array($content, $invalidContents)) {
|
||||
|
||||
$fullPath = $currentDirectory . $content;
|
||||
|
||||
if (is_dir($fullPath)) {
|
||||
|
||||
$paths = $this->getSeederFilesPaths(
|
||||
$invalidContents,
|
||||
$fullPath . '/',
|
||||
$paths
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$paths[] = $fullPath;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require in all the seeder files in a given path.
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
*/
|
||||
public function requireFiles(array $files)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$this->files->requireOnce($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a seeder instance from a file.
|
||||
*
|
||||
* @param string $file
|
||||
* @return object
|
||||
*/
|
||||
public function resolve($file)
|
||||
{
|
||||
$fileArr = explode('_', $file);
|
||||
$class = Str::studly(implode('_', array_slice($fileArr, 4))).'_'.implode(array_slice($fileArr, 0, 4));
|
||||
|
||||
return new $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the seeder.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getSeederName($path)
|
||||
{
|
||||
return str_replace('.php', '', basename($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the seeder files that have not yet run.
|
||||
*
|
||||
* @param array $files
|
||||
* @param array $ran
|
||||
* @return array
|
||||
*/
|
||||
protected function pendingSeeders($files, $ran)
|
||||
{
|
||||
return Collection::make($files)
|
||||
->reject(function ($file) use ($ran) {
|
||||
return in_array($this->getSeederName($file), $ran);
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a seeder instance from the container.
|
||||
* @param string $class
|
||||
* @return \Illuminate\Database\Seeder
|
||||
*/
|
||||
protected function getSeeder($class)
|
||||
{
|
||||
return $this->laravel->make($class)
|
||||
->setContainer($this->laravel)
|
||||
->setCommand($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the database connection to use.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDatabase()
|
||||
{
|
||||
$database = $this->input->getOption('database');
|
||||
|
||||
return $database ?: $this->laravel['config']['database.default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'],
|
||||
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
|
||||
];
|
||||
}
|
||||
}
|
||||
119
api/app/Console/Commands/SeedPermissionsCommand.php
Normal file
119
api/app/Console/Commands/SeedPermissionsCommand.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Database\Seeders\Base\Funcionalidade;
|
||||
use Database\Seeders\Base\FuncionalidadeSub;
|
||||
use Database\Seeders\Base\Menu;
|
||||
use Database\Seeders\Base\Modulo;
|
||||
use Database\Seeders\Base\Permissao;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\ConnectionResolverInterface as Resolver;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class SeedPermissionsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'dev:seed-permissions';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Seed the database with permissions records';
|
||||
|
||||
/**
|
||||
* The connection resolver instance.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionResolverInterface
|
||||
*/
|
||||
protected $resolver;
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* Create a new database seed command instance.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Resolver $resolver)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$previousConnection = $this->resolver->getDefaultConnection();
|
||||
|
||||
$this->resolver->setDefaultConnection($this->getDatabase());
|
||||
|
||||
collect([
|
||||
Modulo::class,
|
||||
Funcionalidade::class,
|
||||
FuncionalidadeSub::class,
|
||||
Menu::class,
|
||||
Permissao::class,
|
||||
])->each(function ($model) {
|
||||
|
||||
$this->getOutput()->writeln("<comment>Seeding:</comment> {$model}");
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
$model::run();
|
||||
|
||||
$runTime = number_format((microtime(true) - $startTime) * 1000, 2);
|
||||
|
||||
$this->getOutput()->writeln("<info>Seeded:</info> {$model} ({$runTime}ms)");
|
||||
});
|
||||
|
||||
if ($previousConnection) {
|
||||
$this->resolver->setDefaultConnection($previousConnection);
|
||||
}
|
||||
|
||||
$this->info('Permissions seeding completed successfully.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the database connection to use.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDatabase()
|
||||
{
|
||||
$database = $this->input->getOption('database');
|
||||
|
||||
return $database ?: $this->laravel['config']['database.default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'],
|
||||
];
|
||||
}
|
||||
}
|
||||
211
api/app/Console/Commands/SeederMakeCommand.php
Normal file
211
api/app/Console/Commands/SeederMakeCommand.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Composer;
|
||||
use Illuminate\Support\Str;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class SeederMakeCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command signature.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make:seeder {name : The name of the seeder}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new seeder file';
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* The Composer instance.
|
||||
*
|
||||
* @var \Illuminate\Support\Composer
|
||||
*/
|
||||
protected $composer;
|
||||
|
||||
/**
|
||||
* Create a new seeder make command instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\Support\Composer $composer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->files = $files;
|
||||
$this->composer = $composer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$name = Str::snake(trim($this->input->getArgument('name')));
|
||||
|
||||
$this->writeSeeder($name);
|
||||
|
||||
$this->composer->dumpAutoloads();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the seeder file to disk.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
protected function writeSeeder($name)
|
||||
{
|
||||
$file = $this->create(
|
||||
$name, $this->getSeederPath()
|
||||
);
|
||||
|
||||
$file = pathinfo($file, PATHINFO_FILENAME);
|
||||
|
||||
$this->line("<info>Created Seeder:</info> {$file}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get seeder path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getSeederPath()
|
||||
{
|
||||
return $this->laravel->databasePath().DIRECTORY_SEPARATOR.'seeders';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new seeder at the given path.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function create($name, $path)
|
||||
{
|
||||
$dateTime = new DateTime();
|
||||
$className = $this->getClassName($dateTime, $name);
|
||||
|
||||
$this->ensureSeederDoesntAlreadyExist($className, $path);
|
||||
|
||||
$stub = $this->getStub();
|
||||
$path = $this->getPath($dateTime, $name, $path);
|
||||
|
||||
$this->files->ensureDirectoryExists(dirname($path));
|
||||
|
||||
$this->files->put(
|
||||
$path, $this->populateStub($className, $stub)
|
||||
);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a seeder with the given name doesn't already exist.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $seederPath
|
||||
* @return void
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function ensureSeederDoesntAlreadyExist($className, $seederPath = null)
|
||||
{
|
||||
if (! empty($seederPath)) {
|
||||
$seederFiles = $this->files->glob($seederPath.'/*.php');
|
||||
|
||||
foreach ($seederFiles as $seederFile) {
|
||||
$this->files->requireOnce($seederFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists($className)) {
|
||||
throw new InvalidArgumentException("A {$className} class already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the seeder stub file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getStub()
|
||||
{
|
||||
$stub = $this->stubPath().'/seeder.stub';
|
||||
|
||||
return $this->files->get($stub);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the place-holders in the seeder stub.
|
||||
*
|
||||
* @param string $className
|
||||
* @param string $stub
|
||||
* @return string
|
||||
*/
|
||||
protected function populateStub($className, $stub)
|
||||
{
|
||||
$stub = str_replace(
|
||||
['DummyClass', '{{ class }}', '{{class}}'],
|
||||
$className, $stub
|
||||
);
|
||||
|
||||
return $stub;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class name of a seeder name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
protected function getClassName($dateTime, $name)
|
||||
{
|
||||
return Str::studly($name).'_'.$dateTime->format('YmdHis');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full path to the seeder.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
protected function getPath($dateTime, $name, $path)
|
||||
{
|
||||
return $path.'/'.$dateTime->format('Y_m_d_His').'_'.$name.'.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the stubs.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function stubPath()
|
||||
{
|
||||
return $this->laravel->basePath().'/stubs';
|
||||
}
|
||||
}
|
||||
152
api/app/Console/Kernel.php
Normal file
152
api/app/Console/Kernel.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
if (!config('app.run_schedule')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// BNAFAR.
|
||||
$schedule->command('integracao:bnafar-enviar-posicao-estoque')
|
||||
->name('integracao:bnafar-enviar-posicao-estoque')
|
||||
->withoutOverlapping()
|
||||
->daily()
|
||||
->at('22:00');
|
||||
|
||||
$schedule->command('integracao:bnafar-enviar-saida')
|
||||
->name('integracao:bnafar-enviar-saida')
|
||||
->withoutOverlapping()
|
||||
->daily()
|
||||
->at('22:00');
|
||||
|
||||
$schedule->command('integracao:bnafar-verificar-posicao-estoque')
|
||||
->name('integracao:bnafar-verificar-posicao-estoque')
|
||||
->withoutOverlapping()
|
||||
->daily()
|
||||
->at('02:30');
|
||||
|
||||
$schedule->command('integracao:bnafar-verificar-saida')
|
||||
->name('integracao:bnafar-verificar-saida')
|
||||
->withoutOverlapping()
|
||||
->daily()
|
||||
->at('02:30');
|
||||
|
||||
// Fila de atendimento.
|
||||
$schedule->command('farmacia:limpar-fila-atendimento')
|
||||
->name('farmacia-limpar-fila-atendimento')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('00:25');
|
||||
|
||||
$schedule->command('painel-senha:limpar-fila-atendimento')
|
||||
->name('painel-senha-limpar-fila-atendimento')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('00:30');
|
||||
|
||||
// Avisos do painel de senha
|
||||
$schedule->command('painel-senha:envio-aviso-agendado')->everyMinute();
|
||||
|
||||
// RIA.
|
||||
$schedule->command('integracao:ria-enviar-registro-aplicacao-retroativo')
|
||||
->name('integracao:ria-enviar-registro-aplicacao-retroativo')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->everyTwoHours();
|
||||
|
||||
$schedule->command('integracao:ria-enviar-registro-atualizacao-retroativo')
|
||||
->name('integracao:ria-enviar-registro-atualizacao-retroativo')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->everyTwoHours();
|
||||
|
||||
$schedule->command('integracao:ria-enviar-registro-aplicacao')
|
||||
->name('integracao:ria-enviar-registro-aplicacao')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('01:00');
|
||||
|
||||
$schedule->command('integracao:ria-enviar-registro-atualizacao')
|
||||
->name('integracao:ria-enviar-registro-atualizacao')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('01:00');
|
||||
|
||||
$schedule->command('integracao:ria-enviar-documento-com-inconsistencia')
|
||||
->name('integracao:ria-enviar-documento-com-inconsistencia')
|
||||
->withoutOverlapping()
|
||||
->weeklyOn(6, '01:00');
|
||||
|
||||
$schedule->command('integracao:ria-enviar-documento-com-inconsistencia-retroativo')
|
||||
->name('integracao:ria-enviar-documento-com-inconsistencia-retroativo')
|
||||
->withoutOverlapping()
|
||||
->weeklyOn(0, '01:00');
|
||||
|
||||
$schedule->command('integracao:ria-enviar-documento-alterado')
|
||||
->name('integracao:ria-enviar-documento-alterado')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('04:00');
|
||||
|
||||
$schedule->command('integracao:ria-enviar-exclusao-documento')
|
||||
->name('integracao:ria-enviar-exclusao-documento')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('05:00');
|
||||
|
||||
// RIRA
|
||||
$schedule->command('integracao:rira-enviar')
|
||||
->name('integracao:rira-enviar')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('02:00');
|
||||
|
||||
// ERPSAUDE
|
||||
$schedule->command('integracao:erpsaude-buscar-atendimentos-hospital-santa-casa')
|
||||
->name('integracao:erpsaude-buscar-atendimentos-hospital-santa-casa')
|
||||
->withoutOverlapping()
|
||||
->days([0,1,2,3,4,5,6])
|
||||
->at('02:30');
|
||||
|
||||
// ESUS
|
||||
$schedule->command('integracao:esus-enviar')
|
||||
->name('integracao:esus-enviar')
|
||||
->withoutOverlapping()
|
||||
->days([1,2,3,4,5])
|
||||
->at('03:00');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
25
api/app/Database/MySqlConnection.php
Normal file
25
api/app/Database/MySqlConnection.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database;
|
||||
|
||||
use App\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\MySqlConnection as BaseMySqlConnection;
|
||||
|
||||
class MySqlConnection extends BaseMySqlConnection
|
||||
{
|
||||
/**
|
||||
* Get a schema builder instance for the connection.
|
||||
*
|
||||
* @return \Illuminate\Database\Schema\MySqlBuilder
|
||||
*/
|
||||
public function getSchemaBuilder()
|
||||
{
|
||||
$builder = parent::getSchemaBuilder();
|
||||
|
||||
$builder->blueprintResolver(function ($table, $callback) {
|
||||
return new Blueprint($table, $callback);
|
||||
});
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
62
api/app/Database/Schema/Blueprint.php
Normal file
62
api/app/Database/Schema/Blueprint.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Schema;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint as BaseBlueprint;
|
||||
|
||||
class Blueprint extends BaseBlueprint
|
||||
{
|
||||
private const MAX_INDEX_NAME_LENGTH = 64;
|
||||
private const MAX_FRAGMENT_INDEX_LEGNTH = 4;
|
||||
private const MIN_FRAGMENT_INDEX_LEGNTH = 3;
|
||||
|
||||
/**
|
||||
* Create a default index name for the table.
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $columns
|
||||
* @return string
|
||||
*/
|
||||
protected function createIndexName($type, array $columns)
|
||||
{
|
||||
$index = $this->getReducedIndexName($type, $columns, self::MAX_FRAGMENT_INDEX_LEGNTH);
|
||||
|
||||
return str_replace(['-', '.'], '_', $index);
|
||||
}
|
||||
|
||||
private function getReducedIndexName($type, array $columns, int $fragmentLength)
|
||||
{
|
||||
$table = null;
|
||||
|
||||
foreach($columns as $key => $value) {
|
||||
$column = null;
|
||||
|
||||
foreach(explode('_', $value) as $explode) {
|
||||
$column .= substr($explode, 0, $fragmentLength) . '_';
|
||||
}
|
||||
|
||||
$columns[$key] = rtrim($column, '_');
|
||||
}
|
||||
|
||||
foreach(explode('_', $this->table) as $explode) {
|
||||
$table .= substr($explode, 0, $fragmentLength) . '_';
|
||||
}
|
||||
|
||||
$index = strtolower($this->prefix.rtrim($table, '_').'_'.implode('_', $columns).'_'.$type);
|
||||
|
||||
if (strlen($index) > self::MAX_INDEX_NAME_LENGTH) {
|
||||
|
||||
$newFragmentLength = $fragmentLength - 1;
|
||||
|
||||
if ($newFragmentLength < self::MIN_FRAGMENT_INDEX_LEGNTH) {
|
||||
|
||||
throw new \Exception("An error has occurred while reducing the length of the index. "
|
||||
. "Please, name it manually.\nThe last try result in: {$index}.");
|
||||
}
|
||||
|
||||
return $this->getReducedIndexName($type, $columns, $newFragmentLength);
|
||||
}
|
||||
|
||||
return $index;
|
||||
}
|
||||
}
|
||||
11
api/app/Enums/Administracao/CrudAcao.php
Normal file
11
api/app/Enums/Administracao/CrudAcao.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Administracao;
|
||||
|
||||
class CrudAcao
|
||||
{
|
||||
const CRIAR = 1;
|
||||
const VISUALIZAR = 2;
|
||||
const ATUALIZAR = 3;
|
||||
const EXCLUIR = 4;
|
||||
}
|
||||
9
api/app/Enums/Administracao/HistoricoAcao.php
Normal file
9
api/app/Enums/Administracao/HistoricoAcao.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Administracao;
|
||||
|
||||
class HistoricoAcao
|
||||
{
|
||||
const CADASTRO = 1;
|
||||
const EXCLUSAO = 2;
|
||||
}
|
||||
15
api/app/Enums/Administracao/Modulo.php
Normal file
15
api/app/Enums/Administracao/Modulo.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Administracao;
|
||||
|
||||
class Modulo
|
||||
{
|
||||
const AMBULATORIO = 'ambulatorio';
|
||||
const EXAME_LABORATORIAL = 'exame-laboratorial';
|
||||
const EXAME_IMAGEM = 'exame-imagem';
|
||||
const IMUNIZACAO = 'imunizacao';
|
||||
const FARMACIA = 'farmacia';
|
||||
const PAINEL_SENHA = 'painel-senha';
|
||||
const PRONTO_ATENDIMENTO = 'pronto-atendimento';
|
||||
const TRANSPORTE_PACIENTE = 'transporte-paciente';
|
||||
}
|
||||
9
api/app/Enums/Administracao/NotificacaoTipo.php
Normal file
9
api/app/Enums/Administracao/NotificacaoTipo.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Administracao;
|
||||
|
||||
class NotificacaoTipo
|
||||
{
|
||||
const ATUALIZACAO = 1;
|
||||
const AVISO = 2;
|
||||
}
|
||||
11
api/app/Enums/Almoxarifado/DocumentoTipo.php
Normal file
11
api/app/Enums/Almoxarifado/DocumentoTipo.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class DocumentoTipo
|
||||
{
|
||||
const NOTA_FISCAL = 1;
|
||||
const OUTRAS = 2;
|
||||
const DOACAO = 3;
|
||||
const DEVOLUCAO = 4;
|
||||
}
|
||||
13
api/app/Enums/Almoxarifado/EntradaTipo.php
Normal file
13
api/app/Enums/Almoxarifado/EntradaTipo.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class EntradaTipo
|
||||
{
|
||||
const MANUAL = 1;
|
||||
const REQUISICAO = 2;
|
||||
const INVENTARIO = 3;
|
||||
const ESTORNO = 4;
|
||||
const INICIAL = 5;
|
||||
const TRANSFERENCIA = 6;
|
||||
}
|
||||
10
api/app/Enums/Almoxarifado/MotivoBaixaTipo.php
Normal file
10
api/app/Enums/Almoxarifado/MotivoBaixaTipo.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class MotivoBaixaTipo
|
||||
{
|
||||
const CONSUMO_INTERNO = 1;
|
||||
const QUEBRADO = 2;
|
||||
const VENCIDO = 3;
|
||||
}
|
||||
14
api/app/Enums/Almoxarifado/RequisicaoRespostaItemMotivo.php
Normal file
14
api/app/Enums/Almoxarifado/RequisicaoRespostaItemMotivo.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class RequisicaoRespostaItemMotivo
|
||||
{
|
||||
const SEM_ESTOQUE = 1;
|
||||
const PEDIDO_EM_EXCESSO = 2;
|
||||
const ENTREGA_PARCIAL = 3;
|
||||
const PENDENTE_DE_ENTREGA = 4;
|
||||
const RECUSADO = 5;
|
||||
const ADEQUACAO_DE_CAIXA = 6;
|
||||
const OUTRO = 7;
|
||||
}
|
||||
10
api/app/Enums/Almoxarifado/RequisicaoRespostaStatus.php
Normal file
10
api/app/Enums/Almoxarifado/RequisicaoRespostaStatus.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class RequisicaoRespostaStatus
|
||||
{
|
||||
const INICIADA = 1;
|
||||
const ENVIADA = 2;
|
||||
const RECEBIDA = 3;
|
||||
}
|
||||
10
api/app/Enums/Almoxarifado/RequisicaoStatus.php
Normal file
10
api/app/Enums/Almoxarifado/RequisicaoStatus.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class RequisicaoStatus
|
||||
{
|
||||
const ABERTA = 1;
|
||||
const RESPOSTA_INICIADA = 2;
|
||||
const FINALIZADA = 3;
|
||||
}
|
||||
8
api/app/Enums/Almoxarifado/ReservaMotivo.php
Normal file
8
api/app/Enums/Almoxarifado/ReservaMotivo.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class ReservaMotivo
|
||||
{
|
||||
const REQUISICAO = 1;
|
||||
}
|
||||
16
api/app/Enums/Almoxarifado/SaidaTipo.php
Normal file
16
api/app/Enums/Almoxarifado/SaidaTipo.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Almoxarifado;
|
||||
|
||||
class SaidaTipo
|
||||
{
|
||||
const MANUAL = 1;
|
||||
const REQUISICAO = 2;
|
||||
const INVENTARIO = 3;
|
||||
const ESTORNO = 4;
|
||||
const DISPENSACAO_FARMACIA = 5;
|
||||
const BAIXA = 6;
|
||||
const TRANSFERENCIA = 7;
|
||||
const DISPENSACAO_ALMOXARIFADO = 8;
|
||||
const DISPENSACAO_AMBULATORIO = 9;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AcompanhamentoOciMotivoEncerramento
|
||||
{
|
||||
const ABANDONO = 1;
|
||||
const OBITO = 2;
|
||||
const CANCELAMENTO_PELO_AUDITOR = 3;
|
||||
const VENCIDO = 4;
|
||||
const CONCLUIDO = 5;
|
||||
}
|
||||
10
api/app/Enums/Ambulatorio/AcompanhamentoOciStatus.php
Normal file
10
api/app/Enums/Ambulatorio/AcompanhamentoOciStatus.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AcompanhamentoOciStatus
|
||||
{
|
||||
const EM_ANDAMENTO = 1;
|
||||
const ENCERRADO_MANUALMENTE = 2;
|
||||
const ENCERRADO_AUTOMATICAMENTE = 3;
|
||||
}
|
||||
16
api/app/Enums/Ambulatorio/AgendamentoStatus.php
Normal file
16
api/app/Enums/Ambulatorio/AgendamentoStatus.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AgendamentoStatus
|
||||
{
|
||||
const AGENDADO = 1;
|
||||
const REAGENDADO_PELO_PACIENTE = 2;
|
||||
const REAGENDADO_PELO_MEDICO = 3;
|
||||
const CANCELADO_PELO_PACIENTE = 4;
|
||||
const CANCELADO_PELO_MEDICO = 5;
|
||||
const FALTA_DO_PACIENTE = 6;
|
||||
const FALTA_DO_MEDICO = 7;
|
||||
const REALIZADO = 8;
|
||||
const EVADIDO = 9;
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/AgendamentoTipo.php
Normal file
9
api/app/Enums/Ambulatorio/AgendamentoTipo.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AgendamentoTipo
|
||||
{
|
||||
const CONSULTA = 1;
|
||||
const RETORNO = 2;
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/ArcadaDentaria.php
Normal file
9
api/app/Enums/Ambulatorio/ArcadaDentaria.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class ArcadaDentaria
|
||||
{
|
||||
const SUPERIOR = 1;
|
||||
const INFERIOR = 2;
|
||||
}
|
||||
11
api/app/Enums/Ambulatorio/AtendimentoEspecificoTipo.php
Normal file
11
api/app/Enums/Ambulatorio/AtendimentoEspecificoTipo.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AtendimentoEspecificoTipo
|
||||
{
|
||||
const SAUDE_BUCAL = 1;
|
||||
const PRE_NATAL = 2;
|
||||
const PUERICULTURA = 3;
|
||||
const IDOSO = 4;
|
||||
}
|
||||
21
api/app/Enums/Ambulatorio/AtendimentoImpressaoTipo.php
Normal file
21
api/app/Enums/Ambulatorio/AtendimentoImpressaoTipo.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AtendimentoImpressaoTipo
|
||||
{
|
||||
const RECEITA_COMUM = 1;
|
||||
const RECEITA_ESPECIAL = 2;
|
||||
const RECEITA_ESPECIAL_AZUL = 3;
|
||||
const RECEITA_ESPECIAL_AMARELA = 4;
|
||||
const RECEITA_NAO_PADRONIZADA_COMUM = 5;
|
||||
const RECEITA_NAO_PADRONIZADA_ESPECIAL = 6;
|
||||
const SERVICO_DE_ANALISES_DIAGNOSTICOS_E_TERAPIA_SOLICITACAO_DE_EXAMES_SADAT = 7;
|
||||
const FICHA_DE_REQUISICAO_DE_SERVICOS_AUXILIARES_DE_DIAGOSE_E_TERAPIA_SADT = 8;
|
||||
const LAUDO_PARA_SOLICITACAO_AUTORIZACAO_DE_PROCEDIMENTO_AMBULATORIAL = 9;
|
||||
const ENCAMINHAMENTO = 10;
|
||||
const ATESTADO_MEDICO = 11;
|
||||
const DECLARACAO_COMPARECIMENTO = 12;
|
||||
const CARTA_MEDICA = 13;
|
||||
const ORIENTACAO = 14;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AtendimentoSoapSolicitacaoExameItemStatus
|
||||
{
|
||||
const SOLICITADO = 1;
|
||||
const AGENDADO = 2;
|
||||
const REALIZADO = 3;
|
||||
const FALTA = 4;
|
||||
const CANCELADO = 5;
|
||||
const REAGENDADO = 6;
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/AtendimentoTipo.php
Normal file
9
api/app/Enums/Ambulatorio/AtendimentoTipo.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AtendimentoTipo
|
||||
{
|
||||
const DEMANDA_ESPONTANEA = 1;
|
||||
const PROGRAMADA = 2;
|
||||
}
|
||||
13
api/app/Enums/Ambulatorio/AtestadoModelo.php
Normal file
13
api/app/Enums/Ambulatorio/AtestadoModelo.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class AtestadoModelo
|
||||
{
|
||||
const PADRAO = 1;
|
||||
const EM_BRANCO = 2;
|
||||
const PERIODO_MANHA = 3;
|
||||
const PERIODO_TARDE = 4;
|
||||
const PERIODO_NOITE = 5;
|
||||
const QUANTIDADE_HORAS = 6;
|
||||
}
|
||||
63
api/app/Enums/Ambulatorio/CasoSuspeito.php
Normal file
63
api/app/Enums/Ambulatorio/CasoSuspeito.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class CasoSuspeito
|
||||
{
|
||||
const ACIDENTE_DE_TRABALHO_COM_EXPOSICAO_A_MATERIAL_BIOLOGICO = 1;
|
||||
const ACIDENTE_DE_TRABALHO_GRAVE = 2;
|
||||
const ACIDENTES_POR_ANIMAIS_PECONHENTOS = 3;
|
||||
const AIDS_PACIENTES_MAIORES_DE_13_ANOS = 4;
|
||||
const ATENDIMENTO_ANTI_RABICO_HUMANO = 5;
|
||||
const BOTULISMO = 6;
|
||||
const CHIKUNGUNYA = 7;
|
||||
const COQUELUCHE = 8;
|
||||
const COLERA = 9;
|
||||
const DENGUE = 10;
|
||||
const DIFTERIA = 11;
|
||||
const DOENCA_MENINGOCOCICA = 12;
|
||||
const DOENCAS_DE_CHAGAS_AGUDA = 13;
|
||||
const DRT_CANCER_RELACIONADO_AO_TRABALHO = 14;
|
||||
const DRT_DERMATOSES_OCUPACIONAIS = 15;
|
||||
const DRT_LER_DORT = 16;
|
||||
const DRT_PAIR = 17;
|
||||
const DRT_PNEUMOCONIOSES = 18;
|
||||
const DRT_TRANSTORNOS_MENTAIS_RELACIONADOS_AO_TRABALHO = 19;
|
||||
const ESQUISTOSSOMOSE = 20;
|
||||
const FEBRE_AMARELA = 21;
|
||||
const FEBRE_MACULOSA_RICKETTSIOSES = 22;
|
||||
const FEBRE_POR_VIRUS_DO_NILO_OCIDENTAL = 23;
|
||||
const FEBRE_TIFOIDE = 24;
|
||||
const GESTANTE_HIV = 25;
|
||||
const HANSENIASE = 26;
|
||||
const HANTAVIROSE = 27;
|
||||
const HEPATITES_VIRAIS = 28;
|
||||
const INTOXICACAO_EXOGENA = 29;
|
||||
const LEISHMANIOSE_TEGUMENTAR_AMERICANA = 30;
|
||||
const LEISHMANIOSE_VISCERAL = 31;
|
||||
const LEPTOSPIROSE = 32;
|
||||
const MALARIA = 33;
|
||||
const OUTRAS_MENINGITES = 34;
|
||||
const PARALISIA_FLACIDA_AGUDA_POLIOMELITE = 35;
|
||||
const PESTE = 36;
|
||||
const RAIVA_HUMANA = 37;
|
||||
const ROTAVIRUS = 38;
|
||||
const RUBEOLA = 39;
|
||||
const SARAMPO = 40;
|
||||
const SIFILIS_CONGENITA = 41;
|
||||
const SIFILIS_EM_GESTANTE = 42;
|
||||
const SINDROME_DA_RUBEOLA_CONGENITA = 43;
|
||||
const TUBERCULOSE = 44;
|
||||
const TETANO_ACIDENTAL = 45;
|
||||
const TETANO_NEONATAL = 46;
|
||||
const AIDS_PACIENTES_MENORES_QUE_13_ANOS = 47;
|
||||
const BOLETIM_DE_INQUERITO_DE_TRACOMA = 48;
|
||||
const DOENCA_DE_CHAGAS_ADULTA = 49;
|
||||
const ENCEFALITE = 50;
|
||||
const INFLUENZA_HUMANA_POR_NOVO_SUBTIPO_PANDEMICO = 51;
|
||||
const MENINGITE = 52;
|
||||
const SINDROME_HEMOLITICO_UREMICA = 53;
|
||||
const SINDROME_RESPIRATORIA_AGUDA_GRAVE_SRAG_INTERNADA_OU_OBITO_POR_SRAG = 54;
|
||||
const SINDROME_DE_GUILLAIN_BARRE_E_OU_OUTRA_MANIFESTACAO_NEUROLOGICA_ASSOCIADA_COM_ARBOVIRUS = 55;
|
||||
const VIOLENCIA_INTERPESSOAL_AUTOPROVOCADA = 56;
|
||||
}
|
||||
11
api/app/Enums/Ambulatorio/ClassificacaoRisco.php
Normal file
11
api/app/Enums/Ambulatorio/ClassificacaoRisco.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class ClassificacaoRisco
|
||||
{
|
||||
const NAO_AGUDA = 1;
|
||||
const BAIXA = 2;
|
||||
const INTERMEDIARIA = 3;
|
||||
const ALTA = 4;
|
||||
}
|
||||
10
api/app/Enums/Ambulatorio/ColetaMaterial.php
Normal file
10
api/app/Enums/Ambulatorio/ColetaMaterial.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class ColetaMaterial
|
||||
{
|
||||
const COLETA_DE_PAPANICOLAU = 1;
|
||||
const COLETA_DE_EXAME_LABORATORIAL = 2;
|
||||
const COLETA_DE_TRIAGEM_NEONATAL = 3;
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/DemandaTipo.php
Normal file
9
api/app/Enums/Ambulatorio/DemandaTipo.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class DemandaTipo
|
||||
{
|
||||
const AGENDADA = 'agendada';
|
||||
const ESPONTANEA = 'espontanea';
|
||||
}
|
||||
10
api/app/Enums/Ambulatorio/Desfecho.php
Normal file
10
api/app/Enums/Ambulatorio/Desfecho.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class Desfecho
|
||||
{
|
||||
const PACIENTE_LIBERADO = 'Paciente liberado';
|
||||
const PACIENTE_ENCAMINHADO = 'Paciente encaminhado';
|
||||
const MANTER_NA_FILA = 'Paciente mantido na fila';
|
||||
}
|
||||
14
api/app/Enums/Ambulatorio/ExameResultadoTipo.php
Normal file
14
api/app/Enums/Ambulatorio/ExameResultadoTipo.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class ExameResultadoTipo
|
||||
{
|
||||
const NORMAL = 1;
|
||||
const ALTERADO = 2;
|
||||
const SUGESTIVO_DE_INFECCAO_CONGENITA = 3;
|
||||
const OUTRAS_ALTERACOES = 4;
|
||||
const INDETERMINADO = 5;
|
||||
const FALHOU = 6;
|
||||
const PASSOU = 7;
|
||||
}
|
||||
43
api/app/Enums/Ambulatorio/FeridaExsudato.php
Normal file
43
api/app/Enums/Ambulatorio/FeridaExsudato.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
final class FeridaExsudato
|
||||
{
|
||||
public const ESCASSO = 1;
|
||||
public const BAIXO = 2;
|
||||
public const MEDIO = 3;
|
||||
public const ALTO = 4;
|
||||
|
||||
public static function fromDescricao(?string $descricao): ?int
|
||||
{
|
||||
if ($descricao === null) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$norm = self::normalize($descricao);
|
||||
|
||||
$map = [
|
||||
'escasso' => self::ESCASSO,
|
||||
'baixo' => self::BAIXO,
|
||||
'medio' => self::MEDIO,
|
||||
'médio' => self::MEDIO,
|
||||
'alto' => self::ALTO,
|
||||
];
|
||||
|
||||
return $map[$norm] ?? null;
|
||||
}
|
||||
|
||||
private static function normalize(string $text): string
|
||||
{
|
||||
$text = trim(mb_strtolower($text));
|
||||
$text = str_replace(
|
||||
['á','à','ã','â','ä','é','è','ê','ë','í','ì','î','ï','ó','ò','õ','ô','ö','ú','ù','û','ü','ç'],
|
||||
['a','a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o','o','u','u','u','u','c'],
|
||||
$text
|
||||
);
|
||||
|
||||
return preg_replace('/\s+/', ' ', $text);
|
||||
}
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/FeridaStatus.php
Normal file
9
api/app/Enums/Ambulatorio/FeridaStatus.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class FeridaStatus
|
||||
{
|
||||
const ATIVO = 0;
|
||||
const CICATRIZADA = 1;
|
||||
}
|
||||
22
api/app/Enums/Ambulatorio/ImpressaoAssinaturaEletronica.php
Normal file
22
api/app/Enums/Ambulatorio/ImpressaoAssinaturaEletronica.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class ImpressaoAssinaturaEletronica
|
||||
{
|
||||
const REGISTRO_DO_ATENDIMENTO_MEDICO = 1;
|
||||
const REGISTRO_DO_ATENDIMENTO_DE_ENFERMAGEM = 2;
|
||||
const RECEITUARIO_MEDICO = 3;
|
||||
const ENCAMINHAMENTOS = 4;
|
||||
const ORIENTACAO = 5;
|
||||
const SOLICITACAO_DE_EXAMES_SADAT = 6;
|
||||
const SOLICITACAO_DE_EXAMES_SADT = 7;
|
||||
const SOLICITACAO_DE_EXAMES_APAC = 8;
|
||||
const SOLICITACAO_DE_EXAMES_CITOPATOLOGICO_DE_COLO_DE_UTERO = 9;
|
||||
const SOLICITACAO_DE_EXAMES_HISTOPATOLOGICO_DE_MAMA = 10;
|
||||
const SOLICITACAO_DE_EXAMES_CITOPATOLOGICO_DE_MAMA = 11;
|
||||
const ATESTADOS_MEDICOS = 12;
|
||||
const DECLARACOES_DE_COMPARECIMENTO = 13;
|
||||
const CARTAS_MEDICAS = 14;
|
||||
const NOTIFICACAO_COMPULSORIA = 15;
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/JornadaTipo.php
Normal file
9
api/app/Enums/Ambulatorio/JornadaTipo.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class JornadaTipo
|
||||
{
|
||||
const DINAMICA = 1;
|
||||
const FIXA = 2;
|
||||
}
|
||||
71
api/app/Enums/Ambulatorio/LocalAnatomico.php
Normal file
71
api/app/Enums/Ambulatorio/LocalAnatomico.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
final class LocalAnatomico
|
||||
{
|
||||
public const CABECA = 1;
|
||||
public const PESCOCO = 2;
|
||||
public const TRONCO_FRENTE = 3;
|
||||
public const TRONCO_COSTAS = 4;
|
||||
public const BRACO = 5;
|
||||
public const MAO_DETALHES = 6;
|
||||
public const PERNA = 7;
|
||||
public const PES_DEDOS = 8;
|
||||
public const PES_REGIOES = 9;
|
||||
public const PES_CALCANHARES = 10;
|
||||
public const PES_VISTA_EXTERNA = 11;
|
||||
public const PARTES_LATERAIS = 12;
|
||||
public const LADO_DIREITO = 13;
|
||||
public const LADO_ESQUERDO = 14;
|
||||
public const PARTES_ESPECIFICAS = 15;
|
||||
public const GLUTEOS_DETALHES = 16;
|
||||
public const GENITALIA = 17;
|
||||
public const NADEGAS = 18;
|
||||
public const OUTROS = 19;
|
||||
|
||||
public static function fromDescricao(?string $descricao): ?int
|
||||
{
|
||||
if ($descricao === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$norm = self::normalize($descricao);
|
||||
|
||||
$map = [
|
||||
'cabeça' => self::CABECA,
|
||||
'pescoço' => self::PESCOCO,
|
||||
'tronco frente' => self::TRONCO_FRENTE,
|
||||
'tronco costas' => self::TRONCO_COSTAS,
|
||||
'braço' => self::BRACO,
|
||||
'mão detalhes' => self::MAO_DETALHES,
|
||||
'perna' => self::PERNA,
|
||||
'pés dedos' => self::PES_DEDOS,
|
||||
'pés regiões' => self::PES_REGIOES,
|
||||
'pés calcanhares' => self::PES_CALCANHARES,
|
||||
'pés vista externa' => self::PES_VISTA_EXTERNA,
|
||||
'partes laterais' => self::PARTES_LATERAIS,
|
||||
'lado direito' => self::LADO_DIREITO,
|
||||
'lado esquerdo' => self::LADO_ESQUERDO,
|
||||
'partes específicas' => self::PARTES_ESPECIFICAS,
|
||||
'glúteos detalhes' => self::GLUTEOS_DETALHES,
|
||||
'genitália' => self::GENITALIA,
|
||||
'nádegas' => self::NADEGAS,
|
||||
'outros' => self::OUTROS,
|
||||
];
|
||||
|
||||
return $map[$norm] ?? null;
|
||||
}
|
||||
|
||||
private static function normalize(string $text): string
|
||||
{
|
||||
$text = trim(mb_strtolower($text));
|
||||
$text = str_replace(
|
||||
['á','à','ã','â','ä','é','è','ê','ë','í','ì','î','ï','ó','ò','õ','ô','ö','ú','ù','û','ü','ç'],
|
||||
['a','a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o','o','u','u','u','u','c'],
|
||||
$text
|
||||
);
|
||||
|
||||
return preg_replace('/\s+/', ' ', $text);
|
||||
}
|
||||
}
|
||||
410
api/app/Enums/Ambulatorio/LocalAnatomicoRegiao.php
Normal file
410
api/app/Enums/Ambulatorio/LocalAnatomicoRegiao.php
Normal file
@@ -0,0 +1,410 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final class LocalAnatomicoRegiao
|
||||
{
|
||||
private const chaveLocalSafecare = [
|
||||
'head' => 1,
|
||||
'forehead' => 1,
|
||||
'nose' => 1,
|
||||
'chin' => 1,
|
||||
'right_cheek' => 1,
|
||||
'left_cheek' => 1,
|
||||
|
||||
'neck' => 2,
|
||||
|
||||
'right_deltoid' => 3,
|
||||
'left_deltoid' => 3,
|
||||
'right_chest' => 3,
|
||||
'left_chest' => 3,
|
||||
'abdomen' => 3,
|
||||
'right_abdomen' => 3,
|
||||
'left_abdomen' => 3,
|
||||
'sacral' => 3,
|
||||
|
||||
'back_body_right' => 4,
|
||||
'back_body_left' => 4,
|
||||
'trapezius_right' => 4,
|
||||
'trapezius_left' => 4,
|
||||
'glute_right' => 4,
|
||||
'glute_left' => 4,
|
||||
'popliteal_right' => 4,
|
||||
'popliteal_left' => 4,
|
||||
'calf_right' => 4,
|
||||
'calf_left' => 4,
|
||||
|
||||
'right_arm' => 5,
|
||||
'left_arm' => 5,
|
||||
'right_forearm' => 5,
|
||||
'left_forearm' => 5,
|
||||
'right_hand' => 5,
|
||||
'left_hand' => 5,
|
||||
|
||||
'pinky' => 6,
|
||||
'ring' => 6,
|
||||
'middle' => 6,
|
||||
'index' => 6,
|
||||
'thumb' => 6,
|
||||
'palm' => 6,
|
||||
'right_pinky' => 6,
|
||||
'right_ring' => 6,
|
||||
'right_middle' => 6,
|
||||
'right_index' => 6,
|
||||
'right_thumb' => 6,
|
||||
'right_palm' => 6,
|
||||
|
||||
'right_thigh' => 7,
|
||||
'left_thigh' => 7,
|
||||
'right_knee' => 7,
|
||||
'left_knee' => 7,
|
||||
'right_tibial' => 7,
|
||||
'left_tibial' => 7,
|
||||
'right_shin' => 7,
|
||||
'left_shin' => 7,
|
||||
'right_foot' => 7,
|
||||
'left_foot' => 7,
|
||||
|
||||
'big_toe' => 8,
|
||||
'second_toe' => 8,
|
||||
'middle_toe' => 8,
|
||||
'fourth_toe' => 8,
|
||||
'little_toe' => 8,
|
||||
'sole' => 8,
|
||||
'right_big_toe' => 8,
|
||||
'right_second_toe' => 8,
|
||||
'right_middle_toe' => 8,
|
||||
'right_fourth_toe' => 8,
|
||||
'right_little_toe' => 8,
|
||||
'right_sole' => 8,
|
||||
|
||||
'medial_forefoot' => 9,
|
||||
'central_forefoot' => 9,
|
||||
'distal_forefoot' => 9,
|
||||
'plantar_arch' => 9,
|
||||
'central_midfoot' => 9,
|
||||
'distal_midfoot' => 9,
|
||||
'medial_hindfoot' => 9,
|
||||
'central_hindfoot' => 9,
|
||||
'distal_hindfoot' => 9,
|
||||
|
||||
'right_heel' => 10,
|
||||
'left_heel' => 10,
|
||||
'right_achilles_tendon' => 10,
|
||||
'left_achilles_tendon' => 10,
|
||||
|
||||
'right_external_malleolus' => 11,
|
||||
'left_external_malleolus' => 11,
|
||||
'right_external_arch' => 11,
|
||||
'left_external_arch' => 11,
|
||||
'right_external_metatarsal' => 11,
|
||||
'left_external_metatarsal' => 11,
|
||||
|
||||
'side_head' => 12,
|
||||
'side_neck' => 12,
|
||||
'side_abdomen' => 12,
|
||||
'side_sacral' => 12,
|
||||
'side_trochanter1' => 12,
|
||||
'side_trochanter2' => 12,
|
||||
'side_malleolus' => 12,
|
||||
|
||||
'side_right_deltoid' => 13,
|
||||
'side_right_arm' => 13,
|
||||
'side_right_forearm' => 13,
|
||||
'side_right_hand' => 13,
|
||||
'side_right_chest' => 13,
|
||||
'side_right_thigh' => 13,
|
||||
'side_right_shin' => 13,
|
||||
'side_right_foot' => 13,
|
||||
|
||||
'side_left_deltoid' => 14,
|
||||
'side_left_arm' => 14,
|
||||
'side_left_forearm' => 14,
|
||||
'side_left_hand' => 14,
|
||||
'side_left_chest' => 14,
|
||||
'side_left_thigh' => 14,
|
||||
'side_left_shin' => 14,
|
||||
'side_left_foot' => 14,
|
||||
|
||||
'trochanter1' => 15,
|
||||
'trochanter2' => 15,
|
||||
'malleolus' => 15,
|
||||
|
||||
'upper_left' => 16,
|
||||
'upper_right' => 16,
|
||||
'lower_left' => 16,
|
||||
'lower_right' => 16,
|
||||
|
||||
'left_foot_subarea_1' => 17,
|
||||
'left_foot_subarea_2' => 17,
|
||||
'left_foot_subarea_3' => 17,
|
||||
'left_foot_subarea_4' => 17,
|
||||
'left_foot_subarea_5' => 17,
|
||||
'left_foot_subarea_6' => 17,
|
||||
'left_foot_subarea_7' => 17,
|
||||
'left_foot_subarea_8' => 17,
|
||||
'left_foot_subarea_9' => 17,
|
||||
'left_foot_subarea_10' => 17,
|
||||
'left_foot_subarea_11' => 17,
|
||||
'left_foot_subarea_12' => 17,
|
||||
'left_foot_subarea_13' => 17,
|
||||
'left_foot_subarea_14' => 17,
|
||||
'left_foot_subarea_15' => 17,
|
||||
|
||||
'right_foot_subarea_1' => 18,
|
||||
'right_foot_subarea_2' => 18,
|
||||
'right_foot_subarea_3' => 18,
|
||||
'right_foot_subarea_4' => 18,
|
||||
'right_foot_subarea_5' => 18,
|
||||
'right_foot_subarea_6' => 18,
|
||||
'right_foot_subarea_7' => 18,
|
||||
'right_foot_subarea_8' => 18,
|
||||
'right_foot_subarea_9' => 18,
|
||||
'right_foot_subarea_10' => 18,
|
||||
'right_foot_subarea_11' => 18,
|
||||
'right_foot_subarea_12' => 18,
|
||||
'right_foot_subarea_13' => 18,
|
||||
'right_foot_subarea_14' => 18,
|
||||
'right_foot_subarea_15' => 18,
|
||||
];
|
||||
|
||||
private const chaveTraduzida = [
|
||||
|
||||
'cabeca' => 'head',
|
||||
'testa' => 'forehead',
|
||||
'nariz' => 'nose',
|
||||
'queixo' => 'chin',
|
||||
'bochecha direita' => 'right_cheek',
|
||||
'bochecha esquerda' => 'left_cheek',
|
||||
|
||||
'pescoco' => 'neck',
|
||||
|
||||
'deltoide direito' => 'right_deltoid',
|
||||
'deltoide esquerdo' => 'left_deltoid',
|
||||
'peito direito' => 'right_chest',
|
||||
'peito esquerdo' => 'left_chest',
|
||||
'abdomen' => 'abdomen',
|
||||
'abdomen direito' => 'right_abdomen',
|
||||
'abdomen esquerdo' => 'left_abdomen',
|
||||
'sacral' => 'sacral',
|
||||
|
||||
'dorso direito' => 'back_body_right',
|
||||
'dorso esquerdo' => 'back_body_left',
|
||||
'trapezio direito' => 'trapezius_right',
|
||||
'trapezio esquerdo' => 'trapezius_left',
|
||||
'gluteo direito' => 'glute_right',
|
||||
'gluteo esquerdo' => 'glute_left',
|
||||
'poplitea direita' => 'popliteal_right',
|
||||
'poplitea esquerda' => 'popliteal_left',
|
||||
'panturrilha direita' => 'calf_right',
|
||||
'panturrilha esquerda' => 'calf_left',
|
||||
|
||||
'braco direito' => 'right_arm',
|
||||
'braco esquerdo' => 'left_arm',
|
||||
'antebraco direito' => 'right_forearm',
|
||||
'antebraco esquerdo' => 'left_forearm',
|
||||
'mao direita' => 'right_hand',
|
||||
'mao esquerda' => 'left_hand',
|
||||
|
||||
'minimo esquerdo' => 'pinky',
|
||||
'anelar esquerdo' => 'ring',
|
||||
'medio esquerdo' => 'middle',
|
||||
'indicador esquerdo' => 'index',
|
||||
'polegar esquerdo' => 'thumb',
|
||||
'palma esquerda' => 'palm',
|
||||
'minimo direito' => 'right_pinky',
|
||||
'anelar direito' => 'right_ring',
|
||||
'medio direito' => 'right_middle',
|
||||
'indicador direito' => 'right_index',
|
||||
'polegar direito' => 'right_thumb',
|
||||
'palma direita' => 'right_palm',
|
||||
|
||||
'coxa direita' => 'right_thigh',
|
||||
'coxa esquerda' => 'left_thigh',
|
||||
'joelho direito' => 'right_knee',
|
||||
'joelho esquerdo' => 'left_knee',
|
||||
'tibial direita' => 'right_tibial',
|
||||
'tibial esquerda' => 'left_tibial',
|
||||
'canela direita' => 'right_shin',
|
||||
'canela esquerda' => 'left_shin',
|
||||
'pe direito' => 'right_foot',
|
||||
'pe esquerdo' => 'left_foot',
|
||||
|
||||
'dedo 1 esquerdo' => 'big_toe',
|
||||
'dedo 2 esquerdo' => 'second_toe',
|
||||
'terceiro dedo esquerdo' => 'middle_toe',
|
||||
'dedo 4 esquerdo' => 'fourth_toe',
|
||||
'dedo 5 esquerdo' => 'little_toe',
|
||||
'planta do pe esquerda' => 'sole',
|
||||
'dedo 1 direito' => 'right_big_toe',
|
||||
'dedo 2 direito' => 'right_second_toe',
|
||||
'dedo 3 direito' => 'right_middle_toe',
|
||||
'dedo 4 direito' => 'right_fourth_toe',
|
||||
'dedo 5 direito' => 'right_little_toe',
|
||||
'planta do pe direita' => 'right_sole',
|
||||
|
||||
'antepe medial' => 'medial_forefoot',
|
||||
'antepe central' => 'central_forefoot',
|
||||
'antepe distal' => 'distal_forefoot',
|
||||
'arco plantar' => 'plantar_arch',
|
||||
'mediope central' => 'central_midfoot',
|
||||
'mediope distal' => 'distal_midfoot',
|
||||
'retrope medial' => 'medial_hindfoot',
|
||||
'retrope central' => 'central_hindfoot',
|
||||
'retrope distal' => 'distal_hindfoot',
|
||||
|
||||
'calcanhar direito' => 'right_heel',
|
||||
'calcanhar esquerdo' => 'left_heel',
|
||||
'tendao de aquiles direito' => 'right_achilles_tendon',
|
||||
'tendao de aquiles esquerdo' => 'left_achilles_tendon',
|
||||
|
||||
'maleolo externo direito' => 'right_external_malleolus',
|
||||
'maleolo externo esquerdo' => 'left_external_malleolus',
|
||||
'arco externo direito' => 'right_external_arch',
|
||||
'arco externo esquerdo' => 'left_external_arch',
|
||||
'metatarso externo direito' => 'right_external_metatarsal',
|
||||
'metatarso externo esquerdo' => 'left_external_metatarsal',
|
||||
|
||||
'cabeca lateral' => 'side_head',
|
||||
'pescoco lateral' => 'side_neck',
|
||||
'abdomen lateral' => 'side_abdomen',
|
||||
'sacral lateral' => 'side_sacral',
|
||||
'trocanter 1 lateral' => 'side_trochanter1',
|
||||
'trocanter 2 lateral' => 'side_trochanter2',
|
||||
'maleolo lateral' => 'side_malleolus',
|
||||
|
||||
'deltoide direito lateral' => 'side_right_deltoid',
|
||||
'braco direito lateral' => 'side_right_arm',
|
||||
'antebraco direito lateral' => 'side_right_forearm',
|
||||
'mao direita lateral' => 'side_right_hand',
|
||||
'peito direito lateral' => 'side_right_chest',
|
||||
'coxa direita lateral' => 'side_right_thigh',
|
||||
'canela direita lateral' => 'side_right_shin',
|
||||
'pe direito lateral' => 'side_right_foot',
|
||||
|
||||
'deltoide esquerdo lateral' => 'side_left_deltoid',
|
||||
'braco esquerdo lateral' => 'side_left_arm',
|
||||
'antebraco esquerdo lateral' => 'side_left_forearm',
|
||||
'mao esquerda lateral' => 'side_left_hand',
|
||||
'peito esquerdo lateral' => 'side_left_chest',
|
||||
'coxa esquerda lateral' => 'side_left_thigh',
|
||||
'canela esquerda lateral' => 'side_left_shin',
|
||||
'pe esquerdo lateral' => 'side_left_foot',
|
||||
|
||||
'trocanter 1' => 'trochanter1',
|
||||
'trocanter 2' => 'trochanter2',
|
||||
'maleolo' => 'malleolus',
|
||||
|
||||
'superior esquerdo' => 'upper_left',
|
||||
'superior direito' => 'upper_right',
|
||||
'inferior esquerdo' => 'lower_left',
|
||||
'inferior direito' => 'lower_right',
|
||||
|
||||
'subarea 1 do pe esquerdo' => 'left_foot_subarea_1',
|
||||
'subarea 2 do pe esquerdo' => 'left_foot_subarea_2',
|
||||
'subarea 3 do pe esquerdo' => 'left_foot_subarea_3',
|
||||
'subarea 4 do pe esquerdo' => 'left_foot_subarea_4',
|
||||
'subarea 5 do pe esquerdo' => 'left_foot_subarea_5',
|
||||
'subarea 6 do pe esquerdo' => 'left_foot_subarea_6',
|
||||
'subarea 7 do pe esquerdo' => 'left_foot_subarea_7',
|
||||
'subarea 8 do pe esquerdo' => 'left_foot_subarea_8',
|
||||
'subarea 9 do pe esquerdo' => 'left_foot_subarea_9',
|
||||
'subarea 10 do pe esquerdo' => 'left_foot_subarea_10',
|
||||
'subarea 11 do pe esquerdo' => 'left_foot_subarea_11',
|
||||
'subarea 12 do pe esquerdo' => 'left_foot_subarea_12',
|
||||
'subarea 13 do pe esquerdo' => 'left_foot_subarea_13',
|
||||
'subarea 14 do pe esquerdo' => 'left_foot_subarea_14',
|
||||
'subarea 15 do pe esquerdo' => 'left_foot_subarea_15',
|
||||
|
||||
'subarea 1 do pe direito' => 'right_foot_subarea_1',
|
||||
'subarea 2 do pe direito' => 'right_foot_subarea_2',
|
||||
'subarea 3 do pe direito' => 'right_foot_subarea_3',
|
||||
'subarea 4 do pe direito' => 'right_foot_subarea_4',
|
||||
'subarea 5 do pe direito' => 'right_foot_subarea_5',
|
||||
'subarea 6 do pe direito' => 'right_foot_subarea_6',
|
||||
'subarea 7 do pe direito' => 'right_foot_subarea_7',
|
||||
'subarea 8 do pe direito' => 'right_foot_subarea_8',
|
||||
'subarea 9 do pe direito' => 'right_foot_subarea_9',
|
||||
'subarea 10 do pe direito' => 'right_foot_subarea_10',
|
||||
'subarea 11 do pe direito' => 'right_foot_subarea_11',
|
||||
'subarea 12 do pe direito' => 'right_foot_subarea_12',
|
||||
'subarea 13 do pe direito' => 'right_foot_subarea_13',
|
||||
'subarea 14 do pe direito' => 'right_foot_subarea_14',
|
||||
'subarea 15 do pe direito' => 'right_foot_subarea_15',
|
||||
];
|
||||
|
||||
public static function fromKey(?string $key, ?int $localAnatomicoId = null): ?int
|
||||
{
|
||||
if ($key === null) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$key = self::normalizeKey($key);
|
||||
|
||||
$query = DB::table('cadastro_local_anatomico_regiao')
|
||||
->where('key', $key);
|
||||
|
||||
if ($localAnatomicoId !== null) {
|
||||
|
||||
$query->where('local_anatomico_id', $localAnatomicoId);
|
||||
} else {
|
||||
|
||||
$hint = self::chaveLocalSafecare[$key] ?? null;
|
||||
|
||||
if ($hint !== null) {
|
||||
|
||||
$query->where('local_anatomico_id', $hint);
|
||||
}
|
||||
}
|
||||
|
||||
$row = $query->first(['id']);
|
||||
return $row ? (int) $row->id : null;
|
||||
}
|
||||
|
||||
public static function fromDescricao(?string $descricao, ?int $localAnatomicoId = null): ?int
|
||||
{
|
||||
if ($descricao === null) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$norm = self::normalize($descricao);
|
||||
$key = self::chaveTraduzida[$norm] ?? null;
|
||||
|
||||
if ($key === null) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::fromKey($key, $localAnatomicoId);
|
||||
}
|
||||
|
||||
public static function localAnatomicoIdForKey(string $key): ?int
|
||||
{
|
||||
$key = self::normalizeKey($key);
|
||||
return self::chaveLocalSafecare[$key] ?? null;
|
||||
}
|
||||
|
||||
public static function normalize(string $text): string
|
||||
{
|
||||
$text = trim(mb_strtolower($text));
|
||||
$text = str_replace(
|
||||
['á','à','ã','â','ä','é','è','ê','ë','í','ì','î','ï','ó','ò','õ','ô','ö','ú','ù','û','ü','ç','́','’',"'",'º','ª'],
|
||||
['a','a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o','o','u','u','u','u','c','','','','',''],
|
||||
$text
|
||||
);
|
||||
|
||||
return preg_replace('/\s+/', ' ', $text);
|
||||
}
|
||||
|
||||
public static function normalizeKey(string $key): string
|
||||
{
|
||||
$key = trim(mb_strtolower($key));
|
||||
$key = preg_replace('/\s+/', '_', $key);
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/Origem.php
Normal file
9
api/app/Enums/Ambulatorio/Origem.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class Origem
|
||||
{
|
||||
const AGENDADA = 1;
|
||||
const ESPONTANEA = 2;
|
||||
}
|
||||
14
api/app/Enums/Ambulatorio/OutroProcedimento.php
Normal file
14
api/app/Enums/Ambulatorio/OutroProcedimento.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class OutroProcedimento
|
||||
{
|
||||
const INALACAO = 1;
|
||||
const RETIRADA_DE_PONTOS = 2;
|
||||
const CURATIVO_SIMPLES = 3;
|
||||
const CURATIVO_GRAU_II_COM_OU_SEM_DEBRIDAMENTO = 4;
|
||||
const PROVA_DO_LACO = 5;
|
||||
const CURATIVO_ESPECIAL = 6;
|
||||
const PREPARACAO_PARA_ECG = 7;
|
||||
}
|
||||
10
api/app/Enums/Ambulatorio/PrescricaoFrequenciaDose.php
Normal file
10
api/app/Enums/Ambulatorio/PrescricaoFrequenciaDose.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class PrescricaoFrequenciaDose
|
||||
{
|
||||
const INTERVALO = 'intervalo';
|
||||
const FREQUENCIA = 'frequencia';
|
||||
const TURNO = 'turno';
|
||||
}
|
||||
10
api/app/Enums/Ambulatorio/ProblemaCondicaoSituacao.php
Normal file
10
api/app/Enums/Ambulatorio/ProblemaCondicaoSituacao.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class ProblemaCondicaoSituacao
|
||||
{
|
||||
const ATIVO = 1;
|
||||
const LATENTE = 2;
|
||||
const RESOLVIDO = 3;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class SaudeBucalDenteProblemaCondicao
|
||||
{
|
||||
const AUSENTE_A = 1;
|
||||
const EXTRAIDO_E = 2;
|
||||
const HIGIDO_H = 3;
|
||||
const HIGIDO_SELADO_HS = 4;
|
||||
const PROTESE_PARCIAL_REMOVIVEL = 5;
|
||||
const PROTESE_TEMPORARIA = 6;
|
||||
const INCLUSO_I = 7;
|
||||
const PROTESE_CORONARIA_UNITARIA = 8;
|
||||
const COROA_CO = 9;
|
||||
const IMPLANTE = 10;
|
||||
const PILAR_P = 11;
|
||||
const NUCLEO_PINO = 12;
|
||||
const RESTO_RADICULAR_RR = 13;
|
||||
const RETRACAO_GENGIVAL_RG = 14;
|
||||
const CALCULO_DENTAL_CD = 15;
|
||||
const EXTRACAO_INDICADA_EI = 16;
|
||||
const SELANTE_INDICADO_SI = 17;
|
||||
const FRATURA_FR = 18;
|
||||
const MANCHA_BRANCA_ATIVA_M = 19;
|
||||
const CARIADO_C = 20;
|
||||
const RESTAURADO_R = 21;
|
||||
const CARIE_DA_RAIZ = 22;
|
||||
const RESTAURADO_COM_CARIE_RC = 23;
|
||||
const RAIZ_RESTAURADA = 24;
|
||||
const NECESSITA_DE_TRATAMENTO_ENDODONTICO = 25;
|
||||
const POSSUI_LESAO_DE_FURCA = 26;
|
||||
const TRATAMENTO_ENDODONTICO_REALIZADO = 27;
|
||||
const LESAO_DE_FURCA_TRATADA = 28;
|
||||
const MANTENEDOR_DE_ESPACO_ME = 29;
|
||||
}
|
||||
11
api/app/Enums/Ambulatorio/ServicoTipo.php
Normal file
11
api/app/Enums/Ambulatorio/ServicoTipo.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class ServicoTipo
|
||||
{
|
||||
const VACINACAO = 1;
|
||||
const DEMANDA_ESPONTANEA = 2;
|
||||
const DEMANDA_AGENDADA = 3;
|
||||
const POS_CONSULTA = 4;
|
||||
}
|
||||
9
api/app/Enums/Ambulatorio/SigiloTipo.php
Normal file
9
api/app/Enums/Ambulatorio/SigiloTipo.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class SigiloTipo
|
||||
{
|
||||
const SIGILO_ATENDIMENTO = 1;
|
||||
const SIGILO_COMPLETO = 2;
|
||||
}
|
||||
10
api/app/Enums/Ambulatorio/SituacaoCodigoEsus.php
Normal file
10
api/app/Enums/Ambulatorio/SituacaoCodigoEsus.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class SituacaoCodigoEsus
|
||||
{
|
||||
const ATIVO = 0;
|
||||
const LATENTE = 1;
|
||||
const RESOLVIDO = 2;
|
||||
}
|
||||
28
api/app/Enums/Ambulatorio/TesteRapido.php
Normal file
28
api/app/Enums/Ambulatorio/TesteRapido.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Ambulatorio;
|
||||
|
||||
class TesteRapido
|
||||
{
|
||||
const GRAVIDEZ = 1;
|
||||
const SIFILIS = 2;
|
||||
const DETECCAO_DE_INFECCAO_PELO_HIV = 3;
|
||||
const DETECCAO_DE_INFECCAO_PELO_HBV = 4;
|
||||
const DETECCAO_DE_HEPATITE_C = 5;
|
||||
const DENGUE_IGG_IGM = 6;
|
||||
const PSA = 7;
|
||||
const DETECCAO_DE_SARS_COVID_2 = 8;
|
||||
const FEBRE_CHIKUNGUNYA_IGM = 9;
|
||||
const VIRUS_ZIKA_IGG_IGM = 10;
|
||||
const SIFILIS_NA_GESTANTE_OU_PAI_PARCEIRO = 11;
|
||||
const DETECCAO_DE_HIV_NA_GESTANTE_OU_PAI_PARCEIRO = 12;
|
||||
const DENGUE_NS1 = 13;
|
||||
const PROTEINURIA = 14;
|
||||
const TESTE_DO_OLHINHO_TRV = 15;
|
||||
const TESTE_RAPIDO_SIFILIS_EM_GESTANTE = 16;
|
||||
const TESTE_RAPIDO_SIFILIS_EM_PARCEIRO_OU_PARCERIA_DE_GESTANTE = 17;
|
||||
const TESTE_RAPIDO_DETECCAO_DE_ANTICORPOS_ANTI_HIV_EM_GESTANTE = 18;
|
||||
const TESTE_RAPIDO_DETECCAO_DE_ANTICORPOS_ANTI_HIV_EM_PARCEIRO_OU_PARCERIA_DE_GESTANTE = 19;
|
||||
const TESTE_RAPIDO_PARA_DETECCAO_DE_HEPATITE_C_POPULACAO_GERAL_EXCETO_GESTANTE_PARCEIRO_OU_PARCERIA = 20;
|
||||
const DETECCAO_DE_INFECCAO_PELO_HBV_POPULACAO_GERAL_EXCETO_GESTANTE_PARCEIRO_OU_PARCERIA = 21;
|
||||
}
|
||||
13
api/app/Enums/Apac/CaraterAtendimento.php
Normal file
13
api/app/Enums/Apac/CaraterAtendimento.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class CaraterAtendimento
|
||||
{
|
||||
const ELETIVO = 1;
|
||||
const URGENCIA = 2;
|
||||
const ACIDENTE_NO_LOCAL_DE_TRABALHO_OU_A_SERVICO_DA_EMPRESA = 3;
|
||||
const ACIDENTE_NO_TRAJETO_PARA_O_TRABALHO = 4;
|
||||
const OUTROS_TIPOS_DE_ACIDENTE_DE_TRANSITO = 5;
|
||||
const OUTROS_TIPOS_DE_LESOES_E_ENVENENAMENTOS_POR_AGENTES_QUIMICOS_OU_FISICOS = 6;
|
||||
}
|
||||
11
api/app/Enums/Apac/FonteOrcamentaria.php
Normal file
11
api/app/Enums/Apac/FonteOrcamentaria.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class FonteOrcamentaria
|
||||
{
|
||||
const MOD_1_SERVICO_DE_SAUDE_AES = 1;
|
||||
const MOD_2_EQUIPE_VOLANTES_AES = 2;
|
||||
const CREDITO_FINANC_PARC_VENCIDAS_E_VICENDAS = 3;
|
||||
const CREDITO_FINANCEIRO_TRANSACAO_TRIBUTARIA = 4;
|
||||
}
|
||||
72
api/app/Enums/Apac/Inconsistencia.php
Normal file
72
api/app/Enums/Apac/Inconsistencia.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class Inconsistencia
|
||||
{
|
||||
const COMPETENCIA_INVALIDA = 1;
|
||||
const NUMERO_DA_APAC_E_OBRIGATORIO = 2;
|
||||
const NUMERO_DA_APAC_INVALIDO = 3;
|
||||
const IBGE_DO_ESTADO_DA_UNIDADE_EXECUTANTE_INVALIDO = 4;
|
||||
const CNES_DA_UNIDADE_EXECUTANTE_E_OBRIGATORIO = 5;
|
||||
const CNES_DA_UNIDADE_EXECUTANTE_INVALIDO = 6;
|
||||
const TIPO_DE_ATENDIMENTO_E_OBRIGATORIO = 7;
|
||||
const NOME_DA_MAE_DO_PACIENTE_E_OBRIGATORIO = 8;
|
||||
const ENDERECO_DO_PACIENTE_E_OBRIGATORIO = 9;
|
||||
const CEP_DO_PACIENTE_INVALIDO = 10;
|
||||
const IBGE_DO_MUNICIPIO_DE_RESIDENCIA_DO_PACIENTE_INVALIDO = 11;
|
||||
const DATA_DE_NASCIMENTO_DO_PACIENTE_E_OBRIGATORIA = 12;
|
||||
const SEXO_DO_PACIENTE_E_OBRIGATORIO = 13;
|
||||
const PROCEDIMENTO_PRINCIPAL_INVALIDO_PARA_A_COMPETENCIA = 14;
|
||||
const PROCEDIMENTO_PRINCIPAL_INVALIDO_PARA_O_SEXO_DO_PACIENTE = 15;
|
||||
const PROCEDIMENTO_PRINCIPAL_INVALIDO_PARA_A_IDADE_DO_PACIENTE = 16;
|
||||
const NOME_DO_PROFISSIONAL_AUTORIZADOR_E_OBRIGATORIO = 17;
|
||||
const CNS_DO_PACIENTE_E_OBRIGATORIO = 18;
|
||||
const CNS_DO_PACIENTE_INVALIDO = 19;
|
||||
const CNS_DO_PROFISSIONAL_RESPONSAVEL_E_OBRIGATORIO = 20;
|
||||
const CNS_DO_PROFISSIONAL_RESPONSAVEL_INVALIDO = 21;
|
||||
const CNS_DO_PROFISSIONAL_AUTORIZADOR_E_OBRIGATORIO = 22;
|
||||
const CNS_DO_PROFISSIONAL_AUTORIZADOR_INVALIDO = 23;
|
||||
const CID_CAUSAS_ASSOCIADAS_INVALIDO_PARA_O_PROCEDIMENTO_PRINCIPAL = 24;
|
||||
const CNES_DA_UNIDADE_SOLICITANTE_INVALIDO = 25;
|
||||
const DATA_DA_AUTORIZACAO_E_OBRIGATORIA = 26;
|
||||
const CODIGO_DO_EMISSOR_E_OBRIGATORIO = 27;
|
||||
const CODIGO_DO_EMISSOR_INVALIDO = 28;
|
||||
const NUMERO_DA_APAC_ANTERIOR_INVALIDO = 29;
|
||||
const RACA_COR_DO_PACIENTE_E_OBRIGATORIO = 30;
|
||||
const ETNIA_INDIGENA_DO_PACIENTE_E_OBRIGATORIA = 31;
|
||||
const PAIS_DE_NASCIMENTO_DO_PACIENTE_E_OBRIGATORIO = 32;
|
||||
const TELEFONE_DO_PACIENTE_INVALIDO = 33;
|
||||
const CNS_DO_PROFISSIONAL_EXECUTANTE_E_OBRIGATORIO = 34;
|
||||
const CNS_DO_PROFISSIONAL_EXECUTANTE_INVALIDO = 35;
|
||||
const CPF_DO_PACIENTE_INVALIDO = 36;
|
||||
const CID_PRINCIPAL_E_OBRIGATORIO = 37;
|
||||
const CID_PRINCIPAL_INVALIDO_PARA_O_PROCEDIMENTO_PRINCIPAL = 38;
|
||||
const CID_SECUNDARIO_INVALIDO_PARA_O_PROCEDIMENTO_PRINCIPAL = 39;
|
||||
const DATA_DE_IDENTIFICACAO_PATOLOGICA_E_OBRIGATORIA = 40;
|
||||
const PROCEDIMENTO_INVALIDO_PARA_A_COMPETENCIA = 41;
|
||||
const PROCEDIMENTO_INVALIDO_PARA_O_SEXO_DO_PACIENTE = 42;
|
||||
const PROCEDIMENTO_INVALIDO_PARA_O_CBO = 43;
|
||||
const PROCEDIMENTO_INVALIDO_PARA_A_IDADE_DO_PACIENTE = 44;
|
||||
const QUANTIDADE_DO_PROCEDIMENTO_INVALIDA = 45;
|
||||
const CNPJ_DE_CESSAO_DE_CREDITO_INVALIDO = 46;
|
||||
const CID_PRINCIPAL_INVALIDO_PARA_O_PROCEDIMENTO = 47;
|
||||
const CID_SECUNDARIO_INVALIDO_PARA_O_PROCEDIMENTO = 48;
|
||||
const CLASSIFICACAO_INVALIDA_PARA_O_PROCEDIMENTO = 49;
|
||||
const CLASSIFICACAO_INVALIDA_PARA_O_SERVICO = 50;
|
||||
const CNES_DA_UNIDADE_PRESTADORA_DE_TERCEIRO_INVALIDO = 51;
|
||||
const CID_CAUSA_ASSOCIADA_INVALIDO_PARA_O_SEXO_DO_PACIENTE = 52;
|
||||
const CID_PRINCIPAL_INVALIDO_PARA_O_SEXO_DO_PACIENTE = 53;
|
||||
const CID_SECUNDARIO_INVALIDO_PARA_O_SEXO_DO_PACIENTE = 54;
|
||||
const CEP_DO_PACIENTE_E_OBRIGATORIO = 55;
|
||||
const NUMERO_DO_ENDERECO_DO_PACIENTE_E_OBRIGATORIO = 56;
|
||||
const PROCEDIMENTO_PRINCIPAL_INVALIDO_PARA_O_CBO = 57;
|
||||
const QUANTIDADE_INVALIDA_PARA_O_PROCEDIMENTO_PRINCIPAL = 58;
|
||||
const CLASSIFICACAO_INVALIDA_PARA_O_PROCEDIMENTO_PRINCIPAL = 59;
|
||||
const CID_PRINCIPAL_DADOS_COMPLEMENTARES_E_OBRIGATORIO = 60;
|
||||
const CID_PRINCIPAL_DADOS_COMPLEMENTARES_INVALIDO_PARA_O_PROCEDIMENTO_PRINCIPAL = 61;
|
||||
const CID_PRINCIPAL_DADOS_COMPLEMENTARES_INVALIDO_PARA_O_SEXO_DO_PACIENTE = 62;
|
||||
const CID_SECUNDARIO_DADOS_COMPLEMENTARES_INVALIDO_PARA_O_PROCEDIMENTO_PRINCIPAL = 63;
|
||||
const CID_SECUNDARIO_DADOS_COMPLEMENTARES_INVALIDO_PARA_O_SEXO_DO_PACIENTE = 64;
|
||||
const CID_PRINCIPAL_E_OBRIGATORIO_PARA_O_PROCEDIMENTO_PRINCIPAL = 65;
|
||||
}
|
||||
21
api/app/Enums/Apac/Linha.php
Normal file
21
api/app/Enums/Apac/Linha.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class Linha
|
||||
{
|
||||
const CABECALHO = '01';
|
||||
const CORPO = '14';
|
||||
const REGISTRO_PROCEDIMENTO = '13';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_QUIMIOTERAPIA = '07';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_RADIOTERAPIA = '08';
|
||||
const PARTE_VARIAVEL_NEFROLOGIA = '09';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_MEDICAMENTO = '10';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_ACOMPANHAMENTO_POS_CIRURGIA_BARIATRICA = '11';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_ACOMPANHAMENTO_PRE_CIRURGIA_BARIATRICA = '17';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_LAUDO_GERAL = '06';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_LAUDO_PROTESE_MAMA = '12';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_LAUDO_TRATAMENTO_DIALITICO = '18';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_LAUDO_ACOMPANHAMENTO_MULTIPROFISSIONAL_DRC = '19';
|
||||
const PARTE_VARIAVEL_PROCEDIMENTO_LAUDO_CONFECCAO_FISTULA_ARTERIOVENOSA = '20';
|
||||
}
|
||||
28
api/app/Enums/Apac/MotivoSaidaPermanencia.php
Normal file
28
api/app/Enums/Apac/MotivoSaidaPermanencia.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class MotivoSaidaPermanencia
|
||||
{
|
||||
const ALTA_CURADO = 1;
|
||||
const ALTA_MELHORADO = 2;
|
||||
const ALTA_DA_PUERPERA_E_PERMANENCIA_DO_RECEM_NASCIDO = 3;
|
||||
const ALTA_A_PEDIDO = 4;
|
||||
const ALTA_COM_PREVISAO_DE_RETORNO_PARA_ACOMPANHAMENTO_DO_PACIENTE = 5;
|
||||
const ALTA_POR_EVASAO = 6;
|
||||
const ALTA_DA_PUERPERA_E_RECEM_NASCIDO = 7;
|
||||
const ALTA_POR_OUTROS_MOTIVOS = 8;
|
||||
const POR_CARACTERISTICAS_PROPRIAS_DA_DOENCA = 9;
|
||||
const POR_INTERCORRENCIA = 10;
|
||||
const POR_IMPOSSIBILIDADE_SOCIO_FAMILIAR = 11;
|
||||
const POR_PROCESSO_DE_DOACAO_DE_ORGAOS_TECIDOS_E_CELULAS_DOADOR_VIVO = 12;
|
||||
const POR_PROCESSO_DE_DOACAO_DE_ORGAOS_TECIDOS_E_CELULAS_DOADOR_MORTO = 13;
|
||||
const POR_MUDANCA_DE_PROCEDIMENTO = 14;
|
||||
const POR_REOPERACAO = 15;
|
||||
const OUTROS_MOTIVOS = 16;
|
||||
const TRANSFERIDO_PARA_OUTRO_ESTABELECIMENTO = 17;
|
||||
const COM_DECLARACAO_DE_OBITO_FORNECIDA_PELO_MEDICO_ASSISTENTE = 18;
|
||||
const COM_DECLARACAO_DE_OBITO_FORNECIDA_PELO_INSTITUTO_MEDICO_LEGAL_IML = 19;
|
||||
const COM_DECLARACAO_DE_OBITO_FORNECIDA_PELO_SERVICO_DE_VERIFICACAO_DE_OBITO_SVO = 20;
|
||||
const ENCERRAMENTO_ADMINISTRATIVO = 21;
|
||||
}
|
||||
12
api/app/Enums/Apac/RacaCor.php
Normal file
12
api/app/Enums/Apac/RacaCor.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class RacaCor
|
||||
{
|
||||
const BRANCA = '01';
|
||||
const PRETA = '02';
|
||||
const PARDA = '03';
|
||||
const AMARELA = '04';
|
||||
const INDIGENA = '05';
|
||||
}
|
||||
9
api/app/Enums/Apac/Sexo.php
Normal file
9
api/app/Enums/Apac/Sexo.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class Sexo
|
||||
{
|
||||
const MASCULINO = 'M';
|
||||
const FEMININO = 'F';
|
||||
}
|
||||
11
api/app/Enums/Apac/Tipo.php
Normal file
11
api/app/Enums/Apac/Tipo.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class Tipo
|
||||
{
|
||||
const INICIAL = 1;
|
||||
const CONTINUIDADE = 2;
|
||||
const UNICA = 3;
|
||||
const ENCERRAMENTO = 4;
|
||||
}
|
||||
10
api/app/Enums/Apac/TipoAtendimento.php
Normal file
10
api/app/Enums/Apac/TipoAtendimento.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Apac;
|
||||
|
||||
class TipoAtendimento
|
||||
{
|
||||
const TRS = 1;
|
||||
const RADIOTERAPIA = 2;
|
||||
const QUIMIOTERAPIA = 3;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoDomiciliar;
|
||||
|
||||
class CondicaoAvaliada
|
||||
{
|
||||
const OXIGENOTERAPIA_DOMICILIAR = 17;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoDomiciliar;
|
||||
|
||||
class CondutaDesfecho
|
||||
{
|
||||
const PERMANENCIA = 1;
|
||||
const ALTA_ADMINISTRATIVA = 2;
|
||||
const ALTA_CLINICA = 3;
|
||||
const OBITO = 4;
|
||||
const ATENCAO_BASICA_AD1 = 5;
|
||||
const SERVICO_DE_URGENCIA_E_EMERGENCIA = 6;
|
||||
const SERVICO_DE_INTERNACAO_HOSPITALAR = 7;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoDomiciliar;
|
||||
|
||||
class Modalidade
|
||||
{
|
||||
const AD_1 = 1;
|
||||
const AD_2 = 2;
|
||||
const AD_3 = 3;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoDomiciliar;
|
||||
|
||||
class PerfilEpidemiologico
|
||||
{
|
||||
const USO_DE_DIETAS_ESPECIAIS = 1;
|
||||
const ENTREGA_DE_MATERIAIS = 2;
|
||||
const ADQUIRIU_INFECCAO_DOMICILIAR = 3;
|
||||
const SISTEMA_NEUROLOGICO = 4;
|
||||
const SISTEMA_RESPIRATORIO = 5;
|
||||
const SISTEMA_ENDOCRINO = 6;
|
||||
const SISTEMA_GENITURINARIO = 7;
|
||||
const USO_DE_ESPESSANTE = 8;
|
||||
const AVALIACAO_DE_PROCESSO = 9;
|
||||
const RESIDENTE_EM_AREA_DE_RISCO = 10;
|
||||
const SISTEMA_CARDIOLOGICO = 11;
|
||||
const SISTEMA_OSTEO_MIO_ARTICULAR = 12;
|
||||
const SISTEMA_TEGUMENTAR = 13;
|
||||
const OUTROS = 14;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoDomiciliar;
|
||||
|
||||
class Procedimento
|
||||
{
|
||||
const ACOMPANHAMENTO_PACIENTE_REABILITACAO_COMUNICACAO = '0301070024';
|
||||
const ANTIBIOTICOTERAPIA_PARENTERAL = '0301050082';
|
||||
const ATENDIMENTO_ACOMPANHAMENTO_PACIENTE_REABILITACAO_DESENVOLVIMENTO_MOTOR = '0301070075';
|
||||
const ATENDIMENTO_FISIOTERAPEUTICO_PACIENTE_TRANSTORNO_RESPIRATORIO_SEM_COMPLICACOES_SISTEMICAS = '0302040021';
|
||||
const ATEMDIMENTO_MEDICO_FINALIDADE_ATESTAR_OBITO = '0301050090';
|
||||
const ATENDIMENTO_ACOMPANHAMENTO_REABILITACAO_MULTIPLAS_DEFICIENCIAS = '0301070067';
|
||||
const CATETERISMO_VESICAL_ALIVIO = '0301100047';
|
||||
const CATETERISMO_VESICAL_DEMORA = '0301100055';
|
||||
const COLETA_MATERIAL_EXAME_LABORATORIAL = '0201020041';
|
||||
const CUIDADOS_ESTOMAS = '0301100063';
|
||||
const CUIDADOS_TRAQUEOSTOMIA = '0301100071';
|
||||
const ENEMA = '0301100098';
|
||||
const OXIGENOTERAPIA = '0301100144';
|
||||
const RETIRADAS_PONTOS_CIRURGIAS_BASICAS = '0301100152';
|
||||
const SONDAGEM_GASTRICA = '0301100179';
|
||||
const TERAPIA_REIDRATACAO_ORAL = '0301100187';
|
||||
const TERAPIA_REIDRATACAO_PARENTERAL = '0301050120';
|
||||
const TERAPIA_FONOAUDIOLOGICA_INDIVIDUAL = '0301070113';
|
||||
const TRATAMENTO_TRAUMATISMO = '0308010019';
|
||||
const TRATAMENTO_REABILITACAO = '0303190019';
|
||||
const TRAQUEOSTOMIA = '0404010377';
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class CondicaoAvaliada
|
||||
{
|
||||
const ASMA = 1;
|
||||
const DESNUTRICAO = 2;
|
||||
const DIABETES = 3;
|
||||
const DPOC = 4;
|
||||
const HIPERTENSAO_ARTERIAL = 5;
|
||||
const OBESIDADE = 6;
|
||||
const PRE_NATAL = 7;
|
||||
const PUERICULTURA = 8;
|
||||
const PUERPERIO_ATE_42_DIAS = 9;
|
||||
const REABILITACAO = 10;
|
||||
const SAUDE_MENTAL = 11;
|
||||
const SAUDE_SEXUAL_E_REPRODUTIVA = 12;
|
||||
const TABAGISMO = 13;
|
||||
const USUARIO_DE_ALCOOL = 14;
|
||||
const USUARIO_DE_OUTRAS_DROGAS = 15;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class CondicaoAvaliadaCodigoEsus
|
||||
{
|
||||
const ASMA = 'ABP009';
|
||||
const DESNUTRICAO = 'ABP008';
|
||||
const DIABETES = 'ABP006';
|
||||
const DPOC = 'ABP010';
|
||||
const HIPERTENSAO_ARTERIAL = 'ABP005';
|
||||
const OBESIDADE = 'ABP007';
|
||||
const PRE_NATAL = 'ABP001';
|
||||
const PUERICULTURA = 'ABP004';
|
||||
const PUERPERIO_ATE_42_DIAS = 'ABP002';
|
||||
const REABILITACAO = 'ABP015';
|
||||
const SAUDE_MENTAL = 'ABP014';
|
||||
const SAUDE_SEXUAL_E_REPRODUTIVA = 'ABP003';
|
||||
const TABAGISMO = 'ABP011';
|
||||
const USUARIO_DE_ALCOOL = 'ABP012';
|
||||
const USUARIO_DE_OUTRAS_DROGAS = 'ABP013';
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class Conduta
|
||||
{
|
||||
const RETORNO_PARA_CONSULTA_AGENDADA = 1;
|
||||
const RETORNO_PARA_CUIDADO_CONTINUADO_PROGRAMADO = 2;
|
||||
const AGENDAMENTO_PARA_GRUPOS = 3;
|
||||
const AGENDAMENTO_PARA_NASF = 4;
|
||||
const ALTA_DO_EPISODIO = 5;
|
||||
const AGENDAMENTO_PARA_E_MULTI = 6;
|
||||
const TRATAMENTO_CONCLUIDO = 7;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class DoencaTransmissivel
|
||||
{
|
||||
const DENGUE = 1;
|
||||
const DST = 2;
|
||||
const HANSENIASE = 3;
|
||||
const TUBERCULOSE = 4;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class Encaminhamento
|
||||
{
|
||||
const ENCAMINHAMENTO_INTERNO_NO_DIA = 1;
|
||||
const ENCAMINHAMENTO_PARA_SERVICO_ESPECIALIZADO = 2;
|
||||
const ENCAMINHAMENTO_PARA_CAPS = 3;
|
||||
const ENCAMINHAMENTO_PARA_INTERNACAO_HOSPITALAR = 4;
|
||||
const ENCAMINHAMENTO_PARA_URGENCIA = 5;
|
||||
const ENCAMINHAMENTO_PARA_SERVICO_DE_ATENCAO_DOMICILIAR = 6;
|
||||
const ENCAMINHAMENTO_INTERSETORIAL = 7;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class ExameSolicitadoAvaliado
|
||||
{
|
||||
const COLESTEROL_TOTAL = 1;
|
||||
const CREATININA = 2;
|
||||
const EAS_EQU = 3;
|
||||
const ELETROCARDIOGRAMA = 4;
|
||||
const ELETROFORESE_DE_HEMOGLOBINA = 5;
|
||||
const ESPIROMETRIA = 6;
|
||||
const EXAME_DE_ESCARRO = 7;
|
||||
const GLICEMIA = 8;
|
||||
const HDL = 9;
|
||||
const HEMOGLOBINA_GLICADA = 10;
|
||||
const HEMOGRAMA = 11;
|
||||
const LDL = 12;
|
||||
const RETINOGRAFIA_FUNDO_DE_OLHO_COM_OFTALMOLOGISTA = 13;
|
||||
const SOROLOGIA_DE_SIFILIS = 14;
|
||||
const SOROLOGIA_PARA_DENGUE = 15;
|
||||
const SOROLOGIA_PARA_HIV = 16;
|
||||
const TESTE_INDIRETO_DE_ANTIGLOBULINA_HUMANA = 17;
|
||||
const TESTE_DE_GRAVIDEZ = 18;
|
||||
const ULTRASSONOGRAFIA_OBSTETRICA = 19;
|
||||
const UROCULTURA = 20;
|
||||
const ANTIBIOGRAMA = 21;
|
||||
const HEPATITE_B = 22;
|
||||
const HEPATITE_C = 23;
|
||||
const FATOR_RH = 24;
|
||||
const GRUPO_ABO = 25;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class LocalAtendimento
|
||||
{
|
||||
const UBS = 1;
|
||||
const UNIDADE_MOVEL = 2;
|
||||
const RUA = 3;
|
||||
const DOMICILIO = 4;
|
||||
const ESCOLA_CRECHE = 5;
|
||||
const OUTROS = 6;
|
||||
const POLO = 7;
|
||||
const INSTITUICAO = 8;
|
||||
const UNIDADE_PRISIONAL_CONGENERES = 9;
|
||||
const UNIDADE_SOCIOEDUCATIVA = 10;
|
||||
const HOSPITAL = 11;
|
||||
const UNIDADE_PRONTO_ATENDIMENTO = 12;
|
||||
const CACON_UNACON = 13;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class ModalidadeAtencaoDomiciliar
|
||||
{
|
||||
const AD_1 = 1;
|
||||
const AD_2 = 2;
|
||||
const AD_3 = 3;
|
||||
const INELEGIVEL = 4;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class Rastreamento
|
||||
{
|
||||
const CANCER_MAMA = 1;
|
||||
const CANCER_COLO_UTERO = 2;
|
||||
const RISCO_CARDIOVASCULAR = 3;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class RastreamentoCodigoEsus
|
||||
{
|
||||
const CANCER_MAMA = 'ABP023';
|
||||
const CANCER_COLO_UTERO = 'ABP022';
|
||||
const RISCO_CARDIOVASCULAR = 'ABP024';
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoIndividual;
|
||||
|
||||
class TipoAtendimento
|
||||
{
|
||||
const CONSULTA_AGENDADA_PROGRAMADA = 1;
|
||||
const CONSULTA_AGENDADA = 2;
|
||||
const ESCUTA_INICIAL_ORIENTACAO = 3;
|
||||
const CONSULTA_NO_DIA = 4;
|
||||
const ATENDIMENTO_DE_URGENCIA = 5;
|
||||
const ATENDIMENTO_PROGRAMADO = 6;
|
||||
const ATENDIMENTO_NAO_PROGRAMADO = 7;
|
||||
const VISITA_DOMICILIAR_POS_OBITO = 8;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AtencaoBasica\AtendimentoOdontologico;
|
||||
|
||||
class CondutaEncaminhamento
|
||||
{
|
||||
const ATENDIMENTO_PACIENTES_NECESSIDADES_ESPECIAIS = 1;
|
||||
const CIRURGIA_BMF = 2;
|
||||
const ENDODONTIA = 3;
|
||||
const ESTOMATOLOGIA = 4;
|
||||
const IMPLANTODONTIA = 5;
|
||||
const ODONTOPEDIATRIA = 6;
|
||||
const ORTODONTIA_ORTOPEDIA = 7;
|
||||
const PERIDONTIA = 8;
|
||||
const PROTESE_DENTARIA = 9;
|
||||
const RADIOLOGIA = 10;
|
||||
const OUTROS = 11;
|
||||
const AGENDAMENTO_OUTROS_PROFISSIONAIS = 12;
|
||||
const AGENDAMENTO_NASF = 13;
|
||||
const AGENDAMENTO_GRUPOS = 14;
|
||||
const TRATAMENTO_CONCLUIDO= 15;
|
||||
const RETORNO_CONSULTA_AGENDADA = 16;
|
||||
const ALTA_EPISODIO = 17;
|
||||
const AGENDAMENTO_PARA_E_MULTI = 18;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user