This commit is contained in:
21
api/app/Http/Controllers/Geral/CiapController.php
Normal file
21
api/app/Http/Controllers/Geral/CiapController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Geral\CiapService;
|
||||
|
||||
class CiapController extends Controller
|
||||
{
|
||||
public function autocomplete()
|
||||
{
|
||||
return datatables()
|
||||
->of(CiapService::autocomplete())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return CiapService::index();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Enums\Cadastro\UnidadeMedida;
|
||||
use App\Utils\ConversaoUnidadeMedidaUtil;
|
||||
|
||||
class ConversaoUnidadeMedidaController extends Controller
|
||||
{
|
||||
public function calc($unidadeMedidaOrigemId, $valor, $unidadeMedidaDestinoId)
|
||||
{
|
||||
if ($unidadeMedidaOrigemId == UnidadeMedida::GRAMAS) {
|
||||
|
||||
if ($unidadeMedidaDestinoId == UnidadeMedida::QUILOGRAMAS) {
|
||||
|
||||
$valor = ConversaoUnidadeMedidaUtil::gramasParaQuilogramas($valor);
|
||||
}
|
||||
}
|
||||
|
||||
if ($unidadeMedidaOrigemId == UnidadeMedida::QUILOGRAMAS) {
|
||||
|
||||
if ($unidadeMedidaDestinoId == UnidadeMedida::GRAMAS) {
|
||||
|
||||
$valor = ConversaoUnidadeMedidaUtil::quilogramasParaGramas($valor);
|
||||
}
|
||||
}
|
||||
|
||||
if ($unidadeMedidaOrigemId == UnidadeMedida::CENTIMETROS) {
|
||||
|
||||
if ($unidadeMedidaDestinoId == UnidadeMedida::METROS) {
|
||||
|
||||
$valor = ConversaoUnidadeMedidaUtil::centimetrosParaMetros($valor);
|
||||
}
|
||||
}
|
||||
|
||||
if ($unidadeMedidaOrigemId == UnidadeMedida::METROS) {
|
||||
|
||||
if ($unidadeMedidaDestinoId == UnidadeMedida::CENTIMETROS) {
|
||||
|
||||
$valor = ConversaoUnidadeMedidaUtil::metrosParaCentimetros($valor);
|
||||
}
|
||||
}
|
||||
|
||||
if ($unidadeMedidaOrigemId == UnidadeMedida::MILIMETROS_DE_MERCURIO) {
|
||||
|
||||
if ($unidadeMedidaDestinoId == UnidadeMedida::CENTIMETROS_DE_MERCURIO) {
|
||||
|
||||
$valor = ConversaoUnidadeMedidaUtil::milimetrosDeMercurioParaCentimetrosDeMercurio($valor);
|
||||
}
|
||||
}
|
||||
|
||||
if ($unidadeMedidaOrigemId == UnidadeMedida::CENTIMETROS_DE_MERCURIO) {
|
||||
|
||||
if ($unidadeMedidaDestinoId == UnidadeMedida::MILIMETROS_DE_MERCURIO) {
|
||||
|
||||
$valor = ConversaoUnidadeMedidaUtil::centimetrosDeMercurioParaMilimetrosDeMercurio($valor);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(compact('valor'), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
21
api/app/Http/Controllers/Geral/DiferencaTempoController.php
Normal file
21
api/app/Http/Controllers/Geral/DiferencaTempoController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Geral\AgeService;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DiferencaTempoController extends Controller
|
||||
{
|
||||
public function calc($year, $month, $day)
|
||||
{
|
||||
$diff = AgeService::getAge(Carbon::create($year, $month, $day)->toDateTime());
|
||||
|
||||
return [
|
||||
'anos' => $diff->years,
|
||||
'meses' => $diff->months,
|
||||
'dias' => $diff->days
|
||||
];
|
||||
}
|
||||
}
|
||||
20
api/app/Http/Controllers/Geral/DocumentoTipoController.php
Normal file
20
api/app/Http/Controllers/Geral/DocumentoTipoController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Geral\DocumentoTipo;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class DocumentoTipoController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json($this->get(DocumentoTipo::class)->get(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return response()->json($this->get(DocumentoTipo::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Geral\GestacaoService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class GestacaoCalculosController extends Controller
|
||||
{
|
||||
public function calc($year, $month, $day)
|
||||
{
|
||||
$dum = Carbon::create($year, $month, $day);
|
||||
|
||||
return response()->json([
|
||||
'idade_gestacional' => GestacaoService::getIdadeGestacional($dum),
|
||||
'dpp' => GestacaoService::getDataPrevistaParto($dum)->format('d/m/Y'),
|
||||
], Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
39
api/app/Http/Controllers/Geral/ImcController.php
Normal file
39
api/app/Http/Controllers/Geral/ImcController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Enums\Cadastro\UnidadeMedida;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Geral\ImcService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ImcController extends Controller
|
||||
{
|
||||
public function calc($unidadeMedidaMassaId, $massa, $unidadeMedidaAlturaId, $altura)
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
if ($unidadeMedidaMassaId != UnidadeMedida::QUILOGRAMAS
|
||||
&& $unidadeMedidaMassaId != UnidadeMedida::GRAMAS
|
||||
) {
|
||||
|
||||
$errors[] = 'A unidade de medida da massa deve ser gramas ou quilogramas.';
|
||||
}
|
||||
|
||||
if ($unidadeMedidaAlturaId != UnidadeMedida::METROS
|
||||
&& $unidadeMedidaAlturaId != UnidadeMedida::CENTIMETROS
|
||||
) {
|
||||
|
||||
$errors[] = 'A unidade de medida da massa deve ser centímetros ou metros.';
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
|
||||
return response()->json($errors, Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$imc = ImcService::calculate($unidadeMedidaMassaId, $massa, $unidadeMedidaAlturaId, $altura);
|
||||
|
||||
return response()->json($imc, Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
20
api/app/Http/Controllers/Geral/MedidaTempoController.php
Normal file
20
api/app/Http/Controllers/Geral/MedidaTempoController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Geral\MedidaTempo;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class MedidaTempoController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json($this->get(MedidaTempo::class)->get(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return response()->json($this->get(MedidaTempo::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
15
api/app/Http/Controllers/Geral/TermoInvalidoController.php
Normal file
15
api/app/Http/Controllers/Geral/TermoInvalidoController.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Cns\TermoInvalido;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TermoInvalidoController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json($this->get(TermoInvalido::class)->get(), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Geral\TipoMedidaAltura;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TipoMedidaAlturaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json($this->get(TipoMedidaAltura::class)->get(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return response()->json($this->get(TipoMedidaAltura::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
20
api/app/Http/Controllers/Geral/TurnoController.php
Normal file
20
api/app/Http/Controllers/Geral/TurnoController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Geral;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Geral\Turno;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TurnoController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json($this->get(Turno::class)->get(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return response()->json($this->get(Turno::class, $id), Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user