<?php 

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

return new class extends Migration {
    public function up(): void {
        Schema::create('lab_reports', function (Blueprint $table) {
            $table->id(); // Auto-increment ID
            $table->unsignedBigInteger('lab_id'); // Foreign key
            $table->text('report'); // Report content

            // Making all other fields nullable
            $table->text('complete_blood_count')->nullable();
            $table->text('lipid_profile')->nullable();
            $table->text('preoperative')->nullable();
            $table->text('acute_illness')->nullable();
            $table->text('screening')->nullable();
            $table->text('medicationmonitoring')->nullable();
            $table->text('cardiacmarkers')->nullable();
            $table->text('inflammatorymarkers')->nullable();
            $table->text('hormonalstudies')->nullable();
            $table->text('infectiousdiseasescreening')->nullable();
            $table->text('genetictesting')->nullable();
            $table->text('drugscreening')->nullable();
            $table->text('cbc')->nullable();
            $table->text('bmp')->nullable();
            $table->text('cmp')->nullable();
            $table->text('lipidpanel')->nullable();
            $table->text('thyroidfunctiontests')->nullable();
            $table->text('glucose')->nullable();
            $table->text('urinalysis')->nullable();
        
            $table->timestamps(); // created_at & updated_at

            // Foreign key constraint (Assuming 'labs' table exists)
            $table->foreign('lab_id')->references('id')->on('lab')->onDelete('cascade');
        });
    } 

    public function down(): void {
        Schema::dropIfExists('lab_reports');  
    }
};
