update
This commit is contained in:
72
Modules/Internal/Transformers/ReportPhrResource.php
Executable file
72
Modules/Internal/Transformers/ReportPhrResource.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReportPhrResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$doctor_name = null;
|
||||
|
||||
if ($this->doctor && $this->doctor->user && $this->doctor->user->detail) {
|
||||
$doctor_name = $this->doctor->user->detail->sTitlePrefix . ' ' . $this->doctor->user->fullname;
|
||||
}
|
||||
|
||||
// Process the plan
|
||||
$plan = [];
|
||||
if ($this->summary && $this->summary->sPlan) {
|
||||
$plan = $this->processPlan($this->summary->sPlan);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'id' => $this->nID,
|
||||
'healthcare' => $this->healthCare ? $this->healthCare->sHealthCare : null,
|
||||
'patient_name' => $this->user ? $this->user->sFirstName : null,
|
||||
'doctor_name' => $doctor_name,
|
||||
'specialis' => $this->doctor ? $this->doctor->speciality->sSpesialis : null,
|
||||
'date_consultation' => $this->summary ? Carbon::parse($this->dCreateOn)->format('Y-m-d H:i:s') : null ,
|
||||
'subject' => $this->summary ? $this->summary->sSubjective : null,
|
||||
'object' => $this->summary ? $this->summary->sObjective : null,
|
||||
'assessment' => $this->summary ? $this->summary->sAssessment : null,
|
||||
'plan' => $plan,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Function to determine if a string is serialized
|
||||
private function is_serialized($string) {
|
||||
return ($string == 'b:0;' || @unserialize($string) !== false);
|
||||
}
|
||||
|
||||
// Function to determine if a string is JSON
|
||||
private function is_json($string) {
|
||||
json_decode($string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
// Function to safely process the plan
|
||||
private function processPlan($sPlan) {
|
||||
if ($this->is_serialized($sPlan)) {
|
||||
$unserializedPlan = @unserialize($sPlan);
|
||||
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
||||
return $unserializedPlan;
|
||||
}
|
||||
} elseif ($this->is_json($sPlan)) {
|
||||
$jsonPlan = json_decode($sPlan, true);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
return $jsonPlan;
|
||||
}
|
||||
}
|
||||
return $sPlan; // Treat as plain text if not serialized or JSON
|
||||
}
|
||||
}
|
||||
32
Modules/Internal/Transformers/ReportPrescriptionResource.php
Normal file
32
Modules/Internal/Transformers/ReportPrescriptionResource.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReportPrescriptionResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$patientName = $this->user ? $this->user->sFirstName .' '. $this->user->sLastName : '-';
|
||||
|
||||
$data = [
|
||||
'id' => $this->nID,
|
||||
'patient_name' => $patientName,
|
||||
'livechat' => $this->livechat,
|
||||
'prescription_code' => $this->sKodeResep,
|
||||
'date_consultation' => $this->dTanggalResep ? Carbon::parse($this->dTanggalResep)->format('Y-m-d H:i:s') : null,
|
||||
'doctor_name' => $this->sDokterName ? $this->sDokterName : '-',
|
||||
'items' => $this->items ? $this->items : [],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
46
Modules/Internal/Transformers/ReportRujukanResource.php
Normal file
46
Modules/Internal/Transformers/ReportRujukanResource.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReportRujukanResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$doctor_name = null;
|
||||
|
||||
if ($this->livechat->doctor && $this->livechat->doctor->user && $this->livechat->doctor->user->detail) {
|
||||
$doctor_name = $this->livechat->doctor->user->detail->sTitlePrefix . ' ' . $this->livechat->doctor->user->fullname;
|
||||
}
|
||||
|
||||
$diagnosis = null;
|
||||
$plan = null;
|
||||
|
||||
if ($this->livechat->summary){
|
||||
$diagnosis = $this->livechat->summary->sAssessment;
|
||||
$plan = $this->livechat->summary->sPlan ? unserialize($this->livechat->summary->sPlan) : $this->livechat->summary->sPlan;
|
||||
}
|
||||
// dd($this->livechat->summary);
|
||||
$data = [
|
||||
'id' => $this->nID,
|
||||
'no_rujukan' => $this->sNoRujukan ? $this->sNoRujukan : null,
|
||||
'patient_name' => $this->livechat ? $this->livechat->user->sFirstName : null,
|
||||
'healthcare' => $this->healthcare ? $this->healthcare->sHealthCare : null,
|
||||
'doctor_name' => $doctor_name,
|
||||
'departement' => $this->sDepartement ? $this->sDepartement : null,
|
||||
'date_rujukan' => $this->dCreatedOn ? Carbon::parse($this->dCreateOn)->format('Y-m-d H:i:s') : null ,
|
||||
'diagnosa' => $diagnosis,
|
||||
'plan' => $plan,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use App\Models\CorporateService;
|
||||
use App\Models\RequestLogBenefit;
|
||||
use App\Models\RequestLogMedicine;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Benefit;
|
||||
use App\Models\Exclusion;
|
||||
use App\Models\ClaimRequest;
|
||||
use App\Models\Icd;
|
||||
@@ -33,7 +34,7 @@ class RequestLogShowResource extends JsonResource
|
||||
$planMember = MemberPlan::where('member_id', $member_id)->get('plan_id');
|
||||
|
||||
$planId = Plan::whereIn('id', $planMember)->where('service_code', $requestLog['service_code'])->first();
|
||||
$benefit = CorporateBenefit::with('benefit')->where('plan_id', $planId->id)->get()->toArray();
|
||||
$benefit = CorporateBenefit::with(['benefit', 'plan'])->where('plan_id', $planId->id)->get()->toArray();
|
||||
$benefitDetailLog = RequestLogBenefit::with('benefit')->where('request_log_id', $requestLog['id'])->get()->toArray();
|
||||
$medicineDetailLog = RequestLogMedicine::where('request_log_id', $requestLog['id'])->get()->toArray();
|
||||
$provider = Organization::where('id', $requestLog['organization_id'])->first();
|
||||
@@ -61,14 +62,19 @@ class RequestLogShowResource extends JsonResource
|
||||
$providerName = '-';
|
||||
}
|
||||
|
||||
// Benefit Data
|
||||
$benefitData = [];
|
||||
|
||||
if (count($benefit)){
|
||||
foreach($benefit as $data){
|
||||
$data['benefit']['plan_id'] = $data['plan_id'];
|
||||
$data['benefit']['limit_amount'] = $data['limit_amount'];
|
||||
$data['benefit']['family_plan'] = $planId->family_plan;
|
||||
$data['benefit']['max_frequency_period'] = $data['max_frequency_period'];
|
||||
$data['benefit']['limit_amount_plan'] = $data['plan']['limit_rules'];
|
||||
$data['benefit']['family_plan_plans'] = $data['plan']['family_plan'];
|
||||
array_push($benefitData, $data['benefit']);
|
||||
}
|
||||
}
|
||||
|
||||
// Medicine
|
||||
$medicineData = [];
|
||||
if (count($medicineDetailLog)){
|
||||
@@ -106,10 +112,12 @@ class RequestLogShowResource extends JsonResource
|
||||
$diagnosis = explode(',', $requestLog['diagnosis']);
|
||||
$icd = Icd::query()
|
||||
->whereIn('code', $diagnosis)
|
||||
->select('code', 'name')
|
||||
->select('code as value', 'name as label')
|
||||
->get();
|
||||
}
|
||||
$memberUsage = Helper::getUsageMember($corporateId, $requestLog['member']['id'], $benefitData);
|
||||
|
||||
// dd($memberLimitUsage);
|
||||
$data = [
|
||||
'id' => $requestLog['id'],
|
||||
'code' => $requestLog['code'],
|
||||
@@ -125,6 +133,7 @@ class RequestLogShowResource extends JsonResource
|
||||
'gender' => $requestLog['member']['gender'],
|
||||
'marital_status' => $requestLog['member']['status_marital'],
|
||||
'member_type' => Helper::memberType($requestLog['member']['record_type']),
|
||||
'member_usage_benefit' => json_decode($memberUsage),
|
||||
'principal_id' => $requestLog['member']['principal_id'] ? $requestLog['member']['principal_id'] : '-',
|
||||
'principal_name' => $requestLog['member']['principal_id'] ? Helper::principalName($requestLog['member']['principal_id']) : '-',
|
||||
'relation_with_principal' => Helper::relationWithPrincipal($requestLog['member']['relation_with_principal']),
|
||||
@@ -151,6 +160,7 @@ class RequestLogShowResource extends JsonResource
|
||||
'reason' => $requestLog['reason'],
|
||||
'diagnosis' => $icd,
|
||||
'is_reversal' => $isReversal, // untuk penjagaan, jika true tidak bisa di edit/hapus lagi
|
||||
|
||||
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user