fixing add prescription

This commit is contained in:
2024-04-30 17:03:44 +07:00
parent f3064d306c
commit 9168af67b6
15 changed files with 294 additions and 62 deletions

View File

@@ -5,6 +5,8 @@ namespace Modules\Internal\Transformers;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Helpers\Helper;
use App\Models\Prescription;
use App\Models\PrescriptionItem;
class LivechatResource extends JsonResource
{
@@ -16,6 +18,12 @@ class LivechatResource extends JsonResource
*/
public function toArray($request)
{
$prescription = Prescription::where('livechat_id', $this->nID)->first();
$diagnosis = $prescription ? $prescription->icd_code : '';
$hospital = $prescription ? $prescription->organization_id : '';
$prescriptionItem = $prescription ? PrescriptionItem::where('prescription_id', $prescription->id)->get() : [];
$livechat = [
'id' => $this->nID,
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->detail->sTitlePrefix . '. ' . $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName . ' ' . $this->doctor->user->detail->sTitleSuffix : null,
@@ -36,6 +44,9 @@ class LivechatResource extends JsonResource
'appointment_media' => $this->appointment->sMedia ?? null,
'status_chat' => $this->status_name ?? null,
'payment_method' => $this->appointment->payment_method ?? null,
'diagnosis' => $diagnosis,
'hospital' => $hospital,
'medicine' => $prescriptionItem
];
$start_time = $this->dStartTime;