Merge branch 'staging' of https://dev.sismedika.online/febio/aso into staging
This commit is contained in:
@@ -27,7 +27,7 @@ class HealthRecordController extends Controller
|
|||||||
// return $request->toArray();
|
// return $request->toArray();
|
||||||
$livechat = Livechat::query()
|
$livechat = Livechat::query()
|
||||||
->with([ 'user', 'doctor', 'doctor.user', 'doctor.user.detail', 'doctor.speciality', 'appointment', 'healthCare', 'summary']);
|
->with([ 'user', 'doctor', 'doctor.user', 'doctor.user.detail', 'doctor.speciality', 'appointment', 'healthCare', 'summary']);
|
||||||
|
|
||||||
if ($request->has('search')) {
|
if ($request->has('search')) {
|
||||||
$search = $request->search;
|
$search = $request->search;
|
||||||
$livechat->where(function ($query) use ($search) {
|
$livechat->where(function ($query) use ($search) {
|
||||||
@@ -41,13 +41,13 @@ class HealthRecordController extends Controller
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($request->has('livechat_start') || $request->has('livechat_end'))
|
if (($request->has('livechat_start') || $request->has('livechat_end'))
|
||||||
&& !empty($request->livechat_start)
|
&& !empty($request->livechat_start)
|
||||||
&& !empty($request->livechat_end)
|
&& !empty($request->livechat_end)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
$livechat = $livechat->where(function($q) use ($request) {
|
$livechat = $livechat->where(function($q) use ($request) {
|
||||||
$q->where('dCreateOn', '>=', $request->livechat_start)
|
$q->where('dCreateOn', '>=', $request->livechat_start)
|
||||||
->where('dCreateOn', '<=', $request->livechat_end);
|
->where('dCreateOn', '<=', $request->livechat_end);
|
||||||
@@ -124,36 +124,50 @@ class HealthRecordController extends Controller
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to determine if a string is serialized
|
// Function to determine if a string is serialized
|
||||||
private function is_serialized($string) {
|
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);
|
return ($string == 'b:0;' || @unserialize($string) !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to determine if a string is JSON
|
// Function to determine if a string is JSON
|
||||||
private function is_json($string) {
|
private function is_json($string) {
|
||||||
|
// Check if string is empty
|
||||||
|
if (empty($string)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Decode JSON and check for errors
|
||||||
json_decode($string);
|
json_decode($string);
|
||||||
return (json_last_error() == JSON_ERROR_NONE);
|
return (json_last_error() == JSON_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to safely process the plan
|
// Function to safely process the plan
|
||||||
private function processPlan($sPlan) {
|
private function processPlan($sPlan) {
|
||||||
|
// Check if the string is serialized
|
||||||
if ($this->is_serialized($sPlan)) {
|
if ($this->is_serialized($sPlan)) {
|
||||||
$unserializedPlan = @unserialize($sPlan);
|
$unserializedPlan = @unserialize($sPlan);
|
||||||
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
||||||
return $unserializedPlan;
|
return $unserializedPlan;
|
||||||
}
|
}
|
||||||
} elseif ($this->is_json($sPlan)) {
|
}
|
||||||
|
// Check if the string is JSON
|
||||||
|
elseif ($this->is_json($sPlan)) {
|
||||||
$jsonPlan = json_decode($sPlan, true);
|
$jsonPlan = json_decode($sPlan, true);
|
||||||
if (json_last_error() == JSON_ERROR_NONE) {
|
if (json_last_error() == JSON_ERROR_NONE) {
|
||||||
return $jsonPlan;
|
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){
|
public function generateExcel(Request $request){
|
||||||
Helper::setCustomPHPIniSettings();
|
Helper::setCustomPHPIniSettings();
|
||||||
|
|
||||||
$file_name = 'Data Report Riwayat Rekam Medis';
|
$file_name = 'Data Report Riwayat Rekam Medis';
|
||||||
// Membuat penulis entitas Spout
|
// Membuat penulis entitas Spout
|
||||||
$writer = WriterEntityFactory::createXLSXWriter();
|
$writer = WriterEntityFactory::createXLSXWriter();
|
||||||
@@ -177,7 +191,7 @@ class HealthRecordController extends Controller
|
|||||||
$writer->addRow($headerRow);
|
$writer->addRow($headerRow);
|
||||||
$livechats = Livechat::query()
|
$livechats = Livechat::query()
|
||||||
->with([ 'user', 'doctor', 'doctor.user', 'doctor.user.detail', 'doctor.speciality', 'appointment', 'healthCare', 'summary']);
|
->with([ 'user', 'doctor', 'doctor.user', 'doctor.user.detail', 'doctor.speciality', 'appointment', 'healthCare', 'summary']);
|
||||||
|
|
||||||
if ($request->has('search')) {
|
if ($request->has('search')) {
|
||||||
$search = $request->search;
|
$search = $request->search;
|
||||||
$livechats->where(function ($query) use ($search) {
|
$livechats->where(function ($query) use ($search) {
|
||||||
@@ -191,7 +205,7 @@ class HealthRecordController extends Controller
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($request->has('livechat_start') || $request->has('livechat_end'))
|
if (($request->has('livechat_start') || $request->has('livechat_end'))
|
||||||
&& !empty($request->livechat_start)
|
&& !empty($request->livechat_start)
|
||||||
&& !empty($request->livechat_end)
|
&& !empty($request->livechat_end)
|
||||||
@@ -201,7 +215,7 @@ class HealthRecordController extends Controller
|
|||||||
->where('dCreateOn', '<=', $request->livechat_end);
|
->where('dCreateOn', '<=', $request->livechat_end);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$livechats = $livechats->get();
|
$livechats = $livechats->get();
|
||||||
|
|
||||||
if ($livechats){
|
if ($livechats){
|
||||||
@@ -209,12 +223,24 @@ class HealthRecordController extends Controller
|
|||||||
$doctor_name = '-';
|
$doctor_name = '-';
|
||||||
if ($row->doctor && $row->doctor->user && $row->doctor->user->detail) {
|
if ($row->doctor && $row->doctor->user && $row->doctor->user->detail) {
|
||||||
$doctor_name = $row->doctor->user->detail->sTitlePrefix . ' ' . $row->doctor->user->fullname;
|
$doctor_name = $row->doctor->user->detail->sTitlePrefix . ' ' . $row->doctor->user->fullname;
|
||||||
}
|
}
|
||||||
$speciality = $row->doctor->speciality->sSpesialis ?? '-';
|
$speciality = $row->doctor->speciality->sSpesialis ?? '-';
|
||||||
// Process the plan
|
// Check if $row->summary and $row->summary->sPlan are set and not null
|
||||||
$plan = '-';
|
if (isset($row->summary) && isset($row->summary->sPlan)) {
|
||||||
if ($row->summary && $row->summary->sPlan) {
|
|
||||||
$plan = $this->processPlan($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 = [
|
$rowData = [
|
||||||
@@ -226,9 +252,10 @@ class HealthRecordController extends Controller
|
|||||||
$row->summary ? $row->summary->sSubjective : '-',
|
$row->summary ? $row->summary->sSubjective : '-',
|
||||||
$row->summary ? $row->summary->sObjective : '-',
|
$row->summary ? $row->summary->sObjective : '-',
|
||||||
$row->summary ? $row->summary->sAssessment : '-',
|
$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
|
// Create a row from the array and add it to the writer
|
||||||
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
||||||
$writer->addRow($rowEntity);
|
$writer->addRow($rowEntity);
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ class ReportPhrResource extends JsonResource
|
|||||||
if ($this->doctor && $this->doctor->user && $this->doctor->user->detail) {
|
if ($this->doctor && $this->doctor->user && $this->doctor->user->detail) {
|
||||||
$doctor_name = $this->doctor->user->detail->sTitlePrefix . ' ' . $this->doctor->user->fullname;
|
$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 = [
|
$data = [
|
||||||
'id' => $this->nID,
|
'id' => $this->nID,
|
||||||
'healthcare' => $this->healthCare ? $this->healthCare->sHealthCare : null,
|
'healthcare' => $this->healthCare ? $this->healthCare->sHealthCare : null,
|
||||||
@@ -30,9 +37,36 @@ class ReportPhrResource extends JsonResource
|
|||||||
'subject' => $this->summary ? $this->summary->sSubjective : null,
|
'subject' => $this->summary ? $this->summary->sSubjective : null,
|
||||||
'object' => $this->summary ? $this->summary->sObjective : null,
|
'object' => $this->summary ? $this->summary->sObjective : null,
|
||||||
'assessment' => $this->summary ? $this->summary->sAssessment : null,
|
'assessment' => $this->summary ? $this->summary->sAssessment : null,
|
||||||
'plan' => $this->summary ? unserialize($this->summary->sPlan) : null,
|
'plan' => $plan,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
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