This commit is contained in:
211
api/app/Models/Cadastro/Especialidade.php
Normal file
211
api/app/Models/Cadastro/Especialidade.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Ambulatorio\Jornada;
|
||||
use App\Models\Ambulatorio\ParametrizacaoInfraestruturaEspecialidade;
|
||||
use App\Models\Ambulatorio\ParametrizacaoInfraestruturaSms;
|
||||
use App\Models\Ambulatorio\ParametrizacaoInfraestruturaSmsEspecialidade;
|
||||
use App\Models\Ambulatorio\ProblemaCondicaoSituacao;
|
||||
use App\Models\Ambulatorio\SaudeBucalVigilancia;
|
||||
use App\Models\AtencaoBasica\AtendimentoIndividual\CondicaoAvaliada;
|
||||
use App\Models\AtencaoBasica\AtendimentoIndividual\Conduta;
|
||||
use App\Models\AtencaoBasica\AtendimentoOdontologico\TipoConsulta;
|
||||
use App\Models\Geral\Ciap;
|
||||
use App\Models\Model;
|
||||
use App\Models\Raas\MotivoSaidaPermanencia;
|
||||
use App\Models\Regulacao\ParametrizacaoDataDesejadaEspecialidade;
|
||||
use App\Models\Sigtap\Cid;
|
||||
use App\Models\Sigtap\Ocupacao;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
|
||||
class Especialidade extends Model
|
||||
{
|
||||
protected $table = 'cadastro_especialidade';
|
||||
|
||||
protected $casts = [
|
||||
'ativo' => 'boolean',
|
||||
'encaminhamento' => 'boolean',
|
||||
'is_regulado' => 'boolean',
|
||||
'permite_agendamento_gestante' => 'boolean',
|
||||
'permite_agendamento_mesmo_dia' => 'boolean',
|
||||
'permite_agendamento_nao_municipe' => 'boolean',
|
||||
'permite_fechamento_sem_procedimento' => 'boolean',
|
||||
'precisa_informar_conclusao_tratamento' => 'boolean',
|
||||
'exigir_peso_altura_circunferencia' => 'boolean',
|
||||
'permite_integracao_conectasus_cidadao' => 'boolean',
|
||||
'permite_integracao_aplicativo_feridas' => 'boolean',
|
||||
'tratamento' => 'boolean',
|
||||
'is_ppi' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'ativo',
|
||||
'encaminhamento',
|
||||
'idade_maxima',
|
||||
'idade_minima',
|
||||
'is_regulado',
|
||||
'limite_consulta',
|
||||
'limite_consulta_mes',
|
||||
'mensagem_protocolo_agendamento',
|
||||
'nome',
|
||||
'ocupacao_id',
|
||||
'permite_agendamento_gestante',
|
||||
'permite_agendamento_mesmo_dia',
|
||||
'permite_agendamento_nao_municipe',
|
||||
'permite_fechamento_sem_procedimento',
|
||||
'precisa_informar_conclusao_tratamento',
|
||||
'exigir_peso_altura_circunferencia',
|
||||
'permite_integracao_conectasus_cidadao',
|
||||
'permite_integracao_aplicativo_feridas',
|
||||
'procedimento_grupo_codigo',
|
||||
'regulacao_tipo_id',
|
||||
'sexo_id',
|
||||
'tratamento',
|
||||
'atencao_basica_procedimento_padrao_codigo',
|
||||
'atencao_basica_motivo_saida_permanencia_id',
|
||||
'atencao_basica_classificacao_codigo',
|
||||
'atencao_basica_numero_autorizacao',
|
||||
'atencao_basica_problema_condicao_situacao_id',
|
||||
'atencao_basica_problema_condicao_ciap_id',
|
||||
'atencao_basica_problema_condicao_cid_id',
|
||||
'atencao_basica_odontologico_consulta_tipo_id',
|
||||
'atencao_basica_odontologico_vigilancia_id',
|
||||
'atencao_basica_odontologico_conduta_id',
|
||||
'is_ppi',
|
||||
'valor_ppi',
|
||||
'limite_ocorrencias_paciente',
|
||||
'periodo_monitoramento',
|
||||
'tempo_liberacao',
|
||||
'tempo_medio_previsto_atendimento_dias',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function ocupacao()
|
||||
{
|
||||
return $this->belongsTo(Ocupacao::class);
|
||||
}
|
||||
|
||||
public function atencaoBasicaMotivoSaidaPermanencia()
|
||||
{
|
||||
return $this->belongsTo(MotivoSaidaPermanencia::class);
|
||||
}
|
||||
|
||||
public function atencaoBasicaProblemaCondicaoSituacao()
|
||||
{
|
||||
return $this->belongsTo(ProblemaCondicaoSituacao::class);
|
||||
}
|
||||
|
||||
public function atencaoBasicaProblemaCondicaoCiap()
|
||||
{
|
||||
return $this->belongsTo(Ciap::class);
|
||||
}
|
||||
|
||||
public function atencaoBasicaProblemaCondicaoCid()
|
||||
{
|
||||
return $this->belongsTo(Cid::class);
|
||||
}
|
||||
|
||||
public function atencaoBasicaOdontologicoConsultaTipo()
|
||||
{
|
||||
return $this->belongsTo(TipoConsulta::class);
|
||||
}
|
||||
|
||||
public function atencaoBasicaOdontologicoVigilancia()
|
||||
{
|
||||
return $this->belongsTo(SaudeBucalVigilancia::class);
|
||||
}
|
||||
|
||||
public function atencaoBasicaOdontologicoConduta()
|
||||
{
|
||||
return $this->belongsTo(Conduta::class);
|
||||
}
|
||||
|
||||
public function condutas()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Conduta::class,
|
||||
'cadastro_especialidade_conduta',
|
||||
'especialidade_id',
|
||||
'conduta_id'
|
||||
)
|
||||
->using(EspecialidadeConduta::class)
|
||||
->as('especialidadeConduta')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function condicoesAvaliadas()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
CondicaoAvaliada::class,
|
||||
'cadastro_especialidade_condicao_avaliada',
|
||||
'especialidade_id',
|
||||
'condicao_avaliada_id'
|
||||
)
|
||||
->using(EspecialidadeCondicaoAvaliada::class)
|
||||
->as('especialidadeCondicaoAvaliada')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function dataDesejadaEspecialidades()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Especialidade::class,
|
||||
'regulacao_parametrizacao_data_desejada_especialidade',
|
||||
'parametrizacao_id',
|
||||
'especialidade_id'
|
||||
)
|
||||
->using(ParametrizacaoDataDesejadaEspecialidade::class)
|
||||
->as('dataDesejadaEspecialidade')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function ambulatorioParametrizacoesSms()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
ParametrizacaoInfraestruturaSms::class,
|
||||
'ambulatorio_parametrizacao_infraestrutura_sms_especialidade',
|
||||
'especialidade_id',
|
||||
'parametrizacao_infraestrutura_sms_id'
|
||||
)
|
||||
->using(ParametrizacaoInfraestruturaSmsEspecialidade::class)
|
||||
->as('parametrizacaoInfraestruturaSmsEspecialidade')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function ambulatorioParametrizacoesInfraestruturaEspecialidade()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoInfraestruturaEspecialidade::class);
|
||||
}
|
||||
|
||||
public function ambulatorioJornadas()
|
||||
{
|
||||
return $this->hasMany(Jornada::class);
|
||||
}
|
||||
|
||||
public function getProcedimentoGrupoAttribute()
|
||||
{
|
||||
return is_null($this->procedimento_grupo_codigo)
|
||||
? null
|
||||
: Procedimento::where('codigo', $this->procedimento_grupo_codigo)
|
||||
->orderByDesc('competencia_id')
|
||||
->first();
|
||||
}
|
||||
|
||||
public function getAtencaoBasicaProcedimentoPadraoAttribute()
|
||||
{
|
||||
return is_null($this->atencao_basica_procedimento_padrao_codigo)
|
||||
? null
|
||||
: Procedimento::where('codigo', $this->atencao_basica_procedimento_padrao_codigo)
|
||||
->orderByDesc('competencia_id')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
17
api/app/Models/Cadastro/EspecialidadeCondicaoAvaliada.php
Normal file
17
api/app/Models/Cadastro/EspecialidadeCondicaoAvaliada.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class EspecialidadeCondicaoAvaliada extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
17
api/app/Models/Cadastro/EspecialidadeConduta.php
Normal file
17
api/app/Models/Cadastro/EspecialidadeConduta.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class EspecialidadeConduta extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
152
api/app/Models/Cadastro/Estabelecimento/CentroCusto.php
Normal file
152
api/app/Models/Cadastro/Estabelecimento/CentroCusto.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Almoxarifado\Entrada;
|
||||
use App\Models\Almoxarifado\ParametrizacaoControleEstoqueGrupo;
|
||||
use App\Models\Almoxarifado\ParametrizacaoPortalDivulgacaoGrupo;
|
||||
use App\Models\Almoxarifado\ParametrizacaoDispensacaoUnidade;
|
||||
use App\Models\Almoxarifado\ParametrizacaoEstoque;
|
||||
use App\Models\Almoxarifado\Requisicao;
|
||||
use App\Models\Almoxarifado\RequisicaoPermissao;
|
||||
use App\Models\Almoxarifado\Saida;
|
||||
use App\Models\Almoxarifado\SaidaRequisicao;
|
||||
use App\Models\Almoxarifado\SaidaTransferencia;
|
||||
use App\Models\Farmacia\AltoCusto\Processo;
|
||||
use App\Models\Farmacia\ReceitaItemEntrega;
|
||||
use App\Models\Model;
|
||||
use App\Models\PainelSenha\Status;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CentroCusto extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_centro_custo';
|
||||
|
||||
protected $fillable = [
|
||||
'infraestrutura_id',
|
||||
'setor_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 infraestrutura()
|
||||
{
|
||||
return $this->belongsTo(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function setor()
|
||||
{
|
||||
return $this->belongsTo(Setor::class);
|
||||
}
|
||||
|
||||
public function salas()
|
||||
{
|
||||
return $this->hasMany(Sala::class);
|
||||
}
|
||||
|
||||
public function status()
|
||||
{
|
||||
return $this->hasMany(Status::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoEntradas()
|
||||
{
|
||||
return $this->hasMany(Entrada::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidas()
|
||||
{
|
||||
return $this->hasMany(Saida::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesControleEstoqueGrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoControleEstoqueGrupo::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesPortalDivulgacaoGrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoPortalDivulgacaoGrupo::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacaoDispensacaoUnidades()
|
||||
{
|
||||
return $this->hasOne(ParametrizacaoDispensacaoUnidade::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesEstoque()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoEstoque::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicaoPermissoesRequisitante()
|
||||
{
|
||||
return $this->hasMany(RequisicaoPermissao::class, 'centro_custo_requisitante_id');
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicaoPermissoesAlmoxarifado()
|
||||
{
|
||||
return $this->hasMany(RequisicaoPermissao::class, 'created_centro_custo_id');
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicoes()
|
||||
{
|
||||
return $this->hasMany(Requisicao::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicoesRequisitante()
|
||||
{
|
||||
return $this->hasMany(Requisicao::class, 'created_centro_custo_id');
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaRequisicoes()
|
||||
{
|
||||
return $this->hasMany(SaidaRequisicao::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaTransferencias()
|
||||
{
|
||||
return $this->hasMany(SaidaTransferencia::class);
|
||||
}
|
||||
|
||||
public function farmaciaReceitaEntregas()
|
||||
{
|
||||
return $this->hasMany(ReceitaItemEntrega::class, 'created_centro_custo_id');
|
||||
}
|
||||
|
||||
public function farmaciaAltoCustoProcessos()
|
||||
{
|
||||
return $this->hasMany(Processo::class, 'created_centro_custo_id');
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'salas',
|
||||
'plantoes',
|
||||
'almoxarifadoEntradas',
|
||||
'almoxarifadoSaidas',
|
||||
'almoxarifadoParametrizacoesControleEstoqueGrupo',
|
||||
'almoxarifadoRequisicaoPermissoesRequisitante',
|
||||
'almoxarifadoRequisicaoPermissoesAlmoxarifado',
|
||||
'almoxarifadoRequisicoes',
|
||||
'almoxarifadoRequisicoesRequisitante',
|
||||
'almoxarifadoSaidaRequisicoes',
|
||||
'almoxarifadoSaidaTransferencias',
|
||||
'farmaciaReceitaEntregas',
|
||||
'farmaciaAltoCustoProcessos',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class EsferaAdministrativa extends Model
|
||||
{
|
||||
protected $table = 'cadastro_esfera_administrativa';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(Unidade::class);
|
||||
}
|
||||
}
|
||||
132
api/app/Models/Cadastro/Estabelecimento/Infraestrutura.php
Normal file
132
api/app/Models/Cadastro/Estabelecimento/Infraestrutura.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Ambulatorio\ParametrizacaoInfraestrutura as AmbulatorioParametrizacaoInfraestrutura;
|
||||
use App\Models\Cadastro\Localizacao\Endereco;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\ExameImagem\CotaPrestador;
|
||||
use App\Models\ExameImagem\Jornada\Jornada;
|
||||
use App\Models\ExameImagem\Parametrizacao;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\Unidade as ExameLaboratorialUnidade;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\UnidadeSolicitanteExame;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Infraestrutura extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_infraestrutura';
|
||||
|
||||
protected $casts = [
|
||||
'principal' => 'boolean',
|
||||
'ativo' => 'boolean'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'infraestrutura_id',
|
||||
'principal',
|
||||
'nome',
|
||||
'telefone',
|
||||
'ativo',
|
||||
'endereco_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',
|
||||
'unidade_id',
|
||||
'endereco_id',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'endereco'
|
||||
];
|
||||
|
||||
public function parametrizacaoExameImagem()
|
||||
{
|
||||
return $this->hasOne(Parametrizacao::class);
|
||||
}
|
||||
|
||||
public function jornadaExameImagem()
|
||||
{
|
||||
return $this->hasMany(Jornada::class);
|
||||
}
|
||||
|
||||
public function cotaPrestadorExameImagem()
|
||||
{
|
||||
return $this->hasOne(CotaPrestador::class);
|
||||
}
|
||||
|
||||
public function unidade()
|
||||
{
|
||||
return $this->belongsTo(Unidade::class);
|
||||
}
|
||||
|
||||
public function infraestrutura()
|
||||
{
|
||||
return $this->belongsTo(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidade()
|
||||
{
|
||||
return $this->hasOne(ExameLaboratorialUnidade::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidadeSolicitanteExame()
|
||||
{
|
||||
return $this->hasOne(UnidadeSolicitanteExame::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasOne(Agendamento::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidadeCotas()
|
||||
{
|
||||
return $this->hasOne(Cota::class);
|
||||
}
|
||||
|
||||
public function endereco()
|
||||
{
|
||||
return $this->belongsTo(Endereco::class);
|
||||
}
|
||||
|
||||
public function centrosCusto()
|
||||
{
|
||||
return $this->hasMany(CentroCusto::class);
|
||||
}
|
||||
|
||||
public function lotacoes()
|
||||
{
|
||||
return $this->hasMany(Lotacao::class);
|
||||
}
|
||||
|
||||
public function ambulatorioParametrizacaoJornadaInfraestrutura()
|
||||
{
|
||||
return $this->hasOne(AmbulatorioParametrizacaoInfraestrutura::class);
|
||||
}
|
||||
|
||||
public function getNomeAttribute($nome)
|
||||
{
|
||||
return $this->principal ? $this->unidade->nome_fantasia : $nome;
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'centrosCusto',
|
||||
'lotacoes',
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/Estabelecimento/NaturezaJuridica.php
Normal file
26
api/app/Models/Cadastro/Estabelecimento/NaturezaJuridica.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class NaturezaJuridica extends Model
|
||||
{
|
||||
protected $table = 'cadastro_natureza_juridica';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(Unidade::class);
|
||||
}
|
||||
}
|
||||
40
api/app/Models/Cadastro/Estabelecimento/Sala.php
Normal file
40
api/app/Models/Cadastro/Estabelecimento/Sala.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Sala extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_sala';
|
||||
|
||||
protected $fillable = [
|
||||
'centro_custo_id',
|
||||
'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',
|
||||
];
|
||||
|
||||
public function centroCusto()
|
||||
{
|
||||
return $this->belongsTo(CentroCusto::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
31
api/app/Models/Cadastro/Estabelecimento/Servico.php
Normal file
31
api/app/Models/Cadastro/Estabelecimento/Servico.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\ProntoAtendimento\Plantao\Plantao;
|
||||
|
||||
class Servico extends Model
|
||||
{
|
||||
protected $table = 'cadastro_servico';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function setores()
|
||||
{
|
||||
return $this->hasMany(Setor::class);
|
||||
}
|
||||
|
||||
public function plantoes()
|
||||
{
|
||||
return $this->hasMany(Plantao::class);
|
||||
}
|
||||
}
|
||||
53
api/app/Models/Cadastro/Estabelecimento/Setor.php
Normal file
53
api/app/Models/Cadastro/Estabelecimento/Setor.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Setor extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_setor';
|
||||
|
||||
protected $fillable = [
|
||||
'tipo_id',
|
||||
'servico_id',
|
||||
'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',
|
||||
];
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(SetorTipo::class);
|
||||
}
|
||||
|
||||
public function servico()
|
||||
{
|
||||
return $this->belongsTo(Servico::class);
|
||||
}
|
||||
|
||||
public function centrosCusto()
|
||||
{
|
||||
return $this->hasMany(CentroCusto::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'centrosCusto',
|
||||
]);
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/Estabelecimento/SetorTipo.php
Normal file
25
api/app/Models/Cadastro/Estabelecimento/SetorTipo.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class SetorTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_setor_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function setores()
|
||||
{
|
||||
return $this->hasMany(Setor::class, 'tipo_id');
|
||||
}
|
||||
}
|
||||
155
api/app/Models/Cadastro/Estabelecimento/Unidade.php
Normal file
155
api/app/Models/Cadastro/Estabelecimento/Unidade.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Almoxarifado\SaidaRequisicao;
|
||||
use App\Models\Bpa\Procedimento;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Paciente;
|
||||
use App\Models\Cadastro\SujeitoAtencao\ProntuarioUnidade;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Usuario;
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\ExameImagem\CotaPrestador;
|
||||
use App\Models\ExameImagem\Fechamento\Faturamento;
|
||||
use App\Models\ExameImagem\Jornada\Jornada;
|
||||
use App\Models\ExameImagem\Parametrizacao;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\Cota;
|
||||
use App\Models\ExameLaboratorial\Parametrizacao\Unidade as ExameLaboratorialUnidade;
|
||||
use App\Models\Model;
|
||||
use App\Models\ProntoAtendimento\Atendimento\Recepcao;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Unidade extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_unidade';
|
||||
|
||||
protected $casts = [
|
||||
'pertence_sus' => 'boolean',
|
||||
'unidade_referencia' => 'boolean',
|
||||
'unidade_prestadora' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'nome_fantasia',
|
||||
'razao_social',
|
||||
'cnpj',
|
||||
'email',
|
||||
'site',
|
||||
'tipo_id',
|
||||
'esfera_administrativa_id',
|
||||
'natureza_juridica_id',
|
||||
'cnes',
|
||||
'pertence_sus',
|
||||
'unidade_referencia',
|
||||
'unidade_prestadora',
|
||||
'gestor_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 tipo()
|
||||
{
|
||||
return $this->belongsTo(UnidadeTipo::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidade()
|
||||
{
|
||||
return $this->hasOne(ExameLaboratorialUnidade::class);
|
||||
}
|
||||
|
||||
public function exameLaboratorialUnidadeCotas()
|
||||
{
|
||||
return $this->hasOne(Cota::class);
|
||||
}
|
||||
|
||||
public function esferaAdministrativa()
|
||||
{
|
||||
return $this->belongsTo(EsferaAdministrativa::class);
|
||||
}
|
||||
|
||||
public function naturezaJuridica()
|
||||
{
|
||||
return $this->belongsTo(NaturezaJuridica::class);
|
||||
}
|
||||
|
||||
public function gestor()
|
||||
{
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
|
||||
public function infraestruturas()
|
||||
{
|
||||
return $this->hasMany(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function parametrizacaoExameImagem()
|
||||
{
|
||||
return $this->hasOne(Parametrizacao::class);
|
||||
}
|
||||
|
||||
public function jornadaExameImagem()
|
||||
{
|
||||
return $this->hasMany(Jornada::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function faturamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Faturamento::class);
|
||||
}
|
||||
|
||||
public function cotaPrestadorExameImagem()
|
||||
{
|
||||
return $this->hasMany(CotaPrestador::class);
|
||||
}
|
||||
|
||||
public function pacientes()
|
||||
{
|
||||
return $this->hasMany(Paciente::class);
|
||||
}
|
||||
|
||||
public function prontuariosUnidade()
|
||||
{
|
||||
return $this->hasMany(ProntuarioUnidade::class);
|
||||
}
|
||||
|
||||
public function recepcoes()
|
||||
{
|
||||
return $this->hasMany(Recepcao::class, 'unidade_encaminhamento_id');
|
||||
}
|
||||
|
||||
public function procedimentos()
|
||||
{
|
||||
return $this->hasMany(Procedimento::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaRequisicoes()
|
||||
{
|
||||
return $this->hasMany(SaidaRequisicao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'infraestruturas',
|
||||
'pacientes',
|
||||
'prontuariosUnidade',
|
||||
'recepcoes',
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/Estabelecimento/UnidadeTipo.php
Normal file
26
api/app/Models/Cadastro/Estabelecimento/UnidadeTipo.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Estabelecimento;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class UnidadeTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_unidade_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(Unidade::class, 'tipo_id');
|
||||
}
|
||||
}
|
||||
24
api/app/Models/Cadastro/EtapaClinica.php
Normal file
24
api/app/Models/Cadastro/EtapaClinica.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class EtapaClinica extends Model
|
||||
{
|
||||
protected $table = 'cadastro_etapa_clinica';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
30
api/app/Models/Cadastro/Fabricante/Fabricante.php
Normal file
30
api/app/Models/Cadastro/Fabricante/Fabricante.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Fabricante;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Fabricante extends Model
|
||||
{
|
||||
protected $table = 'cadastro_fabricante';
|
||||
|
||||
protected $fillable = [
|
||||
'tipo_id',
|
||||
'nome',
|
||||
'cnpj',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(Tipo::class);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/Fabricante/Tipo.php
Normal file
26
api/app/Models/Cadastro/Fabricante/Tipo.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Fabricante;
|
||||
|
||||
use App\Models\Cadastro\Fabricante;
|
||||
use App\Models\Model;
|
||||
|
||||
class Tipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_fabricante_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function fabricantes()
|
||||
{
|
||||
return $this->hasMany(Fabricante::class);
|
||||
}
|
||||
}
|
||||
51
api/app/Models/Cadastro/Feriado/Feriado.php
Normal file
51
api/app/Models/Cadastro/Feriado/Feriado.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Feriado;
|
||||
|
||||
use App\Models\Administracao\Modulo;
|
||||
use App\Models\Cadastro\Feriado\FeriadoTipo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Feriado extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_feriado';
|
||||
|
||||
protected $fillable = [
|
||||
'data',
|
||||
'ano',
|
||||
'mes',
|
||||
'dia',
|
||||
'tipo_id',
|
||||
'observacao'
|
||||
];
|
||||
|
||||
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 tipo()
|
||||
{
|
||||
return $this->belongsTo(FeriadoTipo::class);
|
||||
}
|
||||
|
||||
public function modulos()
|
||||
{
|
||||
return $this->belongsToMany(Modulo::class, 'cadastro_feriado_modulo')->withTimestamps();
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/Feriado/FeriadoTipo.php
Normal file
25
api/app/Models/Cadastro/Feriado/FeriadoTipo.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Feriado;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FeriadoTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_feriado_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function feriado()
|
||||
{
|
||||
return $this->hasMany(Feriado::class);
|
||||
}
|
||||
}
|
||||
37
api/app/Models/Cadastro/Ferida.php
Normal file
37
api/app/Models/Cadastro/Ferida.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Cadastro\FeridaProcedimento;
|
||||
use App\Models\Model;
|
||||
|
||||
class Ferida extends Model
|
||||
{
|
||||
protected $table = 'cadastro_ferida';
|
||||
|
||||
protected $casts = [
|
||||
'ativo' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
'ativo',
|
||||
'identificador_externo',
|
||||
'observacao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function procedimentos()
|
||||
{
|
||||
return $this->hasMany(FeridaProcedimento::class);
|
||||
}
|
||||
}
|
||||
20
api/app/Models/Cadastro/FeridaExsudato.php
Normal file
20
api/app/Models/Cadastro/FeridaExsudato.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class FeridaExsudato extends Model
|
||||
{
|
||||
protected $table = 'cadastro_ferida_exsudato';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/FeridaNecrose.php
Normal file
20
api/app/Models/Cadastro/FeridaNecrose.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class FeridaNecrose extends Model
|
||||
{
|
||||
protected $table = 'cadastro_ferida_necrose';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
39
api/app/Models/Cadastro/FeridaProcedimento.php
Normal file
39
api/app/Models/Cadastro/FeridaProcedimento.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Models\Sigtap\Cid;
|
||||
|
||||
class FeridaProcedimento extends Model
|
||||
{
|
||||
protected $table = 'cadastro_ferida_procedimento';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'procedimento_id',
|
||||
'ferida_id',
|
||||
'cid_id',
|
||||
'quantidade'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function procedimento()
|
||||
{
|
||||
return $this->belongsTo(Procedimento::class);
|
||||
}
|
||||
|
||||
public function cid()
|
||||
{
|
||||
return $this->belongsTo(Cid::class);
|
||||
}
|
||||
}
|
||||
25
api/app/Models/Cadastro/Fornecedor/Categoria.php
Normal file
25
api/app/Models/Cadastro/Fornecedor/Categoria.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Fornecedor;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Categoria extends Model
|
||||
{
|
||||
protected $table = 'cadastro_fornecedor_categoria';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function fornecedores()
|
||||
{
|
||||
return $this->hasMany(Fornecedor::class);
|
||||
}
|
||||
}
|
||||
35
api/app/Models/Cadastro/Fornecedor/Contato.php
Normal file
35
api/app/Models/Cadastro/Fornecedor/Contato.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Fornecedor;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Contato extends Model
|
||||
{
|
||||
protected $table = 'cadastro_fornecedor_contato';
|
||||
|
||||
protected $fillable = [
|
||||
'fornecedor_id',
|
||||
'nome',
|
||||
'departamento',
|
||||
'cargo',
|
||||
'telefone',
|
||||
'email',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id',
|
||||
'fornecedor_id',
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function fornecedor()
|
||||
{
|
||||
return $this->belongsTo(Fornecedor::class);
|
||||
}
|
||||
}
|
||||
51
api/app/Models/Cadastro/Fornecedor/Fornecedor.php
Normal file
51
api/app/Models/Cadastro/Fornecedor/Fornecedor.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Fornecedor;
|
||||
|
||||
use App\Models\Cadastro\Localizacao\Endereco;
|
||||
use App\Models\Model;
|
||||
|
||||
class Fornecedor extends Model
|
||||
{
|
||||
protected $table = 'cadastro_fornecedor';
|
||||
|
||||
protected $fillable = [
|
||||
'cnpj',
|
||||
'inscricao_estadual',
|
||||
'nome_fantasia',
|
||||
'razao_social',
|
||||
'categoria_id',
|
||||
'site',
|
||||
'endereco_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'endereco_id',
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function categoria()
|
||||
{
|
||||
return $this->belongsTo(Categoria::class);
|
||||
}
|
||||
|
||||
public function endereco()
|
||||
{
|
||||
return $this->belongsTo(Endereco::class);
|
||||
}
|
||||
|
||||
public function telefones()
|
||||
{
|
||||
return $this->hasMany(Telefone::class);
|
||||
}
|
||||
|
||||
public function contatos()
|
||||
{
|
||||
return $this->hasMany(Contato::class);
|
||||
}
|
||||
}
|
||||
32
api/app/Models/Cadastro/Fornecedor/Telefone.php
Normal file
32
api/app/Models/Cadastro/Fornecedor/Telefone.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Fornecedor;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Telefone extends Model
|
||||
{
|
||||
protected $table = 'cadastro_fornecedor_telefone';
|
||||
|
||||
protected $fillable = [
|
||||
'fornecedor_id',
|
||||
'numero',
|
||||
'observacao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'id',
|
||||
'fornecedor_id',
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function fornecedor()
|
||||
{
|
||||
return $this->belongsTo(Fornecedor::class);
|
||||
}
|
||||
}
|
||||
101
api/app/Models/Cadastro/Grupo/Grupo.php
Normal file
101
api/app/Models/Cadastro/Grupo/Grupo.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Grupo;
|
||||
|
||||
use App\Models\Almoxarifado\ParametrizacaoControleEstoqueGrupo;
|
||||
use App\Models\Almoxarifado\ParametrizacaoPortalDivulgacaoGrupo;
|
||||
use App\Models\Almoxarifado\ParametrizacaoDispensacaoMateriais;
|
||||
use App\Models\Cadastro\Material\Material;
|
||||
use App\Models\Cadastro\Subgrupo\Subgrupo;
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Model;
|
||||
use App\Models\Regulacao\Tipo as RegulacaoTipo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Grupo extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_grupo';
|
||||
|
||||
protected $fillable = [
|
||||
'nome',
|
||||
'grupo_tipo_id',
|
||||
'impressao_mapa_producao',
|
||||
'regulacao_tipo_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'impressao_mapa_producao' => 'boolean',
|
||||
];
|
||||
|
||||
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 = [
|
||||
'is_regulado',
|
||||
];
|
||||
|
||||
public function grupoTipo()
|
||||
{
|
||||
return $this->belongsTo(GrupoTipo::class);
|
||||
}
|
||||
|
||||
public function regulacaoTipo()
|
||||
{
|
||||
return $this->belongsTo(RegulacaoTipo::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function subgrupos()
|
||||
{
|
||||
return $this->hasMany(Subgrupo::class);
|
||||
}
|
||||
|
||||
public function materiais()
|
||||
{
|
||||
return $this->hasMany(Material::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesControleEstoqueGrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoControleEstoqueGrupo::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesPortalDivulgacaoGrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoPortalDivulgacaoGrupo::class);
|
||||
}
|
||||
|
||||
public function getIsReguladoAttribute()
|
||||
{
|
||||
return !is_null($this->regulacao_tipo_id);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesDispensarMateriais()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoDispensacaoMateriais::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'subgrupos',
|
||||
'materiais',
|
||||
'almoxarifadoParametrizacoesControleEstoqueGrupo',
|
||||
]);
|
||||
}
|
||||
}
|
||||
20
api/app/Models/Cadastro/Grupo/GrupoTipo.php
Normal file
20
api/app/Models/Cadastro/Grupo/GrupoTipo.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Grupo;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class GrupoTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_grupo_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'deleted_at',
|
||||
];
|
||||
}
|
||||
21
api/app/Models/Cadastro/LocalAnatomico.php
Normal file
21
api/app/Models/Cadastro/LocalAnatomico.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LocalAnatomico extends Model
|
||||
{
|
||||
protected $table = 'cadastro_local_anatomico';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'ativo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
22
api/app/Models/Cadastro/LocalAnatomicoRegiao.php
Normal file
22
api/app/Models/Cadastro/LocalAnatomicoRegiao.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LocalAnatomicoRegiao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_local_anatomico_regiao';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'local_anatomico_id',
|
||||
'ativo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
48
api/app/Models/Cadastro/Localizacao/Bairro.php
Normal file
48
api/app/Models/Cadastro/Localizacao/Bairro.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Bairro extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_bairro';
|
||||
|
||||
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',
|
||||
];
|
||||
|
||||
public function logradouros()
|
||||
{
|
||||
return $this->hasMany(Logradouro::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'logradouros'
|
||||
]);
|
||||
}
|
||||
}
|
||||
64
api/app/Models/Cadastro/Localizacao/Domicilio.php
Normal file
64
api/app/Models/Cadastro/Localizacao/Domicilio.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\AtencaoBasica\CadastroDomiciliar\CadastroDomiciliar;
|
||||
use App\Models\Cadastro\Localizacao\DomicilioInformacaoResidencial;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Cidadao;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Domicilio extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_domicilio';
|
||||
|
||||
protected $fillable = [
|
||||
'endereco_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',
|
||||
'endereco_id'
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'endereco'
|
||||
];
|
||||
|
||||
public function endereco()
|
||||
{
|
||||
return $this->belongsTo(Endereco::class);
|
||||
}
|
||||
|
||||
public function cidadaos()
|
||||
{
|
||||
return $this->hasMany(Cidadao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'cidadaos',
|
||||
]);
|
||||
}
|
||||
|
||||
public function cadastroDomiciliar()
|
||||
{
|
||||
return $this->hasOne(CadastroDomiciliar::class);
|
||||
}
|
||||
|
||||
public function informacaoResidencial()
|
||||
{
|
||||
return $this->hasOne(DomicilioInformacaoResidencial::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\AtencaoBasica\CadastroDomiciliar\Animal;
|
||||
use App\Models\AtencaoBasica\CadastroDomiciliar\Lazer;
|
||||
use App\Models\Cadastro\Localizacao\DomicilioInformacaoResidencialAnimal;
|
||||
use App\Models\Cadastro\Localizacao\DomicilioInformacaoResidencialLazer;
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Ocupacao;
|
||||
|
||||
class DomicilioInformacaoResidencial extends Model
|
||||
{
|
||||
|
||||
protected $table = 'cadastro_domicilio_informacao_residencial';
|
||||
|
||||
protected $casts = [
|
||||
'instituicao_outros_profissionais' => 'boolean',
|
||||
'possui_animais' => 'boolean',
|
||||
'bolsa_familia' => 'boolean',
|
||||
'vale_gas' => 'boolean',
|
||||
'bolsa_escola' => 'boolean',
|
||||
'bpc' => 'boolean',
|
||||
'recusa_cadastro' => 'boolean',
|
||||
'fora_area' => 'boolean',
|
||||
'energia_eletrica' => 'boolean',
|
||||
'possui_veiculo_proprio' => 'boolean',
|
||||
'possui_financiamento' => 'boolean',
|
||||
'possui_emprestimo' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'domicilio_id',
|
||||
'microarea_id',
|
||||
'fora_area',
|
||||
'instituicao_nome',
|
||||
'instituicao_outros_profissionais',
|
||||
'instituicao_nome_responsavel_tecnico',
|
||||
'instituicao_cns_responsavel_tecnico',
|
||||
'instituicao_cargo_responsavel_tecnico',
|
||||
'instituicao_telefone_responsavel_tecnico',
|
||||
'imovel_tipo_id',
|
||||
'situacao_domicilio_id',
|
||||
'domicilio_tipo_id',
|
||||
'quantidade_comodos',
|
||||
'situacao_rural_id',
|
||||
'domicilio_zona_id',
|
||||
'domicilio_tipo_acesso_id',
|
||||
'material_predominante_id',
|
||||
'abastecimento_id',
|
||||
'tratamento_id',
|
||||
'destino_lixo_id',
|
||||
'forma_escoamento_id',
|
||||
'possui_animais',
|
||||
'quantidade_animais',
|
||||
'energia_eletrica',
|
||||
'higiene_residencial_id',
|
||||
'bolsa_familia',
|
||||
'vale_gas',
|
||||
'bolsa_escola',
|
||||
'bpc',
|
||||
'escala_coelho_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function lazer()
|
||||
{
|
||||
return $this->belongsToMany(Lazer::class, 'cadastro_domicilio_informacao_residencial_lazer')
|
||||
->using(DomicilioInformacaoResidencialLazer::class)
|
||||
->as('DomicilioInformacaoResidencialLazer')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
'lazer_id',
|
||||
)
|
||||
->select('atencao_basica_cadastro_lazer.id')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function animal()
|
||||
{
|
||||
return $this->belongsToMany(Animal::class, 'cadastro_domicilio_informacao_residencial_animal')
|
||||
->using(DomicilioInformacaoResidencialAnimal::class)
|
||||
->as('DomicilioInformacaoResidencialAnimal')
|
||||
->withPivot(
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
'animal_id',
|
||||
)
|
||||
->select('atencao_basica_cadastro_animal.id')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class DomicilioInformacaoResidencialAnimal extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'animal_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class DomicilioInformacaoResidencialLazer extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
'lazer_id',
|
||||
'domicilio_informacao_residencial_id',
|
||||
];
|
||||
}
|
||||
106
api/app/Models/Cadastro/Localizacao/Endereco.php
Normal file
106
api/app/Models/Cadastro/Localizacao/Endereco.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Endereco extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_endereco';
|
||||
|
||||
protected $fillable = [
|
||||
'logradouro_id',
|
||||
'numero',
|
||||
'complemento',
|
||||
'referencia',
|
||||
'loteamento_id',
|
||||
'zona_id',
|
||||
'latitude',
|
||||
'longitude',
|
||||
];
|
||||
|
||||
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',
|
||||
'logradouro_id',
|
||||
'loteamento_id',
|
||||
'zona_id',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'sem_numero',
|
||||
'completo',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'logradouro',
|
||||
'loteamento',
|
||||
'zona',
|
||||
];
|
||||
|
||||
public function logradouro()
|
||||
{
|
||||
return $this->belongsTo(Logradouro::class);
|
||||
}
|
||||
|
||||
public function loteamento()
|
||||
{
|
||||
return $this->belongsTo(Loteamento::class);
|
||||
}
|
||||
|
||||
public function zona()
|
||||
{
|
||||
return $this->belongsTo(Zona::class);
|
||||
}
|
||||
|
||||
public function infraestruturas()
|
||||
{
|
||||
return $this->hasMany(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function domicilios()
|
||||
{
|
||||
return $this->hasMany(Domicilio::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function getSemNumeroAttribute()
|
||||
{
|
||||
return is_null($this->numero);
|
||||
}
|
||||
|
||||
public function getCompletoAttribute()
|
||||
{
|
||||
$tipo = $this->logradouro->tipo->descricao;
|
||||
$logradouro = $this->logradouro->nome;
|
||||
$numero = $this->sem_numero ? 'S/N' : $this->numero;
|
||||
$bairro = $this->logradouro->bairro->nome;
|
||||
$municipio = $this->logradouro->municipio->nome;
|
||||
$uf = $this->logradouro->municipio->estado->uf;
|
||||
|
||||
return "{$tipo} {$logradouro}, {$numero} - {$bairro}, {$municipio} - {$uf}";
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'infraestruturas',
|
||||
'domicilios',
|
||||
]);
|
||||
}
|
||||
}
|
||||
85
api/app/Models/Cadastro/Localizacao/Logradouro.php
Normal file
85
api/app/Models/Cadastro/Localizacao/Logradouro.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\ExameImagem\Agendamento\Agendamento;
|
||||
use App\Models\Intranet\Municipio;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Logradouro extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_logradouro';
|
||||
|
||||
protected $fillable = [
|
||||
'municipio_id',
|
||||
'bairro_id',
|
||||
'tipo_id',
|
||||
'nome',
|
||||
'cep'
|
||||
];
|
||||
|
||||
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',
|
||||
'municipio_id',
|
||||
'bairro_id',
|
||||
'tipo_id'
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'tipo',
|
||||
'bairro',
|
||||
'municipio'
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'tipo_nome',
|
||||
];
|
||||
|
||||
public function municipio()
|
||||
{
|
||||
return $this->belongsTo(Municipio::class);
|
||||
}
|
||||
|
||||
public function bairro()
|
||||
{
|
||||
return $this->belongsTo(Bairro::class);
|
||||
}
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(LogradouroTipo::class);
|
||||
}
|
||||
|
||||
public function enderecos()
|
||||
{
|
||||
return $this->hasMany(Endereco::class);
|
||||
}
|
||||
|
||||
public function agendamentosExameImagem()
|
||||
{
|
||||
return $this->hasMany(Agendamento::class);
|
||||
}
|
||||
|
||||
public function getTipoNomeAttribute()
|
||||
{
|
||||
return "{$this->tipo->descricao} {$this->nome}";
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'enderecos'
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/Localizacao/LogradouroTipo.php
Normal file
26
api/app/Models/Cadastro/Localizacao/LogradouroTipo.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LogradouroTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_logradouro_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function logradouros()
|
||||
{
|
||||
return $this->hasMany(Logradouro::class, 'tipo_id');
|
||||
}
|
||||
}
|
||||
41
api/app/Models/Cadastro/Localizacao/Loteamento.php
Normal file
41
api/app/Models/Cadastro/Localizacao/Loteamento.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Loteamento extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_loteamento';
|
||||
|
||||
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',
|
||||
];
|
||||
|
||||
public function enderecos()
|
||||
{
|
||||
return $this->hasMany(Endereco::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'enderecos'
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
api/app/Models/Cadastro/Localizacao/Zona.php
Normal file
26
api/app/Models/Cadastro/Localizacao/Zona.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Localizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Zona extends Model
|
||||
{
|
||||
protected $table = 'cadastro_zona';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'descricao',
|
||||
'codigo_esus'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function enderecos()
|
||||
{
|
||||
return $this->hasMany(Endereco::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LogCadastroUnificacaoUsuarioPaciente extends Model
|
||||
{
|
||||
protected $table = 'log_cadastro_unificacao_usuario_paciente';
|
||||
|
||||
protected $fillable = [
|
||||
'dados',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/Material/Apresentacao.php
Normal file
20
api/app/Models/Cadastro/Material/Apresentacao.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Apresentacao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_apresentacao';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/Material/LivroRegistro.php
Normal file
20
api/app/Models/Cadastro/Material/LivroRegistro.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LivroRegistro extends Model
|
||||
{
|
||||
protected $table = 'cadastro_livro_registro';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/Material/LivroRegistroTipo.php
Normal file
20
api/app/Models/Cadastro/Material/LivroRegistroTipo.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class LivroRegistroTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_livro_registro_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
241
api/app/Models/Cadastro/Material/Material.php
Normal file
241
api/app/Models/Cadastro/Material/Material.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Cadastro\Grupo\Grupo;
|
||||
use App\Models\Farmacia\LivroPagina;
|
||||
use App\Models\Farmacia\ReceitaItem;
|
||||
use App\Models\Almoxarifado\SaidaItem;
|
||||
use App\Models\Cadastro\UnidadeMedida;
|
||||
use App\Enums\Cadastro\Grupo\GrupoTipo;
|
||||
use App\Models\Cadastro\MaterialBnafar;
|
||||
use App\Models\Almoxarifado\EntradaItem;
|
||||
use App\Models\Almoxarifado\ReservaItem;
|
||||
use App\Models\Cadastro\Subgrupo\Subgrupo;
|
||||
use App\Models\Almoxarifado\RequisicaoItem;
|
||||
use App\Models\Integracao\Bnafar\Medicamento;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\Cadastro\Material\Apresentacao;
|
||||
use App\Models\Cadastro\Material\LivroRegistro;
|
||||
use App\Models\Farmacia\AltoCusto\ProcessoItem;
|
||||
use App\Models\Almoxarifado\RequisicaoPermissao;
|
||||
use App\Models\Cadastro\Medicamento\ReceitaTipo;
|
||||
use App\Models\Almoxarifado\ParametrizacaoEstoque;
|
||||
use App\Models\Cadastro\Material\LivroRegistroTipo;
|
||||
use App\Models\Cadastro\Medicamento\ViaAdministracao;
|
||||
use App\Models\Cadastro\Medicamento\FormaFarmaceutica;
|
||||
use App\Models\Almoxarifado\ParametrizacaoDispensacaoMateriais;
|
||||
use App\Models\Almoxarifado\ParametrizacaoPortalDivulgacaoMaterialgrupo;
|
||||
|
||||
class Material extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_material';
|
||||
|
||||
protected $casts = [
|
||||
'is_ativo' => 'boolean',
|
||||
'is_exibir_receita' => 'boolean',
|
||||
'is_exibir_prescricao_interna' => 'boolean',
|
||||
'is_alto_custo' => 'boolean',
|
||||
'is_programa_remedio_em_casa' => 'boolean',
|
||||
'is_acao_judicial' => 'boolean',
|
||||
'is_remume' => 'boolean',
|
||||
'is_medicamento' => 'boolean',
|
||||
'possui_lote' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'descricao',
|
||||
'codigo_material',
|
||||
'apresentacao_id',
|
||||
'quantidade',
|
||||
'grupo_id',
|
||||
'subgrupo_id',
|
||||
'is_ativo',
|
||||
'receita_tipo_id',
|
||||
'livro_registro_id',
|
||||
'livro_registro_tipo_id',
|
||||
'forma_farmaceutica_id',
|
||||
'via_administracao_id',
|
||||
'material_bnafar_id',
|
||||
'is_exibir_receita',
|
||||
'is_exibir_prescricao_interna',
|
||||
'is_alto_custo',
|
||||
'is_programa_remedio_em_casa',
|
||||
'is_acao_judicial',
|
||||
'is_remume',
|
||||
'possui_lote',
|
||||
'apresentacao_unidade_medida_id',
|
||||
'prescricao_unidade_medida_id',
|
||||
'quantidade_gotas_ml',
|
||||
];
|
||||
|
||||
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 = [
|
||||
'is_medicamento',
|
||||
];
|
||||
|
||||
public function apresentacao()
|
||||
{
|
||||
return $this->belongsTo(Apresentacao::class);
|
||||
}
|
||||
|
||||
public function apresentacaoUnidadeMedida()
|
||||
{
|
||||
return $this->belongsTo(UnidadeMedida::class);
|
||||
}
|
||||
|
||||
public function prescricaoUnidadeMedida()
|
||||
{
|
||||
return $this->belongsTo(UnidadeMedida::class);
|
||||
}
|
||||
|
||||
public function grupo()
|
||||
{
|
||||
return $this->belongsTo(Grupo::class);
|
||||
}
|
||||
|
||||
public function subgrupo()
|
||||
{
|
||||
return $this->belongsTo(Subgrupo::class);
|
||||
}
|
||||
|
||||
public function receitaTipo()
|
||||
{
|
||||
return $this->belongsTo(ReceitaTipo::class);
|
||||
}
|
||||
|
||||
public function livroRegistro()
|
||||
{
|
||||
return $this->belongsTo(LivroRegistro::class);
|
||||
}
|
||||
|
||||
public function livroRegistroTipo()
|
||||
{
|
||||
return $this->belongsTo(LivroRegistroTipo::class);
|
||||
}
|
||||
|
||||
public function formaFarmaceutica()
|
||||
{
|
||||
return $this->belongsTo(FormaFarmaceutica::class);
|
||||
}
|
||||
|
||||
public function viaAdministracao()
|
||||
{
|
||||
return $this->belongsTo(ViaAdministracao::class);
|
||||
}
|
||||
|
||||
public function materialBnafar()
|
||||
{
|
||||
return $this->belongsTo(MaterialBnafar::class);
|
||||
}
|
||||
|
||||
public function integracaoBnafarMedicamentos()
|
||||
{
|
||||
return $this->belongsToMany(Medicamento::class, 'cadastro_material_integracao_bnafar_medicamento', 'material_id', 'medicamento_id')
|
||||
->using(MaterialIntegracaoBnafarMedicamento::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicaoPermissoes()
|
||||
{
|
||||
return $this->hasMany(RequisicaoPermissao::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoRequisicaoItens()
|
||||
{
|
||||
return $this->hasMany(RequisicaoItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoReservaItens()
|
||||
{
|
||||
return $this->hasMany(ReservaItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoEntradaItens()
|
||||
{
|
||||
return $this->hasMany(EntradaItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoSaidaItens()
|
||||
{
|
||||
return $this->hasMany(SaidaItem::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacaoEstoque()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoEstoque::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacaoDispensacao()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoDispensacaoMateriais::class);
|
||||
}
|
||||
|
||||
public function farmaciaLivroPagina()
|
||||
{
|
||||
return $this->hasMany(LivroPagina::class);
|
||||
}
|
||||
|
||||
public function farmaciaReceitaItens()
|
||||
{
|
||||
return $this->hasMany(ReceitaItem::class);
|
||||
}
|
||||
|
||||
public function farmaciaProcessoItens()
|
||||
{
|
||||
return $this->hasMany(ProcessoItem::class);
|
||||
}
|
||||
|
||||
public function parametrizacaoPortalDivulgacaoMaterialgrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoPortalDivulgacaoMaterialgrupo::class);
|
||||
}
|
||||
|
||||
public function getQuantidadeAttribute($value)
|
||||
{
|
||||
return round($value, 2);
|
||||
}
|
||||
|
||||
public function getIsMedicamentoAttribute()
|
||||
{
|
||||
return ($this->grupo->grupo_tipo_id ?? null) === GrupoTipo::MEDICAMENTO;
|
||||
}
|
||||
|
||||
public function getDescricaoCompletaAttribute()
|
||||
{
|
||||
$apresentacaoNome = Str::upper($this->apresentacao->nome);
|
||||
$apresentacaoQuantidade = (int) $this->quantidade;
|
||||
$apresentacaoUnidadeMedida = Str::upper($this->apresentacaoUnidadeMedida->nome ?? '');
|
||||
|
||||
return "{$this->descricao} - {$apresentacaoNome} {$apresentacaoQuantidade} {$apresentacaoUnidadeMedida}";
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'almoxarifadoRequisicaoPermissoes',
|
||||
'almoxarifadoRequisicaoItens',
|
||||
'almoxarifadoReservaItens',
|
||||
'almoxarifadoEntradaItens',
|
||||
'almoxarifadoSaidaItens',
|
||||
'farmaciaLivroPagina',
|
||||
'farmaciaReceitaItens',
|
||||
'farmaciaProcessoItens',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Material;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class MaterialIntegracaoBnafarMedicamento extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
22
api/app/Models/Cadastro/MaterialBnafar.php
Normal file
22
api/app/Models/Cadastro/MaterialBnafar.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class MaterialBnafar extends Model
|
||||
{
|
||||
protected $table = 'cadastro_material_bnafar';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'codigo',
|
||||
'descricao',
|
||||
'tipo'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/Medicamento/FormaFarmaceutica.php
Normal file
20
api/app/Models/Cadastro/Medicamento/FormaFarmaceutica.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Medicamento;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class FormaFarmaceutica extends Model
|
||||
{
|
||||
protected $table = 'cadastro_forma_farmaceutica';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
66
api/app/Models/Cadastro/Medicamento/Medicamento.php
Normal file
66
api/app/Models/Cadastro/Medicamento/Medicamento.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Medicamento;
|
||||
|
||||
use App\Models\Cadastro\UnidadeMedida;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Medicamento extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_medicamento';
|
||||
|
||||
protected $casts = [
|
||||
'exibir_receita' => 'boolean',
|
||||
'exibir_prescricao_interna' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'nome',
|
||||
'unidade_medida_id',
|
||||
'forma_farmaceutica_id',
|
||||
'via_administracao_id',
|
||||
'receita_tipo_id',
|
||||
'exibir_receita',
|
||||
'exibir_prescricao_interna',
|
||||
];
|
||||
|
||||
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 receitaTipo()
|
||||
{
|
||||
return $this->belongsTo(ReceitaTipo::class);
|
||||
}
|
||||
|
||||
public function unidadeMedida()
|
||||
{
|
||||
return $this->belongsTo(UnidadeMedida::class);
|
||||
}
|
||||
|
||||
public function formaFarmaceutica()
|
||||
{
|
||||
return $this->belongsTo(FormaFarmaceutica::class);
|
||||
}
|
||||
|
||||
public function viaAdministracao()
|
||||
{
|
||||
return $this->belongsTo(ViaAdministracao::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
20
api/app/Models/Cadastro/Medicamento/ReceitaTipo.php
Normal file
20
api/app/Models/Cadastro/Medicamento/ReceitaTipo.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Medicamento;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class ReceitaTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_receita_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/Medicamento/ViaAdministracao.php
Normal file
20
api/app/Models/Cadastro/Medicamento/ViaAdministracao.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Medicamento;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class ViaAdministracao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_via_administracao';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
26
api/app/Models/Cadastro/MedicamentoNaoPadronizado.php
Normal file
26
api/app/Models/Cadastro/MedicamentoNaoPadronizado.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class MedicamentoNaoPadronizado extends Model
|
||||
{
|
||||
protected $table = 'cadastro_medicamento_nao_padronizado';
|
||||
|
||||
protected $fillable = [
|
||||
'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',
|
||||
];
|
||||
}
|
||||
86
api/app/Models/Cadastro/Oci.php
Normal file
86
api/app/Models/Cadastro/Oci.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\Lotacao;
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
|
||||
class Oci extends Model
|
||||
{
|
||||
protected $table = 'cadastro_oci';
|
||||
|
||||
protected $casts = [
|
||||
'ativo' => 'boolean',
|
||||
'inativado_em' => 'datetime:d/m/Y H:i:s'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'codigo',
|
||||
'nome',
|
||||
'procedimento_codigo',
|
||||
'linha_cuidado',
|
||||
'descricao_geral',
|
||||
'objetivo_assistencial',
|
||||
'ativo',
|
||||
'motivo_inativacao',
|
||||
'inativado_em',
|
||||
'inativacao_lotacao_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function etapasClinicas()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
EtapaClinica::class,
|
||||
'cadastro_oci_etapa_clinica',
|
||||
'oci_id',
|
||||
'etapa_clinica_id'
|
||||
)
|
||||
->using(OciEtapaClinica::class)
|
||||
->as('ociEtapaClinica')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function inativacaoLotacao()
|
||||
{
|
||||
return $this->belongsTo(Lotacao::class);
|
||||
}
|
||||
|
||||
public function portarias()
|
||||
{
|
||||
return $this->hasMany(OciPortaria::class);
|
||||
}
|
||||
|
||||
public function procedimentosPrimarios()
|
||||
{
|
||||
return $this->hasMany(OciProcedimentoPrimario::class);
|
||||
}
|
||||
|
||||
public function procedimentosSecundarios()
|
||||
{
|
||||
return $this->hasMany(OciProcedimentoSecundario::class);
|
||||
}
|
||||
|
||||
public function unidadesExecutoras()
|
||||
{
|
||||
return $this->hasMany(OciUnidadeExecutora::class);
|
||||
}
|
||||
|
||||
public function getProcedimentoAttribute()
|
||||
{
|
||||
return is_null($this->procedimento_codigo)
|
||||
? null
|
||||
: Procedimento::where('codigo', $this->procedimento_codigo)
|
||||
->orderByDesc('competencia_id')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
17
api/app/Models/Cadastro/OciEtapaClinica.php
Normal file
17
api/app/Models/Cadastro/OciEtapaClinica.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class OciEtapaClinica extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
29
api/app/Models/Cadastro/OciPortaria.php
Normal file
29
api/app/Models/Cadastro/OciPortaria.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class OciPortaria extends Model
|
||||
{
|
||||
protected $table = 'cadastro_oci_portaria';
|
||||
|
||||
protected $fillable = [
|
||||
'oci_id',
|
||||
'descricao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function oci()
|
||||
{
|
||||
return $this->belongsTo(Oci::class);
|
||||
}
|
||||
}
|
||||
39
api/app/Models/Cadastro/OciProcedimentoPrimario.php
Normal file
39
api/app/Models/Cadastro/OciProcedimentoPrimario.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
|
||||
class OciProcedimentoPrimario extends Model
|
||||
{
|
||||
protected $table = 'cadastro_oci_procedimento_primario';
|
||||
|
||||
protected $fillable = [
|
||||
'oci_id',
|
||||
'procedimento_codigo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function oci()
|
||||
{
|
||||
return $this->belongsTo(Oci::class);
|
||||
}
|
||||
|
||||
public function getProcedimentoAttribute()
|
||||
{
|
||||
return is_null($this->procedimento_codigo)
|
||||
? null
|
||||
: Procedimento::where('codigo', $this->procedimento_codigo)
|
||||
->orderByDesc('competencia_id')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
39
api/app/Models/Cadastro/OciProcedimentoSecundario.php
Normal file
39
api/app/Models/Cadastro/OciProcedimentoSecundario.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
|
||||
class OciProcedimentoSecundario extends Model
|
||||
{
|
||||
protected $table = 'cadastro_oci_procedimento_secundario';
|
||||
|
||||
protected $fillable = [
|
||||
'oci_id',
|
||||
'procedimento_codigo',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function oci()
|
||||
{
|
||||
return $this->belongsTo(Oci::class);
|
||||
}
|
||||
|
||||
public function getProcedimentoAttribute()
|
||||
{
|
||||
return is_null($this->procedimento_codigo)
|
||||
? null
|
||||
: Procedimento::where('codigo', $this->procedimento_codigo)
|
||||
->orderByDesc('competencia_id')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
35
api/app/Models/Cadastro/OciUnidadeExecutora.php
Normal file
35
api/app/Models/Cadastro/OciUnidadeExecutora.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Cadastro\Estabelecimento\Unidade;
|
||||
use App\Models\Model;
|
||||
|
||||
class OciUnidadeExecutora extends Model
|
||||
{
|
||||
protected $table = 'cadastro_oci_unidade_executora';
|
||||
|
||||
protected $fillable = [
|
||||
'oci_id',
|
||||
'unidade_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function oci()
|
||||
{
|
||||
return $this->belongsTo(Oci::class);
|
||||
}
|
||||
|
||||
public function unidade()
|
||||
{
|
||||
return $this->belongsTo(Unidade::class);
|
||||
}
|
||||
}
|
||||
32
api/app/Models/Cadastro/OrigemProgramatica.php
Normal file
32
api/app/Models/Cadastro/OrigemProgramatica.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class OrigemProgramatica extends Model
|
||||
{
|
||||
protected $table = 'cadastro_origem_programatica';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'programa_tipo_id',
|
||||
'fornecimento_tipo_id',
|
||||
'estrutura_apoio_id',
|
||||
'nome',
|
||||
'ativo',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'ativo' => 'boolean',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/OrigemProgramaticaEstruturaApoio.php
Normal file
20
api/app/Models/Cadastro/OrigemProgramaticaEstruturaApoio.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class OrigemProgramaticaEstruturaApoio extends Model
|
||||
{
|
||||
protected $table = 'cadastro_origem_programatica_estrutura_apoio';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class OrigemProgramaticaFornecimentoTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_origem_programatica_fornecimento_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
20
api/app/Models/Cadastro/OrigemProgramaticaProgramaTipo.php
Normal file
20
api/app/Models/Cadastro/OrigemProgramaticaProgramaTipo.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class OrigemProgramaticaProgramaTipo extends Model
|
||||
{
|
||||
protected $table = 'cadastro_origem_programatica_programa_tipo';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
35
api/app/Models/Cadastro/Parametrizacao/Parametrizacao.php
Normal file
35
api/app/Models/Cadastro/Parametrizacao/Parametrizacao.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Parametrizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class Parametrizacao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_parametrizacao';
|
||||
|
||||
protected $fillable = [
|
||||
'cadastro_paciente_desatualizado_quantidade_dias',
|
||||
'exibe_alerta_paciente_cns_temporario_invalido',
|
||||
'cadastro_paciente_provisorio_bloqueado',
|
||||
'cadastro_paciente_provisorio_quantidade_dias',
|
||||
'exige_cpf_paciente',
|
||||
'exige_cns_paciente',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'exibe_alerta_paciente_cns_temporario_invalido' => 'boolean',
|
||||
'cadastro_paciente_provisorio_bloqueado' => 'boolean',
|
||||
'exige_cpf_paciente' => 'boolean',
|
||||
'exige_cns_paciente' => 'boolean',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Parametrizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class ParametrizacaoPacienteAba extends Model
|
||||
{
|
||||
protected $table = 'cadastro_parametrizacao_paciente_aba';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'nome'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'deleted_at',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Parametrizacao;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\Sigtap\Ocupacao;
|
||||
|
||||
class ParametrizacaoPermissaoOcupacao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_parametrizacao_permissao_ocupacao';
|
||||
|
||||
protected $fillable = [
|
||||
'ocupacao_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function ocupacao()
|
||||
{
|
||||
return $this->belongsTo(Ocupacao::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Parametrizacao;
|
||||
|
||||
use App\Models\Cadastro\Estabelecimento\Infraestrutura;
|
||||
use App\Models\Cadastro\SujeitoAtencao\Usuario;
|
||||
use App\Models\Model;
|
||||
|
||||
class ParametrizacaoPermissaoUsuario extends Model
|
||||
{
|
||||
protected $table = 'cadastro_parametrizacao_permissao_usuario';
|
||||
|
||||
protected $fillable = [
|
||||
'usuario_id',
|
||||
'infraestrutura_id',
|
||||
'municipe',
|
||||
'provisorio',
|
||||
'outro_municipio',
|
||||
'desbloquear_usuario',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'municipe' => 'boolean',
|
||||
'provisorio' => 'boolean',
|
||||
'outro_municipio' => 'boolean',
|
||||
'desbloquear_usuario' => 'boolean',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function usuario()
|
||||
{
|
||||
return $this->belongsTo(Usuario::class);
|
||||
}
|
||||
|
||||
public function infraestrutura()
|
||||
{
|
||||
return $this->belongsTo(Infraestrutura::class);
|
||||
}
|
||||
|
||||
public function pacienteAbas()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
ParametrizacaoPacienteAba::class,
|
||||
'cadastro_parametrizacao_permissao_usuario_paciente_aba',
|
||||
'parametrizacao_id',
|
||||
'paciente_aba_id'
|
||||
)
|
||||
->using(ParametrizacaoPermissaoUsuarioPacienteAba::class)
|
||||
->as('permissaoUsuarioPacienteAba')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Parametrizacao;
|
||||
|
||||
use App\Models\Pivot;
|
||||
|
||||
class ParametrizacaoPermissaoUsuarioPacienteAba extends Pivot
|
||||
{
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
27
api/app/Models/Cadastro/ParametrizacaoMaterial.php
Normal file
27
api/app/Models/Cadastro/ParametrizacaoMaterial.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
|
||||
class ParametrizacaoMaterial extends Model
|
||||
{
|
||||
protected $table = 'cadastro_parametrizacao_material';
|
||||
|
||||
protected $fillable = [
|
||||
'gera_codigo_automatico',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'gera_codigo_automatico' => 'boolean',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
}
|
||||
61
api/app/Models/Cadastro/ServicoManutencao.php
Normal file
61
api/app/Models/Cadastro/ServicoManutencao.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Cadastro\Grupo\Grupo;
|
||||
use App\Models\Cadastro\ServicoManutencaoCausasProvaveis;
|
||||
use App\Models\Cadastro\ServicoManutencaoPrestadorFornecedor;
|
||||
use App\Models\Cadastro\Subgrupo\Subgrupo;
|
||||
use App\Models\Model;
|
||||
|
||||
class ServicoManutencao extends Model
|
||||
{
|
||||
protected $table = 'cadastro_servico_manutencao';
|
||||
|
||||
protected $fillable = [
|
||||
'nome',
|
||||
'grupo_id',
|
||||
'sub_grupo_id',
|
||||
'prioridade_id',
|
||||
'is_agendamento_programado',
|
||||
'is_custo',
|
||||
'is_identifica_os_prestador',
|
||||
'is_identifica_itens_almoxarifado',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_agendamento_programado' => 'boolean',
|
||||
'is_custo' => 'boolean',
|
||||
'is_identifica_os_prestador' => 'boolean',
|
||||
'is_identifica_itens_almoxarifado' => 'boolean',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function prestadoresFornecedores()
|
||||
{
|
||||
return $this->hasMany(ServicoManutencaoPrestadorFornecedor::class, 'servico_manutencao_id');
|
||||
}
|
||||
|
||||
public function causasProvaveis()
|
||||
{
|
||||
return $this->hasMany(ServicoManutencaoCausasProvaveis::class);
|
||||
}
|
||||
|
||||
public function grupo()
|
||||
{
|
||||
return $this->belongsTo(Grupo::class);
|
||||
}
|
||||
|
||||
public function subGrupo()
|
||||
{
|
||||
return $this->belongsTo(Subgrupo::class);
|
||||
}
|
||||
}
|
||||
31
api/app/Models/Cadastro/ServicoManutencaoCausasProvaveis.php
Normal file
31
api/app/Models/Cadastro/ServicoManutencaoCausasProvaveis.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Model;
|
||||
use App\Models\Manutencao\SolicitacaoCausaProvavel;
|
||||
|
||||
class ServicoManutencaoCausasProvaveis extends Model
|
||||
{
|
||||
protected $table = 'cadastro_servico_manutencao_causas_provaveis';
|
||||
|
||||
protected $fillable = [
|
||||
'nome',
|
||||
'servico_manutencao_id',
|
||||
'observacao',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function solicitacaoCausaProvavel()
|
||||
{
|
||||
return $this->hasMany(SolicitacaoCausaProvavel::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro;
|
||||
|
||||
use App\Models\Cadastro\Estabelecimento\Infraestrutura;
|
||||
use App\Models\Cadastro\Fornecedor\Fornecedor;
|
||||
use App\Models\Model;
|
||||
|
||||
class ServicoManutencaoPrestadorFornecedor extends Model
|
||||
{
|
||||
protected $table = 'cadastro_servico_manutencao_prestador_fornecedor';
|
||||
|
||||
protected $fillable = [
|
||||
'servico_manutencao_id',
|
||||
'unidade_executante_manutencao_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'created_lotacao_id',
|
||||
'created_centro_custo_id',
|
||||
'updated_at',
|
||||
'updated_lotacao_id',
|
||||
'updated_centro_custo_id',
|
||||
];
|
||||
|
||||
public function getInfraestrutura()
|
||||
{
|
||||
return $this->belongsTo(Infraestrutura::class, 'infraestrutura_id');
|
||||
}
|
||||
|
||||
public function getFornecedor()
|
||||
{
|
||||
return $this->belongsTo(Fornecedor::class, 'fornecedor_id');
|
||||
}
|
||||
}
|
||||
62
api/app/Models/Cadastro/Subgrupo/Subgrupo.php
Normal file
62
api/app/Models/Cadastro/Subgrupo/Subgrupo.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Cadastro\Subgrupo;
|
||||
|
||||
use App\Models\Almoxarifado\ParametrizacaoControleEstoqueSubgrupo;
|
||||
use App\Models\Cadastro\Grupo\Grupo;
|
||||
use App\Models\Cadastro\Material\Material;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\Almoxarifado\ParametrizacaoPortalDivulgacaoSubgrupo;
|
||||
|
||||
class Subgrupo extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'cadastro_subgrupo';
|
||||
|
||||
protected $fillable = [
|
||||
'grupo_id',
|
||||
'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',
|
||||
];
|
||||
|
||||
public function grupo()
|
||||
{
|
||||
return $this->belongsTo(Grupo::class);
|
||||
}
|
||||
|
||||
public function materiais()
|
||||
{
|
||||
return $this->hasMany(Material::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesControleEstoqueSubgrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoControleEstoqueSubgrupo::class);
|
||||
}
|
||||
|
||||
public function almoxarifadoParametrizacoesPortalDivulgacaoSubgrupo()
|
||||
{
|
||||
return $this->hasMany(ParametrizacaoPortalDivulgacaoSubgrupo::class);
|
||||
}
|
||||
|
||||
public function getIsAllowedToDeleteAttribute()
|
||||
{
|
||||
return $this->hasNoOne([
|
||||
'materiais',
|
||||
'almoxarifadoParametrizacoesControleEstoqueSubgrupo',
|
||||
]);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user