list dokter, list RS
This commit is contained in:
85
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
85
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\DoctorResource;
|
||||
|
||||
class DoctorController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$doctors = PractitionerRole::active()->with('practitioner.person', 'organization')->paginate();
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources(DoctorResource::collection($doctors)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\OrganizationResource;
|
||||
|
||||
class OrganizationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$organizations = Organization::active()->hospital()->with('currentAddress')->paginate();
|
||||
return response()->json(Helper::paginateResources(OrganizationResource::collection($organizations)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,11 @@ use Modules\Internal\Http\Controllers\Api\CorporateServiceController;
|
||||
use Modules\Internal\Http\Controllers\Api\DiagnosisController;
|
||||
use Modules\Internal\Http\Controllers\Api\DiagnosisExclusionController;
|
||||
use Modules\Internal\Http\Controllers\Api\DivisionController;
|
||||
use Modules\Internal\Http\Controllers\Api\DoctorController;
|
||||
use Modules\Internal\Http\Controllers\Api\DrugController;
|
||||
use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
||||
use Modules\Internal\Http\Controllers\Api\MemberController;
|
||||
use Modules\Internal\Http\Controllers\Api\OrganizationController;
|
||||
use Modules\Internal\Http\Controllers\Api\PlanController;
|
||||
|
||||
/*
|
||||
@@ -36,10 +38,10 @@ Route::prefix('internal')->group(function () {
|
||||
Route::post('login', [AuthController::class, 'login'])->name('login');
|
||||
Route::post('forget-password', [AuthController::class, 'forgetPassword'])->name('forget-password');
|
||||
Route::post('verify-email', [AuthController::class, 'verifyEmail'])->name('verify-email');
|
||||
|
||||
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
|
||||
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
||||
Route::get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
@@ -53,10 +55,10 @@ Route::prefix('internal')->group(function () {
|
||||
Route::post('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'store']);
|
||||
Route::get('corporates/{corporate_id}/corporate-plans/{id}/edit', [CorporatePlanController::class, 'edit']);
|
||||
Route::put('corporates/{corporate_id}/corporate-plans/{id}', [CorporatePlanController::class, 'update']);
|
||||
|
||||
|
||||
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
|
||||
Route::post('corporates/{corporate_id}/plans/import', [PlanController::class, 'planImport']);
|
||||
|
||||
|
||||
Route::get('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'index']);
|
||||
Route::post('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'store']);
|
||||
Route::get('corporates/{corporate_id}/corporate-benefits/{id}/edit', [CorporateBenefitController::class, 'edit']);
|
||||
@@ -97,13 +99,15 @@ Route::prefix('internal')->group(function () {
|
||||
|
||||
Route::get('members', [MemberController::class, 'index']);
|
||||
Route::get('members/{member_id}/benefits', [MemberController::class, 'benefits']);
|
||||
|
||||
|
||||
Route::get('claims', [ClaimController::class, 'index']);
|
||||
Route::post('claims', [ClaimController::class, 'store']);
|
||||
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
||||
Route::post('check-limit', [ClaimController::class, 'checkLimit']);
|
||||
|
||||
});
|
||||
|
||||
Route::resource('organizations', OrganizationController::class);
|
||||
Route::resource('doctors', DoctorController::class);
|
||||
|
||||
// Route::get('something', [DiagnosisExclusionController::class, 'index']);
|
||||
});
|
||||
|
||||
38
Modules/Internal/Transformers/DoctorResource.php
Normal file
38
Modules/Internal/Transformers/DoctorResource.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DoctorResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$doctor = [
|
||||
'id' => $this->id,
|
||||
'his_dokter_id' => $this->meta->DokterID,
|
||||
'name' => $this->practitioner->person->name,
|
||||
'phone' => $this->practitioner->person->phone,
|
||||
'email' => $this->practitioner->person->email,
|
||||
'address' => $this->practitioner->person->currentAddress->text,
|
||||
'organization' => $this->organization->name,
|
||||
'organization_id' => $this->organization->id,
|
||||
'specialty' => $this->speciality->name,
|
||||
'specialtyI_id' => $this->speciality->id,
|
||||
'education' => $this->practitioner->meta->education,
|
||||
'experience' => $this->practitioner->meta->work_experience,
|
||||
'award' => $this->practitioner->meta->award,
|
||||
'keilmuan' => $this->practitioner->meta->Keilmuan,
|
||||
'tipe_dokter' => $this->practitioner->meta->tipeDokter,
|
||||
|
||||
];
|
||||
|
||||
return $doctor;
|
||||
}
|
||||
}
|
||||
31
Modules/Internal/Transformers/OrganizationResource.php
Normal file
31
Modules/Internal/Transformers/OrganizationResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrganizationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$organization = [
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'code' => $this->code,
|
||||
'description' => $this->description,
|
||||
'kodeRs' => $this->meta->kodeRs ?? null,
|
||||
'phone' => $this->meta->phone ?? null,
|
||||
'lat' => $this->currentAddress->lat ?? null,
|
||||
'lng' => $this->currentAddress->lng ?? null,
|
||||
'address' => $this->currentAddress ?? null,
|
||||
];
|
||||
|
||||
return $organization;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,17 @@ class Address extends Model
|
||||
'period_start',
|
||||
'period_end',
|
||||
];
|
||||
|
||||
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function addressable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
@@ -24,9 +24,18 @@ class Organization extends Model
|
||||
// 'metas'
|
||||
// ];
|
||||
|
||||
// public $appends = [
|
||||
// 'meta'
|
||||
// ];
|
||||
public $appends = [
|
||||
'meta'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* Scope a query to only include active data.
|
||||
|
||||
@@ -19,6 +19,21 @@ class PractitionerRole extends Model
|
||||
'active',
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'meta'
|
||||
];
|
||||
|
||||
public function getMetaAttribute()
|
||||
{
|
||||
$orgMeta = [];
|
||||
foreach ($this->metas as $meta) {
|
||||
$orgMeta[$meta->type] = $meta->value;
|
||||
}
|
||||
|
||||
return (object) $orgMeta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scope a query to only include active data.
|
||||
*
|
||||
|
||||
222
app/Services/DoctorService.php
Normal file
222
app/Services/DoctorService.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\Person;
|
||||
use App\Models\Practitioner;
|
||||
use App\Models\PractitionerRole;
|
||||
use App\Models\Speciality;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
|
||||
class DoctorService
|
||||
{
|
||||
public function getData()
|
||||
{
|
||||
$mapSpecialities = [
|
||||
'Akupunktur' => 'SP027',
|
||||
'Anak' => 'SP001',
|
||||
'Andrologi' => 'SP029',
|
||||
'Anastesia' => 'SP015',
|
||||
'Bedah Anak' => '',
|
||||
'Bedah Digestif' => '',
|
||||
'Bedah Mulut' => '',
|
||||
'Bedah Onkologi' => '',
|
||||
'Bedah Orthopedi' => 'SP007',
|
||||
'Bedah Plastik & Rekonstruksi' => 'SP005',
|
||||
'Bedah Saraf' => '',
|
||||
'Bedah Thorak & Kardiovaskuler' => '',
|
||||
'Bedah Umum' => 'SP004',
|
||||
'Bedah Vaskuler' => '',
|
||||
'Dokter Gigi' => 'SP026',
|
||||
'Fisik & Rehabilitasi' => 'SP014',
|
||||
'Gastroenterologi Hepatologi' => '',
|
||||
'Ginjal Hipertensi' => '',
|
||||
'Gizi Klinik' => 'SP019',
|
||||
'Hematologi Onkologi' => '',
|
||||
'Jantung & Pembuluh Darah' => 'SP008',
|
||||
'Kardio Vaskuler' => '',
|
||||
'Kebidanan & Kandungan' => 'SP003',
|
||||
'Kesehatan Jiwa' => 'SP018',
|
||||
'Kulit & Kelamin' => 'SP013',
|
||||
'Laboratorium' => '',
|
||||
'Mata' => 'SP011',
|
||||
'Okupasi' => 'SP016',
|
||||
'Paru' => 'SP009',
|
||||
'Patologi Klinik' => 'SP021',
|
||||
'Penyakit Dalam' => 'SP002',
|
||||
'Psikologi' => 'SP042',
|
||||
'Radiologi' => 'SP020',
|
||||
'Rehabilitasi Medik' => 'SP039',
|
||||
'Rheumatologi' => '',
|
||||
'Saraf' => 'SP012',
|
||||
'THT' => 'SP010',
|
||||
'Umum' => 'SP025',
|
||||
'Urologi' => 'SP006',
|
||||
'Lain-Lain' => '',
|
||||
];
|
||||
|
||||
$organizations = Organization::query()
|
||||
->whereHas('metas', function ($meta) {
|
||||
$meta->where('type', 'KodeRS');
|
||||
})
|
||||
->with('metas')
|
||||
->get();
|
||||
$specialities = Speciality::pluck('id', 'name')->toArray();
|
||||
foreach ($organizations as $organization) {
|
||||
|
||||
$hisOrganizationCode = $organization->meta->KodeRS ?? null;
|
||||
|
||||
if (empty($hisOrganizationCode)) {
|
||||
$this->command->warn('NO ORGANIZATION CODE' . $organization->name);
|
||||
continue;
|
||||
}
|
||||
$primayaApiService = new PrimayaApi($hisOrganizationCode);
|
||||
|
||||
$this->command->info('Getting RS ' . $hisOrganizationCode . '-' . $organization->name . ' PractitionerRole');
|
||||
|
||||
try {
|
||||
$doctors = $primayaApiService->doctors();
|
||||
$this->processDoctors($doctors, $mapSpecialities, $organization, $specialities);
|
||||
} catch (Exception $e) {
|
||||
$this->command->warn('Something Went Wrong :' . $hisOrganizationCode . ' - ' . $organization->name . ' - ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function processDoctors($doctors, $mapSpecialities, $organization, $specialities)
|
||||
{
|
||||
// foreach ($doctors['data'] as $doctor) {
|
||||
|
||||
// }
|
||||
|
||||
$organizations = Organization::query()
|
||||
->whereHas('metas', function ($meta) {
|
||||
$meta->where('type', 'KodeRS');
|
||||
})
|
||||
->with('metas')
|
||||
->get();
|
||||
$specialities = Speciality::pluck('id', 'name')->toArray();
|
||||
|
||||
foreach ($organizations as $organization) {
|
||||
$response = Http::get('https://app.primaya.id/temp/practitioners?code=' . $organization->meta->KodeRS);
|
||||
|
||||
foreach ($response->json()['practitioners'] as $practitioner) {
|
||||
$practitioner = json_decode(json_encode($practitioner));
|
||||
|
||||
dd($practitioner);
|
||||
if (!empty($practitioner->meta->NIK)) {
|
||||
$newPerson = Person::updateOrCreate([
|
||||
'nik' => $practitioner->meta->NIK
|
||||
], [
|
||||
'nik' => $practitioner->meta->NIK,
|
||||
'name' => $practitioner->doctor->name,
|
||||
'gender' => $practitioner->doctor->gender,
|
||||
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||
]);
|
||||
} else {
|
||||
$newPerson = Person::create([
|
||||
'name' => $practitioner->doctor->name,
|
||||
'gender' => $practitioner->doctor->gender,
|
||||
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||
]);
|
||||
}
|
||||
$newPerson->addresses()->create([
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $practitioner->doctor->address,
|
||||
]);
|
||||
|
||||
$newPractitioner = Practitioner::updateOrCreate([
|
||||
'person_id' => $newPerson->id
|
||||
], [
|
||||
'person_id' => $newPerson->id
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'medical_treatment',
|
||||
'value' => $practitioner->doctor->meta->MedicalTreatment ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'education',
|
||||
'value' => $practitioner->doctor->meta->Education ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'award',
|
||||
'value' => $practitioner->doctor->meta->Award ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'work_experience',
|
||||
'value' => $practitioner->doctor->meta->WorkExperience ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'alias',
|
||||
'value' => $practitioner->meta->Sapaan ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'Keilmuan',
|
||||
'value' => $practitioner->meta->Keilmuan ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'description',
|
||||
'value' => $practitioner->doctor->description ?? null,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
$newPractitionerRole = PractitionerRole::create([
|
||||
'practitioner_id' => $newPractitioner->id,
|
||||
'organization_id' => $organization->id,
|
||||
'speciality_id' => $practitioner->speciality ? ($specialities[$practitioner->speciality->name] ?? null) : null,
|
||||
'active' => 1,
|
||||
]);
|
||||
|
||||
if (empty($newPractitionerRole->speciality_id)) {
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality_code',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality_code',
|
||||
'value' => $practitioner->speciality->code ?? null,
|
||||
]);
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality',
|
||||
'value' => $practitioner->speciality->name ?? null,
|
||||
]);
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality_image',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality_image',
|
||||
'value' => $practitioner->speciality->name ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
], [
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
'value' => $practitioner->meta->DokterID ?? null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
app/Services/PrimayaApi.php
Normal file
123
app/Services/PrimayaApi.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Mockery\Generator\Parameter;
|
||||
use Psy\CodeCleaner\FunctionContextPass;
|
||||
use Termwind\Components\Dd;
|
||||
|
||||
class PrimayaApi
|
||||
{
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* @param string $KodeRS C,DE,...
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $KodeRS)
|
||||
{
|
||||
// TODO Feels Wrong
|
||||
$endpointMaps = [
|
||||
"C" => [
|
||||
"base_url" => "http://tgr.primaya.id:1234",
|
||||
"token" => "1|QGYpSbyi9snAj1bHl1lP6apLJxbl20gsAoPmu1oh",
|
||||
],
|
||||
"D" => [
|
||||
"base_url" => "http://primaya-hospital.com:38588",
|
||||
"token" => "1|nbVbBmNmm967qYs9dNA0JvFNGvArGFGwFHJ8C9nK",
|
||||
],
|
||||
"E" => [
|
||||
"base_url" => "http://evasari.fortiddns.com:9280",
|
||||
"token" => "1|qb17AM6BB5sw1a3vZ2BTfIHXbPisqLSBdhwZKGJv",
|
||||
],
|
||||
"F" => [
|
||||
"base_url" => "http://mks.primaya.id:2588",
|
||||
"token" => null,
|
||||
],
|
||||
"M" => [ // Bektim
|
||||
"base_url" => 'http://101.255.124.84',
|
||||
"token" => null,
|
||||
],
|
||||
"O" => [
|
||||
"base_url" => "http://rsinco.fortiddns.com:88",
|
||||
"token" => "1|7e64N6gfSxsBic7DgwVec6EKQAIAx9Dd7is7K5Db",
|
||||
],
|
||||
"P" => [
|
||||
"base_url" => "http://bekut.primaya.id:88",
|
||||
"token" => "1|N5s4oKJNRnrpA2lneFI5LBhGNq6xwioY6PKDIA10",
|
||||
],
|
||||
"Q" => [
|
||||
"base_url" => "http://krw.primaya.id:4040",
|
||||
"token" => "1|zyS7AbeqzwKavfXFu0ReQOn5npIjdzVqA0pMqaMt",
|
||||
],
|
||||
"N" => [
|
||||
"base_url" => "http://pky.primaya.id:88",
|
||||
"token" => "1|yiajZEyu7pBkJNacv60tmb6McimbakG5lGzhm1Oy",
|
||||
],
|
||||
"SG" => [
|
||||
"base_url" => "http://smg.primaya.id:4040",
|
||||
"token" => "1|2lXZqpzhofXA2IjPdL7z52iBRiqrK5Eio924hMxi",
|
||||
],
|
||||
"BW" => [
|
||||
"base_url" => "http://bwp.primaya.id:4040",
|
||||
"token" => "1|8I6mdDxSUO0019GbbVx6olcACjaklxLUgmg0zUKh",
|
||||
],
|
||||
"SK" => [
|
||||
"base_url" => "http://skb.primaya.id:4040",
|
||||
"token" => "1|nYXzAvDbTceumUIDCr9sqXzj2Hq1kvfjYWeVg60P",
|
||||
],
|
||||
"PK" => [
|
||||
"base_url" => "http://pkt.primaya.id:4040",
|
||||
"token" => "2|nvIdQ7gzJnB7xQhfdjxlkr3oRSqBIvBOunjj72QO",
|
||||
],
|
||||
"CK" => [
|
||||
"base_url" => "http://103.154.92.150:4040",
|
||||
"token" => "1|BEKJwPhrmyjGwYVbl6xARV2auLSMtgYJyP4E3Kgd",
|
||||
],
|
||||
"DE" => [
|
||||
"base_url" => "http://202.148.23.68:38807",
|
||||
"token" => "1|DgEL6wte9vmg5X74AUBPVlbMtTIbDqrrp990Kqrt",
|
||||
],
|
||||
];
|
||||
|
||||
$config = $endpointMaps[$KodeRS];
|
||||
$this->base_url = !empty($config['base_url']) ? ($config['base_url'] . '/api') : null;
|
||||
|
||||
$this->headers = [
|
||||
'Authorization' => 'Bearer ' . ($config['token'] ?? null)
|
||||
];
|
||||
}
|
||||
|
||||
public static function getBaseUrl()
|
||||
{
|
||||
return config('lms-api.base_url');
|
||||
}
|
||||
|
||||
public static function getDefaultHeaders()
|
||||
{
|
||||
return ['id' => config('lms-api.auth_id')];
|
||||
}
|
||||
|
||||
public function consultationPrice($LayananKodes = [], $timeout = 30)
|
||||
{
|
||||
$response = Http::timeout($timeout)
|
||||
->withHeaders($this->headers)
|
||||
->post(
|
||||
$this->base_url . '/consultation-price',
|
||||
empty($LayananKodes) ? null : $LayananKodes
|
||||
)->json();
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function doctors($page = 1)
|
||||
{
|
||||
$response = Http::withHeaders($this->headers)
|
||||
->get($this->base_url . '/doctors' . '?page=' . $page)
|
||||
->json();
|
||||
|
||||
return $response;
|
||||
}
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Address;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
@@ -2,14 +2,20 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Address;
|
||||
use App\Models\Meta;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Person;
|
||||
use App\Models\Practitioner;
|
||||
use App\Models\PractitionerRole;
|
||||
use App\Models\Speciality;
|
||||
use App\Services\DoctorService;
|
||||
use App\Services\PrimayaApi;
|
||||
use Exception;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Termwind\Components\Dd;
|
||||
|
||||
class PractitionerSeeder extends Seeder
|
||||
{
|
||||
@@ -20,127 +26,222 @@ class PractitionerSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Person::truncate();
|
||||
// Practitioner::truncate();
|
||||
// PractitionerRole::truncate();
|
||||
// Meta::query()->where('metaable_type', Practitioner::class)->forceDelete();
|
||||
// Meta::query()->where('metaable_type', PractitionerRole::class)->forceDelete();
|
||||
// Address::query()->where('addressable_type', Person::class)->forceDelete();
|
||||
|
||||
|
||||
|
||||
$mapSpecialities = [
|
||||
'Akupunktur' => 'SP027',
|
||||
'Anak' => 'SP001',
|
||||
'Andrologi' => 'SP029',
|
||||
'Anastesia' => 'SP015',
|
||||
'Bedah Anak' => '',
|
||||
'Bedah Digestif' => '',
|
||||
'Bedah Mulut' => '',
|
||||
'Bedah Onkologi' => '',
|
||||
'Bedah Orthopedi' => 'SP007',
|
||||
'Bedah Plastik & Rekonstruksi' => 'SP005',
|
||||
'Bedah Saraf' => '',
|
||||
'Bedah Thorak & Kardiovaskuler' => '',
|
||||
'Bedah Umum' => 'SP004',
|
||||
'Bedah Vaskuler' => '',
|
||||
'Dokter Gigi' => 'SP026',
|
||||
'Fisik & Rehabilitasi' => 'SP014',
|
||||
'Gastroenterologi Hepatologi' => '',
|
||||
'Ginjal Hipertensi' => '',
|
||||
'Gizi Klinik' => 'SP019',
|
||||
'Hematologi Onkologi' => '',
|
||||
'Jantung & Pembuluh Darah' => 'SP008',
|
||||
'Kardio Vaskuler' => '',
|
||||
'Kebidanan & Kandungan' => 'SP003',
|
||||
'Kesehatan Jiwa' => 'SP018',
|
||||
'Kulit & Kelamin' => 'SP013',
|
||||
'Laboratorium' => '',
|
||||
'Mata' => 'SP011',
|
||||
'Okupasi' => 'SP016',
|
||||
'Paru' => 'SP009',
|
||||
'Patologi Klinik' => 'SP021',
|
||||
'Penyakit Dalam' => 'SP002',
|
||||
'Psikologi' => 'SP042',
|
||||
'Radiologi' => 'SP020',
|
||||
'Rehabilitasi Medik' => 'SP039',
|
||||
'Rheumatologi' => '',
|
||||
'Saraf' => 'SP012',
|
||||
'THT' => 'SP010',
|
||||
'Umum' => 'SP025',
|
||||
'Urologi' => 'SP006',
|
||||
'Lain-Lain' => '',
|
||||
];
|
||||
|
||||
$organizations = Organization::query()
|
||||
->whereHas('metas', function ($meta) {
|
||||
$meta->where('type', 'KodeRS');
|
||||
})
|
||||
->where('type', 'hospital')
|
||||
->with('metas')
|
||||
->get();
|
||||
$specialities = Speciality::pluck('id', 'name')->toArray();
|
||||
|
||||
foreach ($organizations as $organization) {
|
||||
$response = Http::get('https://app.primaya.id/temp/practitioners?code=' . $organization->meta->KodeRS);
|
||||
$hisOrganizationCode = $organization->meta->KodeRS ?? null;
|
||||
|
||||
foreach ($response->json()['practitioners'] as $practitioner) {
|
||||
$practitioner = json_decode(json_encode($practitioner));
|
||||
if (!empty($practitioner->meta->NIK)) {
|
||||
$newPerson = Person::updateOrCreate([
|
||||
'nik' => $practitioner->meta->NIK
|
||||
], [
|
||||
'nik' => $practitioner->meta->NIK,
|
||||
'name' => $practitioner->doctor->name,
|
||||
'gender' => $practitioner->doctor->gender,
|
||||
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||
]);
|
||||
} else {
|
||||
$newPerson = Person::create([
|
||||
'name' => $practitioner->doctor->name,
|
||||
'gender' => $practitioner->doctor->gender,
|
||||
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||
]);
|
||||
}
|
||||
$newPerson->addresses()->create([
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $practitioner->doctor->address,
|
||||
]);
|
||||
if (empty($hisOrganizationCode)) {
|
||||
$this->command->warn('NO ORGANIZATION CODE' . $organization->name);
|
||||
continue;
|
||||
}
|
||||
$primayaApiService = new PrimayaApi($hisOrganizationCode);
|
||||
|
||||
$newPractitioner = Practitioner::updateOrCreate([
|
||||
'person_id' => $newPerson->id
|
||||
$this->command->info('Getting RS ' . $hisOrganizationCode . '-' . $organization->name . ' PractitionerRole');
|
||||
|
||||
try {
|
||||
$doctors = $primayaApiService->doctors();
|
||||
$this->processDoctors($doctors, $mapSpecialities, $organization);
|
||||
} catch (Exception $e) {
|
||||
$this->command->warn('Something Went Wrong :' . $hisOrganizationCode . ' - ' . $organization->name . ' - ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function processDoctors($doctors, $mapSpecialities, $organization)
|
||||
{
|
||||
foreach ($doctors['data'] as $doctor) {
|
||||
|
||||
$DokterID = $doctor['DokterID'];
|
||||
|
||||
// $practitionerRole = PractitionerRole::whereHas('metas', function ($meta) use ($DokterID) {
|
||||
// $meta->where('type', 'DokterID')->where('value', $DokterID);
|
||||
// })->first();
|
||||
|
||||
$SpesialisasiID = optional($doctor['spesialisasi'])['KodeSpesialisasiID'] ?? null;
|
||||
$mapping = array_search($SpesialisasiID, $mapSpecialities);
|
||||
if ($mapping == false) {
|
||||
$this->command->warn('Skip Doctor : ' . $DokterID . '-' . $doctor['Nama'] . ' (Tidak Punya Spesialisasi)');
|
||||
continue;
|
||||
}
|
||||
$findSpecialityId = Speciality::where('name', $mapping)->first()->id;
|
||||
|
||||
$newPerson = Person::updateOrCreate([
|
||||
'nik' => $doctor['NIK']
|
||||
], [
|
||||
'nik' => (!empty($doctor['NIK'])) ? $doctor['NIK'] : null,
|
||||
'name' => $doctor['Nama'],
|
||||
'birth_date' => (!empty($doctor['TanggalLahir']) && $doctor['TanggalLahir'] != '0000-00-00') ? $doctor['TanggalLahir'] : null,
|
||||
'gender' => !empty($doctor['Kelamin']) ? $doctor['Kelamin'] : null,
|
||||
'phone' => (!empty($doctor['Ponsel']) && $doctor['Ponsel'] != '-') ? $doctor['Ponsel'] : null,
|
||||
'email' => (!empty($doctor['Email']) && $doctor['Email'] != '-') ? $doctor['Email'] : null,
|
||||
'birth_place' => (!empty($doctor['TempatLahir']) && $doctor['TempatLahir'] != '-') ? $doctor['TempatLahir'] : null,
|
||||
]);
|
||||
|
||||
// $newPerson = Person::create([
|
||||
// 'name' => $doctor['Nama'],
|
||||
// 'birth_date' => (!empty($doctor['TanggalLahir']) && $doctor['TanggalLahir'] != '0000-00-00') ? $doctor['TanggalLahir'] : null,
|
||||
// 'gender' => !empty($doctor['Kelamin']) ? $doctor['Kelamin'] : null,
|
||||
// ]);
|
||||
|
||||
$newAddress = $newPerson->addresses()->updateOrCreate([
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => (!empty($doctor['Alamat']) && $doctor['Alamat'] != '-') ? $doctor['Alamat'] : null,
|
||||
]);
|
||||
|
||||
$newPerson->main_address_id = $newAddress->id;
|
||||
$newPerson->save();
|
||||
|
||||
$newPractitioner = Practitioner::updateOrCreate([
|
||||
'person_id' => $newPerson->id
|
||||
], [
|
||||
'person_id' => $newPerson->id
|
||||
]);
|
||||
|
||||
|
||||
$newPractitioner->metas()->updateOrCreate([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'education',
|
||||
'value' => (!empty($doctor['ProfilePendidikan']) && $doctor['ProfilePendidikan'] != '-') ? $doctor['ProfilePendidikan'] : null
|
||||
]);
|
||||
$newPractitioner->metas()->updateOrCreate([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'award',
|
||||
'value' => (!empty($doctor['ProfileAward']) && $doctor['ProfileAward'] != '-') ? $doctor['ProfileAward'] : null
|
||||
]);
|
||||
$newPractitioner->metas()->updateOrCreate([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'work_experience',
|
||||
'value' => (!empty($doctor['ProfilePengalamanKerja']) && $doctor['ProfilePengalamanKerja'] != '-') ? $doctor['ProfilePengalamanKerja'] : null
|
||||
]);
|
||||
$newPractitioner->metas()->updateOrCreate([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'alias',
|
||||
'value' => (!empty($doctor['Sapaan']) && $doctor['Sapaan'] != '-') ? $doctor['Sapaan'] : null
|
||||
]);
|
||||
$newPractitioner->metas()->updateOrCreate([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'Keilmuan',
|
||||
'value' => (!empty($doctor['Keilmuan']) && $doctor['Keilmuan'] != '-') ? $doctor['Keilmuan'] : null
|
||||
]);
|
||||
|
||||
$newPractitioner->metas()->updateOrCreate([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'tipeDokter',
|
||||
'value' => (!empty($doctor['Tipe']) && $doctor['Tipe'] != '-') ? $doctor['Tipe'] : null
|
||||
]);
|
||||
// $newPractitioner->metas()->create([
|
||||
// 'system' => 'primaya-his',
|
||||
// 'type' => 'description',
|
||||
// 'value' => $doctor['Description']
|
||||
// ]);
|
||||
|
||||
$newPractitionerRole = PractitionerRole::updateOrCreate([
|
||||
'practitioner_id' => $newPractitioner->id,
|
||||
'organization_id' => $organization->id,
|
||||
'speciality_id' => $findSpecialityId,
|
||||
'active' => 1,
|
||||
]);
|
||||
|
||||
$this->command->info('Doctor : ' . $DokterID . '-' . $doctor['Nama'] . ' (Spesialisasi : ' . $mapping . ')');
|
||||
|
||||
if (empty($newPractitionerRole->speciality_id)) {
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality_code',
|
||||
], [
|
||||
'person_id' => $newPerson->id
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'medical_treatment',
|
||||
'value' => $practitioner->doctor->meta->MedicalTreatment ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'education',
|
||||
'value' => $practitioner->doctor->meta->Education ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'award',
|
||||
'value' => $practitioner->doctor->meta->Award ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'work_experience',
|
||||
'value' => $practitioner->doctor->meta->WorkExperience ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'alias',
|
||||
'value' => $practitioner->meta->Sapaan ?? null,
|
||||
'type' => 'speciality_code',
|
||||
'value' => (!empty($doctor['KodeSpesialisasiID']) && $doctor['KodeSpesialisasiID'] != '-') ? $doctor['KodeSpesialisasiID'] : null
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'Keilmuan',
|
||||
'value' => $practitioner->meta->Keilmuan ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'description',
|
||||
'value' => $practitioner->doctor->description ?? null,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
$newPractitionerRole = PractitionerRole::create([
|
||||
'practitioner_id' => $newPractitioner->id,
|
||||
'organization_id' => $organization->id,
|
||||
'speciality_id' => $practitioner->speciality ? ($specialities[$practitioner->speciality->name] ?? null) : null,
|
||||
'active' => 1,
|
||||
]);
|
||||
|
||||
if (empty($newPractitionerRole->speciality_id)) {
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality_code',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality_code',
|
||||
'value' => $practitioner->speciality->code ?? null,
|
||||
]);
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality',
|
||||
'value' => $practitioner->speciality->name ?? null,
|
||||
]);
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality_image',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality_image',
|
||||
'value' => $practitioner->speciality->name ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
'type' => 'speciality',
|
||||
], [
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
'value' => $practitioner->meta->DokterID ?? null,
|
||||
'type' => 'speciality',
|
||||
'value' => (!empty($doctor['spesialisasi']['Nama']) && $doctor['spesialisasi']['Nama'] != '-') ? $doctor['spesialisasi']['Nama'] : null
|
||||
]);
|
||||
}
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
], [
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
'value' => $DokterID
|
||||
]);
|
||||
}
|
||||
|
||||
$hisOrganizationCode = $organization->meta->KodeRS ?? null;
|
||||
// Recursive
|
||||
if ($doctors['current_page'] < $doctors['last_page']) {
|
||||
try {
|
||||
$primayaApiService = new PrimayaApi($hisOrganizationCode);
|
||||
|
||||
$this->processDoctors($primayaApiService->doctors($doctors['current_page'] + 1), $mapSpecialities, $organization);
|
||||
} catch (Exception $e) {
|
||||
$this->command->info('Something Went Wrong :' . $hisOrganizationCode . ' - ' . $organization->name . ' - ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class SpecialitiesSeeder extends Seeder
|
||||
),
|
||||
array(
|
||||
'code' => '4',
|
||||
'name' => 'Anestesi',
|
||||
'name' => 'Anastesia',
|
||||
'image' => 'image/specialities/anestesi.png',
|
||||
),
|
||||
array(
|
||||
@@ -173,12 +173,12 @@ class SpecialitiesSeeder extends Seeder
|
||||
),
|
||||
array(
|
||||
'code' => '32',
|
||||
'name' => 'Psikolog',
|
||||
'name' => 'Psikologi',
|
||||
'image' => 'image/specialities/psikolog.png',
|
||||
),
|
||||
array(
|
||||
'code' => '33',
|
||||
'name' => 'Radiolog',
|
||||
'name' => 'Radiologi',
|
||||
'image' => 'image/specialities/radiolog.png',
|
||||
),
|
||||
array(
|
||||
@@ -221,7 +221,7 @@ class SpecialitiesSeeder extends Seeder
|
||||
// Speciality::truncate();
|
||||
|
||||
foreach ($specialities as $speciality) {
|
||||
$speciality['code'] = "SP".str_pad($speciality['code'], 4, 0, STR_PAD_LEFT);
|
||||
$speciality['code'] = "SP" . str_pad($speciality['code'], 4, 0, STR_PAD_LEFT);
|
||||
unset($speciality['image']);
|
||||
Speciality::updateOrCreate(
|
||||
[
|
||||
|
||||
16668
package-lock.json
generated
Normal file
16668
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user