table('tm_status_pernikahan')->get()->toArray(); $data = []; if ($maritalStatus){ $temp = []; foreach($maritalStatus as $d){ $temp['id'] = $d->nID; $temp['value'] = $d->sStatusPernikahan; array_push($data, $temp); } } return Helper::responseJson($data); } public function bloodType() { $bloodType = DB::connection('oldlms')->table('tm_golongan_darah')->get()->toArray(); $data = []; if ($bloodType){ $temp = []; foreach($bloodType as $d){ $temp['id'] = $d->nID; $temp['value'] = $d->sGolonganDarah; array_push($data, $temp); } } return Helper::responseJson($data); } public function relationship() { $relation = DB::connection('oldlms')->table('tm_hubungan_keluarga')->get()->toArray(); $data = []; if ($relation){ $temp = []; foreach($relation as $d){ $temp['id'] = $d->nID; $temp['value'] = $d->sHubunganKeluarga; array_push($data, $temp); } } return Helper::responseJson($data); } public function corporate(Request $request) { $search = $request->search; $corporate = DB::table('corporates') ->where('active', 1) ->where(function ($query) use ($search) { $query->where('name', 'like', "%$search%") ->orWhere('code', 'like', "%$search%"); }) ->get() ->toArray(); $data['company'] = []; if ($corporate){ $temp = []; foreach($corporate as $d){ $temp['id'] = $d->id; $temp['name'] = $d->name; $temp['linking_rule'] = json_decode($d->linking_rules); array_push($data['company'], $temp); } } 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' => $request->provider, // 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, 'label' => $drug->name, 'code' => $drug->code, 'price' => $drug->price, 'unit' => $drug->unit, ]; }); 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); } public function signaList(Request $request){ $signa = DB::connection('oldlms')->table('tm_signa')->get()->toArray(); $data = []; if ($signa){ $temp = []; foreach($signa as $d){ $temp['id'] = $d->nID; $temp['value'] = $d->signa; $temp['label'] = $d->signa; array_push($data, $temp); } } return Helper::responseJson($data); } public function signaAdd(Request $request){ $validatedData = $request->validate([ 'signa' => 'required|string|max:255', ]); // Insert the new signa into the tm_signa table DB::connection('oldlms')->table('tm_signa')->insert([ 'sStatusPernikahan' => $validatedData['signa'] ]); // Return a success response return Helper::responseJson(['message' => 'Signa added successfully']); } public function serviceCode(Request $request, $id) { $plans = MemberPlan::with('plan', 'plan.service') ->where('member_id', $id) ->get(); $manipulatedPlan = $plans->map(function ($plan) { return [ 'value' => optional($plan->plan)->service_code ?? '-', 'label' => optional($plan->plan->service)->name ?? 'Unknown' ]; }); return response()->json($manipulatedPlan); } }