Healthcare management app: patients, appointments, consultations, lab, pharmacy inventory, billing, and reports at care.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?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
|
||||
{
|
||||
// Local mirror of the platform identity, keyed by public_id (OIDC sub).
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('public_id')->unique();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('email')->unique();
|
||||
$table->string('avatar_url')->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
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('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Ladill Care core schema — multi-branch healthcare facilities.
|
||||
*
|
||||
* Hierarchy: owner_ref → Organization → Branch → Department
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('care_organizations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->string('name');
|
||||
$table->string('slug')->index();
|
||||
$table->string('logo_path')->nullable();
|
||||
$table->string('timezone')->default('UTC');
|
||||
$table->json('settings')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unique(['owner_ref', 'slug']);
|
||||
});
|
||||
|
||||
Schema::create('care_branches', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('address')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('care_departments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('type')->default('general'); // general, outpatient, laboratory, pharmacy, radiology, etc.
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('care_members', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->string('user_ref')->index();
|
||||
$table->string('role');
|
||||
$table->foreignId('branch_id')->nullable()->constrained('care_branches')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
$table->unique(['organization_id', 'user_ref']);
|
||||
});
|
||||
|
||||
Schema::create('care_audit_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->nullable()->constrained('care_organizations')->nullOnDelete();
|
||||
$table->string('actor_ref')->nullable();
|
||||
$table->string('action');
|
||||
$table->string('subject_type')->nullable();
|
||||
$table->unsignedBigInteger('subject_id')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->string('ip_address')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->index(['owner_ref', 'created_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('care_audit_logs');
|
||||
Schema::dropIfExists('care_members');
|
||||
Schema::dropIfExists('care_departments');
|
||||
Schema::dropIfExists('care_branches');
|
||||
Schema::dropIfExists('care_organizations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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('care_patients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->nullable()->constrained('care_branches')->nullOnDelete();
|
||||
$table->string('patient_number')->index();
|
||||
$table->string('first_name');
|
||||
$table->string('last_name');
|
||||
$table->string('other_names')->nullable();
|
||||
$table->string('gender')->nullable();
|
||||
$table->date('date_of_birth')->nullable();
|
||||
$table->string('phone')->nullable()->index();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('national_id')->nullable()->index();
|
||||
$table->string('address')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('region')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unique(['organization_id', 'patient_number']);
|
||||
$table->index(['owner_ref', 'last_name', 'first_name']);
|
||||
});
|
||||
|
||||
Schema::create('care_patient_allergies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('allergen');
|
||||
$table->string('severity')->default('unknown');
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_patient_conditions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('condition');
|
||||
$table->date('onset_date')->nullable();
|
||||
$table->boolean('is_chronic')->default(false);
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_patient_family_history', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('relation');
|
||||
$table->string('condition');
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_emergency_contacts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('phone');
|
||||
$table->string('relationship')->nullable();
|
||||
$table->boolean('is_primary')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_insurance_policies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('provider_name');
|
||||
$table->string('policy_number')->nullable();
|
||||
$table->string('coverage_type')->nullable();
|
||||
$table->date('expiry_date')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_patient_attachments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('file_path');
|
||||
$table->string('original_name');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->string('document_type')->default('other');
|
||||
$table->string('uploaded_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('care_patient_attachments');
|
||||
Schema::dropIfExists('care_insurance_policies');
|
||||
Schema::dropIfExists('care_emergency_contacts');
|
||||
Schema::dropIfExists('care_patient_family_history');
|
||||
Schema::dropIfExists('care_patient_conditions');
|
||||
Schema::dropIfExists('care_patient_allergies');
|
||||
Schema::dropIfExists('care_patients');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,148 @@
|
||||
<?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('care_practitioners', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->nullable()->constrained('care_branches')->nullOnDelete();
|
||||
$table->foreignId('department_id')->nullable()->constrained('care_departments')->nullOnDelete();
|
||||
$table->foreignId('member_id')->nullable()->constrained('care_members')->nullOnDelete();
|
||||
$table->string('user_ref')->nullable()->index();
|
||||
$table->string('name');
|
||||
$table->string('specialty')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('care_practitioner_schedules', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('practitioner_id')->constrained('care_practitioners')->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('day_of_week'); // 0=Sunday … 6=Saturday
|
||||
$table->time('start_time');
|
||||
$table->time('end_time');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_visits', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('status')->default('open'); // open, in_progress, completed
|
||||
$table->timestamp('checked_in_at')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->string('checked_in_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->index(['owner_ref', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('care_appointments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->foreignId('practitioner_id')->nullable()->constrained('care_practitioners')->nullOnDelete();
|
||||
$table->foreignId('department_id')->nullable()->constrained('care_departments')->nullOnDelete();
|
||||
$table->foreignId('visit_id')->nullable()->constrained('care_visits')->nullOnDelete();
|
||||
$table->string('type')->default('scheduled'); // scheduled, walk_in
|
||||
$table->string('status')->default('scheduled');
|
||||
$table->timestamp('scheduled_at')->nullable();
|
||||
$table->timestamp('checked_in_at')->nullable();
|
||||
$table->timestamp('waiting_at')->nullable();
|
||||
$table->timestamp('started_at')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->timestamp('cancelled_at')->nullable();
|
||||
$table->unsignedInteger('queue_position')->nullable();
|
||||
$table->text('reason')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->index(['branch_id', 'status', 'scheduled_at']);
|
||||
});
|
||||
|
||||
Schema::create('care_consultations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('visit_id')->constrained('care_visits')->cascadeOnDelete();
|
||||
$table->foreignId('appointment_id')->nullable()->constrained('care_appointments')->nullOnDelete();
|
||||
$table->foreignId('practitioner_id')->nullable()->constrained('care_practitioners')->nullOnDelete();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('status')->default('draft'); // draft, completed
|
||||
$table->text('symptoms')->nullable();
|
||||
$table->text('clinical_notes')->nullable();
|
||||
$table->timestamp('started_at')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->string('completed_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('care_vital_signs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('consultation_id')->constrained('care_consultations')->cascadeOnDelete();
|
||||
$table->unsignedSmallInteger('bp_systolic')->nullable();
|
||||
$table->unsignedSmallInteger('bp_diastolic')->nullable();
|
||||
$table->unsignedSmallInteger('pulse')->nullable();
|
||||
$table->decimal('temperature', 4, 1)->nullable();
|
||||
$table->decimal('weight_kg', 5, 2)->nullable();
|
||||
$table->decimal('height_cm', 5, 1)->nullable();
|
||||
$table->unsignedSmallInteger('spo2')->nullable();
|
||||
$table->unsignedSmallInteger('respiratory_rate')->nullable();
|
||||
$table->string('recorded_by')->nullable();
|
||||
$table->timestamp('recorded_at');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_diagnoses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('consultation_id')->constrained('care_consultations')->cascadeOnDelete();
|
||||
$table->string('code')->nullable();
|
||||
$table->string('description');
|
||||
$table->boolean('is_primary')->default(false);
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_consultation_documents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('consultation_id')->constrained('care_consultations')->cascadeOnDelete();
|
||||
$table->string('file_path');
|
||||
$table->string('original_name');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->string('uploaded_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('care_consultation_documents');
|
||||
Schema::dropIfExists('care_diagnoses');
|
||||
Schema::dropIfExists('care_vital_signs');
|
||||
Schema::dropIfExists('care_consultations');
|
||||
Schema::dropIfExists('care_appointments');
|
||||
Schema::dropIfExists('care_visits');
|
||||
Schema::dropIfExists('care_practitioner_schedules');
|
||||
Schema::dropIfExists('care_practitioners');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,144 @@
|
||||
<?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('care_investigation_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('category')->default('blood'); // blood, urine, stool, xray, ultrasound, ct, mri, ecg, custom
|
||||
$table->text('description')->nullable();
|
||||
$table->string('unit')->nullable();
|
||||
$table->decimal('reference_low', 12, 4)->nullable();
|
||||
$table->decimal('reference_high', 12, 4)->nullable();
|
||||
$table->string('reference_text')->nullable();
|
||||
$table->unsignedInteger('price_minor')->default(0);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->index(['organization_id', 'category']);
|
||||
});
|
||||
|
||||
Schema::create('care_investigation_requests', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
|
||||
$table->foreignId('visit_id')->constrained('care_visits')->cascadeOnDelete();
|
||||
$table->foreignId('consultation_id')->nullable()->constrained('care_consultations')->nullOnDelete();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->foreignId('investigation_type_id')->constrained('care_investigation_types')->cascadeOnDelete();
|
||||
$table->foreignId('practitioner_id')->nullable()->constrained('care_practitioners')->nullOnDelete();
|
||||
$table->string('status')->default('pending');
|
||||
$table->string('priority')->default('routine'); // routine, urgent
|
||||
$table->text('clinical_notes')->nullable();
|
||||
$table->string('requested_by')->nullable();
|
||||
$table->foreignId('assigned_member_id')->nullable()->constrained('care_members')->nullOnDelete();
|
||||
$table->string('sample_barcode')->nullable();
|
||||
$table->timestamp('sample_collected_at')->nullable();
|
||||
$table->string('sample_collected_by')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->timestamp('delivered_at')->nullable();
|
||||
$table->string('approved_by')->nullable();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->index(['branch_id', 'status']);
|
||||
$table->index(['patient_id', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('care_investigation_results', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('investigation_request_id')->constrained('care_investigation_requests')->cascadeOnDelete();
|
||||
$table->text('result_summary')->nullable();
|
||||
$table->text('interpretation')->nullable();
|
||||
$table->boolean('is_abnormal')->default(false);
|
||||
$table->string('status')->default('draft'); // draft, approved
|
||||
$table->string('entered_by')->nullable();
|
||||
$table->string('approved_by')->nullable();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_investigation_result_values', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('investigation_result_id')->constrained('care_investigation_results')->cascadeOnDelete();
|
||||
$table->string('parameter');
|
||||
$table->string('value')->nullable();
|
||||
$table->string('unit')->nullable();
|
||||
$table->decimal('reference_low', 12, 4)->nullable();
|
||||
$table->decimal('reference_high', 12, 4)->nullable();
|
||||
$table->string('reference_text')->nullable();
|
||||
$table->boolean('is_abnormal')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_investigation_attachments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('investigation_result_id')->constrained('care_investigation_results')->cascadeOnDelete();
|
||||
$table->string('file_path');
|
||||
$table->string('original_name');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->string('uploaded_by')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_prescriptions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('visit_id')->constrained('care_visits')->cascadeOnDelete();
|
||||
$table->foreignId('consultation_id')->nullable()->constrained('care_consultations')->nullOnDelete();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->foreignId('practitioner_id')->nullable()->constrained('care_practitioners')->nullOnDelete();
|
||||
$table->string('status')->default('draft'); // draft, active, dispensed, cancelled
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('prescribed_by')->nullable();
|
||||
$table->string('dispensed_by')->nullable();
|
||||
$table->timestamp('dispensed_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->index(['patient_id', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('care_prescription_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('prescription_id')->constrained('care_prescriptions')->cascadeOnDelete();
|
||||
$table->boolean('is_procedure')->default(false);
|
||||
$table->string('name');
|
||||
$table->string('dosage')->nullable();
|
||||
$table->string('frequency')->nullable();
|
||||
$table->string('duration')->nullable();
|
||||
$table->string('route')->nullable();
|
||||
$table->string('quantity')->nullable();
|
||||
$table->text('instructions')->nullable();
|
||||
$table->unsignedSmallInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('care_prescription_items');
|
||||
Schema::dropIfExists('care_prescriptions');
|
||||
Schema::dropIfExists('care_investigation_attachments');
|
||||
Schema::dropIfExists('care_investigation_result_values');
|
||||
Schema::dropIfExists('care_investigation_results');
|
||||
Schema::dropIfExists('care_investigation_requests');
|
||||
Schema::dropIfExists('care_investigation_types');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,122 @@
|
||||
<?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('care_bills', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
|
||||
$table->foreignId('visit_id')->constrained('care_visits')->cascadeOnDelete();
|
||||
$table->foreignId('patient_id')->constrained('care_patients')->cascadeOnDelete();
|
||||
$table->string('invoice_number')->unique();
|
||||
$table->string('status')->default('open'); // draft, open, partial, paid, void
|
||||
$table->unsignedInteger('subtotal_minor')->default(0);
|
||||
$table->unsignedInteger('discount_minor')->default(0);
|
||||
$table->unsignedInteger('tax_minor')->default(0);
|
||||
$table->unsignedInteger('total_minor')->default(0);
|
||||
$table->unsignedInteger('amount_paid_minor')->default(0);
|
||||
$table->unsignedInteger('balance_minor')->default(0);
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('created_by')->nullable();
|
||||
$table->timestamp('finalized_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->index(['patient_id', 'status']);
|
||||
$table->index(['branch_id', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('care_bill_line_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('bill_id')->constrained('care_bills')->cascadeOnDelete();
|
||||
$table->string('type')->default('misc'); // consultation, lab, imaging, procedure, pharmacy, nursing, misc
|
||||
$table->string('description');
|
||||
$table->unsignedSmallInteger('quantity')->default(1);
|
||||
$table->unsignedInteger('unit_price_minor')->default(0);
|
||||
$table->unsignedInteger('total_minor')->default(0);
|
||||
$table->string('source_type')->nullable();
|
||||
$table->unsignedBigInteger('source_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('bill_id')->constrained('care_bills')->cascadeOnDelete();
|
||||
$table->unsignedInteger('amount_minor');
|
||||
$table->string('method')->default('cash'); // cash, momo, card, other
|
||||
$table->string('reference')->nullable();
|
||||
$table->timestamp('paid_at');
|
||||
$table->string('recorded_by')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('care_drugs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->nullable()->constrained('care_branches')->nullOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('generic_name')->nullable();
|
||||
$table->string('sku')->nullable();
|
||||
$table->string('unit')->default('unit');
|
||||
$table->unsignedInteger('unit_price_minor')->default(0);
|
||||
$table->unsignedInteger('reorder_level')->default(10);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('care_drug_batches', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('drug_id')->constrained('care_drugs')->cascadeOnDelete();
|
||||
$table->string('batch_number');
|
||||
$table->date('expiry_date')->nullable();
|
||||
$table->unsignedInteger('quantity_on_hand')->default(0);
|
||||
$table->unsignedInteger('cost_minor')->default(0);
|
||||
$table->timestamp('received_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['drug_id', 'expiry_date']);
|
||||
});
|
||||
|
||||
Schema::create('care_dispensing_records', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('prescription_id')->constrained('care_prescriptions')->cascadeOnDelete();
|
||||
$table->foreignId('prescription_item_id')->constrained('care_prescription_items')->cascadeOnDelete();
|
||||
$table->foreignId('drug_batch_id')->constrained('care_drug_batches')->cascadeOnDelete();
|
||||
$table->unsignedInteger('quantity');
|
||||
$table->string('dispensed_by')->nullable();
|
||||
$table->timestamp('dispensed_at');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::table('care_prescription_items', function (Blueprint $table) {
|
||||
$table->foreignId('drug_id')->nullable()->after('prescription_id')->constrained('care_drugs')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('care_prescription_items', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('drug_id');
|
||||
});
|
||||
Schema::dropIfExists('care_dispensing_records');
|
||||
Schema::dropIfExists('care_drug_batches');
|
||||
Schema::dropIfExists('care_drugs');
|
||||
Schema::dropIfExists('care_payments');
|
||||
Schema::dropIfExists('care_bill_line_items');
|
||||
Schema::dropIfExists('care_bills');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user