This commit is contained in:
33
api/app/Http/Requests/Administracao/LotacaoRequest.php
Normal file
33
api/app/Http/Requests/Administracao/LotacaoRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Administracao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class LotacaoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'papeis' => [],
|
||||
'permissoes' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
55
api/app/Http/Requests/Administracao/PapelRequest.php
Normal file
55
api/app/Http/Requests/Administracao/PapelRequest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Administracao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PapelRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST':
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,180',
|
||||
Rule::unique('\App\Models\Administracao\Papel')->where(function ($query) {
|
||||
return $query->whereNull('deleted_at');
|
||||
})->ignore($this->papel),
|
||||
],
|
||||
'permissoes' => [
|
||||
'present',
|
||||
'array',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'O nome do Papel já foi inserido anteriormente.',
|
||||
];
|
||||
}
|
||||
}
|
||||
43
api/app/Http/Requests/Administracao/PermissaoRequest.php
Normal file
43
api/app/Http/Requests/Administracao/PermissaoRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Administracao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PermissaoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'papeis' => [
|
||||
'present',
|
||||
'array',
|
||||
],
|
||||
'permissoes' => [
|
||||
'present',
|
||||
'array',
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
33
api/app/Http/Requests/Autenticacao/LoginRequest.php
Normal file
33
api/app/Http/Requests/Autenticacao/LoginRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Autenticacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'usuario' => ['required', 'min:5', 'max:12', 'unique:login'],
|
||||
'email' => ['required', 'email:rfc,dns', 'max:180', 'unique:login']
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Autenticacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Rules\Cpf;
|
||||
|
||||
class RecuperacaoSenhaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'email' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:5,180',
|
||||
'regex:/(.+)@(.+)\.(.+)/i',
|
||||
],
|
||||
'cpf' => [
|
||||
'required',
|
||||
'digits:11',
|
||||
new Cpf,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
42
api/app/Http/Requests/Autenticacao/TrocaSenhaRequest.php
Normal file
42
api/app/Http/Requests/Autenticacao/TrocaSenhaRequest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Autenticacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Rules\SenhaAntiga;
|
||||
use App\Rules\SenhaAtual;
|
||||
|
||||
class TrocaSenhaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'nova_senha' => [
|
||||
'required',
|
||||
'min:8',
|
||||
'max:100',
|
||||
'regex:/^(?=.*\d)(?=.*[a-zA-Z]).{8,}$/',
|
||||
new SenhaAtual($this->id),
|
||||
new SenhaAntiga($this->id),
|
||||
'confirmed',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
50
api/app/Http/Requests/AvisoRequest.php
Normal file
50
api/app/Http/Requests/AvisoRequest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AvisoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'mensagem' => 'required|string|max:140',
|
||||
'is_ativo' => 'required|boolean',
|
||||
'periodo.start' => 'required|date',
|
||||
'periodo.end' => 'required|date|after_or_equal:periodo.start',
|
||||
'dias_semana' => 'array',
|
||||
'hora_inicial' => 'required|date_format:H:i:s',
|
||||
'hora_final' => 'required|date_format:H:i:s|after:hora_inicial',
|
||||
'intervalo' => 'required|integer|in:15,30,60,120,180,240',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'mensagem.required' => 'A mensagem é obrigatória.',
|
||||
'is_ativo.required' => 'O campo "Ativo" é obrigatório.',
|
||||
'periodo.start.required' => 'A data inicial é obrigatória.',
|
||||
'periodo.end.after_or_equal' => 'A data final deve ser posterior ou igual à data inicial.',
|
||||
'hora_inicial.required' => 'A hora inicial é obrigatória.',
|
||||
'hora_final.required' => 'A hora final é obrigatória e deve ser após a hora inicial.',
|
||||
'intervalo.in' => 'O intervalo deve ser de 15, 30, 60, 120, 180, 240 minutos.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class SalaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST':
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,30',
|
||||
Rule::unique('\App\Models\Cadastro\Estabelecimento\Sala', 'nome')
|
||||
->where(function ($query) {
|
||||
|
||||
return $query
|
||||
->where('centro_custo_id', $this->centro_custo_id)
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
->ignore($this->sala)
|
||||
],
|
||||
'centro_custo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'O nome da Sala já foi inserido anteriormente.'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class SetorRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'tipo_id' => ['required'],
|
||||
'servico_id' => ['required', 'integer'],
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,180',
|
||||
Rule::unique('\App\Models\Cadastro\Estabelecimento\Setor')->where(function ($query) {
|
||||
return $query
|
||||
->where('servico_id', $this->servico_id)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'tipo_id' => ['required'],
|
||||
'servico_id' => ['required', 'integer'],
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,180',
|
||||
Rule::unique('\App\Models\Cadastro\Estabelecimento\Setor')->where(function ($query) {
|
||||
return $query
|
||||
->where('servico_id', $this->servico_id)
|
||||
->whereNull('deleted_at');
|
||||
})->ignore($this->setor),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'Um Setor com o mesmo Serviço e Nome já foi inserido anteriormente.'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Rules\CnsTermoValido;
|
||||
|
||||
class UnidadeExternaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$regex = '/[^a-zA-Z0-9áéíóúâêîôûãõäëïöüÁÉÍÓÚÂÊÎÔÛÃÕÄËÏÖÜ\'()\/,\s-]/';
|
||||
|
||||
return [
|
||||
'nome_fantasia' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,255',
|
||||
'not_regex:' . $regex,
|
||||
new CnsTermoValido(['attribute' => 'Nome Fantasia'])
|
||||
],
|
||||
'municipio_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Intranet\Municipio,id'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,348 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Rules\CnsTermoValido;
|
||||
use App\Rules\Cnpj;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Utils\ImportacaoCns;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UnidadeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'nome_fantasia' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,255',
|
||||
'unique:\App\Models\Cadastro\Estabelecimento\Unidade,nome_fantasia,NULL,id,deleted_at,NULL'
|
||||
],
|
||||
'razao_social' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,255',
|
||||
],
|
||||
'cnpj' => [
|
||||
'nullable',
|
||||
'digits:14',
|
||||
new Cnpj(['attribute' => 'CNPJ']),
|
||||
],
|
||||
'tipo_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'esfera_administrativa_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'natureza_juridica_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'pertence_sus' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'unidade_referencia' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'unidade_prestadora' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'gestor_id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
'cnes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:7,7',
|
||||
],
|
||||
'email' => [
|
||||
'nullable',
|
||||
'email:rfc,dns',
|
||||
'max:180'
|
||||
],
|
||||
'site' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:180'
|
||||
],
|
||||
'infraestruturas' => [
|
||||
'required',
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.infraestrutura_id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
'infraestruturas.*.principal' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'infraestruturas.*.nome' => [
|
||||
'nullable',
|
||||
'required_if:infraestruturas.*.principal,0',
|
||||
'string',
|
||||
'between:3,255',
|
||||
],
|
||||
'infraestruturas.*.telefone' => [
|
||||
'required',
|
||||
'digits_between:10,11'
|
||||
],
|
||||
'infraestruturas.*.endereco' => [
|
||||
'required',
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.endereco.logradouro_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'infraestruturas.*.endereco.numero' => [
|
||||
'nullable',
|
||||
'digits_between:1,6',
|
||||
],
|
||||
'infraestruturas.*.endereco.complemento' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Complemento'])
|
||||
],
|
||||
'infraestruturas.*.endereco.zona_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'infraestruturas.*.centros_custo' => [
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.centros_custo.*.setor_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'infraestruturas.*.centros_custo.*.salas' => [
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.centros_custo.*.salas.*.nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,30',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
$custom = [];
|
||||
|
||||
if (is_array($this->infraestruturas)) {
|
||||
|
||||
foreach ($this->infraestruturas as $i => $infraestrutura) {
|
||||
|
||||
if (isset($infraestrutura['centros_custo'])) {
|
||||
|
||||
foreach ($infraestrutura['centros_custo'] as $j => $centroCusto) {
|
||||
|
||||
$custom["infraestruturas.{$i}.centros_custo.{$j}.setor_id"] = [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::unique('\App\Models\Cadastro\Estabelecimento\CentroCusto', 'setor_id')
|
||||
->where(function ($query) use ($infraestrutura) {
|
||||
|
||||
return $query
|
||||
->where('infraestrutura_id', $infraestrutura['id'] ?? null)
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
->ignore($centroCusto['id'] ?? null)
|
||||
];
|
||||
|
||||
if (isset($centroCusto['salas'])) {
|
||||
|
||||
foreach ($centroCusto['salas'] as $k => $sala) {
|
||||
|
||||
$custom["infraestruturas.{$i}.centros_custo.{$j}.salas.{$k}.nome"] = [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,30',
|
||||
Rule::unique('\App\Models\Cadastro\Estabelecimento\Sala', 'nome')
|
||||
->where(function ($query) use ($centroCusto) {
|
||||
|
||||
return $query
|
||||
->where('centro_custo_id', $centroCusto['id'] ?? null)
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
->ignore($sala['id'] ?? null)
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge([
|
||||
'nome_fantasia' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,255',
|
||||
"unique:\App\Models\Cadastro\Estabelecimento\Unidade,nome_fantasia,{$this->unidade},id,deleted_at,NULL"
|
||||
],
|
||||
'razao_social' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,255',
|
||||
],
|
||||
'cnpj' => [
|
||||
'nullable',
|
||||
'digits:14',
|
||||
new Cnpj(['attribute' => 'CNPJ']),
|
||||
],
|
||||
'tipo_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'esfera_administrativa_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'natureza_juridica_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'pertence_sus' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'unidade_referencia' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'unidade_prestadora' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'gestor_id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
'cnes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:7,7',
|
||||
],
|
||||
'email' => [
|
||||
'nullable',
|
||||
'email:rfc,dns',
|
||||
'max:180'
|
||||
],
|
||||
'site' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:180'
|
||||
],
|
||||
'infraestruturas' => [
|
||||
'required',
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
'infraestruturas.*.principal' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'infraestruturas.*.nome' => [
|
||||
'nullable',
|
||||
'required_if:infraestruturas.*.principal,0',
|
||||
'string',
|
||||
'between:3,255',
|
||||
],
|
||||
'infraestruturas.*.telefone' => [
|
||||
'required',
|
||||
'digits_between:10,11'
|
||||
],
|
||||
'infraestruturas.*.endereco' => [
|
||||
'required',
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.endereco.logradouro_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'infraestruturas.*.endereco.numero' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'max:999999',
|
||||
],
|
||||
'infraestruturas.*.endereco.complemento' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Complemento'])
|
||||
],
|
||||
'infraestruturas.*.endereco.zona_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'infraestruturas.*.centros_custo' => [
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.centros_custo.*.id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
'infraestruturas.*.centros_custo.*.salas' => [
|
||||
'array'
|
||||
],
|
||||
'infraestruturas.*.centros_custo.*.salas.*.id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
]
|
||||
], $custom);
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome_fantasia.unique' => 'Já existe uma unidade com o Nome fantasia informado.',
|
||||
];
|
||||
}
|
||||
}
|
||||
63
api/app/Http/Requests/Cadastro/Localizacao/BairroRequest.php
Normal file
63
api/app/Http/Requests/Cadastro/Localizacao/BairroRequest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Localizacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class BairroRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,180',
|
||||
'unique:\App\Models\Cadastro\Localizacao\Bairro,nome,NULL,id,deleted_at,NULL',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,180',
|
||||
"unique:\App\Models\Cadastro\Localizacao\Bairro,nome,{$this->bairro},id,deleted_at,NULL",
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'O nome do Bairro já foi inserido anteriormente.'
|
||||
];
|
||||
}
|
||||
}
|
||||
148
api/app/Http/Requests/Cadastro/Localizacao/LogradouroRequest.php
Normal file
148
api/app/Http/Requests/Cadastro/Localizacao/LogradouroRequest.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Localizacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Rules\CnsTermoValido;
|
||||
use App\Utils\DataUtil;
|
||||
use App\Utils\ImportacaoCns;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class LogradouroRequest extends FormRequest
|
||||
{
|
||||
private $regexCep = '/[^0-9]/';
|
||||
private $tamanhoNome = '3,250';
|
||||
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'logradouro_nome' => html_entity_decode($this->logradouro_nome, ENT_QUOTES, 'UTF-8'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
if (DataUtil::getBooleanValueFromStringBoolean($this->search_by_base_endereco_nacional) === true) {
|
||||
$rules = [
|
||||
'municipio_id' => ['required', 'integer'],
|
||||
'logradouro_nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:' . $this->tamanhoNome,
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Nome']),
|
||||
],
|
||||
'logradouro_cep' => [
|
||||
'required',
|
||||
'not_regex:' . $this->regexCep,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$rules = [
|
||||
'municipio_id' => ['required', 'integer'],
|
||||
'bairro_id' => ['required', 'integer'],
|
||||
'tipo_id' => ['required', 'integer'],
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:' . $this->tamanhoNome,
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Nome']),
|
||||
Rule::unique('\App\Models\Cadastro\Localizacao\Logradouro')->where(function ($query) {
|
||||
|
||||
return $query
|
||||
->where('municipio_id', $this->municipio_id)
|
||||
->where('bairro_id', $this->bairro_id)
|
||||
->where('tipo_id', $this->tipo_id)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'cep' => [
|
||||
'required',
|
||||
'not_regex:' . $this->regexCep,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
if (DataUtil::getBooleanValueFromStringBoolean($this->search_by_base_endereco_nacional) === true) {
|
||||
$rules = [
|
||||
'municipio_id' => ['required', 'integer'],
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:' . $this->tamanhoNome,
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Nome']),
|
||||
],
|
||||
'cep' => [
|
||||
'required',
|
||||
'not_regex:' . $this->regexCep,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
|
||||
$rules = [
|
||||
'municipio_id' => ['required', 'integer'],
|
||||
'bairro_id' => ['required', 'integer'],
|
||||
'tipo_id' => ['required', 'integer'],
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:' . $this->tamanhoNome,
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Nome']),
|
||||
Rule::unique('\App\Models\Cadastro\Localizacao\Logradouro')->where(function ($query) {
|
||||
|
||||
return $query
|
||||
->where('municipio_id', $this->municipio_id)
|
||||
->where('bairro_id', $this->bairro_id)
|
||||
->where('tipo_id', $this->tipo_id)
|
||||
->whereNull('deleted_at');
|
||||
})->ignore($this->logradouro)
|
||||
],
|
||||
'cep' => [
|
||||
'required',
|
||||
'not_regex:' . $this->regexCep,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'Um Logradouro com o mesmo Tipo, Bairro, Município e Nome já foi inserido anteriormente.'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Localizacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class LoteamentoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:1,100',
|
||||
'unique:\App\Models\Cadastro\Localizacao\Loteamento,nome,NULL,id,deleted_at,NULL',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:1,100',
|
||||
"unique:\App\Models\Cadastro\Localizacao\Loteamento,nome,{$this->loteamento},id,deleted_at,NULL",
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'O nome do Loteamento já foi inserido anteriormente.'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\Medicamento;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\Cadastro\Medicamento\Medicamento;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class MedicamentoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST':
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostPutRules()
|
||||
{
|
||||
|
||||
return [
|
||||
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
Rule::unique(Medicamento::class)->ignore($this->medicamento)
|
||||
],
|
||||
'receita_tipo_id' => ['required', 'integer'],
|
||||
'unidade_medida_id' => ['required', 'integer'],
|
||||
'forma_farmaceutica_id' => ['required', 'integer'],
|
||||
'via_administracao_id' => ['required', 'integer'],
|
||||
'exibir_receita' => ['boolean'],
|
||||
'exibir_prescricao_interna' => ['boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'Este medicamento já foi cadastrado!'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class AlergiaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostPutRules();
|
||||
case 'PUT':
|
||||
return $this->getPostPutRules();
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostPutRules()
|
||||
{
|
||||
return [
|
||||
'tipo_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'agente_substancia_especifica' => [
|
||||
'required',
|
||||
'string',
|
||||
'min:3',
|
||||
'max:100',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\Alergia,agente_substancia_especifica,'
|
||||
. ($this->alergia ?? 'NULL') . ',id,deleted_at,NULL',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'agente_substancia_especifica.unique' =>
|
||||
'O agente / substância específica da Alergia já foi inserido anteriormente.'
|
||||
];
|
||||
}
|
||||
}
|
||||
677
api/app/Http/Requests/Cadastro/SujeitoAtencao/CidadaoRequest.php
Normal file
677
api/app/Http/Requests/Cadastro/SujeitoAtencao/CidadaoRequest.php
Normal file
@@ -0,0 +1,677 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Enums\Cadastro\SujeitoAtencao\Deficiencia;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\EstadoCivil;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\FatorRisco;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\LocalNascimento;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\ModeloCertidao;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\MotivoDuplicidadeCpf;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\Nacionalidade;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\RacaCor;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\Cadastro\Parametrizacao\Parametrizacao;
|
||||
use App\Models\Cadastro\Parametrizacao\ParametrizacaoPermissaoOcupacao;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Rules\Cns;
|
||||
use App\Rules\CnsTermoValido;
|
||||
use App\Rules\Cpf;
|
||||
use App\Rules\CpfDuplication;
|
||||
use App\Rules\NisPisPasep;
|
||||
use App\Rules\NomeCompleto;
|
||||
use App\Utils\ImportacaoCns;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CidadaoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getPostPutRules($instance)
|
||||
{
|
||||
$parametrizcao = Parametrizacao::first();
|
||||
$exigeCnsPaciente = $parametrizcao->exige_cns_paciente ?? true;
|
||||
$exigeCpfPaciente = $parametrizcao->exige_cpf_paciente ?? true;
|
||||
|
||||
$rules = [
|
||||
'cidadao' => [
|
||||
'array',
|
||||
'required',
|
||||
],
|
||||
'cidadao.cadastro_simplificado' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.sem_documentos' => [
|
||||
'required_if:cidadao.cadastro_simplificado,true',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.cns' => [
|
||||
'nullable',
|
||||
Rule::requiredIf(function () use ($exigeCnsPaciente, $instance) {
|
||||
if (isset($instance->origem) && $instance->origem === 'cadastroPaciente' && isset($instance->cidadao['dnv'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($instance->cidadao['cadastro_simplificado']) && $instance->cidadao['cadastro_simplificado'] === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $exigeCnsPaciente;
|
||||
}),
|
||||
'digits:15',
|
||||
new Cns,
|
||||
fn($attr, $value, $fail) => \DB::table('cadastro_cidadao as c')
|
||||
->join('cadastro_paciente as p', 'p.cidadao_id', '=', 'c.id')
|
||||
->where('c.cns', $value)
|
||||
->whereNull('c.deleted_at')
|
||||
->whereNull('p.deleted_at')
|
||||
->when($instance->cidadao['id'] ?? null, fn($q) => $q->where('c.id', '!=', $instance->cidadao['id']))
|
||||
->exists() && $fail('O CNS já está vinculado a outro cidadão.'),
|
||||
],
|
||||
'cidadao.cpf' => [
|
||||
'nullable',
|
||||
Rule::requiredIf(function () use ($exigeCpfPaciente, $instance) {
|
||||
if (isset($instance->origem) && $instance->origem === 'cadastroPaciente' && isset($instance->cidadao['dnv'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($exigeCpfPaciente) {
|
||||
return !(isset($instance->cidadao['sem_documentos']) && $instance->cidadao['sem_documentos']);
|
||||
}
|
||||
|
||||
return false;
|
||||
}),
|
||||
'digits:11',
|
||||
new Cpf,
|
||||
new CpfDuplication($instance->cidadao),
|
||||
],
|
||||
'cidadao.cpf_nao_pertence_ao_cidadao' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.cadastro_simplificado,false',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.motivo_duplicidade_cpf_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'required_if:cidadao.cpf_nao_pertence_ao_cidadao,true',
|
||||
],
|
||||
'cidadao.motivo_duplicidade_cpf_outro' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.motivo_duplicidade_cpf_id,' . MotivoDuplicidadeCpf::OUTRO,
|
||||
'string',
|
||||
'between:3,50',
|
||||
],
|
||||
'cidadao.dnv' => [
|
||||
'nullable',
|
||||
'digits:11',
|
||||
fn($attr, $value, $fail) => \DB::table('cadastro_cidadao as c')
|
||||
->join('cadastro_paciente as p', 'p.cidadao_id', '=', 'c.id')
|
||||
->where('c.dnv', $value)
|
||||
->whereNull('c.deleted_at')
|
||||
->whereNull('p.deleted_at')
|
||||
->when($instance->cidadao['id'] ?? null, fn($q) => $q->where('c.id', '!=', $instance->cidadao['id']))
|
||||
->exists() && $fail('O DNV já está vinculado a outro cidadão.'),
|
||||
],
|
||||
'cidadao.nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:6,150',
|
||||
new CnsTermoValido(['attribute' => 'Nome']),
|
||||
($instance['cidadao']['cadastro_simplificado'] ?? null) === true
|
||||
? null
|
||||
: new NomeCompleto,
|
||||
],
|
||||
'cidadao.nome_social' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,150',
|
||||
new CnsTermoValido(['attribute' => 'Nome social']),
|
||||
],
|
||||
'cidadao.preferencia_nome_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.data_nascimento' => [
|
||||
'nullable',
|
||||
'date_format:Y-m-d',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.sexo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.estado_civil_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.conjuge' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.estado_civil_id,' . EstadoCivil::CASADO,
|
||||
'string',
|
||||
'between:8,150',
|
||||
new NomeCompleto,
|
||||
],
|
||||
'cidadao.situacao_familiar_conjugal_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.raca_cor_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.etnia_indigena_id' => [
|
||||
'nullable',
|
||||
Rule::requiredIf(function () use ($instance) {
|
||||
|
||||
return ($instance->cidadao['raca_cor_id'] ?? null) === RacaCor::INDIGENA
|
||||
&& ($instance->cidadao['nacionalidade_id'] ?? null) === Nacionalidade::BRASILEIRO;
|
||||
}),
|
||||
'integer'
|
||||
],
|
||||
'cidadao.tipo_sanguineo_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.deficiencia_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.deficiencia_outro' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.deficiencia_id,' . Deficiencia::OUTRA,
|
||||
'string',
|
||||
'between:3,50',
|
||||
],
|
||||
'cidadao.mobilidade_reduzida_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.desconhece_nome_mae' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.desconhece_nome_pai' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.nome_mae' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.desconhece_nome_mae,false',
|
||||
'string',
|
||||
'between:8,150',
|
||||
new CnsTermoValido(['attribute' => 'Nome da mãe']),
|
||||
new NomeCompleto,
|
||||
],
|
||||
'cidadao.nome_pai' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.desconhece_nome_pai,false',
|
||||
'between:8,150',
|
||||
new CnsTermoValido(['attribute' => 'Nome do pai']),
|
||||
new NomeCompleto,
|
||||
],
|
||||
'cidadao.local_nascimento_id' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.cadastro_simplificado,false',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.pais_nascimento_id' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.cadastro_simplificado,false',
|
||||
],
|
||||
'cidadao.nacionalidade_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.data_naturalizacao' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.nacionalidade_id,' . Nacionalidade::NATURALIZADO_BRASILEIRO,
|
||||
'exclude_unless:cidadao.nacionalidade_id,' . Nacionalidade::NATURALIZADO_BRASILEIRO,
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.data_nascimento',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.portaria_naturalizacao' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.nacionalidade_id,' . Nacionalidade::NATURALIZADO_BRASILEIRO,
|
||||
'exclude_unless:cidadao.nacionalidade_id,' . Nacionalidade::NATURALIZADO_BRASILEIRO,
|
||||
'string',
|
||||
'size:16',
|
||||
],
|
||||
'cidadao.estado_nascimento_id' => [
|
||||
'nullable',
|
||||
Rule::requiredIf(function () use ($instance) {
|
||||
|
||||
return !($instance['cidadao']['cadastro_simplificado'] ?? null)
|
||||
&& ($instance['cidadao']['local_nascimento_id'] ?? null) !== LocalNascimento::EM_OUTRO_PAIS;
|
||||
})
|
||||
],
|
||||
'cidadao.municipio_nascimento_id' => [
|
||||
'nullable',
|
||||
Rule::requiredIf(function () use ($instance) {
|
||||
|
||||
return !($instance['cidadao']['cadastro_simplificado'] ?? null)
|
||||
&& ($instance['cidadao']['local_nascimento_id'] ?? null) !== LocalNascimento::EM_OUTRO_PAIS;
|
||||
})
|
||||
],
|
||||
'cidadao.frequenta_escola' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.cadastro_simplificado,false',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.escolaridade_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.telefones' => [
|
||||
'array',
|
||||
'nullable',
|
||||
function ($attribute, $value, $fail) {
|
||||
|
||||
if (empty($value)) return;
|
||||
|
||||
$hasPrincipal = false;
|
||||
|
||||
foreach (($value ?? []) as $telefone) {
|
||||
|
||||
if (($telefone['principal'] ?? null) === true) {
|
||||
|
||||
if ($hasPrincipal) {
|
||||
|
||||
$fail('Somente um telefone pode ser marcado como principal');
|
||||
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
||||
$hasPrincipal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasPrincipal) {
|
||||
|
||||
$fail('Obrigatório marcar um telefone como principal.');
|
||||
}
|
||||
},
|
||||
],
|
||||
'cidadao.telefones.*.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.telefones.*.numero' => [
|
||||
'required',
|
||||
'digits_between:10,11',
|
||||
],
|
||||
'cidadao.telefones.*.observacao' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:50',
|
||||
],
|
||||
'cidadao.telefones.*.autoriza_sms' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.telefones.*.principal' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'cidadao.convenios_medicos' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.convenios_medicos.*' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.data_entrada_domicilio' => [
|
||||
'nullable',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.data_nascimento',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.domicilio' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos.carteira_identidade' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos.carteira_identidade.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.carteira_identidade.numero' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:6,15',
|
||||
Rule::unique('\App\Models\Cadastro\SujeitoAtencao\CarteiraIdentidade', 'numero')->where(function ($query) use ($instance) {
|
||||
return $query->where('cidadao_id', '!=', $instance->cidadao['id'])
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
],
|
||||
'cidadao.documentos.carteira_identidade.estado_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.carteira_identidade.orgao_emissor' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:5,8',
|
||||
],
|
||||
'cidadao.documentos.carteira_identidade.data_emissao' => [
|
||||
'nullable',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.data_nascimento',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.documentos.carteira_nacional_habilitacao' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos.carteira_nacional_habilitacao.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.carteira_nacional_habilitacao.numero' => [
|
||||
'nullable',
|
||||
'digits:11',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\CarteiraHabilitacao,numero,'
|
||||
. (($instance->cidadao['documentos']['carteira_nacional_habilitacao']['id'] ?? null) ?? 'NULL')
|
||||
. ',id,deleted_at,NULL',
|
||||
],
|
||||
'cidadao.documentos.carteira_nacional_habilitacao.data_emissao' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_nacional_habilitacao.numero',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.data_nascimento',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.documentos.carteira_nacional_habilitacao.data_validade' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_nacional_habilitacao.numero',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.documentos.carteira_nacional_habilitacao.data_emissao',
|
||||
],
|
||||
'cidadao.documentos.carteira_nacional_habilitacao.estado_id' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_nacional_habilitacao.numero',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.carteira_nacional_habilitacao.categoria_id' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_nacional_habilitacao.numero',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.carteira_trabalho' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos.carteira_trabalho.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.carteira_trabalho.numero' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:7,16',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\CarteiraTrabalho,numero,'
|
||||
. (($instance->cidadao['documentos']['carteira_trabalho']['id'] ?? null) ?? 'NULL')
|
||||
. ',id,deleted_at,NULL',
|
||||
],
|
||||
'cidadao.documentos.carteira_trabalho.serie' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_trabalho.numero',
|
||||
'string',
|
||||
'size:5'
|
||||
],
|
||||
'cidadao.documentos.carteira_trabalho.data_emissao' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_trabalho.numero',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.data_nascimento',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.documentos.carteira_trabalho.estado_id' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_trabalho.numero',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.carteira_trabalho.nis_pis_pasep' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.carteira_trabalho.numero',
|
||||
'digits:11',
|
||||
new NisPisPasep
|
||||
],
|
||||
'cidadao.documentos.estrangeiro_entrada_brasil' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos.estrangeiro_entrada_brasil.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.estrangeiro_entrada_brasil.rne' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:20',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\EstrangeiroEntradaBrasil,rne,'
|
||||
. (($instance->cidadao['documentos']['estrangeiro_entrada_brasil']['id'] ?? null) ?? 'NULL')
|
||||
. ',id,deleted_at,NULL',
|
||||
],
|
||||
'cidadao.documentos.estrangeiro_entrada_brasil.data_entrada' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.estrangeiro__brasil.rne',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.data_nascimento',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.documentos.titulo_eleitor' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos.titulo_eleitor.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.titulo_eleitor.numero' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:9,13',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\TituloEleitor,numero,'
|
||||
. (($instance->cidadao['documentos']['titulo_eleitor']['id'] ?? null) ?? 'NULL')
|
||||
. ',id,deleted_at,NULL',
|
||||
],
|
||||
'cidadao.documentos.titulo_eleitor.zona' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'required_with:cidadao.documentos.titulo_eleitor.numero',
|
||||
'size:4'
|
||||
],
|
||||
'cidadao.documentos.titulo_eleitor.secao' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'required_with:cidadao.documentos.titulo_eleitor.numero',
|
||||
'size:4'
|
||||
],
|
||||
'cidadao.documentos.certidao' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.documentos.certidao.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.certidao.tipo_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.certidao.modelo_id' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.certidao.tipo_id',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.certidao.numero' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.documentos.certidao.tipo_id',
|
||||
(($instance->cidadao['documentos']['certidao']['modelo_id'] ?? null) === ModeloCertidao::ANTIGO
|
||||
? 'between:8,40' : 'digits:32'),
|
||||
Rule::unique('\App\Models\Cadastro\SujeitoAtencao\Certidao', 'numero')
|
||||
->where(function ($query) use ($instance) {
|
||||
|
||||
return $query
|
||||
->where('tipo_id', $instance->cidadao['documentos']['certidao']['tipo_id'] ?? null)
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
->ignore($instance->cidadao['documentos']['certidao']['id'] ?? null)
|
||||
],
|
||||
'cidadao.documentos.certidao.cartorio_nome' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.documentos.certidao.modelo_id,' . ModeloCertidao::ANTIGO,
|
||||
'string',
|
||||
'max:70',
|
||||
],
|
||||
'cidadao.documentos.certidao.livro' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.documentos.certidao.modelo_id,' . ModeloCertidao::ANTIGO,
|
||||
'string',
|
||||
'max:8'
|
||||
],
|
||||
'cidadao.documentos.certidao.folha' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.documentos.certidao.modelo_id,' . ModeloCertidao::ANTIGO,
|
||||
'string',
|
||||
'between:4,10'
|
||||
],
|
||||
'cidadao.documentos.certidao.data_emissao' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.documentos.certidao.modelo_id,' . ModeloCertidao::ANTIGO,
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:cidadao.data_nascimento',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'cidadao.documentos.certidao.municipio_id' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.documentos.certidao.modelo_id,' . ModeloCertidao::ANTIGO,
|
||||
'integer',
|
||||
],
|
||||
'cidadao.documentos.certidao.cartorio_codigo' => [
|
||||
'nullable',
|
||||
'required_if:cidadao.documentos.certidao.modelo_id,' . ModeloCertidao::ANTIGO,
|
||||
'string',
|
||||
'size:15',
|
||||
],
|
||||
'cidadao.fatores_risco' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.fatores_risco.*' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.fator_risco_outro' => [
|
||||
'nullable',
|
||||
Rule::requiredIf(fn () => in_array(FatorRisco::OUTRO, $instance->cidadao['fatores_risco'] ?? [])),
|
||||
'string',
|
||||
'max:100',
|
||||
],
|
||||
'cidadao.documentos.outro.protocolo_cross' => [
|
||||
'nullable',
|
||||
'digits_between:1,10',
|
||||
],
|
||||
];
|
||||
|
||||
$rulesEndereco = [
|
||||
'cidadao.domicilio.endereco' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'cidadao.domicilio.endereco.logradouro_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.domicilio.endereco.numero' => [
|
||||
'nullable',
|
||||
'digits_between:1,6',
|
||||
],
|
||||
'cidadao.domicilio.endereco.complemento' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,180',
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Complemento']),
|
||||
],
|
||||
'cidadao.domicilio.endereco.referencia' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:150',
|
||||
'not_regex:' . ImportacaoCns::regexValidacao(),
|
||||
new CnsTermoValido(['attribute' => 'Referência']),
|
||||
],
|
||||
'cidadao.domicilio.endereco.loteamento_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.domicilio.endereco.zona_id' => [
|
||||
'nullable',
|
||||
'required_with:cidadao.domicilio.endereco.logradouro_id',
|
||||
'integer',
|
||||
],
|
||||
'cidadao.domicilio.endereco.latitude' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'size:10',
|
||||
],
|
||||
'cidadao.domicilio.endereco.longitude' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'size:10',
|
||||
],
|
||||
];
|
||||
|
||||
if (empty($params['id']) || !empty($params['id']) && self::hasPermission()) {
|
||||
$rules = array_merge($rules, $rulesEndereco);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public static function hasPermission() {
|
||||
|
||||
$lotacao = Lotacao::findOrFail(auth()->payload()->get('lotacao_id'));
|
||||
$count = ParametrizacaoPermissaoOcupacao::count();
|
||||
|
||||
return ParametrizacaoPermissaoOcupacao::where('ocupacao_id', $lotacao->ocupacao_id)->exists() || $count === 0;
|
||||
}
|
||||
|
||||
public static function getMessages()
|
||||
{
|
||||
return [
|
||||
'cidadao.documentos.titulo_eleitor.numero.unique' =>
|
||||
'O número do Titulo de eleitor já está vinculado a outro cidadão.',
|
||||
'cidadao.documentos.carteira_identidade.numero.unique' =>
|
||||
'O número da Carteira de identidade já está vinculado a outro cidadão.',
|
||||
'cidadao.documentos.carteira_trabalho.numero.unique' =>
|
||||
'O número da Carteira de trabalho (CTPS) já está vinculado a outro cidadão.',
|
||||
'cidadao.documentos.carteira_nacional_habilitacao.numero.unique' =>
|
||||
'O número da Carteira nacional de habilitação (CNH) já está vinculado a outro cidadão.',
|
||||
'cidadao.documentos.estrangeiro_entrada_brasil.rne.unique' =>
|
||||
'O número do RNE já está vinculado a outro cidadão.',
|
||||
'cidadao.documentos.certidao.numero.unique' =>
|
||||
'O número da Certidão já está vinculado a outro cidadão.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class ConvenioMedicoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:1,50',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\ConvenioMedico,nome,NULL,id,deleted_at,NULL',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:1,50',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\ConvenioMedico'
|
||||
. ",nome,{$this->convenio_medico},id,deleted_at,NULL",
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'O nome do Convênio Médico já foi inserido anteriormente.'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class PacienteRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostPutRules()
|
||||
{
|
||||
$cidadaoRules = array_merge([
|
||||
'cidadao.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\Paciente,cidadao_id,'
|
||||
. ($this->route('paciente') ?? 'NULL') . ',id,deleted_at,NULL',
|
||||
],
|
||||
], CidadaoRequest::getPostPutRules($this));
|
||||
|
||||
$rules = array_merge($cidadaoRules, [
|
||||
'cadastro_simplificado' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'sem_documentos_em' => [
|
||||
'nullable',
|
||||
'date'
|
||||
],
|
||||
'email' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:5,100',
|
||||
'regex:/(.+)@(.+)\.(.+)/i',
|
||||
],
|
||||
'classificacao_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'subclassificacao_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'validade_inicio' => [
|
||||
'nullable',
|
||||
'date_format:Y-m-d',
|
||||
'before_or_equal:validade_fim',
|
||||
],
|
||||
'validade_fim' => [
|
||||
'nullable',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:validade_inicio',
|
||||
],
|
||||
'prontuario_unidade' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:10',
|
||||
],
|
||||
'unidade_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'alimentos_acabaram' => [
|
||||
'nullable',
|
||||
'boolean',
|
||||
'required_unless:comeu_alguns_alimentos,null',
|
||||
],
|
||||
'comeu_alguns_alimentos' => [
|
||||
'nullable',
|
||||
'boolean',
|
||||
'required_unless:alimentos_acabaram,null',
|
||||
],
|
||||
]);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return array_merge(CidadaoRequest::getMessages(), [
|
||||
'comeu_alguns_alimentos.required_unless' =>
|
||||
'O campo "Nos últimos três meses, você comeu apenas alguns alimentos que ainda tinha porque o dinheiro acabou?" é obrigatório.',
|
||||
'alimentos_acabaram.required_unless' =>
|
||||
'O campo "Nos últimos três meses, os alimentos acabaram antes que você tivesse dinheiro para comprar mais comida" é obrigatório.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Rules\SenhaAntiga;
|
||||
use App\Rules\SenhaAtual;
|
||||
|
||||
class UsuarioPerfilRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'email' => ['required'],
|
||||
'senha' => [$this->nova_senha ? 'required' : 'nullable', 'min:8', 'max:100'],
|
||||
'nova_senha' => [
|
||||
$this->senha ? 'required' : 'nullable',
|
||||
'min:8',
|
||||
'max:100',
|
||||
'regex:/^(?=.*\d)(?=.*[a-zA-Z]).{8,}$/',
|
||||
new SenhaAtual($this->usuario_perfil),
|
||||
new SenhaAntiga($this->usuario_perfil),
|
||||
'confirmed',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
134
api/app/Http/Requests/Cadastro/SujeitoAtencao/UsuarioRequest.php
Normal file
134
api/app/Http/Requests/Cadastro/SujeitoAtencao/UsuarioRequest.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UsuarioRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostPutRules()
|
||||
{
|
||||
$cidadaoRules = array_merge([
|
||||
'cidadao.id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\Usuario,cidadao_id,'
|
||||
. ($this->route('usuario') ?? 'NULL') . ',id,deleted_at,NULL',
|
||||
],
|
||||
], CidadaoRequest::getPostPutRules($this));
|
||||
|
||||
$rules = array_merge($cidadaoRules, [
|
||||
'documentos' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'documentos.conselho_profissional' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'documentos.conselho_profissional.registro_tipo_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'documentos.conselho_profissional.registro_tipo_outro' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:50',
|
||||
],
|
||||
'documentos.conselho_profissional.registro_numero' => [
|
||||
'nullable',
|
||||
'required_with:documentos.conselho_profissional.registro_tipo_id',
|
||||
'string',
|
||||
'max:25',
|
||||
Rule::unique('\App\Models\Cadastro\SujeitoAtencao\Usuario', 'registro_numero')
|
||||
->where(function ($query) {
|
||||
|
||||
return $query
|
||||
->where(
|
||||
'registro_tipo_id',
|
||||
$this->documentos['conselho_profissional']['registro_tipo_id'] ?? null
|
||||
)
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
->ignore($this->route('usuario') ?? null)
|
||||
],
|
||||
'documentos.conselho_profissional.registro_estado_id' => [
|
||||
'bail',
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'email' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:5,180',
|
||||
'regex:/(.+)@(.+)\.(.+)/i',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\Usuario,email,'
|
||||
. ($this->route('usuario') ?? 'NULL') . ',id,deleted_at,NULL',
|
||||
],
|
||||
'usuario' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,100',
|
||||
'unique:\App\Models\Cadastro\SujeitoAtencao\Usuario,usuario,'
|
||||
. ($this->route('usuario') ?? 'NULL') . ',id,deleted_at,NULL',
|
||||
],
|
||||
'lotacoes' => [
|
||||
'array'
|
||||
],
|
||||
'lotacoes.*.id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
'lotacoes.*.ocupacao_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'lotacoes.*.realiza_atendimento' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
'lotacoes.*.principal' => [
|
||||
'required',
|
||||
'boolean'
|
||||
],
|
||||
]);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return array_merge(CidadaoRequest::getMessages(), [
|
||||
'email.regex' => 'Informe um email válido.',
|
||||
'email.unique' => 'O Email já está vinculado a outro usuário.',
|
||||
'usuario.unique' => 'O Nome de usuário (Login) já está vinculado a outro usuário.',
|
||||
'documentos.conselho_profissional.registro_numero.unique' =>
|
||||
'O número do Conselho profissional já está vinculado a outro usuário.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class UsuarioTrocaSenhaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'senha' => ['required', 'min:8', 'max:100'],
|
||||
'nova_senha' => ['required', 'min:8', 'max:100'],
|
||||
];
|
||||
}
|
||||
}
|
||||
30
api/app/Http/Requests/ConsumoAlimentarHistoricoRequest.php
Normal file
30
api/app/Http/Requests/ConsumoAlimentarHistoricoRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConsumoAlimentarHistoricoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Externo\Ambulatorio\ConectaSus;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class AtendimentoSafecareStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'metaDataConectaSus' => ['required', 'array'],
|
||||
'metaDataConectaSus.agendamento_id' => ['required', 'integer'],
|
||||
'metaDataConectaSus.jornada_id' => ['required', 'integer'],
|
||||
'metaDataConectaSus.paciente_id' => ['required', 'integer'],
|
||||
|
||||
'antropometria' => ['nullable', 'array'],
|
||||
'antropometria.peso' => ['nullable', 'numeric', 'between:0,999.999'],
|
||||
'antropometria.altura' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
'antropometria.perimetro_cefalico' => ['nullable', 'numeric', 'between:0,99.9'],
|
||||
'antropometria.circunferencia_abdominal' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
'antropometria.perimetro_panturrilha' => ['nullable', 'numeric', 'between:0,99.9'],
|
||||
'antropometria.comprimento_pe_direito' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
'antropometria.largura_pe_direito' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
'antropometria.circunferencia_pe_direito' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
'antropometria.comprimento_pe_esquerdo' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
'antropometria.largura_pe_esquerdo' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
'antropometria.circunferencia_pe_esquerdo' => ['nullable', 'numeric', 'between:0,999.9'],
|
||||
|
||||
'sinais_vitais' => ['nullable', 'array'],
|
||||
'sinais_vitais.pressao_arterial' => ['nullable', 'string', 'max:7', 'regex:/^\d{2,3}\/\d{2,3}$/'],
|
||||
'sinais_vitais.frequencia_respiratoria' => ['nullable', 'integer', 'between:0,32767'],
|
||||
'sinais_vitais.frequencia_cardiaca' => ['nullable', 'integer', 'between:0,32767'],
|
||||
'sinais_vitais.temperatura' => ['nullable', 'numeric', 'between:0,99.9'],
|
||||
'sinais_vitais.saturacao_o2' => ['nullable', 'integer', 'between:0,100'],
|
||||
|
||||
'feridas' => ['nullable', 'array'],
|
||||
'feridas.*.identificador_externo' => ['required', 'string'],
|
||||
'feridas.*.local_anatomico_descricao' => ['nullable', 'string'],
|
||||
'feridas.*.local_regiao_anatomico_descricao' => ['nullable', 'string'],
|
||||
'feridas.*.lado_descricao' => ['nullable', 'string'],
|
||||
'feridas.*.data_inicio_tratamento' => ['nullable', 'date'],
|
||||
'feridas.*.ferida_necrose_porcentagem' => ['nullable', 'string'],
|
||||
'feridas.*.ferida_exsudato_descricao' => ['nullable', 'string'],
|
||||
'feridas.*.foto_ferida' => ['nullable', 'string', 'max:500'],
|
||||
'feridas.*.foto_ferida_limpa' => ['nullable', 'string', 'max:500'],
|
||||
'feridas.*.foto_curativo' => ['nullable', 'string', 'max:500'],
|
||||
'feridas.*.foto_ferida_evolucao' => ['nullable', 'string', 'max:500'],
|
||||
'feridas.*.status_ferida' => ['nullable'],
|
||||
'feridas.*.dor' => ['nullable', 'integer', 'between:0,99'],
|
||||
'feridas.*.largura_ferida' => ['nullable', 'numeric', 'between:0,99'],
|
||||
'feridas.*.comprimento_ferida' => ['nullable', 'numeric', 'between:0,99'],
|
||||
'feridas.*.profundidade_ferida' => ['nullable', 'numeric', 'between:0,99'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'sinais_vitais.pressao_arterial.regex' => 'O formato da pressão arterial deve ser "120/080".',
|
||||
'feridas.*.local_anatomico_descricao.string' => 'O campo local anatômico deve ser uma string.',
|
||||
'feridas.*.local_regiao_anatomico_descricao.string' => 'O campo local anatômico região deve ser uma string.',
|
||||
];
|
||||
}
|
||||
}
|
||||
43
api/app/Http/Requests/FormRequest.php
Normal file
43
api/app/Http/Requests/FormRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
abstract class FormRequest extends LaravelFormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function authorize();
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function rules();
|
||||
|
||||
/**
|
||||
* Handle a failed validation attempt.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\HttpResponseException
|
||||
*/
|
||||
protected function failedValidation(Validator $validator)
|
||||
{
|
||||
$errors = (new ValidationException($validator))->errors();
|
||||
|
||||
throw new HttpResponseException(
|
||||
response()->json($errors, JsonResponse::HTTP_UNPROCESSABLE_ENTITY)
|
||||
);
|
||||
}
|
||||
}
|
||||
33
api/app/Http/Requests/PainelSenha/ChamadaRequest.php
Normal file
33
api/app/Http/Requests/PainelSenha/ChamadaRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class ChamadaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'fila_id' => ['required', 'integer'],
|
||||
'tela_id' => ['required', 'integer'],
|
||||
];
|
||||
}
|
||||
}
|
||||
79
api/app/Http/Requests/PainelSenha/EncaminhamentoRequest.php
Normal file
79
api/app/Http/Requests/PainelSenha/EncaminhamentoRequest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class EncaminhamentoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id_de' => [
|
||||
'required',
|
||||
'integer',
|
||||
'different:centro_custo_id_para',
|
||||
Rule::unique('\App\Models\PainelSenha\Encaminhamento')->where(function ($query) {
|
||||
return $query
|
||||
->where('centro_custo_id_para', $this->centro_custo_id_para)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'centro_custo_id_para' => [
|
||||
'required',
|
||||
'integer',
|
||||
'different:centro_custo_id_de',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id_de' => [
|
||||
'required',
|
||||
'integer',
|
||||
'different:centro_custo_id_para',
|
||||
Rule::unique('\App\Models\PainelSenha\Encaminhamento')->where(function ($query) {
|
||||
return $query
|
||||
->where('centro_custo_id_para', $this->centro_custo_id_para)
|
||||
->whereNull('deleted_at');
|
||||
})->ignore($this->encaminhamento),
|
||||
],
|
||||
'centro_custo_id_para' => [
|
||||
'required',
|
||||
'integer',
|
||||
'different:centro_custo_id_de',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id_de.unique' => 'Já existe um encaminhamento cadastrado com estas informações.'
|
||||
];
|
||||
}
|
||||
}
|
||||
39
api/app/Http/Requests/PainelSenha/FilaRequest.php
Normal file
39
api/app/Http/Requests/PainelSenha/FilaRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Models\PainelSenha\OpcaoEntrada;
|
||||
|
||||
class FilaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'opcao_entrada_id' => ['required', 'integer'],
|
||||
'prioridade_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::requiredIf(fn () => OpcaoEntrada::findOrFail($this->opcao_entrada_id)->prioridade_obrigatoria),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
67
api/app/Http/Requests/PainelSenha/OpcaoChamadaRequest.php
Normal file
67
api/app/Http/Requests/PainelSenha/OpcaoChamadaRequest.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class OpcaoChamadaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id' => [
|
||||
'required',
|
||||
Rule::unique('painel_senha_opcao_chamada')->where(function ($query) {
|
||||
return $query->where('tela_id', $this->tela_id)->whereNull('deleted_at');
|
||||
})
|
||||
],
|
||||
'tela_id' => [
|
||||
'required',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id' => [
|
||||
'required',
|
||||
Rule::unique('painel_senha_opcao_chamada')->where(function ($query) {
|
||||
return $query->where('tela_id', $this->tela_id)->whereNull('deleted_at');
|
||||
})->ignore($this->opcao_chamada),
|
||||
],
|
||||
'tela_id' => [
|
||||
'required',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id.unique' => 'Já existe uma opção de chamada cadastrada com estas informações.'
|
||||
];
|
||||
}
|
||||
}
|
||||
99
api/app/Http/Requests/PainelSenha/OpcaoEntradaRequest.php
Normal file
99
api/app/Http/Requests/PainelSenha/OpcaoEntradaRequest.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class OpcaoEntradaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id' => [
|
||||
'required',
|
||||
Rule::unique('\App\Models\PainelSenha\OpcaoEntrada')->where(function ($query) {
|
||||
return $query
|
||||
->where('nome', $this->nome)
|
||||
->where('sigla', $this->sigla)
|
||||
->where('modulo_id', $this->modulo_id)
|
||||
->where('faixa_etaria_id', $this->faixa_etaria_id)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'modulo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'nome' => [
|
||||
'required',
|
||||
'min:3',
|
||||
'max:100',
|
||||
],
|
||||
'sigla' => [
|
||||
'required',
|
||||
'min:2',
|
||||
'max:2',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id' => [
|
||||
'required',
|
||||
Rule::unique('\App\Models\PainelSenha\OpcaoEntrada')->where(function ($query) {
|
||||
return $query
|
||||
->where('nome', $this->nome)
|
||||
->where('sigla', $this->sigla)
|
||||
->where('modulo_id', $this->modulo_id)
|
||||
->where('faixa_etaria_id', $this->faixa_etaria_id)
|
||||
->whereNull('deleted_at');
|
||||
})->ignore($this->opcao_entrada),
|
||||
],
|
||||
'modulo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'nome' => [
|
||||
'required',
|
||||
'min:3',
|
||||
'max:100',
|
||||
],
|
||||
'sigla' => [
|
||||
'required',
|
||||
'min:2',
|
||||
'max:2',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id.unique' => 'Já existe uma opção de entrada cadastrada com estas informações.'
|
||||
];
|
||||
}
|
||||
}
|
||||
46
api/app/Http/Requests/PainelSenha/ParametrizacaoRequest.php
Normal file
46
api/app/Http/Requests/PainelSenha/ParametrizacaoRequest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class ParametrizacaoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'infraestruturas' => [
|
||||
'present',
|
||||
'array',
|
||||
],
|
||||
'infraestruturas.*.id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'infraestruturas.*.modulos' => [
|
||||
'required',
|
||||
'array',
|
||||
],
|
||||
'infraestruturas.*.modulos.*' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
69
api/app/Http/Requests/PainelSenha/StatusRequest.php
Normal file
69
api/app/Http/Requests/PainelSenha/StatusRequest.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StatusRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id' => [
|
||||
'required',
|
||||
Rule::unique('\App\Models\PainelSenha\Status')->where(function ($query) {
|
||||
return $query
|
||||
->where('tipo_id', $this->tipo_id)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'tipo_id' => ['required'],
|
||||
'nome' => ['required', 'min:3', 'max:100']
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id' => [
|
||||
'required',
|
||||
Rule::unique('\App\Models\PainelSenha\Status')->where(function ($query) {
|
||||
return $query
|
||||
->where('tipo_id', $this->tipo_id)
|
||||
->whereNull('deleted_at');
|
||||
})->ignore($this->status),
|
||||
],
|
||||
'tipo_id' => ['required'],
|
||||
'nome' => ['required', 'min:3', 'max:100']
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'centro_custo_id.unique' => 'Já existe um Status cadastrado com o setor e tipo selecionados.'
|
||||
];
|
||||
}
|
||||
}
|
||||
75
api/app/Http/Requests/PainelSenha/TelaRequest.php
Normal file
75
api/app/Http/Requests/PainelSenha/TelaRequest.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class TelaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'infraestrutura_id' => [
|
||||
'required',
|
||||
Rule::unique('painel_senha_tela')->where(function ($query) {
|
||||
return $query
|
||||
->where('nome', $this->nome)
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
],
|
||||
'nome' => [
|
||||
'required',
|
||||
'min:3',
|
||||
'max:100',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'infraestrutura_id' => [
|
||||
'required',
|
||||
Rule::unique('painel_senha_tela')->where(function ($query) {
|
||||
return $query
|
||||
->where('nome', $this->nome)
|
||||
->where('id', '!=', $this->tela)
|
||||
->whereNull('deleted_at');
|
||||
})
|
||||
],
|
||||
'nome' => [
|
||||
'required',
|
||||
'max:100',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'infraestrutura_id.unique' => 'Já existe uma tela cadastrada com estas informações.'
|
||||
];
|
||||
}
|
||||
}
|
||||
87
api/app/Http/Requests/PainelSenha/TempoEsperaRequest.php
Normal file
87
api/app/Http/Requests/PainelSenha/TempoEsperaRequest.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\PainelSenha;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class TempoEsperaRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'infraestrutura_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::unique('\App\Models\PainelSenha\TempoEspera')->where(function ($query) {
|
||||
return $query
|
||||
->where('tempo', $this->tempo)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'cor' => [
|
||||
'required',
|
||||
'string',
|
||||
],
|
||||
'tempo' => [
|
||||
'required',
|
||||
'integer',
|
||||
'min:1',
|
||||
'max:240',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'infraestrutura_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::unique('\App\Models\PainelSenha\TempoEspera')->where(function ($query) {
|
||||
return $query
|
||||
->where('tempo', $this->nome)
|
||||
->whereNull('deleted_at');
|
||||
})->ignore($this->tempo_espera),
|
||||
],
|
||||
'cor' => [
|
||||
'required',
|
||||
'string',
|
||||
],
|
||||
'tempo' => [
|
||||
'required',
|
||||
'integer',
|
||||
'min:1',
|
||||
'max:240',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'infraestrutura_id.unique' => 'Já existe um tempo de espera cadastrado com estas informações.'
|
||||
];
|
||||
}
|
||||
}
|
||||
115
api/app/Http/Requests/Parametrizacao/ExameRequest.php
Normal file
115
api/app/Http/Requests/Parametrizacao/ExameRequest.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Parametrizacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ExameRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
if (request()->has('action') && request()->action === 'atribuicao-parametro-grupo') {
|
||||
return [];
|
||||
} else {
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST':
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPostPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,180',
|
||||
Rule::unique('\App\Models\Parametrizacao\Exame\Exame', 'nome')
|
||||
->where(function ($query) {
|
||||
|
||||
return $query->whereNull('deleted_at');
|
||||
})
|
||||
->ignore($this->exame)
|
||||
],
|
||||
'tipo_id' => [
|
||||
'required'
|
||||
],
|
||||
'sigla_exame' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:2,5',
|
||||
],
|
||||
'prazo_entrega' => [
|
||||
'integer',
|
||||
'max:999'
|
||||
],
|
||||
'validade' => [
|
||||
'integer',
|
||||
'max:999'
|
||||
],
|
||||
'quantidade_maxima' => [
|
||||
'integer',
|
||||
'max:99999'
|
||||
],
|
||||
'ultimo_resultado' => [
|
||||
'integer',
|
||||
'max:99'
|
||||
],
|
||||
'resultado' => [
|
||||
'max:500',
|
||||
],
|
||||
'regulacao_tipo_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
'is_ppi' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'tempo_medio_previsto_atendimento_dias' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'max:9999'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'O nome do Exame já foi inserido anteriormente.',
|
||||
'sigla_exame.max' => 'O limite de caracteres foi atingido na sigla do exame.',
|
||||
'sigla_exame.required' => 'Obrigatório informar a sigla do exame.',
|
||||
'prazo_entrega.max' => 'O limite de caracteres foi atingido no prazo de entrega.',
|
||||
'validade.max' => 'O limite de caracteres foi atingido na validade.',
|
||||
'quantidade_maxima.max' => 'O limite de caracteres foi atingido na quantidade máxima.',
|
||||
'ultimo_resultado.max' => 'O limite de caracteres foi atingido no últimos resultados.',
|
||||
'resultado.max' => 'O limite de caracteres foi atingido no resultado.',
|
||||
];
|
||||
}
|
||||
}
|
||||
126
api/app/Http/Requests/Parametrizacao/KitExame/ItemRequest.php
Normal file
126
api/app/Http/Requests/Parametrizacao/KitExame/ItemRequest.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Parametrizacao\KitExame;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\Parametrizacao\Exame\Exame;
|
||||
use App\Models\Parametrizacao\KitExame\KitExame;
|
||||
|
||||
class ItemRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'unique:\App\Models\Parametrizacao\KitExame\KitExame,nome,NULL,id,deleted_at,NULL',
|
||||
],
|
||||
'tipo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'itens' => [
|
||||
'bail',
|
||||
'required',
|
||||
'array',
|
||||
function ($attribute, $value, $fail) {
|
||||
|
||||
foreach ($value as $item) {
|
||||
|
||||
if (Exame::findOrFail($item['exame_id'])->tipo_id != $this->tipo_id) {
|
||||
|
||||
$fail("Os exames devem ser do mesmo tipo do kit.");
|
||||
}
|
||||
}
|
||||
},
|
||||
function ($attribute, $value, $fail) {
|
||||
|
||||
$this->validateDuplicatedKitItems($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
'itens.*.exame_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'distinct',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
"unique:\App\Models\Parametrizacao\KitExame\KitExame,nome,{$this->kit},id,deleted_at,NULL",
|
||||
],
|
||||
'itens' => [
|
||||
'bail',
|
||||
'required',
|
||||
'array',
|
||||
function ($attribute, $value, $fail) {
|
||||
|
||||
$this->validateDuplicatedKitItems($attribute, $value, $fail);
|
||||
}
|
||||
],
|
||||
'itens.*.exame_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'distinct',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function validateDuplicatedKitItems($attribute, $value, $fail)
|
||||
{
|
||||
$exames = collect($value)->pluck('exame_id');
|
||||
$examesCount = $exames->count();
|
||||
|
||||
foreach (KitExame::where('id', '<>', $this->kit)->get() as $kit) {
|
||||
|
||||
$currentExames = $kit->itens->pluck('exame_id');
|
||||
|
||||
if ($currentExames->count() != $examesCount) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($currentExames->diff($exames)->isEmpty()) {
|
||||
|
||||
$fail("O kit {$kit->nome} já possui estes mesmos exames cadastrados. Utilize ou atualize ele.");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'nome.unique' => 'Já existe um kit com este nome cadastrado.'
|
||||
];
|
||||
}
|
||||
}
|
||||
59
api/app/Http/Requests/Parametrizacao/KitExame/KitRequest.php
Normal file
59
api/app/Http/Requests/Parametrizacao/KitExame/KitRequest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Parametrizacao\KitExame;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class KitRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
return $this->getPutRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'tipo_id' => ['required', 'integer'],
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:100',
|
||||
Rule::unique('\App\Models\Parametrizacao\KitExame\Kit')->where(function ($query) {
|
||||
return $query
|
||||
->where('nome', $this->nome)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:100',
|
||||
"unique:\App\Models\Parametrizacao\KitExame\Kit,nome,{$this->nome},id,deleted_at,NULL"
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
71
api/app/Http/Requests/Parametrizacao/ProcedimentoRequest.php
Normal file
71
api/app/Http/Requests/Parametrizacao/ProcedimentoRequest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Parametrizacao;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProcedimentoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'procedimento_codigo' => [
|
||||
'required',
|
||||
'string',
|
||||
'size:10',
|
||||
'unique:\App\Models\Parametrizacao\Procedimento,procedimento_codigo,NULL,id,deleted_at,NULL'
|
||||
],
|
||||
'apelido' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:100',
|
||||
'unique:\App\Models\Parametrizacao\Procedimento,apelido,NULL,id,deleted_at,NULL'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'apelido' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:100',
|
||||
"unique:\App\Models\Parametrizacao\Procedimento,apelido,{$this->procedimento},id,deleted_at,NULL"
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'procedimento_codigo.unique' => 'O Procedimento já foi configurado anteriormente.',
|
||||
'apelido.unique' => 'O apelido do Procedimento já foi inserido anteriormente.',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,911 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\Atendimento;
|
||||
|
||||
use App\Enums\Cadastro\SujeitoAtencao\FatorRisco;
|
||||
use App\Enums\Cadastro\UnidadeMedida;
|
||||
use App\Enums\Parametrizacao\Exame\Status as ExameStatus;
|
||||
use App\Enums\ProntoAtendimento\Atendimento\Desfecho;
|
||||
use App\Enums\Sigtap\Ocupacao as OcupacaoEnum;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Atendimento;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Rules\NomeCompleto;
|
||||
use App\Rules\Sigtap\Procedimento\ValidCompetencia;
|
||||
use App\Rules\Sigtap\Procedimento\Idade;
|
||||
use App\Rules\Sigtap\Procedimento\Ocupacao;
|
||||
use App\Rules\Sigtap\Procedimento\Quantidade;
|
||||
use App\Rules\Sigtap\Procedimento\Sexo as SexoRule;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class EnfermagemRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
$atendimento = is_numeric($this->atendimento_id ?? null)
|
||||
? Atendimento::find($this->atendimento_id)
|
||||
: null;
|
||||
|
||||
$rules = [
|
||||
'plantao_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'atendimento_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\Atendimento\Atendimento,id'
|
||||
],
|
||||
];
|
||||
|
||||
if (is_null($atendimento)) {
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
'classificacao_risco_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\ClassificacaoRisco\ClassificacaoRisco,id'
|
||||
],
|
||||
'historico' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000'
|
||||
],
|
||||
'diagnostico' => [
|
||||
'nullable',
|
||||
'string',
|
||||
$this->getIsUsuarioCboEnfermeiroValidator(),
|
||||
'max:3000'
|
||||
],
|
||||
'planejamento' => [
|
||||
'nullable',
|
||||
'string',
|
||||
$this->getIsUsuarioCboEnfermeiroValidator(),
|
||||
'max:3000'
|
||||
],
|
||||
'implementacao' => [
|
||||
'nullable',
|
||||
'string',
|
||||
$this->getIsUsuarioCboEnfermeiroValidator(),
|
||||
'max:3000'
|
||||
],
|
||||
'avaliacao' => [
|
||||
'nullable',
|
||||
'string',
|
||||
$this->getIsUsuarioCboEnfermeiroValidator(),
|
||||
'max:6000'
|
||||
],
|
||||
'medicamentos_uso' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000',
|
||||
],
|
||||
'observacoes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000',
|
||||
],
|
||||
'centro_custo_id_para' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\Estabelecimento\CentroCusto,id',
|
||||
],
|
||||
'escala_coma_glasgow' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'escala_coma_glasgow.*.abertura_ocular_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowAberturaOcular,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.resposta_verbal_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowRespostaVerbal,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.resposta_motora_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowRespostaMotora,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.reatividade_pupilar_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowReatividadePupilar,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.observacao' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:2500'
|
||||
],
|
||||
]);
|
||||
|
||||
return array_merge(
|
||||
$rules,
|
||||
$this->getPostAlergiaRules(),
|
||||
$this->getPostSinaisVitaisRules(),
|
||||
$this->getPostAvaliacaoAntropometricaRules(),
|
||||
$this->getPostFatoresRicoRules(),
|
||||
$this->getPostGestacaoRules(),
|
||||
$this->getPostAnotacoesRules(),
|
||||
$this->getPostServicosEnfermagemRules($atendimento),
|
||||
$this->getPostProcedimentosRules($atendimento),
|
||||
$this->getPostPrescricoesInternaRules($atendimento),
|
||||
$this->getPostPedidoExamesRules($atendimento),
|
||||
$this->getPostFinalizacaoRules($atendimento),
|
||||
);
|
||||
}
|
||||
|
||||
private function getIsUsuarioCboEnfermeiroValidator()
|
||||
{
|
||||
return function ($value, $attribute, $fail) {
|
||||
|
||||
if ($this->getOcupacaoProfissionalLogado()->codigo !== OcupacaoEnum::ENFERMEIRO) {
|
||||
|
||||
$fail('Não permitido para a CBO logado');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function getPostFatoresRicoRules()
|
||||
{
|
||||
return [
|
||||
'fatores_risco' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'fatores_risco.*' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'fator_risco_outro' => [
|
||||
'nullable',
|
||||
Rule::requiredIf(fn () => in_array(FatorRisco::OUTRO, $this->fatores_risco ?? [])),
|
||||
'string',
|
||||
'max:100',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getPostAlergiaRules()
|
||||
{
|
||||
return [
|
||||
'alergias' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'alergias.*.alergia_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\SujeitoAtencao\Alergia,id',
|
||||
],
|
||||
'alergias.*.criticidade_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\SujeitoAtencao\AlergiaCriticidade,id',
|
||||
],
|
||||
'alergias.*.reacoes_observacoes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,100',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getPostSinaisVitaisRules()
|
||||
{
|
||||
$rules = [
|
||||
'sinais_vitais' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'sinais_vitais.*.pa_unidade_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:sinais_vitais.*.pa',
|
||||
'integer',
|
||||
Rule::in([UnidadeMedida::MILIMETROS_DE_MERCURIO, UnidadeMedida::CENTIMETROS_DE_MERCURIO]),
|
||||
],
|
||||
'sinais_vitais.*.glicemia' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'max:999',
|
||||
],
|
||||
'sinais_vitais.*.temperatura' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'numeric',
|
||||
'max:99.9',
|
||||
],
|
||||
'sinais_vitais.*.pulso' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'max:999',
|
||||
],
|
||||
'sinais_vitais.*.respiracao' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'max:99',
|
||||
],
|
||||
'sinais_vitais.*.saturacao' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'between:1,100',
|
||||
],
|
||||
'sinais_vitais.*.intensidade_dor' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'between:1,10',
|
||||
],
|
||||
'sinais_vitais.*.cintura' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,',
|
||||
'integer',
|
||||
'max:999',
|
||||
],
|
||||
];
|
||||
|
||||
foreach (($this->sinais_vitais ?? []) as $i => $sinalVital) {
|
||||
|
||||
$rules["sinais_vitais.{$i}.pa"] = [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. "sinais_vitais.{$i}.glicemia,"
|
||||
. "sinais_vitais.{$i}.temperatura,"
|
||||
. "sinais_vitais.{$i}.pulso,"
|
||||
. "sinais_vitais.{$i}.respiracao,"
|
||||
. "sinais_vitais.{$i}.saturacao,"
|
||||
. "sinais_vitais.{$i}.intensidade_dor,"
|
||||
. "sinais_vitais.{$i}.cintura'",
|
||||
'string',
|
||||
];
|
||||
|
||||
if ($sinalVital['pa_unidade_medida_id'] === UnidadeMedida::MILIMETROS_DE_MERCURIO) {
|
||||
|
||||
$rules["sinais_vitais.{$i}.pa"][] = 'regex:/^[0-9]{2,3}\/+[0-9]{2,3}$/';
|
||||
}
|
||||
else if ($sinalVital['pa_unidade_medida_id'] === UnidadeMedida::CENTIMETROS_DE_MERCURIO) {
|
||||
|
||||
$rules["sinais_vitais.{$i}.pa"][] = 'regex:/^[0-9]{1,2}\/+[0-9]{1,2}$/';
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getPostAvaliacaoAntropometricaRules()
|
||||
{
|
||||
$rules = [
|
||||
'avaliacao_antropometrica' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
];
|
||||
|
||||
if (is_array($this->avaliacao_antropometrica ?? null)) {
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
'avaliacao_antropometrica.massa' => [
|
||||
'nullable',
|
||||
'required_without:avaliacao_antropometrica.altura',
|
||||
'numeric',
|
||||
'max:999.999',
|
||||
],
|
||||
'avaliacao_antropometrica.massa_unidade_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:avaliacao_antropometrica.massa',
|
||||
'integer',
|
||||
Rule::in([UnidadeMedida::GRAMAS, UnidadeMedida::QUILOGRAMAS]),
|
||||
],
|
||||
'avaliacao_antropometrica.altura' => [
|
||||
'nullable',
|
||||
'required_without:avaliacao_antropometrica.massa',
|
||||
'numeric',
|
||||
'max:999.99',
|
||||
],
|
||||
'avaliacao_antropometrica.altura_unidade_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:avaliacao_antropometrica.altura',
|
||||
'integer',
|
||||
Rule::in([UnidadeMedida::CENTIMETROS, UnidadeMedida::METROS]),
|
||||
],
|
||||
'avaliacao_antropometrica.altura_tipo_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:avaliacao_antropometrica.altura',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\TipoMedidaAltura,id',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getPostGestacaoRules()
|
||||
{
|
||||
$rules = [
|
||||
'gestacao' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
];
|
||||
|
||||
if (is_array($this->gestacao ?? null)) {
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
'gestacao.gestante' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'gestacao.dum' => [
|
||||
'nullable',
|
||||
'date_format:Y-m-d',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getPostAnotacoesRules()
|
||||
{
|
||||
$rules = [
|
||||
'anotacoes' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'anotacoes.*.anotado_em' => [
|
||||
'required',
|
||||
'date_format:Y-m-d H:i',
|
||||
'before_or_equal:now',
|
||||
],
|
||||
'anotacoes.*.descricao' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:6000'
|
||||
]
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getPostServicosEnfermagemRules(Atendimento $atendimento)
|
||||
{
|
||||
$rules = [
|
||||
'servicos_enfermagem' => [
|
||||
'nullable',
|
||||
'array',
|
||||
]
|
||||
];
|
||||
|
||||
foreach (($this->servicos_enfermagem ?? []) as $i => $param) {
|
||||
|
||||
$rules["servicos_enfermagem.{$i}.id"] = [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\Atendimento\ServicoEnfermagem,id',
|
||||
];
|
||||
|
||||
$rules["servicos_enfermagem.{$i}.observacoes"] = [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:100'
|
||||
];
|
||||
|
||||
$rules["servicos_enfermagem.{$i}.status_id"] = [
|
||||
'nullable',
|
||||
"required_with:servicos_enfermagem.{$i}.id",
|
||||
'integer',
|
||||
Rule::in(ExameStatus::SOLICITADO, ExameStatus::REALIZADO, ExameStatus::NAO_REALIZADO),
|
||||
'exists:\App\Models\Parametrizacao\Exame\ExameStatus,id',
|
||||
];
|
||||
|
||||
$procedimento = is_numeric($param['procedimento_id'] ?? null)
|
||||
? Procedimento::find($param['procedimento_id'])
|
||||
: null;
|
||||
|
||||
$rules["servicos_enfermagem.{$i}.procedimento_id"] = [
|
||||
'required',
|
||||
'integer',
|
||||
new ValidCompetencia($procedimento),
|
||||
$atendimento->faa->paciente->cidadao->idade
|
||||
? new Idade($procedimento, $atendimento->faa->paciente->cidadao->idade['anos'])
|
||||
: null,
|
||||
new Ocupacao($procedimento, $this->getOcupacaoProfissionalLogado()),
|
||||
new Quantidade($procedimento, 1),
|
||||
new SexoRule($procedimento, $atendimento->faa->paciente->cidadao->sexo),
|
||||
$this->getMatchProcedimentoIdAndServicoEnfermagemIdValidator($atendimento, $this->servicos_enfermagem[$i]),
|
||||
'exists:\App\Models\Sigtap\Procedimento,id',
|
||||
];
|
||||
|
||||
$rules["servicos_enfermagem.{$i}.cid_id"] = [
|
||||
'nullable',
|
||||
Rule::requiredIf(fn () => $procedimento->hasCidPrincipal
|
||||
&& ($param['status_id'] == ExameStatus::REALIZADO)),
|
||||
'integer',
|
||||
$procedimento->hasCidPrincipal
|
||||
? Rule::in($procedimento->cidsPrincipais()->pluck('id'))
|
||||
: 'exists:\App\Models\Sigtap\Cid,id',
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getMatchProcedimentoIdAndServicoEnfermagemIdValidator($atendimento, $currentServicoEnfermagem)
|
||||
{
|
||||
return function ($attribute, $value, $fail) use ($atendimento, $currentServicoEnfermagem) {
|
||||
|
||||
if (is_null($currentServicoEnfermagem['id'] ?? null))
|
||||
return;
|
||||
|
||||
$found = false;
|
||||
$atendimentos = [];
|
||||
|
||||
foreach ($atendimento->atendimentosMedico as $atendimentoMedico) {
|
||||
|
||||
if (!empty($atendimentoMedico->servicosEnfermagem()->get()->toArray())) {
|
||||
|
||||
$atendimentos[] = $atendimentoMedico->servicosEnfermagem;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($atendimento->atendimentosEnfermagem as $atendimentoEnfermagem) {
|
||||
|
||||
if (!empty($atendimentoEnfermagem->servicosEnfermagem()->get()->toArray())) {
|
||||
|
||||
$atendimentos[] = $atendimentoEnfermagem->servicosEnfermagem;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($atendimentos as $servicosEnfermagem) {
|
||||
|
||||
foreach ($servicosEnfermagem as $servicoEnfermagem) {
|
||||
|
||||
$found = $currentServicoEnfermagem['id'] == $servicoEnfermagem->id
|
||||
&& $currentServicoEnfermagem['procedimento_id'] == $servicoEnfermagem->procedimento_id;
|
||||
|
||||
if ($found) {
|
||||
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
|
||||
$fail('O ' . $attribute . ' não é válido para o serviço de enfermagem!');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function getPostProcedimentosRules($atendimento)
|
||||
{
|
||||
$rules = [
|
||||
'procedimentos' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
];
|
||||
|
||||
if (is_array($this->procedimentos ?? null)) {
|
||||
|
||||
foreach ($this->procedimentos as $i => $params) {
|
||||
|
||||
$procedimento = is_numeric($params['procedimento_id'] ?? null)
|
||||
? Procedimento::find($params['procedimento_id'])
|
||||
: null;
|
||||
|
||||
$rules["procedimentos.{$i}.procedimento_id"] = [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Sigtap\Procedimento,id',
|
||||
];
|
||||
|
||||
if (is_null($procedimento)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$rules["procedimentos.{$i}.procedimento_id"] = [
|
||||
$this->getDuplicatedValidator($this->procedimentos, $i),
|
||||
new ValidCompetencia($procedimento),
|
||||
new Ocupacao($procedimento, $this->getOcupacaoProfissionalLogado()),
|
||||
new SexoRule($procedimento, $atendimento->faa->paciente->cidadao->sexo),
|
||||
($atendimento->faa->paciente->cidadao->idade
|
||||
? new Idade($procedimento, $atendimento->faa->paciente->cidadao->idade['anos'])
|
||||
: null),
|
||||
];
|
||||
|
||||
if (is_numeric($params['quantidade'] ?? null)) {
|
||||
|
||||
$rules["procedimentos.{$i}.procedimento_id"][] = new Quantidade(
|
||||
$procedimento,
|
||||
$params['quantidade']
|
||||
);
|
||||
}
|
||||
|
||||
$rules["procedimentos.{$i}.cid_principal_id"] = [
|
||||
'nullable',
|
||||
Rule::requiredIf(fn () => $procedimento->hasCidPrincipal),
|
||||
'integer',
|
||||
$procedimento->hasCidPrincipal
|
||||
? Rule::in($procedimento->cidsPrincipais()->pluck('id'))
|
||||
: 'exists:\App\Models\Sigtap\Cid,id',
|
||||
];
|
||||
|
||||
$rules["procedimentos.{$i}.quantidade"] = [
|
||||
'required',
|
||||
'integer',
|
||||
'min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getDuplicatedValidator($procedimentos, $index)
|
||||
{
|
||||
return function ($attribute, $value, $fail) use ($procedimentos, $index) {
|
||||
|
||||
foreach ($procedimentos as $j => $params) {
|
||||
|
||||
if ($index === $j || !isset($params['procedimento_id'])) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value == $params['procedimento_id']) {
|
||||
|
||||
$fail('O campo ' . $attribute . ' campo tem um valor duplicado.');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function getPostPrescricoesInternaRules()
|
||||
{
|
||||
$rule = [
|
||||
'prescricao_interna_aplicacoes' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'prescricao_interna_aplicacoes.*.id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\Atendimento\PrescricaoInternaMedicamentoAplicacao,id'
|
||||
],
|
||||
'prescricao_interna_aplicacoes.*.status_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::in(ExameStatus::SOLICITADO, ExameStatus::REALIZADO, ExameStatus::NAO_REALIZADO),
|
||||
'exists:\App\Models\Parametrizacao\Exame\ExameStatus,id',
|
||||
]
|
||||
];
|
||||
|
||||
return $rule;
|
||||
}
|
||||
|
||||
private function getPostPedidoExamesRules($atendimento)
|
||||
{
|
||||
$rules = [
|
||||
'pedidos_exames' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'pedidos_exames.*.data_solicitacao' => [
|
||||
'nullable',
|
||||
'date_format:d/m/Y',
|
||||
],
|
||||
'pedidos_exames.*.unidade_encaminhamento_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\Estabelecimento\Unidade,id',
|
||||
],
|
||||
'pedidos_exames.*.unidade_externa_encaminhamento_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\UnidadeExterna,id'
|
||||
],
|
||||
'pedidos_exames.*.medico_solicitante_encaminhamento' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:6,150',
|
||||
new NomeCompleto,
|
||||
],
|
||||
];
|
||||
|
||||
foreach (($this->pedidos_exames ?? []) as $i => $pedidoExames) {
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
"pedidos_exames.{$i}.id" => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
"pedidos_exames.{$i}.urgente" => [
|
||||
'nullable',
|
||||
"required_without:pedidos_exames.{$i}.id",
|
||||
'boolean',
|
||||
],
|
||||
"pedidos_exames.{$i}.justificativa" => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:100',
|
||||
],
|
||||
"pedidos_exames.{$i}.exames" => [
|
||||
'required',
|
||||
'array',
|
||||
],
|
||||
]);
|
||||
|
||||
foreach ($pedidoExames['exames'] as $j => $item) {
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
"pedidos_exames.{$i}.exames.{$j}.id" => [
|
||||
'nullable',
|
||||
"required_with:pedidos_exames.{$i}.id",
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\PedidoExame\Item,id'
|
||||
],
|
||||
"pedidos_exames.{$i}.exames.{$j}.status_id" => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Parametrizacao\Exame\ExameStatus,id'
|
||||
],
|
||||
"pedidos_exames.{$i}.exames.{$j}.horario_realizacao" => [
|
||||
Rule::requiredIf(fn () => $this->isRealizado($item['status_id'])),
|
||||
'nullable',
|
||||
'date_format:H:i:s',
|
||||
],
|
||||
"pedidos_exames.{$i}.exames.{$j}.observacao" => [
|
||||
'nullable',
|
||||
'string',
|
||||
'min:1',
|
||||
'max:1000'
|
||||
],
|
||||
"pedidos_exames.{$i}.exames.{$j}.exame_id" => [
|
||||
'required',
|
||||
$this->getDistinctExameValidator($pedidoExames, $item, $j),
|
||||
'integer',
|
||||
'exists:\App\Models\Parametrizacao\Exame\Exame,id',
|
||||
],
|
||||
]);
|
||||
|
||||
if (!$this->isRealizado($item['status_id'] ?? null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$atendimento->faa->paciente->is_desconhecido) {
|
||||
|
||||
$rules["pedidos_exames.{$i}.exames.{$j}.exame_id"] =
|
||||
array_merge($rules["pedidos_exames.{$i}.exames.{$j}.exame_id"], [
|
||||
$this->getHasDataNascimentoValidator($atendimento),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getDistinctExameValidator($pedidoExames, $currentItem, $currentIndex)
|
||||
{
|
||||
return function ($value, $attribute, $fail) use ($pedidoExames, $currentIndex, $currentItem) {
|
||||
|
||||
foreach ($pedidoExames['exames'] as $i => $item) {
|
||||
|
||||
if ($currentIndex != $i && $currentItem['exame_id'] == $item['exame_id']) {
|
||||
|
||||
return $fail(":attribute possui valor duplicado.");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function getHasDataNascimentoValidator(Atendimento $atendimento)
|
||||
{
|
||||
return function ($value, $attribute, $fail) use ($atendimento) {
|
||||
|
||||
if ($this->isNullIdade($atendimento)) {
|
||||
|
||||
$fail("O :attribute exige que a data de nascimento do paciente seja preenchida!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function isRealizado(?int $statusId)
|
||||
{
|
||||
return $statusId === ExameStatus::REALIZADO;
|
||||
}
|
||||
|
||||
private function getOcupacaoProfissionalLogado()
|
||||
{
|
||||
return Lotacao::find(auth()->payload()->get('lotacao_id'))->ocupacao;
|
||||
}
|
||||
|
||||
private function isNullIdade(Atendimento $atendimento)
|
||||
{
|
||||
return is_null($atendimento->faa->paciente->cidadao->idade ?? null);
|
||||
}
|
||||
|
||||
private function getPostFinalizacaoRules(Atendimento $atendimento)
|
||||
{
|
||||
$rules = [
|
||||
'finalizacao' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
];
|
||||
|
||||
return array_merge(
|
||||
$rules,
|
||||
[
|
||||
'finalizacao.desfecho_id' => [
|
||||
Rule::requiredIf($this->hasFinalizacao()),
|
||||
'integer',
|
||||
$this->getDesfechoValidator($atendimento),
|
||||
'exists:\App\Models\ProntoAtendimento\Atendimento\Desfecho,id',
|
||||
],
|
||||
'finalizacao.evasao' => [
|
||||
'nullable',
|
||||
'required_if:finalizacao.desfecho_id,' . Desfecho::EVASAO,
|
||||
'array',
|
||||
],
|
||||
'finalizacao.evasao.motivo' => [
|
||||
'nullable',
|
||||
'required_if:finalizacao.desfecho_id,' . Desfecho::EVASAO,
|
||||
'string',
|
||||
'max:200'
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
private function getDesfechoValidator($atendimento)
|
||||
{
|
||||
return function ($attribute, $value, $fail) use ($atendimento) {
|
||||
|
||||
switch ($value) {
|
||||
|
||||
case Desfecho::PACIENTE_ATENDIDO: {
|
||||
|
||||
if (!$this->isDesfechoPacienteAtendidoValid($value, $atendimento)) {
|
||||
|
||||
return $fail(":attribute selecionado é inválido.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Desfecho::ALTA_MEDICA: {
|
||||
|
||||
if (!$this->isDesfechoAltaMedicaValid($value, $atendimento)) {
|
||||
|
||||
return $fail(":attribute selecionado é inválido.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function isDesfechoPacienteAtendidoValid(int $desfecho, Atendimento $atendimento)
|
||||
{
|
||||
$atendimentosMedico = $atendimento->atendimentosMedico;
|
||||
|
||||
return $desfecho === Desfecho::PACIENTE_ATENDIDO && $atendimentosMedico->count() === 0;
|
||||
}
|
||||
|
||||
private function isDesfechoAltaMedicaValid(int $desfecho, Atendimento $atendimento)
|
||||
{
|
||||
$atendimentoMedico = $atendimento->atendimentosMedico->sortByDesc('created_at')->first();
|
||||
|
||||
return !is_null($atendimentoMedico) && $desfecho === Desfecho::ALTA_MEDICA && !$atendimentoMedico->solicitou_reavaliacao;
|
||||
}
|
||||
|
||||
private function hasFinalizacao()
|
||||
{
|
||||
return isset($this->finalizacao);
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
$cboNotAllowd = 'Não permitido para a CBO logado';
|
||||
|
||||
return [
|
||||
'diagnostico.in' => $cboNotAllowd,
|
||||
'planejamento.in' => $cboNotAllowd,
|
||||
'implementacao.in' => $cboNotAllowd,
|
||||
'avaliacao.in' => $cboNotAllowd,
|
||||
];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\Atendimento;
|
||||
|
||||
use App\Enums\Cadastro\Estabelecimento\Servico;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\Sexo;
|
||||
use App\Enums\PainelSenha\PrioridadeTipo;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Paciente;
|
||||
use App\Rules\CnsTermoValido;
|
||||
use App\Rules\NomeCompleto;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RecepcaoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'plantao_id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
|
||||
/*
|
||||
* Paciente.
|
||||
*/
|
||||
|
||||
'paciente' => ['required', 'array'],
|
||||
'paciente.id' => ['nullable', 'integer'],
|
||||
'paciente.sexo_id' => ['required_without:paciente.id', 'nullable', 'integer'],
|
||||
'paciente.caracteristicas_fisicas' => ['required_without:paciente.id', 'string', 'max:500'],
|
||||
|
||||
/*
|
||||
* Fila.
|
||||
*/
|
||||
|
||||
'fila' => ['required', 'array'],
|
||||
'fila.id' => ['nullable', 'integer'],
|
||||
'fila.prioridade_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
function ($attribute, $value, $fail) {
|
||||
|
||||
$sexoId = null;
|
||||
|
||||
if (isset($this->paciente['id']) && !is_null($this->paciente['id'])) {
|
||||
|
||||
$paciente = Paciente::with('cidadao')->find($this->paciente['id']);
|
||||
|
||||
if (!is_null($paciente)) {
|
||||
|
||||
$sexoId = $paciente->cidadao->sexo->id;
|
||||
}
|
||||
}
|
||||
else if (isset($this->paciente['sexo_id']) && !is_null($this->paciente['sexo_id'])) {
|
||||
|
||||
$sexoId = $this->paciente['sexo_id'];
|
||||
}
|
||||
|
||||
if ($sexoId === Sexo::MASCULINO && $value === PrioridadeTipo::GESTANTE) {
|
||||
|
||||
$fail('O '.$attribute.' não pode ser gestante quando o paciente for do sexo masculino.');
|
||||
}
|
||||
}
|
||||
],
|
||||
'fila.opcao_entrada_id' => ['required_without:fila.id', 'nullable', 'integer'],
|
||||
'fila.centro_custo_id_para' => ['required', 'integer'],
|
||||
|
||||
/*
|
||||
* Atendimento
|
||||
*/
|
||||
|
||||
'atendido_em' => ['required', 'date'],
|
||||
'urgente' => [
|
||||
Rule::requiredIf(fn () => isset($this->paciente['id'])),
|
||||
'nullable',
|
||||
'boolean'
|
||||
],
|
||||
'urgente_motivo' => ['required_if:urgente,true', 'nullable', 'string', 'max:100'],
|
||||
'origem_entrada_id' => ['nullable', 'integer'],
|
||||
'medico_samu' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:150'
|
||||
],
|
||||
"motivo_atendimento" => ['required', 'nullable', 'string', 'max:3000'],
|
||||
"acompanhante" => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:6,150',
|
||||
new NomeCompleto,
|
||||
new CnsTermoValido(['attribute' => 'Acompanhante']),
|
||||
],
|
||||
"unidade_encaminhamento_id" => ['nullable', 'integer'],
|
||||
"unidade_externa_encaminhamento_id" => ['nullable', 'integer'],
|
||||
"medico_solicitante_encaminhamento" => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:6,150',
|
||||
new NomeCompleto,
|
||||
],
|
||||
"servico_id" => ['required', 'integer'],
|
||||
"ocupacao_id" => [
|
||||
Rule::requiredIf(fn () => !is_null($this->servico_id)
|
||||
&& $this->servico_id === Servico::CONSULTA_MEDICA),
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
"observacao" => ['nullable', 'string', 'max:3000'],
|
||||
|
||||
/*
|
||||
* RAAT.
|
||||
*/
|
||||
|
||||
'raat' => ['nullable', 'array'],
|
||||
|
||||
'raat.empresa' => [
|
||||
Rule::requiredIf(fn () => !is_null($this->raat)),
|
||||
'array'
|
||||
],
|
||||
'raat.empresa.nome' => [
|
||||
Rule::requiredIf(fn () => !is_null($this->raat)),
|
||||
'string',
|
||||
'between:2,150'
|
||||
],
|
||||
'raat.empresa.ramo_atividade' => ['nullable', 'string', 'between:2,150'],
|
||||
'raat.empresa.endereco' => ['nullable', 'string', 'between:2,150'],
|
||||
'raat.empresa.telefone' => ['nullable', 'digits_between:10,11'],
|
||||
|
||||
'raat.acidente' => [
|
||||
Rule::requiredIf(fn () => !is_null($this->raat)),
|
||||
'array'
|
||||
],
|
||||
'raat.acidente.data' => [
|
||||
Rule::requiredIf(fn () => !is_null($this->raat)),
|
||||
'date_format:Y-m-d'
|
||||
],
|
||||
'raat.acidente.hora' => ['nullable', 'date_format:H:i'],
|
||||
'raat.acidente.tipo_id' => ['nullable', 'integer'],
|
||||
'raat.acidente.local' => ['nullable', 'string', 'between:3,150'],
|
||||
'raat.acidente.descricao' => [
|
||||
Rule::requiredIf(fn () => !is_null($this->raat)),
|
||||
'string',
|
||||
'between:3,250'
|
||||
],
|
||||
|
||||
'raat.regime_trabalho_id' => ['nullable', 'integer'],
|
||||
'raat.regime_trabalho_outro' => ['nullable', 'string', 'max:50'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\Atendimento;
|
||||
|
||||
use App\Enums\Cadastro\UnidadeMedida;
|
||||
use App\Enums\ProntoAtendimento\Atendimento\Desfecho;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class TriagemRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
$rules = [
|
||||
'dor_toracica' => [
|
||||
'nullable',
|
||||
'boolean',
|
||||
],
|
||||
'plantao_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'alergias' => ['nullable', 'array'],
|
||||
'alergias.*.alergia_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\SujeitoAtencao\Alergia,id',
|
||||
],
|
||||
'alergias.*.criticidade_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\SujeitoAtencao\AlergiaCriticidade,id',
|
||||
],
|
||||
'alergias.*.reacoes_observacoes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:3,100',
|
||||
],
|
||||
'atendimento_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\Atendimento\Atendimento,id',
|
||||
],
|
||||
'avaliacao_antropometrica' => ['nullable', 'array'],
|
||||
'avaliacao_antropometrica.altura' => [
|
||||
'nullable',
|
||||
'numeric',
|
||||
'max:999.99',
|
||||
],
|
||||
'avaliacao_antropometrica.altura_tipo_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:avaliacao_antropometrica.altura',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\TipoMedidaAltura,id',
|
||||
],
|
||||
'avaliacao_antropometrica.altura_unidade_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:avaliacao_antropometrica.altura',
|
||||
'integer',
|
||||
Rule::in([UnidadeMedida::CENTIMETROS, UnidadeMedida::METROS]),
|
||||
],
|
||||
'avaliacao_antropometrica.massa' => [
|
||||
'nullable',
|
||||
'numeric',
|
||||
'max:999.99',
|
||||
],
|
||||
'avaliacao_antropometrica.massa_unidade_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:avaliacao_antropometrica.massa',
|
||||
'integer',
|
||||
Rule::in([UnidadeMedida::GRAMAS, UnidadeMedida::QUILOGRAMAS]),
|
||||
],
|
||||
'centro_custo_id_para' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::requiredIf(fn () => !$this->hasFinalizacao()),
|
||||
'exists:\App\Models\Cadastro\Estabelecimento\CentroCusto,id',
|
||||
],
|
||||
'classificacao_risco_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\ClassificacaoRisco\ClassificacaoRisco,id',
|
||||
],
|
||||
'fila_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\PainelSenha\Fila,id',
|
||||
],
|
||||
'gestacao' => ['nullable', 'array'],
|
||||
'gestacao.dum' => ['nullable', 'date_format:Y-m-d', 'before_or_equal:now'],
|
||||
'gestacao.gestante' => ['required', 'boolean'],
|
||||
'historico_enfermagem' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000',
|
||||
],
|
||||
'medicamentos_uso' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000',
|
||||
],
|
||||
'observacoes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000',
|
||||
],
|
||||
'outras_avaliacoes_condicoes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000',
|
||||
],
|
||||
'sinais_vitais' => ['nullable', 'array'],
|
||||
'sinais_vitais.*.cintura' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,',
|
||||
'integer',
|
||||
'max:999',
|
||||
],
|
||||
'sinais_vitais.*.glicemia' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'max:999',
|
||||
],
|
||||
'sinais_vitais.*.intensidade_dor' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'between:1,10',
|
||||
],
|
||||
'sinais_vitais.*.pa_unidade_medida_id' => [
|
||||
'nullable',
|
||||
'required_with:sinais_vitais.*.pa',
|
||||
'integer',
|
||||
Rule::in([UnidadeMedida::MILIMETROS_DE_MERCURIO, UnidadeMedida::CENTIMETROS_DE_MERCURIO]),
|
||||
],
|
||||
'sinais_vitais.*.pulso' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'max:999',
|
||||
],
|
||||
'sinais_vitais.*.respiracao' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'max:99',
|
||||
],
|
||||
'sinais_vitais.*.saturacao' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.temperatura,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'integer',
|
||||
'between:1,100',
|
||||
],
|
||||
'sinais_vitais.*.temperatura' => [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. 'sinais_vitais.*.pa,'
|
||||
. 'sinais_vitais.*.glicemia,'
|
||||
. 'sinais_vitais.*.pulso,'
|
||||
. 'sinais_vitais.*.respiracao,'
|
||||
. 'sinais_vitais.*.saturacao,'
|
||||
. 'sinais_vitais.*.intensidade_dor,'
|
||||
. 'sinais_vitais.*.cintura',
|
||||
'numeric',
|
||||
'max:99.9',
|
||||
],
|
||||
'escala_coma_glasgow' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'escala_coma_glasgow.*.abertura_ocular_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowAberturaOcular,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.resposta_verbal_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowRespostaVerbal,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.resposta_motora_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowRespostaMotora,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.reatividade_pupilar_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Geral\GlasgowReatividadePupilar,id'
|
||||
],
|
||||
'escala_coma_glasgow.*.observacao' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:2500'
|
||||
],
|
||||
'finalizacao' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'finalizacao.desfecho_id' => [
|
||||
Rule::requiredIf(fn () => $this->hasFinalizacao()),
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\Atendimento\Desfecho,id',
|
||||
],
|
||||
'finalizacao.evasao' => [
|
||||
'nullable',
|
||||
'required_if:finalizacao.desfecho_id,' . Desfecho::EVASAO,
|
||||
'array',
|
||||
],
|
||||
'finalizacao.evasao.motivo' => [
|
||||
'nullable',
|
||||
'required_if:finalizacao.desfecho_id,' . Desfecho::EVASAO,
|
||||
'string',
|
||||
'max:200'
|
||||
],
|
||||
];
|
||||
|
||||
foreach (($this->sinais_vitais ?? []) as $i => $sinalVital) {
|
||||
|
||||
$rules["sinais_vitais.{$i}.pa"] = [
|
||||
'nullable',
|
||||
'required_without_all:'
|
||||
. "sinais_vitais.{$i}.glicemia,"
|
||||
. "sinais_vitais.{$i}.temperatura,"
|
||||
. "sinais_vitais.{$i}.pulso,"
|
||||
. "sinais_vitais.{$i}.respiracao,"
|
||||
. "sinais_vitais.{$i}.saturacao,"
|
||||
. "sinais_vitais.{$i}.intensidade_dor,"
|
||||
. "sinais_vitais.{$i}.cintura'",
|
||||
'string',
|
||||
];
|
||||
|
||||
if ($sinalVital['pa_unidade_medida_id'] === UnidadeMedida::MILIMETROS_DE_MERCURIO) {
|
||||
|
||||
$rules["sinais_vitais.{$i}.pa"][] = 'regex:/^[0-9]{2,3}\/+[0-9]{2,3}$/';
|
||||
}
|
||||
else if ($sinalVital['pa_unidade_medida_id'] === UnidadeMedida::CENTIMETROS_DE_MERCURIO) {
|
||||
|
||||
$rules["sinais_vitais.{$i}.pa"][] = 'regex:/^[0-9]{1,2}\/+[0-9]{1,2}$/';
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function hasFinalizacao()
|
||||
{
|
||||
return isset($this->finalizacao);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\ClassificacaoRisco;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ClassificacaoRiscoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PUT': {
|
||||
|
||||
return $this->getPutRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'max:100',
|
||||
Rule::unique('\App\Models\ProntoAtendimento\ClassificacaoRisco\ClassificacaoRisco')->where(function ($query) {
|
||||
return $query->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'tipo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::unique('\App\Models\ProntoAtendimento\ClassificacaoRisco\ClassificacaoRisco')->where(function ($query) {
|
||||
return $query->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutRules()
|
||||
{
|
||||
return [
|
||||
'nome' => [
|
||||
'required',
|
||||
'max:100',
|
||||
Rule::unique('\App\Models\ProntoAtendimento\ClassificacaoRisco\ClassificacaoRisco')->where(function ($query) {
|
||||
return $query->whereNull('deleted_at');
|
||||
})->ignore($this->classificacao_risco),
|
||||
],
|
||||
'tipo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::unique('\App\Models\ProntoAtendimento\ClassificacaoRisco\ClassificacaoRisco')->where(function ($query) {
|
||||
return $query->whereNull('deleted_at');
|
||||
})->ignore($this->classificacao_risco),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'tipo_id.unique' => 'Já existe uma classificação de risco com este tipo.',
|
||||
'nome.unique' => 'Já existe uma classificação de risco com este nome.'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\Parametrizacao;
|
||||
|
||||
use App\Enums\Sigtap\Ocupacao;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
|
||||
class ParametrizacaoRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'servicos_enfermagem' => [
|
||||
'array',
|
||||
],
|
||||
'servicos_enfermagem.*.procedimento_codigo' => [
|
||||
'bail',
|
||||
'required',
|
||||
'string',
|
||||
'size:10',
|
||||
'distinct',
|
||||
function ($attribute, $value, $fail) {
|
||||
|
||||
$procedimento = Procedimento::where('codigo', $value)->orderByDesc('competencia_id')->first();
|
||||
|
||||
$allowedToEnfermagem = $procedimento->ocupacoes()->whereIn('codigo', [
|
||||
Ocupacao::ENFERMEIRO,
|
||||
Ocupacao::TECNICO_ENFERMAGEM,
|
||||
Ocupacao::AUXILIAR_ENFERMAGEM,
|
||||
])->exists();
|
||||
|
||||
if (!$allowedToEnfermagem) {
|
||||
|
||||
$fail("Procedimento {$value} não permitido.");
|
||||
}
|
||||
}
|
||||
],
|
||||
'atendimento_medico' => [
|
||||
'required',
|
||||
'array',
|
||||
],
|
||||
'atendimento_medico.procedimento_padrao_codigo' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'size:10',
|
||||
],
|
||||
'atendimento_medico.tipos' => [
|
||||
'array',
|
||||
],
|
||||
'atendimento_medico.tipos.*.infraestrutura_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'distinct'
|
||||
],
|
||||
'atendimento_medico.tipos.*.tipo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'faturamento_automatico_enfermagem' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'assinatura_eletronica' => [
|
||||
'required',
|
||||
'boolean',
|
||||
],
|
||||
'lotacoes_exame_laboratorial' => [
|
||||
'present',
|
||||
'array',
|
||||
],
|
||||
'lotacoes_exame_laboratorial.*' => [
|
||||
'integer'
|
||||
],
|
||||
'tempo_aidicional_plantao' => [
|
||||
'nullable',
|
||||
'digits_between:0,300',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\PedidoExame;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class LaudoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getPostRules() {
|
||||
return [
|
||||
'arquivo' => [
|
||||
'required',
|
||||
'array',
|
||||
],
|
||||
'arquivo.*' => [
|
||||
'distinct',
|
||||
'mimes:doc,pdf,png,jpeg',
|
||||
'max:2048',
|
||||
],
|
||||
'pedido_exame_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\PedidoExame\PedidoExame,id'
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\PedidoExame;
|
||||
|
||||
use App\Enums\Cadastro\Estabelecimento\SetorTipo;
|
||||
use App\Enums\Parametrizacao\Exame\Status as ExameStatus;
|
||||
use App\Enums\ProntoAtendimento\Atendimento\Desfecho;
|
||||
use App\Enums\Sigtap\Ocupacao as OcupacaoEnum;
|
||||
use App\Enums\Sigtap\Ocupacao;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Models\Parametrizacao\Exame\Exame;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Atendimento;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Rules\NomeCompleto;
|
||||
use App\Rules\Sigtap\Procedimento\ValidCompetencia;
|
||||
use App\Rules\Sigtap\Procedimento\Idade;
|
||||
use App\Rules\Sigtap\Procedimento\Ocupacao as OcupacaoRule;
|
||||
use App\Rules\Sigtap\Procedimento\Quantidade;
|
||||
use App\Rules\Sigtap\Procedimento\Sexo as SexoRule;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PedidoExameRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch($this->method()) {
|
||||
case 'POST':
|
||||
return $this->getPostRules();
|
||||
break;
|
||||
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getPostRules() {
|
||||
|
||||
$atendimento = is_numeric($this->atendimento_id ?? null)
|
||||
? Atendimento::find($this->atendimento_id)
|
||||
: null;
|
||||
|
||||
return $this->getPostPedidoExamesRules($atendimento);
|
||||
}
|
||||
|
||||
private function getPostPedidoExamesRules($atendimento)
|
||||
{
|
||||
$isEncaminhamento = $atendimento->recepcao->is_encaminhamento;
|
||||
$isPacienteEmObservacao = $this->isPacienteEmObservacao($atendimento);
|
||||
|
||||
$rules = [
|
||||
'plantao_id' => [
|
||||
'required',
|
||||
'integer'
|
||||
],
|
||||
'pedidos_exames' => [
|
||||
'nullable',
|
||||
'array',
|
||||
],
|
||||
'pedidos_exames.*.data_solicitacao' => [
|
||||
'nullable',
|
||||
'date_format:d/m/Y',
|
||||
],
|
||||
'pedidos_exames.*.unidade_encaminhamento_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\Estabelecimento\Unidade,id',
|
||||
],
|
||||
'pedidos_exames.*.unidade_externa_encaminhamento_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\UnidadeExterna,id'
|
||||
],
|
||||
'pedidos_exames.*.medico_solicitante_encaminhamento' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'between:6,150',
|
||||
new NomeCompleto,
|
||||
],
|
||||
'observacoes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:3000',
|
||||
],
|
||||
'centro_custo_id_para' => [
|
||||
Rule::requiredIf(fn () =>
|
||||
!$this->hasFinalizacao() && !$isEncaminhamento && !$isPacienteEmObservacao
|
||||
),
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\Estabelecimento\CentroCusto,id',
|
||||
],
|
||||
];
|
||||
|
||||
foreach (($this->pedidos_exames ?? []) as $i => $pedidoExames) {
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
"pedidos_exames.{$i}.id" => [
|
||||
'nullable',
|
||||
'integer',
|
||||
],
|
||||
"pedidos_exames.{$i}.urgente" => [
|
||||
'nullable',
|
||||
"required_without:pedidos_exames.{$i}.id",
|
||||
'boolean',
|
||||
],
|
||||
"pedidos_exames.{$i}.justificativa" => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:100',
|
||||
],
|
||||
"pedidos_exames.{$i}.exames" => [
|
||||
'required',
|
||||
'array',
|
||||
],
|
||||
]);
|
||||
|
||||
foreach ($pedidoExames['exames'] as $j => $item) {
|
||||
|
||||
$rules = array_merge($rules, [
|
||||
"pedidos_exames.{$i}.exames.{$j}.id" => [
|
||||
'nullable',
|
||||
"required_with:pedidos_exames.{$i}.id",
|
||||
'integer',
|
||||
'exists:\App\Models\ProntoAtendimento\PedidoExame\Item,id'
|
||||
],
|
||||
"pedidos_exames.{$i}.exames.{$j}.status_id" => [
|
||||
'nullable',
|
||||
'integer',
|
||||
'exists:\App\Models\Parametrizacao\Exame\ExameStatus,id'
|
||||
],
|
||||
"pedidos_exames.{$i}.exames.{$j}.observacao" => [
|
||||
'nullable',
|
||||
'string',
|
||||
'min:1',
|
||||
'max:1000'
|
||||
],
|
||||
"pedidos_exames.{$i}.exames.{$j}.exame_id" => [
|
||||
'required',
|
||||
$this->getDistinctExameValidator($pedidoExames, $item, $j),
|
||||
'integer',
|
||||
'exists:\App\Models\Parametrizacao\Exame\Exame,id',
|
||||
],
|
||||
]);
|
||||
|
||||
if (!$this->isRealizado($item['status_id'] ?? null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = is_numeric($item['exame_id'])
|
||||
? Exame::find($item['exame_id'])
|
||||
: null;
|
||||
|
||||
if (is_null($item) || $this->isNullIdade($atendimento)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$procedimento = Procedimento::where('codigo', $item->codigo)
|
||||
->orderByDesc('competencia_id')
|
||||
->first();
|
||||
|
||||
$rules["pedidos_exames.{$i}.exames.{$j}.exame_id"] =
|
||||
array_merge($rules["pedidos_exames.{$i}.exames.{$j}.exame_id"], [
|
||||
new ValidCompetencia($procedimento),
|
||||
new Idade($procedimento, $atendimento->faa->paciente->cidadao->idade['anos']),
|
||||
new Quantidade($procedimento, 1),
|
||||
new SexoRule($procedimento, $atendimento->faa->paciente->cidadao->sexo),
|
||||
]);
|
||||
|
||||
if (!$atendimento->faa->paciente->isDesconhecido) {
|
||||
|
||||
$rules["pedidos_exames.{$i}.exames.{$j}.exame_id"] =
|
||||
array_merge($rules["pedidos_exames.{$i}.exames.{$j}.exame_id"], [
|
||||
new Idade($procedimento, $atendimento->faa->paciente->cidadao->idade['anos']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function getOcupacaoProfissionalLogado()
|
||||
{
|
||||
return Lotacao::find(auth()->payload()->get('lotacao_id'))->ocupacao;
|
||||
}
|
||||
|
||||
private function getDistinctExameValidator($pedidoExames, $currentItem, $currentIndex)
|
||||
{
|
||||
return function ($value, $attribute, $fail) use ($pedidoExames, $currentIndex, $currentItem) {
|
||||
|
||||
foreach ($pedidoExames['exames'] as $i => $item) {
|
||||
|
||||
if ($currentIndex != $i && $currentItem['exame_id'] == $item['exame_id']) {
|
||||
|
||||
return $fail(":attribute possui valor duplicado.");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function isRealizado(?int $statusId)
|
||||
{
|
||||
return $statusId === ExameStatus::REALIZADO;
|
||||
}
|
||||
|
||||
private function isNullIdade(Atendimento $atendimento)
|
||||
{
|
||||
return is_null($atendimento->faa->paciente->cidadao->idade ?? null);
|
||||
}
|
||||
|
||||
private function getPostFinalizacaoDesfechoRules($atendimento)
|
||||
{
|
||||
$rules = [
|
||||
'finalizacao.desfecho_id' => [
|
||||
Rule::requiredIf(fn () => $this->hasFinalizacao()),
|
||||
'integer',
|
||||
Rule::in(Desfecho::PACIENTE_LIBERADO),
|
||||
$this->getDesfechoIdValidator($atendimento),
|
||||
'exists:\App\Models\ProntoAtendimento\Atendimento\Desfecho,id',
|
||||
]
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
private function hasFinalizacao()
|
||||
{
|
||||
return isset($this->finalizacao);
|
||||
}
|
||||
|
||||
private function isPacienteEmObservacao($atendimento)
|
||||
{
|
||||
return !is_null($atendimento->fila) && $atendimento->fila->whereHas('centroCusto.setor', function ($query) {
|
||||
|
||||
$query->where('tipo_id', SetorTipo::OBSERVACAO);
|
||||
})
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ProntoAtendimento\Plantao;
|
||||
|
||||
use App\Enums\ProntoAtendimento\Plantao\TipoEscala;
|
||||
use App\Http\Requests\FormRequest;
|
||||
use App\Models\ProntoAtendimento\Plantao\Status;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PlantaoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
|
||||
case 'POST': {
|
||||
|
||||
return $this->getPostRules();
|
||||
}
|
||||
case 'PATCH': {
|
||||
|
||||
return $this->getPatchRules();
|
||||
}
|
||||
default: {
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getPostRules()
|
||||
{
|
||||
return [
|
||||
'lotacao_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'servico_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'faixa_etaria_id' => [
|
||||
'nullable',
|
||||
'integer'
|
||||
],
|
||||
'escala.tipo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
'escala.inicio' => [
|
||||
'required',
|
||||
'date',
|
||||
],
|
||||
'escala.fim' => [
|
||||
'required',
|
||||
'date',
|
||||
'after:escala.inicio',
|
||||
],
|
||||
'escala.dias_semana' => [
|
||||
'required_if:escala.tipo_id,' . TipoEscala::FIXA,
|
||||
'array',
|
||||
],
|
||||
'escala.dias_semana.*' => [
|
||||
'integer',
|
||||
'between:1,7'
|
||||
],
|
||||
'escala.jornada_em_horas' => [
|
||||
'required_if:escala_tipo_id,' . TipoEscala::FIXA . ',' . TipoEscala::DINAMICA,
|
||||
'integer',
|
||||
Rule::in([6, 8, 12, 24])
|
||||
],
|
||||
'escala.quantidade_atendimentos' => [
|
||||
'required',
|
||||
'integer',
|
||||
'max:99999999',
|
||||
],
|
||||
'status_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists(Status::class, 'id'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getPatchRules()
|
||||
{
|
||||
return [
|
||||
'status_id' => [
|
||||
'integer'
|
||||
],
|
||||
'escala.inicio' => [
|
||||
'required_with:escala.fim',
|
||||
'date',
|
||||
],
|
||||
'escala.fim' => [
|
||||
'required_with:escala.inicio',
|
||||
'date',
|
||||
'after:escala.inicio',
|
||||
],
|
||||
'escala.quantidade_atendimentos' => [
|
||||
'integer',
|
||||
'max:99999999',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
38
api/app/Http/Requests/Sigtap/ValidacaoIdadeRequest.php
Normal file
38
api/app/Http/Requests/Sigtap/ValidacaoIdadeRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Sigtap;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class ValidacaoIdadeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'procedimento_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Sigtap\Procedimento,id',
|
||||
],
|
||||
'idade_em_anos' => [
|
||||
'required',
|
||||
'integer',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
38
api/app/Http/Requests/Sigtap/ValidacaoOcupacaoRequest.php
Normal file
38
api/app/Http/Requests/Sigtap/ValidacaoOcupacaoRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Sigtap;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class ValidacaoOcupacaoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'procedimento_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Sigtap\Procedimento,id',
|
||||
],
|
||||
'ocupacao_id' => [
|
||||
'integer',
|
||||
'exists:\App\Models\Sigtap\Ocupacao,id',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
39
api/app/Http/Requests/Sigtap/ValidacaoQuantidadeRequest.php
Normal file
39
api/app/Http/Requests/Sigtap/ValidacaoQuantidadeRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Sigtap;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class ValidacaoQuantidadeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'procedimento_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Sigtap\Procedimento,id',
|
||||
],
|
||||
'quantidade' => [
|
||||
'required',
|
||||
'integer',
|
||||
'min:0',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
39
api/app/Http/Requests/Sigtap/ValidacaoSexoRequest.php
Normal file
39
api/app/Http/Requests/Sigtap/ValidacaoSexoRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Sigtap;
|
||||
|
||||
use App\Http\Requests\FormRequest;
|
||||
|
||||
class ValidacaoSexoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'procedimento_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Sigtap\Procedimento,id',
|
||||
],
|
||||
'sexo_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
'exists:\App\Models\Cadastro\SujeitoAtencao\Sexo,id',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user