This commit is contained in:
1017
api/app/Http/Controllers/Parametrizacao/ExameController.php
Normal file
1017
api/app/Http/Controllers/Parametrizacao/ExameController.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Parametrizacao\KitExame;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Parametrizacao\KitExame\ItemRequest;
|
||||
use App\Models\Parametrizacao\KitExame\Item;
|
||||
use App\Models\Parametrizacao\KitExame\KitExame;
|
||||
use App\Models\Parametrizacao\KitExame\Tipo;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class KitExameController extends Controller
|
||||
{
|
||||
protected $modulo = 'parametrizacao';
|
||||
protected $funcionalidade = 'kit-exame';
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
$kits = DB::table('parametrizacao_kit_exame')
|
||||
->join(
|
||||
'parametrizacao_kit_exame_tipo',
|
||||
'parametrizacao_kit_exame_tipo.id',
|
||||
'parametrizacao_kit_exame.tipo_id'
|
||||
)
|
||||
->select(
|
||||
'parametrizacao_kit_exame.id',
|
||||
'parametrizacao_kit_exame.nome',
|
||||
'parametrizacao_kit_exame_tipo.nome as tipo'
|
||||
)
|
||||
->whereNull('parametrizacao_kit_exame.deleted_at');
|
||||
|
||||
return datatables()->of($kits)->skipTotalRecords()->toJson();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$kits = $this->get(KitExame::class)->orderBy('nome')->get();
|
||||
|
||||
return response()->json($kits, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$kit = new KitExame;
|
||||
$kit->fill(array_fill_keys($kit->getFillable(), null));
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'form' => $this->getFormData(),
|
||||
'model' => $kit->makeHidden('id')->load('itens')
|
||||
],
|
||||
Response::HTTP_OK
|
||||
);
|
||||
}
|
||||
|
||||
public function store(ItemRequest $request)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$kit = new KitExame;
|
||||
$params = $request->all();
|
||||
|
||||
DB::transaction(function () use ($kit, $params) {
|
||||
|
||||
$kit->fill($params)->save();
|
||||
$kit->itens()->createMany($params['itens']);
|
||||
});
|
||||
|
||||
return response()->json($kit->fresh(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json($this->get(KitExame::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$kit = KitExame::findOrFail($id);
|
||||
|
||||
$kit->itens->each(function ($item) {
|
||||
|
||||
$item->exame->procedimento_nome = $item->exame->procedimento->nome ?? null;
|
||||
|
||||
$item->exame->unsetRelation('tipo')->unsetRelation('procedimento');
|
||||
$item->unsetRelation('kit');
|
||||
});
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'form' => $this->getFormData(),
|
||||
'model' => $kit->makeHidden('id')->unsetRelation('tipo'),
|
||||
],
|
||||
Response::HTTP_OK
|
||||
);
|
||||
}
|
||||
|
||||
private function getFormData()
|
||||
{
|
||||
return [
|
||||
'tipos' => Tipo::orderBy('nome')->get()
|
||||
];
|
||||
}
|
||||
|
||||
public function update(ItemRequest $request, $id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$kit = KitExame::findOrFail($id);
|
||||
$params = $request->only(['nome', 'itens']);
|
||||
|
||||
DB::transaction(function () use ($kit, $params) {
|
||||
|
||||
$kit->update($params);
|
||||
|
||||
Item::destroy($kit->itens->pluck('id'));
|
||||
|
||||
$kit->itens()->createMany($params['itens']);
|
||||
});
|
||||
|
||||
return response()->json($kit->fresh(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
KitExame::findOrFail($id)->delete();
|
||||
|
||||
return response()->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Parametrizacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Parametrizacao\ProcedimentoCirurgico;
|
||||
use App\Services\Parametrizacao\ProcedimentoCirurgicoService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ProcedimentoCirurgicoController extends Controller
|
||||
{
|
||||
protected $modulo = 'parametrizacao';
|
||||
protected $funcionalidade = 'procedimento-cirurgico';
|
||||
|
||||
public function autocomplete()
|
||||
{
|
||||
return datatables()
|
||||
->of(ProcedimentoCirurgicoService::autocomplete())
|
||||
->skipTotalRecords()
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return ProcedimentoCirurgicoService::datatable();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ProcedimentoCirurgicoService::index(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ProcedimentoCirurgicoService::create(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ProcedimentoCirurgicoService::store($request), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json($this->get(ProcedimentoCirurgico::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ProcedimentoCirurgicoService::edit($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ProcedimentoCirurgicoService::update($request, $id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(ProcedimentoCirurgico::destroy($id), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Parametrizacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Parametrizacao\ProcedimentoRequest;
|
||||
use App\Models\Parametrizacao\Procedimento;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProcedimentoController extends Controller
|
||||
{
|
||||
protected $modulo = 'parametrizacao';
|
||||
protected $funcionalidade = 'procedimento';
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
$procedimentos = DB::table('parametrizacao_procedimento')
|
||||
->join('sigtap.procedimento', function($join) {
|
||||
$join->on('procedimento.codigo', 'parametrizacao_procedimento.procedimento_codigo')
|
||||
->where('procedimento.competencia_id', function ($query) {
|
||||
$query->select('competencia.id')
|
||||
->from('sigtap.competencia')
|
||||
->orderByDesc('competencia.valor')
|
||||
->limit(1);
|
||||
});
|
||||
})
|
||||
->select(
|
||||
'parametrizacao_procedimento.id',
|
||||
'parametrizacao_procedimento.apelido',
|
||||
'procedimento.codigo',
|
||||
'procedimento.nome',
|
||||
)
|
||||
->whereNull('parametrizacao_procedimento.deleted_at');
|
||||
|
||||
return datatables()
|
||||
->of($procedimentos)
|
||||
->filterColumn('procedimento.codigo', function ($query, $keyword) {
|
||||
|
||||
$query
|
||||
->whereRaw("procedimento.codigo like ?", ["%{$keyword}%"])
|
||||
->orWhereRaw(
|
||||
"CONCAT(
|
||||
SUBSTR(procedimento.codigo,1,2),
|
||||
'.',
|
||||
SUBSTR(procedimento.codigo,3,2),
|
||||
'.',
|
||||
SUBSTR(procedimento.codigo,5,2),
|
||||
'.',
|
||||
SUBSTR(procedimento.codigo,7,3),
|
||||
'-',
|
||||
SUBSTR(procedimento.codigo,10,1)
|
||||
) like ?",
|
||||
["%{$keyword}%"]
|
||||
);
|
||||
})
|
||||
->skipTotalRecords()
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$procedimentos = $this->get(Procedimento::class)->orderBy('nome')->get();
|
||||
|
||||
return response()->json($procedimentos, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$procedimento = new Procedimento;
|
||||
$procedimento->fill(array_fill_keys($procedimento->getFillable(), null));
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'model' => $procedimento->makeHidden(['id', 'procedimento_codigo'])
|
||||
],
|
||||
Response::HTTP_OK
|
||||
);
|
||||
}
|
||||
|
||||
public function store(ProcedimentoRequest $request)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$procedimento = Procedimento::create($request->all())->fresh();
|
||||
|
||||
return response()->json($procedimento, Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json($this->get(Procedimento::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$procedimento = Procedimento::findOrFail($id);
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'model' => $procedimento->makeHidden(['id', 'procedimento_codigo']),
|
||||
],
|
||||
Response::HTTP_OK
|
||||
);
|
||||
}
|
||||
|
||||
public function update(ProcedimentoRequest $request, $id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
$procedimento = tap(Procedimento::findOrFail($id))->update($request->except('procedimento_codigo'));
|
||||
|
||||
return response()->json($procedimento->fresh(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
Procedimento::findOrFail($id)->delete();
|
||||
|
||||
return response()->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Parametrizacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Services\Parametrizacao\RelatorioExameCadastradoService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class RelatorioExameCadastradoController extends Controller
|
||||
{
|
||||
protected $modulo = 'parametrizacao';
|
||||
protected $funcionalidade = 'relatorio-exame-cadastrado';
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(RelatorioExameCadastradoService::index(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return response()->json(RelatorioExameCadastradoService::create(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return response()->json(RelatorioExameCadastradoService::list(), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Parametrizacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Sigtap\CidService;
|
||||
|
||||
class TabelaCidController extends Controller
|
||||
{
|
||||
protected $modulo = 'parametrizacao';
|
||||
protected $funcionalidade = 'tabela-cid';
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return CidService::datatable();
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return CidService::update($id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Parametrizacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Parametrizacao\TabelaObmService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TabelaObmController extends Controller
|
||||
{
|
||||
protected $modulo = 'parametrizacao';
|
||||
protected $funcionalidade = 'tabela-obm';
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(TabelaObmService::show($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
return response()->json(TabelaObmService::store($request), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return datatables()->of(TabelaObmService::datatable())->make(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user