This commit is contained in:
43
api/app/Rules/Sigtap/Procedimento/Idade.php
Normal file
43
api/app/Rules/Sigtap/Procedimento/Idade.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class Idade implements Rule
|
||||
{
|
||||
private Procedimento $procedimento;
|
||||
private int $idadeAnos;
|
||||
|
||||
public function __construct(Procedimento $procedimento, int $idadeAnos)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
$this->idadeAnos = $idadeAnos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$validation = new ProcedimentoValidationService($this->procedimento);
|
||||
|
||||
return $validation->isIdadeValid($this->idadeAnos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return ":attribute não permitido para a idade do paciente.";
|
||||
}
|
||||
}
|
||||
46
api/app/Rules/Sigtap/Procedimento/Ocupacao.php
Normal file
46
api/app/Rules/Sigtap/Procedimento/Ocupacao.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Sigtap\Ocupacao as OcupacaoSigtap;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class Ocupacao implements Rule
|
||||
{
|
||||
private Procedimento $procedimento;
|
||||
private OcupacaoSigtap $ocupacao;
|
||||
private $field;
|
||||
|
||||
public function __construct(Procedimento $procedimento, OcupacaoSigtap $ocupacao, $field = null)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
$this->ocupacao = $ocupacao;
|
||||
$this->field = $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$validation = new ProcedimentoValidationService($this->procedimento);
|
||||
|
||||
return $validation->isOcupacaoValid($this->ocupacao);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return ($this->field ?? ':attribute') . ' não permitido para o CBO.';
|
||||
}
|
||||
}
|
||||
43
api/app/Rules/Sigtap/Procedimento/Quantidade.php
Normal file
43
api/app/Rules/Sigtap/Procedimento/Quantidade.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class Quantidade implements Rule
|
||||
{
|
||||
private Procedimento $procedimento;
|
||||
private ?int $quantidade;
|
||||
|
||||
public function __construct(Procedimento $procedimento, ?int $quantidade = null)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
$this->quantidade = $quantidade;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$validation = new ProcedimentoValidationService($this->procedimento);
|
||||
|
||||
return $validation->isQuantidadeValid($this->quantidade ?? $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return "Quantidade máxima atingida para o :attribute";
|
||||
}
|
||||
}
|
||||
44
api/app/Rules/Sigtap/Procedimento/Sexo.php
Normal file
44
api/app/Rules/Sigtap/Procedimento/Sexo.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\Sexo as CidadaoSexo;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class Sexo implements Rule
|
||||
{
|
||||
private CidadaoSexo $sexo;
|
||||
private Procedimento $procedimento;
|
||||
|
||||
public function __construct(Procedimento $procedimento, CidadaoSexo $sexo)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
$this->sexo = $sexo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$validation = new ProcedimentoValidationService($this->procedimento);
|
||||
|
||||
return $validation->isSexoValid($this->sexo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return ":attribute não permitido para o sexo do paciente.";
|
||||
}
|
||||
}
|
||||
41
api/app/Rules/Sigtap/Procedimento/ValidCompetencia.php
Normal file
41
api/app/Rules/Sigtap/Procedimento/ValidCompetencia.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class ValidCompetencia implements Rule
|
||||
{
|
||||
private Procedimento $procedimento;
|
||||
|
||||
public function __construct(Procedimento $procedimento)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$validation = new ProcedimentoValidationService($this->procedimento);
|
||||
|
||||
return $validation->isOnValidCompetencia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return "Competência do :attribute inválida.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user