Titans (ISP Reporting) Doctor & MSL code
Specific Folder FTP Upload / ftp-deploy (push) Successful in 2m10s Details

This commit is contained in:
zeeshan 2026-11-17 11:46:08 +05:30
parent cf6c097d75
commit b7986cd015
1 changed files with 175 additions and 2 deletions

View File

@ -364,7 +364,7 @@
// $(mslField).parent().hide();
// })
$('#field-no_of_attendees').on('change',function(){
/* $('#field-no_of_attendees').on('change',function(){
let qtyValue=parseInt($(this).val());
$('#doctor_msl_wrapper').html('')
for(let i = 1; i <= qtyValue; i++) {
@ -377,7 +377,180 @@
<input type="text" id="field-msl_code_${i}" name="msl_code[]" class="form-control" value="" required>
</div>`)
}
})
}) */
// Generate Doctor Dropdowns based on No. of Attendees
$('#field-no_of_attendees').on('change', function () {
let qtyValue = parseInt($(this).val()) || 0;
$('#doctor_msl_wrapper').html('');
for (let i = 1; i <= qtyValue; i++) {
let doctorHtml = `
<div class="col-md-12 mb-2">
<label for="field-contact_id_${i}" class="form-label">
HCP Name ${i}
<span class="text-danger">*</span>
</label>
<select
id="field-contact_id_${i}"
name="contact_id[]"
class="form-control doctor-dropdown"
required>
<option value="">-- Select Doctor --</option>
</select>
</div>
<div class="col-md-12 mb-2">
<label for="field-msl_code_${i}" class="form-label">
P Code ${i}
<span class="text-danger">*</span>
</label>
<input
type="text"
id="field-msl_code_${i}"
name="msl_code[]"
class="form-control"
value=""
readonly
required>
</div>
`;
$('#doctor_msl_wrapper').append(doctorHtml);
let select = $('#field-contact_id_' + i);
// Load doctors from API response
contacts.forEach(function (itm) {
if (!itm || !itm.value || !itm.display) {
return;
}
let doctorValue = String(itm.value);
let doctorName = String(itm.display);
let legacyCode = '';
if (itm.contact) {
legacyCode = itm.contact.legacy_code || itm.contact.msl_code || '';
} else {
legacyCode = itm.legacy_code || itm.msl_code || '';
}
let valCheck = doctorValue.trim().toLowerCase();
let textCheck = doctorName.trim().toLowerCase();
let isAlreadySubmitted =
submittedDoctors.includes(valCheck) ||
submittedDoctors.includes(textCheck);
let displayText = doctorName;
if (isAlreadySubmitted) {
displayText += ' - Already Added';
}
let option = $('<option></option>')
.val(doctorValue)
.text(displayText)
.attr('data-legacy-code', legacyCode)
.prop('disabled', isAlreadySubmitted);
select.append(option);
});
// Initialize Select2
select.select2({
width: '100%',
placeholder: '-- Select Doctor --',
allowClear: true
});
}
});
// When Doctor is selected, populate P Code
$(document).on('change', '.doctor-dropdown', function () {
let selectedOption = $(this).find(':selected');
let legacyCode = selectedOption.attr('data-legacy-code') || '';
let selectId = $(this).attr('id');
let match = selectId.match(/^field-contact_id_(\d+)$/);
if (match) {
let index = match[1];
$('#field-msl_code_' + index).val(legacyCode);
}
// Prevent duplicate doctor selection
let selectedValues = [];
$('.doctor-dropdown').each(function () {
let value = $(this).val();
if (value) {
selectedValues.push(String(value));
}
});
$('.doctor-dropdown').each(function () {
let currentSelect = $(this);
let currentValue = String(currentSelect.val() || '');
currentSelect.find('option').each(function () {
let option = $(this);
let optionValue = String(option.val() || '');
if (!optionValue) {
return;
}
if (
selectedValues.includes(optionValue) &&
optionValue !== currentValue
) {
option.prop('disabled', true);
} else if (
!option.text().includes('Already Added')
) {
option.prop('disabled', false);
}
});
currentSelect.trigger('change.select2');
});
});
function hideDoctorFields (){
docNameFields.forEach((docField, index) => {