@extends('layouts.master')
@section('content')
<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header">
                <h4 class="card-title">Daftar Pasien</h4>
            </div>
            <div class="card-body">
                <div class="card-text">
                    <div class="row">
                        <div class="col-md-8">
                            @livewire('admin.masters.registrasi.add-registrasi-component')
                        </div>
                        <div class="col-md-4 text-right">
                            <div class="row">
                                <label class="col-sm-3 col-form-label"></label>
                                <label class="col-sm-3 col-form-label">Cari : </label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control align-right" placeholder="Search" wire:model="keyword">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="table-responsive mb-4">
                <table id="zero-config" class="table table-hover" style="width:100%">
                    <thead>
                        <tr>
                            <th>No.</th>
                            <th style="text-align: left">Nama</th>
                            <th style="text-align: left">No. Identitas</th>
                            <th style="text-align: left">NIK</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        {{-- @dd($registrasis) --}}
                        {{-- @foreach ($registrasis as $item)
                            @php
                                $token = Str::random(30);
                            @endphp
                            <tr>
                                <td>
                                    {{ $loop->iteration + $registrasis->firstItem() - 1  }}
                                </td>
                                <td style="text-align: left">{{ $item->nama }}</td>
                                <td style="text-align: left">{{ ($item->no_identitas != null) ? $item->no_identitas : $item->no_referral." (No. Referral)" }}</td>
                                <td style="text-align: left">{{ $item->nik }}</td>
                                <td>
                                    <button type="button" class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#editRegistrasiModal" wire:click="edit('{{ encrypt($item->id) }}')"><i data-feather='edit'></i> Edit</button>
                                    <button type="button" class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#addNewAntrianModal" wire:click="dataPasien('{{ encrypt($item->id) }}')"><i data-feather='edit'></i> Buat Antrian Poli</button>
                                    <button type="button" class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#rekamMedisModal" wire:click="rekammedis('{{ encrypt($item->id) }}')"><i data-feather='book'></i> Rekam Medis</button>
                                    <button type="button" class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#deleteRegistrasiModal" wire:click="deleteId('{{ encrypt($item->id) }}')"><i data-feather='trash-2'></i></button>
                                </td>
                            </tr>
                        @endforeach --}}
                    </tbody>
                </table>
                <nav aria-label="Page navigation">
                    <ul class="pagination justify-content-center mt-2">
                        {{-- {{ $registrasis->links() }} --}}
                    </ul>
                </nav>
                <!-- edit registrasi modal -->
                <div class="modal fade" id="editRegistrasiModal" tabindex="-1" aria-labelledby="editRegistrasi" aria-hidden="true" wire:ignore.self>
                    <div class="modal-dialog modal-dialog-centered modal-lg">
                        <div class="modal-content">
                            <div class="modal-header bg-transparent">
                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                            </div>
                            <div class="modal-body pb-5 px-sm-4 mx-50">
                                <h1 class="address-title text-center mb-1" id="addNewAddressTitle">Edit Data Pasien</h1>

                                <form id="addNewAddressForm" wire:submit.prevent="update()">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">NIP/NIM/No. Referral Pasien</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.no_identitas" placeholder="NIP/NIM/No. Referral Pasien" data-msg="Masukkan NIP/NIM/No. Referral Pasien" readonly/>
                                            @error('inputs.no_identitas')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">NIK</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.nik" placeholder="NIK Pasien" data-msg="Masukkan NIK Pasien" />
                                            @error('inputs.nik')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Nama</label>
                                        <input type="text" class="form-control" wire:model.defer="inputs.nama" placeholder="Nama Pasien" data-msg="Masukkan Nama Pasien" />
                                        @error('inputs.nama')
                                        {{-- <span class="danger">{{ $message }}</span> --}}
                                        @enderror
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Alamat</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.alamat" placeholder="Alamat Pasien" data-msg="Masukkan Alamat Pasien" />
                                            @error('inputs.alamat')
                                            <span class="danger">{{ $message }}</span>
                                            @enderror
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Telepon</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.telepon" placeholder="Telepon Pasien" data-msg="Masukkan Telepon Pasien" />
                                            @error('inputs.telepon')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Tempat Lahir</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.tempat_lahir" placeholder="Tempat Lahir Pasien" data-msg="Masukkan Tempat Lahir Pasien" />
                                            @error('inputs.tempat_lahir')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Tanggal Lahir</label>
                                            <input type="date" class="form-control" wire:model.defer="inputs.tanggal_lahir" placeholder="Tanggal Lahir Pasien" data-msg="Masukkan Tanggal Lahir Pasien" />
                                            @error('inputs.tanggal_lahir')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Umur</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.umur" placeholder="Umur Pasien" data-msg="Masukkan Umur Pasien" />
                                            @error('inputs.umur')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Golongan Darah</label>
                                            <select class="form-control" wire:model.defer="inputs.gol_darah" id="">
                                                <option value="">Pilih Golongan Darah</option>
                                                <option value="A">A</option>
                                                <option value="B">B</option>
                                                <option value="AB">AB</option>
                                                <option value="O">O</option>
                                                <option value="Tidak Diketahui">Tidak Diketahui</option>
                                            </select>
                                            @error('inputs.gol_darah')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Jenis Kelamin</label>
                                        <br>
                                        <label>
                                            <input type="radio" id="modalAddressFirstName" name="modalAddressFirstName" value="L" wire:model.defer="inputs.jenis_kelamin" placeholder="Jenis Kelamin Pasien" data-msg="Masukkan Jenis Kelamin Pasien" />
                                            Laki-Laki
                                        </label>
                                        <label>
                                            <input type="radio" id="modalAddressFirstName" name="modalAddressFirstName" value="P" wire:model.defer="inputs.jenis_kelamin" placeholder="Jenis Kelamin Pasien" data-msg="Masukkan Jenis Kelamin Pasien" />
                                            Perempuan
                                        </label>
                                        @error('inputs.jenis_kelamin')
                                        {{-- <span class="danger">{{ $message }}</span> --}}
                                        @enderror
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Fakultas</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.fakultas" placeholder="Fakultas Pasien" data-msg="Masukkan Fakultas Pasien" />
                                            @error('inputs.fakultas')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-label" for="modalAddressFirstName">Jurusan</label>
                                            <input type="text" class="form-control" wire:model.defer="inputs.jurusan" placeholder="Jurusan Pasien" data-msg="Masukkan Jurusan Pasien" />
                                            @error('inputs.jurusan')
                                            {{-- <span class="danger">{{ $message }}</span> --}}
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Pekerjaan</label>
                                        <input type="text" class="form-control" wire:model.defer="inputs.pekerjaan" placeholder="Pekerjaan Pasien" data-msg="Masukkan Pekerjaan Pasien" />
                                        @error('inputs.pekerjaan')
                                        {{-- <span class="danger">{{ $message }}</span> --}}
                                        @enderror
                                    </div>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Email</label>
                                        <input type="text" class="form-control" wire:model.defer="inputs.email" placeholder="Email Pasien" data-msg="Masukkan Email Pasien"/>
                                        @error('inputs.email')
                                        {{-- <span class="danger">{{ $message }}</span> --}}
                                        @enderror
                                    </div>
                                    <hr>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Riwayat Alergi Obat</label>
                                        <input type="text" class="form-control" wire:model.defer="inputs.alergi_obat" placeholder="Riwayat Alergi Pasien" data-msg="Masukkan Riwayat Alergi Pasien"/>
                                        @error('inputs.alergi_obat')
                                        {{-- <span class="danger">{{ $message }}</span> --}}
                                        @enderror
                                    </div>
                                    <div class="col-12 text-center">
                                        <button type="submit" class="btn btn-primary me-1 mt-2">Submit</button>
                                        <button type="reset" class="btn btn-outline-secondary mt-2" data-bs-dismiss="modal" aria-label="Close">
                                            Cancel
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- / edit registrasi modal -->

                <!-- delete registrasi modal -->
                <div class="modal fade" id="deleteRegistrasiModal" tabindex="-1" aria-labelledby="deleteRegistrasi" aria-hidden="true" wire:ignore.self>
                    <div class="modal-dialog modal-dialog-centered modal-lg">
                        <div class="modal-content">
                            <div class="modal-body pb-5 px-sm-4 mx-50">
                                <h1 class="address-title text-center mb-1" id="addNewAddressTitle">Apakah anda yakin ingin menghapus data pasien?</h1>

                                <form id="addNewAddressForm" wire:submit.prevent="delete()">
                                    <div class="col-12 text-center">
                                        <button type="submit" class="btn btn-primary me-1 mt-2">OK</button>
                                        <button type="reset" class="btn btn-outline-secondary mt-2" data-bs-dismiss="modal" aria-label="Close">
                                            Cancel
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- / delete registrasi modal -->

                <!-- tambah antrian modal -->
                <div class="modal fade" id="addNewAntrianModal" tabindex="-1" aria-labelledby="tambahAntrian" aria-hidden="true" wire:ignore.self>
                    <div class="modal-dialog modal-dialog-centered modal-lg">
                        <div class="modal-content">
                            <div class="modal-header bg-transparent">
                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                            </div>
                            <div class="modal-body pb-5 px-sm-4 mx-50">
                                <livewire:admin.masters.registrasi.add-antrian-component/>
                                {{-- <h1 class="address-title text-center mb-1" id="addNewAddressTitle">Buat Antrian Poli</h1>

                                <form id="addNewAddressForm" wire:submit.prevent="tambahAntrian()">
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Nama</label>
                                        <input type="text" class="form-control" wire:model.defer="inputs.nama" placeholder="Nama Pasien" data-msg="Masukkan Nama Pasien" readonly />
                                        @error('inputs.nama')
                                        <span class="danger">{{ $message }}</span>
                                        @enderror
                                    </div>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Tanggal</label>
                                        <input type="date" id="modalAddressFirstName" name="modalAddressFirstName" class="form-control" wire:model.defer="inputs.tanggal" wire:change="filterDokter()" placeholder="Tanggal Antrian Poli" data-msg="Masukkan Tanggal Antrian Poli" />
                                        @error('inputs.tanggal')
                                        <span class="danger">{{ $message }}</span>
                                        @enderror
                                    </div>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Poli</label>
                                        <select class="form-control" wire:model.defer="inputs.poli" wire:change="filterDokter()" id="">
                                            <option value="">Select Poli</option>
                                            @foreach($polis as $item)
                                                <option value="{{ $item->id }}">{{ $item->nama }}</option>
                                            @endforeach
                                        </select>
                                        @error('inputs.poli')
                                        <span class="danger">{{ $message }}</span>
                                        @enderror
                                    </div>
                                    <div class="col-md-12">
                                        <label class="form-label" for="modalAddressFirstName">Dokter</label>
                                        <select class="form-control" wire:model.defer="inputs.dokter" id="">
                                            {{ var_export($jadwals) }}
                                            <option value="">Select Dokter</option>
                                            @foreach($jadwals as $item)
                                                @if($item->dokter != null)
                                                    <option value="{{ $item->dokter->id }}">{{ $item->dokter->biodata->nama }}</option>
                                                @endif
                                            @endforeach
                                        </select>
                                        @error('inputs.dokter')
                                        <span class="danger">{{ $message }}</span>
                                        @enderror
                                    </div>
                                    <div class="col-12 text-center">
                                        <button type="submit" class="btn btn-primary me-1 mt-2">Submit</button>
                                        <button type="reset" class="btn btn-outline-secondary mt-2" data-bs-dismiss="modal" aria-label="Close">
                                            Cancel
                                        </button>
                                    </div>
                                </form> --}}
                            </div>
                        </div>
                    </div>
                </div>
                <!-- / tambah antrian modal -->
                <!-- rekam medis modal -->
                <div class="modal fade" id="rekamMedisModal" tabindex="-1" aria-labelledby="rekamMedis" aria-hidden="true" wire:ignore.self>
                    <div class="modal-dialog modal-dialog-centered modal-xl">
                        <div class="modal-content">
                            <div class="modal-header bg-transparent">
                                <button wire:click="downloadRekamMedis()" class="btn btn-success"><i data-feather='download'></i> Excel</button>
                                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                            </div>
                            <livewire:dokter.pasien.rekam-medis-component/>
                        </div>
                    </div>
                </div>
                <!-- / rekam medis modal -->
            </div>
        </div>
    </div>
</div>
@push('js')
@endpush
@stop
