report excel
This commit is contained in:
@@ -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