This commit is contained in:
140
api/app/Models/ProntoAtendimento/Atendimento/Procedimento.php
Normal file
140
api/app/Models/ProntoAtendimento/Atendimento/Procedimento.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\ProntoAtendimento\Atendimento;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Models\Model;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Enfermagem\AtendimentoEnfermagem;
|
||||
use App\Models\ProntoAtendimento\Atendimento\ExameImagem\AtendimentoExameImagem;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Medico\AtendimentoMedico;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Observacao\PacienteObservacao;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Triagem\AtendimentoTriagem;
|
||||
use App\Models\ProntoAtendimento\Plantao\Plantao;
|
||||
use App\Models\Sigtap\Cid as SigtapCid;
|
||||
use App\Models\Sigtap\Procedimento as SigtapProcedimento;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Procedimento extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'pronto_atendimento_atendimento_procedimento';
|
||||
|
||||
protected $casts = [
|
||||
'is_parametrizado' => 'boolean',
|
||||
'realizado_em' => 'date:d/m/Y'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'atendimento_id',
|
||||
'atendimento_medico_id',
|
||||
'atendimento_triagem_id',
|
||||
'atendimento_enfermagem_id',
|
||||
'paciente_observacao_id',
|
||||
'exame_imagem_id',
|
||||
'bpa_procedimento_id',
|
||||
'procedimento_id',
|
||||
'realizado_em',
|
||||
'lotacao_id',
|
||||
'cid_principal_id',
|
||||
'cid_secundario_id',
|
||||
'quantidade',
|
||||
'is_parametrizado',
|
||||
'plantao_id',
|
||||
];
|
||||
|
||||
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',
|
||||
];
|
||||
|
||||
public function lotacao()
|
||||
{
|
||||
return $this->belongsTo(Lotacao::class);
|
||||
}
|
||||
|
||||
public function atendimento()
|
||||
{
|
||||
return $this->belongsTo(Atendimento::class);
|
||||
}
|
||||
|
||||
public function atendimentoMedico()
|
||||
{
|
||||
return $this->belongsTo(AtendimentoMedico::class);
|
||||
}
|
||||
|
||||
public function atendimentoTriagem()
|
||||
{
|
||||
return $this->belongsTo(AtendimentoTriagem::class);
|
||||
}
|
||||
|
||||
public function atendimentoEnfermagem()
|
||||
{
|
||||
return $this->belongsTo(AtendimentoEnfermagem::class);
|
||||
}
|
||||
|
||||
public function atendimentoExameImagem()
|
||||
{
|
||||
return $this->belongsTo(AtendimentoExameImagem::class, 'exame_imagem_id');
|
||||
}
|
||||
|
||||
public function pacienteObservacao()
|
||||
{
|
||||
return $this->belongsTo(PacienteObservacao::class);
|
||||
}
|
||||
|
||||
public function procedimento()
|
||||
{
|
||||
return $this->belongsTo(SigtapProcedimento::class);
|
||||
}
|
||||
|
||||
public function cidPrincipal()
|
||||
{
|
||||
return $this->belongsTo(SigtapCid::class);
|
||||
}
|
||||
|
||||
public function cidSecundario()
|
||||
{
|
||||
return $this->belongsTo(SigtapCid::class);
|
||||
}
|
||||
|
||||
public function plantao()
|
||||
{
|
||||
return $this->belongsTo(Plantao::class);
|
||||
}
|
||||
|
||||
public function getFromFechamentoFaaAttribute()
|
||||
{
|
||||
return is_null($this->atendimento_medico_id)
|
||||
&& is_null($this->atendimento_triagem_id)
|
||||
&& is_null($this->atendimento_enfermagem_id)
|
||||
&& is_null($this->paciente_observacao_id)
|
||||
&& is_null($this->exame_imagem_id);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
|
||||
if (is_null($model->realizado_em)) {
|
||||
|
||||
$model->realizado_em = Carbon::now();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user