This commit is contained in:
51
api/app/Models/Cadastro/SujeitoAtencao/Alergia.php
Normal file
51
api/app/Models/Cadastro/SujeitoAtencao/Alergia.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Alergia extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_alergia';
|
||||
|
||||
protected $fillable = [
|
||||
'tipo_id',
|
||||
'agente_substancia_especifica',
|
||||
];
|
||||
|
||||
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',
|
||||
'pivot'
|
||||
];
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(AlergiaTipo::class);
|
||||
}
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->belongsToMany(Cidadao::class, 'cadastro_cidadao_alergia')
|
||||
->using(CidadaoAlergia::class)
|
||||
->withPivot('criticidade_id', 'reacoes_observacoes', 'cid_id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'cidadaos',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class AlergiaCriticidade extends Model
|
||||
{
|
||||
protected $table = 'cadastro_alergia_criticidade';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
25
api/app/Models/Cadastro/SujeitoAtencao/AlergiaTipo.php
Normal file
25
api/app/Models/Cadastro/SujeitoAtencao/AlergiaTipo.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class AlergiaTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_alergia_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function alergias()
|
||||
{
|
||||
return $this->hasMany(Alergia::class, 'tipo_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Intranet\Estado;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CarteiraHabilitacao extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_carteira_habilitacao';
|
||||
|
||||
protected $casts = [
|
||||
'data_emissao' => 'datetime:Y-m-d',
|
||||
'data_validade' => 'datetime:Y-m-d'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'numero',
|
||||
'data_emissao',
|
||||
'data_validade',
|
||||
'estado_id',
|
||||
'categoria_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',
|
||||
'cidadao_id',
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(Estado::class);
|
||||
}
|
||||
|
||||
public function categoria()
|
||||
{
|
||||
return $this->belongsTo(CarteiraHabilitacaoCategoria::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class CarteiraHabilitacaoCategoria extends Model
|
||||
{
|
||||
protected $table = 'cadastro_carteira_habilitacao_categoria';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'letra',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function carteirasHabilitacao()
|
||||
{
|
||||
return $this->hasMany(CarteiraHabilitacao::class, 'categoria_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Intranet\Estado;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CarteiraIdentidade extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_carteira_identidade';
|
||||
|
||||
protected $casts = [
|
||||
'data_emissao' => 'datetime:Y-m-d'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'numero',
|
||||
'estado_id',
|
||||
'orgao_emissor',
|
||||
'data_emissao',
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadao_id',
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(Estado::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
54
api/app/Models/Cadastro/SujeitoAtencao/CarteiraTrabalho.php
Normal file
54
api/app/Models/Cadastro/SujeitoAtencao/CarteiraTrabalho.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Intranet\Estado;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CarteiraTrabalho extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_carteira_trabalho';
|
||||
|
||||
protected $casts = [
|
||||
'data_emissao' => 'datetime:Y-m-d'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'numero',
|
||||
'serie',
|
||||
'data_emissao',
|
||||
'estado_id',
|
||||
'nis_pis_pasep',
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadao_id',
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(Estado::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
68
api/app/Models/Cadastro/SujeitoAtencao/Certidao.php
Normal file
68
api/app/Models/Cadastro/SujeitoAtencao/Certidao.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Intranet\Municipio;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Certidao extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_certidao';
|
||||
|
||||
protected $casts = [
|
||||
'data_emissao' => 'datetime:Y-m-d'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'tipo_id',
|
||||
'modelo_id',
|
||||
'numero',
|
||||
'cartorio_nome',
|
||||
'livro',
|
||||
'folha',
|
||||
'data_emissao',
|
||||
'municipio_id',
|
||||
'cartorio_codigo',
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadao_id',
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(CertidaoTipo::class);
|
||||
}
|
||||
|
||||
public function modelo()
|
||||
{
|
||||
return $this->belongsTo(CertidaoModelo::class);
|
||||
}
|
||||
|
||||
public function municipio()
|
||||
{
|
||||
return $this->belongsTo(Municipio::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/SujeitoAtencao/CertidaoModelo.php
Normal file
25
api/app/Models/Cadastro/SujeitoAtencao/CertidaoModelo.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class CertidaoModelo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_certidao_modelo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function certidoes()
|
||||
{
|
||||
return $this->hasMany(Certidao::class, 'modelo_id');
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/SujeitoAtencao/CertidaoTipo.php
Normal file
25
api/app/Models/Cadastro/SujeitoAtencao/CertidaoTipo.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class CertidaoTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_certidao_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function certidoes()
|
||||
{
|
||||
return $this->hasMany(Certidao::class, 'tipo_id');
|
||||
}
|
||||
}
|
||||
400
api/app/Models/Cadastro/SujeitoAtencao/Cidadao.php
Normal file
400
api/app/Models/Cadastro/SujeitoAtencao/Cidadao.php
Normal file
@@ -0,0 +1,400 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Enums\Cadastro\SujeitoAtencao\Nacionalidade as EnumNacionalidade;
|
||||
use App\Enums\Cadastro\SujeitoAtencao\RacaCor as EnumRacaCor;
|
||||
use App\Enums\Intranet\Pais as IntranetPais;
|
||||
use App\Models\Cadastro\Localizacao\Domicilio;
|
||||
use App\Models\Cadastro\Medicamento\Medicamento;
|
||||
use App\Models\Cadastro\SujeitoAtencao\DoencaCronica;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Nacionalidade;
|
||||
use App\Models\Cadastro\SujeitoAtencao\RacaCor;
|
||||
use App\Models\Intranet\Estado;
|
||||
use App\Models\Intranet\Municipio;
|
||||
use App\Models\Intranet\Pais;
|
||||
use App\Models\Model;
|
||||
use App\Services\Geral\AgeService;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Cidadao extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_cidadao';
|
||||
|
||||
protected $casts = [
|
||||
'frequenta_escola' => 'boolean',
|
||||
'data_nascimento' => 'datetime:Y-m-d',
|
||||
'data_entrada_domicilio' => 'datetime:Y-m-d',
|
||||
'data_naturalizacao' => 'datetime:Y-m-d',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'cns',
|
||||
'cpf',
|
||||
'dnv',
|
||||
'motivo_duplicidade_cpf_id',
|
||||
'motivo_duplicidade_cpf_outro',
|
||||
'nome',
|
||||
'nome_social',
|
||||
'preferencia_nome_id',
|
||||
'data_nascimento',
|
||||
'sexo_id',
|
||||
'identidade_genero_id',
|
||||
'estado_civil_id',
|
||||
'conjuge',
|
||||
'situacao_familiar_conjugal_id',
|
||||
'raca_cor_id',
|
||||
'etnia_indigena_id',
|
||||
'tipo_sanguineo_id',
|
||||
'deficiencia_id',
|
||||
'deficiencia_outro',
|
||||
'mobilidade_reduzida_id',
|
||||
'nome_mae',
|
||||
'nome_pai',
|
||||
'local_nascimento_id',
|
||||
'pais_nascimento_id',
|
||||
'nacionalidade_id',
|
||||
'data_naturalizacao',
|
||||
'portaria_naturalizacao',
|
||||
'estado_nascimento_id',
|
||||
'municipio_nascimento_id',
|
||||
'frequenta_escola',
|
||||
'escolaridade_id',
|
||||
'data_entrada_domicilio',
|
||||
'domicilio_id',
|
||||
'caracteristicas_fisicas',
|
||||
'fator_risco_outro',
|
||||
'cd_usuario_sistema_v1',
|
||||
'cd_sus_complemento_v1',
|
||||
];
|
||||
|
||||
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 = [
|
||||
'telefone_principal',
|
||||
'desconhece_nome_mae',
|
||||
'desconhece_nome_pai',
|
||||
'cpf_nao_pertence_ao_cidadao',
|
||||
'idade',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'carteiraIdentidade',
|
||||
'carteiraHabilitacao',
|
||||
'carteiraTrabalho',
|
||||
'estrangeiroEntradaBrasil',
|
||||
'tituloEleitor',
|
||||
'certidao',
|
||||
'telefones',
|
||||
'conveniosMedico',
|
||||
'domicilio',
|
||||
'fatoresRisco',
|
||||
'alergias',
|
||||
'obito',
|
||||
'sexo',
|
||||
];
|
||||
|
||||
public function motivoDuplicidadeCpf()
|
||||
{
|
||||
return $this->belongsTo(MotivoDuplicidadeCpf::class);
|
||||
}
|
||||
|
||||
public function preferenciaNome()
|
||||
{
|
||||
return $this->belongsTo(PreferenciaNome::class);
|
||||
}
|
||||
|
||||
public function sexo()
|
||||
{
|
||||
return $this->belongsTo(Sexo::class);
|
||||
}
|
||||
|
||||
public function doencasCronicas()
|
||||
{
|
||||
return $this->hasMany(DoencaCronica::class);
|
||||
}
|
||||
|
||||
public function identidadeGenero()
|
||||
{
|
||||
return $this->belongsTo(IdentidadeGenero::class);
|
||||
}
|
||||
|
||||
public function estadoCivil()
|
||||
{
|
||||
return $this->belongsTo(EstadoCivil::class);
|
||||
}
|
||||
|
||||
public function situacaoFamiliarConjugal()
|
||||
{
|
||||
return $this->belongsTo(SituacaoFamiliarConjugal::class);
|
||||
}
|
||||
|
||||
public function racaCor()
|
||||
{
|
||||
return $this->belongsTo(RacaCor::class);
|
||||
}
|
||||
|
||||
public function etniaIndigena()
|
||||
{
|
||||
return $this->belongsTo(EtniaIndigena::class);
|
||||
}
|
||||
|
||||
public function tipoSanguineo()
|
||||
{
|
||||
return $this->belongsTo(TipoSanguineo::class);
|
||||
}
|
||||
|
||||
public function deficiencia()
|
||||
{
|
||||
return $this->belongsTo(Deficiencia::class);
|
||||
}
|
||||
|
||||
public function mobilidadeReduzida()
|
||||
{
|
||||
return $this->belongsTo(MobilidadeReduzida::class);
|
||||
}
|
||||
|
||||
public function localNascimento()
|
||||
{
|
||||
return $this->belongsTo(LocalNascimento::class);
|
||||
}
|
||||
|
||||
public function paisNascimento()
|
||||
{
|
||||
return $this->belongsTo(Pais::class);
|
||||
}
|
||||
|
||||
public function nacionalidade()
|
||||
{
|
||||
return $this->belongsTo(Nacionalidade::class);
|
||||
}
|
||||
|
||||
public function estadoNascimento()
|
||||
{
|
||||
return $this->belongsTo(Estado::class);
|
||||
}
|
||||
|
||||
public function municipioNascimento()
|
||||
{
|
||||
return $this->belongsTo(Municipio::class);
|
||||
}
|
||||
|
||||
public function escolaridade()
|
||||
{
|
||||
return $this->belongsTo(Escolaridade::class);
|
||||
}
|
||||
|
||||
public function domicilio()
|
||||
{
|
||||
return $this->belongsTo(Domicilio::class);
|
||||
}
|
||||
|
||||
public function conveniosMedico()
|
||||
{
|
||||
return $this->belongsToMany(ConvenioMedico::class, 'cadastro_cidadao_convenio_medico')
|
||||
->using(CidadaoConvenioMedico::class)
|
||||
->as('cidadaoConvenioMedico')
|
||||
->withTimestamps()
|
||||
->orderBy('nome');
|
||||
}
|
||||
|
||||
public function alergias()
|
||||
{
|
||||
return $this->belongsToMany(Alergia::class, 'cadastro_cidadao_alergia')
|
||||
->with('tipo')
|
||||
->using(CidadaoAlergia::class)
|
||||
->as('cidadaoAlergia')
|
||||
->withPivot('created_lotacao_id', 'created_centro_custo_id', 'criticidade_id', 'reacoes_observacoes', 'cid_id')
|
||||
->withTimestamps()
|
||||
->orderBy('agente_substancia_especifica');
|
||||
}
|
||||
|
||||
public function medicamentosUsoContinuo()
|
||||
{
|
||||
return $this->belongsToMany(Medicamento::class, 'cadastro_cidadao_medicamento_uso_continuo')
|
||||
->using(CidadaoMedicamentoUsoContinuo::class)
|
||||
->as('CidadaoMedicamentoUsoContinuo')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
)
|
||||
->withTimestamps()
|
||||
->orderBy('cadastro_medicamento.nome');
|
||||
}
|
||||
|
||||
public function fatoresRisco()
|
||||
{
|
||||
return $this->belongsToMany(FatorRisco::class, 'cadastro_cidadao_fator_risco')
|
||||
->using(CidadaoFatorRisco::class)
|
||||
->as('cidadaoFatorRisco')
|
||||
->withPivot('created_lotacao_id', 'created_centro_custo_id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function obito()
|
||||
{
|
||||
return $this->hasOne(Obito::class);
|
||||
}
|
||||
|
||||
public function telefones()
|
||||
{
|
||||
return $this->hasMany(CidadaoTelefone::class);
|
||||
}
|
||||
|
||||
public function carteiraIdentidade()
|
||||
{
|
||||
return $this->hasOne(CarteiraIdentidade::class);
|
||||
}
|
||||
|
||||
public function carteiraHabilitacao()
|
||||
{
|
||||
return $this->hasOne(CarteiraHabilitacao::class);
|
||||
}
|
||||
|
||||
public function carteiraTrabalho()
|
||||
{
|
||||
return $this->hasOne(CarteiraTrabalho::class);
|
||||
}
|
||||
|
||||
public function estrangeiroEntradaBrasil()
|
||||
{
|
||||
return $this->hasOne(EstrangeiroEntradaBrasil::class);
|
||||
}
|
||||
|
||||
public function tituloEleitor()
|
||||
{
|
||||
return $this->hasOne(TituloEleitor::class);
|
||||
}
|
||||
|
||||
public function certidao()
|
||||
{
|
||||
return $this->hasOne(Certidao::class);
|
||||
}
|
||||
|
||||
public function paciente()
|
||||
{
|
||||
return $this->hasOne(Paciente::class);
|
||||
}
|
||||
|
||||
public function usuario()
|
||||
{
|
||||
return $this->hasOne(Usuario::class);
|
||||
}
|
||||
|
||||
public function getTelefonePrincipalAttribute()
|
||||
{
|
||||
return $this->telefones()->where('principal', true)->first();
|
||||
}
|
||||
|
||||
public function getDesconheceNomeMaeAttribute()
|
||||
{
|
||||
return is_null($this->nome_mae);
|
||||
}
|
||||
|
||||
public function getDesconheceNomePaiAttribute()
|
||||
{
|
||||
return is_null($this->nome_pai);
|
||||
}
|
||||
|
||||
public function getCpfNaoPertenceAoCidadaoAttribute()
|
||||
{
|
||||
return !is_null($this->motivo_duplicidade_cpf_id);
|
||||
}
|
||||
|
||||
public function getIdadeAttribute()
|
||||
{
|
||||
if (!$this->data_nascimento) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$age = AgeService::getAge($this->data_nascimento);
|
||||
|
||||
return [
|
||||
'anos' => $age->years,
|
||||
'meses' => $age->months,
|
||||
'dias' => $age->days
|
||||
];
|
||||
}
|
||||
|
||||
public function getIdadeFormatadaAttribute()
|
||||
{
|
||||
if (is_null($this->idade)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$idade = $this->idade;
|
||||
|
||||
$anosText = $idade['anos'] > 1 ? 'anos' : 'ano';
|
||||
$mesesText = $idade['meses'] > 1 ? 'meses' : 'mês';
|
||||
$diasText = $idade['dias'] > 1 ? 'dias' : 'dia';
|
||||
|
||||
return "{$idade['anos']} {$anosText} e "
|
||||
. "{$idade['meses']} {$mesesText} e "
|
||||
. "{$idade['dias']} {$diasText}";
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function scopeDadosSemRecusaCadastro($query)
|
||||
{
|
||||
return $query
|
||||
->whereNotNull('nacionalidade_id')
|
||||
->where(function ($query) {
|
||||
$query->where(function ($query) {
|
||||
$query->where('pais_nascimento_id', IntranetPais::BRASIL)
|
||||
->whereNotNull('municipio_nascimento_id');
|
||||
})
|
||||
->orWhere('pais_nascimento_id', '!=', IntranetPais::BRASIL);
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereNotNull("{$this->table}.nome")
|
||||
->where("{$this->table}.nome", '!=', '');
|
||||
})
|
||||
->whereNotNull('raca_cor_id')
|
||||
->whereNotNull('sexo_id')
|
||||
->where(function ($query) {
|
||||
$query->where(function ($query) {
|
||||
$query->where("{$this->table}.raca_cor_id", EnumRacaCor::INDIGENA)
|
||||
->whereNotNull("{$this->table}.etnia_indigena_id");
|
||||
})->orWhere("{$this->table}.raca_cor_id", '!=', EnumRacaCor::INDIGENA)
|
||||
->whereNull("{$this->table}.etnia_indigena_id");
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->where(function ($query) {
|
||||
$query->where("{$this->table}.nacionalidade_id", EnumNacionalidade::NATURALIZADO_BRASILEIRO)
|
||||
->where("{$this->table}.portaria_naturalizacao", '!=', '')
|
||||
->whereNotNull("{$this->table}.portaria_naturalizacao")
|
||||
->whereNotNull("{$this->table}.data_naturalizacao");
|
||||
})->orWhere("{$this->table}.nacionalidade_id", '!=', EnumNacionalidade::NATURALIZADO_BRASILEIRO)
|
||||
->whereNull("{$this->table}.data_naturalizacao");
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->where("{$this->table}.cpf", '!=', '')
|
||||
->orWhere("{$this->table}.cns", '!=', '');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->where(function ($query) {
|
||||
$query->where("{$this->table}.nacionalidade_id", '!=', EnumNacionalidade::ESTRANGEIRO)
|
||||
->whereHas('telefones');
|
||||
})->orWhere("{$this->table}.nacionalidade_id", EnumNacionalidade::ESTRANGEIRO);
|
||||
})
|
||||
;
|
||||
}
|
||||
}
|
||||
28
api/app/Models/Cadastro/SujeitoAtencao/CidadaoAlergia.php
Normal file
28
api/app/Models/Cadastro/SujeitoAtencao/CidadaoAlergia.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
use App\Models\Sigtap\Cid;
|
||||
|
||||
class CidadaoAlergia extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function criticidade()
|
||||
{
|
||||
return $this->belongsTo(AlergiaCriticidade::class);
|
||||
}
|
||||
|
||||
public function cid()
|
||||
{
|
||||
return $this->belongsTo(Cid::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class CidadaoConvenioMedico extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Cadastro\Localizacao\Domicilio;
|
||||
use App\Models\Model;
|
||||
|
||||
class CidadaoDomicilioHistorico extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_cidadao_domicilio_historico';
|
||||
|
||||
protected $casts = [
|
||||
'data_entrada' => 'date:Y-m-d',
|
||||
'data_saida' => 'date:Y-m-d',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'cidadao_id',
|
||||
'domicilio_id',
|
||||
'data_entrada',
|
||||
'data_saida',
|
||||
];
|
||||
|
||||
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 cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function domicilio()
|
||||
{
|
||||
return $this->belongsTo(Domicilio::class);
|
||||
}
|
||||
}
|
||||
17
api/app/Models/Cadastro/SujeitoAtencao/CidadaoFatorRisco.php
Normal file
17
api/app/Models/Cadastro/SujeitoAtencao/CidadaoFatorRisco.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class CidadaoFatorRisco extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class CidadaoMedicamentoUsoContinuo extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
49
api/app/Models/Cadastro/SujeitoAtencao/CidadaoTelefone.php
Normal file
49
api/app/Models/Cadastro/SujeitoAtencao/CidadaoTelefone.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CidadaoTelefone extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_cidadao_telefone';
|
||||
|
||||
protected $casts = [
|
||||
'autoriza_sms' => 'boolean',
|
||||
'principal' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'cidadao_id',
|
||||
'numero',
|
||||
'observacao',
|
||||
'autoriza_sms',
|
||||
'principal',
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadao_id',
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
45
api/app/Models/Cadastro/SujeitoAtencao/ConvenioMedico.php
Normal file
45
api/app/Models/Cadastro/SujeitoAtencao/ConvenioMedico.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ConvenioMedico extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_convenio_medico';
|
||||
|
||||
protected $fillable = [
|
||||
'nome'
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadaoConvenioMedico'
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->belongsToMany(Cidadao::class, 'cadastro_cidadao_convenio_medico')
|
||||
->using(CidadaoConvenioMedico::class)
|
||||
->as('cidadaoConvenioMedico')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'cidadaos'
|
||||
]);
|
||||
}
|
||||
}
|
||||
32
api/app/Models/Cadastro/SujeitoAtencao/Deficiencia.php
Normal file
32
api/app/Models/Cadastro/SujeitoAtencao/Deficiencia.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Deficiencia extends Model
|
||||
{
|
||||
protected $table = 'cadastro_deficiencia';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'deficiencia_base_id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'base_id',
|
||||
];
|
||||
|
||||
public function base()
|
||||
{
|
||||
return $this->belongsTo(DeficienciaBase::class);
|
||||
}
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/SujeitoAtencao/DeficienciaBase.php
Normal file
26
api/app/Models/Cadastro/SujeitoAtencao/DeficienciaBase.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class DeficienciaBase extends Model
|
||||
{
|
||||
protected $table = 'cadastro_deficiencia_base';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo_esus',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function deficiencias()
|
||||
{
|
||||
return $this->hasMany(Deficiencia::class, 'base_id');
|
||||
}
|
||||
}
|
||||
32
api/app/Models/Cadastro/SujeitoAtencao/DoencaCronica.php
Normal file
32
api/app/Models/Cadastro/SujeitoAtencao/DoencaCronica.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class DoencaCronica extends Model
|
||||
{
|
||||
protected $table = 'cadastro_cidadao_doenca_cronica';
|
||||
|
||||
protected $fillable = [
|
||||
'cidadao_id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
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 cidadao()
|
||||
{
|
||||
return $this->belongsToMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
27
api/app/Models/Cadastro/SujeitoAtencao/Escolaridade.php
Normal file
27
api/app/Models/Cadastro/SujeitoAtencao/Escolaridade.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Escolaridade extends Model
|
||||
{
|
||||
protected $table = 'cadastro_escolaridade';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/SujeitoAtencao/EstadoCivil.php
Normal file
25
api/app/Models/Cadastro/SujeitoAtencao/EstadoCivil.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class EstadoCivil extends Model
|
||||
{
|
||||
protected $table = 'cadastro_estado_civil';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EstrangeiroEntradaBrasil extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_estrangeiro_entrada_brasil';
|
||||
|
||||
protected $casts = [
|
||||
'data_entrada' => 'datetime:Y-m-d'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'rne',
|
||||
'data_entrada',
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadao_id'
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
27
api/app/Models/Cadastro/SujeitoAtencao/EtniaIndigena.php
Normal file
27
api/app/Models/Cadastro/SujeitoAtencao/EtniaIndigena.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class EtniaIndigena extends Model
|
||||
{
|
||||
protected $table = 'cadastro_etnia_indigena';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'codigo',
|
||||
'codigo_cadsus',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
28
api/app/Models/Cadastro/SujeitoAtencao/FatorRisco.php
Normal file
28
api/app/Models/Cadastro/SujeitoAtencao/FatorRisco.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class FatorRisco extends Model
|
||||
{
|
||||
protected $table = 'cadastro_fator_risco';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'pivot'
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->belongsToMany(Cidadao::class, 'cadastro_cidadao_fator_risco')
|
||||
->using(CidadaoFatorRisco::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
28
api/app/Models/Cadastro/SujeitoAtencao/IdentidadeGenero.php
Normal file
28
api/app/Models/Cadastro/SujeitoAtencao/IdentidadeGenero.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class IdentidadeGenero extends Model
|
||||
{
|
||||
protected $table = 'cadastro_identidade_genero';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo_esus',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/SujeitoAtencao/LocalNascimento.php
Normal file
25
api/app/Models/Cadastro/SujeitoAtencao/LocalNascimento.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LocalNascimento extends Model
|
||||
{
|
||||
protected $table = 'cadastro_local_nascimento';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
174
api/app/Models/Cadastro/SujeitoAtencao/Lotacao.php
Normal file
174
api/app/Models/Cadastro/SujeitoAtencao/Lotacao.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Administracao\LotacaoPapel;
|
||||
use App\Models\Administracao\LotacaoPermissao;
|
||||
use App\Models\Administracao\Papel;
|
||||
use App\Models\Administracao\Permissao;
|
||||
use App\Models\Almoxarifado\Requisicao;
|
||||
use App\Models\Almoxarifado\SaidaItem;
|
||||
use App\Models\Ambulatorio\Jornada;
|
||||
use App\Models\Cadastro\Estabelecimento\CentroCusto;
|
||||
use App\Models\Cadastro\Estabelecimento\Infraestrutura;
|
||||
use App\Models\Model;
|
||||
use App\Models\ProntoAtendimento\Plantao\Plantao;
|
||||
use App\Models\Sigtap\Ocupacao;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Lotacao extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_lotacao';
|
||||
|
||||
protected $casts = [
|
||||
'realiza_atendimento' => 'boolean',
|
||||
'principal' => 'boolean',
|
||||
'ativo' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'infraestrutura_id',
|
||||
'ocupacao_id',
|
||||
'realiza_atendimento',
|
||||
'principal',
|
||||
'ativo',
|
||||
];
|
||||
|
||||
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',
|
||||
'pivot'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'unidade_id'
|
||||
];
|
||||
|
||||
public function infraestrutura()
|
||||
{
|
||||
return $this->belongsTo(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function usuario()
|
||||
{
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
|
||||
public function ocupacao()
|
||||
{
|
||||
return $this->belongsTo(Ocupacao::class);
|
||||
}
|
||||
|
||||
public function papeis()
|
||||
{
|
||||
return $this
|
||||
->belongsToMany(
|
||||
Papel::class,
|
||||
'administracao_lotacao_papel',
|
||||
'lotacao_id',
|
||||
'papel_id'
|
||||
)
|
||||
->using(LotacaoPapel::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function permissoes()
|
||||
{
|
||||
return $this
|
||||
->belongsToMany(
|
||||
Permissao::class,
|
||||
'administracao_lotacao_permissao',
|
||||
'lotacao_id',
|
||||
'permissao_id'
|
||||
)
|
||||
->using(LotacaoPermissao::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function plantoes()
|
||||
{
|
||||
return $this->hasMany(Plantao::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicoesRequisitante()
|
||||
{
|
||||
return $this->hasMany(Requisicao::class, 'created_lotacao_id');
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaItens()
|
||||
{
|
||||
return $this->hasMany(SaidaItem::class, 'created_lotacao_id');
|
||||
}
|
||||
|
||||
public function ambulatorioJornadas()
|
||||
{
|
||||
return $this->hasMany(Jornada::class);
|
||||
}
|
||||
|
||||
public function centrosCusto()
|
||||
{
|
||||
return $this->belongsToMany(CentroCusto::class,'cadastro_lotacao_centro_custo', 'lotacao_id', 'centro_custo_id')
|
||||
->using(LotacaoCentroCusto::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function getUnidadeIdAttribute()
|
||||
{
|
||||
return Infraestrutura::findOrFail($this->infraestrutura_id)->unidade_id;
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'papeis',
|
||||
'permissoes',
|
||||
'plantoes',
|
||||
'almoxarifadoRequisicoesRequisitante',
|
||||
'almoxarifadoSaidaItens',
|
||||
'ambulatorioJornadas',
|
||||
]);
|
||||
}
|
||||
|
||||
public function hasPermissao(Permissao $permissao)
|
||||
{
|
||||
return $this->isAllowed($permissao) || $this->isParentAllowed($permissao);
|
||||
}
|
||||
|
||||
private function isParentAllowed(Permissao $permissao)
|
||||
{
|
||||
foreach (($permissao->funcionalidade->funcionalidadesPai ?? []) as $funcionalidadePai) {
|
||||
|
||||
foreach (($funcionalidadePai->permissoes ?? []) as $permissaoPai) {
|
||||
|
||||
if ($this->isAllowed($permissaoPai)) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isAllowed(Permissao $permissao)
|
||||
{
|
||||
foreach (($this->papeis ?? []) as $papel) {
|
||||
|
||||
if ($papel->permissoes->contains('id', $permissao->id)) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->permissoes->contains('id', $permissao->id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class LotacaoCentroCusto extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class MobilidadeReduzida extends Model
|
||||
{
|
||||
protected $table = 'cadastro_mobilidade_reduzida';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class MotivoDuplicidadeCpf extends Model
|
||||
{
|
||||
protected $table = 'cadastro_motivo_duplicidade_cpf';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/SujeitoAtencao/Nacionalidade.php
Normal file
26
api/app/Models/Cadastro/SujeitoAtencao/Nacionalidade.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Nacionalidade extends Model
|
||||
{
|
||||
protected $table = 'cadastro_nacionalidade';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo_esus',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
64
api/app/Models/Cadastro/SujeitoAtencao/Obito.php
Normal file
64
api/app/Models/Cadastro/SujeitoAtencao/Obito.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\Cidadao;
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Cid;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Obito extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_obito';
|
||||
|
||||
protected $fillable = [
|
||||
'cidadao_id',
|
||||
'usuario_id',
|
||||
'obito_em',
|
||||
'declaracao',
|
||||
'causa',
|
||||
'cid_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',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'obito_em' => 'datetime',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'cid'
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function usuario()
|
||||
{
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
|
||||
public function cid()
|
||||
{
|
||||
return $this->belongsTo(Cid::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
295
api/app/Models/Cadastro/SujeitoAtencao/Paciente.php
Normal file
295
api/app/Models/Cadastro/SujeitoAtencao/Paciente.php
Normal file
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Exceptions\Model\DeletingModelException;
|
||||
use App\Models\Ambulatorio\Agendamento as AmbulatorioAgendamento;
|
||||
use App\Models\Ambulatorio\DemandaEspontanea;
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\CadastroIndividual;
|
||||
use App\Models\AtencaoBasica\Parametrizacao\Equipe;
|
||||
use App\Models\Cadastro\Estabelecimento\Unidade;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteCondicaoSaude;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteInformacaoResidencial;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteInformacaoSocial;
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento as ExameImagemAgendamento;
|
||||
use App\Models\ExameImagem\Agendamento\AgendamentoExame;
|
||||
use App\Models\ExameImagem\Jornada\Jornada;
|
||||
use App\Models\ExameLaboratorial\AgendamentoExame\Agendamento as ExameLaboratorialAgendamento;
|
||||
use App\Models\Farmacia\AltoCusto\Processo;
|
||||
use App\Models\Model;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Faa;
|
||||
use Dyrynda\Database\Support\CascadeSoftDeletes;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
|
||||
class Paciente extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use SoftDeletes, CascadeSoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_paciente';
|
||||
|
||||
protected $casts = [
|
||||
'sequencial_desconhecido_em' => 'datetime:Y-m-d H:i:s',
|
||||
'sem_documentos_em' => 'datetime:Y-m-d H:i:s',
|
||||
'validade_inicio' => 'datetime:Y-m-d',
|
||||
'validade_fim' => 'datetime:Y-m-d',
|
||||
'data_ultima_menstruacao' => 'datetime:Y-m-d',
|
||||
'bloqueado' => 'boolean',
|
||||
];
|
||||
|
||||
protected $cascadeDeletes = [
|
||||
'prontuariosUnidade',
|
||||
'historicoClassificacoes'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'cidadao_id',
|
||||
'classificacao_id',
|
||||
'subclassificacao_id',
|
||||
'validade_inicio',
|
||||
'validade_fim',
|
||||
'unidade_id',
|
||||
'email',
|
||||
'sequencial_desconhecido',
|
||||
'sequencial_desconhecido_em',
|
||||
'sem_documentos_em',
|
||||
'prontuario',
|
||||
'observacao',
|
||||
'protocolo_cross',
|
||||
'bloqueado',
|
||||
'senha',
|
||||
];
|
||||
|
||||
|
||||
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',
|
||||
'cidadao_id',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'cidadao',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'prontuario_unidade',
|
||||
'is_desconhecido',
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function jornadasExameImagem()
|
||||
{
|
||||
return $this->hasMany(Jornada::class);
|
||||
}
|
||||
|
||||
public function classificacao()
|
||||
{
|
||||
return $this->belongsTo(PacienteClassificacao::class);
|
||||
}
|
||||
|
||||
public function subclassificacao()
|
||||
{
|
||||
return $this->belongsTo(PacienteSubclassificacao::class);
|
||||
}
|
||||
|
||||
public function unidade()
|
||||
{
|
||||
return $this->belongsTo(Unidade::class);
|
||||
}
|
||||
|
||||
public function condicaoSaude()
|
||||
{
|
||||
return $this->hasOne(PacienteCondicaoSaude::class);
|
||||
}
|
||||
|
||||
public function informacaoSocial()
|
||||
{
|
||||
return $this->hasOne(PacienteInformacaoSocial::class);
|
||||
}
|
||||
|
||||
public function informacaoResidencial()
|
||||
{
|
||||
return $this->hasOne(PacienteInformacaoResidencial::class);
|
||||
}
|
||||
|
||||
public function responsavel()
|
||||
{
|
||||
return $this->hasOne(PacienteResponsavel::class);
|
||||
}
|
||||
|
||||
public function dum()
|
||||
{
|
||||
return $this->hasOne(PacienteDum::class);
|
||||
}
|
||||
|
||||
public function prontuariosUnidade()
|
||||
{
|
||||
return $this->hasMany(ProntuarioUnidade::class);
|
||||
}
|
||||
|
||||
public function historicoClassificacoes()
|
||||
{
|
||||
return $this->hasMany(PacienteClassificacaoHistorico::class);
|
||||
}
|
||||
|
||||
public function gestacoes()
|
||||
{
|
||||
return $this->hasMany(PacienteGestacao::class);
|
||||
}
|
||||
|
||||
public function faas()
|
||||
{
|
||||
return $this->hasMany(Faa::class);
|
||||
}
|
||||
|
||||
public function cadastroIndividual()
|
||||
{
|
||||
return $this->hasOne(CadastroIndividual::class);
|
||||
}
|
||||
|
||||
public function agendamento()
|
||||
{
|
||||
return $this->hasMany(ExameLaboratorialAgendamento::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(ExameImagemAgendamento::class);
|
||||
}
|
||||
|
||||
public function farmaciaAltoCustoProcessos()
|
||||
{
|
||||
return $this->hasMany(Processo::class);
|
||||
}
|
||||
|
||||
public function agendamentoExame()
|
||||
{
|
||||
return $this->belongsTo(AgendamentoExame::class);
|
||||
}
|
||||
|
||||
public function ambulatorioAgendamentos()
|
||||
{
|
||||
return $this->hasMany(AmbulatorioAgendamento::class);
|
||||
}
|
||||
|
||||
public function ambulatorioDemandasEspontaneas()
|
||||
{
|
||||
return $this->hasMany(DemandaEspontanea::class);
|
||||
}
|
||||
|
||||
public function getProntuarioAttribute($value)
|
||||
{
|
||||
return Str::padLeft($value, 6, '0');
|
||||
}
|
||||
|
||||
public function getProntuarioUnidadeAttribute()
|
||||
{
|
||||
$prontuarioUnidade = $this->prontuariosUnidade()->where('unidade_id', $this->unidade_id)->first();
|
||||
|
||||
return $prontuarioUnidade->prontuario ?? null;
|
||||
}
|
||||
|
||||
public function getIsDesconhecidoAttribute()
|
||||
{
|
||||
return $this->sequencial_desconhecido_em ? true : false;
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'faas',
|
||||
'ambulatorioAgendamentos',
|
||||
'ambulatorioDemandasEspontaneas'
|
||||
]);
|
||||
}
|
||||
|
||||
private function hasNoOne(array $relations) : bool
|
||||
{
|
||||
foreach ($relations as $relation) {
|
||||
|
||||
if (!is_null($this->{$relation}) && $this->{$relation}()->get()->isNotEmpty()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
|
||||
if (auth()->check()) {
|
||||
|
||||
$model->created_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->created_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
|
||||
$model->updated_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->updated_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
}
|
||||
});
|
||||
|
||||
static::updating(function ($model) {
|
||||
|
||||
if (auth()->check()) {
|
||||
|
||||
$model->updated_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->updated_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
}
|
||||
});
|
||||
|
||||
static::deleting(function ($model) {
|
||||
|
||||
if (!$model->isAllowedToDelete) {
|
||||
|
||||
throw new DeletingModelException();
|
||||
}
|
||||
});
|
||||
|
||||
static::deleted(function ($model) {
|
||||
|
||||
if ($model->trashed() && auth()->check()) {
|
||||
|
||||
$model->deleted_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->deleted_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
|
||||
$model->save();
|
||||
}
|
||||
});
|
||||
|
||||
static::restored(function ($model) {
|
||||
|
||||
$model->deleted_lotacao_id = null;
|
||||
$model->deleted_centro_custo_id = null;
|
||||
|
||||
$model->save();
|
||||
});
|
||||
}
|
||||
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
}
|
||||
|
||||
public function getJWTCustomClaims()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteClassificacao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_paciente_classificacao';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function pacientes()
|
||||
{
|
||||
return $this->hasMany(Paciente::class, 'classificacao_id');
|
||||
}
|
||||
|
||||
public function historicoClassificacoes()
|
||||
{
|
||||
return $this->hasMany(PacienteClassificacaoHistorico::class, 'classificacao_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PacienteClassificacaoHistorico extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_paciente_classificacao_historico';
|
||||
|
||||
protected $fillable = [
|
||||
'classificacao_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 paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
|
||||
public function classificacao()
|
||||
{
|
||||
return $this->belongsTo(Classificacao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
124
api/app/Models/Cadastro/SujeitoAtencao/PacienteCondicaoSaude.php
Normal file
124
api/app/Models/Cadastro/SujeitoAtencao/PacienteCondicaoSaude.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\DoencaCardiaca;
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\DoencaRespiratoria;
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\ProblemasRins;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteCondicaoSaudeDoencaRespiratoria;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteCondicaoSaudeProblemasRins;
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteCondicaoSaude extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_condicao_saude';
|
||||
|
||||
protected $casts = [
|
||||
'internacao' => 'boolean',
|
||||
'doenca_cardiaca' => 'boolean',
|
||||
'problemas_rins' => 'boolean',
|
||||
'doenca_respiratoria' => 'boolean',
|
||||
'tratamento_psiquiatrico' => 'boolean',
|
||||
'acamado' => 'boolean',
|
||||
'domiciliado' => 'boolean',
|
||||
'plantas_medicinais' => 'boolean',
|
||||
'praticas_integrativas' => 'boolean',
|
||||
'tratamento_saude_mental' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'paciente_id',
|
||||
'peso_id',
|
||||
'internacao',
|
||||
'internacao_motivo',
|
||||
'internacao_data',
|
||||
'doenca_cardiaca',
|
||||
'problemas_rins',
|
||||
'doenca_respiratoria',
|
||||
'tratamento_saude_mental',
|
||||
'tratamento_saude_mental_internacao_data',
|
||||
'tratamento_saude_mental_alta_data',
|
||||
'acamado',
|
||||
'orientacao_sexual',
|
||||
'orientacao_sexual_id',
|
||||
'domiciliado',
|
||||
'plantas_medicinais',
|
||||
'plantas_medicinais_quais',
|
||||
'praticas_integrativas',
|
||||
'outras_condicoes_primaria',
|
||||
'outras_condicoes_secundaria',
|
||||
'outras_condicoes_terciaria',
|
||||
];
|
||||
|
||||
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 paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
|
||||
public function doencaCardiaca()
|
||||
{
|
||||
return $this->belongsToMany(DoencaCardiaca::class, 'cadastro_paciente_condicao_saude_doenca_cardiaca')
|
||||
->using(PacienteCondicaoSaudeDoencaCardiaca::class)
|
||||
->as('PacienteCondicaoSaudeDoencaCardiaca')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'paciente_condicao_saude_id',
|
||||
'doenca_cardiaca_id',
|
||||
)
|
||||
->select(
|
||||
'atencao_basica_cadastro_doenca_cardiaca.id',
|
||||
'atencao_basica_cadastro_doenca_cardiaca.descricao'
|
||||
)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function doencaRespiratoria()
|
||||
{
|
||||
return $this->belongsToMany(DoencaRespiratoria::class, 'cadastro_paciente_condicao_saude_doenca_respiratoria')
|
||||
->using(PacienteCondicaoSaudeDoencaRespiratoria::class)
|
||||
->as('PacienteCondicaoSaudeDoencaRespiratoria')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'paciente_condicao_saude_id',
|
||||
'doenca_respiratoria_id',
|
||||
)
|
||||
->select(
|
||||
'atencao_basica_cadastro_doenca_respiratoria.id',
|
||||
'atencao_basica_cadastro_doenca_respiratoria.descricao'
|
||||
)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function problemasRins()
|
||||
{
|
||||
return $this->belongsToMany(ProblemasRins::class, 'cadastro_paciente_condicao_saude_problemas_rins')
|
||||
->using(PacienteCondicaoSaudeProblemasRins::class)
|
||||
->as('PacienteCondicaoSaudeProblemasRins')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'paciente_condicao_saude_id',
|
||||
'problemas_rins_id',
|
||||
)
|
||||
->select(
|
||||
'atencao_basica_cadastro_problemas_rins.id',
|
||||
'atencao_basica_cadastro_problemas_rins.descricao'
|
||||
)
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class PacienteCondicaoSaudeDoencaCardiaca extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'doenca_cardiaca_id',
|
||||
'paciente_condicao_saude_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class PacienteCondicaoSaudeDoencaRespiratoria extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'doenca_respiratoria_id',
|
||||
'paciente_condicao_saude_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class PacienteCondicaoSaudeProblemasRins extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'problemas_rins_id',
|
||||
'paciente_condicao_saude_id',
|
||||
];
|
||||
}
|
||||
45
api/app/Models/Cadastro/SujeitoAtencao/PacienteDum.php
Normal file
45
api/app/Models/Cadastro/SujeitoAtencao/PacienteDum.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\AtencaoBasica\Parametrizacao\Equipe;
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteDum extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_dum';
|
||||
|
||||
protected $casts = [
|
||||
'gravidez_planejada' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'paciente_id',
|
||||
'data_ultima_menstruacao',
|
||||
'idade_gestacional_semanas',
|
||||
'idade_gestacional_dias',
|
||||
'data_possivel_parto',
|
||||
'gravidez_planejada',
|
||||
'gestacao_previa',
|
||||
'parto',
|
||||
];
|
||||
|
||||
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 paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
}
|
||||
36
api/app/Models/Cadastro/SujeitoAtencao/PacienteGestacao.php
Normal file
36
api/app/Models/Cadastro/SujeitoAtencao/PacienteGestacao.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteGestacao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_paciente_gestacao';
|
||||
|
||||
protected $casts = [
|
||||
'inicio' => 'datetime:d/m/Y',
|
||||
'fim' => 'datetime:d/m/Y',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'paciente_id',
|
||||
'inicio',
|
||||
'fim',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
}
|
||||
41
api/app/Models/Cadastro/SujeitoAtencao/PacienteHistorico.php
Normal file
41
api/app/Models/Cadastro/SujeitoAtencao/PacienteHistorico.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\AtencaoBasica\Parametrizacao\Equipe;
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteHistorico extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_historico';
|
||||
|
||||
protected $fillable = [
|
||||
'paciente_id',
|
||||
'equipe',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
|
||||
public function equipe()
|
||||
{
|
||||
return $this->belongsTo(Equipe::class);
|
||||
}
|
||||
|
||||
public function lotacao()
|
||||
{
|
||||
return $this->belongsTo(lotacao::class, 'created_lotacao_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteInformacaoResidencialFinanciamento;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteInformacaoResidencialVeiculo;
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Ocupacao;
|
||||
|
||||
class PacienteInformacaoResidencial extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_informacao_residencial';
|
||||
|
||||
protected $casts = [
|
||||
'possui_veiculo_proprio' => 'boolean',
|
||||
'possui_financiamento' => 'boolean',
|
||||
'possui_emprestimo' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'paciente_id',
|
||||
'renda_mensal',
|
||||
'ocupacao_id',
|
||||
'renda_total_familiar',
|
||||
'possui_veiculo_proprio',
|
||||
'possui_financiamento',
|
||||
'possui_emprestimo',
|
||||
];
|
||||
|
||||
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 paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
|
||||
public function veiculo()
|
||||
{
|
||||
return $this->hasMany(PacienteInformacaoResidencialVeiculo::class);
|
||||
}
|
||||
|
||||
public function financiamento()
|
||||
{
|
||||
return $this->hasMany(PacienteInformacaoResidencialFinanciamento::class);
|
||||
}
|
||||
|
||||
public function emprestimo()
|
||||
{
|
||||
return $this->hasMany(PacienteInformacaoResidencialEmprestimo::class);
|
||||
}
|
||||
|
||||
public function ocupacao()
|
||||
{
|
||||
return $this->belongsTo(Ocupacao::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteInformacaoResidencialEmprestimo extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_informacao_residencial_emprestimo';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'paciente_informacao_residencial_id',
|
||||
'tipo',
|
||||
'valor_parcela',
|
||||
'quantidade_parcela',
|
||||
];
|
||||
|
||||
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 pacienteInformacaoResidencial()
|
||||
{
|
||||
return $this->belongsTo(PacienteInformacaoResidencial::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteInformacaoResidencialFinanciamento extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_informacao_residencial_financiamento';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'paciente_informacao_residencial_id',
|
||||
'tipo',
|
||||
'valor_parcela',
|
||||
'quantidade_parcela',
|
||||
];
|
||||
|
||||
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 pacienteInformacaoResidencial()
|
||||
{
|
||||
return $this->belongsTo(PacienteInformacaoResidencial::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteInformacaoResidencialVeiculo extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_informacao_residencial_veiculo';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'paciente_informacao_residencial_id',
|
||||
'modelo',
|
||||
'ano',
|
||||
];
|
||||
|
||||
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 pacienteInformacaoResidencial()
|
||||
{
|
||||
return $this->belongsTo(PacienteInformacaoResidencial::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\AcompanhamentoInfantil;
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\ComunidadeTradicional;
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\Curso;
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\SaidaCidadao;
|
||||
use App\Models\AtencaoBasica\CadastroIndividual\SituacaoMercadoTrabalho;
|
||||
use App\Models\Cadastro\SujeitoAtencao\DeficienciaBase;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteInformacaoSocialAcompanhamentoInfantil;
|
||||
use App\Models\Cadastro\SujeitoAtencao\PacienteInformacaoSocialDeficiencia;
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteInformacaoSocial extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_informacao_social';
|
||||
|
||||
protected $casts = [
|
||||
'responsavel' => 'boolean',
|
||||
'frequenta_escola_creche' => 'boolean',
|
||||
'frequenta_cuidador_tradicional' => 'boolean',
|
||||
'participa_grupo_comunitario' => 'boolean',
|
||||
'plano_saude' => 'boolean',
|
||||
'comunidade_tradicional' => 'boolean',
|
||||
'recusa_cadastro' => 'boolean',
|
||||
'deficiente' => 'boolean',
|
||||
'orientacao_sexual' => 'boolean',
|
||||
'alimentos_acabaram' => 'boolean',
|
||||
'comeu_alguns_alimentos' => 'boolean',
|
||||
'data_atualizacao_tria' => 'date',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'paciente_id',
|
||||
'responsavel',
|
||||
'responsavel_cidadao_id',
|
||||
'parentesco_responsavel_id',
|
||||
'curso_id',
|
||||
'orientacao_sexual',
|
||||
'orientacao_sexual_id',
|
||||
'deficiente',
|
||||
'frequenta_escola_creche',
|
||||
'situacao_mercado_trabalho_id',
|
||||
'frequenta_cuidador_tradicional',
|
||||
'participa_grupo_comunitario',
|
||||
'plano_saude',
|
||||
'comunidade_tradicional',
|
||||
'comunidade_tradicional_id',
|
||||
'saida_cidadao_id',
|
||||
'motivo_saida_data',
|
||||
'recusa_cadastro',
|
||||
'alimentos_acabaram',
|
||||
'comeu_alguns_alimentos',
|
||||
'data_atualizacao_tria',
|
||||
];
|
||||
|
||||
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 paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
|
||||
public function curso()
|
||||
{
|
||||
return $this->belongsTo(Curso::class);
|
||||
}
|
||||
|
||||
public function saidaCidadao()
|
||||
{
|
||||
return $this->belongsTo(SaidaCidadao::class);
|
||||
}
|
||||
|
||||
public function responsavelCidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function situacaoMercadoTrabalho()
|
||||
{
|
||||
return $this->belongsTo(SituacaoMercadoTrabalho::class);
|
||||
}
|
||||
|
||||
public function comunidadeTradicionalQual()
|
||||
{
|
||||
return $this->belongsTo(ComunidadeTradicional::class, 'comunidade_tradicional_id');
|
||||
}
|
||||
|
||||
public function acompanhamentoInfantil()
|
||||
{
|
||||
return $this->belongsToMany(AcompanhamentoInfantil::class, 'cadastro_paciente_informacao_social_acompanhamento_infantil')
|
||||
->using(PacienteInformacaoSocialAcompanhamentoInfantil::class)
|
||||
->as('PacienteInformacaoSocialAcompanhamentoInfantil')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'paciente_informacao_social_id',
|
||||
'acompanhamento_infantil_id',
|
||||
)
|
||||
->select(
|
||||
'atencao_basica_cadastro_acompanhamento_infantil.id',
|
||||
'atencao_basica_cadastro_acompanhamento_infantil.descricao'
|
||||
)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function deficiencia()
|
||||
{
|
||||
return $this->belongsToMany(DeficienciaBase::class, 'cadastro_paciente_informacao_social_deficiencia_base')
|
||||
->using(PacienteInformacaoSocialDeficiencia::class)
|
||||
->as('PacienteInformacaoSocialDeficiencia')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'paciente_informacao_social_id',
|
||||
'deficiencia_base_id',
|
||||
)
|
||||
->select('cadastro_deficiencia_base.id')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class PacienteInformacaoSocialAcompanhamentoInfantil extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'acompanhamento_infantil_id',
|
||||
'paciente_informacao_social_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class PacienteInformacaoSocialDeficiencia extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'deficiencia_base_id',
|
||||
'paciente_informacao_social_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\AtencaoBasica\Parametrizacao\Equipe;
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteResponsavel extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_paciente_responsavel';
|
||||
|
||||
protected $casts = [
|
||||
'responsavel_data' => 'datetime:Y-m-d',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'paciente_id',
|
||||
'responsavel_usuario_id',
|
||||
'responsavel_equipe_id',
|
||||
'responsavel_ocupacao_id',
|
||||
'responsavel_data',
|
||||
];
|
||||
|
||||
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 paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
|
||||
public function usuario()
|
||||
{
|
||||
return $this->belongsTo(Usuario::class, 'responsavel_usuario_id');
|
||||
}
|
||||
|
||||
public function equipe()
|
||||
{
|
||||
return $this->belongsTo(Equipe::class, 'responsavel_equipe_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class PacienteSubclassificacao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_paciente_subclassificacao';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function pacientes()
|
||||
{
|
||||
return $this->hasMany(Paciente::class, 'subclassificacao_id');
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/SujeitoAtencao/PreferenciaNome.php
Normal file
25
api/app/Models/Cadastro/SujeitoAtencao/PreferenciaNome.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class PreferenciaNome extends Model
|
||||
{
|
||||
protected $table = 'cadastro_preferencia_nome';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
53
api/app/Models/Cadastro/SujeitoAtencao/ProntuarioUnidade.php
Normal file
53
api/app/Models/Cadastro/SujeitoAtencao/ProntuarioUnidade.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Cadastro\Estabelecimento\Unidade;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProntuarioUnidade extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_prontuario_unidade';
|
||||
|
||||
protected $fillable = [
|
||||
'paciente_id',
|
||||
'unidade_id',
|
||||
'prontuario'
|
||||
];
|
||||
|
||||
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',
|
||||
'paciente_id',
|
||||
'unidade_id'
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'unidade'
|
||||
];
|
||||
|
||||
public function paciente()
|
||||
{
|
||||
return $this->belongsTo(Paciente::class);
|
||||
}
|
||||
|
||||
public function unidade()
|
||||
{
|
||||
return $this->belongsTo(Unidade::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
27
api/app/Models/Cadastro/SujeitoAtencao/RacaCor.php
Normal file
27
api/app/Models/Cadastro/SujeitoAtencao/RacaCor.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class RacaCor extends Model
|
||||
{
|
||||
protected $table = 'cadastro_raca_cor';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'codigo',
|
||||
'descricao',
|
||||
'codigo_esus',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
45
api/app/Models/Cadastro/SujeitoAtencao/Sexo.php
Normal file
45
api/app/Models/Cadastro/SujeitoAtencao/Sexo.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Enums\Cadastro\SujeitoAtencao\Sexo as SujeitoAtencaoSexo;
|
||||
use App\Models\Model;
|
||||
|
||||
class Sexo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_sexo';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo_esus',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'identificador'
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
|
||||
public function getIdentificadorAttribute()
|
||||
{
|
||||
if ($this->id === SujeitoAtencaoSexo::MASCULINO) {
|
||||
|
||||
return 'M';
|
||||
}
|
||||
if ($this->id === SujeitoAtencaoSexo::FEMININO) {
|
||||
|
||||
return 'F';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class SituacaoFamiliarConjugal extends Model
|
||||
{
|
||||
protected $table = 'cadastro_situacao_familiar_conjugal';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/SujeitoAtencao/TipoSanguineo.php
Normal file
25
api/app/Models/Cadastro/SujeitoAtencao/TipoSanguineo.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class TipoSanguineo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_tipo_sanguineo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
}
|
||||
42
api/app/Models/Cadastro/SujeitoAtencao/TituloEleitor.php
Normal file
42
api/app/Models/Cadastro/SujeitoAtencao/TituloEleitor.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TituloEleitor extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_titulo_eleitor';
|
||||
|
||||
protected $fillable = [
|
||||
'numero',
|
||||
'zona',
|
||||
'secao',
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadao_id'
|
||||
];
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
251
api/app/Models/Cadastro/SujeitoAtencao/Usuario.php
Normal file
251
api/app/Models/Cadastro/SujeitoAtencao/Usuario.php
Normal file
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Exceptions\Model\DeletingModelException;
|
||||
use App\Models\Almoxarifado\SaidaBaixa;
|
||||
use App\Models\Almoxarifado\SaidaRequisicao;
|
||||
use App\Models\Almoxarifado\SaidaTransferencia;
|
||||
use App\Models\AtencaoBasica\Parametrizacao\Equipe;
|
||||
use App\Models\AtencaoBasica\Parametrizacao\EquipeUsuario;
|
||||
use App\Models\Cadastro\Estabelecimento\Unidade;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Farmacia\Receita;
|
||||
use App\Models\Intranet\Estado;
|
||||
use Hash;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
class Usuario extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_usuario';
|
||||
|
||||
protected $fillable = [
|
||||
'cidadao_id',
|
||||
'registro_tipo_id',
|
||||
'registro_tipo_outro',
|
||||
'registro_numero',
|
||||
'registro_estado_id',
|
||||
'usuario',
|
||||
'email',
|
||||
'senha',
|
||||
'bloqueado',
|
||||
'is_administrador',
|
||||
'troca_senha',
|
||||
'tempo_sessao',
|
||||
'data_hora_ultimo_acesso',
|
||||
'data_hora_ultima_tentativa',
|
||||
'data_hora_ultima_troca_senha',
|
||||
];
|
||||
|
||||
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',
|
||||
'cidadao_id',
|
||||
'senha'
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'registroTipo',
|
||||
'cidadao',
|
||||
'atencaoBasicaEquipes',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_administrador' => 'boolean',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
|
||||
if (auth()->check()) {
|
||||
|
||||
$model->created_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->created_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
|
||||
$model->updated_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->updated_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
}
|
||||
});
|
||||
|
||||
self::created(function($model){
|
||||
UsuarioHistoricoSenha::create([
|
||||
'usuario_id' => $model->id,
|
||||
'senha' => $model->senha,
|
||||
]);
|
||||
});
|
||||
|
||||
static::updating(function ($model) {
|
||||
|
||||
if (auth()->check()) {
|
||||
|
||||
$model->updated_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->updated_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
}
|
||||
});
|
||||
|
||||
self::updated(function($model){
|
||||
if ($model->senha !== $model->getOriginal('senha')) {
|
||||
UsuarioHistoricoSenha::create([
|
||||
'usuario_id' => $model->id,
|
||||
'senha' => $model->senha,
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
static::deleting(function ($model) {
|
||||
|
||||
if (!$model->isAllowedToDelete) {
|
||||
|
||||
throw new DeletingModelException;
|
||||
}
|
||||
});
|
||||
|
||||
static::deleted(function ($model) {
|
||||
|
||||
if ($model->trashed() && auth()->check()) {
|
||||
|
||||
$model->deleted_lotacao_id = auth()->payload()->get('lotacao_id');
|
||||
$model->deleted_centro_custo_id = auth()->payload()->get('centro_custo_id');
|
||||
|
||||
$model->save();
|
||||
}
|
||||
});
|
||||
|
||||
static::restored(function ($model) {
|
||||
|
||||
$model->deleted_lotacao_id = null;
|
||||
$model->deleted_centro_custo_id = null;
|
||||
|
||||
$model->save();
|
||||
});
|
||||
}
|
||||
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
}
|
||||
|
||||
public function getJWTCustomClaims()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function cidadao()
|
||||
{
|
||||
return $this->belongsTo(Cidadao::class);
|
||||
}
|
||||
|
||||
public function registroTipo()
|
||||
{
|
||||
return $this->belongsTo(UsuarioRegistroTipo::class);
|
||||
}
|
||||
|
||||
public function registroEstado()
|
||||
{
|
||||
return $this->belongsTo(Estado::class);
|
||||
}
|
||||
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(Unidade::class, 'gestor_id');
|
||||
}
|
||||
|
||||
public function lotacoes()
|
||||
{
|
||||
return $this->hasMany(Lotacao::class);
|
||||
}
|
||||
|
||||
public function lotacoesAtivas()
|
||||
{
|
||||
return $this->hasMany(Lotacao::class)->where('ativo', true);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaRequisicoes()
|
||||
{
|
||||
return $this->hasMany(SaidaRequisicao::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaTransferencias()
|
||||
{
|
||||
return $this->hasMany(SaidaTransferencia::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaBaixas()
|
||||
{
|
||||
return $this->hasMany(SaidaBaixa::class, 'usuario_solicitante_id');
|
||||
}
|
||||
|
||||
public function farmaciaReceitas()
|
||||
{
|
||||
return $this->hasMany(Receita::class);
|
||||
}
|
||||
|
||||
public function getNomeAttribute()
|
||||
{
|
||||
return $this->cidadao->nome;
|
||||
}
|
||||
|
||||
public function setSenhaAttribute($value)
|
||||
{
|
||||
$this->attributes['senha'] = Hash::make($value);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'unidades',
|
||||
'lotacoes',
|
||||
'almoxarifadoSaidaRequisicoes',
|
||||
'almoxarifadoSaidaTransferencias',
|
||||
'almoxarifadoSaidaBaixas',
|
||||
'farmaciaReceitas',
|
||||
]);
|
||||
}
|
||||
|
||||
private function hasNoOne(array $relations) : bool
|
||||
{
|
||||
foreach ($relations as $relation) {
|
||||
|
||||
if (!is_null($this->{$relation}) && $this->{$relation}()->get()->isNotEmpty()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function atencaoBasicaEquipes()
|
||||
{
|
||||
|
||||
return $this->belongsToMany(Equipe::class, 'atencao_basica_parametrizacao_equipe_usuario')
|
||||
->using(EquipeUsuario::class)
|
||||
->as('equipeUsuario')
|
||||
->withPivot('ativo')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
24
api/app/Models/Cadastro/SujeitoAtencao/UsuarioAssinatura.php
Normal file
24
api/app/Models/Cadastro/SujeitoAtencao/UsuarioAssinatura.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class UsuarioAssinatura extends Model
|
||||
{
|
||||
protected $table = 'cadastro_usuario_assinatura';
|
||||
|
||||
protected $fillable = [
|
||||
'usuario_id',
|
||||
'arquivo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_centro_custo_id',
|
||||
'created_lotacao_id',
|
||||
'updated_at',
|
||||
'updated_centro_custo_id',
|
||||
'updated_lotacao_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class UsuarioHistoricoAcesso extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_usuario_historico_acesso';
|
||||
|
||||
protected $fillable = [
|
||||
'usuario_id',
|
||||
'sucesso',
|
||||
'ativo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_centro_custo_id',
|
||||
'created_lotacao_id',
|
||||
'updated_at',
|
||||
'updated_centro_custo_id',
|
||||
'updated_lotacao_id',
|
||||
'deleted_at',
|
||||
'deleted_centro_custo_id',
|
||||
'deleted_lotacao_id',
|
||||
];
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class UsuarioHistoricoSenha extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_usuario_historico_senha';
|
||||
|
||||
protected $fillable = [
|
||||
'usuario_id',
|
||||
'senha',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_centro_custo_id',
|
||||
'created_lotacao_id',
|
||||
'updated_at',
|
||||
'updated_centro_custo_id',
|
||||
'updated_lotacao_id',
|
||||
'deleted_at',
|
||||
'deleted_centro_custo_id',
|
||||
'deleted_lotacao_id',
|
||||
];
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\SujeitoAtencao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class UsuarioRegistroTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_usuario_registro_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'sigla',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function usuarios()
|
||||
{
|
||||
return $this->hasMany(Usuario::class, 'registro_tipo_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user