init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->id();
$table->foreignId('paciente_id')->constrained('cadastro_paciente');
$table->foreignId('medico_id')->constrained('cadastro_usuario');
$table->foreignId('unidade_id')->constrained('cadastro_unidade');
$table->foreignId('infraestrutura_id')->nullable()->constrained('cadastro_infraestrutura');
$table->foreignId('coleta_unidade_id')->nullable()->constrained('cadastro_unidade');
$table->foreignId('coleta_infraestrutura_id')->nullable()->constrained('cadastro_infraestrutura');
$table->foreignId('laboratorio_unidade_id')->nullable()->constrained('cadastro_unidade');
$table->foreignId('laboratorio_infraestrutura_id')->nullable()->constrained('cadastro_infraestrutura');
$table->foreignId('jornada_id')->constrained('exame_laboratorial_jornada');
$table->foreignId('supervisor_id')->nullable()->constrained('cadastro_usuario');
$table->string('uso_medicamento', 500)->nullable();
$table->string('suspeita_clinica', 500)->nullable();
$table->string('observacao', 500)->nullable();
$table->boolean('urgente')->default(false);
$table->date('ultima_menstruacao')->nullable();
$table->string('responsavel', 100)->nullable();
$table->boolean('gestante')->default(false);
$table->date('data');
$table->time('horario');
$table->integer('agendamento_numero');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->id();
$table->foreignId('agendamento_id')->constrained('exame_laboratorial_agendamento');
$table->foreignId('paciente_id')->constrained('cadastro_paciente');
$table->foreignId('exame_id')->constrained('parametrizacao_exame');
$table->decimal('valor', 8, 2)->nullable();
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_exame');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoHistoricoMedicamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_historico_medicamento', function (Blueprint $table) {
$table->id();
$table->foreignId('agendamento_id')->constrained('exame_laboratorial_agendamento');
$table->date('data');
$table->foreignId('paciente_id')->constrained('cadastro_paciente');
$table->string('uso_medicamento', 500)->nullable();
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_historico_medicamento');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoExameStatusTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_exame_status', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->string('descricao', 20);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_exame_status');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddStatusIdToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('status_id')->nullable()->after('paciente_id')->constrained('exame_laboratorial_agendamento_exame_status');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropForeign(['status_id']);
$table->dropColumn(['status_id']);
});
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('usuario_id')->nullable()->after('valor')->constrained('cadastro_usuario');
$table->foreignId('ocupacao_id')->nullable()->after('usuario_id')->constrained('sigtap.ocupacao');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropForeign(['usuario_id']);
$table->dropColumn(['usuario_id']);
$table->dropForeign(['ocupacao_id']);
$table->dropColumn(['ocupacao_id']);
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddImpressaoMapaProducaoToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->boolean('impressao_mapa_producao')->default(false)->after('ocupacao_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropColumn(['impressao_mapa_producao']);
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDataColetaToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->timestamp('data_coleta')->nullable()->after('status_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropColumn(['data_coleta']);
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterDescricaoToExameLaboratorialAgendamentoExameStatusTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame_status', function (Blueprint $table) {
$table->string('descricao', 30)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame_status', function (Blueprint $table) {
$table->string('descricao', 20)->change();
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddMotivoIdToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('motivo_id')->nullable()->after('status_id')->constrained('exame_laboratorial_parametrizacao_motivo');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropForeign(['motivo_id']);
$table->dropColumn(['motivo_id']);
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoExameResultadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_exame_resultado', function (Blueprint $table) {
$table->id();
$table->foreignId('agendamento_exame_id')->constrained('exame_laboratorial_agendamento_exame');
$table->foreignId('composicao_id')->constrained('parametrizacao_exame_composicao');
$table->string('valor', 500)->nullable();
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_exame_resultado');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDataLaudoToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->timestamp('data_laudo')->nullable()->after('data_coleta');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropColumn(['data_laudo']);
});
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddObservacaoToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->string('observacao', 500)->nullable()->after('impressao_mapa_producao');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropColumn(['observacao']);
});
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsAssinaturaToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->timestamp('data_assinatura')->nullable()->after('data_laudo');
$table->foreignId('assinatura_profissional_id')->nullable()->after('data_assinatura')->constrained('cadastro_usuario');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropColumn(['data_assinatura']);
$table->dropForeign(['assinatura_profissional_id']);
$table->dropColumn(['assinatura_profissional_id']);
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoLaudoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_laudo', function (Blueprint $table) {
$table->id();
$table->foreignId('agendamento_id')->constrained('exame_laboratorial_agendamento');
$table->string('arquivo', 100);
$table->tinyInteger('ordem')->nullable();
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_laudo');
}
}

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddImpressaoEntregueToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->boolean('entregue')->default(false)->after('assinatura_profissional_id');
$table->foreignId('entregue_usuario_id')->nullable()->after('entregue')->constrained('cadastro_usuario');
$table->timestamp('data_entregue')->nullable()->after('entregue_usuario_id');
$table->boolean('impressao')->default(false)->after('data_entregue');
$table->foreignId('impressao_usuario_id')->nullable()->after('impressao')->constrained('cadastro_usuario');
$table->timestamp('data_impressao')->nullable()->after('impressao_usuario_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropColumn(['entregue']);
$table->dropColumn(['data_entregue']);
$table->dropColumn(['impressao']);
$table->dropColumn(['data_impressao']);
$table->dropForeign(['entregue_usuario_id']);
$table->dropColumn(['entregue_usuario_id']);
$table->dropForeign(['impressao_usuario_id']);
$table->dropColumn(['impressao_usuario_id']);
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRetroativoToExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->boolean('retroativo')->nullable()->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropColumn(['retroativo']);
});
}
}

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsBpaLaboratorialToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('bpa_procedimento_id')->after('observacao')->nullable()->constrained('bpa_procedimento');
$table->foreignId('procedimento_id')->nullable()->after('bpa_procedimento_id')->constrained('sigtap.procedimento');
$table->foreignId('lotacao_id')->nullable()->after('procedimento_id')->constrained('cadastro_lotacao');
$table->unsignedSmallInteger('quantidade')->after('lotacao_id');
$table->foreignId('cid_principal_id')->after('quantidade')->nullable()->constrained('sigtap.cid');
$table->foreignId('cid_secundario_id')->after('cid_principal_id')->nullable()->constrained('sigtap.cid');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropForeign(['bpa_procedimento_id']);
$table->dropColumn(['bpa_procedimento_id']);
$table->dropForeign(['procedimento_id']);
$table->dropColumn('procedimento_id');
$table->dropForeign(['lotacao_id']);
$table->dropColumn('lotacao_id');
$table->dropColumn('quantidade');
$table->dropForeign(['cid_principal_id']);
$table->dropColumn(['cid_principal_id']);
$table->dropForeign(['cid_secundario_id']);
$table->dropColumn(['cid_secundario_id']);
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddSupervisorIdToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('supervisor_id')->nullable()->after('data_impressao')->constrained('cadastro_usuario');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropForeign(['supervisor_id']);
$table->dropColumn(['supervisor_id']);
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoExameBloqueadoMotivoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_exame_bloqueado_motivo', function (Blueprint $table) {
MigrationUtil::idWithoutIncrements($table);
$table->text('descricao', 100);
MigrationUtil::addCommonFields($table, ['staticData' => true]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_exame_bloqueado_motivo');
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoExameBloqueadoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_exame_bloqueado', function (Blueprint $table) {
$table->id();
$table->foreignId('paciente_id')->constrained('cadastro_paciente');
$table->foreignId('exame_id')->constrained('parametrizacao_exame');
$table->foreignId('supervisor_id')->nullable()->constrained('cadastro_usuario');
$table->foreignId('motivo_id')->nullable()->constrained('exame_laboratorial_agendamento_exame_bloqueado_motivo');
$table->decimal('valor', 8, 2)->nullable();
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_exame_bloqueado');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPreAtendimentoIdToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('pre_atendimento_id')
->nullable()
->after('agendamento_id')
->constrained('ambulatorio_atendimento_pre_atendimento');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropConstrainedForeignId('pre_atendimento_id');
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoExameHistoricoAcao extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_exame_historico_acao', function (Blueprint $table) {
$table->id();
$table->string('descricao');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_exame_historico_acao');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use App\Enums\ExameLaboratorial\Acao;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExameLaboratorialAgendamentoExameHistorico extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('exame_laboratorial_agendamento_exame_historico', function (Blueprint $table) {
$table->id();
$table->foreignId('exame_id')->constrained('parametrizacao_exame');
$table->foreignId('agendamento_id')->constrained('exame_laboratorial_agendamento');
$table->foreignId('acao_id')->constrained('exame_laboratorial_agendamento_exame_historico_acao')->default(Acao::INSERCAO);
$table->date('data');
$table->time('horario');
$table->foreignId('status_id')->constrained('exame_laboratorial_agendamento_exame_status');
MigrationUtil::addCommonFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('exame_laboratorial_agendamento_exame_historico');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRegulacaoSolicitacaoIdToExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->foreignId('regulacao_solicitacao_id')
->nullable()
->after('agendamento_numero')
->constrained('regulacao_solicitacao');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropConstrainedForeignId('regulacao_solicitacao_id');
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateAgendamentoExameHistoricoForeignKey extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame_historico', function (Blueprint $table) {
$table->dropForeign(['agendamento_id']);
$table->foreign('agendamento_id')
->references('id')->on('exame_laboratorial_agendamento')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame_historico', function (Blueprint $table) {
$table->dropForeign(['agendamento_id']);
$table->foreign('agendamento_id')
->references('id')->on('exame_laboratorial_agendamento');
});
}
}

View File

@@ -0,0 +1,61 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsLaboratorioToExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->foreignId('usuario_id')->nullable()->after('regulacao_solicitacao_id')->constrained('cadastro_usuario');
$table->foreignId('ocupacao_id')->nullable()->after('usuario_id')->constrained('sigtap.ocupacao');
$table->foreignId('lotacao_id')->nullable()->after('ocupacao_id')->constrained('cadastro_lotacao');
$table->foreignId('laboratorio_usuario_id')->nullable()->after('lotacao_id')->constrained('cadastro_usuario');
$table->foreignId('laboratorio_ocupacao_id')->nullable()->after('laboratorio_usuario_id')->constrained('sigtap.ocupacao');
$table->foreignId('laboratorio_lotacao_id')->nullable()->after('laboratorio_ocupacao_id')->constrained('cadastro_lotacao');
$table->foreignId('bpa_procedimento_id')->nullable()->after('laboratorio_ocupacao_id')->constrained('bpa_procedimento');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropForeign(['usuario_id']);
$table->dropColumn(['usuario_id']);
$table->dropForeign(['ocupacao_id']);
$table->dropColumn(['ocupacao_id']);
$table->dropForeign(['lotacao_id']);
$table->dropColumn(['lotacao_id']);
$table->dropForeign(['laboratorio_usuario_id']);
$table->dropColumn(['laboratorio_usuario_id']);
$table->dropForeign(['laboratorio_ocupacao_id']);
$table->dropColumn(['laboratorio_ocupacao_id']);
$table->dropForeign(['laboratorio_lotacao_id']);
$table->dropColumn(['laboratorio_lotacao_id']);
$table->dropForeign(['bpa_procedimento_id']);
$table->dropColumn(['bpa_procedimento_id']);
});
}
}

View File

@@ -0,0 +1,39 @@
<?php
use App\Enums\WebService\Laboratorio\Cliente\PedidoStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddWebServiceLaboratorioClientePedidoStatusIdToExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->foreignId('web_service_laboratorio_cliente_pedido_status_id')
->nullable()
->after('laboratorio_lotacao_id')
->constrained('web_service_laboratorio_cliente_pedido_status');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropConstrainedForeignId('web_service_laboratorio_cliente_pedido_status_id');
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddWebServiceLaboratorioClientePedidoResultadoUrlToExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->string('web_service_laboratorio_cliente_pedido_resultado_url', 300)
->nullable()
->after('web_service_laboratorio_cliente_pedido_status_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropColumn('web_service_laboratorio_cliente_pedido_resultado_url');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddExternalFieldsToExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
MigrationUtil::addExternalFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropConstrainedForeignId('externo_created_usuario_id');
$table->dropConstrainedForeignId('externo_updated_usuario_id');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddExternalFieldsToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
MigrationUtil::addExternalFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropConstrainedForeignId('externo_created_usuario_id');
$table->dropConstrainedForeignId('externo_updated_usuario_id');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddExternalFieldsToExameLaboratorialAgendamentoExameHistoricoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame_historico', function (Blueprint $table) {
MigrationUtil::addExternalFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame_historico', function (Blueprint $table) {
$table->dropConstrainedForeignId('externo_created_usuario_id');
$table->dropConstrainedForeignId('externo_updated_usuario_id');
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DropWebServiceLaboratorioClientePedidoResultadoUrlOnExameLaboratorialAgendamento extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropColumn('web_service_laboratorio_cliente_pedido_resultado_url');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->string('web_service_laboratorio_cliente_pedido_resultado_url', 300)
->nullable()
->after('web_service_laboratorio_cliente_pedido_status_id');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUrlToExameLaboratorialAgendamentoLaudoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_laudo', function (Blueprint $table) {
$table->string('url', 300)->nullable()->after('arquivo');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_laudo', function (Blueprint $table) {
$table->dropColumn('url');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddExternalFieldsToExameLaboratorialAgendamentoLaudoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_laudo', function (Blueprint $table) {
MigrationUtil::addExternalFields($table);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_laudo', function (Blueprint $table) {
$table->dropConstrainedForeignId('externo_created_usuario_id');
$table->dropConstrainedForeignId('externo_updated_usuario_id');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterFieldSuspeitaClinicaOnExameLaboratorialAgendamentoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->text('suspeita_clinica')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->string('suspeita_clinica', 500)->nullable()->change();
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddSoapSolicitacaoExameItemIdToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('soap_solicitacao_exame_item_id')
->nullable()
->after('pre_atendimento_id')
->constrained('ambulatorio_atendimento_soap_solicitacao_exame_item');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropConstrainedForeignId('soap_solicitacao_exame_item_id');
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddApacProcedimentoSecundarioIdToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('apac_procedimento_secundario_id')
->nullable()
->after('bpa_procedimento_id')
->constrained('apac_solicitacao_autorizacao_procedimento_secundario');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropConstrainedForeignId('apac_procedimento_secundario_id');
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAcompanhamentoOciIdToExameLaboratorialAgendamentoExameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->foreignId('acompanhamento_oci_id')
->nullable()
->after('cid_secundario_id')
->constrained('ambulatorio_acompanhamento_oci');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame', function (Blueprint $table) {
$table->dropConstrainedForeignId('acompanhamento_oci_id');
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AddIsEnviadoWebserviceToExameLaboratorialAgendamentoLaudo extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_laudo', function (Blueprint $table) {
$table->boolean('is_enviado_webservice')->default(false)->after('ordem');
});
DB::table('exame_laboratorial_agendamento_laudo')->whereNotNull('url')->update(['is_enviado_webservice' => true]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_laudo', function (Blueprint $table) {
$table->dropColumn('is_enviado_webservice');
});
}
}

View File

@@ -0,0 +1,68 @@
<?php
use App\Enums\ExameLaboratorial\StatusAgendamento;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
class DeleteAgendamentoExameOrigemAmbulatorioDuplicado extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::transaction(function () {
$agendamentoExames = DB::table('exame_laboratorial_agendamento_exame as agendamento_exame')
->select(
'agendamento_exame.agendamento_id',
'agendamento_exame.exame_id'
)
->whereNotNull('agendamento_exame.soap_solicitacao_exame_item_id')
->groupBy(
'agendamento_exame.agendamento_id',
'agendamento_exame.exame_id'
)
->havingRaw('COUNT(*) > 1')
->get();
$agendamentoExames->each(function ($agendamentoExame) {
$hasNaoAgendado = DB::table('exame_laboratorial_agendamento_exame as agendamento_exame')
->where('agendamento_exame.agendamento_id', $agendamentoExame->agendamento_id)
->where('agendamento_exame.exame_id', $agendamentoExame->exame_id)
->where('agendamento_exame.status_id', '<>', StatusAgendamento::AGENDADO)
->exists();
DB::table('exame_laboratorial_agendamento_exame as agendamento_exame')
->select('agendamento_exame.id')
->where('agendamento_exame.agendamento_id', $agendamentoExame->agendamento_id)
->where('agendamento_exame.exame_id', $agendamentoExame->exame_id)
->where('agendamento_exame.status_id', StatusAgendamento::AGENDADO)
->orderBy('agendamento_exame.id')
->get()
->each(function ($agendamentoExame, $i) use ($hasNaoAgendado) {
if ($i === 0 && !$hasNaoAgendado) {
return;
}
DB::table('exame_laboratorial_agendamento_exame')->where('id', $agendamentoExame->id)->delete();
});
});
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@@ -0,0 +1,65 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use App\Models\ExameLaboratorial\AgendamentoExame\Agendamento;
class AddUniqueToAgendamentoNumeroOnExameLaboratorialAgendamento extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$duplicados = DB::table('exame_laboratorial_agendamento')
->select(
'agendamento_numero',
DB::raw('COUNT(agendamento_numero) as total')
)
->groupBy('agendamento_numero')
->having('total', '>', 1)
->get();
foreach($duplicados as $duplicado)
{
$registros = DB::table('exame_laboratorial_agendamento')
->where('agendamento_numero', $duplicado->agendamento_numero)
->orderBy('created_at')
->get();
foreach($registros as $index => $registro)
{
if($index === 0 ){
continue;
}
$ultimo_numero_agendamento = Agendamento::orderByDesc('agendamento_numero')->first();
$novoNumero = $ultimo_numero_agendamento ? $ultimo_numero_agendamento->agendamento_numero + 1 : 1;
DB::table('exame_laboratorial_agendamento')
->where('id', $registro->id)
->update([
'agendamento_numero' => $novoNumero
]);
}
}
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->unique('agendamento_numero');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAppCidadaoToExameLaboratorialAgendamentoTable extends Migration
{
public function up()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table
->boolean('app_conectasus_cidadao')
->nullable()
->default(null)
->after('agendamento_numero');
});
}
public function down()
{
Schema::table('exame_laboratorial_agendamento', function (Blueprint $table) {
$table->dropColumn('app_conectasus_cidadao');
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddJustificativaToExameLaboratorialAgendamentoExameHistoricoTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('exame_laboratorial_agendamento_exame_historico', function (Blueprint $table) {
$table->text('justificativa')->nullable()->after('status_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('exame_laboratorial_agendamento_exame_historico', function (Blueprint $table) {
$table->dropColumn('justificativa');
});
}
}