This commit is contained in:
85
api/app/Models/ProntoAtendimento/Atendimento/Gestacao.php
Normal file
85
api/app/Models/ProntoAtendimento/Atendimento/Gestacao.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\ProntoAtendimento\Atendimento;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Enfermagem\AtendimentoEnfermagem;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Medico\AtendimentoMedico;
|
||||
use App\Services\Geral\GestacaoService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Gestacao extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'pronto_atendimento_atendimento_gestacao';
|
||||
|
||||
protected $casts = [
|
||||
'gestante' => 'boolean',
|
||||
'dum' => 'datetime:d/m/Y',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'atendimento_triagem_id',
|
||||
'atendimento_medico_id',
|
||||
'atendimento_enfermagem_id',
|
||||
'paciente_observacao_id',
|
||||
'gestante',
|
||||
'dum',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'deleted_at',
|
||||
'deleted_lotacao_id',
|
||||
'deleted_centro_custo_id',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'idade_gestacional',
|
||||
'dpp'
|
||||
];
|
||||
|
||||
public function atendimento()
|
||||
{
|
||||
return $this->belongsTo(Atendimento::class);
|
||||
}
|
||||
|
||||
public function atendimentoMedico()
|
||||
{
|
||||
return $this->belongsTo(AtendimentoMedico::class);
|
||||
}
|
||||
|
||||
public function atendimentoEnfermagem()
|
||||
{
|
||||
return $this->belongsTo(AtendimentoEnfermagem::class);
|
||||
}
|
||||
|
||||
public function getIdadeGestacionalAttribute()
|
||||
{
|
||||
if (!is_null($this->dum)) {
|
||||
|
||||
return GestacaoService::getIdadeGestacional($this->dum);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDppAttribute()
|
||||
{
|
||||
if (!is_null($this->dum)) {
|
||||
|
||||
$dum = GestacaoService::getDataPrevistaParto(Carbon::parse($this->dum))->toDateString();
|
||||
return Carbon::create($dum)->format('d/m/Y');
|
||||
}
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user