Update Doctor Resource

This commit is contained in:
R
2022-09-23 08:36:30 +07:00
parent a67afc27b6
commit 5fe1dc4bc6
36 changed files with 92181 additions and 15 deletions

View File

@@ -0,0 +1,40 @@
<?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('practices', function (Blueprint $table) {
$table->id();
$table->foreignId('practitioner_role_id');
$table->string('service_code');
$table->boolean('active')->default(1);
$table->timestamps();
$table->softDeletes();
$table->foreignId('created_by')->nullable()->index();
$table->foreignId('updated_by')->nullable()->index();
$table->foreignId('deleted_by')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('practices');
}
};

View File

@@ -0,0 +1,45 @@
<?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('prices', function (Blueprint $table) {
$table->id();
$table->morphs('priceable');
$table->foreignId('price_group_id');
$table->string('price_gross');
$table->string('price_net');
$table->boolean('has_tax');
$table->string('discount_type');
$table->string('discount_percentage');
$table->string('discount_absolute');
$table->timestamps();
$table->softDeletes();
$table->foreignId('created_by')->nullable()->index();
$table->foreignId('updated_by')->nullable()->index();
$table->foreignId('deleted_by')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('prices');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('practitioner_role_availabilities', function (Blueprint $table) {
$table->id();
$table->foreignId('practitioner_role_id');
$table->boolean('all_day');
$table->time('start_time')->nullable();
$table->time('end_time')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreignId('created_by')->nullable()->index();
$table->foreignId('updated_by')->nullable()->index();
$table->foreignId('deleted_by')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('practitioner_role_availabilities');
}
};

View File

@@ -0,0 +1,39 @@
<?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('practitioner_role_availability_days', function (Blueprint $table) {
$table->id();
$table->foreignId('availability_id');
$table->string('day');
$table->timestamps();
$table->softDeletes();
$table->foreignId('created_by')->nullable()->index();
$table->foreignId('updated_by')->nullable()->index();
$table->foreignId('deleted_by')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('practitioner_role_availability_days');
}
};

View File

@@ -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.
*
* @return void
*/
public function up()
{
Schema::create('provinces', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('provinces');
}
};

View File

@@ -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.
*
* @return void
*/
public function up()
{
Schema::create('cities', function (Blueprint $table) {
$table->id();
$table->foreignId('province_id');
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cities');
}
};

View File

@@ -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.
*
* @return void
*/
public function up()
{
Schema::create('districts', function (Blueprint $table) {
$table->id();
$table->foreignId('city_id');
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('districts');
}
};

View File

@@ -0,0 +1,34 @@
<?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('villages', function (Blueprint $table) {
$table->id();
$table->foreignId('district_id');
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('villages');
}
};

View File

@@ -0,0 +1,54 @@
<?php
namespace Database\Seeders;
use App\Models\City;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class CitySeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
City::truncate();
$chunks = [];
$time = now();
if (($handle = fopen(resource_path('files/city.csv'), "r")) !== FALSE) {
$firstline = true;
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
if (!$firstline) {
$d = explode(';', $data[0]);
$row = [
"id" => $d[0],
"province_id" => $d[1],
"name" => ucwords(strtolower($d[2])),
"created_at" => $time,
"updated_at" => $time
];
$chunks[] = $row;
}
$firstline = false;
if ($chunks && count($chunks) == 100) {
City::insert($chunks);
$chunks = [];
}
}
if ($chunks && count($chunks) > 0) {
City::insert($chunks);
$chunks = [];
}
fclose($handle);
}
}
}

View File

@@ -22,6 +22,10 @@ class DatabaseSeeder extends Seeder
IcdSeeder::class,
ServiceSeeder::class,
SpecialitiesSeeder::class,
ProvinceSeeder::class,
CitySeeder::class,
DistrictSeeder::class,
VillageSeeder::class
]);
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Database\Seeders;
use App\Models\District;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DistrictSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
District::truncate();
$chunks = [];
$time = now();
if (($handle = fopen(resource_path('files/district.csv'), "r")) !== FALSE) {
$firstline = true;
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
if (!$firstline) {
$d = explode(';', $data[0]);
$row = [
"id" => $d[0],
"city_id" => $d[1],
"name" => ucwords(strtolower($d[2])),
"created_at" => $time,
"updated_at" => $time
];
$chunks[] = $row;
}
$firstline = false;
if ($chunks && count($chunks) == 100) {
District::insert($chunks);
$chunks = [];
}
}
if ($chunks && count($chunks) > 0) {
District::insert($chunks);
$chunks = [];
}
fclose($handle);
}
}
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Database\Seeders;
use App\Models\Practice;
use App\Models\PractitionerRole;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class PractitionerRoleDummySeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Practice::truncate();
$times = [
'07:00:00',
'07:30:00',
'08:00:00',
'08:30:00',
'09:00:00',
'09:30:00',
'10:00:00',
'10:30:00',
'11:00:00',
'11:30:00',
'12:00:00',
'12:30:00',
'13:00:00',
'13:30:00',
'14:00:00',
'14:30:00',
'15:00:00',
'15:30:00',
'16:00:00',
'16:30:00',
'17:00:00',
'17:30:00',
'18:00:00',
'18:30:00',
];
PractitionerRole::chunk(100, function($chunkedPractitionerRoles) use ($times) {
foreach ($chunkedPractitionerRoles as $practitionerRole) {
$practitionerRole->practices()->insert([
[
'practitioner_role_id' => $practitionerRole->id,
'service_code' => 'instant-chat',
'active' => 1,
],
[
'practitioner_role_id' => $practitionerRole->id,
'service_code' => 'chat',
'active' => 1,
],
[
'practitioner_role_id' => $practitionerRole->id,
'service_code' => 'video',
'active' => 1,
],
[
'practitioner_role_id' => $practitionerRole->id,
'service_code' => 'walkin',
'active' => 1,
],
]);
$availabilities_data = [];
foreach($times as $time) {
$availabilities_data[] = [
'practitioner_role_id' => $practitionerRole->id,
'all_day' => 0,
'start_time' => $time
];
}
$practitionerRole->availabilities()->insert($availabilities_data);
}
});
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace Database\Seeders;
use App\Models\Province;
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ProvinceSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Province::truncate();
$chunks = [];
$time = now();
if (($handle = fopen(resource_path('files/province.csv'), "r")) !== FALSE) {
$firstline = true;
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
if (!$firstline) {
$d = explode(';', $data[0]);
$row = [
"id" => $d[0],
"name" => ucwords(strtolower($d[1])),
"created_at" => $time,
"updated_at" => $time
];
if ($row['name'] == 'Dki Jakarta') {
$row['name'] = 'DKI Jakarta';
}
$chunks[] = $row;
}
$firstline = false;
if ($chunks && count($chunks) == 100) {
Province::insert($chunks);
$chunks = [];
}
}
if ($chunks && count($chunks) > 0) {
Province::insert($chunks);
$chunks = [];
}
fclose($handle);
}
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Database\Seeders;
use App\Models\District;
use App\Models\Organization;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class UpdateOrganizationCities extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$organizations = Organization::with('currentAddress')->get();
$districtsMap = [
'ORG000C' => "367111",
'ORG000D' => "327504",
'ORG000E' => "317105",
'ORG000F' => "737109",
'ORG000M' => "327501",
'ORG000O' => "732402",
'ORG000P' => "327503",
'ORG000Q' => "321503",
'ORG000N' => "627103",
'ORG000SG' => "337410",
'ORG000BW' => "197104",
'ORG000SK' => "320233",
'ORG000PK' => "360312",
'ORG000CK' => "317106",
];
foreach ($organizations as $organization) {
$district = District::with([
'city',
'city.province'
])->find($districtsMap[$organization->code]);
$organization->currentAddress->district_id = $district->id ?? null;
$organization->currentAddress->city_id = $district->city->id ?? null;
$organization->currentAddress->province_id = $district->city->province->id ?? null;
$organization->currentAddress->save();
}
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Database\Seeders;
use App\Models\Village;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class VillageSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Village::truncate();
$chunks = [];
$time = now();
if (($handle = fopen(resource_path('files/village.csv'), "r")) !== FALSE) {
$firstline = true;
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
if (!$firstline) {
$d = explode(';', $data[0]);
$row = [
"id" => $d[0],
"district_id" => $d[1],
"name" => ucwords(strtolower($d[2])),
"created_at" => $time,
"updated_at" => $time
];
$chunks[] = $row;
}
$firstline = false;
if ($chunks && count($chunks) == 100) {
Village::insert($chunks);
$chunks = [];
}
}
if ($chunks && count($chunks) > 0) {
Village::insert($chunks);
$chunks = [];
}
fclose($handle);
}
}
}