من این کد جاوا اسکریپت
const data = {
        allow_insurance_organization_turn: "بیمه ایران, بیمه تامین اجتماعی",
        allow_internet_turn: 10,
        allow_manualt_turn: 5,
        allow_organization_turn: 3,
        doctor: "دکتر رضا بیگی",
        endtime: "17:00:00",
        exist_internet_turn: 10,
        exist_manualt_turn: 5,
        exist_organization_turn: 3,
        id: 1,
        medical_center: "بیمارستان امام رضا",
        quota_internet_turn: 50,
        quota_manualt_turn: 50,
        quota_organization_turn: 0,
        reserved_internet_turn: 2,
        reserved_manualt_turn: 1,
        reserved_organization_turn: 1,
        starttime: "09:00:00",
        status: true,
        time_each_visit: 10,
        visit_date: "2023-10-30"
    };

    // محاسبه اولین وقت ویزیت
    const firstAvailableTime = (startTime, timeEachVisit, reservedTurns) => {
        const start = new Date(`1970-01-01T${startTime}Z`);
        const firstAvailable = new Date(start.getTime() + reservedTurns * timeEachVisit * 60000);
        return firstAvailable.toISOString().substr(11, 5);
    };

    // اضافه کردن اطلاعات به DOM
    document.getElementById('visitInfo').innerHTML = `
        <div class="col-12 col-md-6">
            <strong>نام دکتر:</strong> ${data.doctor}
        </div>
        <div class="col-12 col-md-6">
            <strong>تاریخ ویزیت:</strong> ${data.visit_date}
        </div>
        <div class="col-12 col-md-6">
            <strong>مرکز درمانی:</strong> ${data.medical_center}
        </div>
        <div class="col-12 col-md-6">
            <strong>اولین وقت آزاد:</strong> ${firstAvailableTime(data.starttime, data.time_each_visit, data.reserved_internet_turn + data.reserved_manualt_turn + data.reserved_organization_turn)}
        </div>
        <div class="col-12 col-md-6">
            <strong>ویزیت‌های گرفته شده:</strong> اینترنتی: ${data.reserved_internet_turn}, دستی: ${data.reserved_manualt_turn}, سازمانی: ${data.reserved_organization_turn}
        </div>
        <div class="col-12 col-md-6">
            <strong>ویزیت‌های خالی:</strong> اینترنتی: ${data.quota_internet_turn - data.reserved_internet_turn}, دستی: ${data.quota_manualt_turn - data.reserved_manualt_turn}, سازمانی: ${data.quota_organization_turn - data.reserved_organization_turn}
        </div>
    `;

و این کد جاوا اسکریپت 

async function timeToMinutes(time) {
    const [hours, minutes, seconds] = time.split(':').map(Number);
    const totalMinutes = hours * 60 + minutes;
    return totalMinutes;
}

async function gregorianToJalali(gy, gm, gd) {
    const g_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    const j_days_in_month = [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29];

    gy -= 1600;
    gm -= 1;
    gd -= 1;

    let g_day_no = 365 * gy + Math.floor((gy + 3) / 4) - Math.floor((gy + 99) / 100) + Math.floor((gy + 399) / 400);

    for (let i = 0; i < gm; ++i) {
        g_day_no += g_days_in_month[i];
    }

    if (gm > 1 && ((gy % 4 === 0 && gy % 100 !== 0) || (gy % 400 === 0))) {
        g_day_no++;
    }
    g_day_no += gd;

    let j_day_no = g_day_no - 79;
    const j_np = Math.floor(j_day_no / 12053);
    j_day_no %= 12053;

    let jy = 979 + 33 * j_np + 4 * Math.floor(j_day_no / 1461);
    j_day_no %= 1461;

    if (j_day_no >= 366) {
        jy += Math.floor((j_day_no - 1) / 365);
        j_day_no = (j_day_no - 1) % 365;
    }

    let jm;
    for (jm = 0; jm < 11 && j_day_no >= j_days_in_month[jm]; ++jm) {
        j_day_no -= j_days_in_month[jm];
    }

    const jd = j_day_no + 1;
    return [jy, jm + 1, jd];
}

async function calculateFirstAvailableSlot(data) {
    const startMinutes = await timeToMinutes(data.starttime);
    const endMinutes = await timeToMinutes(data.endtime);
    const totalSlots = (endMinutes - startMinutes) / data.time_each_visit;

    // تعداد رزروها
    const totalReserved = data.reserved_internet_turn + data.reserved_manualt_turn + data.reserved_organization_turn;

    // محاسبه اولین زمان خالی
    if (totalReserved < totalSlots) {
        const firstAvailableSlotMinutes = startMinutes + totalReserved * data.time_each_visit;
        const hours = Math.floor(firstAvailableSlotMinutes / 60);
        const minutes = firstAvailableSlotMinutes % 60;
        const timeString = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;

        const [gy, gm, gd] = data.visit_date.split('-').map(Number);
        const [jy, jm, jd] = await gregorianToJalali(gy, gm, gd);

        return `${timeString} ${jy}/${jm.toString().padStart(2, '0')}/${jd.toString().padStart(2, '0')}`;
    } else {
        return "زمانی برای ویزیت خالی نیست.";
    }
}

async function get_data() {
    const url = 'http://localhost/TakingTurns/visits/';

    try {
        const response = await send_requests(url, {}, 'GET');

        if (!response.ok) {
            throw new Error('Network response was not ok');
        }

        const data = await response.json();
        console.log('Data saved successfully:', data);
        return data
    } catch (error) {
        console.error('Error saving data:', error);
    }
}

async function addRow(data) {
    Body_Table = document.getElementById("data_table");

    data.forEach(async function(item, index) {

        async function convert_to_list(text) {
            const items = text.slice(1, -1);
            const items_list_text = items.split(',')
            var text_items = ""
            items_list_text.forEach(async function(items_list){
                text_items += items_list.slice(1, -1) + ", "
            })
            console.log(text_items)
            return text_items.slice(0, -2);
        }

        Body_Table.insertAdjacentHTML('beforeend', `
            <tr>
                <td>${item.doctor}</td>
                <td>${"اطفال"}</td>
                <td>${item.medical_center}</td>
                <td>${await calculateFirstAvailableSlot(item)}</td>
                <td><button class="btn btn-primary waves-effect waves-light" data-bs-target="#editUser" data-bs-toggle="modal" type="button" id="data-${index}"> نمایش</button></td>
            </tr>
        `);
    });
    
}

document.addEventListener('DOMContentLoaded', async function() {
    const data = await get_data();
    if (data.length != 0){await addRow(data)}
});

document.getElementById('filterInput').addEventListener('input', async function() {
    const filterValue = this.value.toLowerCase();
    const rows = document.querySelectorAll('#data_table tr');
    
    for (let row of rows) {
        await filterRow(row, filterValue);
    }
});

async function filterRow(row, filterValue) {
    const cells = row.querySelectorAll('td');
    const match = Array.from(cells).some(cell => {
        return cell.textContent.toLowerCase().includes(filterValue);
    });

    row.style.display = match ? '' : 'none';
}

رو دارم
این دو کد رو ادغام و بهینه کن برام