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 CreateApacExportacaoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_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('apac_exportacao');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacMotivoSaidaPermanenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_motivo_saida_permanencia', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->string('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_motivo_saida_permanencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacCaraterAtendimentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_carater_atendimento', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->string('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_carater_atendimento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacTipoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_tipo', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 50);
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_tipo');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacTipoAtendimentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_tipo_atendimento', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 50);
|
||||
$table->string('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_tipo_atendimento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacFonteOrcamentariaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_fonte_orcamentaria', function (Blueprint $table) {
|
||||
|
||||
MigrationUtil::idWithoutIncrements($table);
|
||||
|
||||
$table->string('nome', 100);
|
||||
$table->string('codigo', 2)->unique();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_fonte_orcamentaria');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacSolicitacaoAutorizacaoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_solicitacao_autorizacao', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('exportacao_id')->nullable()->constrained('apac_exportacao');
|
||||
$table->foreignId('competencia_id')->constrained('sigtap.competencia');
|
||||
$table->date('data_processamento');
|
||||
$table->string('numero_apac', 13)->nullable();
|
||||
$table->string('numero_apac_anterior', 13)->nullable();
|
||||
$table->foreignId('unidade_solicitante_id')->nullable()->constrained('cadastro_unidade');
|
||||
$table->foreignId('unidade_executante_id')->constrained('cadastro_unidade');
|
||||
$table->foreignId('usuario_executante_id')->constrained('cadastro_usuario');
|
||||
$table->date('data_inicial_validade');
|
||||
$table->date('data_final_validade');
|
||||
$table->foreignId('paciente_id')->constrained('cadastro_paciente');
|
||||
$table->foreignId('procedimento_principal_id')->constrained('sigtap.procedimento');
|
||||
$table->foreignId('procedimento_principal_ocupacao_id')->constrained('sigtap.ocupacao');
|
||||
$table->integer('procedimento_principal_quantidade');
|
||||
$table->string('procedimento_principal_cnpj_cessao_credito', 14)->nullable();
|
||||
$table->string('procedimento_principal_numero_nota_fiscal_cessao', 6)->nullable();
|
||||
$table->foreignId('procedimento_principal_cid_principal_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('procedimento_principal_cid_secundario_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('procedimento_principal_servico_id')->nullable()->constrained('sigtap.servico');
|
||||
$table->foreignId('procedimento_principal_classificacao_id')->nullable()->constrained('sigtap.classificacao');
|
||||
$table->string('procedimento_principal_unidade_prestadora_terceiro_cnes', 7)->nullable();
|
||||
$table->foreignId('cid_causa_associada_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('motivo_saida_permanencia_id')->constrained('apac_motivo_saida_permanencia');
|
||||
$table->date('data_ocorrencia')->nullable();
|
||||
$table->foreignId('tipo_atendimento_id')->nullable()->constrained('apac_tipo_atendimento');
|
||||
$table->foreignId('carater_atendimento_id')->constrained('apac_carater_atendimento');
|
||||
$table->foreignId('tipo_apac_id')->constrained('apac_tipo');
|
||||
$table->foreignId('usuario_responsavel_id')->constrained('cadastro_usuario');
|
||||
$table->date('data_solicitacao');
|
||||
$table->string('usuario_autorizador_nome', 30)->nullable();
|
||||
$table->string('usuario_autorizador_cns', 15)->nullable();
|
||||
$table->date('data_autorizacao')->nullable();
|
||||
$table->string('codigo_emissor', 10)->nullable();
|
||||
$table->foreignId('fonte_orcamentaria_id')->nullable()->constrained('apac_fonte_orcamentaria');
|
||||
$table->boolean('emenda_parlamentar')->nullable();
|
||||
$table->boolean('is_automatico');
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_solicitacao_autorizacao');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacSolicitacaoAutorizacaoProcedimentoSecundarioTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_solicitacao_autorizacao_procedimento_secundario', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('solicitacao_autorizacao_id')->constrained('apac_solicitacao_autorizacao')->onDelete('cascade');
|
||||
$table->foreignId('procedimento_id')->constrained('sigtap.procedimento');
|
||||
$table->foreignId('ocupacao_id')->constrained('sigtap.ocupacao');
|
||||
$table->integer('quantidade');
|
||||
$table->string('cnpj_cessao_credito', 14)->nullable();
|
||||
$table->string('numero_nota_fiscal_cessao', 6)->nullable();
|
||||
$table->foreignId('cid_principal_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('cid_secundario_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->foreignId('servico_id')->nullable()->constrained('sigtap.servico');
|
||||
$table->foreignId('classificacao_id')->nullable()->constrained('sigtap.classificacao');
|
||||
$table->string('unidade_prestadora_terceiro_cnes', 7)->nullable();
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_solicitacao_autorizacao_procedimento_secundario');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacSolicitacaoAutorizacaoLaudoGeralTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_solicitacao_autorizacao_laudo_geral', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('solicitacao_autorizacao_id')->constrained('apac_solicitacao_autorizacao')->onDelete('cascade');
|
||||
$table->foreignId('cid_principal_id')->constrained('sigtap.cid');
|
||||
$table->foreignId('cid_secundario_id')->nullable()->constrained('sigtap.cid');
|
||||
$table->date('data_identificacao_patologica')->nullable();
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_solicitacao_autorizacao_laudo_geral');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_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('apac_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacSolicitacaoAutorizacaoInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_solicitacao_autorizacao_inconsistencia', function (Blueprint $table) {
|
||||
|
||||
$table->foreignId('solicitacao_autorizacao_id')->constrained('apac_solicitacao_autorizacao')->onDelete('cascade');
|
||||
$table->foreignId('inconsistencia_id')->constrained('apac_inconsistencia');
|
||||
|
||||
$table->primary(['solicitacao_autorizacao_id', 'inconsistencia_id']);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_solicitacao_autorizacao_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateApacSolicitacaoAutorizacaoProcedimentoSecundInconsistenciaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('apac_solicitacao_autorizacao_procedimento_secund_inconsistencia', function (Blueprint $table) {
|
||||
|
||||
$table->foreignId('procedimento_secundario_id')
|
||||
->constrained('apac_solicitacao_autorizacao_procedimento_secundario')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreignId('inconsistencia_id')->constrained('apac_inconsistencia');
|
||||
|
||||
$table->primary(['procedimento_secundario_id', 'inconsistencia_id']);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('apac_solicitacao_autorizacao_procedimento_secund_inconsistencia');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTransferirDirectoryInApac extends Migration
|
||||
{
|
||||
|
||||
public function up()
|
||||
{
|
||||
|
||||
$cliente = app('config')->get('database.default');
|
||||
|
||||
$destino = storage_path("app/faturamento/apac/" . $cliente);
|
||||
|
||||
if (!File::exists($destino)) {
|
||||
File::makeDirectory($destino, 0775, true);
|
||||
}
|
||||
|
||||
DB::table('apac_exportacao')
|
||||
->select(['id', 'arquivo'])
|
||||
->whereNotNull('arquivo')
|
||||
->orderBy('id')
|
||||
->chunk(1000, function ($registros) use ($destino) {
|
||||
|
||||
foreach ($registros as $registro) {
|
||||
|
||||
$origem = storage_path('app/faturamento/apac/' . $registro->arquivo);
|
||||
|
||||
if (File::exists($origem)) {
|
||||
$novoDestino = $destino . '/' . basename($registro->arquivo);
|
||||
File::move($origem, $novoDestino);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user