<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
  @include('layout.header')
    <style>
        .bullet-line-list li:before{
            top: 25% !important;
        }
        .group-test-box{
            max-height: 300px;
            min-height: 300px;
            overflow: auto;
        }
        .bullet-line-list:after {
            border: 1px dashed #f3f3f3;
            top: 35px; /* 45px;*/
        }

        .first-lv::before{
            content: "---";
            position: absolute;
            left: -30px;
            color: #f3f3f3;
        }
        .grandchildren-lv::before{
            content: "|---";
            position: absolute;
            left: -25px;
            color: #f3f3f3;
        }
        .modal-header span{font-size: 15px !important;}
</style>
</head>
<body>

  <div class="container-scroller">
    @include('layout.navbar')
    <!-- partial -->
    @include('layout.breadscrum')
    <div class="container-fluid page-body-wrapper">

      @include('layout.sidebar')

      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">
          <div class="row">
            <div class="col-md-12 grid-margin stretch-card">
                <div class="card min-vh-70">
                    <div class="card-body">
                        <h4 class="card-title"><i class="mdi mdi-dots-vertical menu-icon"></i> New Sample</h4>
                        <hr>
                        <form method="post" class="p-2" action="#" id="form-test-sample">
                            @csrf
                            <div class="row">
                                <div class="col-lg-12">
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="form-vertical mb-4 bg-light">
                                                <div class="col-lg-12 pt-2 border">
                                                    <div class="row">
                                                        <div class="col-lg-8">
                                                            <div class="form-group mb-1">
                                                                <label for="lab-name-en">{{__('Patient')}} <span class="text-danger">*</span></label>
                                                                <div class="input-group" id="testItem">
                                                                    <div class="form-group" style="flex: 1 !important;">
                                                                        <select class="form-control select2" name="patient_id" id="patient-id" style=" width: 100% !important;">
                                                                            <option></option>
                                                                            @foreach($patients as $patient)
                                                                                <option value="{{$patient->id}}">{{$patient->patient_uuid . ' - ' . $patient->name_en}}</option>
                                                                            @endforeach
                                                                        </select>
                                                                    </div>
                                                                    <div class="input-group-append">
                                                                        <button class="btn btn-sm btn-inverse-secondary px-3" id="searchPatientAddForm"  type="button"><i class="fa fa-search"></i>&nbsp;Search&nbsp;</button>
                                                                        <button class="btn btn-info waves-effect rounded-0 px-3 ml-2" type="button" data-action="new" data-toggle="modal" data-target="#modal-patient" data-backdrop="static"><i class="typcn typcn-plus"></i> Add New Patient</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-vertical sample-creation-form border p-4" style="display: none">
                                                <div class="row">
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Sample Number')}} <span class="text-danger">*</span></label>
                                                            <div class="input-group">
                                                                <input type="text" class="form-control rounded-0" {{$labSettings->sample_number == 1 ? ' disabled readonly ' : ''}} name="sample_number" id="sample-number" placeholder="Sample Number">
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-sm btn-info px-3 shadow-none rounded-0" title="Auto generate patient code" type="button" onclick="generate_uuid('S','#sample-number')"><i class="mdi mdi-autorenew"></i>&nbsp;</button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Sample Source')}} <span class="text-danger">*</span></label>
                                                            <select class="form-control select2 rounded-0" name="sample_source_id" id="sample-source-id" style="width: 100%">
                                                                <option></option>
                                                                @foreach($sampleSources as $sampleSource)
                                                                    <option value="{{$sampleSource->id}}">{{$sampleSource->name_en}}</option>
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Requester')}} <span class="text-danger">*</span></label>
                                                            <select class="form-control select2  rounded-0" name="physician_id" id="physician-id" style="width: 100%">
                                                                <option></option>
                                                                @foreach($physicians as $physician)
                                                                <option value="{{$physician->id}}">{{$physician->name_en}}</option>
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Collected Date')}} <span class="text-danger">*</span></label>
                                                            <input type="datetime-local" value="{{date('Y-m-d\TH:i:s')}}" class="form-control" name="collected_date" id="collected-date">
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Received Date')}} <span class="text-danger">*</span></label>
                                                            <input type="datetime-local" value="{{date('Y-m-d\TH:i:s')}}" class="form-control" name="received_date" id="received-date">
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Admission Date')}} <span class="text-danger">*</span></label>
                                                            <input type="datetime-local" value="{{date('Y-m-d\TH:i:s')}}" class="form-control" name="admission_date" id="admission-date">
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Diagnosis')}}</label>
                                                            <input type="text" class="form-control rounded-0" name="diagnosis" id="diagnosis" placeholder="Diagnosis">
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('Sample Condition')}} <span class="text-danger"></span></label>
                                                            <div class="input-group">
                                                                <div class="input-group-append">
                                                                    <div class="form-check pr-4">
                                                                        <label class="form-check-label">
                                                                            <input type="checkbox" name="is_urgent" id="is-urgent" class="form-check-input"> Is Urgent
                                                                        </label>
                                                                    </div>
                                                                </div>
                                                                <select class="form-control rounded-0" name="sample_condition" id="sample-condition">
                                                                    <option selected disabled>Sample Condition</option>
                                                                    <option value="1">Good</option>
                                                                    <option value="0">Rejected</option>
                                                                    <option value="2">Acceptable</option>
                                                                </select>

                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-6 col-lg-4">
                                                        <div class="form-group mb-1 " style="flex: 1 !important;">
                                                            <label for="lab-name-en">{{__('Reject Reason')}} <span class="text-danger text-small"></span></label>
                                                            <div class="input-group">
                                                                <div class="form-group" style="flex: 1 !important;">
                                                                    <select class="form-control select2 rounded-0" style="width: 100%" disabled name="reject_comment_id" id="reject-comment-id">
                                                                        <option></option>
                                                                        @foreach($rejectComments as $rejectComment)
                                                                            <option value="{{$rejectComment->id}}">{{$rejectComment->reject_comment}}</option>
                                                                        @endforeach
                                                                    </select>
                                                                </div>
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-sm btn-info rounded-0 px-3" type="button" onclick="addRejectComment('reject-comment-id')"><i class="typcn typcn-plus"></i>&nbsp;</button>
                                                                </div>
                                                            </div>

                                                        </div>
                                                    </div>
                                                    <div class="col-lg-12 pt-4 text-right">
                                                        <button type="button" data-toggle="modal" class="d-none" id="show-modal-assign-test" data-target="#modal-assign-test" data-backdrop="static"></button>
                                                        <button class="btn btn-info" type="button" id="saveSample"><i class="mdi mdi-check-all"></i> Save & Assign Test</button>
{{--                                                        <button class="btn btn-info mr-2" type="button"><i class="mdi mdi-content-paste"></i> Add Result</button>--}}
{{--                                                        <button class="btn btn-info" id="saveSample" type="button"><i class="fa fa-floppy-o"></i> Save</button>--}}
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                </div>
            </div>
          </div>
        </div>
      </div>

          <!-- Modal Patient -->
          <div class="modal fade modal-primary" id="modal-patient">
              <div class="modal-dialog show modal-xl">
                  <div class="modal-content">
                      <div class="modal-header">
                          <h6 class="modal-title">{{__('Patient')}}</h6>
                          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="mdi mdi-close"></span></button>
                      </div>

                      <div class="modal-body">
                          <form method="post" action="#" id="form" onkeydown="return event.key != 'Enter';">
                              @csrf
                              <input type="hidden" class="form-control" name="uid" id="data-id" value="0" />
                              <div class="form-vertical">
                                  <div class="row">
                                      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-6 px-3">
                                          <div class="form-group mb-1">
                                              <label for="patient-code">{{__('Patient-Code')}} <span class="text-danger">*</span></label>
                                              <div class="input-group">
                                                  <input type="text" class="form-control" {{$labSettings->patient_code == 1 ? ' disabled readonly ' : ''}} name="patient_code" id="patient-code" placeholder="Patient code">
                                                  <div class="input-group-append">
                                                      <button class="btn btn-sm btn-info px-3 shadow-none rounded-0" title="Auto generate patient code" type="button" onclick="generate_uuid('P','#patient-code')"><i class="mdi mdi-autorenew"></i>&nbsp;</button>
                                                  </div>
                                              </div>
                                          </div>
                                      </div>
                                  </div>
                                  <div class="row">
                                      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-6 px-3">
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Patient-Name')}} <span class="text-danger">*</span></label>
                                              <input type="text" class="form-control" name="patient_name" id="patient-name" placeholder="Patient name">
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-kh">Dob <b>or</b> Age <span class="text-danger">*</span></label>
                                              <div class="input-group">
                                                  <div class="input-group-append" style="flex: 4 !important;">
                                                      <input class="form-control datepicker" name="dob" type="text" id="dob" placeholder="{{__('general.date_placeholder')}}" required="" autocomplete="off">
                                                  </div>
                                                  <input type="number" id="age" name="age" placeholder="Age" value="" class="form-control" autocomplete="off">
                                                  <div class="input-group-append">
                                                      <select class="form-control" name="age_unit" id="age-unit">
                                                          <option value="1">Day</option>
                                                          <option value="30">Month</option>
                                                          <option selected value="365">Year</option>
                                                      </select>
                                                  </div>
                                              </div>
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Gender')}} <span class="text-danger">*</span></label>
                                              <div class="form-group pl-3">
                                                  <div class="row">
                                                      <div class="form-check col-sm-12 col-md-12 col-lg-3" style="margin-bottom: 6px !important;">
                                                          <label class="form-check-label">
                                                              <input type="radio" class="form-check-input" checked name="gender" data-id="1" value="1"> Male
                                                          </label>
                                                      </div>
                                                      <div class="form-check col-sm-12 col-md-12 col-lg-3" style="margin-bottom: 6px !important;">
                                                          <label class="form-check-label">
                                                              <input type="radio" class="form-check-input" name="gender" data-id="2" value="2"> Female
                                                          </label>
                                                      </div>
                                                      <div class="form-check col-sm-12 col-md-12 col-lg-3" style="margin-bottom: 6px !important;">
                                                          <label class="form-check-label">
                                                              <input type="radio" class="form-check-input" name="gender" data-id="3" value="3"> Other
                                                          </label>
                                                      </div>
                                                  </div>
                                              </div>
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Marital-Status')}} <span class="text-danger">*</span></label>
                                              <div class="form-group pl-3">
                                                  <div class="row">
                                                      <div class="form-check col-sm-12 col-md-12 col-lg-3" style="margin-bottom: 6px !important;">
                                                          <label class="form-check-label">
                                                              <input type="radio" class="form-check-input" checked name="marital_status" data-id="1" value="1"> Single
                                                          </label>
                                                      </div>
                                                      <div class="form-check col-sm-12 col-md-12 col-lg-3" style="margin-bottom: 6px !important;">
                                                          <label class="form-check-label">
                                                              <input type="radio" class="form-check-input" name="marital_status" data-id="2" value="2"> Married
                                                          </label>
                                                      </div>
                                                      <div class="form-check col-sm-12 col-md-12 col-lg-3" style="margin-bottom: 6px !important;">
                                                          <label class="form-check-label">
                                                              <input type="radio" class="form-check-input" name="marital_status" data-id="3" value="3"> Other
                                                          </label>
                                                      </div>
                                                  </div>
                                              </div>
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('KH-ID Number')}}</label>
                                              <input type="text" class="form-control" name="khid_number" id="khid-number" placeholder="Khmer-ID Number">
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Phone Number')}}</label>
                                              <input type="text" class="form-control" name="phone_number" id="phone-number" placeholder="Phone number">
                                          </div>
                                      </div>
                                      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-6 px-3">
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('House-Number')}}</label>
                                              <input type="text" class="form-control" name="house_number" id="house-number" placeholder="House number">
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Street-Number')}}</label>
                                              <input type="text" class="form-control" name="street_number" id="street-number" placeholder="Street number">
                                          </div>

                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Province')}} <span class="text-danger">*</span></label>
                                              <select class="form-control select2" name="province_id" id="province-id" style="width: 100% !important;">
                                                  <option></option>
                                                  @foreach($provinces as $province)
                                                      <option value="{{$province->id}}">{{$province->name_en}}</option>
                                                  @endforeach
                                              </select>
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('District')}} <span class="text-danger">*</span></label>
                                              <select class="form-control select2" name="district_id" id="district-id" style="width: 100% !important;">
                                              </select>
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Commune')}} <span class="text-danger">*</span></label>
                                              <select class="form-control select2" name="commune_id" id="commune-id" style="width: 100% !important;">
                                              </select>
                                          </div>
                                          <div class="form-group mb-1">
                                              <label for="lab-name-en">{{__('Village')}} <span class="text-danger">*</span></label>
                                              <select class="form-control select2" name="village_id" id="village-id" style="width: 100% !important;">
                                              </select>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                          </form>
                      </div>
                      <div class="modal-footer">
                          <button type="button" class="btn btn-info" id="savePatient"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('lang.save')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></button>
                          <button type="button" class="btn btn-light" data-dismiss='modal'>{{__('lang.cancel')}}</button>
                      </div>
                  </div>
              </div>
          </div>

          <!-- Modal Assign Test -->
          <div class="modal fade modal-primary" id="modal-assign-test">
              <div class="modal-dialog modal-xxl">
                  <div class="modal-content">
                      <div class="modal-header">
                          <h6 class="modal-title"><i class="mdi mdi-playlist-check"></i> {{__('Assign Test')}}</h6>
                          <span class="pl-4 text-muted">Patient's ID: <b class="pl-1 patient-code text-info">HDGD</b></span>
                          <span class="pl-3 text-muted">Patient's Name: <b class="pl-1 patient-name text-info">HDGD</b></span>
                          <span class="pl-3 text-muted">Sample Number: <b class="pl-1 sample-number text-info">HDGD</b></span>
                          <span class="pl-3 text-muted">Sample Source: <b class="pl-1 sample-source text-info">HDGD</b></span>
                          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="mdi mdi-close"></span></button>
                      </div>

                      <div class="modal-body" style="min-height: 650px">
                          <form method="post" action="#" id="form" onkeydown="return event.key != 'Enter';">
                              @csrf
                              <input type="hidden" class="form-control" name="uid" id="data-id" value="0" />
                              <div class="form-vertical">
                                  <div class="row" id="test-item-list">

                                  </div>

                              </div>
                          </form>
                      </div>
                      <div class="modal-footer">
                          <button type="button" class="btn btn-info" id="savePatient"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('lang.save')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></button>
                          <button type="button" class="btn btn-light" data-dismiss='modal'>{{__('lang.cancel')}}</button>
                      </div>
                  </div>
              </div>
          </div>



        @include('layout.footer')
    </div>
  </div>
</div>
  @include('layout.common_script')
    <script>


        var patient_base_url = "{{url('patient')}}";
        var get_refs_base_url = "{{url('refs')}}";
        var sample_base_url = "{{url('sample')}}"
        var is_auto_generate_sample_number = 0;

    </script>
    <script src="{{url(env("APP_URL").'storage/assets/js/admin/sample.js')}}"></script>
</body>

</html>

