<!DOCTYPE html>
<html lang="en" class="default-style">

<head>
    <title>{{projectTitle()}}</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="Codedthemes">
    @include('headerscript')
    <style type="text/css">
    fieldset legend {
        background: inherit;
        font-family: "Lato", sans-serif;
        color: #650812;
        font-size: 15px;
        left: 10px;
        padding: 0 10px;
        position: absolute;
        top: -12px;
        font-weight: 400;
        width: auto !important;
        border: none !important;
    }

    fieldset {
        background: #ffffff;
        border: 1px solid #C43853;
        border-radius: 5px;
        margin: 17px 0 1px 0;
    padding: 15px;
        position: relative;
    }

    .form-control {
        min-height: 1px;
        height: 25px;
    }
    .container,
.container-fluid {
    padding-right: 15px;
    padding-left: 15px;
}

.table th,
.table td {
    padding: 1px;
    padding-left: 7px;
}
    </style>
</head>
@php
$UserId = Session::get('UserId');
if(file_exists('json_files/json-file.json')){
$json = file_get_contents('json_files/json-file.json');
//Decode JSON
$json_data = json_decode($json,true);
$results = array();
}

if(file_exists('json_files/timetables_date.json')){
$json2 = file_get_contents('json_files/timetables_date.json');
//Decode JSON
$json_data2 = json_decode($json2,true);
$results2 = array();
}
@endphp
<div class="container-fluid flex-grow-1 container-p-y">
    <!-- <h4 class="font-weight-bold py-3 mb-0">Discharge Card</h4> -->
    <form id="validation-form" novalidate="novalidate" method="POST" enctype="multipart/form-data" autocomplete="off"
        action="">
        <input type="hidden" name="actionvalue" id="actionvalue" value="Save">
        <input type="hidden" name="saveid" id="saveid" value="">
        <input type="hidden" name="IpdNo" id="otid" value="{{$otdetails->id}}">
        @csrf
        <div class="row">


            <div class="col-md-12">
                <div class="card mb-12 mb-1">
                    <div class="card-body">
                        <table class="table table-bordered table-striped mb-0">
                            <thead>


                                <tr>


                                    <th width="10" align="center" valign="top">Mrd.No </th>
                                    <th width="50" align="center" valign="top"><input type="text" class="form-control"
                                            placeholder="" id="MrdNo" name="MrdNo" readonly value="{{$MrdNo}}">
                                        <div class="clearfix"></div>
                                    </th>
                                    <th width="30" align="center" valign="top">Patient Name </th>
                                    <th width="180" align="center" valign="top"><input type="text" class="form-control"
                                            placeholder="" name="PatientName" id="PatientName"
                                            value="{{$otdetails->PatientName}}">
                                        <div class="clearfix"></div>
                                    </th>
                                    <th width="20" align="center" valign="top">Age/Gender </th>
                                    <th width="80" align="center" valign="top"><input type="text" class="form-control"
                                            placeholder="" id="AgeGender" name="AgeGender"
                                            value="{{$otdetails->Age}}/{{$otdetails->Gender}}">
                                    <th width="20" align="center" valign="top">Mobile</th>
                                    <th width="80" align="center" valign="top"><input type="text" class="form-control"
                                            placeholder="" id="Phone" name="Mobile" value="{{$otdetails->Phone}}">
                                        <div class="clearfix"></div>
                                    </th>
                                    <th width="10" align="center" valign="top">Address</th>
                                    <th width="80" align="center" valign="top" colspan="2"><input type="text" class="form-control"
                                            placeholder="" id="Address" name="Address" value="{{$otdetails->Address}}">
                                        <div class="clearfix"></div>
                                    </th>
                                    
                                </tr>

                                
                                <tr style="padding-top: 7px;">
                                <th width="10" align="center" valign="top" colspan="3"></th>
                                  
                                    <th width="175" align="center" valign="top">Date of Admission </th>
                                    <th width="50" align="center" valign="top"><input type="date" name="AdmissionDate"
                                            class="form-control" id="AdmissionDate" value="{{$otdetails->CreatedDate}}">
                                    </th>

                                    <th width="20" align="center" valign="top">Date of Operation </th>
                                    <th width="50" align="center" valign="top"><input type="date" name="OperationDate"
                                            id="OperationDate" class="form-control" value="{{$otdetails->CreatedDate}}">
                                    </th>
                                    <th width="20" align="center" valign="top">Date of Discharge </th>
                                    <th width="50" align="center" valign="top"><input type="date" name="DischargeDate"
                                            class="form-control" id="DischargeDate" value="{{$otdetails->CreatedDate}}">
                                    </th>
                                    <th width="100" align="center" valign="top">Follow up Date </th>
                                    <th width="50" align="center" valign="top"><input type="date" name="FollowUpDate1"
                                            class="form-control" id="FollowUpDate1" value="{{$otdetails->CreatedDate}}">
                                    </th>
                                </tr>

                            </thead>
                            <tbody>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>

        <div class="row">
           

            <div class="col-md-12">
                <div class="row">
                    <div class="col-lg-5">
                        <div class="row">
                            <div class="col-md-12">
                                <fieldset style="padding-bottom: 0px;">
                                    <legend>Diagnosis</legend>
                                    <div class="row">
                                        <div class="col-lg-10">
                                            <div class="form-group">
                                                <textarea class="form-control" placeholder="Search for..."
                                                    name="Diagnosis" id="Diagnosis">{{$otdetails->Diagnosis}}</textarea>

                                            </div>
                                        </div>
                                        <div class="col-lg-2">
                                            <span class="input-group-append">
                                                <button class="btn btn-secondary" type="button" data-toggle="modal"
                                                    data-target="#modal-report" id="add_button"
                                                    onclick="getValue('Diagnosis','Diagnosis')">...</button>
                                            </span>
                                        </div>
                                    </div>
                                </fieldset>
                            </div>
                            <div class="col-md-12">
                                <fieldset style="padding-bottom: 0px;">
                                    <legend>Operation Notes</legend>
                                    <div class="row">
                                        <div class="col-lg-10">
                                            <div class="form-group">
                                                <textarea class="form-control" placeholder="Search for..."
                                                    name="OperationNotes"
                                                    id="OperationNotes">{{$otdetails->SurgeryPerformed}}</textarea>

                                            </div>
                                        </div>
                                        <div class="col-lg-2">
                                            <span class="input-group-append">
                                                <button class="btn btn-secondary" type="button" data-toggle="modal"
                                                    data-target="#modal-report" id="add_button"
                                                    onclick="getValue('OperationNotes','OperationNotes')">...</button>
                                            </span>
                                        </div>
                                    </div>


                                </fieldset>
                            </div>

                            <div class="col-md-12">
                                <fieldset style="padding-bottom: 0px;">
                                    <legend>Slit Lamp Examination after surgery</legend>
                                    <div class="row">
                                        <div class="col-lg-10">
                                            <div class="form-group">
                                                <textarea class="form-control" placeholder="Search for..."
                                                    name="SlitLamp" id="SlitLamp"></textarea>

                                            </div>
                                        </div>
                                        <div class="col-lg-2">
                                            <span class="input-group-append">
                                                <button class="btn btn-secondary" type="button" data-toggle="modal"
                                                    data-target="#modal-report" id="add_button"
                                                    onclick="getValue('SlitLamp','SlitLamp')">...</button>
                                            </span>
                                        </div>
                                    </div>


                                </fieldset>
                            </div>

                            <div class="col-md-12">
                                <fieldset style="padding-bottom: 0px;">
                                    <legend>Special Instruction</legend>
                                    <div class="row">
                                        <div class="col-lg-10">
                                            <div class="form-group">
                                                <textarea class="form-control" placeholder="Search for..."
                                                    name="txtremark" id="txtremark"></textarea>

                                            </div>
                                        </div>
                                        <div class="col-lg-2">
                                            <span class="input-group-append">
                                                <button class="btn btn-secondary" type="button" data-toggle="modal"
                                                    data-target="#modal-report" id="add_button"
                                                    onclick="getValue('otremark','txtremark')">...</button>
                                            </span>
                                        </div>
                                    </div>


                                </fieldset>
                            </div>

                            <div class="col-md-12">
                                <fieldset style="padding-bottom: 0px;">
                                    <legend>Sticker Print</legend>
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                            <input type="checkbox" class="" name="StickerPrint" id="StickerPrint"
                                                                        value="1" 
                                                                        style="transform: scale(1);margin-left: 10px;margin-right: 10px;">
                                                                        <label for="StickerPrint">Sticker Print</label>

                                            </div>
                                        </div>
                                        
                                    </div>


                                </fieldset>
                            </div>




                            <div class="col-md-12">
                                <fieldset>
                                    <button class="btn btn-primary" type="submit" name="submit"
                                        id="submit">Save</button>
                                    <button class="btn btn-success" onclick="printOt()" id="printbtn" type="button"
                                        disabled>Print</button>
                                        <button class="btn btn-secondary" type="button" onclick="ipdReceipt()" id="receiptbtn"
                            disabled>IPD Receipt
                            Card</button>
                        <button class="btn btn-danger" type="button" onclick="ipdBill()" id="billbtn" disabled>IPD
                            Bill
                        </button>
                                  
                                </fieldset>
                            </div>




                        </div>
                    </div>


                    <div class="col-lg-7">
                        <div class="row">
                            <div class="col-md-12">
                                <fieldset>
                                    <legend>Investigation</legend>
                                    <div class="row">
                                        <table class="table table-bordered table-striped mb-0">
                                            <thead>

                                                <tr>
                                                    <th width="50" align="center" valign="top">B.S</th>

                                                    <th width="113" align="center" valign="top"><input type="text"
                                                            name="txtbsfasting" id="txtbsfasting" class="form-control"
                                                            placeholder="" value="{{$otdetails->Bs}}">
                                                        <div class="clearfix"></div>
                                                        </td>
                                                    </th>
                                                    <th width="50" align="center" valign="top">U.S </th>

                                                    <th width="105" align="center" valign="top"><input type="text"
                                                            name="txtusfasting" id="txtusfasting" class="form-control"
                                                            placeholder="" value="">
                                                        <div class="clearfix"></div>
                                                        </td>
                                                    </th>

                                                    <th width="50" align="center" valign="top">B.P </th>
                                                    <th width="129" align="center" valign="top"><input type="text"
                                                            name="txtbp" id="txtbp" class="form-control" placeholder=""
                                                            value="{{$otdetails->Bp}}">
                                                        <div class="clearfix"></div>
                                                        </td>
                                                    </th>
                                                </tr>

                                            </thead>
                                            <thead>

                                                <tr>
                                                    <th width="50" align="center" valign="top">IOP</th>

                                                    <th width="113" align="center" valign="top"><input type="text"
                                                            name="IopRe" id="IopRe" class="form-control" placeholder=""
                                                            value="{{$otdetails->IopRe}}">
                                                        <div class="clearfix"></div>
                                                        </td>
                                                    </th>
                                                    <th width="113" align="center" valign="top"><input type="text"
                                                            name="IopLe" id="IopLe" class="form-control" placeholder=""
                                                            value="{{$otdetails->IopLe}}">
                                                        <div class="clearfix"></div>
                                                        </td>
                                                    </th>
                                                    <th width="50" align="center" valign="top">IOL Power</th>

                                                    <th width="105" align="center" valign="top"><input type="text"
                                                            name="IolPowerRe" id="IolPowerRe" class="form-control"
                                                            placeholder="" value="{{$otdetails->IolPower}}">
                                                        <div class="clearfix"></div>
                                                        </td>
                                                    </th>


                                                    <th width="129" align="center" valign="top"><input type="text"
                                                            name="IolPowerLe" id="IolPowerLe" class="form-control"
                                                            placeholder="" value="">
                                                        <div class="clearfix"></div>
                                                        </td>
                                                    </th>
                                                </tr>

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


                                </fieldset>
                            </div>




                            <div class="col-md-12">
                                @include('ipd/inctreatments')
                            </div>

                        </div>
                        <div>

                        </div>

                    </div>
                </div>
            </div>



            <input type="hidden" id="CurrDate" value="{{date('Y-m-d')}}">


    </form>
</div>
</div>
</div>
<!-- [ Layout content ] Start -->

</div>
<!-- [ Layout container ] End -->

</div>
<!-- Overlay -->

<div class="layout-overlay layout-sidenav-toggle"></div>
</div>
<script src="{{url('assets/js/jquery-3.6.0.min.js')}}"></script>
@include('masters/inccommonmodal')
<div class="layout-overlay layout-sidenav-toggle"></div><!-- [ Layout wrapper] End -->
<!-- Modal -->
@include('footerscript')
<script>
function checkTap(previd,id){
    var PrevTreatDate = $('#TreatDate'+previd).val();
        var TreatDate = $('#TreatDate'+id).val();
            var TreatDur = $('#TreatDur'+id).val();
            //console.log(TreatDate,TreatDur);
        if($('#Tapchk'+id).prop('checked') == true) {
            $.ajax({
        url: "{{ url('getTapDate') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            TreatDate: TreatDate,
            TreatDur:TreatDur,
            PrevTreatDate:PrevTreatDate
        },
        success: function(data) {
            $('#TreatDate'+id).val(data);
            console.log(data);
        }
    });
        }
        else{
            $.ajax({
        url: "{{ url('getUnchkTapDate') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            TreatDate: TreatDate,
            TreatDur:TreatDur
        },
        success: function(data) {
            $('#TreatDate'+id).val(data);
            console.log(data);
        }
    });
            }
        }
       
    function getTreatDate(id,val){
        //alert(id);alert(val);
        $.ajax({
        url: "{{ url('getTreatDate') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            val: val
        },
        success: function(data) {
            //console.log(data);
            $('#TreatDate'+id).val(data);
        }
    });
    }
function ipdBill() {
    var dcid = $('#saveid').val();
    var otid = $('#otid').val();
    var mrdno = $('#MrdNo').val();
    setTimeout(function() {
        window.open(
            '/{{projectUrl()}}addOtherIpdBill2/' + mrdno + '/' + otid + '/' + dcid, 'popUpWindow4',
            'height=1000,width=1500,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no'
        );
    }, 1);
}

function ipdReceipt() {
    var otid = $('#otid').val();
    var mrdno = $('#MrdNo').val();
    setTimeout(function() {
        window.open(
            '/{{projectUrl()}}addOtherIpdReceipt/' + mrdno + '/' + otid, 'popUpWindow5',
            'height=1000,width=1500,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no'
        );
    }, 1);
}

function printOt() {
    var id = $('#saveid').val();
    setTimeout(function() {
        window.open(
            '/{{projectUrl()}}printDischargeCardOther/' + id, 'popUpWindow2',
            'height=1000,width=800,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no'
        );
    }, 1);
}

function getValue(val, idval) {
    $('#ModalValue').val(val);
    $('#ValueId').val(idval);
    $('#OldValue').val('');
    $('#search_text77').val('');
    $('#Ref_By').focus();
    desc_lists(val);
}


function getRecords(val) {
    $.ajax({
        url: "{{ url('getTreatments2') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            Treatment: val
        },
        success: function(data) {
            console.log(data);
            $('#showTreatments').html(data);
        }
    });
}

function getPatientTreatment(val) {
    $.ajax({
        url: "{{ url('getPatientTreatment') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            id: val
        },
        success: function(data) {
            console.log(data);
            var res = JSON.parse(data);
            var result = res.data;
            var Diagnosis = res.Diagnosis;
            //$('#Diagnosis').val(Diagnosis);
            $('#Treatment').val(result.Treatment);
            if (result.TreatChk1 == 1) {
                $('#TreatChk1').prop("checked", true);
            } else {
                $('#TreatChk1').prop("checked", false);
            }
            $('#TreatType1').val(result.TreatType1);
            $('#TreatName1').val(result.TreatName1);
            $('#TreatDose1').val(result.TreatDose1);
            $('#TreatFreq1').val(result.TreatFreq1);
            $('#TreatDur1').val(result.TreatDur1);
            $('#TreatEye1').val(result.TreatEye1);
            $('#TreatDate2').val(result.TreatDate2);

            if (result.TreatChk2 == 1) {
                $('#TreatChk2').prop("checked", true);
            } else {
                $('#TreatChk2').prop("checked", false);
            }
            $('#TreatType2').val(result.TreatType2);
            $('#TreatName2').val(result.TreatName2);
            $('#TreatDose2').val(result.TreatDose2);
            $('#TreatFreq2').val(result.TreatFreq2);
            $('#TreatDur2').val(result.TreatDur2);
            $('#TreatEye2').val(result.TreatEye2);
            $('#TreatDate2').val(result.TreatDate2);
            if (result.TreatChk3 == 1) {
                $('#TreatChk3').prop("checked", true);
            } else {
                $('#TreatChk3').prop("checked", false);
            }
            $('#TreatType3').val(result.TreatType3);
            $('#TreatName3').val(result.TreatName3);
            $('#TreatDose3').val(result.TreatDose3);
            $('#TreatFreq3').val(result.TreatFreq3);
            $('#TreatDur3').val(result.TreatDur3);
            $('#TreatEye3').val(result.TreatEye3);
            $('#TreatDate3').val(result.TreatDate3);

            if (result.TreatChk4 == 1) {
                $('#TreatChk4').prop("checked", true);
            } else {
                $('#TreatChk4').prop("checked", false);
            }
            $('#TreatType4').val(result.TreatType4);
            $('#TreatName4').val(result.TreatName4);
            $('#TreatDose4').val(result.TreatDose4);
            $('#TreatFreq4').val(result.TreatFreq4);
            $('#TreatDur4').val(result.TreatDur4);
            $('#TreatEye4').val(result.TreatEye4);
            $('#TreatDate4').val(result.TreatDate4);

            if (result.TreatChk5 == 1) {
                $('#TreatChk5').prop("checked", true);
            } else {
                $('#TreatChk5').prop("checked", false);
            }
            $('#TreatType5').val(result.TreatType5);
            $('#TreatName5').val(result.TreatName5);
            $('#TreatDose5').val(result.TreatDose5);
            $('#TreatFreq5').val(result.TreatFreq5);
            $('#TreatDur5').val(result.TreatDur5);
            $('#TreatEye5').val(result.TreatEye5);
            $('#TreatDate5').val(result.TreatDate5);

            if (result.TreatChk6 == 1) {
                $('#TreatChk6').prop("checked", true);
            } else {
                $('#TreatChk6').prop("checked", false);
            }
            $('#TreatType6').val(result.TreatType6);
            $('#TreatName6').val(result.TreatName6);
            $('#TreatDose6').val(result.TreatDose6);
            $('#TreatFreq6').val(result.TreatFreq6);
            $('#TreatDur6').val(result.TreatDur6);
            $('#TreatEye6').val(result.TreatEye6);
            $('#TreatDate6').val(result.TreatDate6);

            if (result.TreatChk7 == 1) {
                $('#TreatChk7').prop("checked", true);
            } else {
                $('#TreatChk7').prop("checked", false);
            }
            $('#TreatType7').val(result.TreatType7);
            $('#TreatName7').val(result.TreatName7);
            $('#TreatDose7').val(result.TreatDose7);
            $('#TreatFreq7').val(result.TreatFreq7);
            $('#TreatDur7').val(result.TreatDur7);
            $('#TreatEye7').val(result.TreatEye7);
            $('#TreatDate7').val(result.TreatDate7);

            if (result.TreatChk8 == 1) {
                $('#TreatChk8').prop("checked", true);
            } else {
                $('#TreatChk8').prop("checked", false);
            }
            $('#TreatType8').val(result.TreatType8);
            $('#TreatName8').val(result.TreatName8);
            $('#TreatDose8').val(result.TreatDose8);
            $('#TreatFreq8').val(result.TreatFreq8);
            $('#TreatDur8').val(result.TreatDur8);
            $('#TreatEye8').val(result.TreatEye8);
            $('#TreatDate8').val(result.TreatDate8);

            if (result.TreatChk9 == 1) {
                $('#TreatChk9').prop("checked", true);
            } else {
                $('#TreatChk9').prop("checked", false);
            }
            $('#TreatType9').val(result.TreatType9);
            $('#TreatName9').val(result.TreatName9);
            $('#TreatDose9').val(result.TreatDose9);
            $('#TreatFreq9').val(result.TreatFreq9);
            $('#TreatDur9').val(result.TreatDur9);
            $('#TreatEye9').val(result.TreatEye9);
            $('#TreatDate9').val(result.TreatDate9);

            if (result.TreatChk10 == 1) {
                $('#TreatChk10').prop("checked", true);
            } else {
                $('#TreatChk10').prop("checked", false);
            }
            $('#TreatType10').val(result.TreatType10);
            $('#TreatName10').val(result.TreatName10);
            $('#TreatDose10').val(result.TreatDose10);
            $('#TreatFreq10').val(result.TreatFreq10);
            $('#TreatDur10').val(result.TreatDur10);
            $('#TreatEye10').val(result.TreatEye10);
            $('#TreatDate10').val(result.TreatDate10);
        }
    });
}


function getPatientTreatment2(val) {
    $.ajax({
        url: "{{ url('getDichargeOtherTreatment') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            id: val
        },
        success: function(data) {
            //console.log(data);
            var res = JSON.parse(data);
            var result = res.data;
            //var Diagnosis = res.Diagnosis;
            //$('#Diagnosis').val(Diagnosis);
            $('#Treatment').val(result.Treatment);
            if (result.TreatChk1 == 1) {
                $('#TreatChk1').prop("checked", true);
            } else {
                $('#TreatChk1').prop("checked", false);
            }
            $('#TreatType1').val(result.TreatType1);
            $('#TreatName1').val(result.TreatName1);
            $('#TreatDose1').val(result.TreatDose1);
            $('#TreatFreq1').val(result.TreatFreq1);
            $('#TreatDur1').val(result.TreatDur1);
            $('#TreatEye1').val(result.TreatEye1);
            $('#TreatDate1').val(result.TreatDate1);

            if (result.TreatChk2 == 1) {
                $('#TreatChk2').prop("checked", true);
            } else {
                $('#TreatChk2').prop("checked", false);
            }
            $('#TreatType2').val(result.TreatType2);
            $('#TreatName2').val(result.TreatName2);
            $('#TreatDose2').val(result.TreatDose2);
            $('#TreatFreq2').val(result.TreatFreq2);
            $('#TreatDur2').val(result.TreatDur2);
            $('#TreatEye2').val(result.TreatEye2);
            $('#TreatDate2').val(result.TreatDate2);

            if (result.TreatChk3 == 1) {
                $('#TreatChk3').prop("checked", true);
            } else {
                $('#TreatChk3').prop("checked", false);
            }
            $('#TreatType3').val(result.TreatType3);
            $('#TreatName3').val(result.TreatName3);
            $('#TreatDose3').val(result.TreatDose3);
            $('#TreatFreq3').val(result.TreatFreq3);
            $('#TreatDur3').val(result.TreatDur3);
            $('#TreatEye3').val(result.TreatEye3);
            $('#TreatDate3').val(result.TreatDate3);

            if (result.TreatChk4 == 1) {
                $('#TreatChk4').prop("checked", true);
            } else {
                $('#TreatChk4').prop("checked", false);
            }
            $('#TreatType4').val(result.TreatType4);
            $('#TreatName4').val(result.TreatName4);
            $('#TreatDose4').val(result.TreatDose4);
            $('#TreatFreq4').val(result.TreatFreq4);
            $('#TreatDur4').val(result.TreatDur4);
            $('#TreatEye4').val(result.TreatEye4);
            $('#TreatDate4').val(result.TreatDate4);

            if (result.TreatChk5 == 1) {
                $('#TreatChk5').prop("checked", true);
            } else {
                $('#TreatChk5').prop("checked", false);
            }
            $('#TreatType5').val(result.TreatType5);
            $('#TreatName5').val(result.TreatName5);
            $('#TreatDose5').val(result.TreatDose5);
            $('#TreatFreq5').val(result.TreatFreq5);
            $('#TreatDur5').val(result.TreatDur5);
            $('#TreatEye5').val(result.TreatEye5);
            $('#TreatDate5').val(result.TreatDate5);

            if (result.TreatChk6 == 1) {
                $('#TreatChk6').prop("checked", true);
            } else {
                $('#TreatChk6').prop("checked", false);
            }
            $('#TreatType6').val(result.TreatType6);
            $('#TreatName6').val(result.TreatName6);
            $('#TreatDose6').val(result.TreatDose6);
            $('#TreatFreq6').val(result.TreatFreq6);
            $('#TreatDur6').val(result.TreatDur6);
            $('#TreatEye6').val(result.TreatEye6);
            $('#TreatDate6').val(result.TreatDate6);

            if (result.TreatChk7 == 1) {
                $('#TreatChk7').prop("checked", true);
            } else {
                $('#TreatChk7').prop("checked", false);
            }
            $('#TreatType7').val(result.TreatType7);
            $('#TreatName7').val(result.TreatName7);
            $('#TreatDose7').val(result.TreatDose7);
            $('#TreatFreq7').val(result.TreatFreq7);
            $('#TreatDur7').val(result.TreatDur7);
            $('#TreatEye7').val(result.TreatEye7);
            $('#TreatDate7').val(result.TreatDate7);

            if (result.TreatChk8 == 1) {
                $('#TreatChk8').prop("checked", true);
            } else {
                $('#TreatChk8').prop("checked", false);
            }
            $('#TreatType8').val(result.TreatType8);
            $('#TreatName8').val(result.TreatName8);
            $('#TreatDose8').val(result.TreatDose8);
            $('#TreatFreq8').val(result.TreatFreq8);
            $('#TreatDur8').val(result.TreatDur8);
            $('#TreatEye8').val(result.TreatEye8);
            $('#TreatDate8').val(result.TreatDate8);

            if (result.TreatChk9 == 1) {
                $('#TreatChk9').prop("checked", true);
            } else {
                $('#TreatChk9').prop("checked", false);
            }
            $('#TreatType9').val(result.TreatType9);
            $('#TreatName9').val(result.TreatName9);
            $('#TreatDose9').val(result.TreatDose9);
            $('#TreatFreq9').val(result.TreatFreq9);
            $('#TreatDur9').val(result.TreatDur9);
            $('#TreatEye9').val(result.TreatEye9);
            $('#TreatDate9').val(result.TreatDate9);

            if (result.TreatChk10 == 1) {
                $('#TreatChk10').prop("checked", true);
            } else {
                $('#TreatChk10').prop("checked", false);
            }
            $('#TreatType10').val(result.TreatType10);
            $('#TreatName10').val(result.TreatName10);
            $('#TreatDose10').val(result.TreatDose10);
            $('#TreatFreq10').val(result.TreatFreq10);
            $('#TreatDur10').val(result.TreatDur10);
            $('#TreatEye10').val(result.TreatEye10);
            $('#TreatDate10').val(result.TreatDate10);
        }
    });
}

function getPatientDetails(val) {
    $.ajax({
        url: "{{ url('getPatientDetails') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            id: val
        },
        dataType: "json",
        success: function(data) {
            var AgeGender = data.Age + "/" + data.Gender;
            $('#MrdNo').val(data.MrdNo);
            $('#PatientName').val(data.PatientName);
            $('#Age').val(AgeGender);
            //$('#Gender').val(data.Gender);
            $('#Phone').val(data.Phone);
            $('#Address').val(data.Address);
            getPatientTreatment(data.MrdNo);
        }
    });
}

function checkDcPatient(val, otid) {
    var CurrDate = $('#CurrDate').val();
    //var otid = $('#otid').val();
    $.ajax({
        url: "{{ url('checkDcOtherPatient') }}",
        method: "POST",
        data: {
            _token: '{{csrf_token()}}',
            id: val,
            otid: otid
        },
        success: function(data) {
            console.log(data);
            var res = JSON.parse(data);
            var Status = res.Status;
            var result = res.result;
            console.log(result);
            if (Status == 0) {
                getPatientDetails(val);
                $('#actionvalue').val('Save');
                $('#saveid').val('');
                $('#printbtn').attr("disabled", true);
                $('#billbtn').attr("disabled", true);
                $('#receiptbtn').attr("disabled", true);
                //$('#cmbtreateye').val('').attr("selected",true);
                // $('#MrdNo').val('');
                // $('#PatientName').val('');
                // $('#AgeGender').val('');
                // $('#Mobile').val('');
                // $('#Address').val('');

                // $('#AdmissionDate').val(CurrDate);
                // $('#AdmissionTime').val('');
                // $('#OperationDate').val(CurrDate);
                // $('#OperationTime').val('');
                // $('#DischargeDate').val(CurrDate);
                // $('#DischargeTime').val('');
                // $('#FollowUpDate1').val('');
                // $('#Diagnosis').val('');
                // $('#SurgeryPerformed').val('');
                // $('#CondDischarge').val('');
                // $('#cmbbsrandom').val('');
                // $('#txtbsfasting').val('');
                // $('#cmbusrandom').val('');
                // $('#txtusfasting').val('');
                // $('#cmbhbsag').val('');
                // $('#txtbp').val('');
                // $('#cmbbspostmeal').val('');
                // $('#txtbspostmeal').val('');
                // $('#cmbuspostmeal').val('');
                // $('#txtuspostmeal').val('');
                // $('#cmbecg').val('');
                // $('#cmbhiv').val('');
                // $('#txtfitnessby').val('');
                // $('#txtother').val('');
                // $('#IolPower').val('');
                // $('#CylToric').val('');

                // $('#Axis').val('');
                // $('#Multifocal').val('');
                // $('#Constant').val('');
                // $('#IopRe').val('');
                // $('#IopLe').val('');
            } else {
                $('#actionvalue').val('Edit');
                $('#printbtn').attr("disabled", false);
                $('#billbtn').attr("disabled", false);
    $('#receiptbtn').attr("disabled", false);
                $('#saveid').val(result.id);

                $('#MrdNo').val(result.MrdNo);
                $('#PatientName').val(result.PatientName);
                $('#AgeGender').val(result.AgeGender);
                $('#Phone').val(result.Mobile);
                $('#Address').val(result.Address);
                $('#OptEye').val(result.OptEye).attr("selected", true);
                $('#AdmissionDate').val(result.AdmissionDate);
                $('#AdmissionTime').val(result.AdmissionTime);
                $('#OperationDate').val(result.OperationDate);
                $('#OperationTime').val(result.OperationTime);
                $('#DischargeDate').val(result.DischargeDate);
                $('#DischargeTime').val(result.DischargeTime);
                $('#FollowUpDate1').val(result.FollowUpDate1);
                $('#Diagnosis').val(result.Diagnosis);
                $('#OtNotes').val(result.OtNotes).attr("selected", true);
                $('#SurgeryPerformed').val(result.SurgeryPerformed);
                $('#CondDischarge').val(result.CondDischarge);
                $('#cmbbsrandom').val(result.cmbbsrandom);
                $('#txtbsfasting').val(result.txtbsfasting);
                $('#cmbusrandom').val(result.cmbusrandom);
                $('#txtusfasting').val(result.txtusfasting);
                $('#cmbhbsag').val(result.cmbhbsag);
                $('#txtbp').val(result.txtbp);
                $('#cmbbspostmeal').val(result.cmbbspostmeal);
                $('#txtbspostmeal').val(result.txtbspostmeal);
                $('#cmbuspostmeal').val(result.cmbuspostmeal);
                $('#txtuspostmeal').val(result.txtuspostmeal);
                $('#cmbecg').val(result.cmbecg);
                $('#cmbhiv').val(result.cmbhiv);
                $('#txtfitnessby').val(result.txtfitnessby);
                $('#txtother').val(result.txtother);
                $('#IolPower').val(result.IolPower);
                $('#CylToric').val(result.CylToric);

                $('#Axis').val(result.Axis);
                $('#Multifocal').val(result.Multifocal);
                $('#Constant').val(result.Constant);
                $('#IopRe').val(result.IopRe);
                $('#IopLe').val(result.IopLe);
                $('#txtremark').val(result.txtremark);
                $('#OperationNotes').val(result.OperationNotes);
                $('#SlitLamp').val(result.SlitLamp);
                $('#txtremark').val(result.txtremark);
                $('#IolPowerRe').val(result.IolPowerRe);
                $('#IolPowerLe').val(result.IolPowerLe);
                if(result.StickerPrint == 1){
                    $('#StickerPrint').attr('checked',true);
                }
                else{
                    $('#StickerPrint').attr('checked',false);
                }
                getPatientTreatment2(result.id);

            }
        }
    });
}

$(document).ready(function() {
    var MrdNo = $('#MrdNo').val();
    var otid = $('#otid').val();
    //getPatientDetails(MrdNo);
    checkDcPatient(MrdNo, otid);
    $(document).on("input", "#Treatment", function(event) {
        var val = $(this).val();
        getRecords(val);
    });

    $(document).on("change", "#OptEye", function(event) {
        var eye = this.value;
        var val = $('#MrdNo').val();
        checkDcPatient(val, eye);
    });
    $(document).on("change", "#PatientId", function(event) {
        var val = this.value;
        var otid = $('#otid').val();
        checkDcPatient(val, otid);

    });

    $(document).on("shown.bs.modal", "#modal-report", function() {
        $('#search_text77').focus();
    });

    $('#validation-form').on('submit', function(e) {
        e.preventDefault();
        if ($('#validation-form').valid()) {
            $.ajax({
                url: "{{ url('saveDischargeCardOther') }}",
                method: "POST",
                data: new FormData(this),
                contentType: false,
                processData: false,
                beforeSend: function() {
                    $('#submit').attr('disabled', 'disabled');
                    $('#submit').text('Please Wait...');
                },
                success: function(data) {
                    $('#actionvalue').val('Edit');
                    $('#saveid').val(data);
                    $('#printbtn').attr("disabled", false);
                    $('#submit').attr('disabled', false);
                    $('#submit').text('Submit');
                    $('#billbtn').attr("disabled", false);
    $('#receiptbtn').attr("disabled", false);
                }
            });
        }

    });






});
</script>