0, ]; $periodo = [ 'start' => Carbon::createFromFormat('d/m/Y', request()->periodo['start'])->startOfDay(), 'end' => Carbon::createFromFormat('d/m/Y', request()->periodo['end'])->endOfDay(), ]; $procedimentosBuilder = DB::query() ->fromSub(DB::table('sigtap.procedimento as procedimento') ->join('ambulatorio_atendimento_procedimento as atendimento_procedimento', 'atendimento_procedimento.procedimento_id', 'procedimento.id') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_agendamento as agendamento', 'agendamento.id', 'atendimento.agendamento_id') ->join('cadastro_paciente as paciente', 'paciente.id', 'agendamento.paciente_id') ->join('cadastro_cidadao as paciente_cidadao', 'paciente_cidadao.id', 'paciente.cidadao_id') ->join('ambulatorio_jornada as jornada', 'jornada.id', 'agendamento.jornada_id') ->join('cadastro_lotacao as lotacao', 'lotacao.id', 'jornada.lotacao_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'lotacao.infraestrutura_id') ->join('sigtap.ocupacao as ocupacao', 'ocupacao.id', 'atendimento_procedimento.ocupacao_id') ->join('cadastro_usuario as usuario', 'usuario.id', 'atendimento_procedimento.usuario_id') ->join('cadastro_cidadao as cidadao', 'cidadao.id', 'usuario.cidadao_id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('jornada.data', $periodo) ->when(request()->unidade_id, fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when(request()->infraestrutura_id, fn ($q, $id) => $q->where('lotacao.infraestrutura_id', $id)) ->when(request()->ocupacao_id, fn ($q, $id) => $q->where('atendimento_procedimento.ocupacao_id', $id)) ->when(request()->usuario_id, fn ($q, $id) => $q->where('atendimento_procedimento.usuario_id', $id)) ->when(request()->procedimento_codigo, fn ($q, $codigo) => $q->where('procedimento.codigo', $codigo)) ->when(request()->idade_de, fn ($q, $idadeDe) => $q ->whereRaw("TIMESTAMPDIFF(YEAR, paciente_cidadao.data_nascimento, NOW()) >= {$idadeDe}") ) ->when(request()->idade_ate, fn ($q, $idadeAte) => $q ->whereRaw("TIMESTAMPDIFF(YEAR, paciente_cidadao.data_nascimento, NOW()) <= {$idadeAte}") ) ->whereNull('lotacao.deleted_at') ->whereNull('infraestrutura.deleted_at') ->selectRaw(" procedimento.codigo as procedimento_codigo, procedimento.nome as procedimento_nome, ocupacao.codigo as ocupacao_codigo, ocupacao.nome as ocupacao_nome, usuario.id as usuario_id, cidadao.nome as usuario_nome, SUM(atendimento_procedimento.quantidade) as quantidade ") ->groupByRaw(" procedimento.codigo, ocupacao.codigo, usuario.id ") ->unionAll(DB::table('sigtap.procedimento as procedimento') ->join('ambulatorio_atendimento_procedimento as atendimento_procedimento', 'atendimento_procedimento.procedimento_id', 'procedimento.id') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_demanda_espontanea as demanda_espontanea', 'demanda_espontanea.id', 'atendimento.demanda_espontanea_id') ->join('cadastro_paciente as paciente', 'paciente.id', 'demanda_espontanea.paciente_id') ->join('cadastro_cidadao as paciente_cidadao', 'paciente_cidadao.id', 'paciente.cidadao_id') ->join('cadastro_centro_custo as centro_custo', 'centro_custo.id', 'demanda_espontanea.created_centro_custo_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'centro_custo.infraestrutura_id') ->join('sigtap.ocupacao as ocupacao', 'ocupacao.id', 'atendimento_procedimento.ocupacao_id') ->join('cadastro_usuario as usuario', 'usuario.id', 'atendimento_procedimento.usuario_id') ->join('cadastro_cidadao as cidadao', 'cidadao.id', 'usuario.cidadao_id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('demanda_espontanea.data', $periodo) ->when(request()->unidade_id, fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when(request()->infraestrutura_id, fn ($q, $id) => $q->where('centro_custo.infraestrutura_id', $id)) ->when(request()->ocupacao_id, fn ($q, $id) => $q->where('atendimento_procedimento.ocupacao_id', $id)) ->when(request()->usuario_id, fn ($q, $id) => $q->where('atendimento_procedimento.usuario_id', $id)) ->when(request()->procedimento_codigo, fn ($q, $codigo) => $q->where('procedimento.codigo', $codigo)) ->when(request()->idade_de, fn ($q, $idadeDe) => $q ->whereRaw("TIMESTAMPDIFF(YEAR, paciente_cidadao.data_nascimento, NOW()) >= {$idadeDe}") ) ->when(request()->idade_ate, fn ($q, $idadeAte) => $q ->whereRaw("TIMESTAMPDIFF(YEAR, paciente_cidadao.data_nascimento, NOW()) <= {$idadeAte}") ) ->whereNull('centro_custo.deleted_at') ->whereNull('infraestrutura.deleted_at') ->selectRaw(" procedimento.codigo as procedimento_codigo, procedimento.nome as procedimento_nome, ocupacao.codigo as ocupacao_codigo, ocupacao.nome as ocupacao_nome, usuario.id as usuario_id, cidadao.nome as usuario_nome, SUM(atendimento_procedimento.quantidade) as quantidade ") ->groupByRaw(" procedimento.codigo, ocupacao.codigo, usuario.id ") ) , 'sub') ->groupByRaw(" sub.procedimento_codigo, sub.ocupacao_codigo, sub.usuario_id ") ->selectRaw(" sub.procedimento_codigo, sub.procedimento_nome, sub.ocupacao_codigo, sub.ocupacao_nome, sub.usuario_nome, SUM(sub.quantidade) as quantidade "); self::setOrderBy($procedimentosBuilder); $procedimentos = $procedimentosBuilder->get(); $procedimentos->each(function ($procedimento) use ($totalizadores) { $procedimento->procedimento_codigo = MaskUtil::getProcedimentoMasked($procedimento->procedimento_codigo); $totalizadores->quantidade += $procedimento->quantidade; }); return compact('procedimentos', 'totalizadores'); } public static function list() { $data = (object) [ 'additionals' => [], 'form' => [], 'model' => [], ]; $params = self::getParams(); $sets = [ 'periodo' => function () use ($data) { $data->model['periodo'] = ['start' => null, 'end' => null]; }, 'unidade' => function () use ($data, $params) { $unidadesData = self::getUnidadesData($params); $data->form['unidades'] = $unidadesData['form']; $data->model['unidade_id'] = $unidadesData['model']; }, 'infraestrutura' => function () use ($data, $params) { $infraestruturasData = self::getInfraestruturasData($params); $data->form['infraestruturas'] = $infraestruturasData['form']; $data->model['infraestrutura_id'] = $infraestruturasData['model']; }, 'ocupacao' => function () use ($data, $params) { $ocupacoesData = self::getOcupacoesData($params); $data->form['ocupacoes'] = $ocupacoesData['form']; $data->model['ocupacao_id'] = $ocupacoesData['model']; }, 'usuario' => function () use ($data, $params) { $usuarioData = self::getUsuariosData($params); $data->form['usuarios'] = $usuarioData['form']; $data->model['usuario_id'] = $usuarioData['model']; }, 'procedimento' => function () use ($data, $params) { $procedimentosData = self::getProcedimentosData($params); $data->form['procedimentos'] = $procedimentosData['form']; $data->model['procedimento_codigo'] = $procedimentosData['model']; }, ]; $load = is_null(request()->load_from); if ($load) { $data->additionals = [ 'data_atual' => Carbon::today()->format('d/m/Y') ]; $data->model['idade_de'] = null; $data->model['idade_ate'] = null; } foreach ($sets as $field => $set) { if ($load) { $set(); } else if ($field === request()->load_from) { $load = true; } } foreach ($data as $property => $itens) { if (empty($itens)) { unset($data->{$property}); } } return $data; } private static function getParams() { $params = request()->only([ 'periodo', 'unidade_id', 'infraestrutura_id', 'ocupacao_id', 'usuario_id', 'procedimento_codigo', ]); if (isset($params['periodo']) && !is_null($params['periodo']['start']) && !is_null($params['periodo']['end']) ) { $start = Carbon::createFromFormat('d/m/Y', $params['periodo']['start'])->startOfDay(); $end = Carbon::createFromFormat('d/m/Y', $params['periodo']['end'])->endOfDay(); $params['periodo']['start'] = $start; $params['periodo']['end'] = $end; } else { $params['periodo'] = null; } return $params; } private static function getUnidadesData($params) { $unidades = collect(); $id = null; if (!is_null($params['periodo'])) { $unidades = DB::table('cadastro_unidade as unidade') ->whereExists(fn ($q) => $q ->selectRaw(1) ->from('cadastro_infraestrutura as infraestrutura') ->where(fn ($q) => $q ->whereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_atendimento_procedimento as atendimento_procedimento') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_agendamento as agendamento', 'agendamento.id', 'atendimento.agendamento_id') ->join('ambulatorio_jornada as jornada', 'jornada.id', 'agendamento.jornada_id') ->join('cadastro_lotacao as lotacao', 'lotacao.id', 'jornada.lotacao_id') ->whereColumn('lotacao.infraestrutura_id', 'infraestrutura.id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('jornada.data', $params['periodo']) ->whereNull('lotacao.deleted_at') ) ->orWhereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_atendimento_procedimento as atendimento_procedimento') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_demanda_espontanea as demanda_espontanea', 'demanda_espontanea.id', 'atendimento.demanda_espontanea_id') ->join('cadastro_centro_custo as centro_custo', 'centro_custo.id', 'demanda_espontanea.created_centro_custo_id') ->whereColumn('centro_custo.infraestrutura_id', 'infraestrutura.id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('demanda_espontanea.data', $params['periodo']) ->whereNull('centro_custo.deleted_at') ) ) ->whereColumn('infraestrutura.unidade_id', 'unidade.id') ->whereNull('infraestrutura.deleted_at') ) ->whereNull('unidade.deleted_at') ->orderBy('unidade.nome_fantasia') ->selectRaw(" unidade.id, unidade.nome_fantasia ") ->get(); } return ['form' => $unidades, 'model' => $id]; } private static function getInfraestruturasData($params) { $infraestruturas = collect(); $id = null; if (!is_null($params['periodo']) && !is_null($params['unidade_id'])) { $infraestruturas = DB::table('cadastro_infraestrutura as infraestrutura') ->join('cadastro_unidade as unidade', 'unidade.id', 'infraestrutura.unidade_id') ->where('infraestrutura.unidade_id', $params['unidade_id']) ->where(fn ($q) => $q ->whereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_atendimento_procedimento as atendimento_procedimento') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_agendamento as agendamento', 'agendamento.id', 'atendimento.agendamento_id') ->join('ambulatorio_jornada as jornada', 'jornada.id', 'agendamento.jornada_id') ->join('cadastro_lotacao as lotacao', 'lotacao.id', 'jornada.lotacao_id') ->whereColumn('lotacao.infraestrutura_id', 'infraestrutura.id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('jornada.data', $params['periodo']) ->whereNull('lotacao.deleted_at') ) ->orWhereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_atendimento_procedimento as atendimento_procedimento') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_demanda_espontanea as demanda_espontanea', 'demanda_espontanea.id', 'atendimento.demanda_espontanea_id') ->join('cadastro_centro_custo as centro_custo', 'centro_custo.id', 'demanda_espontanea.created_centro_custo_id') ->whereColumn('centro_custo.infraestrutura_id', 'infraestrutura.id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('demanda_espontanea.data', $params['periodo']) ->whereNull('centro_custo.deleted_at') ) ) ->whereNull('infraestrutura.deleted_at') ->whereNull('unidade.deleted_at') ->orderByRaw("COALESCE(infraestrutura.nome, unidade.nome_fantasia)") ->selectRaw(" infraestrutura.id, COALESCE(infraestrutura.nome, unidade.nome_fantasia) as nome ") ->get(); } return ['form' => $infraestruturas, 'model' => $id]; } private static function getOcupacoesData($params) { $ocupacoes = collect(); $id = null; if (!is_null($params['periodo'])) { $ocupacoes = DB::table('sigtap.ocupacao as ocupacao') ->where(fn ($q) => $q ->whereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_atendimento_procedimento as atendimento_procedimento') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_agendamento as agendamento', 'agendamento.id', 'atendimento.agendamento_id') ->join('ambulatorio_jornada as jornada', 'jornada.id', 'agendamento.jornada_id') ->join('cadastro_lotacao as lotacao', 'lotacao.id', 'jornada.lotacao_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'lotacao.infraestrutura_id') ->whereColumn('atendimento_procedimento.ocupacao_id', 'ocupacao.id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('jornada.data', $params['periodo']) ->when($params['unidade_id'], fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when($params['infraestrutura_id'], fn ($q, $id) => $q->where('lotacao.infraestrutura_id', $id)) ->whereNull('lotacao.deleted_at') ->whereNull('infraestrutura.deleted_at') ) ->orWhereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_atendimento_procedimento as atendimento_procedimento') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_demanda_espontanea as demanda_espontanea', 'demanda_espontanea.id', 'atendimento.demanda_espontanea_id') ->join('cadastro_centro_custo as centro_custo', 'centro_custo.id', 'demanda_espontanea.created_centro_custo_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'centro_custo.infraestrutura_id') ->whereColumn('atendimento_procedimento.ocupacao_id', 'ocupacao.id') ->whereNotNull('atendimento.finalizado_em') ->whereBetween('demanda_espontanea.data', $params['periodo']) ->when($params['unidade_id'], fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when($params['infraestrutura_id'], fn ($q, $id) => $q->where('centro_custo.infraestrutura_id', $id)) ->whereNull('centro_custo.deleted_at') ->whereNull('infraestrutura.deleted_at') ) ) ->orderByRaw("CONCAT(ocupacao.codigo, ' - ', ocupacao.nome)") ->selectRaw(" ocupacao.id, CONCAT(ocupacao.codigo, ' - ', ocupacao.nome) as descricao ") ->get(); } return ['form' => $ocupacoes, 'model' => $id]; } private static function getUsuariosData($params) { $usuarios = collect(); $id = null; if (!is_null($params['periodo'])) { $usuarios = DB::table('cadastro_usuario as usuario') ->join('cadastro_cidadao as cidadao', 'cidadao.id', 'usuario.cidadao_id') ->where(fn ($q) => $q ->whereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_agendamento as agendamento') ->join('ambulatorio_jornada as jornada', 'jornada.id', 'agendamento.jornada_id') ->join('ambulatorio_atendimento as atendimento', 'atendimento.agendamento_id', 'agendamento.id') ->join('cadastro_lotacao as lotacao', 'lotacao.id', 'jornada.lotacao_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'lotacao.infraestrutura_id') ->join('ambulatorio_atendimento_procedimento as atendimento_procedimento', 'atendimento_procedimento.atendimento_id', 'atendimento.id') ->whereColumn('atendimento_procedimento.usuario_id', 'usuario.id') ->whereBetween('jornada.data', $params['periodo']) ->when($params['unidade_id'], fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when($params['infraestrutura_id'], fn ($q, $id) => $q->where('lotacao.infraestrutura_id', $id)) ->when($params['ocupacao_id'], fn ($q, $id) => $q->where('atendimento_procedimento.ocupacao_id', $id)) ->whereNotNull('atendimento.finalizado_em') ->whereNull('lotacao.deleted_at') ->whereNull('infraestrutura.deleted_at') ) ->orWhereExists(fn ($q) => $q ->selectRaw(1) ->from('ambulatorio_demanda_espontanea as demanda_espontanea') ->join('ambulatorio_atendimento as atendimento', 'atendimento.demanda_espontanea_id', 'demanda_espontanea.id') ->join('cadastro_centro_custo as centro_custo', 'centro_custo.id', 'demanda_espontanea.created_centro_custo_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'centro_custo.infraestrutura_id') ->join('ambulatorio_atendimento_procedimento as atendimento_procedimento', 'atendimento_procedimento.atendimento_id', 'atendimento.id') ->whereColumn('atendimento_procedimento.usuario_id', 'usuario.id') ->whereBetween('demanda_espontanea.data', $params['periodo']) ->when($params['unidade_id'], fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when($params['infraestrutura_id'], fn ($q, $id) => $q->where('centro_custo.infraestrutura_id', $id)) ->when($params['ocupacao_id'], fn ($q, $id) => $q->where('atendimento_procedimento.ocupacao_id', $id)) ->whereNotNull('atendimento.finalizado_em') ->whereNull('centro_custo.deleted_at') ->whereNull('infraestrutura.deleted_at') ) ) ->orderBy('cidadao.nome') ->selectRaw(" usuario.id, cidadao.nome ") ->get(); } return ['form' => $usuarios, 'model' => $id]; } private static function getProcedimentosData($params) { $procedimentos = collect(); $codigo = null; if (!is_null($params['periodo'])) { $procedimentos = DB::table('sigtap.procedimento as procedimento') ->join('ambulatorio_atendimento_procedimento as atendimento_procedimento', 'atendimento_procedimento.procedimento_id', 'procedimento.id') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_agendamento as agendamento', 'agendamento.id', 'atendimento.agendamento_id') ->join('ambulatorio_jornada as jornada', 'jornada.id', 'agendamento.jornada_id') ->join('cadastro_lotacao as lotacao', 'lotacao.id', 'jornada.lotacao_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'lotacao.infraestrutura_id') ->whereNotNull('atendimento.finalizado_em') ->whereNull('lotacao.deleted_at') ->whereNull('infraestrutura.deleted_at') ->whereBetween('jornada.data', $params['periodo']) ->when($params['unidade_id'], fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when($params['infraestrutura_id'], fn ($q, $id) => $q->where('lotacao.infraestrutura_id', $id)) ->when($params['ocupacao_id'], fn ($q, $id) => $q->where('atendimento_procedimento.ocupacao_id', $id)) ->when($params['usuario_id'], fn ($q, $id) => $q->where('atendimento_procedimento.usuario_id', $id)) ->selectRaw(" procedimento.codigo, procedimento.nome ") ->distinct() ->union(DB::table('sigtap.procedimento as procedimento') ->join('ambulatorio_atendimento_procedimento as atendimento_procedimento', 'atendimento_procedimento.procedimento_id', 'procedimento.id') ->join('ambulatorio_atendimento as atendimento', 'atendimento.id', 'atendimento_procedimento.atendimento_id') ->join('ambulatorio_demanda_espontanea as demanda_espontanea', 'demanda_espontanea.id', 'atendimento.demanda_espontanea_id') ->join('cadastro_centro_custo as centro_custo', 'centro_custo.id', 'demanda_espontanea.created_centro_custo_id') ->join('cadastro_infraestrutura as infraestrutura', 'infraestrutura.id', 'centro_custo.infraestrutura_id') ->whereNotNull('atendimento.finalizado_em') ->whereNull('centro_custo.deleted_at') ->whereNull('infraestrutura.deleted_at') ->whereBetween('demanda_espontanea.data', $params['periodo']) ->when($params['unidade_id'], fn ($q, $id) => $q->where('infraestrutura.unidade_id', $id)) ->when($params['infraestrutura_id'], fn ($q, $id) => $q->where('centro_custo.infraestrutura_id', $id)) ->when($params['ocupacao_id'], fn ($q, $id) => $q->where('atendimento_procedimento.ocupacao_id', $id)) ->when($params['usuario_id'], fn ($q, $id) => $q->where('atendimento_procedimento.usuario_id', $id)) ->selectRaw(" procedimento.codigo, procedimento.nome ") ->distinct() ) ->orderByRaw("CONCAT(codigo, ' - ', nome)") ->get(); $procedimentos->each(function ($procedimento) { $procedimento->descricao = MaskUtil::getProcedimentoMasked($procedimento->codigo) . " - {$procedimento->nome}"; unset($procedimento->nome); }); } return ['form' => $procedimentos, 'model' => $codigo]; } private static function setOrderBy($builder) { $columns = [ 'procedimento_codigo' => 'sub.procedimento_codigo', 'procedimento_nome' => 'sub.procedimento_nome', 'ocupacao_codigo' => 'sub.ocupacao_codigo', 'ocupacao_nome' => 'sub.ocupacao_nome', 'usuario_nome' => 'sub.usuario_nome', 'quantidade' => 'quantidade', ]; if (is_null(request()->sortBy)) { $builder->orderByRaw(join(', ', $columns)); return; } $column = $columns[request()->sortBy]; $direction = DataUtil::getBooleanValueFromStringBoolean(request()->sortDesc) ? 'DESC' : 'ASC'; unset($columns[request()->sortBy]); $builder->orderByRaw( "{$column} {$direction}, " . join(', ', $columns) ); } public static function getPrintExportData() { $resultado = self::index(); $itens = $resultado['procedimentos']; $unidade = Unidade::find(request()->unidade_id); $infraestrutura = Infraestrutura::find(request()->infraestrutura_id); $ocupacao = Ocupacao::find(request()->ocupacao_id); $usuario = Usuario::find(request()->usuario_id); $procedimento = Procedimento::where('codigo', request()->procedimento_codigo)->orderByDesc('competencia_id')->first(); return [ 'inicio' => request()->periodo['start'], 'fim' => request()->periodo['end'], 'unidade' => $unidade->nome_fantasia ?? 'Todas', 'infraestrutura' => $infraestrutura->nome ?? 'Todos', 'ocupacao' => $ocupacao ? "{$ocupacao->codigo} - {$ocupacao->nome}" : 'Todas', 'usuario' => $usuario->cidadao->nome ?? 'Todos', 'procedimento' => $procedimento ? MaskUtil::getProcedimentoMasked($procedimento->codigo) . " - {$procedimento->nome}" : 'Todos', 'idadeDe' => request()->idade_de, 'idadeAte' => request()->idade_ate, 'colunas' => collect(request()->columns), 'itens' => $itens, 'totalizadores' => $resultado['totalizadores'], ]; } }