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 CreateIntegracaoBnafarParametrizacaoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('integracao_bnafar_parametrizacao', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('usuario', 100);
|
||||
$table->string('senha', 100);
|
||||
$table->boolean('ativo', 100)->default(false);
|
||||
|
||||
MigrationUtil::addCommonFields($table);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('integracao_bnafar_parametrizacao');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateIntegracaoBnafarMedicamentoTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('integracao_bnafar_medicamento', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('codigo', 20)->unique();
|
||||
$table->string('codigo_catmat', 100)->nullable();
|
||||
$table->string('codigo_registro_sanitario', 20)->nullable();
|
||||
$table->string('codigo_barras_primario', 20)->nullable();
|
||||
$table->string('codigo_barras_secundario', 20)->nullable();
|
||||
$table->text('descricao', 300)->nullable();
|
||||
$table->string('cnpj_nome_fabricante', 200)->nullable();
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('integracao_bnafar_medicamento');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIntegracaoBnafarMedicamentoIdToIntegracaoBnafarPosicaoEstoqueItemTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function (Blueprint $table) {
|
||||
$table->foreignId('integracao_bnafar_medicamento_id')->nullable()->after('fabricante_id')->constrained('integracao_bnafar_medicamento');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('integracao_bnafar_medicamento_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIntegracaoBnafarMedicamentoIdToIntegracaoBnafarSaidaItemTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_saida_item', function (Blueprint $table) {
|
||||
$table->foreignId('integracao_bnafar_medicamento_id')->nullable()->after('fabricante_id')->constrained('integracao_bnafar_medicamento');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_saida_item', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('integracao_bnafar_medicamento_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddValorUnitarioToIntegracaoBnafarPosicaoEstoqueItemTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function (Blueprint $table) {
|
||||
$table->decimal('valor_unitario', 19, 2)->after('quantidade')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function (Blueprint $table) {
|
||||
$table->dropColumn('valor_unitario');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddValorUnitarioToIntegracaoBnafarSaidaItemTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_saida_item', function (Blueprint $table) {
|
||||
$table->decimal('valor_unitario', 19, 2)->after('quantidade')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_saida_item', function (Blueprint $table) {
|
||||
$table->dropColumn('valor_unitario');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateIntegracaoBnafarRespostaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('integracao_bnafar_resposta', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('codigo', 100);
|
||||
$table->text('mensagem');
|
||||
$table->text('descricao');
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('integracao_bnafar_resposta');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateIntegracaoBnafarProtocoloRespostaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('integracao_bnafar_protocolo_resposta', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('protocolo_id')->constrained('integracao_bnafar_protocolo')->onDelete('cascade');
|
||||
$table->json('resposta');
|
||||
|
||||
MigrationUtil::addCommonFields($table, ['staticData' => true]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('integracao_bnafar_protocolo_resposta');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Integracao\Bnafar\ProtocoloResposta;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateIntegracaoBnafarProtocoloTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
DB::table('integracao_bnafar_protocolo')
|
||||
->select([
|
||||
'id',
|
||||
'erro'
|
||||
])
|
||||
->whereNotNull('erro')
|
||||
->get()
|
||||
->each(function($protocolo) {
|
||||
$erros = json_decode($protocolo->erro, true) ?? null;
|
||||
|
||||
if (!is_null($erros)) {
|
||||
if (isset($erros['exceptions'])) {
|
||||
foreach ($erros['exceptions'] as $exception) {
|
||||
ProtocoloResposta::create([
|
||||
'protocolo_id' => $protocolo->id,
|
||||
'resposta' => json_encode($exception),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
foreach ($erros as $erro) {
|
||||
if (isset($erro['inconsistencias'])) {
|
||||
foreach ($erro['inconsistencias'] as $inconsistencia) {
|
||||
ProtocoloResposta::create([
|
||||
'protocolo_id' => $protocolo->id,
|
||||
'resposta' => json_encode($inconsistencia),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropErroOnIntegracaoBnafarProtocoloTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_protocolo', function(Blueprint $table) {
|
||||
$table->dropColumn('erro');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_protocolo', function(Blueprint $table) {
|
||||
$table->json('erro')->nullable()->after('data_protocolo');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddCascadeOnIntegracaoBnafarTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_entrada_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['entrada_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_entrada', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['saida_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['dispensacao_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['posicao_estoque_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_protocolo_resposta', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_entrada_item', function(Blueprint $table) {
|
||||
$table->foreign('entrada_id')->references('id')->on('integracao_bnafar_entrada')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_entrada', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida_item', function(Blueprint $table) {
|
||||
$table->foreign('saida_id')->references('id')->on('integracao_bnafar_saida')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao_item', function(Blueprint $table) {
|
||||
$table->foreign('dispensacao_id')->references('id')->on('integracao_bnafar_dispensacao')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function(Blueprint $table) {
|
||||
$table->foreign('posicao_estoque_id')->references('id')->on('integracao_bnafar_posicao_estoque')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_protocolo_resposta', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_entrada_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['entrada_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_entrada', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['saida_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['dispensacao_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function(Blueprint $table) {
|
||||
$table->dropForeign(['posicao_estoque_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_protocolo_resposta', function(Blueprint $table) {
|
||||
$table->dropForeign(['protocolo_id']);
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_entrada_item', function(Blueprint $table) {
|
||||
$table->foreign('entrada_id')->references('id')->on('integracao_bnafar_entrada');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_entrada', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida_item', function(Blueprint $table) {
|
||||
$table->foreign('saida_id')->references('id')->on('integracao_bnafar_saida');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_saida', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao_item', function(Blueprint $table) {
|
||||
$table->foreign('dispensacao_id')->references('id')->on('integracao_bnafar_dispensacao');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_dispensacao', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function(Blueprint $table) {
|
||||
$table->foreign('posicao_estoque_id')->references('id')->on('integracao_bnafar_posicao_estoque');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_posicao_estoque', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo');
|
||||
});
|
||||
|
||||
Schema::table('integracao_bnafar_protocolo_resposta', function(Blueprint $table) {
|
||||
$table->foreign('protocolo_id')->references('id')->on('integracao_bnafar_protocolo');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddMensagemToIntegracaoBnafarPosicaoEstoqueItemTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function (Blueprint $table) {
|
||||
$table->text('mensagem')->after('valor_unitario')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_posicao_estoque_item', function (Blueprint $table) {
|
||||
$table->dropColumn('mensagem');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddMensagemToIntegracaoBnafarSaidaItemTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('integracao_bnafar_saida_item', function (Blueprint $table) {
|
||||
$table->text('mensagem')->after('valor_unitario')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('integracao_bnafar_saida_item', function (Blueprint $table) {
|
||||
$table->dropColumn('mensagem');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Enums\Integracao\Bnafar\BnafarProcessamentoStatus;
|
||||
|
||||
class RemoveSaidaEEstoqueTravados extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('integracao_bnafar_protocolo')
|
||||
->whereIn('processamento_status_id',[BnafarProcessamentoStatus::SERVIDOR_INICIOU_PROCESSAMENTO_PROTOCOLO, BnafarProcessamentoStatus::PROTOCOLO_NA_FILA_AGUARDANDO_INICIO_DO_PROCESSAMENTO])
|
||||
->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user