This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasExportacaoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_exportacao', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('unidade_id')->constrained('cadastro_unidade');
|
||||
$table->foreignId('competencia_id')->constrained('sigtap.competencia');
|
||||
$table->string('arquivo', 100)->nullable();
|
||||
$table->boolean('encaminhado')->default(false);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_exportacao');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasExportacaoFinanciamentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_exportacao_financiamento', function (Blueprint $table) {
|
||||
|
||||
$table->foreignId('exportacao_id')->constrained('raas_exportacao')->onDelete('cascade');
|
||||
$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('raas_exportacao_financiamento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasCaraterAtendimentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_carater_atendimento', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->char('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_carater_atendimento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasDestinoPacienteTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_destino_paciente', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->char('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_destino_paciente');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasMotivoSaidaPermanenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_motivo_saida_permanencia', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->char('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_motivo_saida_permanencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasOrigemPacienteTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_origem_paciente', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->char('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_origem_paciente');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasLocalRealizacaoExameTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_local_realizacao_exame', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->char('identificador', 1)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_local_realizacao_exame');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasAtendimentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_atendimento', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('exportacao_id')->nullable()->constrained('raas_exportacao');
|
||||
$table->foreignId('unidade_id')->constrained('cadastro_unidade');
|
||||
$table->foreignId('competencia_id')->constrained('sigtap.competencia');
|
||||
$table->date('data_admissao');
|
||||
$table->date('data_conclusao')->nullable();
|
||||
$table->foreignId('origem_paciente_id')->constrained('raas_origem_paciente');
|
||||
$table->foreignId('paciente_id')->constrained('cadastro_paciente');
|
||||
$table->boolean('cobertura_estrategia_saude_familia');
|
||||
$table->foreignId('unidade_cobertura_estrategia_familia_id')->nullable()->constrained('cadastro_unidade');
|
||||
$table->foreignId('cid_principal_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('cid_secundario_1_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('cid_secundario_2_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('cid_secundario_3_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('cid_causa_associada_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('destino_paciente_id')->constrained('raas_destino_paciente');
|
||||
$table->foreignId('motivo_saida_permanencia_id')->constrained('raas_motivo_saida_permanencia');
|
||||
$table->date('data_ocorrencia')->nullable();
|
||||
$table->foreignId('carater_atendimento_id')->nullable()->constrained('raas_carater_atendimento');
|
||||
$table->string('numero_autorizacao', 13)->nullable();
|
||||
$table->boolean('is_automatico');
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_atendimento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasAtendimentoProcedimentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_atendimento_procedimento', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('atendimento_id')->constrained('raas_atendimento')->onDelete('cascade');
|
||||
$table->foreignId('usuario_id')->constrained('cadastro_usuario');
|
||||
$table->foreignId('ocupacao_id')->constrained('sigtap.ocupacao');
|
||||
$table->foreignId('procedimento_id')->constrained('sigtap.procedimento');
|
||||
$table->unsignedInteger('quantidade');
|
||||
$table->date('data_execucao');
|
||||
$table->foreignId('servico_id')->nullable()->constrained('sigtap.servico');
|
||||
$table->foreignId('classificacao_id')->nullable()->constrained('sigtap.classificacao');
|
||||
$table->foreignId('local_realizacao_exame_id')->constrained('raas_local_realizacao_exame');
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_atendimento_procedimento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_inconsistencia', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('descricao', 100);
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasAtendimentoInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_atendimento_inconsistencia', function (Blueprint $table) {
|
||||
|
||||
$table->foreignId('atendimento_id')->constrained('raas_atendimento');
|
||||
$table->foreignId('inconsistencia_id')->constrained('raas_inconsistencia');
|
||||
|
||||
$table->primary(['atendimento_id', 'inconsistencia_id']);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_atendimento_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRaasAtendimentoProcedimentoInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('raas_atendimento_procedimento_inconsistencia', function (Blueprint $table) {
|
||||
|
||||
$table->foreignId('atendimento_procedimento_id')->constrained('raas_atendimento_procedimento');
|
||||
$table->foreignId('inconsistencia_id')->constrained('raas_inconsistencia');
|
||||
|
||||
$table->primary(['atendimento_procedimento_id', 'inconsistencia_id']);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('raas_atendimento_procedimento_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class CreateTransferirDirectoryInRaas extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
|
||||
$cliente = app('config')->get('database.default');
|
||||
|
||||
$destino = storage_path("app/faturamento/raas/" . $cliente);
|
||||
|
||||
if (!File::exists($destino)) {
|
||||
File::makeDirectory($destino, 0775, true);
|
||||
}
|
||||
|
||||
DB::table('raas_exportacao')
|
||||
->select(['id', 'arquivo'])
|
||||
->whereNotNull('arquivo')
|
||||
->orderBy('id')
|
||||
->chunk(1000, function ($registros) use ($destino) {
|
||||
|
||||
foreach ($registros as $registro) {
|
||||
|
||||
$origem = storage_path('app/faturamento/raas/' . $registro->arquivo);
|
||||
|
||||
if (File::exists($origem)) {
|
||||
$novoDestino = $destino . '/' . basename($registro->arquivo);
|
||||
File::move($origem, $novoDestino);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user