get('view_type', 'si'); $patientId = $request->get('patient_id'); $patientInfo = null; if ($viewType == 'si') $patient = SiSttMedicalHistory::where('id', $id)->first(); else $patient = MisSttMedicalHistory::where('MedicalHistoryID', $id)->first(); $archiveJournal = $patient->archiveHistory ? ArchiveHistoryResource::collection($patient->archiveHistory) : null; if (!empty($patient->archiveInfo)) { $archiveInfo = ArchiveInfoResource::make($patient->archiveInfo)->toArray(request()); } else { $archiveInfo = null; } $patientInfo = [ 'historyable_type' => $viewType == 'si' ? SiSttMedicalHistory::class : MisSttMedicalHistory::class, 'info' => [ 'historyable_type' => $viewType == 'si' ? SiSttMedicalHistory::class : MisSttMedicalHistory::class, ...PatientInfoResource::make($patient)->toArray(request()), 'can_be_issued' => $patient->canBeIssued() ], 'journal' => $archiveJournal, 'archiveInfo' => $archiveInfo ]; return response()->json($patientInfo); } }