45 lines
1.7 KiB
PHP
45 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Resources\ArchiveHistoryResource;
|
|
use App\Http\Resources\ArchiveInfoResource;
|
|
use App\Http\Resources\PatientInfoResource;
|
|
use App\Models\SI\SttMedicalHistory as SiSttMedicalHistory;
|
|
use App\Models\Mis\SttMedicalHistory as MisSttMedicalHistory;
|
|
use App\Repositories\MedicalHistoryRepository;
|
|
use Illuminate\Http\Request;
|
|
|
|
class MedicalHistoryController extends Controller
|
|
{
|
|
public function patient($id, Request $request)
|
|
{
|
|
$viewType = $request->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);
|
|
}
|
|
}
|