49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\WebService\Laboratorio\ConectaSus;
|
|
|
|
use App\Enums\Parametrizacao\Exame\Tipo;
|
|
use App\Exceptions\WebService\Laboratorio\ConectaSus\ExameNotFoundException;
|
|
use App\Models\Parametrizacao\Exame\Exame;
|
|
use App\Services\Service;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ExameService extends Service
|
|
{
|
|
public static function index()
|
|
{
|
|
return DB::table('parametrizacao_exame AS exame')
|
|
->whereNull('exame.deleted_at')
|
|
->where('exame.ativo', true)
|
|
->where('exame.tipo_id', Tipo::LABORATORIAL)
|
|
->select([
|
|
'exame.id',
|
|
'exame.nome',
|
|
])
|
|
->orderBy('exame.nome')
|
|
->get();
|
|
}
|
|
|
|
public static function show($id)
|
|
{
|
|
$exame = self::getExameModel($id);
|
|
|
|
return (object) [
|
|
'id' => $exame->id,
|
|
'nome' => $exame->nome,
|
|
];
|
|
}
|
|
|
|
private static function getExameModel($id)
|
|
{
|
|
$exame = Exame::find($id);
|
|
|
|
if (is_null($exame)) {
|
|
|
|
throw new ExameNotFoundException();
|
|
}
|
|
|
|
return $exame;
|
|
}
|
|
}
|