401 lines
10 KiB
PHP
401 lines
10 KiB
PHP
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->enum('role', ['admin', 'pegawai'])->default('pegawai');
|
|
$table->rememberToken();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('pasiens', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('nik')->unique();
|
|
$table->string('nama_pasien');
|
|
$table->enum('jenis_kelamin', ['Laki-Laki', 'Perempuan']);
|
|
$table->date('tanggal_lahir');
|
|
$table->string('nomor_telepon')->nullable();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('asuransis', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('nama_asuransi');
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('pegawais', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('ruang_pelayanan_id')->constrained('ruang_pelayanans');
|
|
$table->string('nip')->unique();
|
|
$table->string('nama_pegawai');
|
|
$table->string('spesialisasi')->nullable();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('ruang_pelayanans', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('nama_ruang_pelayanan');
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('registrasis', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('pasien_id')->constrained('pasiens');
|
|
$table->foreignId('asuransi_id')->constrained('asuransis');
|
|
$table->foreignId('pegawai_id')->constrained('pegawais');
|
|
$table->foreignId('ruang_pelayanan_id')->constrained('ruang_pelayanans');
|
|
$table->string('nomor_kartu_asuransi');
|
|
$table->date('tanggal_registrasi');
|
|
$table->string('keluhan');
|
|
$table->string('nomor_antrian');
|
|
$table->enum('status', ['menunggu', 'proses', 'selesai'])->default('menunggu');
|
|
$table->timestamps();
|
|
});
|
|
|
|
public function up(): void
|
|
{
|
|
Schema::create('tindakans', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('nama_tindakan');
|
|
$table->decimal('tarif_tindakan', 10, 2);
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
Schema::create('transaksis', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('registrasi_id')->constrained('registrasis')->unique();
|
|
$table->foreignId('tindakan_id')->constrained('tindakans');
|
|
$table->foreignId('pegawai_id')->constrained('pegawais');
|
|
$table->integer('jumlah_tindakan');
|
|
$table->decimal('total_tarif', 10, 2);
|
|
$table->date('tanggal_transaksi');
|
|
$table->enum('metode_pembayaran', ['cash', 'transfer', 'debit', 'asuransi', 'qris'])->default('cash');
|
|
$table->enum('status_pembayaran', ['belum lunas', 'lunas'])->default('belum lunas');
|
|
$table->date('tanggal_pembayaran')->nullable();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('pasien_asuransi', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('pasien_id')->constrained('pasiens')->onDelete('cascade');
|
|
$table->foreignId('asuransi_id')->constrained('asuransis')->onDelete('cascade');
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('status_logs', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('transaksi_id')->constrained('transaksis')->onDelete('cascade');
|
|
$table->enum('status', ['menunggu', 'proses', 'selesai'])->default('menunggu');
|
|
$table->foreignId('pegawai_id')->constrained('pegawais');
|
|
$table->timestamp('waktu_perubahan')->default(DB::raw('CURRENT_TIMESTAMP'));
|
|
$table->timestamps();
|
|
});
|
|
|
|
class Asuransi extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\AsuransiFactory> */
|
|
use HasFactory;
|
|
|
|
protected $table = 'asuransis';
|
|
|
|
protected $fillable = [
|
|
'nama_asuransi',
|
|
];
|
|
|
|
public function pasien(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Pasien::class, 'pasien_asuransi',
|
|
'asuransi_id', 'pasien_id');
|
|
}
|
|
|
|
public function registrasi(): HasMany{
|
|
return $this->hasMany(Registrasi::class);
|
|
}
|
|
}
|
|
|
|
class Pasien extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\PasienFactory> */
|
|
use HasFactory;
|
|
|
|
|
|
protected $table = 'pasiens';
|
|
|
|
protected $fillable = [
|
|
'nik',
|
|
'nama_pasien',
|
|
'jenis_kelamin',
|
|
'tanggal_lahir',
|
|
'nomor_telepon',
|
|
];
|
|
|
|
public function umur(){
|
|
return Carbon::parse($this->tanggal_lahir)->age;
|
|
}
|
|
|
|
public function registrasi(): HasMany
|
|
{
|
|
return $this->hasMany(Registrasi::class);
|
|
}
|
|
|
|
public function transaksi(): HasOneThrough
|
|
{
|
|
return $this->hasOneThrough(Transaksi::class, Registrasi::class);
|
|
}
|
|
|
|
public function asuransi(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Asuransi::class, 'pasien_asuransi',
|
|
'pasien_id', 'asuransi_id');
|
|
}
|
|
}
|
|
|
|
class Pegawai extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\PegawaiFactory> */
|
|
use HasFactory;
|
|
|
|
protected $table = 'pegawais';
|
|
|
|
protected $fillable = [
|
|
'nip',
|
|
'ruang_pelayanan_id',
|
|
'nama_pegawai',
|
|
'spesialisasi',
|
|
];
|
|
|
|
public function registrasi (): HasMany {
|
|
return $this->hasMany(Registrasi::class);
|
|
}
|
|
|
|
public function transaksi(): HasMany
|
|
{
|
|
return $this->hasMany(Transaksi::class);
|
|
}
|
|
|
|
public function ruangPelayanan(): BelongsTo
|
|
{
|
|
return $this->belongsTo(RuangPelayanan::class);
|
|
}
|
|
}
|
|
|
|
class Registrasi extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\RegistrasiFactory> */
|
|
use HasFactory;
|
|
|
|
protected $table = 'registrasis';
|
|
|
|
protected $fillable = [
|
|
'pasien_id',
|
|
'asuransi_id',
|
|
'pegawai_id',
|
|
'ruang_pelayanan_id',
|
|
'nomor_kartu_asuransi',
|
|
'tanggal_registrasi',
|
|
'keluhan',
|
|
'nomor_antrian',
|
|
];
|
|
|
|
public function pasien ():BelongsTo {
|
|
return $this->belongsTo(Pasien::class);
|
|
}
|
|
|
|
public function asuransi ():BelongsTo {
|
|
return $this->belongsTo(Asuransi::class);
|
|
}
|
|
|
|
public function pegawai ():BelongsTo {
|
|
return $this->belongsTo(Pegawai::class);
|
|
}
|
|
|
|
public function ruang_pelayanan ():BelongsTo {
|
|
return $this->belongsTo(RuangPelayanan::class);
|
|
}
|
|
|
|
public function transaksi ():HasOne {
|
|
return $this->hasOne(Transaksi::class);
|
|
}
|
|
|
|
public function statusLog ():HasMany {
|
|
return $this->hasMany(StatusLog::class);
|
|
}
|
|
}
|
|
|
|
class RuangPelayanan extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\RuangPelayananFactory> */
|
|
use HasFactory;
|
|
|
|
protected $table = 'ruang_pelayanans';
|
|
|
|
protected $fillable = [
|
|
'nama_ruang_pelayanan',
|
|
];
|
|
|
|
public function pegawai (): HasMany {
|
|
return $this->hasMany(Pegawai::class);
|
|
}
|
|
|
|
public function registrasi(): HasMany {
|
|
return $this->hasMany(Registrasi::class);
|
|
}
|
|
}
|
|
|
|
class Tindakan extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\TindakanFactory> */
|
|
use HasFactory;
|
|
|
|
protected $table = 'tindakans';
|
|
|
|
protected $fillable = [
|
|
'nama_tindakan',
|
|
'tarif_tindakan',
|
|
];
|
|
|
|
public function transaksi ():HasMany {
|
|
return $this->hasMany(Transaksi::class);
|
|
}
|
|
|
|
public function transaksiDetails(): HasMany
|
|
{
|
|
return $this->hasMany(TransaksiDetail::class);
|
|
}
|
|
}
|
|
|
|
class Transaksi extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\TransaksiFactory> */
|
|
use HasFactory;
|
|
|
|
protected $table = 'transaksis';
|
|
|
|
protected $fillable = [
|
|
'registrasi_id',
|
|
'tindakan_id',
|
|
'pegawai_id',
|
|
'jumlah_tindakan',
|
|
'total_tarif',
|
|
'tanggal_transaksi',
|
|
'metode_pembayaran',
|
|
'tanggal_pembayaran',
|
|
];
|
|
|
|
public function registrasi ():BelongsTo {
|
|
return $this->belongsTo(Registrasi::class);
|
|
}
|
|
|
|
public function pegawai ():BelongsTo {
|
|
return $this->belongsTo(Pegawai::class);
|
|
}
|
|
|
|
public function tindakan (): BelongsTo{
|
|
return $this->belongsTo(Tindakan::class);
|
|
}
|
|
|
|
public function details (): HasMany {
|
|
return $this->hasMany(TransaksiDetail::class);
|
|
}
|
|
|
|
}
|
|
|
|
class TransaksiDetail extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\TransaksiDetailFactory> */
|
|
use HasFactory;
|
|
|
|
public function transaksi (): BelongsTo {
|
|
return $this->belongsTo(Transaksi::class);
|
|
}
|
|
}
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
|
use HasFactory, Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'role',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
}
|
|
|
|
class StatusLog extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\StatusLogFactory> */
|
|
use HasFactory;
|
|
protected $fillable = [
|
|
'registrasi_id',
|
|
'status',
|
|
'user_id',
|
|
'waktu_perubahan',
|
|
];
|
|
|
|
public function registrasi(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Registrasi::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|
|
|
|
class TransaksiDetail extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\TransaksiDetailFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'transaksi_id',
|
|
'tindakan_id',
|
|
'jumlah_tindakan',
|
|
'subtotal',
|
|
];
|
|
|
|
public function transaksi(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Transaksi::class);
|
|
}
|
|
|
|
public function tindakan(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tindakan::class);
|
|
}
|
|
}
|