Merge branch 'staging' of https://dev.sismedika.online/febio/aso into staging
This commit is contained in:
@@ -124,31 +124,45 @@ class HealthRecordController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
// Function to determine if a string is serialized
|
||||
private function is_serialized($string) {
|
||||
// Function to determine if a string is serialized
|
||||
private function is_serialized($string) {
|
||||
// Check if string is empty
|
||||
if (empty($string)) {
|
||||
return false;
|
||||
}
|
||||
// Check for common serialized string patterns
|
||||
return ($string == 'b:0;' || @unserialize($string) !== false);
|
||||
}
|
||||
|
||||
// Function to determine if a string is JSON
|
||||
private function is_json($string) {
|
||||
// Check if string is empty
|
||||
if (empty($string)) {
|
||||
return false;
|
||||
}
|
||||
// Decode JSON and check for errors
|
||||
json_decode($string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
// Function to safely process the plan
|
||||
private function processPlan($sPlan) {
|
||||
// Check if the string is serialized
|
||||
if ($this->is_serialized($sPlan)) {
|
||||
$unserializedPlan = @unserialize($sPlan);
|
||||
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
||||
return $unserializedPlan;
|
||||
}
|
||||
} elseif ($this->is_json($sPlan)) {
|
||||
}
|
||||
// Check if the string is JSON
|
||||
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
|
||||
// Treat as plain text if not serialized or JSON
|
||||
return $sPlan;
|
||||
}
|
||||
|
||||
public function generateExcel(Request $request){
|
||||
@@ -211,10 +225,22 @@ class HealthRecordController extends Controller
|
||||
$doctor_name = $row->doctor->user->detail->sTitlePrefix . ' ' . $row->doctor->user->fullname;
|
||||
}
|
||||
$speciality = $row->doctor->speciality->sSpesialis ?? '-';
|
||||
// Process the plan
|
||||
$plan = '-';
|
||||
if ($row->summary && $row->summary->sPlan) {
|
||||
// Check if $row->summary and $row->summary->sPlan are set and not null
|
||||
if (isset($row->summary) && isset($row->summary->sPlan)) {
|
||||
$plan = $this->processPlan($row->summary->sPlan);
|
||||
|
||||
if (is_array($plan)) {
|
||||
// Mengubah array menjadi string dengan format yang diinginkan
|
||||
$plans = implode(', ', array_map(function($item) {
|
||||
return !empty($item['note']) ? $item['note'] : '-';
|
||||
}, $plan));
|
||||
} else {
|
||||
// Jika $plan bukan array, set $plans menjadi tanda '-'
|
||||
$plans = '-';
|
||||
}
|
||||
} else {
|
||||
// If $row->summary or $row->summary->sPlan are not set, set $plans to '-'
|
||||
$plans = '-';
|
||||
}
|
||||
|
||||
$rowData = [
|
||||
@@ -226,7 +252,8 @@ class HealthRecordController extends Controller
|
||||
$row->summary ? $row->summary->sSubjective : '-',
|
||||
$row->summary ? $row->summary->sObjective : '-',
|
||||
$row->summary ? $row->summary->sAssessment : '-',
|
||||
is_array($plan) ? implode(', ', $plan) : $plan, // Handle arrays from unserialized or JSON data
|
||||
// is_array($plan) ? implode(', ', $plan[0]) : $plan, // Handle arrays from unserialized or JSON data
|
||||
$row->summary ? $plans : '-',
|
||||
];
|
||||
|
||||
// Create a row from the array and add it to the writer
|
||||
|
||||
@@ -20,6 +20,13 @@ class ReportPhrResource extends JsonResource
|
||||
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,
|
||||
@@ -30,9 +37,36 @@ class ReportPhrResource extends JsonResource
|
||||
'subject' => $this->summary ? $this->summary->sSubjective : null,
|
||||
'object' => $this->summary ? $this->summary->sObjective : null,
|
||||
'assessment' => $this->summary ? $this->summary->sAssessment : null,
|
||||
'plan' => $this->summary ? unserialize($this->summary->sPlan) : 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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user