update autocomplite

This commit is contained in:
2024-05-17 15:40:27 +07:00
parent ba55866203
commit 664f015c94
2 changed files with 52 additions and 0 deletions

View File

@@ -3,6 +3,9 @@
namespace Modules\Linksehat\Http\Controllers\Api;
use App\Helpers\Helper;
use App\Models\OLDLMS\User;
use App\Models\Icd;
use App\Models\Drug;
use App\Models\Unit;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
@@ -93,5 +96,51 @@ class AutocompleteController extends Controller {
}
return Helper::responseJson($data);
}
public function diagnosis(){
$icds = Icd::query()
->get();
$manipulatedIcds = $icds->map(function ($icd) {
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
return [
'value' => $icd->code, // Ganti dengan properti yang sesuai dari model Icd
'label' => $icd->code . ' - ' .$icd->name, // Ganti dengan properti yang sesuai dari model Icd
];
});
return Helper::responseJson(data: $manipulatedIcds);
}
public function drugList(Request $request){
$drugs = Drug::query()
->where([
'atc_code' => 'lms', // ini untuk menggunakan list obat yang baru
])
->get();
$manipulatedDrugs = $drugs->map(function ($drug) {
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
return [
'value' => $drug->id, // Ganti dengan properti yang sesuai dari model Icd
'label' => $drug->name, // Ganti dengan properti yang sesuai dari model Icd
];
});
return Helper::responseJson(data: $manipulatedDrugs);
}
public function unitList(Request $request){
$units = Unit::query()
->get();
$manipulatedUnits = $units->map(function ($unit) {
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
return [
'value' => $unit->id, // Ganti dengan properti yang sesuai dari model Icd
'label' => $unit->name, // Ganti dengan properti yang sesuai dari model Icd
];
});
return Helper::responseJson(data: $manipulatedUnits);
}
}