Skip to content

Commit

Permalink
pusing cuyy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrian17 committed Dec 24, 2022
1 parent f981637 commit aca04d4
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 39 deletions.
92 changes: 69 additions & 23 deletions app/Http/Controllers/DiagnosaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
use App\Http\Requests\StoreDiagnosaRequest;
use App\Http\Requests\UpdateDiagnosaRequest;
use App\Models\Gejala;
use App\Models\Keputusan;
use App\Models\KondisiUser;
use App\Models\TingkatDepresi;
use Illuminate\Support\Arr;

class DiagnosaController extends Controller
{
Expand All @@ -21,19 +24,6 @@ public function index()
'gejala' => Gejala::all(),
'kondisi_user' => KondisiUser::all()
];
// dd($data);

// $dataDummy = [
// "G001" => "0.6",
// "G002" => "0",
// "G003" => "0.4",
// "G004" => "0",
// ];
// // dd($dataDummy);
// foreach ($dataDummy as $key => $val) {
// echo "<p>key : " . $key . "| val :" . $val . "</p>";
// echo "<br>";
// }

return view('clients.form_diagnosa', $data);
}
Expand All @@ -56,18 +46,74 @@ public function create()
*/
public function store(StoreDiagnosaRequest $request)
{
dd($request->all());
// dd($request->post('kondisi'));
$kondisi = $request->post('kondisi');
$kodeGejala = [];
foreach ($kondisi as $key => $item) {
echo "key : " . $key . " item : " . $item;
echo "<br>";
if ($item != "-") {
array_push($kodeGejala, $key);
}
}
// dd($kodeGejala);
$keputusan = new Keputusan();
$rule = Keputusan::whereIn('kode_gejala', $kodeGejala)->get();
$depresi = TingkatDepresi::all();

$cfTotalTemp = 0;
$cf = 0;
$cfLama = 0;
$cfArr = [];
// var_dump($kodeGejala);
// penyakit
$arrGejala = [];
foreach ($depresi as $key) {
$cfArr = [];
$res = 0;
// dd($key->kode_depresi);
// $ruleSetiapDepresi = Keputusan::whereIn('kode_gejala', $kodeGejala)->where('kode_depresi', 'P001')->orderBy('kode_gejala', 'ASC')->get();
$ruleSetiapDepresi = Keputusan::whereIn('kode_gejala', $kodeGejala)->where('kode_depresi', 'P003')->orderBy('kode_gejala', 'ASC')->get();
// dd($ruleSetiapDepresi);
foreach ($ruleSetiapDepresi as $ruleKey) {
// dd($ruleKey);
// setiap penyakit
$cf = $ruleKey->mb - $ruleKey->md;
array_push($cfArr, $cf);
}
$res = $this->getGabunganCf($cfArr);
// if ($key->kode_depresi == "P002") {
dd($cfArr);
// dd($res);
// }
// print_r($cfArr);
// echo "<br>";
dd($res);
array_push($arrGejala, $res);
}
}










public function getGabunganCf($cfArr)
{
echo "<br>----------- <br>";
if (count($cfArr) == 1) {
return $cfArr;
}
print_r($cfArr);
$cfoldGabungan = $cfArr[0];
// $cfoldGabungan = 0;
// print_r(count($cfArr));
echo "<br> awal : " . $cfoldGabungan . "<br>";

for ($i = 0; $i < count($cfArr) - 1; $i++) {
$cfoldGabungan = $cfoldGabungan + $cfArr[$i + 1] * (1 - $cfArr[$i]);
echo "<br> index : " . $i . "<br>";
echo $cfoldGabungan;
echo "<br>";
}
echo "return : " . $cfoldGabungan;
return $cfoldGabungan;
}


/**
Expand Down
25 changes: 10 additions & 15 deletions app/Models/Keputusan.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public function fillTable()
'mb' => 0.8,
'md' => 0.2
],
[
'kode_depresi' => 'P001',
'kode_gejala' => 'G007',
'mb' => 0.4,
'md' => 0.2
],

// P002 => Depresi Ringan
[
Expand All @@ -74,15 +80,16 @@ public function fillTable()
'mb' => 1.0,
'md' => 0.0
],

[
'kode_depresi' => 'P002',
'kode_gejala' => 'G007',
'mb' => 0.4,
'kode_gejala' => 'G008',
'mb' => 0.6,
'md' => 0.2
],
[
'kode_depresi' => 'P002',
'kode_gejala' => 'G008',
'kode_gejala' => 'G0010',
'mb' => 0.6,
'md' => 0.2
],
Expand Down Expand Up @@ -122,12 +129,6 @@ public function fillTable()
'kode_depresi' => 'P003',
'kode_gejala' => 'G001',
'mb' => 0.8,
'md' => 0.2
],
[
'kode_depresi' => 'P003',
'kode_gejala' => 'G006',
'mb' => 1.0,
'md' => 0.0
],
[
Expand Down Expand Up @@ -216,12 +217,6 @@ public function fillTable()
'mb' => 0.8,
'md' => 0.0
],
[
'kode_depresi' => 'P004',
'kode_gejala' => 'G011',
'mb' => 0.8,
'md' => 0.2
],
[
'kode_depresi' => 'P004',
'kode_gejala' => 'G012',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/clients/form_diagnosa.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<td>
<div class="pilihan">
<select class="form-select" aria-label="Default select example" name="kondisi[{{ $item->kode_gejala }}]">
<option value="0">Pilih</option>
<option value="-">Pilih</option>
@foreach ($kondisi_user as $kondisi)
<option value='{{ $kondisi->nilai }}'>{{ $kondisi->kondisi }}</option>
@endforeach
Expand Down

0 comments on commit aca04d4

Please sign in to comment.