api detail appointment

This commit is contained in:
Muhammad Fajar
2022-11-08 09:31:09 +07:00
parent d742e87285
commit f0bf98b153
2 changed files with 17 additions and 5 deletions

View File

@@ -70,9 +70,7 @@ class AppointmentController extends Controller
{
$appointment = Appointment::query()->with(['appointmentParticipants', 'organization'])->find($id);
return new AppointmentDetailResource($appointment);
return response()->json($appointment);
return Helper::responseJson(new AppointmentDetailResource($appointment));
}
/**

View File

@@ -2,6 +2,7 @@
namespace Modules\Linksehat\Transformers\Appointment;
use App\Helpers\Helper;
use App\Models\Person;
use App\Models\PractitionerRole;
use Carbon\Carbon;
@@ -25,7 +26,8 @@ class AppointmentDetailResource extends JsonResource
}
}
$queryPatient = Person::query()->find($patiendId);
$queryPatient = Person::query()
->find($patiendId);
$patient = [
'id' => $queryPatient->id,
@@ -34,7 +36,18 @@ class AppointmentDetailResource extends JsonResource
'phone' => $queryPatient->phone,
];
$queryDoctor = PractitionerRole::query()->with(['practitioner.person', 'speciality'])->where('practitioner_id', $doctorId)->first();
$queryDoctor = PractitionerRole::query()
->with(['practitioner.person', 'speciality', 'practices.prices'])
->where('practitioner_id', $doctorId)
->first();
foreach ($queryDoctor->practices as $qPractice) {
foreach ($qPractice->prices as $qPrice) {
if (strtolower($qPractice->service_code) == strtolower($this->appointment_type)) {
$price = $qPrice->price_net;
}
}
}
$doctor = [
'id' => $doctorId,
@@ -54,6 +67,7 @@ class AppointmentDetailResource extends JsonResource
'address' => $this->organization->currentAddress->text,
],
'patient' => $patient,
'price' => Helper::currencyIdrFormat($price)
];
}
}