init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Rules\Sigtap;
use App\Models\Sigtap\Procedimento;
use App\Utils\MaskUtil;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\DB;
class QuantidadeIsValidForProcedimento implements Rule
{
private $procedimentoId;
public function __construct($procedimentoId)
{
$this->procedimentoId = $procedimentoId;
}
public function passes($attribute, $value)
{
return self::isValid($this->procedimentoId, $value);
}
public static function isValid($procedimentoId, $value)
{
$procedimento = DB::table('sigtap.procedimento')
->where('id', $procedimentoId)
->select('quantidade_maxima_execucao')
->first();
return $value >= 0
&& $value <= $procedimento->quantidade_maxima_execucao;
}
public function message()
{
$procedimento = Procedimento::where('id', $this->procedimentoId)
->first(['codigo', 'nome', 'quantidade_maxima_execucao']);
$descricao = MaskUtil::getProcedimentoMasked($procedimento->codigo) . " - {$procedimento->nome}";
return "A quantidade máxima permitida para o procedimento {$descricao} é "
. $procedimento->quantidade_maxima_execucao;
}
}