diff --git a/app/Models/Provider.php b/app/Models/Provider.php new file mode 100644 index 00000000..7d91d6be --- /dev/null +++ b/app/Models/Provider.php @@ -0,0 +1,39 @@ +belongsTo(Organization::class, 'organization_id'); + } +} + diff --git a/app/Models/RequestLog.php b/app/Models/RequestLog.php new file mode 100644 index 00000000..e9d7ddee --- /dev/null +++ b/app/Models/RequestLog.php @@ -0,0 +1,106 @@ + 'boolean', + 'admission_date' => 'datetime', + 'discharge_date' => 'datetime', + ]; + + protected static function boot() + { + parent::boot(); + + static::creating(function (self $model) { + if (empty($model->uuid)) { + $model->uuid = (string) Str::orderedUuid(); + } + + if (empty($model->code)) { + $model->code = self::getNextCode(); + } + }); + } + + public static function getNextCode(): string + { + $lastCode = (string) self::withTrashed()->max('code'); + preg_match('/(\d+)$/', $lastCode, $matches); + $nextNumber = isset($matches[1]) ? ((int) $matches[1] + 1) : (self::withTrashed()->count() + 1); + + return self::makeCode($nextNumber); + } + + public static function makeCode(int $nextNumber): string + { + return self::$codePrefix . '-' . str_pad((string) $nextNumber, 5, '0', STR_PAD_LEFT); + } + + public function organization() + { + return $this->belongsTo(Organization::class, 'organization_id'); + } + + public function member() + { + return $this->belongsTo(Member::class, 'member_id'); + } + + public function plan() + { + return $this->belongsTo(Plan::class, 'plan_id'); + } + + public function requestLogBenefits() + { + return $this->hasMany(RequestLogBenefit::class, 'request_log_id'); + } +} diff --git a/app/Models/RequestLogBenefit.php b/app/Models/RequestLogBenefit.php new file mode 100644 index 00000000..80bbeed2 --- /dev/null +++ b/app/Models/RequestLogBenefit.php @@ -0,0 +1,33 @@ +belongsTo(RequestLog::class, 'request_log_id'); + } + + public function benefit() + { + return $this->belongsTo(Benefit::class, 'benefit_id'); + } +} diff --git a/database/migrations/2026_05_13_150000_create_providers_table.php b/database/migrations/2026_05_13_150000_create_providers_table.php new file mode 100644 index 00000000..fb5d37fe --- /dev/null +++ b/database/migrations/2026_05_13_150000_create_providers_table.php @@ -0,0 +1,48 @@ +id(); + $table->foreignId('organization_id')->nullable()->index(); + $table->string('username')->index(); + $table->string('password'); + $table->string('code')->index(); + $table->string('status')->default('active'); + $table->text('header_token')->nullable(); + $table->text('token')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable()->index(); + $table->unsignedBigInteger('updated_by')->nullable()->index(); + $table->unsignedBigInteger('deleted_by')->nullable()->index(); + + $table->unique(['organization_id', 'username']); + $table->unique(['organization_id', 'code']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('providers'); + } +}; + diff --git a/database/migrations/2026_05_13_150100_create_request_logs_table.php b/database/migrations/2026_05_13_150100_create_request_logs_table.php new file mode 100644 index 00000000..94e57552 --- /dev/null +++ b/database/migrations/2026_05_13_150100_create_request_logs_table.php @@ -0,0 +1,93 @@ +id(); + $table->uuid('uuid'); + $table->string('code')->index(); + $table->foreignId('organization_id')->nullable()->index(); + $table->foreignId('member_id')->nullable()->index(); + $table->foreignId('plan_id')->nullable()->index(); + + $table->string('service_code')->nullable()->comment('IP / OP'); + $table->string('status')->nullable()->default('approved'); + $table->boolean('final_log')->default(false); + $table->string('status_final_log')->nullable(); + $table->string('source')->nullable()->default('api'); + + $table->text('keterangan')->nullable(); + $table->string('penempatan_kamar')->nullable(); + $table->decimal('total_cob', 18, 2)->nullable(); + + $table->string('nomor_sep')->nullable(); + $table->string('inacbgs_code')->nullable(); + $table->decimal('inacbgs_amount', 18, 2)->nullable(); + $table->string('no_transaksi_provider')->nullable(); + + $table->dateTime('admission_date')->nullable(); + $table->dateTime('discharge_date')->nullable(); + $table->string('diagnosis')->nullable(); + $table->string('nomor_rujukan')->nullable(); + $table->string('status_rujukan')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable()->index(); + $table->unsignedBigInteger('updated_by')->nullable()->index(); + $table->unsignedBigInteger('deleted_by')->nullable()->index(); + }); + return; + } + + Schema::table('request_logs', function (Blueprint $table) { + if (!Schema::hasColumn('request_logs', 'plan_id')) { + $table->foreignId('plan_id')->nullable()->index()->after('member_id'); + } + if (!Schema::hasColumn('request_logs', 'nomor_sep')) { + $table->string('nomor_sep')->nullable()->after('penempatan_kamar'); + } + if (!Schema::hasColumn('request_logs', 'inacbgs_code')) { + $table->string('inacbgs_code')->nullable()->after('nomor_sep'); + } + if (!Schema::hasColumn('request_logs', 'inacbgs_amount')) { + $table->decimal('inacbgs_amount', 18, 2)->nullable()->after('inacbgs_code'); + } + if (!Schema::hasColumn('request_logs', 'no_transaksi_provider')) { + $table->string('no_transaksi_provider')->nullable()->after('inacbgs_amount'); + } + if (!Schema::hasColumn('request_logs', 'admission_date')) { + $table->dateTime('admission_date')->nullable()->after('submission_date'); + } + if (!Schema::hasColumn('request_logs', 'nomor_rujukan')) { + $table->string('nomor_rujukan')->nullable()->after('nomor_sep'); + } + if (!Schema::hasColumn('request_logs', 'status_rujukan')) { + $table->string('status_rujukan')->nullable()->after('nomor_rujukan'); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('request_logs'); + } +}; diff --git a/database/migrations/2026_05_13_150200_create_request_log_benefits_table.php b/database/migrations/2026_05_13_150200_create_request_log_benefits_table.php new file mode 100644 index 00000000..84487ab8 --- /dev/null +++ b/database/migrations/2026_05_13_150200_create_request_log_benefits_table.php @@ -0,0 +1,54 @@ +id(); + $table->foreignId('request_log_id')->index(); + $table->foreignId('benefit_id')->index(); + $table->decimal('amount_incurred', 18, 2)->nullable()->default(0); + $table->decimal('amount_approved', 18, 2)->nullable()->default(0); + $table->decimal('excess_paid', 18, 2)->nullable()->default(0); + $table->string('keterangan')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable()->index(); + $table->unsignedBigInteger('updated_by')->nullable()->index(); + $table->unsignedBigInteger('deleted_by')->nullable()->index(); + + $table->unique(['request_log_id', 'benefit_id']); + }); + return; + } + + Schema::table('request_log_benefits', function (Blueprint $table) { + if (!Schema::hasColumn('request_log_benefits', 'keterangan')) { + $table->string('keterangan')->nullable()->after('excess_paid'); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('request_log_benefits'); + } +};