update 33
This commit is contained in:
parent
5f98198b67
commit
b02c277bb8
@ -41,30 +41,27 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- Patient Form: Auto-calculate DOB from Age ---
|
// --- Patient Form: Auto-calculate DOB from Age ---
|
||||||
function calculateDobFromAge(ageInputId, dobInputId) {
|
// Use jQuery for better compatibility with Inputmask and existing events
|
||||||
const ageInput = document.getElementById(ageInputId);
|
function setupAgeToDob(ageId, dobId) {
|
||||||
const dobInput = document.getElementById(dobInputId);
|
$(document).on('input', '#' + ageId, function() {
|
||||||
|
var age = parseInt($(this).val());
|
||||||
if (ageInput && dobInput) {
|
var $dob = $('#' + dobId);
|
||||||
ageInput.addEventListener('input', function() {
|
|
||||||
const age = parseInt(this.value);
|
if (!isNaN(age) && age >= 0) {
|
||||||
if (!isNaN(age) && age >= 0) {
|
var currentYear = new Date().getFullYear();
|
||||||
const currentYear = new Date().getFullYear();
|
var birthYear = currentYear - age;
|
||||||
const birthYear = currentYear - age;
|
// Default to Jan 1st of the birth year: YYYY-01-01
|
||||||
// Default to Jan 1st of the birth year
|
var dob = birthYear + '-01-01';
|
||||||
const dob = `${birthYear}-01-01`;
|
|
||||||
dobInput.value = dob;
|
// Set value and trigger input/change for Inputmask and other listeners
|
||||||
|
$dob.val(dob).trigger('input').trigger('change');
|
||||||
// Trigger change event if needed (e.g. for validation or other listeners)
|
} else {
|
||||||
dobInput.dispatchEvent(new Event('change'));
|
// Optional: Clear DOB if age is invalid/cleared?
|
||||||
dobInput.dispatchEvent(new Event('input'));
|
// $dob.val('').trigger('input');
|
||||||
} else {
|
}
|
||||||
dobInput.value = '';
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateDobFromAge('add_patient_age', 'add_patient_dob');
|
setupAgeToDob('add_patient_age', 'add_patient_dob');
|
||||||
calculateDobFromAge('edit_patient_age', 'edit_patient_dob');
|
setupAgeToDob('edit_patient_age', 'edit_patient_dob');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1299,6 +1299,7 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/5.0.7/jquery.inputmask.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/5.0.7/jquery.inputmask.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.js"></script>
|
||||||
<script src="assets/js/ai_helper.js"></script>
|
<script src="assets/js/ai_helper.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
<script>
|
<script>
|
||||||
// --- Patient Modals ---
|
// --- Patient Modals ---
|
||||||
function showEditPatientModal(data) {
|
function showEditPatientModal(data) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user