589 lines
24 KiB
PHP
589 lines
24 KiB
PHP
<?php
|
|
|
|
namespace App\Services\ExameImagem;
|
|
|
|
use App\Enums\ExameImagem\Fechamento\Status;
|
|
use App\Enums\Parametrizacao\Exame\Tipo;
|
|
use App\Models\Cadastro\Estabelecimento\Unidade;
|
|
use App\Models\ExameImagem\Agendamento\AgendamentoExame;
|
|
use App\Models\ExameImagem\Fechamento\StatusFechamento;
|
|
use App\Models\Parametrizacao\Exame\Exame;
|
|
use App\Services\Service;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class RelatorioFinanceiroExameService extends Service
|
|
{
|
|
public static function index()
|
|
{
|
|
$params = request()->all();
|
|
|
|
$agendamentosBuilder = self::getAgendamentosBuilder();
|
|
|
|
if (!$agendamentosBuilder) {
|
|
|
|
return [];
|
|
}
|
|
|
|
$agendamentosBuilder = $agendamentosBuilder
|
|
->select(
|
|
'exame_imagem_agendamento_exame.id AS atendimento_id',
|
|
'cadastro_paciente.id AS paciente_id',
|
|
'exame_imagem_agendamento_exame.id AS id_paciente',
|
|
'cidadao.nome AS paciente_nome',
|
|
'medico_cidadao.nome AS medico_solicitante',
|
|
'parametrizacao_exame.id AS exame_id',
|
|
'parametrizacao_exame.nome AS exame_nome',
|
|
'parametrizacao_exame.codigo AS procedimento',
|
|
'parametrizacao_exame.valor AS valor',
|
|
'parametrizacao_exame.valor_sigtap AS valor_sigtap',
|
|
'sigtap.procedimento.valor_servico_ambilatorial AS valor_servico_ambilatorial',
|
|
'sigtap.procedimento.nome AS nome_procedimento',
|
|
'cadastro_grupo.nome AS grupo',
|
|
'cadastro_grupo.id AS grupo_exame_id',
|
|
'cadastro_unidade.nome_fantasia',
|
|
'cadastro_unidade_solicitante.nome_fantasia AS unidade_solicitante_nome',
|
|
|
|
DB::raw('LPAD(cadastro_paciente.prontuario,7,0) AS prontuario'),
|
|
DB::raw("DATE_FORMAT(exame_imagem_agendamento.data, '%d/%m/%Y') AS data"),
|
|
DB::raw("DATE_FORMAT(exame_imagem_agendamento.created_at, '%d/%m/%Y') AS data_pedido"),
|
|
DB::raw('IF (cidadao.data_nascimento IS NULL, "Não informada", DATE_FORMAT(cidadao.data_nascimento, "%d/%m/%Y")) as data_nascimento'),
|
|
DB::raw(
|
|
'(
|
|
CASE WHEN cidadao.nome_mae IS NULL THEN
|
|
"Não informado"
|
|
ELSE
|
|
cidadao.nome_mae
|
|
END
|
|
) as nome_mae'
|
|
),
|
|
DB::raw('CASE WHEN exame_imagem_agendamento_exame.status_id IS NULL THEN
|
|
"AGENDADO"
|
|
ELSE
|
|
exame_imagem_fechamento_status.nome
|
|
END AS status_nome'),
|
|
DB::raw('COUNT(exame_imagem_agendamento_exame.exame_id) AS quantidade'),
|
|
);
|
|
|
|
return $agendamentosBuilder
|
|
->orderBy('exame_imagem_agendamento_exame.created_at')
|
|
->get()
|
|
->map(function ($relatorio) {
|
|
|
|
return [
|
|
'exame_nome' => $relatorio->exame_nome,
|
|
'procedimento' => $relatorio->procedimento,
|
|
'nome_procedimento' => $relatorio->nome_procedimento,
|
|
'status_nome' => $relatorio->status_nome,
|
|
'quantidade' => $relatorio->quantidade,
|
|
'valor_unitario' => $relatorio->valor_sigtap ? $relatorio->valor_servico_ambilatorial : $relatorio->valor,
|
|
'valor' => $relatorio->valor,
|
|
'valor_servico_ambilatorial' => $relatorio->valor_servico_ambilatorial,
|
|
'unidade_solicitante_nome' => $relatorio->unidade_solicitante_nome,
|
|
'nome_fantasia' => $relatorio->nome_fantasia,
|
|
];
|
|
});
|
|
}
|
|
|
|
private static function getAgendamentosBuilder()
|
|
{
|
|
|
|
if (!request()->get('periodo')) {
|
|
|
|
return null;
|
|
}
|
|
|
|
$params = request()->all();
|
|
|
|
$agendamentos = DB::table('exame_imagem_agendamento_exame')
|
|
->join(
|
|
'exame_imagem_agendamento',
|
|
'exame_imagem_agendamento.id',
|
|
'exame_imagem_agendamento_exame.agendamento_id'
|
|
)
|
|
->join(
|
|
'cadastro_paciente',
|
|
'cadastro_paciente.id',
|
|
'exame_imagem_agendamento_exame.paciente_id'
|
|
)
|
|
->join(
|
|
'cadastro_cidadao AS cidadao',
|
|
'cidadao.id',
|
|
'cadastro_paciente.cidadao_id'
|
|
)
|
|
->join(
|
|
'cadastro_usuario',
|
|
'cadastro_usuario.id',
|
|
'exame_imagem_agendamento.medico_id'
|
|
)
|
|
->join(
|
|
'cadastro_cidadao AS medico_cidadao',
|
|
'medico_cidadao.id',
|
|
'cadastro_usuario.cidadao_id'
|
|
)
|
|
->leftJoin(
|
|
'exame_imagem_fechamento_status',
|
|
'exame_imagem_fechamento_status.id',
|
|
'exame_imagem_agendamento_exame.status_id'
|
|
)
|
|
->join(
|
|
'parametrizacao_exame',
|
|
'parametrizacao_exame.id',
|
|
'exame_imagem_agendamento_exame.exame_id'
|
|
)
|
|
->join(
|
|
'cadastro_grupo',
|
|
'cadastro_grupo.id',
|
|
'exame_imagem_agendamento.exame_id'
|
|
)
|
|
->join(
|
|
'cadastro_infraestrutura',
|
|
'cadastro_infraestrutura.id',
|
|
'exame_imagem_agendamento.infraestrutura_id'
|
|
)
|
|
->join(
|
|
'cadastro_unidade',
|
|
'cadastro_unidade.id',
|
|
'cadastro_infraestrutura.unidade_id'
|
|
)
|
|
->join(
|
|
'cadastro_infraestrutura AS cadastro_infraestrutura_solicitante',
|
|
'cadastro_infraestrutura_solicitante.id',
|
|
'exame_imagem_agendamento.infraestrutura_solicitante_id'
|
|
)
|
|
->join(
|
|
'cadastro_unidade AS cadastro_unidade_solicitante',
|
|
'cadastro_unidade_solicitante.id',
|
|
'cadastro_infraestrutura_solicitante.unidade_id'
|
|
)
|
|
->leftJoin('sigtap.procedimento', function ($join) {
|
|
|
|
$join->on('sigtap.procedimento.codigo', 'parametrizacao_exame.codigo')
|
|
->where('sigtap.procedimento.competencia_id', '=', function ($query) {
|
|
|
|
$query->select('sigtap.competencia.id')
|
|
->from('sigtap.competencia')
|
|
->orderByDesc('sigtap.competencia.valor')
|
|
->limit(1);
|
|
});
|
|
})
|
|
->leftJoin(
|
|
'parametrizacao_procedimento',
|
|
'parametrizacao_procedimento.procedimento_codigo',
|
|
'parametrizacao_exame.codigo'
|
|
)
|
|
->groupBy('exame_id')
|
|
->orderBy('cidadao.nome')
|
|
->whereBetween('exame_imagem_agendamento.data', [
|
|
Carbon::createFromFormat('d/m/Y', $params['periodo']['start'])->setTime(0, 0, 0),
|
|
Carbon::createFromFormat('d/m/Y', $params['periodo']['end'])->setTime(23, 59, 59)
|
|
])
|
|
->where(function ($query) use ($params) {
|
|
|
|
if (!is_null($params['unidade_id'])) {
|
|
|
|
$query->where('exame_imagem_agendamento.unidade_id', $params['unidade_id']);
|
|
}
|
|
})
|
|
->where(function ($query) use ($params) {
|
|
|
|
if (!is_null($params['unidade_solicitante_id'])) {
|
|
|
|
$query->where('exame_imagem_agendamento.unidade_solicitante_id', $params['unidade_solicitante_id']);
|
|
}
|
|
})
|
|
->where(function ($query) use ($params) {
|
|
|
|
if (!is_null($params['procedimento'])) {
|
|
|
|
$query->where('parametrizacao_exame.codigo', $params['procedimento']);
|
|
}
|
|
})
|
|
->where(function ($query) use ($params) {
|
|
|
|
if (!is_null($params['exame_id'])) {
|
|
|
|
$query->where('exame_imagem_agendamento_exame.exame_id', $params['exame_id']);
|
|
}
|
|
});
|
|
|
|
return $agendamentos;
|
|
}
|
|
|
|
public static function list()
|
|
{
|
|
$now = Carbon::now();
|
|
$currentDate = $now->format('d/m/Y');
|
|
$currentLotacao = self::getCurrentLotacao();
|
|
|
|
return [
|
|
'form' => self::getForm(),
|
|
'model' => [
|
|
'periodo' => [
|
|
'start' => $currentDate,
|
|
'end' => $currentDate,
|
|
],
|
|
'atendimento' => null,
|
|
'prontuario' => null,
|
|
'lancamentos' => [],
|
|
'paciente' => null,
|
|
'exame' => null,
|
|
'relatorioFinanceiroExame' => self::getFinanceiroExame(),
|
|
],
|
|
'additionals' => [
|
|
'periodo_min_date' => $now->copy()->subYears(130)->format('d/m/Y'),
|
|
'current_date' => $now->format('d/m/Y')
|
|
]
|
|
];
|
|
}
|
|
|
|
public static function datatable(Request $request)
|
|
{
|
|
$agendamentos = DB::table('exame_imagem_agendamento_exame')
|
|
->select(
|
|
'exame_imagem_agendamento_exame.id AS atendimento_id',
|
|
'cadastro_paciente.id AS paciente_id',
|
|
'exame_imagem_agendamento_exame.id AS id_paciente',
|
|
'exame_imagem_agendamento.unidade_id',
|
|
'cidadao.nome AS paciente_nome',
|
|
'medico_cidadao.nome AS medico_solicitante',
|
|
'parametrizacao_exame.id AS exame_id',
|
|
'parametrizacao_exame.nome AS exame_nome',
|
|
'parametrizacao_exame.codigo AS procedimento',
|
|
'parametrizacao_exame.valor AS valor',
|
|
'parametrizacao_exame.valor_sigtap AS valor_sigtap',
|
|
'sigtap.procedimento.valor_servico_ambilatorial AS valor_servico_ambilatorial',
|
|
'sigtap.procedimento.nome AS nome_procedimento',
|
|
'cadastro_unidade.nome_fantasia',
|
|
'cadastro_unidade_solicitante.nome_fantasia AS unidade_solicitante_nome',
|
|
'cadastro_unidade_solicitante.id AS unidade_solicitante_id',
|
|
DB::raw("DATE_FORMAT(exame_imagem_agendamento.data, '%d/%m/%Y') AS data"),
|
|
DB::raw("DATE_FORMAT(exame_imagem_agendamento.created_at, '%d/%m/%Y') AS data_pedido"),
|
|
DB::raw('CASE WHEN exame_imagem_agendamento_exame.status_id IS NULL THEN
|
|
"AGENDADO"
|
|
ELSE
|
|
exame_imagem_fechamento_status.nome
|
|
END AS status_nome'),
|
|
DB::raw('COUNT(exame_imagem_agendamento_exame.exame_id) AS quantidade'),
|
|
)
|
|
->join(
|
|
'exame_imagem_agendamento',
|
|
'exame_imagem_agendamento.id',
|
|
'exame_imagem_agendamento_exame.agendamento_id'
|
|
)
|
|
->join(
|
|
'cadastro_paciente',
|
|
'cadastro_paciente.id',
|
|
'exame_imagem_agendamento_exame.paciente_id'
|
|
)
|
|
->join(
|
|
'cadastro_cidadao AS cidadao',
|
|
'cidadao.id',
|
|
'cadastro_paciente.cidadao_id'
|
|
)
|
|
->join(
|
|
'cadastro_usuario',
|
|
'cadastro_usuario.id',
|
|
'exame_imagem_agendamento.medico_id'
|
|
)
|
|
->join(
|
|
'cadastro_cidadao AS medico_cidadao',
|
|
'medico_cidadao.id',
|
|
'cadastro_usuario.cidadao_id'
|
|
)
|
|
->leftJoin(
|
|
'exame_imagem_fechamento_status',
|
|
'exame_imagem_fechamento_status.id',
|
|
'exame_imagem_agendamento_exame.status_id'
|
|
)
|
|
->join(
|
|
'parametrizacao_exame',
|
|
'parametrizacao_exame.id',
|
|
'exame_imagem_agendamento_exame.exame_id'
|
|
)
|
|
->leftJoin('sigtap.procedimento', function ($join) {
|
|
|
|
$join->on('sigtap.procedimento.codigo', 'parametrizacao_exame.codigo')
|
|
->where('sigtap.procedimento.competencia_id', '=', function ($query) {
|
|
|
|
$query->select('sigtap.competencia.id')
|
|
->from('sigtap.competencia')
|
|
->orderByDesc('sigtap.competencia.valor')
|
|
->limit(1);
|
|
});
|
|
})
|
|
->leftJoin(
|
|
'parametrizacao_procedimento',
|
|
'parametrizacao_procedimento.procedimento_codigo',
|
|
'parametrizacao_exame.codigo'
|
|
)
|
|
->join(
|
|
'cadastro_infraestrutura',
|
|
'cadastro_infraestrutura.id',
|
|
'exame_imagem_agendamento.infraestrutura_id'
|
|
)
|
|
->join(
|
|
'cadastro_unidade',
|
|
'cadastro_unidade.id',
|
|
'cadastro_infraestrutura.unidade_id'
|
|
)
|
|
->join(
|
|
'cadastro_infraestrutura AS cadastro_infraestrutura_solicitante',
|
|
'cadastro_infraestrutura_solicitante.id',
|
|
'exame_imagem_agendamento.infraestrutura_solicitante_id'
|
|
)
|
|
->join(
|
|
'cadastro_unidade AS cadastro_unidade_solicitante',
|
|
'cadastro_unidade_solicitante.id',
|
|
'cadastro_infraestrutura_solicitante.unidade_id'
|
|
)
|
|
->groupBy('exame_id')
|
|
->orderBy('cidadao.nome')
|
|
->where(function ($query) {
|
|
|
|
$query->where('exame_imagem_agendamento_exame.status_id', Status::AGENDADO)
|
|
->orWhere('exame_imagem_agendamento_exame.status_id', Status::REALIZADO)
|
|
->orWhere('exame_imagem_agendamento_exame.status_id', NULL);
|
|
})
|
|
->whereBetween('exame_imagem_agendamento.data', [
|
|
Carbon::createFromFormat('d/m/Y', $request->periodo['start'])->setTime(0, 0, 0),
|
|
Carbon::createFromFormat('d/m/Y', $request->periodo['end'])->setTime(23, 59, 59)
|
|
])
|
|
->when($request->unidade_id, function ($query, $value) {
|
|
|
|
$query->where('exame_imagem_agendamento.unidade_id', $value);
|
|
})
|
|
->when($request->unidade_solicitante_id, function ($query, $value) {
|
|
|
|
$query->where('exame_imagem_agendamento.unidade_solicitante_id', $value);
|
|
})
|
|
->when($request->exame_id, function ($query, $value) {
|
|
|
|
$query->where('exame_imagem_agendamento_exame.exame_id', $value);
|
|
})
|
|
->when($request->procedimento, function ($query, $value) {
|
|
|
|
$query->where('parametrizacao_exame.codigo', $value);
|
|
});
|
|
|
|
$agendamentos = $agendamentos->get();
|
|
|
|
return $agendamentos
|
|
->map(function ($relatorio) {
|
|
|
|
return [
|
|
'exame_nome' => $relatorio->exame_nome,
|
|
'status_nome' => $relatorio->status_nome,
|
|
'procedimento' => $relatorio->procedimento,
|
|
'nome_procedimento' => $relatorio->nome_procedimento,
|
|
'valorUnitario' => $relatorio->valor_sigtap ? $relatorio->valor_servico_ambilatorial : $relatorio->valor,
|
|
'valor' => $relatorio->valor,
|
|
'valor_servico_ambilatorial' => $relatorio->valor_servico_ambilatorial,
|
|
'quantidade' => $relatorio->quantidade,
|
|
'unidade_solicitante_nome' => $relatorio->unidade_solicitante_nome,
|
|
'nome_fantasia' => $relatorio->nome_fantasia,
|
|
];
|
|
});
|
|
}
|
|
|
|
private static function getFinanceiroExame()
|
|
{
|
|
$agendamentos = DB::table('exame_imagem_agendamento_exame')
|
|
->select(
|
|
'exame_imagem_agendamento_exame.id AS id_paciente',
|
|
'exame_imagem_agendamento_exame.agendamento_id AS agendamento_id',
|
|
'exame_imagem_agendamento.medico_id',
|
|
'exame_imagem_agendamento.unidade_id',
|
|
'exame_imagem_agendamento.profissional_id',
|
|
'exame_imagem_agendamento.agendamento_numero AS agendamento_numero',
|
|
'exame_imagem_agendamento.jornada_id AS jornada_agendamento',
|
|
'cadastro_unidade.nome_fantasia',
|
|
'medico_cidadao.nome AS medico_solicitante',
|
|
'profissional.nome AS profissional_nome',
|
|
'cadastro_unidade_solicitante.nome_fantasia AS unidade_solicitante_nome',
|
|
'cadastro_unidade_solicitante.id AS unidade_solicitante_id',
|
|
'cadastro_paciente.id AS paciente_id',
|
|
'cadastro_grupo.nome AS grupo',
|
|
'cadastro_grupo.id AS grupo_exame_id',
|
|
'cidadao.nome AS paciente_nome',
|
|
'exame_imagem_jornada.id AS jornada_id',
|
|
'exame_imagem_jornada.status_id AS jornada_status_id',
|
|
'parametrizacao_exame.id AS exame_id',
|
|
'parametrizacao_exame.nome AS exame_nome',
|
|
|
|
DB::raw('DATE_FORMAT(exame_imagem_agendamento.hora_exame, "%H:%i") AS hora_exame'),
|
|
DB::raw("DATE_FORMAT(exame_imagem_agendamento.data, '%d/%m/%Y') AS data"),
|
|
DB::raw("DATE_FORMAT(exame_imagem_agendamento.created_at, '%d/%m/%Y') AS data_pedido"),
|
|
DB::raw('LPAD(cadastro_paciente.prontuario,7,0) AS prontuario'),
|
|
DB::raw('IF (cidadao.data_nascimento IS NULL, "Não informada", DATE_FORMAT(cidadao.data_nascimento, "%d/%m/%Y")) as data_nascimento'),
|
|
DB::raw("
|
|
(
|
|
SELECT cadastro_cidadao_telefone.numero
|
|
FROM cadastro_cidadao_telefone
|
|
WHERE cadastro_cidadao_telefone.principal = TRUE
|
|
AND cadastro_cidadao_telefone.cidadao_id = cadastro_paciente.cidadao_id
|
|
AND cadastro_cidadao_telefone.deleted_at IS NULL
|
|
LIMIT 1
|
|
) AS paciente_telefone
|
|
"),
|
|
DB::raw(
|
|
'(
|
|
CASE WHEN cidadao.nome_mae IS NULL THEN
|
|
"Não informado"
|
|
ELSE
|
|
cidadao.nome_mae
|
|
END
|
|
) as nome_mae'
|
|
),
|
|
)
|
|
->join(
|
|
'exame_imagem_agendamento',
|
|
'exame_imagem_agendamento.id',
|
|
'exame_imagem_agendamento_exame.agendamento_id'
|
|
)
|
|
->join(
|
|
'cadastro_infraestrutura',
|
|
'cadastro_infraestrutura.id',
|
|
'exame_imagem_agendamento.infraestrutura_id'
|
|
)
|
|
->join(
|
|
'cadastro_unidade',
|
|
'cadastro_unidade.id',
|
|
'cadastro_infraestrutura.unidade_id'
|
|
)
|
|
->join(
|
|
'cadastro_infraestrutura AS cadastro_infraestrutura_solicitante',
|
|
'cadastro_infraestrutura_solicitante.id',
|
|
'exame_imagem_agendamento.infraestrutura_solicitante_id'
|
|
)
|
|
->join(
|
|
'cadastro_unidade AS cadastro_unidade_solicitante',
|
|
'cadastro_unidade_solicitante.id',
|
|
'cadastro_infraestrutura_solicitante.unidade_id'
|
|
)
|
|
->join(
|
|
'cadastro_usuario',
|
|
'cadastro_usuario.id',
|
|
'exame_imagem_agendamento.medico_id'
|
|
)
|
|
->join(
|
|
'cadastro_cidadao AS medico_cidadao',
|
|
'medico_cidadao.id',
|
|
'cadastro_usuario.cidadao_id'
|
|
)
|
|
->join(
|
|
'cadastro_usuario AS profissional_cidadao',
|
|
'profissional_cidadao.id',
|
|
'exame_imagem_agendamento.profissional_id'
|
|
)
|
|
->join(
|
|
'cadastro_cidadao AS profissional',
|
|
'profissional.id',
|
|
'profissional_cidadao.cidadao_id'
|
|
)
|
|
->join(
|
|
'cadastro_cidadao AS cadastro_cidadao_usuario',
|
|
'cadastro_cidadao_usuario.id',
|
|
'cadastro_usuario.cidadao_id'
|
|
)
|
|
->join(
|
|
'parametrizacao_exame',
|
|
'parametrizacao_exame.id',
|
|
'exame_imagem_agendamento_exame.exame_id'
|
|
)
|
|
->join(
|
|
'cadastro_grupo',
|
|
'cadastro_grupo.id',
|
|
'exame_imagem_agendamento.exame_id'
|
|
)
|
|
->join(
|
|
'exame_imagem_jornada',
|
|
'exame_imagem_jornada.id',
|
|
'exame_imagem_agendamento.jornada_id'
|
|
)
|
|
->leftJoin(
|
|
'cadastro_usuario_registro_tipo',
|
|
'cadastro_usuario_registro_tipo.id',
|
|
'profissional_cidadao.registro_tipo_id'
|
|
)
|
|
->leftJoin(
|
|
'cadastro_paciente',
|
|
'cadastro_paciente.id',
|
|
'exame_imagem_agendamento_exame.paciente_id'
|
|
)
|
|
->leftJoin(
|
|
'cadastro_cidadao AS cidadao',
|
|
'cidadao.id',
|
|
'cadastro_paciente.cidadao_id'
|
|
)
|
|
->where(function ($query) {
|
|
|
|
$query->where('exame_imagem_agendamento_exame.status_id', Status::AGENDADO)
|
|
->orWhere('exame_imagem_agendamento_exame.status_id', Status::REALIZADO)
|
|
->orWhere('exame_imagem_agendamento_exame.status_id', NULL);
|
|
});
|
|
|
|
$agendamentos = $agendamentos->get();
|
|
|
|
return $agendamentos;
|
|
}
|
|
|
|
private static function getForm()
|
|
{
|
|
return [
|
|
'unidadesSolicitantes' => self::getUnidadesSolicitantes(),
|
|
'unidadesExecutantes' => self::getUnidadesExecutantes(),
|
|
'exames' => self::getExames(),
|
|
];
|
|
}
|
|
|
|
private static function getUnidadesSolicitantes()
|
|
{
|
|
return Unidade::orderBy('nome_fantasia')
|
|
->get()
|
|
->map(function ($query) {
|
|
return [
|
|
'id' => $query->id,
|
|
'nome_fantasia' => $query->nome_fantasia,
|
|
'infraestruturas' => $query->infraestruturas->sortBy('nome')->map(fn ($infraestrutura) => [
|
|
'id' => $infraestrutura->id,
|
|
'nome' => $infraestrutura->nome,
|
|
'principal' => $infraestrutura->principal,
|
|
])->values()
|
|
];
|
|
});
|
|
}
|
|
|
|
private static function getUnidadesExecutantes()
|
|
{
|
|
return Unidade::orderBy('nome_fantasia')
|
|
->get()
|
|
->map(function ($query) {
|
|
return [
|
|
'id' => $query->id,
|
|
'nome_fantasia' => $query->nome_fantasia,
|
|
'infraestruturas' => $query->infraestruturas->sortBy('nome')->map(fn ($infraestrutura) => [
|
|
'id' => $infraestrutura->id,
|
|
'nome' => $infraestrutura->nome,
|
|
'principal' => $infraestrutura->principal,
|
|
])->values()
|
|
];
|
|
});
|
|
}
|
|
|
|
private static function getExames()
|
|
{
|
|
return Exame::where('tipo_id', Tipo::IMAGEM)
|
|
->orderBy('nome')
|
|
->get()
|
|
->map(function ($query) {
|
|
return [
|
|
'id' => $query->id,
|
|
'nome' => $query->nome,
|
|
];
|
|
})
|
|
->values();
|
|
}
|
|
}
|