<?php

function judul_pemeriksaan_lab($id)
{
    sleep(3);
    $returnHTML = '<ul>
    <li style="padding:0px !important;"><h3 class="title-tab">3 Kelainan Pemeriksaan Lab terbesar :</h3></li>
    </ul>';

    return $returnHTML;
}

function judul_pemeriksaan_non_lab($id)
{
    sleep(3);
    $returnHTML = '<ul>
    <li style="padding:0px !important;"><h3 class="title-tab">3 Kelainan Pemeriksaan Non Lab terbesar :</h3></li>
    </ul>';

    return $returnHTML;
}

function judul_pemeriksaan_fisik($id)
{
    sleep(3);
    $returnHTML = '<ul>
    <li style="padding:0px !important;"><h3 class="title-tab">3 Kelainan Pemeriksaan Fisik terbesar :</h3></li>
    </ul>';

    return $returnHTML;
}

function pemeriksaanLab($id)
{
    sleep(3);
    $data = array(
        array("No" => 1, "Pemeriksaan" => "Hipercholesterolemia", "Persentase" => 44.5),
        array("No" => 2, "Pemeriksaan" => "Hiperuricemia", "Persentase" => 22.7),
        array("No" => 3, "Pemeriksaan" => "Peningkatan SGPT", "Persentase" => 15.8)
    );

    // Variable string untuk menyimpan kode HTML tabel
    $tableHTML = '<table id="' . $id . '" class="table table-borderless">';
    $tableHTML .= '<colgroup>';
    $tableHTML .= '<col style="width: 10%">';
    $tableHTML .= '<col style="width: 70%">';
    $tableHTML .= '<col style="width: 20%">';
    $tableHTML .= '</colgroup>';
    $tableHTML .= '<thead class="title-table-thead">';
    $tableHTML .= '<tr>';
    $tableHTML .= '<th scope="col">No</th>';
    $tableHTML .= '<th scope="col">Pemeriksaan</th>';
    $tableHTML .= '<th scope="col">Persentase</th>';
    $tableHTML .= '</tr>';
    $tableHTML .= '</thead>';
    $tableHTML .= '<tbody class="title-table-tbody">';
    foreach ($data as $row) {
        $tableHTML .= '<tr>';
        $tableHTML .= '<th scope="row">' . $row["No"] . '</th>';
        $tableHTML .= '<td>' . $row["Pemeriksaan"] . '</td>';
        $tableHTML .= '<td>' . $row["Persentase"] . '</td>';
        $tableHTML .= '</tr>';
    }
    $tableHTML .= '</tbody>';
    $tableHTML .= '</table>';

    // Kembalikan kode HTML tabel
    return $tableHTML;
}

function pemeriksaanNonLab($id)
{
    sleep(3);
    $data = array(
        array("No" => 1, "Pemeriksaan" => "Retriksi Ringan", "Persentase" => 22.0),
        array("No" => 2, "Pemeriksaan" => "Gangguan Konduksi Ringan", "Persentase" => 15.0),
        array("No" => 3, "Pemeriksaan" => "Obstruksi Sedang", "Persentase" => 13.0)
    );

    // Variable string untuk menyimpan kode HTML tabel
    $tableHTML = '<table id="' . $id . '" class="table table-borderless">';
    $tableHTML .= '<colgroup>';
    $tableHTML .= '<col style="width: 10%">';
    $tableHTML .= '<col style="width: 70%">';
    $tableHTML .= '<col style="width: 20%">';
    $tableHTML .= '</colgroup>';
    $tableHTML .= '<thead class="title-table-thead">';
    $tableHTML .= '<tr>';
    $tableHTML .= '<th scope="col">No</th>';
    $tableHTML .= '<th scope="col">Pemeriksaan</th>';
    $tableHTML .= '<th scope="col">Persentase</th>';
    $tableHTML .= '</tr>';
    $tableHTML .= '</thead>';
    $tableHTML .= '<tbody class="title-table-tbody">';
    foreach ($data as $row) {
        $tableHTML .= '<tr>';
        $tableHTML .= '<th scope="row">' . $row["No"] . '</th>';
        $tableHTML .= '<td>' . $row["Pemeriksaan"] . '</td>';
        $tableHTML .= '<td>' . $row["Persentase"] . '</td>';
        $tableHTML .= '</tr>';
    }
    $tableHTML .= '</tbody>';
    $tableHTML .= '</table>';

    // Kembalikan kode HTML tabel
    return $tableHTML;
}

function pemeriksaanFisik($id)
{
    sleep(3);
    $data = array(
        array("No" => 1, "Pemeriksaan" => "Obesitas Stage 1", "Persentase" => 41.7),
        array("No" => 2, "Pemeriksaan" => "Pre Hipertensi", "Persentase" => 39.0),
        array("No" => 3, "Pemeriksaan" => "Kelainan Refraksi", "Persentase" => 35.2)
    );

    // Variable string untuk menyimpan kode HTML tabel
    $tableHTML = '<table id="' . $id . '" class="table table-borderless">';
    $tableHTML .= '<colgroup>';
    $tableHTML .= '<col style="width: 10%">';
    $tableHTML .= '<col style="width: 70%">';
    $tableHTML .= '<col style="width: 20%">';
    $tableHTML .= '</colgroup>';
    $tableHTML .= '<thead class="title-table-thead">';
    $tableHTML .= '<tr>';
    $tableHTML .= '<th scope="col">No</th>';
    $tableHTML .= '<th scope="col">Pemeriksaan</th>';
    $tableHTML .= '<th scope="col">Persentase</th>';
    $tableHTML .= '</tr>';
    $tableHTML .= '</thead>';
    $tableHTML .= '<tbody class="title-table-tbody">';
    foreach ($data as $row) {
        $tableHTML .= '<tr>';
        $tableHTML .= '<th scope="row">' . $row["No"] . '</th>';
        $tableHTML .= '<td>' . $row["Pemeriksaan"] . '</td>';
        $tableHTML .= '<td>' . $row["Persentase"] . '</td>';
        $tableHTML .= '</tr>';
    }
    $tableHTML .= '</tbody>';
    $tableHTML .= '</table>';

    // Kembalikan kode HTML tabel
    return $tableHTML;
} 

function saran_overweight($id)
{
    sleep(3);
    $tableHTML = '
        <h3 class="title-tab">Overweight/Obese</h3>    
        <ul>
            <li style="padding:0px !important;"><h3 class="content-saran">Olah raga teratur</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Penurunan berat badan</h3></li>
        </ul>';

    return $tableHTML;
}

function saran_kelainan_refraksi($id)
{
    sleep(3);
    $tableHTML = '<h3 class="title-tab">Kelainan Refraksi</h3>
        <h3 class="content-saran">1. Kelainan refraksi dengan kacamata</h3>
        <ul>
            <li style="padding:0px !important;"><h3 class="content-saran">Konsul dokter Scpesialis Mata untuk pemakaian kacamata/ lensa kontak</h3></li>
        </ul>
        <h3 class="content-saran">2. Kelainan refraksi tanpa kacamata</h3>
        <ul>
            <li style="padding:0px !important;"><h3 class="content-saran">Pemakaian kacamata/ lensa kontak</h3></li>
        </ul>';

    return $tableHTML;
}

function saran_tekanan_darah($id)
{
    sleep(3);
    $tableHTML = '<h3 class="title-tab">Tekanan Darah</h3>
        <h3 class="content-saran">1. Pre Hipertensi </h3>
        <ul>
            <li style="padding:0px !important;"><h3 class="content-saran">Olah raga teratur</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Cukup istirahat</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Pemeriksaan tekanan darah secara teratur.</h3></li>
        </ul>
        <h3 class="content-saran">2. Hipertensi stage 1 dan 2</h3>
        <ul>
            <li style="padding:0px !important;"><h3 class="content-saran">Olah raga teratur</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Cukup istirahat</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Batasi konsumsi garam</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Pemeriksaan tekanan darah secara teratur</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Pengobatan/ minum obat secara teratur (bila ybs sudah minum obat, hipertensi tetapi  kadang-kadang atau tidak rutin)</h3></li>
            <li style="padding:0px !important;"><h3 class="content-saran">Bila minum obat rutin tetapi tekanan darah tetap tinggi, Konsul dokter Spesialis Penyakit Dalam untuk evaluai obat.</h3></li>
        </ul>';
    
    return $tableHTML;
}

function saran_profile_lemak($id)
{
    sleep(3);
    $tableHTML = '<h3 class="title-tab">Peningkatan Profil lemak dan Hiperglikemia</h3>
    <h3 class="content-saran">1. Pre Hipertensi </h3>
    <ul>
        <li style="padding:0px !important;"><h3 class="content-saran">Diet rendah lemak, karbohidrat dan gula.</h3></li>
        <li style="padding:0px !important;"><h3 class="content-saran">Olahraga secara teratur.</h3></li>
        <li style="padding:0px !important;"><h3 class="content-saran">Program promosi kesehatan terutama untuk mencegah terjadinya dampak serius peningkatan lemak darah.</h3></li>
    </ul>';

    return $tableHTML;
}

function saran_hiperuricemia($id)
{
    sleep(3);
    $tableHTML = '<h3 class="title-tab">Hiperuricemia</h3>
    <ul>
        <li style="padding:0px !important;"><h3 class="content-saran">Mengurangi asupan makanan/sayuran yang mengandung purin (melinjo, kangkung, jeroan, emping, dll).</h3></li>
    </ul>';

    return $tableHTML;
}


if(isset($_POST['id'])){
    $id = $_POST['id'];
    if ($id == 'pemeriksaanLab') {
        echo pemeriksaanLab($id);
    } elseif ($id == 'pemeriksaanNonLab') {
        echo pemeriksaanNonLab($id);
    } elseif ($id == 'pemeriksaanFisik') {
        echo pemeriksaanFisik($id);
    } elseif ($id == 'saran_overweight') {
        echo saran_overweight($id);
    } elseif ($id == 'saran_kelainan_refraksi') {
        echo saran_kelainan_refraksi($id);
    } elseif ($id == 'saran_tekanan_darah') {
        echo saran_tekanan_darah($id);
    } elseif ($id == 'saran_profile_lemak') {
        echo saran_profile_lemak($id);
    } elseif ($id == 'saran_hiperuricemia') {
        echo saran_hiperuricemia($id);
    } elseif ($id == 'judul_pemeriksaan_lab') {
        echo judul_pemeriksaan_lab($id);
    } elseif ($id == 'judul_pemeriksaan_non_lab') {
        echo judul_pemeriksaan_non_lab($id);
    } elseif ($id == 'judul_pemeriksaan_fisik') {
        echo judul_pemeriksaan_fisik($id);
    } else {
        // Jika parameter 'type' tidak sesuai, kembalikan pesan error atau lakukan sesuai kebutuhan
        echo 'Invalid type parameter.';
    }
}

?>