Data Docter dan Hospital dnegan Filter di dashboard

This commit is contained in:
pajri
2022-12-16 15:57:40 +07:00
parent 1857653ce0
commit 0d6c2ab30b
20 changed files with 2680 additions and 80 deletions

View File

@@ -17,6 +17,7 @@ class OrganizationSeeder extends Seeder
*/
public function run()
{
$response = Http::get('https://app.primaya.id/temp/organizations');
foreach ($response->json()['organizations'] as $organization) {

View File

@@ -33,8 +33,6 @@ class PractitionerSeeder extends Seeder
// Meta::query()->where('metaable_type', PractitionerRole::class)->forceDelete();
// Address::query()->where('addressable_type', Person::class)->forceDelete();
$mapSpecialities = [
'Akupunktur' => 'SP027',
'Anak' => 'SP001',
@@ -125,7 +123,7 @@ class PractitionerSeeder extends Seeder
$findSpecialityId = Speciality::where('name', $mapping)->first()->id;
$newPerson = Person::updateOrCreate([
'nik' => $doctor['NIK']
'name' => $doctor['Nama'],
], [
'nik' => (!empty($doctor['NIK'])) ? $doctor['NIK'] : null,
'name' => $doctor['Nama'],
@@ -195,41 +193,83 @@ class PractitionerSeeder extends Seeder
// 'value' => $doctor['Description']
// ]);
$newPractitionerRole = PractitionerRole::updateOrCreate([
'practitioner_id' => $newPractitioner->id,
'organization_id' => $organization->id,
'speciality_id' => $findSpecialityId,
'active' => 1,
]);
$ownedDepartemenIDs = $newPractitioner->practitionerRoles->pluck('meta.DepartemenID');
$this->command->info('Doctor : ' . $DokterID . '-' . $doctor['Nama'] . ' (Spesialisasi : ' . $mapping . ')');
$DepartemenIDs = $doctor['departementIDs'];
foreach ($DepartemenIDs as $DepartemenID) {
$updatePractitionerRole = $newPractitioner->practitionerRoles->where('meta.DepartemenID', $DepartemenID)->first();
if (empty($newPractitionerRole->speciality_id)) {
$newPractitionerRole->metas()->updateOrCreate([
'type' => 'speciality_code',
], [
'system' => 'primaya-his',
'type' => 'speciality_code',
'value' => (!empty($doctor['KodeSpesialisasiID']) && $doctor['KodeSpesialisasiID'] != '-') ? $doctor['KodeSpesialisasiID'] : null
]);
$newPractitionerRole->metas()->updateOrCreate([
'type' => 'speciality',
], [
'system' => 'primaya-his',
'type' => 'speciality',
'value' => (!empty($doctor['spesialisasi']['Nama']) && $doctor['spesialisasi']['Nama'] != '-') ? $doctor['spesialisasi']['Nama'] : null
]);
if (empty($updatePractitionerRole)) {
$updatePractitionerRole = $newPractitioner->practitionerRoles->where('meta.DokterID', $DokterID)->first();
if (!empty($updatePractitionerRole->meta->DepartemenID) && $updatePractitionerRole->meta->DepartemenID != $DepartemenID) {
$updatePractitionerRole = null;
}
}
if (
isset($updatePractitionerRole)
) {
$updatePractitionerRole->metas()->updateOrCreate([
'type' => 'DepartemenID',
], [
'type' => 'DepartemenID',
'system' => 'his',
'value' => $DepartemenID
]);
$newPractitioner->load('practitionerRoles');
$this->command->info('Updating Practitioner Role : ' . $updatePractitionerRole->id . '-' . $DokterID . '-' . $doctor['Nama'] . '-' . $DepartemenID);
} else {
$newPractitionerRole = PractitionerRole::Create([
'practitioner_id' => $newPractitioner->id,
'organization_id' => $organization->id,
'speciality_id' => $findSpecialityId,
'active' => 1,
]);
if (empty($newPractitionerRole->speciality_id)) {
$newPractitionerRole->metas()->updateOrCreate([
'type' => 'speciality_code',
], [
'system' => 'primaya-his',
'type' => 'speciality_code',
'value' => (!empty($doctor['KodeSpesialisasiID']) && $doctor['KodeSpesialisasiID'] != '-') ? $doctor['KodeSpesialisasiID'] : null
]);
$newPractitionerRole->metas()->updateOrCreate([
'type' => 'speciality',
], [
'system' => 'primaya-his',
'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
]);
$newPractitionerRole->metas()->updateOrCreate([
'type' => 'primaya-his',
'type' => 'DepartemenID',
], [
'system' => 'primaya-his',
'type' => 'DepartemenID',
'value' => $DepartemenID
]);
$this->command->info('Creating Practitioner Role : ' . $newPractitionerRole->id . '-' . $DokterID . '-' . $doctor['Nama'] . '-' . $DepartemenID);
}
}
$newPractitionerRole->metas()->updateOrCreate([
'type' => 'primaya-his',
'type' => 'DokterID',
], [
'system' => 'primaya-his',
'type' => 'DokterID',
'value' => $DokterID
]);
}
$hisOrganizationCode = $organization->meta->KodeRS ?? null;