[WIP] Encounter

This commit is contained in:
R
2023-03-16 14:27:53 +07:00
parent f65b28107c
commit 229908e492
15 changed files with 433 additions and 10 deletions

View File

@@ -3,6 +3,8 @@
namespace Modules\Internal\Http\Controllers\Api;
use App\Models\Icd;
use App\Models\Organization;
use App\Models\Practitioner;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
@@ -30,6 +32,35 @@ class OptionController extends Controller
return $icds;
break;
case 'doctors':
$doctors = Practitioner::query()
->whereHas('person', function ($person) use ($request) {
$person->where('name', 'LIKE', '%'.$request->search.'%');
})
->limit('10')
->get();
$doctors = $doctors->map(function($doctor) {
$doctorDetail = $doctor->person->toArray();
unset($doctorDetail['id']);
return array_merge([
'id' => $doctor->id,
'code' => $doctor->code
], $doctorDetail);
});
return $doctors;
break;
case 'healthcares':
$healthcares = Organization::query()
->hospital()
->where('name', 'LIKE', '%'.$request->search.'%')
->limit('10')
->get();
return $healthcares;
break;
default:
# code...