<div id="job_all" class="row m-0 mb-3">
    <div class="col-lg-3">
        <div class="input-icon">
            <input id="search_hnall" type="text" class="form-control bg-gray-input search_all" autocomplete="off" placeholder="HN" />

            <span><i class="flaticon2-search-1 icon-md"></i></span>
        </div>
    </div>
    <div class="col-lg-3">
        <div class="input-icon">
            <input id="search_nameall" type="text" class="form-control bg-gray-input search_all" autocomplete="off" placeholder="Name" />

            <span><i class="flaticon2-search-1 icon-md"></i></span>
        </div>
    </div>
    <div class="col-lg-3">
        <div class="row mt-res">
            <div class="col-6 ">
                Doctor
            </div>
            <div class="col-6">
                Procedure
            </div>
        </div>
    </div>
    <div class="col-lg-2">
        @php
            $now = date('Y-m-d');
        @endphp
        <input type="text" class="form-control flatpickr-input search_date_all bg-gray-input search_all" id="search_date"
            data-provider="flatpickr" data-date-format="Y-m-d" data-range-date="true" readonly="readonly"
            placeholder="Date Select">
        <input type="hidden" id="date_from" value="">
        <input type="hidden" id="date_to" value="">
    </div>

    <div class="allcase-header  mt-2">
        <table class="table " style="overflow-x:auto;">
            <thead>
                <tr class="bg-light TextTable-header">
                    <td> &ensp; &ensp; Action </td>
                    <td>Operation Date</td>
                    <td>HN</td>
                    <td>Name</td>
                    <td>Status</td>
                    <td>Physician</td>
                    <td>Procedure</td>
                    <td>Room</td>
                    <td>Urease Test</td>
                    <td>Pre - Diagnosis</td>
                    <td>Complication</td>
                    <td>Description</td>
                </tr>
            </thead>
            <tbody>

            @php
                $i = 0;
            @endphp

            @foreach ($tb_case as $in => $data)
            @if (isset($data['case_hn']) || isset($data['hn']))
            {{-- @dd($data) --}}
                    @php
                        $data               = (object) $data;
                        $_id                = $data->_id;
                        $hn                 = isset($data->case_hn)         ? $data->case_hn : $data->hn;
                        $patientname        = isset($data->patientname)     ? $data->patientname : $data->firstname . ' ' . $data->lastname;
                        $procedure          = isset($data->procedurename)   ? $data->procedurename : $data->procedure;
                        $statusjob          = isset($data->statusjob)       ? ucfirst($data->statusjob) : '';
                        $appointment        = isset($data->appointment)     ? explode(' ', $data->appointment) : null;
                        $date               = isset($appointment)           ? format_date($appointment[0], 'd M Y') : '';
                        $physician          = isset($data->doctorname)      && @$data->doctorname . '' !== '' ? $data->doctorname : $data->physician;
                        $room               = isset($data->room)            && @$data->room != '' ? get_room_name(intval($data->room)) : '';
                        $case_pdfversion    = isset($data->case_pdfversion) && @$data->case_pdfversion != '' ? $data->case_pdfversion : [];
                        $count_pdf          = is_array($case_pdfversion)    ? count($case_pdfversion) : 0;
                        $patient_tel        = get_patient_data($hn, 'phone');
                    @endphp
                    <tr>
                        <td class="index" style="white-space: nowrap;">
                                <a href="{{ url("fileexport/$_id") }}" class="btn btn-icon btn-dark-primary"><i
                                        class="ri-folder-open-fill  ri-lg"></i></a>
                        </td>
                        <td>
                            <a href="{{ url("procedure/$_id") }}" class="">
                                <span style="color: #245788;">
                                    @isset($data->appointment)
                                        {{ $data->appointment }}
                                    @else
                                        -
                                    @endisset
                                </span>
                            </a>
                        </td>

                        <td data-text="{{$hn}}">
                            <a href="{{ url("procedure/$_id") }}" class="">
                                <span style="color: #245788;">{{ @$hn }}</span>
                            </a>
                        </td>

                        <td data-text="{{$patientname}}">{{ @$patientname }}</td>
                        <td>
                            @if ($statusjob != 'Discharged')
                                <span class="badge-soft-danger px-1">Incomplete</span>
                            @else
                                <span class="badge-soft-success px-1">Complete</span>
                            @endif
                        </td>

                        <td>
                            @isset($physician)
                                {{ $physician }}
                            @else
                                -
                            @endisset
                        </td>

                        <td>{{ @$procedure }}</td>
                        <td>{{ @$data->room }}</td>
                        <td>
                            @isset($data->rapid_urease_test)
                                @if (strlen($data->rapid_urease_test) > 15 || $data->rapid_urease_test == 'Pending')
                                    <a class="btn btn-sm modal_ureasetest btn-soft-warning " sub-name="pending"
                                    cid="{{@$_id}}" hn="{{@$hn}}" patientname="{{@$patientname}}" contact="{{@$patient_tel}}" select="{{@$data->rapid_urease_test}}" other="{{@$data->rapid_other}}">Pending</a>
                                @endif
                                @if ($data->rapid_urease_test == 'Positive (+)')
                                    <a class="btn btn-sm modal_ureasetest btn-soft-danger " sub-name="positive"
                                    cid="{{@$_id}}" hn="{{@$hn}}" patientname="{{@$patientname}}" contact="{{@$patient_tel}}" select="{{@$data->rapid_urease_test}}" other="{{@$data->rapid_other}}">Positive(+)</a>
                                @endif
                                @if ($data->rapid_urease_test == 'Negative (-)')
                                    <a class="btn btn-sm modal_ureasetest btn-soft-success" sub-name="negative"
                                    cid="{{@$_id}}" hn="{{@$hn}}" patientname="{{@$patientname}}" contact="{{@$patient_tel}}" select="{{@$data->rapid_urease_test}}" other="{{@$data->rapid_other}}">Negative (-)</a>
                                @endif
                            @else
                                -
                            @endisset
                        </td>
                        <td>
                            @if (isset($data->prediagnostic_other) && @$data->prediagnostic_other . '' != '')
                                {{ $data->prediagnostic_other }}
                            @else
                                -
                            @endif

                        </td>
                        <td>
                            @if (isset($data->complication_other) && @$data->complication_other . '' != '')
                                {{ $data->complication_other }}
                            @else
                                -
                            @endif
                        </td>
                        <td>
                            @isset($data->description)
                                {{ $data->description }}
                            @else
                                -
                            @endisset
                        </td>
                    </tr>

                    @php
                        $i = $i + 1;
                    @endphp
                @endif
            @endforeach










            </tbody>
        </table>
    </div>
</div>

