This commit is contained in:
43
api/app/Rules/AtencaoBasica/Exportacao/ExameIsValid.php
Normal file
43
api/app/Rules/AtencaoBasica/Exportacao/ExameIsValid.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\AtencaoBasica\Exportacao;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class ExameIsValid implements Rule
|
||||
{
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return self::isValid($value);
|
||||
}
|
||||
|
||||
public static function isValid($value)
|
||||
{
|
||||
|
||||
$fields = [
|
||||
['data_realizacao_teste_olhinho', 'resultado_teste_olhinho_id'],
|
||||
['data_realizacao_fundo_olho', 'resultado_fundo_olho_id'],
|
||||
['data_realizacao_teste_orelhinha', 'resultado_teste_orelhinha_id'],
|
||||
['data_realizacao_us_transfontanela', 'resultado_us_transfontanela_id'],
|
||||
['data_realizacao_tomografia_computadorizada', 'resultado_tomografia_computadorizada_id'],
|
||||
['data_realizacao_ressonancia_magnetica', 'resultado_ressonancia_magnetica_id']
|
||||
];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
|
||||
$dataField = 'atencao_basica_ficha_complementar.' . $field[0];
|
||||
$resultField = 'atencao_basica_ficha_complementar.' . $field[1];
|
||||
|
||||
if (!empty($value->$dataField) && empty($value->$resultField)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return 'Exame com data preenchida e sem resultado.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user