Add Additional Information

This commit is contained in:
R
2023-02-15 09:57:00 +07:00
parent 7f77deb09e
commit d8f493103c
6 changed files with 65 additions and 16 deletions

View File

@@ -18,7 +18,7 @@ class AppointmentController extends Controller
public function index()
{
$appointments = Appointment::query()
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare')
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare', 'user')
->latest()
->paginate(15);
return response()->json(Helper::paginateResources(AppointmentResource::collection($appointments)));

View File

@@ -17,7 +17,8 @@ class AppointmentResource extends JsonResource
{
$appointment = [
'id' => $this->nID,
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null,
'patient_name' => $this->user ? $this->user->full_name : '',
'doctor_name' => $this->doctor ? $this->doctor->user?->full_name : '',
'speciality' => $this->doctor->speciality->sKeterangan,
'date_appointment' => Carbon::parse($this->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $this->appointmentDetail->tTimeAppointment,
'date_created' => Carbon::parse($this->dCreateOn)->format('d-m-Y H:i:s') ?? null,
@@ -25,6 +26,12 @@ class AppointmentResource extends JsonResource
'status' => $this->status_name,
'health_care' => $this->healthCare->sHealthCare ?? null,
'payment_method' => $this->payment_method ?? null,
'patient' => $this->user,
'booking_code' => $this->sBookingCode,
'his_detail' => [
'RegID' => $this->sRegID,
'Medrec' => $this->sNomorRekamMedis
]
];
$payment_detail = null;

View File

@@ -50,15 +50,13 @@ class Appointment extends Model
'dUpdateOn',
'dDeleteOn',
];
protected $appends = [
'status_name',
'payment_method'
];
protected function StatusName(): Attribute
protected function statusName(): Attribute
{
return Attribute::make(
get: function ($value) {
@@ -67,7 +65,7 @@ class Appointment extends Model
);
}
protected function PaymentMethod(): Attribute
protected function paymentMethod(): Attribute
{
return Attribute::make(
get: function ($value) {

View File

@@ -31,7 +31,7 @@ class Livechat extends Model
'status_name',
];
protected function StatusName(): Attribute
protected function statusName(): Attribute
{
return Attribute::make(
get: function ($value) {

View File

@@ -2,6 +2,7 @@
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -17,4 +18,25 @@ class User extends Model
protected $connection = 'oldlms';
protected $table = 'tm_users';
protected $appends = [
'full_name',
];
protected function fullName(): Attribute
{
return Attribute::make(
get: function ($value) {
$names = [];
if (!empty($this->sFirstName)) {
array_push($names, $this->sFirstName);
}
if (!empty($this->sLastName)) {
array_push($names, $this->sLastName);
}
return implode(' ', $names);
}
);
}
}

View File

@@ -178,13 +178,17 @@ export default function List() {
return (
<React.Fragment>
<TableRow>
<TableCell />
<TableCell>
<IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
</IconButton>
</TableCell>
<TableCell align="left">{row.date_created ? row.date_created : '-'}</TableCell>
<TableCell align="left">{row.date_appointment ? row.date_appointment : '-'}</TableCell>
<TableCell align="left">{row.booking_code ?? '-'}</TableCell>
<TableCell align="left">{row.patient_name ? row.patient_name : '-'}</TableCell>
<TableCell align="left">{row.health_care ? row.health_care : '-'}</TableCell>
<TableCell align="left">{row.doctor_name ? row.doctor_name : '-'}</TableCell>
<TableCell align="left">{row.speciality ? row.speciality : '-'}</TableCell>
<TableCell align="left">{row.appointment_media ? row.appointment_media : '-'}</TableCell>
<TableCell align="left">{row.status ? row.status : '-'}</TableCell>
<TableCell align="center">
@@ -197,6 +201,21 @@ export default function List() {
</ButtonGroup>
</TableCell>
</TableRow>
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={15}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Stack>
<Grid container>
<Grid item xs={2}>Spesialisasi</Grid><Grid item xs="10">: {row.speciality}</Grid>
<Grid item xs={2}>Via</Grid><Grid item xs="10">: {row.appointment_media}</Grid>
<Grid item xs={2}>Metode Pembayaran</Grid><Grid item xs="10">: {row.payment_method}</Grid>
<Grid item xs={2}>HIS RegID</Grid><Grid item xs="10">: {row.his_detail?.sRegID}</Grid>
<Grid item xs={2}>HIS Medrec</Grid><Grid item xs="10">: {row.his_detail?.Medrec}</Grid>
</Grid>
</Stack>
</Collapse>
</TableCell>
</TableRow>
<Dialog
open={openDialog}
@@ -329,19 +348,22 @@ export default function List() {
<TableRow>
<TableCell style={headStyle} align="left" />
<TableCell style={headStyle} align="left">
Tanggal Booking
Tanggal Pemesanan
</TableCell>
<TableCell style={headStyle} align="left">
Tanggal Appointment
</TableCell>
<TableCell style={headStyle} align="left">
Kode Booking
</TableCell>
<TableCell style={headStyle} align="left">
Pasien
</TableCell>
<TableCell style={headStyle} align="left">
Faskes
</TableCell>
<TableCell style={headStyle} align="left">
Nama Dokter
</TableCell>
<TableCell style={headStyle} align="left">
Spesialisasi
Dokter
</TableCell>
<TableCell style={headStyle} align="left">
Appointment Via App/Website