Initial commit - Physiotherapy Clinic Management System
This commit is contained in:
commit
dbb326f2cc
300 files changed
+144285
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->text('two_factor_secret')->nullable();
|
||||
$table->text('two_factor_recovery_codes')->nullable();
|
||||
$table->boolean('two_factor_enabled')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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('currencies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code', 3)->unique(); // USD, EUR, BHD
|
||||
$table->string('name');
|
||||
$table->string('symbol', 10)->nullable();
|
||||
$table->integer('decimal_places')->default(2);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('currencies');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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('chart_of_accounts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code')->unique();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['asset', 'liability', 'equity', 'income', 'expense']);
|
||||
$table->enum('category', ['current_asset', 'fixed_asset', 'current_liability', 'long_term_liability', 'revenue', 'cost_of_goods_sold', 'operating_expense', 'other_income', 'other_expense']);
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('chart_of_accounts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('patients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('patient_code')->unique();
|
||||
$table->string('first_name');
|
||||
$table->string('last_name');
|
||||
$table->string('email')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->date('date_of_birth')->nullable();
|
||||
$table->enum('gender', ['male', 'female', 'other'])->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('emergency_contact_name')->nullable();
|
||||
$table->string('emergency_contact_phone')->nullable();
|
||||
$table->text('medical_history')->nullable();
|
||||
$table->text('allergies')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->foreignId('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('patients');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('appointments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('patient_id')->constrained('patients');
|
||||
$table->foreignId('user_id')->constrained('users'); // therapist/doctor
|
||||
$table->dateTime('appointment_date');
|
||||
$table->integer('duration_minutes')->default(60);
|
||||
$table->enum('status', ['scheduled', 'confirmed', 'in_progress', 'completed', 'cancelled', 'no_show'])->default('scheduled');
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('cancellation_reason')->nullable();
|
||||
$table->foreignId('cancelled_by')->nullable()->constrained('users');
|
||||
$table->timestamp('cancelled_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('appointments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('treatments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('patient_id')->constrained('patients');
|
||||
$table->foreignId('appointment_id')->nullable()->constrained('appointments');
|
||||
$table->foreignId('user_id')->constrained('users'); // therapist
|
||||
$table->string('treatment_code')->unique();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('sessions_count')->default(1);
|
||||
$table->integer('sessions_completed')->default(0);
|
||||
$table->date('start_date');
|
||||
$table->date('end_date')->nullable();
|
||||
$table->enum('status', ['planned', 'in_progress', 'completed', 'cancelled'])->default('planned');
|
||||
$table->decimal('total_cost', 15, 2)->default(0);
|
||||
$table->foreignId('currency_id')->constrained('currencies');
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('treatments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('invoices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('invoice_number')->unique();
|
||||
$table->foreignId('patient_id')->constrained('patients');
|
||||
$table->foreignId('treatment_id')->nullable()->constrained('treatments');
|
||||
$table->date('invoice_date');
|
||||
$table->date('due_date');
|
||||
$table->decimal('subtotal', 15, 2)->default(0);
|
||||
$table->decimal('tax_amount', 15, 2)->default(0);
|
||||
$table->decimal('discount_amount', 15, 2)->default(0);
|
||||
$table->decimal('total_amount', 15, 2)->default(0);
|
||||
$table->decimal('paid_amount', 15, 2)->default(0);
|
||||
$table->enum('status', ['draft', 'sent', 'paid', 'partial', 'overdue', 'cancelled'])->default('draft');
|
||||
$table->foreignId('currency_id')->constrained('currencies');
|
||||
$table->text('notes')->nullable();
|
||||
$table->foreignId('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invoices');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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('payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('payment_number')->unique();
|
||||
$table->foreignId('invoice_id')->constrained('invoices');
|
||||
$table->date('payment_date');
|
||||
$table->decimal('amount', 15, 2);
|
||||
$table->enum('payment_method', ['cash', 'card', 'bank_transfer', 'check', 'insurance', 'other']);
|
||||
$table->string('reference_number')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->foreignId('received_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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::table('currencies', function (Blueprint $table) {
|
||||
$table->decimal('exchange_rate_to_base', 15, 6)->default(1.00)->after('decimal_places');
|
||||
$table->boolean('is_base')->default(false)->after('exchange_rate_to_base');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->dropColumn(['exchange_rate_to_base', 'is_base']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('users', function (Blueprint $table) {
|
||||
$table->enum('role', ['admin', 'manager', 'therapist', 'receptionist'])->default('therapist')->after('email');
|
||||
$table->string('specialization')->nullable()->after('role');
|
||||
$table->decimal('hourly_rate', 10, 2)->nullable()->after('specialization');
|
||||
$table->decimal('session_rate', 10, 2)->nullable()->after('hourly_rate');
|
||||
$table->integer('target_sessions_per_day')->nullable()->after('session_rate');
|
||||
$table->integer('target_sessions_per_month')->nullable()->after('target_sessions_per_day');
|
||||
$table->json('working_schedule')->nullable()->after('target_sessions_per_month');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['role', 'specialization', 'hourly_rate', 'session_rate', 'target_sessions_per_day', 'target_sessions_per_month', 'working_schedule']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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::table('patients', function (Blueprint $table) {
|
||||
$table->string('whatsapp')->nullable()->after('phone');
|
||||
$table->string('national_id')->nullable()->after('whatsapp');
|
||||
$table->string('referral_source')->nullable()->after('national_id');
|
||||
$table->enum('status', ['active', 'inactive'])->default('active')->after('notes');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('patients', function (Blueprint $table) {
|
||||
$table->dropColumn(['whatsapp', 'national_id', 'referral_source', 'status']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('packages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->integer('number_of_sessions');
|
||||
$table->decimal('price', 15, 2);
|
||||
$table->foreignId('currency_id')->constrained('currencies');
|
||||
$table->integer('validity_days');
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('packages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('patient_packages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('patient_id')->constrained('patients');
|
||||
$table->foreignId('package_id')->constrained('packages');
|
||||
$table->integer('total_sessions');
|
||||
$table->integer('remaining_sessions');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->enum('status', ['active', 'expired', 'completed', 'cancelled'])->default('active');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('patient_packages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('reminder_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->text('content'); // with placeholders like {patient_name}, {date}, {time}, {therapist_name}
|
||||
$table->enum('channel', ['sms', 'whatsapp', 'email', 'internal']);
|
||||
$table->integer('hours_before')->default(24);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('reminders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('appointment_id')->constrained('appointments');
|
||||
$table->foreignId('template_id')->nullable()->constrained('reminder_templates');
|
||||
$table->enum('channel', ['sms', 'whatsapp', 'email', 'internal']);
|
||||
$table->text('content');
|
||||
$table->timestamp('send_at');
|
||||
$table->timestamp('sent_at')->nullable();
|
||||
$table->enum('status', ['queued', 'sent', 'failed'])->default('queued');
|
||||
$table->text('error_message')->nullable();
|
||||
$table->text('response')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('reminders');
|
||||
Schema::dropIfExists('reminder_templates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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('ledger_entries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('entry_date');
|
||||
$table->foreignId('chart_of_account_id')->constrained('chart_of_accounts');
|
||||
$table->foreignId('currency_id')->constrained('currencies');
|
||||
$table->decimal('amount', 15, 2);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('source_type')->nullable(); // invoice, payment, wage, manual
|
||||
$table->unsignedBigInteger('source_id')->nullable();
|
||||
$table->foreignId('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ledger_entries');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('wages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users'); // therapist/staff
|
||||
$table->date('period_start');
|
||||
$table->date('period_end');
|
||||
$table->integer('sessions_count')->default(0);
|
||||
$table->integer('hours_worked')->default(0);
|
||||
$table->decimal('base_amount', 15, 2);
|
||||
$table->decimal('bonus', 15, 2)->default(0);
|
||||
$table->decimal('deductions', 15, 2)->default(0);
|
||||
$table->decimal('total_amount', 15, 2);
|
||||
$table->foreignId('currency_id')->constrained('currencies');
|
||||
$table->enum('status', ['draft', 'approved', 'paid'])->default('draft');
|
||||
$table->text('notes')->nullable();
|
||||
$table->foreignId('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('wages');
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user