$(document).ready(function () {
    $('#loaderimg').show();
    basicdetails();
    check_previlige_tabs(20,'PS_V1');
});
function check_previlige_tabs(formid,tab_id) {
    debugger;
    var RightData = {
        Stringtype: formid,
        Dml_Indicator: "CTABR",
        tab_id: tab_id
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/UserRight/User_rights_privileges',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(RightData),
        success: function (data) {
            debugger;
            var data1 = JSON.parse(data);
            if (data1.msg == "Success") {
                var data1 = data1.data;
                if (jQuery.isEmptyObject((data1))) {

                }
                else {
                    var j = 0

                    //$.each(data1.Table, function (i, emp1) {
                    //    $("[data-id=" + emp1.tab_id + "]").removeClass('hidden');
                    //})

                    $.each(data1.Table1, function (i, emp) {
                        if (emp.status == 0) {
                            $("[data-id=" + emp.role_rights_view + "]").addClass('hidden');
                        }
                        else if (emp.status == 1) {
                            if (j == 0) {
                                if (emp.role_rights_view == 'PSPD_V1') {
                                    $('#tab_Procedure').click();

                                }
                                else if (emp.role_rights_view == 'PSD_V1') {
                                    $('#tab_diet').click();
                                }
                                else if (emp.role_rights_view == 'PSM_V1') {
                                    $('#tab_medical').click();
                                }


                            }
                            j = j + 1;
                        }
                    });
                }
            }
        }
    });
}

var previewImage = (input) => {

    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#previewHeadImage').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}

var previewImage2 = (input) => {

    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#preview2HeadImage').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}

var previewImage3 = (input) => {

    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#preview3HeadImage').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}

var updateVitals = () => {

    if ($('#ChkVitals').val() == 1) {
        $('#previewVitals').show();

        if ($('#ChkBP').val() == 1) {
            $('#previewVitalsBP').show();
        } else {
            $('#previewVitalsBP').hide();
        }
        if ($('#ChkBS').val() == 1) {
            $('#previewVitalsSugar').show();
        } else {
            $('#previewVitalsSugar').hide();
        }
        if ($('#ChkWeight').val() == 1) {
            $('#previewVitalsWeight').show();
        } else {
            $('#previewVitalsWeight').hide();
        }
        if ($('#ChkHBA1C').val() == 1) {
            $('#previewVitalsHBA1C').show();
        } else {
            $('#previewVitalsHBA1C').hide();
        }
        if ($('#Chkpulserate').val() == 1) {
            $('#previewVitalsPulse').show();
        } else {
            $('#previewVitalsPulse').hide();
        }
    } else {
        $('#previewVitals').hide();
    }


}

var updatePreview = (x) => {

    $('#previewFootText1').html($('#txtMarketing').val());
    $('#previewFootText2').html($('#txtanyother').val());
    $('#previewContText').html($('#lblcustomize').val());
    if ($('#labChkheader').val() == 1) {
        if ($('#Chkheader').val() == 1) {
            //let mtop = parseInt($("#mtop").val(), 10) + 40;
            let mbottom = $('#mbottom').val();
            let mtop = $('#mtop').val();
            let mright = $('#mright').val();
            let mleft = $('#mleft').val();
            $('#previewCont').css({ 'margin-top': mtop + 'px' });
            $('#previewCont').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont').css({ 'margin-left': mleft + 'px' });
            $('#previewCont').css({ 'margin-right': mright + 'px' });
        } else {
            //let mtop = parseInt($("#mtop").val(), 10) + 40;
            let mbottom = $('#mbottom').val();
            let mtop = $('#mtop').val();
            let mright = $('#mright').val();
            let mleft = $('#mleft').val();
            $('#previewCont').css({ 'margin-top': mtop + 'px' });
            $('#previewCont').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont').css({ 'margin-left': mleft + 'px' });
            $('#previewCont').css({ 'margin-right': mright + 'px' });
        }
    } else {
        $('#previewCont').css({ 'margin': '0' + 'px' });
    }

    if ($('#Chkheader').val() == 1) {
        $('#previewHead').css({ 'visibility': 'visible' });
    } else {
        if ($('#labChkheader').val() == 1) {
            let mtop = parseInt($("#mtop").val(), 10);
            let mbottom = $('#mbottom').val();
            let mright = $('#mright').val();
            let mleft = $('#mleft').val();
            $('#previewCont').css({ 'margin-top': mtop + 'px' });
            $('#previewCont').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont').css({ 'margin-left': mleft + 'px' });
            $('#previewCont').css({ 'margin-right': mright + 'px' });
            $('#previewHead').css({ 'visibility': 'hidden' });
        } else {
            $('#previewHead').css({ 'visibility': 'hidden' });
        }
    }
    if ($('#Chkfooter').val() == 1) {
        $('#previewFoot').show();
    } else {
        $('#previewFoot').hide();
    }
    if ($('#ChkDianostics').val() == 1) {
        $('#previewTest').show();
    } else {
        $('#previewTest').hide();
    }
    if ($('#ChkExercise').val() == 1) {
        $('#previewExercise').show();
    } else {
        $('#previewExercise').hide();
    }
    if ($('#Chkvisitdate').val() == 1) {
        $('#previewAppointment').show();
    } else {
        $('#previewAppointment').hide();
    }
    if ($('#Chkother').val() == 1) {
        $('#previewContText').show();
    } else {
        $('#previewContText').hide();
    }




}

var updatePreview2 = (x) => {

    $('#preview2FootText1').html($('#txtMarketing2').val());
    $('#preview2FootText2').html($('#txtanyother2').val());
    $('#preview2ContText').html($('#lblcustomize2').val());
    if ($('#labChkheader2').val() == 1) {
        if ($('#Chkheader2').val() == 1) {
            //let mtop = parseInt($("#mtop").val(), 10) + 40;
            let mbottom = $('#mbottom2').val();
            let mtop = $('#mtop2').val();
            let mright = $('#mright2').val();
            let mleft = $('#mleft2').val();
            $('#previewCont2').css({ 'margin-top': mtop + 'px' });
            $('#previewCont2').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont2').css({ 'margin-left': mleft + 'px' });
            $('#previewCont2').css({ 'margin-right': mright + 'px' });
        } else {
            //let mtop = parseInt($("#mtop").val(), 10) + 40;
            let mbottom = $('#mbottom2').val();
            let mtop = $('#mtop2').val();
            let mright = $('#mright2').val();
            let mleft = $('#mleft2').val();
            $('#previewCont2').css({ 'margin-top': mtop + 'px' });
            $('#previewCont2').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont2').css({ 'margin-left': mleft + 'px' });
            $('#previewCont2').css({ 'margin-right': mright + 'px' });
        }
    } else {
        $('#previewCont2').css({ 'margin': '0' + 'px' });
    }

    if ($('#Chkheader2').val() == 1) {
        $('#previewHead2').css({ 'visibility': 'visible' });
    } else {
        if ($('#labChkheader2').val() == 1) {
            let mtop = parseInt($("#mtop2").val(), 10);
            let mbottom = $('#mbottom2').val();
            let mright = $('#mright2').val();
            let mleft = $('#mleft2').val();
            $('#previewCont2').css({ 'margin-top': mtop + 'px' });
            $('#previewCont2').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont2').css({ 'margin-left': mleft + 'px' });
            $('#previewCont2').css({ 'margin-right': mright + 'px' });
            $('#previewHead2').css({ 'visibility': 'hidden' });
        } else {
            $('#previewHead2').css({ 'visibility': 'hidden' });
        }
    }
    if ($('#Chkfooter2').val() == 1) {
        $('#previewFoot2').show();
    } else {
        $('#previewFoot2').hide();
    }
    if ($('#ChkInvoice').val() == 1) {
        $('#previewInvoice').show();
    } else {
        $('#previewInvoice').hide();
    }
    if ($('#Chkother2').val() == 1) {
        $('#preview2ContText').show();
    } else {
        $('#preview2ContText').hide();
    }
}

var updatePreview3 = (x) => {

    $('#preview3FootText1').html($('#txtMarketing3').val());
    $('#preview3FootText2').html($('#txtanyother3').val());
    $('#preview3ContText').html($('#lblcustomize3').val());
    if ($('#labChkheader3').val() == 1) {
        if ($('#Chkheader3').val() == 1) {
            //let mtop = parseInt($("#mtop").val(), 10) + 40;
            let mbottom = $('#mbottom3').val();
            let mtop = $('#mtop3').val();
            let mright = $('#mright3').val();
            let mleft = $('#mleft3').val();
            $('#previewCont3').css({ 'margin-top': mtop + 'px' });
            $('#previewCont3').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont3').css({ 'margin-left': mleft + 'px' });
            $('#previewCont3').css({ 'margin-right': mright + 'px' });
        } else {
            //let mtop = parseInt($("#mtop").val(), 10) + 40;
            let mbottom = $('#mbottom3').val();
            let mtop = $('#mtop3').val();
            let mright = $('#mright3').val();
            let mleft = $('#mleft3').val();
            $('#previewCont3').css({ 'margin-top': mtop + 'px' });
            $('#previewCont3').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont3').css({ 'margin-left': mleft + 'px' });
            $('#previewCont3').css({ 'margin-right': mright + 'px' });
        }
    } else {
        $('#previewCont3').css({ 'margin': '0' + 'px' });
    }

    if ($('#Chkheader3').val() == 1) {
        $('#previewHead3').css({ 'visibility': 'visible' });
    } else {
        if ($('#labChkheader3').val() == 1) {
            let mtop = parseInt($("#mtop3").val(), 10);
            let mbottom = $('#mbottom3').val();
            let mright = $('#mright3').val();
            let mleft = $('#mleft3').val();
            $('#previewCont3').css({ 'margin-top': mtop + 'px' });
            $('#previewCont3').css({ 'margin-bottom': mbottom + 'px' });
            $('#previewCont3').css({ 'margin-left': mleft + 'px' });
            $('#previewCont3').css({ 'margin-right': mright + 'px' });
            $('#previewHead3').css({ 'visibility': 'hidden' });
        } else {
            $('#previewHead3').css({ 'visibility': 'hidden' });
        }
    }
    if ($('#Chkfooter3').val() == 1) {
        $('#previewFoot3').show();
    } else {
        $('#previewFoot3').hide();
    }
    if ($('#ChkLabReports').val() == 1) {
        $('#previewLab').show();
    } else {
        $('#previewLab').hide();
    }
    if ($('#Chkother3').val() == 1) {
        $('#preview3ContText').show();
    } else {
        $('#preview3ContText').hide();
    }
}

function basicdetails() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'DS'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/doctor_details',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {
                            $('#lblDoctorName').html(data.Table[i].first_name);
                            $('#lblSpecialty').html(data.Table[i].doctor_speciality_code_display);
                            $('#lblemail').html(data.Table[i].email_id);
                            $('#lblPhoneno').html(data.Table[i].phone_number_1);
                            $('#lblDoctorName2').html(data.Table[i].first_name);
                            $('#lblSpecialty2').html(data.Table[i].doctor_speciality_code_display);
                            $('#lblemail2').html(data.Table[i].email_id);
                            $('#lblPhoneno2').html(data.Table[i].phone_number_1);
                            $('#lblDoctorName3').html(data.Table[i].first_name);
                            $('#lblSpecialty3').html(data.Table[i].doctor_speciality_code_display);
                            $('#lblemail3').html(data.Table[i].email_id);
                            $('#lblPhoneno3').html(data.Table[i].phone_number_1);
                            $('#lblDoctorName4').html(data.Table[i].first_name);
                            $('#lblSpecialty4').html(data.Table[i].doctor_speciality_code_display);
                            $('#lblemail4').html(data.Table[i].email_id);
                            $('#lblPhoneno4').html(data.Table[i].phone_number_1);

                            $('#dietDoctorName4').html(data.Table[i].first_name);
                            $('#dietSpecialty4').html(data.Table[i].doctor_speciality_code_display);
                            $('#dietemail4').html(data.Table[i].email_id);
                            $('#dietPhoneno4').html(data.Table[i].phone_number_1);
                            $('#labinlblDoctorName4').html(data.Table[i].first_name);
                            $('#labinlblSpecialty4').html(data.Table[i].doctor_speciality_code_display);
                            $('#labinlblemail4').html(data.Table[i].email_id);
                            $('#labinlblPhoneno4').html(data.Table[i].phone_number_1);
                            $('#MClabinlblDoctorName4').html(data.Table[i].first_name);
                            $('#MClabinlblSpecialty4').html(data.Table[i].doctor_speciality_code_display);
                            $('#MClabinlblemail4').html(data.Table[i].email_id);
                            $('#MClabinlblPhoneno4').html(data.Table[i].phone_number_1);

                            $('#previewHeadText1').html(data.Table[i].first_name);
                            $('#previewHeadText2').html(data.Table[i].doctor_speciality_code_display);
                            $('#previewHeadText3').html(data.Table[i].email_id);
                            $('#previewHeadText4').html(data.Table[i].phone_number_1);
                            $('#preview2HeadText1').html(data.Table[i].first_name);
                            $('#preview2HeadText2').html(data.Table[i].doctor_speciality_code_display);
                            $('#preview2HeadText3').html(data.Table[i].email_id);
                            $('#preview2HeadText4').html(data.Table[i].phone_number_1);
                            $('#preview3HeadText1').html(data.Table[i].first_name);
                            $('#preview3HeadText2').html(data.Table[i].doctor_speciality_code_display);
                            $('#preview3HeadText3').html(data.Table[i].email_id);
                            $('#preview3HeadText4').html(data.Table[i].phone_number_1);
                            $('#preview4HeadText1').html(data.Table[i].first_name);
                            $('#preview4HeadText2').html(data.Table[i].doctor_speciality_code_display);
                            $('#preview4HeadText3').html(data.Table[i].email_id);
                            $('#preview4HeadText4').html(data.Table[i].phone_number_1);

                            $('#dietpreview3HeadText1').html(data.Table[i].first_name);
                            $('#dietpreview3HeadText2').html(data.Table[i].doctor_speciality_code_display);
                            $('#dietpreview3HeadText3').html(data.Table[i].email_id);
                            $('#dietpreview3HeadText4').html(data.Table[i].phone_number_1);
                            $('#labinpreview3HeadText1').html(data.Table[i].first_name);
                            $('#labinpreview3HeadText2').html(data.Table[i].doctor_speciality_code_display);
                            $('#labinpreview3HeadText3').html(data.Table[i].email_id);
                            $('#labinpreview3HeadText4').html(data.Table[i].phone_number_1);
                            $('#MClabinpreview3HeadText1').html(data.Table[i].first_name);
                            $('#MClabinpreview3HeadText2').html(data.Table[i].doctor_speciality_code_display);
                            $('#MClabinpreview3HeadText3').html(data.Table[i].email_id);
                            $('#MClabinpreview3HeadText4').html(data.Table[i].phone_number_1);


                            $('#DSlblDoctorName4').html(data.Table[i].first_name);
                            $('#DSlblSpecialty4').html(data.Table[i].doctor_speciality_code_display);
                            $('#DSlblemail4').html(data.Table[i].email_id);
                            $('#DSlblPhoneno4').html(data.Table[i].phone_number_1);

                            $('#RefdietDoctorName4').html(data.Table[i].first_name);
                            $('#RefdietSpecialty4').html(data.Table[i].doctor_speciality_code_display);
                            $('#Refdietemail4').html(data.Table[i].email_id);
                            $('#RefdietPhoneno4').html(data.Table[i].phone_number_1);

                        }
                    }
                    if (data.Table1.length > 0) {
                        var qualification_name = '';
                        for (var i = 0; i < data.Table1.length; i++) {
                            if (i >= 1) {
                                qualification_name = qualification_name + ', ' + data.Table1[i].qualification_name;
                            }
                            else {
                                qualification_name = data.Table1[i].qualification_name;
                            }
                            $('#lblQualification').html(qualification_name);
                            $('#lblQualification2').html(qualification_name);
                            $('#lblQualification3').html(qualification_name);
                            $('#lblQualification4').html(qualification_name);
                            $('#dietQualification4').html(qualification_name);
                            $('#labinlblQualification4').html(qualification_name);
                            $('#MClabinlblQualification4').html(qualification_name);
                            $('#previewHeadText1').append(' , ' + qualification_name);
                            $('#preview2HeadText1').append(' , ' + qualification_name);
                            $('#preview3HeadText1').append(' , ' + qualification_name);
                            $('#dietpreview3HeadText1').append(' , ' + qualification_name);
                            $('#labinpreview3HeadText1').append(' , ' + qualification_name);
                            $('#MClabinpreview3HeadText1').append(' , ' + qualification_name);

                            $('#DSlblQualification4').html(qualification_name);
                            $('#RefdietQualification4').html(qualification_name);
                        }
                    }
                    if (data.Table2.length > 0) {
                        var address1 = '', address2 = '';
                        for (var i = 0; i < data.Table2.length; i++) {
                            var address1 = data.Table2[0].address_line_1 + ' , ' + data.Table2[0].address_line_2 + ' , ' + data.Table2[0].town_village + ', ' + data.Table2[0].country + ', ' + data.Table2[0].state + ', ' + data.Table2[0].city;
                            if (data.Table2.length > 1) {
                                var address2 = data.Table2[1].address_line_1 + ' , ' + data.Table2[1].address_line_2 + ' , ' + data.Table2[1].town_village + ', ' + data.Table2[1].country + ', ' + data.Table2[1].state + ', ' + data.Table2[1].city;
                            }
                        }
                        $('#lblAddress1').html(address1);
                        $('#lblAddress2').html(address2);
                        $('#lbl2Address1').html(address1);
                        $('#lbl2Address2').html(address2);
                        $('#lbl3Address1').html(address1);
                        $('#lbl3Address2').html(address2);
                        $('#lbl4Address1').html(address1);
                        $('#lbl4Address2').html(address2);
                        $('#dietlbl4Address1').html(address1);
                        $('#dietlbl4Address2').html(address2);
                        $('#labinlbl4Address1').html(address1);
                        $('#labinlbl4Address2').html(address2);
                        $('#MClabinlbl4Address1').html(address1);
                        $('#MClabinlbl4Address2').html(address2);

                        $('#Address1').html(address1);
                        $('#Address2').html(address2);
                        $('#Address3').html(address2);
                        $('#Address21').html(address1);
                        $('#Address22').html(address2);
                        $('#Address23').html(address2);
                        $('#Address31').html(address1);
                        $('#Address32').html(address2);
                        $('#Address33').html(address2);
                        $('#Address41').html(address1);
                        $('#Address42').html(address2);
                        $('#Address43').html(address2);

                        $('#DSlbl4Address1').html(address1);
                        $('#DSlbl4Address2').html(address2);

                        $('#Refdietlbl4Address1').html(address1);
                        $('#Refdietlbl4Address2').html(address2);

                    }
                }
                else {
                    console.log(data);
                }



            }
            print_details();
            lab_details();
            invoice_details();
            procedure_details();
            diet_details();
            labinvoice_details();
            medicalcertificate_details();
            discharge_summary_details();
            referral_print_details();
        }
    });
}


$('#ChkVitals').change(function () {
    debugger;
    if ($('#ChkVitals').val() == 1) {
        $('#ChkBP').val(1);
        $('a[data-toggle=ChkBP][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkBP][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkBP][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkBP][data-title="' + 2 + '"]').addClass('not-active');

        $('#ChkBS').val(1);
        $('a[data-toggle=ChkBS][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkBS][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkBS][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkBS][data-title="' + 2 + '"]').addClass('not-active');

        $('#ChkWeight').val(1);
        $('a[data-toggle=ChkWeight][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkWeight][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkWeight][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkWeight][data-title="' + 2 + '"]').addClass('not-active');

        $('#ChkHBA1C').val(1);
        $('a[data-toggle=ChkHBA1C][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkHBA1C][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkHBA1C][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkHBA1C][data-title="' + 2 + '"]').addClass('not-active');


        $('#Chkpulserate').val(1);
        $('a[data-toggle=Chkpulserate][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkpulserate][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkpulserate][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkpulserate][data-title="' + 2 + '"]').addClass('not-active');

        $('#ChkECG').val(1);
        $('a[data-toggle=ChkECG][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkECG][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkECG][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkECG][data-title="' + 2 + '"]').addClass('not-active');


        $('#ChkTemp').val(1);
        $('a[data-toggle=ChkTemp][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkTemp][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkTemp][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkTemp][data-title="' + 2 + '"]').addClass('not-active');
    }
    else {
        $('#ChkBP').val(2);
        $('a[data-toggle=ChkBP][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkBP][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkBP][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkBP][data-title="' + 1 + '"]').addClass('not-active');

        $('#ChkBS').val(2);
        $('a[data-toggle=ChkBS][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkBS][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkBS][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkBS][data-title="' + 1 + '"]').addClass('not-active');

        $('#ChkWeight').val(2);
        $('a[data-toggle=ChkWeight][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkWeight][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkWeight][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkWeight][data-title="' + 1 + '"]').addClass('not-active');

        $('#ChkHBA1C').val(2);
        $('a[data-toggle=ChkHBA1C][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkHBA1C][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkHBA1C][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkHBA1C][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkpulserate').val(2);
        $('a[data-toggle=Chkpulserate][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkpulserate][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkpulserate][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkpulserate][data-title="' + 1 + '"]').addClass('not-active');

        $('#ChkECG').val(2);
        $('a[data-toggle=ChkECG][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkECG][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkECG][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkECG][data-title="' + 1 + '"]').addClass('not-active');

        $('#ChkTemp').val(2);
        $('a[data-toggle=ChkTemp][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkTemp][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkTemp][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkTemp][data-title="' + 1 + '"]').addClass('not-active');
    }
});
$('#ChkDiag').change(function () {
    if ($('#ChkDiag').val() == 1) {
        $('#ChkComplaints').val(1);
        $('a[data-toggle=ChkComplaints][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkComplaints][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkComplaints][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkComplaints][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkdiagnosis').val(1);
        $('a[data-toggle=Chkdiagnosis][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkdiagnosis][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkdiagnosis][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkdiagnosis][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkinv').val(1);
        $('a[data-toggle=Chkinv][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkinv][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkinv][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkinv][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkobs').val(1);
        $('a[data-toggle=Chkobs][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkobs][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkobs][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkobs][data-title="' + 2 + '"]').addClass('not-active');

        $('#ChkProcedure').val(1);
        $('a[data-toggle=ChkProcedure][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkProcedure][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkProcedure][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkProcedure][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkins').val(1);
        $('a[data-toggle=Chkins][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkins][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkins][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkins][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chknotes').val(1);
        $('a[data-toggle=Chknotes][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chknotes][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chknotes][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chknotes][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkxrayfind').val(1);
        $('a[data-toggle=Chkxrayfind][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkxrayfind][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkxrayfind][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkxrayfind][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkreview_notes').val(1);
        $('a[data-toggle=Chkreview_notes][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkreview_notes][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkreview_notes][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkreview_notes][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkpast_medical_history').val(1);
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkpast_significant_adverse_events').val(1);
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkgeneral_examination').val(1);
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chklocal_examination').val(1);
        $('a[data-toggle=Chklocal_examination][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chklocal_examination][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chklocal_examination][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chklocal_examination][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkabdomen_girth').val(1);
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkadvice').val(1);
        $('a[data-toggle=Chkadvice][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkadvice][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkadvice][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkadvice][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkcounselling').val(1);
        $('a[data-toggle=Chkcounselling][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkcounselling][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkcounselling][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkcounselling][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chklab_findings').val(1);
        $('a[data-toggle=Chklab_findings][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chklab_findings][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chklab_findings][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chklab_findings][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkxray_findings').val(1);
        $('a[data-toggle=Chkxray_findings][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkxray_findings][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkxray_findings][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkxray_findings][data-title="' + 2 + '"]').addClass('not-active');
    }
    else {
        $('#ChkComplaints').val(2);
        $('a[data-toggle=ChkComplaints][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkComplaints][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkComplaints][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkComplaints][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkdiagnosis').val(2);
        $('a[data-toggle=Chkdiagnosis][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkdiagnosis][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkdiagnosis][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkdiagnosis][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkinv').val(2);
        $('a[data-toggle=Chkinv][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkinv][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkinv][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkinv][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkobs').val(2);
        $('a[data-toggle=Chkobs][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkobs][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkobs][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkobs][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkobs').val(2);
        $('a[data-toggle=ChkProcedure][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkProcedure][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkProcedure][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkProcedure][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkins').val(2);
        $('a[data-toggle=Chkins][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkins][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkins][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkins][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chknotes').val(2);
        $('a[data-toggle=Chknotes][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chknotes][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chknotes][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chknotes][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkxrayfind').val(2);
        $('a[data-toggle=Chkxrayfind][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkxrayfind][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkxrayfind][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkxrayfind][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkreview_notes').val(2);
        $('a[data-toggle=Chkreview_notes][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkreview_notes][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkreview_notes][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkreview_notes][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkpast_medical_history').val(2);
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkpast_medical_history][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkpast_significant_adverse_events').val(2);
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkgeneral_examination').val(2);
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkgeneral_examination][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chklocal_examination').val(2);
        $('a[data-toggle=Chklocal_examination][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chklocal_examination][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chklocal_examination][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chklocal_examination][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkabdomen_girth').val(2);
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkabdomen_girth][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkadvice').val(2);
        $('a[data-toggle=Chkadvice][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkadvice][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkadvice][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkadvice][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkcounselling').val(2);
        $('a[data-toggle=Chkcounselling][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkcounselling][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkcounselling][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkcounselling][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chklab_findings').val(2);
        $('a[data-toggle=Chklab_findings][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chklab_findings][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chklab_findings][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chklab_findings][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkxray_findings').val(2);
        $('a[data-toggle=Chkxray_findings][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkxray_findings][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkxray_findings][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkxray_findings][data-title="' + 1 + '"]').addClass('not-active');
    }
})

$('#ChkAssessment').change(function () {
    if ($("#ChkAssessment").val() == 1) {
        $('#ChkAssessment_details').val(1);
        $('a[data-toggle=ChkAssessment_details][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkAssessment_details][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkAssessment_details][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkAssessment_details][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chklifestyle').val(1);
        $('a[data-toggle=Chklifestyle][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chklifestyle][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chklifestyle][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chklifestyle][data-title="' + 2 + '"]').addClass('not-active');
    }
    else {
        $('#ChkAssessment_details').val(2);
        $('a[data-toggle=ChkAssessment_details][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkAssessment_details][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkAssessment_details][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkAssessment_details][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chklifestyle').val(2);
        $('a[data-toggle=Chklifestyle][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chklifestyle][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chklifestyle][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chklifestyle][data-title="' + 1 + '"]').addClass('not-active');
    }
})

$('#Chksignature').change(function () {
    if ($('#Chksignature').val() == 1) {
        $('#ChkDoctorName').val(1);
        $('a[data-toggle=ChkDoctorName][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkDoctorName][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkDoctorName][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkDoctorName][data-title="' + 2 + '"]').addClass('not-active');

        $('#ChkNPI').val(1);
        $('a[data-toggle=ChkNPI][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkNPI][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=ChkNPI][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=ChkNPI][data-title="' + 2 + '"]').addClass('not-active');

        $('#Chkdqual').val(1);
        $('a[data-toggle=Chkdqual][data-title="' + 1 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkdqual][data-title="' + 1 + '"]').addClass('active');
        $('a[data-toggle=Chkdqual][data-title="' + 2 + '"]').removeClass('active');
        $('a[data-toggle=Chkdqual][data-title="' + 2 + '"]').addClass('not-active');
    }
    else {
        $('#ChkDoctorName').val(2);
        $('a[data-toggle=ChkDoctorName][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkDoctorName][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkDoctorName][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkDoctorName][data-title="' + 1 + '"]').addClass('not-active');

        $('#ChkNPI').val(2);
        $('a[data-toggle=ChkNPI][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=ChkNPI][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=ChkNPI][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=ChkNPI][data-title="' + 1 + '"]').addClass('not-active');

        $('#Chkdqual').val(2);
        $('a[data-toggle=Chkdqual][data-title="' + 2 + '"]').removeClass('not-active');
        $('a[data-toggle=Chkdqual][data-title="' + 2 + '"]').addClass('active');
        $('a[data-toggle=Chkdqual][data-title="' + 1 + '"]').removeClass('active');
        $('a[data-toggle=Chkdqual][data-title="' + 1 + '"]').addClass('not-active');
    }
})


$('#btnSubmit').click(function () {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        header: $('#Chkheader').val(),
        logo: $('#Hdn_profile_image').val(),
        visit_time: $('#txtanyother').val(),
        footer: $('#Chkfooter').val(),
        marketing: $('#txtMarketing').val(),
        medicine_prescription: $('#ChkPrescription').val(),
        //lab_record: $('#ChkDianostics').val(),
        vitals: $('#ChkVitals').val(),
        bloodpressure: $('#ChkBP').val(),
        bloodsugar: $('#ChkBS').val(),
        weight: $('#ChkWeight').val(),
        height: '',
        HBA1C: $('#ChkHBA1C').val(),
        pulserate: $('#Chkpulserate').val(),
        exercise: $('#ChkExercise').val(),
        diet: $('#ChkDiet').val(),
        anyother: $('#Chkother').val(),
        customize_text: $('#lblcustomize').val(),
        visit_date: $('#Chkvisitdate').val(),
        prescription_page_top: $('#mtop').val(),
        prescription_page_bottom: $('#mbottom').val(),
        prescription_page_left: $('#mleft').val(),
        prescription_page_right: $('#mright').val(),
        diagnosis: $('#Chkdiagnosis').val(),
        ECG: $('#ChkECG').val(),
        prescription_page_setting: $('#labChkheader').val(),
        complaints: $('#ChkComplaints').val(),
        signature: $('#Chksignature').val(),
        doctor_name: $('#ChkDoctorName').val(),
        NPI: $('#ChkNPI').val(),
        doctor_signature: $('#Hdn_doctorsign').val(),
        doctor_qualification: $('#Chkdqual').val(),
        assessment_report: $('#ChkAssessment').val(),
        assessment_details: $('#ChkAssessment_details').val(),
        life_style: $('#Chklifestyle').val(),
        prescription_page_style: $('#P_type').val(),
        doctor_signature_size: $('#ChkSingType').val(),
        prescription_generic_name: $('#generic_name').val(),
        gender: $('#gender').val(),
        font_size: $('#fontsize').val(),
        table_color: $('#fontcolor').val(),
        font_style: $('#fontstyle_1').val(),
        casesheet_report: $('#ChkCsreport').val(),
        premorbidconditions: $('#ChkPMConn').val(),
        observednutrition: $('#ChkObservedNutrition').val(),
        instruction: $('#Chkins').val(),
        observation: $('#Chkobs').val(),
        investigation: $('#Chkinv').val(),
        diagnosis_observation: $('#ChkDiag').val(),
        temperature: $('#ChkTemp').val(),
        procedure: $('#ChkProcedure').val(),
        vas: $('#chkvas').val(),
        notes: $('#Chknotes').val(),
        xray_findings: $('#Chkxrayfind').val(),
        advice: $('#Chkadvice').val(),
        counselling: $('#Chkcounselling').val(),
        respiratory_rate: $('#ChkRespiratoryRate').val(),
        lab_findings:$('#Chklab_findings').val(),
        xray_findings_new: $('#Chkxray_findings').val(),
        review_notes: $('#Chkreview_notes').val(),

        past_medical_history: $('#Chkpast_medical_history').val(),
        past_adverse_events: $('#Chkpast_significant_adverse_events').val(),
        general_examination: $('#Chkgeneral_examination').val(),
        local_examination: $('#Chklocal_examination').val(),
        abdomen_girth: $('#Chkabdomen_girth').val(),
        dental: $('#ChkDental').val(),
        writing_prescription: $('#ChkWritingPrescription').val(),
        future_services: $('#ChkFutureServices').val()
    }
    console.log(details);
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/doctor_details',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            debugger;
            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Prescription Saved Successfully',
                        {
                            closeButton: true,
                            progressBar: true,
                            allowHtml: true,
                            timeOut: 20000000,

                            onShown: function (toast) {
                                $("#confirmationRevertYes").click(function () {
                                    window.location.href = '/Prescription_Settings/';
                                })
                            }
                        })
               
            }
            else {
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Prescription Saved Successfully',
                         {
                             closeButton: true,
                             progressBar: true,
                             allowHtml: true,
                             timeOut: 20000000,

                             onShown: function (toast) {
                                 $("#confirmationRevertYes").click(function () {
                                     window.location.href = '/Prescription_Settings/';
                                 })
                             }
                         })
                console.log(data);
            }

        }
    });
});

function print_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/doctor_details',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            console.log(data);
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {


                if (data2.msg == "Success") {
                    var data = data2.data;
                    //var data = JSON.parse(data);

                    console.log(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {
                            $('#Chkheader').val(data.Table[i].header);
                            $('a[data-toggle=Chkheader][data-title="' + data.Table[i].header + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkheader][data-title="' + data.Table[i].header + '"]').addClass('active');
                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_profile_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#photolog').empty();
                            var d, n, drloimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].logo != null) {
                                $('#photolog').show();
                                drloimage = filepath + Doctor_Id + '/logo/' + data.Table[i].logo + '?' + n;
                                $('#photolog').append('<a href="' + drloimage + '" target="_blank">Profile Photo</a>');
                                $('#Hdn_profile_image').val(data.Table[i].logo);
                            }

                            // $('#photolog').html(data.Table[i].logo);
                            $('#txtanyother').val(data.Table[i].visit_time);


                            $('#Chkfooter').val(data.Table[i].footer);
                            $('a[data-toggle=Chkfooter][data-title="' + data.Table[i].footer + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkfooter][data-title="' + data.Table[i].footer + '"]').addClass('active');

                            $('#txtMarketing').val(data.Table[i].marketing);

                            $('#ChkPrescription').val(data.Table[i].medicine_prescription);
                            $('a[data-toggle=ChkPrescription][data-title="' + data.Table[i].medicine_prescription + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkPrescription][data-title="' + data.Table[i].medicine_prescription + '"]').addClass('active');

                            //$('#ChkDianostics').val(data.Table[i].lab_record);
                            //$('a[data-toggle=ChkDianostics][data-title="' + data.Table[i].lab_record + '"]').removeClass('not-active');
                            //$('a[data-toggle=ChkDianostics][data-title="' + data.Table[i].lab_record + '"]').addClass('active');


                            $('#ChkVitals').val(data.Table[i].vitals);
                            $('a[data-toggle=ChkVitals][data-title="' + data.Table[i].vitals + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkVitals][data-title="' + data.Table[i].vitals + '"]').addClass('active');

                            $('#ChkBP').val(data.Table[i].bloodpressure);
                            $('a[data-toggle=ChkBP][data-title="' + data.Table[i].bloodpressure + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkBP][data-title="' + data.Table[i].bloodpressure + '"]').addClass('active');

                            $('#ChkBS').val(data.Table[i].bloodsugar);
                            $('a[data-toggle=ChkBS][data-title="' + data.Table[i].bloodsugar + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkBS][data-title="' + data.Table[i].bloodsugar + '"]').addClass('active');

                            $('#ChkWeight').val(data.Table[i].weight);
                            $('a[data-toggle=ChkWeight][data-title="' + data.Table[i].weight + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkWeight][data-title="' + data.Table[i].weight + '"]').addClass('active');

                            $('#ChkHBA1C').val(data.Table[i].HBA1C);
                            $('a[data-toggle=ChkHBA1C][data-title="' + data.Table[i].HBA1C + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkHBA1C][data-title="' + data.Table[i].HBA1C + '"]').addClass('active');

                            $('#Chkpulserate').val(data.Table[i].pulserate);
                            $('a[data-toggle=Chkpulserate][data-title="' + data.Table[i].pulserate + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkpulserate][data-title="' + data.Table[i].pulserate + '"]').addClass('active');

                            $('#ChkExercise').val(data.Table[i].exercise);
                            $('a[data-toggle=ChkExercise][data-title="' + data.Table[i].exercise + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkExercise][data-title="' + data.Table[i].exercise + '"]').addClass('active');

                            $('#ChkDiet').val(data.Table[i].diet);
                            $('a[data-toggle=ChkDiet][data-title="' + data.Table[i].diet + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkDiet][data-title="' + data.Table[i].diet + '"]').addClass('active');

                            $('#Chkvisitdate').val(data.Table[i].visit_date);
                            $('a[data-toggle=Chkvisitdate][data-title="' + data.Table[i].visit_date + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkvisitdate][data-title="' + data.Table[i].visit_date + '"]').addClass('active');

                            $('#Chkother').val(data.Table[i].anyother);
                            $('a[data-toggle=Chkother][data-title="' + data.Table[i].anyother + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkother][data-title="' + data.Table[i].anyother + '"]').addClass('active');

                            $('#lblcustomize').val(data.Table[i].customize_text);

                            $('#mtop').val(data.Table[i].prescription_page_top);
                            $('#mright').val(data.Table[i].prescription_page_right);
                            $('#mbottom').val(data.Table[i].prescription_page_bottom);
                            $('#mleft').val(data.Table[i].prescription_page_left);

                            $('#labChkheader').val(data.Table[i].prescription_page_setting);
                            $('a[data-toggle=labChkheader][data-title="' + data.Table[i].prescription_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=labChkheader][data-title="' + data.Table[i].prescription_page_setting + '"]').addClass('active');

                            $('#Chkdiagnosis').val(data.Table[i].diagnosis);
                            $('a[data-toggle=Chkdiagnosis][data-title="' + data.Table[i].diagnosis + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkdiagnosis][data-title="' + data.Table[i].diagnosis + '"]').addClass('active');

                            $('#ChkECG').val(data.Table[i].ECG);
                            $('a[data-toggle=ChkECG][data-title="' + data.Table[i].ECG + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkECG][data-title="' + data.Table[i].ECG + '"]').addClass('active');

                            $('#ChkTemp').val(data.Table[i].temperature);
                            $('a[data-toggle=ChkTemp][data-title="' + data.Table[i].temperature + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkTemp][data-title="' + data.Table[i].temperature + '"]').addClass('active');

                            $('#ChkRespiratoryRate').val(data.Table[i].respiratory_rate);
                            $('a[data-toggle=ChkRespiratoryRate][data-title="' + data.Table[i].respiratory_rate + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkRespiratoryRate][data-title="' + data.Table[i].respiratory_rate + '"]').addClass('active');

                            $('#ChkProcedure').val(data.Table[i].procedure_details);
                            $('a[data-toggle=ChkProcedure][data-title="' + data.Table[i].procedure_details + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkProcedure][data-title="' + data.Table[i].procedure_details + '"]').addClass('active');

                            $('#ChkComplaints').val(data.Table[i].complaints);
                            $('a[data-toggle=ChkComplaints][data-title="' + data.Table[i].complaints + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkComplaints][data-title="' + data.Table[i].complaints + '"]').addClass('active');

                            $('#Chksignature').val(data.Table[i].signature);
                            $('a[data-toggle=Chksignature][data-title="' + data.Table[i].signature + '"]').removeClass('not-active');
                            $('a[data-toggle=Chksignature][data-title="' + data.Table[i].signature + '"]').addClass('active');

                            $('#ChkDoctorName').val(data.Table[i].doctor_name);
                            $('a[data-toggle=ChkDoctorName][data-title="' + data.Table[i].doctor_name + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkDoctorName][data-title="' + data.Table[i].doctor_name + '"]').addClass('active');

                            $('#ChkNPI').val(data.Table[i].NPI);
                            $('a[data-toggle=ChkNPI][data-title="' + data.Table[i].NPI + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkNPI][data-title="' + data.Table[i].NPI + '"]').addClass('active');

                            $('#Chkdqual').val(data.Table[i].doctor_qualification);
                            $('a[data-toggle=Chkdqual][data-title="' + data.Table[i].doctor_qualification + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkdqual][data-title="' + data.Table[i].doctor_qualification + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_profile_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#doctorsignimg').empty();
                            var d, n, drsigimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].doctor_signature != null) {
                                $('#doctorsignimg').show();
                                drsigimage = filepath + Doctor_Id + '/Sign/' + data.Table[i].doctor_signature + '?' + n;
                                $('#doctorsignimg').append('<a href="' + drsigimage + '" target="_blank">Signature</a>');
                                $('#Hdn_doctorsign').val(data.Table[i].doctor_signature);
                            }
                            $('#ChkAssessment').val(data.Table[i].assessment_report);
                            $('a[data-toggle=ChkAssessment][data-title="' + data.Table[i].assessment_report + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkAssessment][data-title="' + data.Table[i].assessment_report + '"]').addClass('active');

                            $('#ChkAssessment_details').val(data.Table[i].assessment_details);
                            $('a[data-toggle=ChkAssessment_details][data-title="' + data.Table[i].assessment_details + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkAssessment_details][data-title="' + data.Table[i].assessment_details + '"]').addClass('active');

                            $('#Chklifestyle').val(data.Table[i].life_style);
                            $('a[data-toggle=Chklifestyle][data-title="' + data.Table[i].life_style + '"]').removeClass('not-active');
                            $('a[data-toggle=Chklifestyle][data-title="' + data.Table[i].life_style + '"]').addClass('active');

                            $('#P_type').val(data.Table[i].prescription_page_style);
                            $('a[data-toggle=P_type][data-title="' + data.Table[i].prescription_page_style + '"]').removeClass('not-active');
                            $('a[data-toggle=P_type][data-title="' + data.Table[i].prescription_page_style + '"]').addClass('active');

                            $('#ChkSingType').val(data.Table[i].doctor_signature_size);
                            $('a[data-toggle=ChkSingType][data-title="' + data.Table[i].doctor_signature_size + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkSingType][data-title="' + data.Table[i].doctor_signature_size + '"]').addClass('active');

                            $('#generic_name').val(data.Table[i].prescription_generic_name);
                            $('a[data-toggle=generic_name][data-title="' + data.Table[i].prescription_generic_name + '"]').removeClass('not-active');
                            $('a[data-toggle=generic_name][data-title="' + data.Table[i].prescription_generic_name + '"]').addClass('active');

                            $('#gender').val(data.Table[i].gender);
                            $('a[data-toggle=gender][data-title="' + data.Table[i].gender + '"]').removeClass('not-active');
                            $('a[data-toggle=gender][data-title="' + data.Table[i].gender + '"]').addClass('active');

                            $('#fontsize').val(data.Table[i].font_size);

                            $('#fontcolor').val(data.Table[i].table_color);
                            $('a[data-toggle=fontcolor][data-title="' + data.Table[i].table_color + '"]').removeClass('not-active');
                            $('a[data-toggle=fontcolor][data-title="' + data.Table[i].table_color + '"]').addClass('active');
                            $('#fontstyle_1').val(data.Table[i].font_style_1);

                            $('#ChkCsreport').val(data.Table[i].casesheet_report);
                            $('a[data-toggle=ChkCsreport][data-title="' + data.Table[i].casesheet_report + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkCsreport][data-title="' + data.Table[i].casesheet_report + '"]').addClass('active');

                            $('#ChkObservedNutrition').val(data.Table[i].observed_nutrition);
                            $('a[data-toggle=ChkObservedNutrition][data-title="' + data.Table[i].observed_nutrition + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkObservedNutrition][data-title="' + data.Table[i].observed_nutrition + '"]').addClass('active');

                            $('#ChkDental').val(data.Table[i].dental);
                            $('a[data-toggle=ChkDental][data-title="' + data.Table[i].dental + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkDental][data-title="' + data.Table[i].dental + '"]').addClass('active');

                            $('#ChkWritingPrescription').val(data.Table[i].writing_prescription);
                            $('a[data-toggle=ChkWritingPrescription][data-title="' + data.Table[i].writing_prescription + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkWritingPrescription][data-title="' + data.Table[i].writing_prescription + '"]').addClass('active');

                            $('#ChkFutureServices').val(data.Table[i].future_services);
                            $('a[data-toggle=ChkFutureServices][data-title="' + data.Table[i].future_services + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkFutureServices][data-title="' + data.Table[i].future_services + '"]').addClass('active');

                            $('#ChkPMConn').val(data.Table[i].pre_morbid);
                            $('a[data-toggle=ChkPMConn][data-title="' + data.Table[i].pre_morbid + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkPMConn][data-title="' + data.Table[i].pre_morbid + '"]').addClass('active');

                            $('#Chkinv').val(data.Table[i].investigation);
                            $('a[data-toggle=Chkinv][data-title="' + data.Table[i].investigation + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkinv][data-title="' + data.Table[i].investigation + '"]').addClass('active');

                            $('#Chkins').val(data.Table[i].instructions);
                            $('a[data-toggle=Chkins][data-title="' + data.Table[i].instructions + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkins][data-title="' + data.Table[i].instructions + '"]').addClass('active');

                            $('#Chkobs').val(data.Table[i].observation);
                            $('a[data-toggle=Chkobs][data-title="' + data.Table[i].observation + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkobs][data-title="' + data.Table[i].observation + '"]').addClass('active');

                            $('#ChkDiag').val(data.Table[i].diagnosis_observation);
                            $('a[data-toggle=ChkDiag][data-title="' + data.Table[i].diagnosis_observation + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkDiag][data-title="' + data.Table[i].diagnosis_observation + '"]').addClass('active');

                            $('#chkvas').val(data.Table[i].vas);
                            $('a[data-toggle=chkvas][data-title="' + data.Table[i].vas + '"]').removeClass('not-active');
                            $('a[data-toggle=chkvas][data-title="' + data.Table[i].vas + '"]').addClass('active');

                            $('#Chknotes').val(data.Table[i].notes);
                            $('a[data-toggle=Chknotes][data-title="' + data.Table[i].notes + '"]').removeClass('not-active');
                            $('a[data-toggle=Chknotes][data-title="' + data.Table[i].notes + '"]').addClass('active');

                            $('#Chkxrayfind').val(data.Table[i].xray_findings);
                            $('a[data-toggle=Chkxrayfind][data-title="' + data.Table[i].xray_findings + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkxrayfind][data-title="' + data.Table[i].xray_findings + '"]').addClass('active');

                            $('#Chkadvice').val(data.Table[i].advice);
                            $('a[data-toggle=Chkadvice][data-title="' + data.Table[i].advice + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkadvice][data-title="' + data.Table[i].advice + '"]').addClass('active');

                            $('#Chkcounselling').val(data.Table[i].counselling);
                            $('a[data-toggle=Chkcounselling][data-title="' + data.Table[i].counselling + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkcounselling][data-title="' + data.Table[i].counselling + '"]').addClass('active');

                            $('#Chklab_findings').val(data.Table[i].lab_findings);
                            $('a[data-toggle=Chklab_findings][data-title="' + data.Table[i].lab_findings + '"]').removeClass('not-active');
                            $('a[data-toggle=Chklab_findings][data-title="' + data.Table[i].lab_findings + '"]').addClass('active');

                            $('#Chklab_findings').val(data.Table[i].lab_findings);
                            $('a[data-toggle=Chklab_findings][data-title="' + data.Table[i].lab_findings + '"]').removeClass('not-active');
                            $('a[data-toggle=Chklab_findings][data-title="' + data.Table[i].lab_findings + '"]').addClass('active');

                            $('#Chkxray_findings').val(data.Table[i].xray_findings_new);
                            $('a[data-toggle=Chkxray_findings][data-title="' + data.Table[i].xray_findings_new + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkxray_findings][data-title="' + data.Table[i].xray_findings_new + '"]').addClass('active');

                            $('#Chkreview_notes').val(data.Table[i].review_notes);
                            $('a[data-toggle=Chkreview_notes][data-title="' + data.Table[i].review_notes + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkreview_notes][data-title="' + data.Table[i].review_notes + '"]').addClass('active');


                            $('#Chkpast_medical_history').val(data.Table[i].past_medical_history);
                            $('a[data-toggle=Chkpast_medical_history][data-title="' + data.Table[i].past_medical_history + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkpast_medical_history][data-title="' + data.Table[i].past_medical_history + '"]').addClass('active');

                            $('#Chkpast_significant_adverse_events').val(data.Table[i].past_adverse_events);
                            $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + data.Table[i].past_adverse_events + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkpast_significant_adverse_events][data-title="' + data.Table[i].past_adverse_events + '"]').addClass('active');

                            $('#Chkgeneral_examination').val(data.Table[i].general_examination);
                            $('a[data-toggle=Chkgeneral_examination][data-title="' + data.Table[i].general_examination + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkgeneral_examination][data-title="' + data.Table[i].general_examination + '"]').addClass('active');

                            $('#Chklocal_examination').val(data.Table[i].local_examination);
                            $('a[data-toggle=Chklocal_examination][data-title="' + data.Table[i].local_examination + '"]').removeClass('not-active');
                            $('a[data-toggle=Chklocal_examination][data-title="' + data.Table[i].local_examination + '"]').addClass('active');

                            $('#Chkabdomen_girth').val(data.Table[i].abdomen_girth);
                            $('a[data-toggle=Chkabdomen_girth][data-title="' + data.Table[i].abdomen_girth + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkabdomen_girth][data-title="' + data.Table[i].abdomen_girth + '"]').addClass('active');
                        }
                    }
                }
                else {
                    console.log(data);
                }



                //updatePreview();
            }
        }

    });
}

$('#documents').change(function () {
    LogoImgUpload()
});

function LogoImgUpload() {

    var uploadpath = $('#documents').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);

    if (window.FormData !== undefined) {

        var fileUpload = $("#documents").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
               
        $.when(checkimagedimensionvalidation(fileUpload.files[0], 512, 512)).
         done(function (Results) {
             if(Results=='Success')
             { 
        for (var i = 0; i < files.length; i++) {
            fileData.append(files[i].name, files[i]);
        }
        fileData.append('username', 'Manas');

        $.ajax({
            url: '/Prescription_Settings/UploadPhotoFiles',
            type: "POST",
            contentType: false, // Not to set any content header
            processData: false, // Not to process data
            data: fileData,
            success: function (result) {
                console.log(result);
                $.each(result, function (i, emp) {
                    $('#Hdn_profile_image').val(emp);
                    var filepath = $('#hdnfilepath1').val();
                    var profilephoto = $('#Hdn_profile_image').val();
                    var Doctor_Id = $('#myHiddenVar').val();
                    var d, n, drloimage;
                    d = new Date();
                    n = d.getTime();
                    drloimage = filepath + Doctor_Id + '/logo/' + profilephoto + '?' + n;
                    $('#photolog').empty();
                    $('#photolog').append('<a href="' + drloimage + '" target="_blank">Profile Photo</a>');
                });
            }
        });
             }
             else {
                 $('#documents').val('');
              // $('#imagefile').val('');
                 $('#photolog').empty();
             }          
         });

    }
}

$('#doctorsign').change(function () {
    signatureUpload()
});

function signatureUpload() {

    var uploadpath = $('#doctorsign').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);

    if (window.FormData !== undefined) {

        var fileUpload = $("#doctorsign").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        $.when(checkimagedimensionvalidation(fileUpload.files[0], 512, 512)).
        done(function (Results) {
            debugger;
            if(Results=='Success')
            { 

                for (var i = 0; i < files.length; i++) {
                    fileData.append(files[i].name, files[i]);
                }
                fileData.append('username', 'Manas');

                $.ajax({
                    url: '/Prescription_Settings/UploadSignFiles',
                    type: "POST",
                    contentType: false, // Not to set any content header
                    processData: false, // Not to process data
                    data: fileData,
                    success: function (result) {
                        console.log(result);
                        $.each(result, function (i, emp) {
                            $('#Hdn_doctorsign').val(emp);
                            var filepath = $('#hdnfilepath1').val();
                            var photo = $('#hdnPhoto').val();
                            var profilephoto = $('#Hdn_doctorsign').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            var d, n, drsigimage;
                            d = new Date();
                            n = d.getTime();
                            drsigimage = filepath + Doctor_Id + '/Sign/' + profilephoto + '?' + n;
                            $('#doctorsignimg').empty();
                            $('#doctorsignimg').show();
                            $('#doctorsignimg').append('<a href="' + drsigimage + '" target="_blank">Signature</a>');
                        });
                    }
                });
            }
            else {
                $('#doctorsign').val('');
                $('#photolog').empty();
            }
        });
    }
}

//invoice sections started

$('#btninvoice').click(function () {
    debugger;
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        invoice_page_setting: $('#labChkheader2').val(),
        invoice_page_top: $('#mtop2').val(),
        invoice_page_bottom: $('#mbottom2').val(),
        invoice_page_left: $('#mleft2').val(),
        invoice_page_right: $('#mright2').val(),
        invoice_header: $('#Chkheader2').val(),
        invoice_logo: $('#Hdn_invoice_img').val(),
        invoice_footer: $('#Chkfooter2').val(),
        invoice_marketing: $('#txtMarketing2').val(),
        invoice_anyother: $('#txtanyother2').val(),
        invoice: $('#ChkInvoice').val(),
        invoice_customize_id: $('#Chkother2').val(),
        invoice_customize: $('#lblcustomize2').val(),
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/invoice_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            debugger;
            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                debugger;
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Invoice Saved Successfully',
                        {
                            closeButton: true,
                            progressBar: true,
                            allowHtml: true,
                            timeOut: 20000000,

                            onShown: function (toast) {
                                $("#confirmationRevertYes").click(function () {
                                    window.location.href = '/Prescription_Settings/';
                                })
                            }
                        })

                
            }
            else {
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Invoice Saved Successfully',
                        {
                            closeButton: true,
                            progressBar: true,
                            allowHtml: true,
                            timeOut: 20000000,

                            onShown: function (toast) {
                                $("#confirmationRevertYes").click(function () {
                                    window.location.href = '/Prescription_Settings/';
                                })
                            }
                        })
                console.log(data);
            }

        }
    });
});

function invoice_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/invoice_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {

                            $('#labChkheader2').val(data.Table[i].invoice_page_setting);
                            $('a[data-toggle=labChkheader2][data-title="' + data.Table[i].invoice_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=labChkheader2][data-title="' + data.Table[i].invoice_page_setting + '"]').addClass('active');

                            $('#mtop2').val(data.Table[i].invoice_page_top);
                            //$('#mright2').val(data.Table[i].invoice_page_right);
                            $('#mbottom2').val(data.Table[i].invoice_page_bottom);
                            //$('#mleft2').val(data.Table[i].invoice_page_left);


                            $('#Chkheader2').val(data.Table[i].invoice_header);
                            $('a[data-toggle=Chkheader2][data-title="' + data.Table[i].invoice_header + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkheader2][data-title="' + data.Table[i].invoice_header + '"]').addClass('active');


                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_profile_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#invoicelog').empty();
                            var d, n, drinimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].invoice_logo != null || data.Table[i].invoice_logo != "") {
                                drinimage = filepath + Doctor_Id + '/invoicelogo/' + data.Table[i].invoice_logo + '?' + n;
                                $('#invoicelog').append('<a href="' + drinimage + '" target="_blank">invoice logo</a>');
                                $('#Hdn_invoice_img').val(data.Table[i].invoice_logo);
                            }

                            // $('#photolog').html(data.Table[i].logo);

                            $('#Chkfooter2').val(data.Table[i].invoice_footer);
                            $('a[data-toggle=Chkfooter2][data-title="' + data.Table[i].invoice_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkfooter2][data-title="' + data.Table[i].invoice_footer + '"]').addClass('active');

                            $('#txtMarketing2').val(data.Table[i].invoice_marketing);
                            $('#txtanyother2').val(data.Table[i].invoice_anyother);

                            $('#ChkInvoice').val(data.Table[i].invoice);
                            $('a[data-toggle=ChkInvoice][data-title="' + data.Table[i].invoice + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkInvoice][data-title="' + data.Table[i].invoice + '"]').addClass('active');

                            $('#Chkother2').val(data.Table[i].invoice_customize_id);
                            $('a[data-toggle=Chkother2][data-title="' + data.Table[i].invoice_customize_id + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkother2][data-title="' + data.Table[i].invoice_customize_id + '"]').addClass('active');


                            $('#lblcustomize2').val(data.Table[i].invoice_customize);

                        }
                    }
                }
                else {
                    console.log(data);
                }


            }
        }

    });
}

$('#documents2').change(function () {
    invoiceLogoUpload();
});

function invoiceLogoUpload() {
    var uploadpath = $('#documents2').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);
    if (window.FormData !== undefined) {
        var fileUpload = $("#documents2").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        for (var i = 0; i < files.length; i++) {
            fileData.append(files[i].name, files[i]);
        }
        fileData.append('username', 'Manas');
        $.ajax({
            url: '/Prescription_Settings/UploadPhotoFilesinvoice',
            type: "POST",
            contentType: false, // Not to set any content header
            processData: false, // Not to process data
            data: fileData,
            success: function (result) {
                console.log(result);
                $.each(result, function (i, emp) {
                    $('#Hdn_invoice_img').val(emp);
                    var filepath, photo, profilephoto, Doctor_Id, d, n, drinimage;
                    filepath = $('#hdnfilepath1').val();
                    photo = $('#hdnPhoto').val();
                    profilephoto = $('#Hdn_invoice_img').val();
                    Doctor_Id = $('#myHiddenVar').val();
                    d = new Date();
                    n = d.getTime();
                    drinimage = filepath + Doctor_Id + '/invoicelogo/' + profilephoto + '?' + n;
                    $('#invoicelog').empty();
                    // $('#profile-photo').append('<a href="' + filepath + Doctor_Id + photo + profilephoto + '" target="_blank">Profile Photo</a>');
                    $('#invoicelog').append('<a href="' + drinimage + '" target="_blank">invoice logo</a>');
                });
            }
        });
    }
}
//invoice sections ended


//lab sections started

$('#btnLabsubmit').click(function () {
    debugger;
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        lab_page_setting: $('#labChkheader3').val(),
        lab_page_top: $('#mtop3').val(),
        lab_page_bottom: $('#mbottom3').val(),
        lab_page_left: $('#mleft3').val(),
        lab_page_right: $('#mright3').val(),
        lab_header: $('#Chkheader3').val(),
        lab_logo: $('#Hdn_lab_image').val(),
        lab_footer: $('#Chkfooter3').val(),
        lab_marketing: $('#txtMarketing3').val(),
        lab_anyother: $('#txtanyother3').val(),
        lab: $('#ChkLabReports').val(),
        lab_customize_id: $('#Chkother3').val(),
        lab_customize: $('#lblcustomize3').val(),
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/lab_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            debugger;
            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                toastr.success("<button type='button' id='confirmationRevertLab' class='btn btn-warning btn-xs mt20'>OK</button>", 'Lab Results Saved Successfully',
                       {
                           closeButton: true,
                           progressBar: true,
                           allowHtml: true,
                           timeOut: 20000000,

                           onShown: function (toast) {
                               $("#confirmationRevertLab").click(function () {
                                   window.location.href = '/Prescription_Settings/';
                               })
                           }
                       })
               
            }
            else {
                console.log(data);
            }

        }
    });
});

function lab_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/lab_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {

                            $('#labChkheader3').val(data.Table[i].lab_page_setting);
                            $('a[data-toggle=labChkheader3][data-title="' + data.Table[i].lab_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=labChkheader3][data-title="' + data.Table[i].lab_page_setting + '"]').addClass('active');

                            $('#mtop3').val(data.Table[i].lab_page_top);
                            $('#mright3').val(data.Table[i].lab_page_right);
                            $('#mbottom3').val(data.Table[i].lab_page_bottom);
                            $('#mleft3').val(data.Table[i].lab_page_left);

                            $('#Chkheader3').val(data.Table[i].lab_header);
                            $('a[data-toggle=Chkheader3][data-title="' + data.Table[i].lab_header + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkheader3][data-title="' + data.Table[i].lab_header + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_profile_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#lablog').empty();
                            var d, n, laimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].lab_logo == null || data.Table[i].lab_logo == "") {
                            }
                            else {
                                laimage = filepath + Doctor_Id + '/lablogo/' + data.Table[i].lab_logo + '?' + n;
                                $('#lablog').append('<a href="' + laimage + '" target="_blank">lab logo</a>');
                                $('#Hdn_lab_image').val(data.Table[i].lab_logo);
                            }
                            // $('#photolog').html(data.Table[i].logo);

                            $('#Chkfooter3').val(data.Table[i].lab_footer);
                            $('a[data-toggle=Chkfooter3][data-title="' + data.Table[i].lab_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkfooter3][data-title="' + data.Table[i].lab_footer + '"]').addClass('active');

                            $('#txtMarketing3').val(data.Table[i].lab_marketing);
                            $('#txtanyother3').val(data.Table[i].lab_anyother);

                            $('#ChkLabReports').val(data.Table[i].lab);
                            $('a[data-toggle=ChkLabReports][data-title="' + data.Table[i].lab + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkLabReports][data-title="' + data.Table[i].lab + '"]').addClass('active');

                            $('#Chkother3').val(data.Table[i].lab_customize_id);
                            $('a[data-toggle=Chkother3][data-title="' + data.Table[i].lab_customize_id + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkother3][data-title="' + data.Table[i].lab_customize_id + '"]').addClass('active');


                            $('#lblcustomize3').val(data.Table[i].lab_customize);

                        }
                    }
                }
                else {
                    console.log(data);
                }
            }
        }

    });
}


$('#documents3').change(function () {
    LabLogoUpload();
});

function LabLogoUpload() {

    var uploadpath = $('#documents3').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);

    if (window.FormData !== undefined) {

        var fileUpload = $("#documents3").get(0);
        var files = fileUpload.files;

        // Create FormData object
        var fileData = new FormData();

        // Looping over all files and add it to FormData object
        for (var i = 0; i < files.length; i++) {
            fileData.append(files[i].name, files[i]);
        }

        // Adding one more key to FormData object
        fileData.append('username', 'Manas');

        $.ajax({
            url: '/Prescription_Settings/UploadPhotoFileslab',
            type: "POST",
            contentType: false, // Not to set any content header
            processData: false, // Not to process data
            data: fileData,
            success: function (result) {
                console.log(result);
                $.each(result, function (i, emp) {
                    $('#Hdn_lab_image').val(emp);
                    var filepath, photo, profilephoto, Doctor_Id, d, n, laimage;
                    filepath = $('#hdnfilepath1').val();
                    photo = $('#hdnPhoto').val();
                    profilephoto = $('#Hdn_lab_image').val();
                    Doctor_Id = $('#myHiddenVar').val();
                    //$('#profile-photo').empty();
                    d = new Date();
                    n = d.getTime();
                    laimage = filepath + Doctor_Id + '/lablogo/' + profilephoto + '?' + n;
                    $('#lablog').empty();
                    // $('#profile-photo').append('<a href="' + filepath + Doctor_Id + photo + profilephoto + '" target="_blank">Profile Photo</a>');
                    $('#lablog').append('<a href="' + laimage + '" target="_blank">lab logo</a>');
                });
            }
        });
    }
}

//lab sections ended


//procedure sections started


$('#btnproceduresubmit').click(function () {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        procedure_page_setting: $('#ProcedureChkheader4').val(),
        procedure_page_top: $('#mtop4').val(),
        procedure_page_bottom: $('#mbottom4').val(),
        procedure_page_left: $('#mleft4').val(),
        procedure_page_right: $('#mright4').val(),
        procedure_header: $('#Chkheader4').val(),
        procedure_logo: $('#Hdn_procedure_image').val(),
        procedure_footer: $('#Chkfooter4').val(),
        procedure_marketing: $('#txtMarketing4').val(),
        procedure_anyother: $('#txtanyother4').val(),
        procedure_val: $('#ChkprocedureReports').val(),
        procedure_customize_id: $('#Chkother4').val(),
        procedure_customize: $('#lblcustomize4').val(),
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/procedure_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {

            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Procedure Saved Successfully',
                       {
                           closeButton: true,
                           progressBar: true,
                           allowHtml: true,
                           timeOut: 20000000,

                           onShown: function (toast) {
                               $("#confirmationRevertYes").click(function () {
                                   window.location.href = '/Prescription_Settings/';
                               })
                           }
                       })
                
            }
            else {
                console.log(data);
            }

        }
    });
});

function procedure_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/procedure_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {

                            $('#ProcedureChkheader4').val(data.Table[i].procedure_page_setting);
                            $('a[data-toggle=ProcedureChkheader4][data-title="' + data.Table[i].procedure_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=ProcedureChkheader4][data-title="' + data.Table[i].procedure_page_setting + '"]').addClass('active');

                            $('#mtop4').val(data.Table[i].procedure_page_top);
                            //$('#mright4').val(data.Table[i].procedure_page_right);
                            $('#mbottom4').val(data.Table[i].procedure_page_bottom);
                            //$('#mleft4').val(data.Table[i].procedure_page_left);


                            $('#Chkheader4').val(data.Table[i].procedure_header);
                            $('a[data-toggle=Chkheader4][data-title="' + data.Table[i].procedure_header + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkheader4][data-title="' + data.Table[i].procedure_header + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_profile_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#procedurelog').empty();
                            var d, n, primage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].procedure_logo == null || data.Table[i].procedure_logo == "") {
                            }
                            else {
                                primage = filepath + Doctor_Id + '/procedurelogo/' + data.Table[i].procedure_logo + '?' + n;
                                $('#procedurelog').append('<a href="' + primage + '" target="_blank">procedure logo</a>');
                                $('#Hdn_procedure_image').val(data.Table[i].procedure_logo);
                            }

                            // $('#photolog').html(data.Table[i].logo);

                            $('#Chkfooter4').val(data.Table[i].procedure_footer);
                            $('a[data-toggle=Chkfooter4][data-title="' + data.Table[i].procedure_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkfooter4][data-title="' + data.Table[i].procedure_footer + '"]').addClass('active');

                            $('#txtMarketing4').val(data.Table[i].procedure_marketing);
                            $('#txtanyother4').val(data.Table[i].procedure_anyother);

                            $('#ChkprocedureReports').val(data.Table[i].procedure_val);
                            $('a[data-toggle=ChkprocedureReports][data-title="' + data.Table[i].procedure_val + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkprocedureReports][data-title="' + data.Table[i].procedure_val + '"]').addClass('active');

                            $('#Chkother4').val(data.Table[i].procedure_customize_id);
                            $('a[data-toggle=Chkother4][data-title="' + data.Table[i].procedure_customize_id + '"]').removeClass('not-active');
                            $('a[data-toggle=Chkother4][data-title="' + data.Table[i].procedure_customize_id + '"]').addClass('active');


                            $('#lblcustomize4').val(data.Table[i].procedure_customize);

                        }
                    }
                }
                else {
                    console.log(data);
                }

            }
        }

    });
}


$('#documents4').change(function () {
    procedureLogoUpload();
});

function procedureLogoUpload() {

    var uploadpath = $('#documents4').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);

    if (window.FormData !== undefined) {

        var fileUpload = $("#documents4").get(0);
        var files = fileUpload.files;

        // Create FormData object
        var fileData = new FormData();
        $.when(checkimagedimensionvalidation(fileUpload.files[0], 512, 512)).
        done(function (Results) {
            if(Results=='Success')
            { 

                // Looping over all files and add it to FormData object
                for (var i = 0; i < files.length; i++) {
                    fileData.append(files[i].name, files[i]);
                }

                // Adding one more key to FormData object
                fileData.append('username', 'Manas');

                $.ajax({
                    url: '/Prescription_Settings/UploadPhotoFilesprocedure',
                    type: "POST",
                    contentType: false, // Not to set any content header
                    processData: false, // Not to process data
                    data: fileData,
                    success: function (result) {
                        console.log(result);
                        $.each(result, function (i, emp) {
                            $('#Hdn_procedure_image').val(emp);
                            var filepath, photo, profilephoto, Doctor_Id, d, n, primage;
                            filepath = $('#hdnfilepath1').val();
                            photo = $('#hdnPhoto').val();
                            profilephoto = $('#Hdn_procedure_image').val();
                            Doctor_Id = $('#myHiddenVar').val();
                            d = new Date();
                            n = d.getTime();
                            primage = filepath + Doctor_Id + '/procedurelogo/' + profilephoto + '?' + n;
                            $('#procedurelog').empty();
                            $('#procedurelog').append('<a href="' + primage + '" target="_blank">procedure logo</a>');
                        });
                    }
                });
            }
            else {
                $('#documents4').val('');            
                $('#photolog').empty();
            }          
        });
    }
}

//procedure sections ended



//diet sections started


$('#btndietproceduresubmit').click(function () {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        deit_page_setting: $('#dietChkheader4').val(),
        deit_page_top: $('#diettop4').val(),
        deit_page_bottom: $('#dietbottom4').val(),
        deit_page_left: $('#dietleft4').val(),
        deit_page_right: $('#dietht4').val(),
        deit_header: $('#diet1Chkheader4').val(),
        deit_logo: $('#Hdn_diet_image').val(),
        deit_footer: $('#dietChkfooter4').val(),
        deit_marketing: $('#diettxtMarketing4').val(),
        deit_anyother: $('#diettxtanyother4').val(),
        deit_val: $('#dietChkprocedureReports').val(),
        deit_customize_id: $('#dietChkother4').val(),
        deit_customize: $('#dietlblcustomize4').val(),
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/deit_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {

            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Diet Saved Successfully',
                       {
                           closeButton: true,
                           progressBar: true,
                           allowHtml: true,
                           timeOut: 20000000,

                           onShown: function (toast) {
                               $("#confirmationRevertYes").click(function () {
                                   window.location.href = '/Prescription_Settings/';
                               })
                           }
                       })
                
            }
            else {
                console.log(data);
            }

        }
    });
});

function diet_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/deit_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {

            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {

                            $('#dietChkheader4').val(data.Table[i].diet_page_setting);
                            $('a[data-toggle=dietChkheader4][data-title="' + data.Table[i].diet_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=dietChkheader4][data-title="' + data.Table[i].diet_page_setting + '"]').addClass('active');

                            $('#diettop4').val(data.Table[i].diet_page_top);
                            $('#dietht4').val(data.Table[i].diet_page_right);
                            $('#dietbottom4').val(data.Table[i].diet_page_bottom);
                            $('#dietleft4').val(data.Table[i].diet_page_left);

                            $('#diet1Chkheader4').val(data.Table[i].diet_header);
                            $('a[data-toggle=diet1Chkheader4][data-title="' + data.Table[i].diet_header + '"]').removeClass('not-active');
                            $('a[data-toggle=diet1Chkheader4][data-title="' + data.Table[i].diet_header + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_diet_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#dietlog').empty();
                            var d, n, dtimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].diet_logo == null || data.Table[i].diet_logo == "") {
                            }
                            else {
                                dtimage = filepath + Doctor_Id + '/dietlogo/' + data.Table[i].diet_logo + '?' + n;
                                $('#dietlog').append('<a href="' + dtimage + '" target="_blank">Diet logo</a>');
                                $('#Hdn_diet_image').val(data.Table[i].diet_logo);
                            }

                            $('#dietChkfooter4').val(data.Table[i].diet_footer);
                            $('a[data-toggle=dietChkfooter4][data-title="' + data.Table[i].diet_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=dietChkfooter4][data-title="' + data.Table[i].diet_footer + '"]').addClass('active');

                            $('#diettxtMarketing4').val(data.Table[i].diet_marketing);
                            $('#diettxtanyother4').val(data.Table[i].diet_anyother);

                            $('#dietChkprocedureReports').val(data.Table[i].diet_val);
                            $('a[data-toggle=dietChkprocedureReports][data-title="' + data.Table[i].diet_val + '"]').removeClass('not-active');
                            $('a[data-toggle=dietChkprocedureReports][data-title="' + data.Table[i].diet_val + '"]').addClass('active');

                            $('#dietChkother4').val(data.Table[i].diet_customize_id);
                            $('a[data-toggle=dietChkother4][data-title="' + data.Table[i].diet_customize_id + '"]').removeClass('not-active');
                            $('a[data-toggle=dietChkother4][data-title="' + data.Table[i].diet_customize_id + '"]').addClass('active');

                            $('#dietlblcustomize4').val(data.Table[i].diet_customize);

                        }
                    }
                }
                else {
                    console.log(data);
                }
            }
        }

    });
}


$('#dietdocuments4').change(function () {
    dietLogoUpload();
});

function dietLogoUpload() {
    var uploadpath = $('#dietdocuments4').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);
    if (window.FormData !== undefined) {
        var fileUpload = $("#dietdocuments4").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        $.when(checkimagedimensionvalidation(fileUpload.files[0], 512, 512)).
          done(function (Results) {
              if(Results=='Success')
              { 
                  for (var i = 0; i < files.length; i++) {
                      fileData.append(files[i].name, files[i]);
                  }
                  fileData.append('username', 'Manas');
                  $.ajax({
                      url: '/Prescription_Settings/UploadPhotoFilesdiet',
                      type: "POST",
                      contentType: false, // Not to set any content header
                      processData: false, // Not to process data
                      data: fileData,
                      success: function (result) {
                          console.log(result);
                          $.each(result, function (i, emp) {
                              $('#Hdn_diet_image').val(emp);
                              var filepath, photo, profilephoto, Doctor_Id, d, n, dtimage;
                              filepath = $('#hdnfilepath1').val();
                              photo = $('#hdnPhoto').val();
                              profilephoto = $('#Hdn_diet_image').val();
                              Doctor_Id = $('#myHiddenVar').val();
                              d = new Date();
                              n = d.getTime();
                              dtimage = filepath + Doctor_Id + '/dietlogo/' + profilephoto + '?' + n;
                              $('#dietlog').empty();
                              $('#dietlog').append('<a href="' + dtimage + '" target="_blank">Diet logo</a>');
                          });
                      }
                  });
              }

              else {
                  $('#dietdocuments4').val('');                
                  $('#photolog').empty();
              }            
          });

    }
}

//diet sections ended


//labinvoice sections started


$('#btnlabinproceduresubmit').click(function () {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        labinvoice_page_setting: $('#labinProcedureChkheader4').val(),
        labinvoice_page_top: $('#labinmtop4').val(),
        labinvoice_page_bottom: $('#labinmbottom4').val(),
        labinvoice_page_left: $('#labinmleft4').val(),
        labinvoice_page_right: $('#labinmright4').val(),
        labinvoice_header: $('#labinChkheader4').val(),
        labinvoice_logo: $('#Hdn_labin_image').val(),
        labinvoice_footer: $('#labinChkfooter4').val(),
        labinvoice_marketing: $('#labintxtMarketing4').val(),
        labinvoice_anyother: $('#labintxtanyother4').val(),
        labinvoice_val: $('#labinChkprocedureReports').val(),
        labinvoice_customize_id: $('#labinChkother4').val(),
        labinvoice_customize: $('#labinlblcustomize4').val(),
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/laninvoice_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {

            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Lab Invoice Saved Successfully',
                       {
                           closeButton: true,
                           progressBar: true,
                           allowHtml: true,
                           timeOut: 20000000,

                           onShown: function (toast) {
                               $("#confirmationRevertYes").click(function () {
                                   window.location.href = '/Prescription_Settings/';
                               })
                           }
                       })
               
            }
            else {
                console.log(data);
            }

        }
    });
});

function labinvoice_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/laninvoice_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {

                            $('#labinProcedureChkheader4').val(data.Table[i].labinvoice_page_setting);
                            $('a[data-toggle=labinProcedureChkheader4][data-title="' + data.Table[i].labinvoice_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=labinProcedureChkheader4][data-title="' + data.Table[i].labinvoice_page_setting + '"]').addClass('active');

                            $('#labinmtop4').val(data.Table[i].labinvoice_page_top);
                            //$('#labinmright4').val(data.Table[i].labinvoice_page_right);
                            $('#labinmbottom4').val(data.Table[i].labinvoice_page_bottom);
                            //$('#labinmleft4').val(data.Table[i].labinvoice_page_left);

                            $('#labinChkheader4').val(data.Table[i].labinvoice_header);
                            $('a[data-toggle=labinChkheader4][data-title="' + data.Table[i].labinvoice_header + '"]').removeClass('not-active');
                            $('a[data-toggle=labinChkheader4][data-title="' + data.Table[i].labinvoice_header + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_labin_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#labinprocedurelog').empty();
                            var d, n, linimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].labinvoice_logo == null || data.Table[i].labinvoice_logo == "") {
                            }
                            else {
                                linimage = filepath + Doctor_Id + '/labinvoice/' + data.Table[i].labinvoice_logo + '?' + n;
                                $('#labinprocedurelog').append('<a href="' + linimage + '" target="_blank">Lab Invoice logo</a>');
                                $('#Hdn_labin_image').val(data.Table[i].labinvoice_logo);
                            }
                            $('#labinChkfooter4').val(data.Table[i].labinvoice_footer);
                            $('a[data-toggle=labinChkfooter4][data-title="' + data.Table[i].labinvoice_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=labinChkfooter4][data-title="' + data.Table[i].labinvoice_footer + '"]').addClass('active');

                            $('#labintxtMarketing4').val(data.Table[i].labinvoice_marketing);
                            $('#labintxtanyother4').val(data.Table[i].labinvoice_anyother);

                            $('#labinChkprocedureReports').val(data.Table[i].labinvoice_val);
                            $('a[data-toggle=labinChkprocedureReports][data-title="' + data.Table[i].labinvoice_val + '"]').removeClass('not-active');
                            $('a[data-toggle=labinChkprocedureReports][data-title="' + data.Table[i].labinvoice_val + '"]').addClass('active');

                            $('#labinChkother4').val(data.Table[i].labinvoice_customize_id);
                            $('a[data-toggle=labinChkother4][data-title="' + data.Table[i].labinvoice_customize_id + '"]').removeClass('not-active');
                            $('a[data-toggle=labinChkother4][data-title="' + data.Table[i].labinvoice_customize_id + '"]').addClass('active');

                            $('#labinlblcustomize4').val(data.Table[i].labinvoice_customize);

                        }
                    }
                }
                else {
                    console.log(data);
                }


            }
        }

    });
}


$('#labindocuments4').change(function () {
    labinvoiceLogoUpload();
});

function labinvoiceLogoUpload() {
    var uploadpath = $('#labindocuments4').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);
    if (window.FormData !== undefined) {
        var fileUpload = $("#labindocuments4").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        for (var i = 0; i < files.length; i++) {
            fileData.append(files[i].name, files[i]);
        }
        fileData.append('username', 'Manas');
        $.ajax({
            url: '/Prescription_Settings/UploadPhotoFileslabinvoice',
            type: "POST",
            contentType: false, // Not to set any content header
            processData: false, // Not to process data
            data: fileData,
            success: function (result) {
                console.log(result);
                $.each(result, function (i, emp) {
                    $('#Hdn_labin_image').val(emp);
                    var filepath, photo, profilephoto, Doctor_Id, d, n, linimage;
                    filepath = $('#hdnfilepath1').val();
                    photo = $('#hdnPhoto').val();
                    profilephoto = $('#Hdn_labin_image').val();
                    Doctor_Id = $('#myHiddenVar').val();
                    d = new Date();
                    n = d.getTime();
                    linimage = filepath + Doctor_Id + '/labinvoice/' + profilephoto + '?' + n;
                    $('#labinprocedurelog').empty();
                    $('#labinprocedurelog').append('<a href="' + linimage + '" target="_blank">Lab Invoice logo</a>');
                });
            }
        });
    }
}

//labinvoice sections ended


//Medical certificate print setting started

$('#btnMClabinproceduresubmit').click(function () {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        medical_certificate_page_setting: $('#MClabinProcedureChkheader4').val(),
        medical_certificate_page_top: $('#MClabinmtop4').val(),
        medical_certificate_page_bottom: $('#MClabinmbottom4').val(),
        medical_certificate_page_left: $('#MClabinmleft4').val(),
        medical_certificate_page_right: $('#MClabinmright4').val(),
        medical_certificate_header: $('#MClabinChkheader4').val(),
        medical_certificate_logo: $('#Hdn_MClabin_image').val(),
        medical_certificate_footer: $('#MClabinChkfooter4').val(),
        medical_certificate_marketing: $('#MClabintxtMarketing4').val(),
        medical_certificate_anyother: $('#MClabintxtanyother4').val(),
        medical_certificate_val: $('#MClabinChkprocedureReports').val(),
        medical_certificate_customize_id: $('#MClabinChkother4').val(),
        medical_certificate_customize: $('#MClabinlblcustomize4').val(),
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/medicalcertificate_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {

            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Medical Certificate Saved Successfully',
                       {
                           closeButton: true,
                           progressBar: true,
                           allowHtml: true,
                           timeOut: 20000000,

                           onShown: function (toast) {
                               $("#confirmationRevertYes").click(function () {
                                   window.location.href = '/Prescription_Settings/';
                               })
                           }
                       })
                
            }
            else {
                console.log(data);
            }

        }
    });
});

function medicalcertificate_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S'
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/medicalcertificate_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            $('#loaderimg').hide();
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {

                            $('#MClabinProcedureChkheader4').val(data.Table[i].medical_certificate_page_setting);
                            $('a[data-toggle=MClabinProcedureChkheader4][data-title="' + data.Table[i].medical_certificate_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=MClabinProcedureChkheader4][data-title="' + data.Table[i].medical_certificate_page_setting + '"]').addClass('active');

                            $('#MClabinmtop4').val(data.Table[i].medical_certificate_page_top);
                            $('#MClabinmbottom4').val(data.Table[i].medical_certificate_page_bottom);

                            $('#MClabinChkheader4').val(data.Table[i].medical_certificate_header);
                            $('a[data-toggle=MClabinChkheader4][data-title="' + data.Table[i].medical_certificate_header + '"]').removeClass('not-active');
                            $('a[data-toggle=MClabinChkheader4][data-title="' + data.Table[i].medical_certificate_header + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var profilephoto = $('#Hdn_MClabin_image').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#MClabinprocedurelog').empty();
                            var d, n, l_mcimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].medical_certificate_logo == null || data.Table[i].medical_certificate_logo == "") {
                            }
                            else {
                                l_mcimage = filepath + Doctor_Id + '/medicalcertificate/' + data.Table[i].medical_certificate_logo + '?' + n;
                                $('#MClabinprocedurelog').append('<a href="' + l_mcimage + '" target="_blank">Medical Certificate logo</a>');
                                $('#Hdn_MClabin_image').val(data.Table[i].medical_certificate_logo);
                            }
                            $('#MClabinChkfooter4').val(data.Table[i].medical_certificate_footer);
                            $('a[data-toggle=MClabinChkfooter4][data-title="' + data.Table[i].medical_certificate_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=MClabinChkfooter4][data-title="' + data.Table[i].medical_certificate_footer + '"]').addClass('active');

                            $('#MClabintxtMarketing4').val(data.Table[i].medical_certificate_marketing);
                            $('#MClabintxtanyother4').val(data.Table[i].medical_certificate_anyother);

                            $('#MClabinChkprocedureReports').val(data.Table[i].medical_certificate_val);
                            $('a[data-toggle=MClabinChkprocedureReports][data-title="' + data.Table[i].medical_certificate_val + '"]').removeClass('not-active');
                            $('a[data-toggle=MClabinChkprocedureReports][data-title="' + data.Table[i].medical_certificate_val + '"]').addClass('active');

                            $('#MClabinChkother4').val(data.Table[i].medical_certificate_customize_id);
                            $('a[data-toggle=MClabinChkother4][data-title="' + data.Table[i].medical_certificate_customize_id + '"]').removeClass('not-active');
                            $('a[data-toggle=MClabinChkother4][data-title="' + data.Table[i].medical_certificate_customize_id + '"]').addClass('active');

                            $('#MClabinlblcustomize4').val(data.Table[i].medical_certificate_customize);
                        }
                    }
                }
                else {
                    console.log(data);
                }
            }
        }
    });
}


$('#MClabindocuments4').change(function () {
    medicalcertificateLogoUpload();
});

function medicalcertificateLogoUpload() {
    var uploadpath = $('#MClabindocuments4').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);
    if (window.FormData !== undefined) {
        var fileUpload = $("#MClabindocuments4").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        $.when(checkimagedimensionvalidation(fileUpload.files[0], 512, 512)).
         done(function (Results) {
             if(Results=='Success')
             { 
                 for (var i = 0; i < files.length; i++) {
                     fileData.append(files[i].name, files[i]);
                 }
                 fileData.append('username', 'Manas');
                 $.ajax({
                     url: '/Prescription_Settings/UploadPhotoFilesMedicalCertificcate',
                     type: "POST",
                     contentType: false, // Not to set any content header
                     processData: false, // Not to process data
                     data: fileData,
                     success: function (result) {
                         console.log(result);
                         $.each(result, function (i, emp) {
                             $('#Hdn_MClabin_image').val(emp);
                             var filepath, photo, profilephoto, Doctor_Id, d, n, mcimage;
                             filepath = $('#hdnfilepath1').val();
                             photo = $('#hdnPhoto').val();
                             profilephoto = $('#Hdn_MClabin_image').val();
                             Doctor_Id = $('#myHiddenVar').val();
                             d = new Date();
                             n = d.getTime();
                             mcimage = filepath + Doctor_Id + '/medicalcertificate/' + profilephoto + '?' + n;
                             console.log(mcimage);
                             $('#MClabinprocedurelog').empty();
                             $('#MClabinprocedurelog').append('<a href="' + mcimage + '" target="_blank">Medical Certificate logo</a>');
                             //$('#MClabinprocedurelog').append('<a href="' + filepath + Doctor_Id + '/medicalcertificate/' + profilephoto + '"? ' + n + ' target="_blank">Medical Certificate logo</a>');
                         });
                     }
                 });
             }
             else {
                 $('#MClabindocuments4').val('');                 
                 $('#MClabinprocedurelog').empty();
             }
            
         });
    }
}

//Medical certificate print setting ended




// prescription print preview 

function printprescription(value) {
    if (value == "1") {
        var doctor_id;
        var Dml_Indicator;
        var header;
        var logo;
        var footer;
        var marketing;
        var medicine_prescription;
        var lab_record;
        var vitals;
        var bloodpressure;
        var bloodsugar;
        var weight;
        var height;
        var HBA1C;
        var pulserate;
        var exercise;
        var diet;
        var anyother;
        var customize_text;
        var visit_date;
        var prescription_page_top;
        var prescription_page_bottom;
        var prescription_page_left;
        var prescription_page_right;
        var diagnosis;
        var ECG;
        var prescription_page_setting;
        var complaints;
        var signature;
        var doctor_name;
        var NPI;
        var doctor_signature;
        var assessment_report;
        var assessment_details;
        var life_style;
        var prescription_page_style;
        var doctor_signature_size;
        var prescription_generic_name;
        var gender;
        var font_size;
        var table_color;
        var font_style;
        var casesheet_report;
        var premorbidconditions;
        var observednutrition;
        var filepath = $('#hdnfilepath1').val();
        var drlo_image;

        doctor_id = $('#HiddenDoctorID').val(),
        Dml_Indicator = 'I',
        header = $('#Chkheader').val(),
        logo = $('#Hdn_profile_image').val(),
        visit_time = $('#txtanyother').val(),
        footer = $('#Chkfooter').val(),
        marketing = $('#txtMarketing').val(),
        medicine_prescription = $('#ChkPrescription').val(),
        //lab_record = $('#ChkDianostics').val(),
        vitals = $('#ChkVitals').val(),
        bloodpressure = $('#ChkBP').val(),
        bloodsugar = $('#ChkBS').val(),
        weight = $('#ChkWeight').val(),
        height = '',
        HBA1C = $('#ChkHBA1C').val(),
        pulserate = $('#Chkpulserate').val(),
        exercise = $('#ChkExercise').val(),
        diet = $('#ChkDiet').val(),
        anyother = $('#Chkother').val(),
        customize_text = $('#lblcustomize').val(),
        visit_date = $('#Chkvisitdate').val(),
        prescription_page_top = $('#mtop').val(),
        prescription_page_bottom = $('#mbottom').val(),
        prescription_page_left = $('#mleft').val(),
        prescription_page_right = $('#mright').val(),
        diagnosis = $('#Chkdiagnosis').val(),
        ECG = $('#ChkECG').val(),
        prescription_page_setting = $('#labChkheader').val(),
        complaints = $('#ChkComplaints').val(),
        signature = $('#Chksignature').val(),
        doctor_name = $('#ChkDoctorName').val(),
        NPI = $('#ChkNPI').val(),
        doctor_signature = $('#Hdn_doctorsign').val(),
        assessment_report = $('#ChkAssessment').val(),
        assessment_details = $('#ChkAssessment_details').val(),
        life_style = $('#Chklifestyle').val(),
        prescription_page_style = $('#P_type').val(),
        doctor_signature_size = $('#ChkSingType').val(),
        prescription_generic_name = $('#generic_name').val(),
        gender = $('#gender').val(),
        font_size = $('#fontsize').val(),
        table_color = $('#fontcolor').val(),
        font_style = $('#fontstyle_1').val(),
        casesheet_report = $('#ChkCsreport').val(),
        premorbidconditions = $('#ChkPMConn').val(),
        observednutrition = $('#ChkObservedNutrition').val(),
        drlo_image = filepath + doctor_id + '/logo/' + logo;

        console.log("-------------------------------");
        console.log(filepath);
        console.log(logo);
        console.log(drloimage);
        console.log("-----------------------------");


        // custom css using in javascript 

        $("#headerspace").css('paddingTop', prescription_page_top + "PX");
        $("#footerspace").css('paddingBottom', prescription_page_bottom + "PX");
        $(".heading").css('background-color', table_color);
        $(".thead-type5").css('background-color', table_color);
        $(".appointmentdate").css('background-color', table_color);
        $(".thead-bg").css('background-color', table_color);
        //$("#patient-header").css('background-color', table_color); 
        $(".patient-details").css({ 'font-size': font_size + "PX" });
        $(".diagnosis").css({ 'font-size': font_size + "PX" });
        $(".Prescription").css({ 'font-size': font_size + "PX" });
        $(".labtest").css({ 'font-size': font_size + "PX" });
        $(".exercise").css({ 'font-size': font_size + "PX" });
        $(".diet").css({ 'font-size': font_size + "PX" });
        $(".appointmentdate").css({ 'font-size': font_size + "PX" });
        $(".signature").css({ 'font-size': font_size + "PX" });
        $(".footerpreview").css({ 'font-size': font_size + "PX" });
        $(".vitals-preview").css({ 'font-size': font_size + "PX" });
        $(".family-details").css({ 'font-size': font_size + "PX" });
        $(".as-report").css({ 'font-size': font_size + "PX" });
        $(".lifestyle").css({ 'font-size': font_size + "PX" });

        $("#Prescription.table-type2").css('font-size', font_size + 'px');


        $("#myModalprintpreview").css('font-family', font_style);
        $("#headerpreview").css('font-family', font_style);

        $("#myModalprintpreview").find('h1').css('font-family', font_style);
        $("#myModalprintpreview").find('h2').css('font-family', font_style);
        $("#myModalprintpreview").find('h3').css('font-family', font_style);
        $("#myModalprintpreview").find('h4').css('font-family', font_style);
        $("#myModalprintpreview").find('h5').css('font-family', font_style);

        // custom css using in javascript 


        //condition to select the prescription table style 

        if (prescription_page_style == "1") {
            $('#type1').show();
            $('#type2').hide();
            $('#type3').hide();
            $('#type4').hide();
            $('#type5').hide();
        }
        else if (prescription_page_style == "2") {
            $('#type2').show();
            $('#type5').hide();
            $('#type4').hide();
            $('#type3').hide();
            $('#type1').hide();
        }
        else if (prescription_page_style == "3") {
            $('#type3').show();
            $('#type1').hide();
            $('#type2').hide();
            $('#type4').hide();
            $('#type5').hide();
        }
        else if (prescription_page_style == "4") {
            $('#type4').show();
            $('#type5').hide();
            $('#type3').hide();
            $('#type2').hide();
            $('#type1').hide();
        }
        else if (prescription_page_style == "5") {
            $('#type5').show();
            $('#type4').hide();
            $('#type3').hide();
            $('#type2').hide();
            $('#type1').hide();
        }

        //condition to select the prescription table style 

        if (prescription_page_setting == "1") {
            $('#headerspace').show();
            $('#footerspace').show();
        }
        else if (prescription_page_setting == "2") {
            $('#headerspace').hide();
            $('#footerspace').hide();
        }

        if (medicine_prescription == "1") {
            $('#Prescription-heading').show();
            $('#Prescription').show();
            $('#genericname').show();
            $('#gender1').show();
        }
        else {
            $('#Prescription-heading').hide();
            $('#Prescription').hide();
            $('#genericname').hide();
            $('#gender1').hide();
        }

        if (doctor_name == "1") {
            $('#doctor_name').show();
        }
        else {
            $('#doctor_name').hide();
        }

        if (header == "1") {
            $('#headerpreview').show();
        }
        else {
            $('#headerpreview').hide();
        }

        if (prescription_generic_name == "1") {
            $('.genericname').show();
            $('.genericname1').show();
        }
        else {
            $('.genericname').hide();
            $('.genericname1').hide();
        }

        if (signature == "1") {
            $('#signature').show();
        }
        else {
            $('#signature').hide();
        }

        if (gender == "1") {
            $('#gender1').show();
        }
        else {
            $('#gender1').hide();
        }

        if (vitals == "1") {
            $('#vitals-heading').show();
            $('#vitals').show();
            $('#diagnosis').show();
        }
        else {
            $('#vitals-heading').hide();
            $('#vitals').hide();
            $('#diagnosis').hide();
        }

        if (bloodpressure == "1") {
            $('#bloodpressure').show();
        }
        else {
            $('#bloodpressure').hide();
        }

        if (bloodsugar == "1") {
            $('#bloodsugar').show();
        }
        else {
            $('#bloodsugar').hide();
        }

        if (weight == "1") {
            $('#weight').show();
        }
        else {
            $('#weight').hide();
        }

        if (HBA1C == "1") {
            $('#HBA1C').show();
        }
        else {
            $('#HBA1C').hide();
        }

        if (pulserate == "1") {
            $('#pulserate').show();
        }
        else {
            $('#pulserate').hide();
        }

        if (ECG == "1") {
            $('#ecg').show();
        }
        else {
            $('#ecg').hide();
        }

        if (vitals == "1" && diagnosis == "1") {
            $('#diagnosis-heading').show();
            $('#diagnosis').show();
        }
        else {
            $('#diagnosis-heading').hide();
            $('#diagnosis').hide();
        }

        if (complaints == "1") {
            $('#complaints').show();
        }
        else {
            $('#complaints').hide();
        }

        if (assessment_report == "1") {
            $('#assessment_report').show();
            $('#assessment_heading').show();
        }
        else {
            $('#assessment_report').hide();
            $('#assessment_heading').hide();
        }

        if (assessment_details == "1") {
            $('#assessment_heading').show();
            $('#assessment_details').show();
            $('#family-heading').show();
            $('#family-details').show();
        }
        else {
            $('#assessment_heading').hide();
            $('#assessment_details').hide();
            $('#family-heading').hide();
            $('#family-details').hide();
        }

        if (life_style == "1") {
            $('#lifestyle').show();
        }
        else {
            $('#lifestyle').hide();
        }


        if (lab_record == "1") {
            $('#lab-heading').show();
            $('#lab-record').show();
        }
        else {
            $('#lab-heading').hide();
            $('#lab-record').hide();
        }

        if (exercise == "1") {
            $('#exercise-heading').show();
            $('#exercise').show();
        }
        else {
            $('#exercise-heading').hide();
            $('#exercise').hide();
        }

        if (diet == "1") {
            $('#diet-heading').show();
            $('#diet').show();
        }
        else {
            $('#diet-heading').hide();
            $('#diet').hide();
        }

        if (visit_date == "1") {
            $('#appointmentdate').show();
        }
        else {
            $('#appointmentdate').hide();
        }

        if (footer == "1") {
            $('#footerpreview').show();
        }
        else {
            $('#footerpreview').hide();
        }

        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            header: $('#Chkheader').val(),
            logo: $('#Hdn_profile_image').val(),
            visit_time: $('#txtanyother').val(),
            footer: $('#Chkfooter').val(),
            marketing: $('#txtMarketing').val(),
            medicine_prescription: $('#ChkPrescription').val(),
            //lab_record: $('#ChkDianostics').val(),
            vitals: $('#ChkVitals').val(),
            bloodpressure: $('#ChkBP').val(),
            bloodsugar: $('#ChkBS').val(),
            weight: $('#ChkWeight').val(),
            height: '',
            HBA1C: $('#ChkHBA1C').val(),
            pulserate: $('#Chkpulserate').val(),
            exercise: $('#ChkExercise').val(),
            diet: $('#ChkDiet').val(),
            anyother: $('#Chkother').val(),
            customize_text: $('#lblcustomize').val(),
            visit_date: $('#Chkvisitdate').val(),
            prescription_page_top: $('#mtop').val(),
            prescription_page_bottom: $('#mbottom').val(),
            prescription_page_left: $('#mleft').val(),
            prescription_page_right: $('#mright').val(),
            diagnosis: $('#Chkdiagnosis').val(),
            ECG: $('#ChkECG').val(),
            prescription_page_setting: $('#labChkheader').val(),
            complaints: $('#ChkComplaints').val(),
            signature: $('#Chksignature').val(),
            doctor_name: $('#ChkDoctorName').val(),
            NPI: $('#ChkNPI').val(),
            doctor_signature: $('#Hdn_doctorsign').val(),

            assessment_report: $('#ChkAssessment').val(),
            assessment_details: $('#ChkAssessment_details').val(),
            life_style: $('#Chklifestyle').val(),
            prescription_page_style: $('#P_type').val(),
            doctor_signature_size: $('#ChkSingType').val(),
            prescription_generic_name: $('#generic_name').val(),
            gender: $('#gender').val(),
            font_size: $('#fontsize').val(),
            table_color: $('#fontcolor').val(),
            font_style: $('#fontstyle_1').val(),
            casesheet_report: $('#ChkCsreport').val(),
            premorbidconditions: $('#ChkPMConn').val(),
            observednutrition: $('#ChkObservedNutrition').val(),
            instruction: $('#Chkins').val(),
            observation: $('#Chkobs').val(),
            investigation: $('#Chkinv').val(),
            diagnosis_observation: $('#ChkDiag').val(),
            temperature: $('#ChkTemp').val(),
            procedure: $('#ChkProcedure').val(),
            respiratory_rate: $('#ChkRespiratoryRate').val()
        }

        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/doctor_details',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
        });
    }
    else if (value == "2") {
        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            header: $('#Chkheader').val(),
            logo: $('#Hdn_profile_image').val(),
            visit_time: $('#txtanyother').val(),
            footer: $('#Chkfooter').val(),
            marketing: $('#txtMarketing').val(),
            medicine_prescription: $('#ChkPrescription').val(),
            //lab_record: $('#ChkDianostics').val(),
            vitals: $('#ChkVitals').val(),
            bloodpressure: $('#ChkBP').val(),
            bloodsugar: $('#ChkBS').val(),
            weight: $('#ChkWeight').val(),
            height: '',
            HBA1C: $('#ChkHBA1C').val(),
            pulserate: $('#Chkpulserate').val(),
            exercise: $('#ChkExercise').val(),
            diet: $('#ChkDiet').val(),
            anyother: $('#Chkother').val(),
            customize_text: $('#lblcustomize').val(),
            visit_date: $('#Chkvisitdate').val(),
            prescription_page_top: $('#mtop').val(),
            prescription_page_bottom: $('#mbottom').val(),
            prescription_page_left: $('#mleft').val(),
            prescription_page_right: $('#mright').val(),
            diagnosis: $('#Chkdiagnosis').val(),
            ECG: $('#ChkECG').val(),
            prescription_page_setting: $('#labChkheader').val(),
            complaints: $('#ChkComplaints').val(),
            signature: $('#Chksignature').val(),
            doctor_name: $('#ChkDoctorName').val(),
            NPI: $('#ChkNPI').val(),
            doctor_signature: $('#Hdn_doctorsign').val(),

            assessment_report: $('#ChkAssessment').val(),
            assessment_details: $('#ChkAssessment_details').val(),
            life_style: $('#Chklifestyle').val(),
            prescription_page_style: $('#P_type').val(),
            doctor_signature_size: $('#ChkSingType').val(),
            prescription_generic_name: $('#generic_name').val(),
            gender: $('#gender').val(),
            font_size: $('#fontsize').val(),
            table_color: $('#fontcolor').val(),
            font_style: $('#fontstyle_1').val(),
            casesheet_report: $('#ChkCsreport').val(),
            premorbidconditions: $('#ChkPMConn').val(),
            observednutrition: $('#ChkObservedNutrition').val(),
            instruction: $('#Chkins').val(),
            observation: $('#Chkobs').val(),
            investigation: $('#Chkinv').val(),
            diagnosis_observation: $('#ChkDiag').val(),
            temperature: $('#ChkTemp').val(),
            procedure: $('#ChkProcedure').val(),
            respiratory_rate: $('#ChkRespiratoryRate').val()
        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/doctor_details',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
            success: function (data) {

                var data2 = JSON.parse(data);
                if (data2.msg == "Success") {
                    var data1 = data2.data;
                    window.location.href = '/Prescription_Settings/';
                }
                else {
                    console.log(data);
                }

            }
        });
    }
}

// prescription print preview 

// print invoice preview 
function printpreview_invoice(value) {

    if (value == "1") {
        var doctor_id;
        var Dml_Indicator;
        var invoice_page_setting;
        var invoice_page_top;
        var invoice_page_bottom;
        var invoice_page_left;
        var invoice_page_right;
        var invoice_header;
        var invoice_logo;
        var invoice_footer;
        var invoice_marketing;
        var invoice_anyother;
        var invoice;
        var invoice_customize_id;
        var invoice_customize;
        var filepath = $('#hdnfilepath1').val();
        var invoice_image;

        doctor_id = $('#HiddenDoctorID').val(),
        Dml_Indicator = 'I',
        invoice_page_setting = $('#labChkheader2').val(),
        invoice_page_top = $('#mtop2').val(),
        invoice_page_bottom = $('#mbottom2').val(),
        invoice_page_left = $('#mleft2').val(),
        invoice_page_right = $('#mright2').val(),
        invoice_header = $('#Chkheader2').val(),
        invoice_logo = $('#Hdn_invoice_img').val(),
        invoice_footer = $('#Chkfooter2').val(),
        invoice_marketing = $('#txtMarketing2').val(),
        invoice_anyother = $('#txtanyother2').val(),
        invoice = $('#ChkInvoice').val(),
        invoice_customize_id = $('#Chkother2').val(),
        invoice_customize = $('#lblcustomize2').val()
        invoice_image = filepath + doctor_id + '/invoice_logo/' + invoice_logo;

        console.log(invoice_page_bottom);

        $("#headerspace_invoice").css('paddingTop', invoice_page_top + "PX");
        $("#footerspace_invoice").css('paddingBottom', invoice_page_bottom + "PX");


        if (invoice_page_setting == "1") {
            $('#headerspace_invoice').show();
            $('#footerspace_invoice').show();
        }
        else if (invoice_page_setting == "2") {
            $('#headerspace_invoice').hide();
            $('#footerspace_invoice').hide();
        }
        if (invoice_header == "1") {
            $('#invoice_header').show();
        }
        else {
            $('#invoice_header').hide();
        }

        if (invoice_footer == "1") {
            $('#invoice_footer').show();
        }
        else {
            $('#invoice_footer').hide();
        }


        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            invoice_page_setting: $('#labChkheader2').val(),
            invoice_page_top: $('#mtop2').val(),
            invoice_page_bottom: $('#mbottom2').val(),
            invoice_page_left: $('#mleft2').val(),
            invoice_page_right: $('#mright2').val(),
            invoice_header: $('#Chkheader2').val(),
            invoice_logo: $('#Hdn_invoice_img').val(),
            invoice_footer: $('#Chkfooter2').val(),
            invoice_marketing: $('#txtMarketing2').val(),
            invoice_anyother: $('#txtanyother2').val(),
            invoice: $('#ChkInvoice').val(),
            invoice_customize_id: $('#Chkother2').val(),
            invoice_customize: $('#lblcustomize2').val(),
        }

        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/invoice_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details)
        });
    }
    else if (value == "2") {
        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            invoice_page_setting: $('#labChkheader2').val(),
            invoice_page_top: $('#mtop2').val(),
            invoice_page_bottom: $('#mbottom2').val(),
            invoice_page_left: $('#mleft2').val(),
            invoice_page_right: $('#mright2').val(),
            invoice_header: $('#Chkheader2').val(),
            invoice_logo: $('#Hdn_invoice_img').val(),
            invoice_footer: $('#Chkfooter2').val(),
            invoice_marketing: $('#txtMarketing2').val(),
            invoice_anyother: $('#txtanyother2').val(),
            invoice: $('#ChkInvoice').val(),
            invoice_customize_id: $('#Chkother2').val(),
            invoice_customize: $('#lblcustomize2').val(),
        }


        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/invoice_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
            success: function (data) {

                var data2 = JSON.parse(data);
                if (data2.msg == "Success") {
                    var data1 = data2.data;
                    //toastr.warning("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Invoice saved successfully',
                    //   {
                    //       closeButton: true,
                    //       progressBar: true,
                    //       allowHtml: true,
                    //       timeOut: 20000000,

                    //       onShown: function (toast) {
                    //           $("#confirmationRevertYes").click(function () {
                    //               window.location.href = '/Prescription_Settings/';
                    //           })
                    //       }
                    //   })
                   
                }
                else {
                    console.log(data);
                }

            }
        });
    }
}

// print invoice preview

// print lab results preview 

function printpreview_labresult(value) {
    if (value == "1") {
        var doctor_id;
        var Dml_Indicator;
        var lab_page_setting;
        var lab_page_top;
        var lab_page_bottom;
        var lab_page_left;
        var lab_page_right;
        var lab_header;
        var lab_logo;
        var lab_footer;
        var lab_marketing;
        var lab_anyother;
        var lab;
        var lab_customize_id;
        var lab_customize;
        var filepath = $('#hdnfilepath1').val();
        var lab_image;

        doctor_id = $('#HiddenDoctorID').val(),
        Dml_Indicator = 'I',
        lab_page_setting = $('#labChkheader3').val(),
        lab_page_top = $('#mtop3').val(),
        lab_page_bottom = $('#mbottom3').val(),
        lab_page_left = $('#mleft3').val(),
        lab_page_right = $('#mright3').val(),
        lab_header = $('#Chkheader3').val(),
        lab_logo = $('#Hdn_lab_image').val(),
        lab_footer = $('#Chkfooter3').val(),
        lab_marketing = $('#txtMarketing3').val(),
        lab_anyother = $('#txtanyother3').val(),
        lab = $('#ChkLabReports').val(),
        lab_customize_id = $('#Chkother3').val(),
        lab_customize = $('#lblcustomize3').val()
        lab_image = filepath + doctor_id + '/lablogo/' + lab_logo;

        $("#headerspace_labresults").css('paddingTop', lab_page_top + "PX");
        $("#footerspace_labresults").css('paddingBottom', lab_page_bottom + "PX");

        if (lab_page_setting == "1") {
            $('#headerspace_labresults').show();
            $('#footerspace_labresults').show();
        }
        else if (lab_page_setting == "2") {
            $('#headerspace_labresults').hide();
            $('#footerspace_labresults').hide();
        }


        if (lab_header == "1") {
            $('#lab_result_header').show();
        }
        else {
            $('#lab_result_header').hide();
        }

        if (lab_footer == "1") {
            $('#lab_result_footer').show();
        }
        else {
            $('#lab_result_footer').hide();
        }

        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            lab_page_setting: $('#labChkheader3').val(),
            lab_page_top: $('#mtop3').val(),
            lab_page_bottom: $('#mbottom3').val(),
            lab_page_left: $('#mleft3').val(),
            lab_page_right: $('#mright3').val(),
            lab_header: $('#Chkheader3').val(),
            lab_logo: $('#Hdn_lab_image').val(),
            lab_footer: $('#Chkfooter3').val(),
            lab_marketing: $('#txtMarketing3').val(),
            lab_anyother: $('#txtanyother3').val(),
            lab: $('#ChkLabReports').val(),
            lab_customize_id: $('#Chkother3').val(),
            lab_customize: $('#lblcustomize3').val(),
            lab_image: filepath + doctor_id + '/lablogo/' + lab_logo,
        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/lab_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
        });
    }
    else if (value == "2") {
        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            lab_page_setting: $('#labChkheader3').val(),
            lab_page_top: $('#mtop3').val(),
            lab_page_bottom: $('#mbottom3').val(),
            lab_page_left: $('#mleft3').val(),
            lab_page_right: $('#mright3').val(),
            lab_header: $('#Chkheader3').val(),
            lab_logo: $('#Hdn_lab_image').val(),
            lab_footer: $('#Chkfooter3').val(),
            lab_marketing: $('#txtMarketing3').val(),
            lab_anyother: $('#txtanyother3').val(),
            lab: $('#ChkLabReports').val(),
            lab_customize_id: $('#Chkother3').val(),
            lab_customize: $('#lblcustomize3').val(),
        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/lab_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
            success: function (data) {

                var data2 = JSON.parse(data);
                if (data2.msg == "Success") {
                    var data1 = data2.data;

                    //window.location.href = '/Prescription_Settings/';
                }
                else {
                    console.log(data);
                }

            }
        });
    }
}
// print lab results preview 

// print procedure lab
function printpreview_procedureLab(value) {
    if (value == "1") {
        var doctor_id;
        var Dml_Indicator;
        var procedure_page_setting;
        var procedure_page_top;
        var procedure_page_bottom;
        var procedure_page_left;
        var procedure_page_right;
        var procedure_header;
        var procedure_logo;
        var procedure_footer;
        var procedure_marketing;
        var procedure_anyother;
        var procedure_val;
        var procedure_customize_id;
        var procedure_customize;
        var filepath = $('#hdnfilepath1').val();
        var pro_logo;


        doctor_id = $('#HiddenDoctorID').val(),
        Dml_Indicator = 'I',
        procedure_page_setting = $('#ProcedureChkheader4').val(),
        procedure_page_top = $('#mtop4').val(),
        procedure_page_bottom = $('#mbottom4').val(),
        procedure_page_left = $('#mleft4').val(),
        procedure_page_right = $('#mright4').val(),
        procedure_header = $('#Chkheader4').val(),
        procedure_logo = $('#Hdn_procedure_image').val(),
        procedure_footer = $('#Chkfooter4').val(),
        procedure_marketing = $('#txtMarketing4').val(),
        procedure_anyother = $('#txtanyother4').val(),
        procedure_val = $('#ChkprocedureReports').val(),
        procedure_customize_id = $('#Chkother4').val(),
        procedure_customize = $('#lblcustomize4').val(),
        pro_logo = filepath + doctor_id + '/procedurelogo/' + procedure_logo

        $("#headerspace_procedurelab").css('paddingTop', procedure_page_top + "PX");
        $("#footerspace_procedurelab").css('paddingBottom', procedure_page_bottom + "PX");


        if (procedure_page_setting == "1") {
            $('#headerspace_procedurelab').show();
            $('#footerspace_procedurelab').show();
        }
        else if (procedure_page_setting == "2") {
            $('#headerspace_procedurelab').hide();
            $('#footerspace_procedurelab').hide();
        }

        if (procedure_header == "1") {
            $('#procedure_header').show();
        }
        else {
            $('#procedure_header').hide();
        }

        if (procedure_footer == "1") {
            $('#procedure_footer').show();
        }
        else {
            $('#procedure_footer').hide();
        }

        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            procedure_page_setting: $('#ProcedureChkheader4').val(),
            procedure_page_top: $('#mtop4').val(),
            procedure_page_bottom: $('#mbottom4').val(),
            procedure_page_left: $('#mleft4').val(),
            procedure_page_right: $('#mright4').val(),
            procedure_header: $('#Chkheader4').val(),
            procedure_logo: $('#Hdn_procedure_image').val(),
            procedure_footer: $('#Chkfooter4').val(),
            procedure_marketing: $('#txtMarketing4').val(),
            procedure_anyother: $('#txtanyother4').val(),
            procedure_val: $('#ChkprocedureReports').val(),
            procedure_customize_id: $('#Chkother4').val(),
            procedure_customize: $('#lblcustomize4').val(),
        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/procedure_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details)
        });
    }
    else if (value == "2") {
        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            procedure_page_setting: $('#ProcedureChkheader4').val(),
            procedure_page_top: $('#mtop4').val(),
            procedure_page_bottom: $('#mbottom4').val(),
            procedure_page_left: $('#mleft4').val(),
            procedure_page_right: $('#mright4').val(),
            procedure_header: $('#Chkheader4').val(),
            procedure_logo: $('#Hdn_procedure_image').val(),
            procedure_footer: $('#Chkfooter4').val(),
            procedure_marketing: $('#txtMarketing4').val(),
            procedure_anyother: $('#txtanyother4').val(),
            procedure_val: $('#ChkprocedureReports').val(),
            procedure_customize_id: $('#Chkother4').val(),
            procedure_customize: $('#lblcustomize4').val(),
        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/procedure_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
            success: function (data) {

                var data2 = JSON.parse(data);
                if (data2.msg == "Success") {
                    var data1 = data2.data;

                    //window.location.href = '/Prescription_Settings/';
                }
                else {
                    console.log(data);
                }


            }
        });
    }
}

// print procedure lab

//print diet

function printpreview_diet(value) {
    debugger;
    //if (value == "1") {
    //    var doctor_id;
    //    var Dml_Indicator;
    //    var diet_page_setting;
    //    var diet_page_top;
    //    var diet_page_bottom;
    //    var diet_page_left;
    //    var diet_page_right;
    //    var diet_heade;
    //    var diet_logo;
    //    var diet_footer;
    //    var diet_marketing;
    //    var diet_anyother;
    //    var diet_val;
    //    var diet_customize_id;
    //    var diet_customize;
    //    var filepath = $('#hdnfilepath1').val();
    //    var diet_image;

    //    doctor_id = $('#HiddenDoctorID').val(),
    //    Dml_Indicator = 'I',
    //    diet_page_setting = $('#dietChkheader4').val(),
    //    diet_page_top = $('#diettop4').val(),
    //    diet_page_bottom = $('#dietbottom4').val(),
    //    diet_page_left = $('#dietleft4').val(),
    //    diet_page_right = $('#dietht4').val(),
    //    diet_header = $('#diet1Chkheader4').val(),
    //    diet_logo = $('#Hdn_diet_image').val(),
    //    diet_footer = $('#dietChkfooter4').val(),
    //    diet_marketing = $('#diettxtMarketing4').val(),
    //    diet_anyother = $('#diettxtanyother4').val(),
    //    diet_val = $('#dietChkprocedureReports').val(),
    //    diet_customize_id = $('#dietChkother4').val(),
    //    diet_customize = $('#dietlblcustomize4').val(),
    //    diet_image = filepath + doctor_id + '/dietlogo/' + diet_logo;


    //    $("#headerspace_diet").css('paddingTop', diet_page_top + "PX");
    //    $("#footerspace_diet").css('paddingBottom', diet_page_bottom + "PX");


    //    if (diet_page_setting == "1") {
    //        $('#headerspace_diet').show();
    //        $('#footerspace_diet').show();
    //    }
    //    else if (diet_page_setting == "2") {
    //        $('#headerspace_diet').hide();
    //        $('#footerspace_diet').hide();
    //    }

    //    if (diet_header == "1") {
    //        $('#diet_header').show();
    //    }
    //    else {
    //        $('#diet_header').hide();
    //    }

    //    if (diet_footer == "1") {
    //        $('#diet_footer').show();
    //    }
    //    else {
    //        $('#diet_footer').hide();
    //    }

    //    var details = {
    //        doctor_id: $('#HiddenDoctorID').val(),
    //        Dml_Indicator: 'I',
    //        diet_page_setting: $('#dietChkheader4').val(),
    //        diet_page_top: $('#diettop4').val(),
    //        diet_page_bottom: $('#dietbottom4').val(),
    //        diet_page_left: $('#dietleft4').val(),
    //        diet_page_right: $('#dietht4').val(),
    //        diet_header: $('#diet1Chkheader4').val(),
    //        diet_logo: $('#Hdn_diet_image').val(),
    //        diet_footer: $('#dietChkfooter4').val(),
    //        diet_marketing: $('#diettxtMarketing4').val(),
    //        diet_anyother: $('#diettxtanyother4').val(),
    //        diet_val: $('#dietChkprocedureReports').val(),
    //        diet_customize_id: $('#dietChkother4').val(),
    //        diet_customize: $('#dietlblcustomize4').val(),
    //        diet_image:filepath + doctor_id + '/dietlogo/' + diet_logo

    //    }
    //    $.ajax({
    //        async: true,
    //        type: 'POST',
    //        url: '/Prescription_Settings/deit_print_settings',
    //        contentType: 'application/json; charset=UTF-8',
    //        data: JSON.stringify(details)
    //    });
    //}
    //else if (value == "2") {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        diet_page_setting: $('#dietChkheader4').val(),
        diet_page_top: $('#diettop4').val(),
        diet_page_bottom: $('#dietbottom4').val(),
        diet_page_left: $('#dietleft4').val(),
        diet_page_right: $('#dietht4').val(),
        diet_header: $('#diet1Chkheader4').val(),
        diet_logo: $('#Hdn_diet_image').val(),
        diet_footer: $('#dietChkfooter4').val(),
        diet_marketing: $('#diettxtMarketing4').val(),
        diet_anyother: $('#diettxtanyother4').val(),
        diet_val: $('#dietChkprocedureReports').val(),
        diet_customize_id: $('#dietChkother4').val(),
        diet_customize: $('#dietlblcustomize4').val(),
        diet_image: filepath + doctor_id + '/dietlogo/' + diet_logo
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/deit_print_settings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {

            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data1 = data2.data;


                    //var data1 = JSON.parse(data);
                    //window.location.href = '/Prescription_Settings/';
                }
                else {
                    console.log(data);
                }

            }
        }
    });
    //}
}

//print diet

//print lab invoice 

function printpreview_labinvoice(value) {
    if (value == "1") {

        var doctor_id;
        var Dml_Indicator;
        var labinvoice_page_setting;
        var labinvoice_page_top;
        var labinvoice_page_bottom;
        var labinvoice_page_left;
        var labinvoice_page_right;
        var labinvoice_header;
        var labinvoice_logo;
        var labinvoice_footer;
        var labinvoice_marketing;
        var labinvoice_anyother;
        var labinvoice_val;
        var labinvoice_customize_id;
        var labinvoice_customize;
        var filepath = $('#hdnfilepath1').val();
        var labinvoice_image;

        doctor_id = $('#HiddenDoctorID').val(),
        Dml_Indicator = 'I',
        labinvoice_page_setting = $('#labinProcedureChkheader4').val(),
        labinvoice_page_top = $('#labinmtop4').val(),
        labinvoice_page_bottom = $('#labinmbottom4').val(),
        labinvoice_page_left = $('#labinmleft4').val(),
        labinvoice_page_right = $('#labinmright4').val(),
        labinvoice_header = $('#labinChkheader4').val(),
        labinvoice_logo = $('#Hdn_labin_image').val(),
        labinvoice_footer = $('#labinChkfooter4').val(),
        labinvoice_marketing = $('#labintxtMarketing4').val(),
        labinvoice_anyother = $('#labintxtanyother4').val(),
        labinvoice_val = $('#labinChkprocedureReports').val(),
        labinvoice_customize_id = $('#labinChkother4').val(),
        labinvoice_customize = $('#labinlblcustomize4').val(),
        labinvoice_image = filepath + doctor_id + '/logo/' + labinvoice_logo

        $("#headerspace_labinvoice").css('paddingTop', labinvoice_page_top + "PX");
        $("#footerspace_labinvoice").css('paddingBottom', labinvoice_page_bottom + "PX");

        if (labinvoice_page_setting == "1") {
            $('#headerspace_labinvoice').show();
            $('#footerspace_labinvoice').show();
        }
        else if (labinvoice_page_setting == "2") {
            $('#headerspace_labinvoice').hide();
            $('#footerspace_labinvoice').hide();
        }

        if (labinvoice_header == "1") {
            $('#labinvoice_header').show();
        }
        else {
            $('#labinvoice_header').hide();
        }

        if (labinvoice_footer == "1") {
            $('#labinvoice_footer').show();
        }
        else {
            $('#labinvoice_footer').hide();
        }

        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            labinvoice_page_setting: $('#labinProcedureChkheader4').val(),
            labinvoice_page_top: $('#labinmtop4').val(),
            labinvoice_page_bottom: $('#labinmbottom4').val(),
            labinvoice_page_left: $('#labinmleft4').val(),
            labinvoice_page_right: $('#labinmright4').val(),
            labinvoice_header: $('#labinChkheader4').val(),
            labinvoice_logo: $('#Hdn_labin_image').val(),
            labinvoice_footer: $('#labinChkfooter4').val(),
            labinvoice_marketing: $('#labintxtMarketing4').val(),
            labinvoice_anyother: $('#labintxtanyother4').val(),
            labinvoice_val: $('#labinChkprocedureReports').val(),
            labinvoice_customize_id: $('#labinChkother4').val(),
            labinvoice_customize: $('#labinlblcustomize4').val(),
            labinvoice_image: filepath + doctor_id + '/logo/' + labinvoice_logo

        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/laninvoice_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details)
        });
    }
    else if (value == "2") {
        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            labinvoice_page_setting: $('#labinProcedureChkheader4').val(),
            labinvoice_page_top: $('#labinmtop4').val(),
            labinvoice_page_bottom: $('#labinmbottom4').val(),
            labinvoice_page_left: $('#labinmleft4').val(),
            labinvoice_page_right: $('#labinmright4').val(),
            labinvoice_header: $('#labinChkheader4').val(),
            labinvoice_logo: $('#Hdn_labin_image').val(),
            labinvoice_footer: $('#labinChkfooter4').val(),
            labinvoice_marketing: $('#labintxtMarketing4').val(),
            labinvoice_anyother: $('#labintxtanyother4').val(),
            labinvoice_val: $('#labinChkprocedureReports').val(),
            labinvoice_customize_id: $('#labinChkother4').val(),
            labinvoice_customize: $('#labinlblcustomize4').val(),
            labinvoice_image: filepath + doctor_id + '/logo/' + labinvoice_logo

        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/laninvoice_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
            success: function (data) {

                var data2 = JSON.parse(data);
                if (data2.msg == "Success") {
                    var data1 = data2.data;
                    //window.location.href = '/Prescription_Settings/';
                }
                else {
                    console.log(data);
                }

            }
        });
    }
}

//print lab invoice 

// print medical certificate

function printpreview_medicalcertificate(value) {
    if (value == "1") {
        var doctor_id;
        var Dml_Indicator;
        var medical_certificate_page_setting;
        var medical_certificate_page_top;
        var medical_certificate_page_bottom;
        var medical_certificate_page_left;
        var medical_certificate_page_right;
        var medical_certificate_header;
        var medical_certificate_logo;
        var medical_certificate_footer;
        var medical_certificate_marketing;
        var medical_certificate_anyother;
        var medical_certificate_val;
        var medical_certificate_customize_id;
        var medical_certificate_customize;
        var filepath = $('#hdnfilepath1').val();
        var mdl_logo;

        doctor_id = $('#HiddenDoctorID').val(),
        Dml_Indicator = 'I',
        medical_certificate_page_setting = $('#MClabinProcedureChkheader4').val(),
        medical_certificate_page_top = $('#MClabinmtop4').val(),
        medical_certificate_page_bottom = $('#MClabinmbottom4').val(),
        medical_certificate_page_left = $('#MClabinmleft4').val(),
        medical_certificate_page_right = $('#MClabinmright4').val(),
        medical_certificate_header = $('#MClabinChkheader4').val(),
        medical_certificate_logo = $('#Hdn_MClabin_image').val(),
        medical_certificate_footer = $('#MClabinChkfooter4').val(),
        medical_certificate_marketing = $('#MClabintxtMarketing4').val(),
        medical_certificate_anyother = $('#MClabintxtanyother4').val(),
        medical_certificate_val = $('#MClabinChkprocedureReports').val(),
        medical_certificate_customize_id = $('#MClabinChkother4').val(),
        medical_certificate_customize = $('#MClabinlblcustomize4').val(),
        mdl_logo = filepath + doctor_id + '/medicalcertificate/' + medical_certificate_logo;

        $("#headerspace_medicalcertificate").css('paddingTop', medical_certificate_page_top + "PX");
        $("#footerspace_medicalcertificate").css('paddingBottom', medical_certificate_page_bottom + "PX");

        if (medical_certificate_page_setting == "1") {
            $('#headerspace_medicalcertificate').show();
            $('#footerspace_medicalcertificate').show();
        }
        else if (medical_certificate_page_setting == "2") {
            $('#headerspace_medicalcertificate').hide();
            $('#footerspace_medicalcertificate').hide();
        }

        if (medical_certificate_header == "1") {
            $('#medical_certificate_header').show();
        }
        else {
            $('#medical_certificate_header').hide();
        }

        if (medical_certificate_footer == "1") {
            $('#medical_certificate_footer').show();
        }
        else {
            $('#medical_certificate_footer').hide();
        }

        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            medical_certificate_page_setting: $('#MClabinProcedureChkheader4').val(),
            medical_certificate_page_top: $('#MClabinmtop4').val(),
            medical_certificate_page_bottom: $('#MClabinmbottom4').val(),
            medical_certificate_page_left: $('#MClabinmleft4').val(),
            medical_certificate_page_right: $('#MClabinmright4').val(),
            medical_certificate_header: $('#MClabinChkheader4').val(),
            medical_certificate_logo: $('#Hdn_MClabin_image').val(),
            medical_certificate_footer: $('#MClabinChkfooter4').val(),
            medical_certificate_marketing: $('#MClabintxtMarketing4').val(),
            medical_certificate_anyother: $('#MClabintxtanyother4').val(),
            medical_certificate_val: $('#MClabinChkprocedureReports').val(),
            medical_certificate_customize_id: $('#MClabinChkother4').val(),
            medical_certificate_customize: $('#MClabinlblcustomize4').val(),
            mdl_logo: filepath + doctor_id + '/medicalcertificate/' + medical_certificate_logo

        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/medicalcertificate_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
            success: function (data) {
                // window.location.href = '/Prescription_Settings/';
                var data2 = JSON.parse(data);
                if (jQuery.isEmptyObject((data2.data))) {
                }
                else {

                    if (data2.msg == "Success") {
                        var data = data2.data;
                        //var data = JSON.parse(data);
                    }
                    else {
                        console.log(data);
                    }

                }
            }
        });
    }
    else if (value == "2") {
        var details = {
            doctor_id: $('#HiddenDoctorID').val(),
            Dml_Indicator: 'I',
            medical_certificate_page_setting: $('#MClabinProcedureChkheader4').val(),
            medical_certificate_page_top: $('#MClabinmtop4').val(),
            medical_certificate_page_bottom: $('#MClabinmbottom4').val(),
            medical_certificate_page_left: $('#MClabinmleft4').val(),
            medical_certificate_page_right: $('#MClabinmright4').val(),
            medical_certificate_header: $('#MClabinChkheader4').val(),
            medical_certificate_logo: $('#Hdn_MClabin_image').val(),
            medical_certificate_footer: $('#MClabinChkfooter4').val(),
            medical_certificate_marketing: $('#MClabintxtMarketing4').val(),
            medical_certificate_anyother: $('#MClabintxtanyother4').val(),
            medical_certificate_val: $('#MClabinChkprocedureReports').val(),
            medical_certificate_customize_id: $('#MClabinChkother4').val(),
            medical_certificate_customize: $('#MClabinlblcustomize4').val(),
        }
        $.ajax({
            async: true,
            type: 'POST',
            url: '/Prescription_Settings/medicalcertificate_print_settings',
            contentType: 'application/json; charset=UTF-8',
            data: JSON.stringify(details),
            success: function (data) {

                var data2 = JSON.parse(data);
                if (data2.msg == "Success") {
                    var data1 = data2.data;

                    //window.location.href = '/Prescription_Settings/';
                }
                else {
                    console.log(data);
                }

            }
        });
    }
}
// print medical certificate


// discharge summary

$('#btnDSsubmit').click(function () {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        discharge_summary_page_setting: $('#DSChkdischargeSetting').val(),
        discharge_summary_page_top: $('#DSlabinmtop4').val(),
        discharge_summary_page_bottom: $('#DSlabinmbottom4').val(),
        discharge_summary_header: $('#DSChkheader4').val(),
        discharge_summary_logo: $('#Hdn_dischargesummary_image').val(),
        discharge_summary_footer: $('#DSChkfooter4').val(),
        discharge_advice: $('#ChkDischargeAdvice').val(),
        follow_up_instruction: $('#ChkFollowUpInstruct').val(),
        treatment_in_hospital: $('#ChkTreatmentInHospital').val(),
        examination: $('#ChkExamination').val(),
        patient_history: $('#ChkPatientHistory').val(),
        investigation_history: $('#ChkInvestigationHistory').val(),
        operation_details: $('#ChkOperationDetails').val(),
        transfer_order: $('#ChkTransferOrder').val()
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/DischargeSummaryPrintSettings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                toastr.success("<button type='button' id='confirmationRevertYes' class='btn btn-warning btn-xs mt20'>OK</button>", 'Discharge Summary Saved Successfully',
                       {
                           closeButton: true,
                           progressBar: true,
                           allowHtml: true,
                           timeOut: 20000000,

                           onShown: function (toast) {
                               $("#confirmationRevertYes").click(function () {
                                   window.location.href = '/Prescription_Settings/';
                               })
                           }
                       })
                
            }
            else {
                console.log(data);
            }

        }
    });
});

function discharge_summary_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S',
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/DischargeSummaryPrintSettings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            console.log(data);
            var data = JSON.parse(data);
            if (jQuery.isEmptyObject((data.data))) {
            }
            else {
                
                if (data.msg == "Success") {
                    var data = data.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {

                            $('#DSlabinmtop4').val(data.Table[i].discharge_page_top);
                            $('#DSlabinmbottom4').val(data.Table[i].discharge_page_bottom);
                            $('#DSChkdischargeSetting').val(data.Table[i].discharge_page_setting);
                            $('a[data-toggle=DSChkdischargeSetting][data-title="' + data.Table[i].discharge_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=DSChkdischargeSetting][data-title="' + data.Table[i].discharge_page_setting + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#DSprocedurelog').empty();
                            var d, n, drloimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].discharge_logo != null) {
                                $('#DSprocedurelog').show();
                                drloimage = filepath + Doctor_Id + '/dischargesummary/' + data.Table[i].discharge_logo + '?' + n;
                                $('#DSprocedurelog').append('<a href="' + drloimage + '" target="_blank">Discharge Summary logo</a>');
                                $('#Hdn_dischargesummary_image').val(data.Table[i].discharge_logo);
                            }

                            $('#DSChkheader4').val(data.Table[i].discharge_header);
                            $('a[data-toggle=DSChkheader4][data-title="' + data.Table[i].discharge_header + '"]').removeClass('not-active');
                            $('a[data-toggle=DSChkheader4][data-title="' + data.Table[i].discharge_header + '"]').addClass('active');


                            $('#DSChkfooter4').val(data.Table[i].discharge_footer);
                            $('a[data-toggle=DSChkfooter4][data-title="' + data.Table[i].discharge_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=DSChkfooter4][data-title="' + data.Table[i].discharge_footer + '"]').addClass('active');

                            $('#ChkDischargeAdvice').val(data.Table[i].discharge_advice);
                            $('a[data-toggle=ChkDischargeAdvice][data-title="' + data.Table[i].discharge_advice + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkDischargeAdvice][data-title="' + data.Table[i].discharge_advice + '"]').addClass('active');

                            $('#ChkFollowUpInstruct').val(data.Table[i].follow_up_instructions);
                            $('a[data-toggle=ChkFollowUpInstruct][data-title="' + data.Table[i].follow_up_instructions + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkFollowUpInstruct][data-title="' + data.Table[i].follow_up_instructions + '"]').addClass('active');

                            $('#ChkTreatmentInHospital').val(data.Table[i].treatment);
                            $('a[data-toggle=ChkTreatmentInHospital][data-title="' + data.Table[i].treatment + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkTreatmentInHospital][data-title="' + data.Table[i].treatment + '"]').addClass('active');

                            $('#ChkExamination').val(data.Table[i].examination);
                            $('a[data-toggle=ChkExamination][data-title="' + data.Table[i].examination + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkExamination][data-title="' + data.Table[i].examination + '"]').addClass('active');

                            $('#ChkPatientHistory').val(data.Table[i].patient_history);
                            $('a[data-toggle=ChkPatientHistory][data-title="' + data.Table[i].patient_history + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkPatientHistory][data-title="' + data.Table[i].patient_history + '"]').addClass('active');

                            $('#ChkInvestigationHistory').val(data.Table[i].investigation_history);
                            $('a[data-toggle=ChkInvestigationHistory][data-title="' + data.Table[i].investigation_history + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkInvestigationHistory][data-title="' + data.Table[i].investigation_history + '"]').addClass('active');

                            $('#ChkOperationDetails').val(data.Table[i].operation_details);
                            $('a[data-toggle=ChkOperationDetails][data-title="' + data.Table[i].operation_details + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkOperationDetails][data-title="' + data.Table[i].operation_details + '"]').addClass('active');

                            $('#ChkTransferOrder').val(data.Table[i].transfer_order);
                            $('a[data-toggle=ChkTransferOrder][data-title="' + data.Table[i].transfer_order + '"]').removeClass('not-active');
                            $('a[data-toggle=ChkTransferOrder][data-title="' + data.Table[i].transfer_order + '"]').addClass('active');
                        }
                    }
                }
                else {
                    console.log(data);
                }

            }
        }

    });
}



$('#DSdocuments4').change(function () {
    DischargeSummaryLogoUpload();
});

function DischargeSummaryLogoUpload() {
    var uploadpath = $('#DSdocuments4').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);
    if (window.FormData !== undefined) {
        var fileUpload = $("#DSdocuments4").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        for (var i = 0; i < files.length; i++) {
            fileData.append(files[i].name, files[i]);
        }
        fileData.append('username', 'Manas');
        $.ajax({
            url: '/Prescription_Settings/UploadPhotoFilesDischargeSummary',
            type: "POST",
            contentType: false, // Not to set any content header
            processData: false, // Not to process data
            data: fileData,
            success: function (result) {
                console.log(result);
                $.each(result, function (i, emp) {
                    $('#Hdn_dischargesummary_image').val(emp);
                    var filepath, photo, profilephoto, Doctor_Id, d, n, mcimage;
                    filepath = $('#hdnfilepath1').val();
                    photo = $('#hdnPhoto').val();
                    profilephoto = $('#Hdn_dischargesummary_image').val();
                    Doctor_Id = $('#myHiddenVar').val();
                    d = new Date();
                    n = d.getTime();
                    mcimage = filepath + Doctor_Id + '/dischargesummary/' + profilephoto + '?' + n;
                    console.log(mcimage);
                    $('#DSprocedurelog').empty();
                    $('#DSprocedurelog').append('<a href="' + mcimage + '" target="_blank">Discharge Summary logo</a>');
                });
            }
        });
    }
}
//discharge summary

//referral print details on load
function referral_print_details() {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'S',
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/ReferralPrintSettings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (jQuery.isEmptyObject((data2.data))) {
            }
            else {

                if (data2.msg == "Success") {
                    var data = data2.data;

                    //var data = JSON.parse(data);
                    if (data.Table.length > 0) {
                        for (var i = 0; i < data.Table.length; i++) {
                            $('#Refdiettop4').val(data.Table[i].referral_page_top);
                            $('#Refdietbottom4').val(data.Table[i].referral_page_bottom);
                            $('#RefdietChkheader4').val(data.Table[i].referral_page_setting);
                            $('a[data-toggle=RefdietChkheader4][data-title="' + data.Table[i].referral_page_setting + '"]').removeClass('not-active');
                            $('a[data-toggle=RefdietChkheader4][data-title="' + data.Table[i].referral_page_setting + '"]').addClass('active');

                            var filepath = $('#hdnfilepath1').val();
                            var Doctor_Id = $('#myHiddenVar').val();
                            $('#Refdietlog').empty();
                            var d, n, drloimage;
                            d = new Date();
                            n = d.getTime();
                            if (data.Table[i].referral_logo != null) {
                                $('#Refdietlog').show();
                                drloimage = filepath + Doctor_Id + '/referral/' + data.Table[i].referral_logo + '?' + n;
                                $('#Refdietlog').append('<a href="' + drloimage + '" target="_blank">Referral Logo</a>');
                                $('#Hdn_refdiet_image').val(data.Table[i].referral_logo);
                            }

                            if (data.Table[i].doctor_signature != null) {
                                $('#refdoctorsignimg').show();
                                drloimage = filepath + Doctor_Id + '/referral/' + data.Table[i].doctor_signature + '?' + n;
                                $('#refdoctorsignimg').append('<a href="' + drloimage + '" target="_blank">Sign</a>');
                                $('#Hdn_refdoctorsign').val(data.Table[i].doctor_signature);
                            }

                            $('#RefdietChkfooter4').val(data.Table[i].referral_footer);
                            $('a[data-toggle=RefdietChkfooter4][data-title="' + data.Table[i].referral_footer + '"]').removeClass('not-active');
                            $('a[data-toggle=RefdietChkfooter4][data-title="' + data.Table[i].referral_footer + '"]').addClass('active');

                            $('#Refdiet1Chkheader4').val(data.Table[i].referral_header);
                            $('a[data-toggle=Refdiet1Chkheader4][data-title="' + data.Table[i].referral_header + '"]').removeClass('not-active');
                            $('a[data-toggle=Refdiet1Chkheader4][data-title="' + data.Table[i].referral_header + '"]').addClass('active');

                            $('#refChkDoctorName').val(data.Table[i].doctor_name);
                            $('a[data-toggle=refChkDoctorName][data-title="' + data.Table[i].doctor_name + '"]').removeClass('not-active');
                            $('a[data-toggle=refChkDoctorName][data-title="' + data.Table[i].doctor_name + '"]').addClass('active');

                            $('#refChkNPI').val(data.Table[i].npi);
                            $('a[data-toggle=refChkNPI][data-title="' + data.Table[i].npi + '"]').removeClass('not-active');
                            $('a[data-toggle=refChkNPI][data-title="' + data.Table[i].npi + '"]').addClass('active');

                            $('#refChksignature').val(data.Table[i].signature);
                            $('a[data-toggle=refChksignature][data-title="' + data.Table[i].signature + '"]').removeClass('not-active');
                            $('a[data-toggle=refChksignature][data-title="' + data.Table[i].signature + '"]').addClass('active');

                            $('#refChkSingType').val(data.Table[i].doctor_signature_size);
                            $('a[data-toggle=refChkSingType][data-title="' + data.Table[i].doctor_signature_size + '"]').removeClass('not-active');
                            $('a[data-toggle=refChkSingType][data-title="' + data.Table[i].doctor_signature_size + '"]').addClass('active');

                            $('#refChkdqual').val(data.Table[i].doctor_qualification);
                            $('a[data-toggle=refChkdqual][data-title="' + data.Table[i].doctor_qualification + '"]').removeClass('not-active');
                            $('a[data-toggle=refChkdqual][data-title="' + data.Table[i].doctor_qualification + '"]').addClass('active');

                        }
                    }
                }
                else {
                    console.log(data);
                }
            }
        }
    });
}

//referral logo upload
$('#Refdietdocuments4').change(function () {
    RefLogoUpload();
});

function RefLogoUpload() {
    var uploadpath = $('#Refdietdocuments4').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);
    if (window.FormData !== undefined) {
        var fileUpload = $("#Refdietdocuments4").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        for (var i = 0; i < files.length; i++) {
            fileData.append(files[i].name, files[i]);
        }
        fileData.append('username', 'Manas');
        $.ajax({
            url: '/Prescription_Settings/ReferralLogoUpload',
            type: "POST",
            contentType: false, // Not to set any content header
            processData: false, // Not to process data
            data: fileData,
            success: function (result) {
                console.log(result);
                $.each(result, function (i, emp) {
                    $('#Hdn_refdiet_image').val(emp);
                    var filepath, profilephoto, Doctor_Id, d, n, mcimage;
                    filepath = $('#hdnfilepath1').val();
                    profilephoto = $('#Hdn_refdiet_image').val();
                    Doctor_Id = $('#myHiddenVar').val();
                    d = new Date();
                    n = d.getTime();
                    mcimage = filepath + Doctor_Id + '/referral/' + profilephoto + '?' + n;
                    $('#Refdietlog').empty();
                    $('#Refdietlog').append('<a href="' + mcimage + '" target="_blank">Referral Logo</a>');
                });
            }
        });
    }
}

//referral print setting save

$('#btnreferralprint').click(function () {
    var details = {
        doctor_id: $('#HiddenDoctorID').val(),
        Dml_Indicator: 'I',
        referral_page_setting: $('#RefdietChkheader4').val(),
        referral_page_top: $('#Refdiettop4').val(),
        referral_page_bottom: $('#Refdietbottom4').val(),
        referral_header: $('#Refdiet1Chkheader4').val(),
        referral_logo: $('#Hdn_refdiet_image').val(),
        referral_footer: $('#RefdietChkfooter4').val(),
        referral_val: "1",
        ref_doctor_name: $('#refChkDoctorName').val(),
        ref_npi: $('#refChkNPI').val(),
        ref_signature: $('#refChksignature').val(),
        ref_doctor_signature: $('#Hdn_refdoctorsign').val(),
        refdoctor_signature_size: $('#refChkSingType').val(),
        refdoctor_qualification: $('#refChkdqual').val()
    }
    $.ajax({
        async: true,
        type: 'POST',
        url: '/Prescription_Settings/ReferralPrintSettings',
        contentType: 'application/json; charset=UTF-8',
        data: JSON.stringify(details),
        success: function (data) {
            var data2 = JSON.parse(data);
            if (data2.msg == "Success") {
                var data1 = data2.data;
                window.location.href = '/Prescription_Settings/';
            }
            else {
                console.log(data);
            }

        }
    });
});

//referral doctor sign upload

$('#refdoctorsign').change(function () {
    RefSignLogoUpload();
});

function RefSignLogoUpload() {
    var uploadpath = $('#refdoctorsign').val();
    var fileExtension = uploadpath.substring(uploadpath.lastIndexOf(".") + 1, uploadpath.length);
    if (window.FormData !== undefined) {
        var fileUpload = $("#refdoctorsign").get(0);
        var files = fileUpload.files;
        var fileData = new FormData();
        for (var i = 0; i < files.length; i++) {
            fileData.append(files[i].name, files[i]);
        }
        fileData.append('username', 'Manas');
        $.ajax({
            url: '/Prescription_Settings/ReferralSignLogoUpload',
            type: "POST",
            contentType: false, // Not to set any content header
            processData: false, // Not to process data
            data: fileData,
            success: function (result) {
                console.log(result);
                $.each(result, function (i, emp) {
                    $('#Hdn_refdoctorsign').val(emp);
                    var filepath, profilephoto, Doctor_Id, d, n, mcimage;
                    filepath = $('#hdnfilepath1').val();
                    profilephoto = $('#Hdn_refdoctorsign').val();
                    Doctor_Id = $('#myHiddenVar').val();
                    d = new Date();
                    n = d.getTime();
                    mcimage = filepath + Doctor_Id + '/referral/' + profilephoto + '?' + n;
                    $('#refdoctorsignimg').empty();
                    $('#refdoctorsignimg').append('<a href="' + mcimage + '" target="_blank">Sign</a>');
                });
            }
        });
    }
}