[Client Portal] Penyesuaian get data alarm center

This commit is contained in:
Linksehat Staging Server
2024-01-13 18:19:12 +07:00
parent 30cfcce4af
commit 0bda72da48
4 changed files with 92 additions and 13 deletions

View File

@@ -3,6 +3,7 @@
namespace Modules\Client\Transformers\AlarmCenter;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Models\Service;
class DataListClaimMemberResource extends JsonResource
{
@@ -14,13 +15,27 @@ class DataListClaimMemberResource extends JsonResource
*/
public function toArray($request)
{
$serviceData = Service::where('code', $this->service_code)->first();
if ($serviceData) {
$serviceName = $serviceData->name;
} else {
$serviceName = $this->service_cod;
}
if ($this->status == 'approved' && $this->status_final_log ){
$status = 'Done';
} else if ($this->status == 'declined' || $this->status_final_log == 'declined') {
$status = 'Declined';
} else {
$status = 'Ongoing';
}
return [
'id' => $this->id,
'admission_date' => $this->submission_date ?? null,
'discharge_date' => $this->discharge_date ?? null,
'code' => $this->code ?? null,
'service_type' => $this->service_code == 'IP' ? 'Inpatient' : 'Outpatient',
'status' => $this->status === 'requested' || ($this->status === 'approved' && $this->status_final_log) || ($this->status_final_log === 'requested' && $this->status === 'requested') ? 'Ongoing' : ($this->status === 'approved' && $this->status_final_log === 'approved' ? 'Approved' : 'Declined')
'service_type' => $serviceName,
'status' => $status,
];
}
}