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