<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('encounters', function (Blueprint $table) {
            $table->id();
            $table->foreignId('part_of')->nullable()->comment('encounter_id')->index();
            $table->string('status');
            $table->string('class')->nullable();
            $table->string('type')->nullable();
            $table->foreignId('patient_id')->nullable()->index();
            $table->foreignId('healthcare_id')->nullable()->index();
            $table->dateTime('start')->nullable();
            $table->dateTime('end')->nullable();
            $table->integer('number_of_bed')->nullable();
            $table->integer('duration_day')->nullable();

            $table->timestamps();
            $table->softDeletes();
            $table->unsignedBigInteger('created_by')->nullable()->index();
            $table->unsignedBigInteger('updated_by')->nullable()->index();
            $table->unsignedBigInteger('deleted_by')->nullable()->index();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('encounters');
    }
};
