Files
Antonio Lopes dos Santos afec302c3e
All checks were successful
build-api-image / build (push) Successful in 51s
init commit
2026-08-04 16:52:02 -03:00

86 lines
1.9 KiB
PHP

<?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;
}
}