This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaCaraterAtendimentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_carater_atendimento', function (Blueprint $table) {
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->char('codigo', 2);
|
||||
$table->string('nome', 100);
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_carater_atendimento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_inconsistencia', function (Blueprint $table) {
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->char('codigo', 3)->unique();
|
||||
$table->string('descricao', 100);
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaExportacaoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_exportacao', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('unidade_id')->constrained('cadastro_unidade');
|
||||
$table->foreignId('competencia_id')->constrained('sigtap.competencia');
|
||||
$table->string('arquivo', 100);
|
||||
$table->boolean('encaminhado')->default(false);
|
||||
|
||||
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_exportacao');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaExportacaoFinanciamentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_exportacao_financiamento', function (Blueprint $table) {
|
||||
$table->foreignId('exportacao_id')->constrained('bpa_exportacao');
|
||||
$table->foreignId('financiamento_id')->constrained('sigtap.financiamento');
|
||||
|
||||
$table->primary(['exportacao_id', 'financiamento_id']);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_exportacao_financiamento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaProcedimentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_procedimento', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('exportacao_id')->nullable()->constrained('bpa_exportacao');
|
||||
$table->foreignId('unidade_id')->constrained('cadastro_unidade');
|
||||
$table->foreignId('competencia_id')->constrained('sigtap.competencia');
|
||||
$table->foreignId('usuario_id')->nullable()->constrained('cadastro_usuario');
|
||||
$table->foreignId('ocupacao_id')->nullable()->constrained('sigtap.ocupacao');
|
||||
$table->foreignId('paciente_id')->nullable()->constrained('cadastro_paciente');
|
||||
$table->foreignId('procedimento_id')->constrained('sigtap.procedimento');
|
||||
$table->foreignId('registro_id')->constrained('sigtap.registro');
|
||||
$table->foreignId('servico_id')->nullable()->constrained('sigtap.servico');
|
||||
$table->foreignId('classificacao_id')->nullable()->constrained('sigtap.classificacao');
|
||||
$table->foreignId('cid_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('carater_atendimento_id')->nullable()->constrained('bpa_carater_atendimento');
|
||||
$table->string('origem', 100);
|
||||
$table->date('data_atendimento')->nullable();
|
||||
$table->integer('quantidade');
|
||||
$table->integer('idade')->nullable();
|
||||
|
||||
MigrationUtil::addCommonFieldsWithSoftDeletes($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_procedimento_consolidado');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaProcedimentoInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_procedimento_inconsistencia', function (Blueprint $table) {
|
||||
$table->foreignId('procedimento_id')->constrained('bpa_procedimento');
|
||||
$table->foreignId('inconsistencia_id')->constrained('bpa_inconsistencia');
|
||||
|
||||
$table->primary(['procedimento_id', 'inconsistencia_id']);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_procedimento_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class SetNullFieldArquivoFromBpaExportacao extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bpa_exportacao', function (Blueprint $table) {
|
||||
|
||||
$table->string('arquivo', 100)
|
||||
->nullable(true)
|
||||
->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('bpa_exportacao', function (Blueprint $table) {
|
||||
|
||||
$table->string('arquivo', 100)
|
||||
->nullable(false)
|
||||
->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterArquivosExportacaoBpaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
$cliente = app('config')->get('database.default');
|
||||
$destino = storage_path("app/faturamento/bpa/" . $cliente);
|
||||
|
||||
if (!File::exists($destino)) {
|
||||
File::makeDirectory($destino, 0775, true);
|
||||
}
|
||||
|
||||
DB::table('bpa_exportacao')
|
||||
->select(['arquivo'])
|
||||
->whereNotNull('arquivo')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->each(function ($registro) use ($destino) {
|
||||
$origem = storage_path('app/faturamento/bpa/' . $registro->arquivo);
|
||||
|
||||
if (File::exists($origem)) {
|
||||
File::move($origem, $destino . DIRECTORY_SEPARATOR . $registro->arquivo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaExportacaoStatusTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_exportacao_status', function (Blueprint $table) {
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_exportacao_status');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBpaExportacaoUnidadeTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bpa_exportacao_unidade', function (Blueprint $table) {
|
||||
$table->foreignId('exportacao_id')->constrained('bpa_exportacao');
|
||||
$table->foreignId('unidade_id')->constrained('cadastro_unidade');
|
||||
|
||||
$table->primary(['exportacao_id', 'unidade_id']);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bpa_exportacao_unidade');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Bpa\Exportacao;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddStatusIdToBpaExportacaoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('bpa_exportacao', function (Blueprint $table) {
|
||||
$table->foreignId('status_id')->nullable()->after('id')->constrained('bpa_exportacao_status');
|
||||
$table->dateTime('data_hora_inicio')->nullable()->after('arquivo');
|
||||
$table->dateTime('data_hora_fim')->nullable()->after('data_hora_inicio');
|
||||
$table->integer('quantidade_consistencia')->nullable()->after('data_hora_fim');
|
||||
$table->integer('quantidade_inconsistencia')->nullable()->after('quantidade_consistencia');
|
||||
});
|
||||
|
||||
DB::table('bpa_exportacao')
|
||||
->select([
|
||||
'bpa_exportacao.id',
|
||||
'cadastro_unidade.cnes',
|
||||
])
|
||||
->join('cadastro_unidade', 'cadastro_unidade.id', '=', 'bpa_exportacao.unidade_id')
|
||||
->get()
|
||||
->each(function ($query) {
|
||||
Exportacao::withTrashed()
|
||||
->find($query->id)
|
||||
->update(['cnes' => $query->cnes]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('bpa_exportacao', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('status_id');
|
||||
$table->dropColumn('cnes');
|
||||
$table->dropColumn('data_hora_inicio');
|
||||
$table->dropColumn('data_hora_fim');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Bpa\Exportacao;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropUnidadeIdOnBpaExportacaoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('bpa_exportacao')
|
||||
->select([
|
||||
'id',
|
||||
'unidade_id',
|
||||
])
|
||||
->get()
|
||||
->each(function ($query) {
|
||||
Exportacao::withTrashed()
|
||||
->find($query->id)
|
||||
->unidades()->sync($query->unidade_id);
|
||||
});
|
||||
|
||||
Schema::table('bpa_exportacao', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('unidade_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user