$(document).ready(function() {
    $('table[data-form="pacientesForm"]').on("click", ".paciente-delete", function(e) {
            e.preventDefault();
            var $form = $(this);
            $("#eliminarPaciente").modal({ backdrop: "static", keyboard: false })
                .on("click", "#delete-paciente-btn", function() {
                    $form.submit();
                });
        }
    );
    $("#pacienteOrdenMedica").on("show.bs.modal", function(event) {
        var button = $(event.relatedTarget);
        var recipient = button.data("image");
        var modal = $(this);
        modal.find(".paciente-orden-medica").attr("src", recipient);
    });
});

function CalculaEdad(e){
    var x = (e.target.value);
    if(x!==""){
        var fecha = new Date(e.target.value);
        var fechaNow = new Date();
        var diff = fechaNow - fecha;

        var nroAnios = 0;
        var nroDias = Math.round(diff/(1000*60*60*24));
        nroAnios = Math.floor(nroDias / 365);
        document.getElementById("txt_edad").value = nroAnios;
    }
}
