Team4 - Molecule Identification form Changes (not allowing same doctor in same table but allowing same doctor in different table if it is not already covered in other molecule use.)
Specific Folder FTP Upload / ftp-deploy (push) Successful in 41s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 41s
Details
This commit is contained in:
parent
463d464acb
commit
cf768ce3df
|
|
@ -492,7 +492,7 @@ select option:disabled {
|
|||
var categoryDoctorSubmissions = {!! json_encode($categoryDoctorSubmissions) !!};
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
$(document).on(
|
||||
/* $(document).on(
|
||||
'change',
|
||||
'.other-molecule-select',
|
||||
function(){
|
||||
|
|
@ -502,7 +502,17 @@ select option:disabled {
|
|||
);
|
||||
|
||||
}
|
||||
);*/
|
||||
$(document).on('change', '.other-molecule-select', function(){
|
||||
|
||||
toggleOtherMoleculeRxSupport(
|
||||
$(this).closest('tr')
|
||||
);
|
||||
|
||||
updateDoctorDropdowns();
|
||||
updateOtherMoleculeOptions();
|
||||
|
||||
});
|
||||
function getDoctorRows() {
|
||||
let rows = [];
|
||||
|
||||
|
|
@ -653,7 +663,7 @@ select option:disabled {
|
|||
});
|
||||
}
|
||||
*/
|
||||
function updateDoctorDropdowns() {
|
||||
/*function updateDoctorDropdowns() {
|
||||
|
||||
let selectedDoctors = [];
|
||||
|
||||
|
|
@ -693,6 +703,294 @@ select option:disabled {
|
|||
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
/* This func is like allowing same doctor in same table
|
||||
|
||||
function updateDoctorDropdowns() {
|
||||
|
||||
let blockedDoctors = {
|
||||
erdosteine: [],
|
||||
erdosteine_acebrophylline: [],
|
||||
nac_acebrophylline: []
|
||||
};
|
||||
|
||||
$('.doctor-row').each(function(){
|
||||
|
||||
let doctorId = $(this).find('.doctor-select').val();
|
||||
let otherMolecule = $(this).find('.other-molecule-select').val();
|
||||
|
||||
if(!doctorId || !otherMolecule){
|
||||
return;
|
||||
}
|
||||
|
||||
switch(otherMolecule){
|
||||
|
||||
case 'Erdosteine Prescriber':
|
||||
blockedDoctors.erdosteine.push(doctorId);
|
||||
break;
|
||||
|
||||
case 'Erdosteine + Acebrophylline':
|
||||
blockedDoctors.erdosteine_acebrophylline.push(doctorId);
|
||||
break;
|
||||
|
||||
case 'NAC + Acebrophylline':
|
||||
blockedDoctors.nac_acebrophylline.push(doctorId);
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('.doctor-table-body').each(function(){
|
||||
|
||||
let category = $(this).data('category');
|
||||
|
||||
let doctorsToBlock = blockedDoctors[category] || [];
|
||||
|
||||
$(this).find('.doctor-select').each(function(){
|
||||
|
||||
let currentDropdown = $(this);
|
||||
let currentValue = currentDropdown.val();
|
||||
|
||||
currentDropdown.find('option').each(function(){
|
||||
|
||||
let option = $(this);
|
||||
let originalText = option.data('original-text') || option.text();
|
||||
|
||||
option.data('original-text', originalText);
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(originalText);
|
||||
|
||||
let optionValue = option.val();
|
||||
|
||||
if(
|
||||
optionValue &&
|
||||
optionValue !== currentValue &&
|
||||
doctorsToBlock.includes(optionValue)
|
||||
){
|
||||
option.prop('disabled', true);
|
||||
option.text(originalText + ' (Already Added)');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
/*This function is like not same doctor in same table. */
|
||||
|
||||
function updateDoctorDropdowns() {
|
||||
|
||||
let blockedDoctors = {
|
||||
erdosteine: [],
|
||||
erdosteine_acebrophylline: [],
|
||||
nac_acebrophylline: []
|
||||
};
|
||||
|
||||
let sameTableDoctors = {};
|
||||
|
||||
$('.doctor-table-body').each(function(){
|
||||
|
||||
let category = $(this).data('category');
|
||||
|
||||
sameTableDoctors[category] = [];
|
||||
|
||||
$(this).find('.doctor-row').each(function(){
|
||||
|
||||
let doctorId = $(this).find('.doctor-select').val();
|
||||
let otherMolecule = $(this).find('.other-molecule-select').val();
|
||||
|
||||
// Same table duplicate tracking
|
||||
if(doctorId){
|
||||
sameTableDoctors[category].push(doctorId);
|
||||
}
|
||||
|
||||
// Existing business logic
|
||||
if(!doctorId || !otherMolecule){
|
||||
return;
|
||||
}
|
||||
|
||||
switch(otherMolecule){
|
||||
|
||||
case 'Erdosteine Prescriber':
|
||||
blockedDoctors.erdosteine.push(doctorId);
|
||||
break;
|
||||
|
||||
case 'Erdosteine + Acebrophylline':
|
||||
blockedDoctors.erdosteine_acebrophylline.push(doctorId);
|
||||
break;
|
||||
|
||||
case 'NAC + Acebrophylline':
|
||||
blockedDoctors.nac_acebrophylline.push(doctorId);
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('.doctor-table-body').each(function(){
|
||||
|
||||
let category = $(this).data('category');
|
||||
|
||||
let doctorsToBlock = blockedDoctors[category] || [];
|
||||
let sameTableBlocked = sameTableDoctors[category] || [];
|
||||
|
||||
$(this).find('.doctor-select').each(function(){
|
||||
|
||||
let currentDropdown = $(this);
|
||||
let currentValue = currentDropdown.val();
|
||||
|
||||
currentDropdown.find('option').each(function(){
|
||||
|
||||
let option = $(this);
|
||||
let originalText = option.data('original-text') || option.text();
|
||||
|
||||
option.data('original-text', originalText);
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(originalText);
|
||||
|
||||
let optionValue = option.val();
|
||||
|
||||
if(
|
||||
optionValue &&
|
||||
optionValue !== currentValue &&
|
||||
(
|
||||
doctorsToBlock.includes(optionValue) ||
|
||||
sameTableBlocked.includes(optionValue)
|
||||
)
|
||||
){
|
||||
option.prop('disabled', true);
|
||||
option.text(originalText + ' (Already Added)');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function updateOtherMoleculeOptions() {
|
||||
|
||||
let doctorCoverage = {};
|
||||
|
||||
$('.doctor-table-body').each(function(){
|
||||
|
||||
let tableCategory = $(this).data('category');
|
||||
|
||||
$(this).find('.doctor-row').each(function(){
|
||||
|
||||
let doctorId = $(this).find('.doctor-select').val();
|
||||
let otherMolecule = $(this).find('.other-molecule-select').val();
|
||||
|
||||
if(!doctorId){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!doctorCoverage[doctorId]){
|
||||
doctorCoverage[doctorId] = [];
|
||||
}
|
||||
|
||||
// current table coverage
|
||||
if(!doctorCoverage[doctorId].includes(tableCategory)){
|
||||
doctorCoverage[doctorId].push(tableCategory);
|
||||
}
|
||||
|
||||
// other molecule coverage
|
||||
switch(otherMolecule){
|
||||
|
||||
case 'Erdosteine Prescriber':
|
||||
if(!doctorCoverage[doctorId].includes('erdosteine')){
|
||||
doctorCoverage[doctorId].push('erdosteine');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Erdosteine + Acebrophylline':
|
||||
if(!doctorCoverage[doctorId].includes('erdosteine_acebrophylline')){
|
||||
doctorCoverage[doctorId].push('erdosteine_acebrophylline');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NAC + Acebrophylline':
|
||||
if(!doctorCoverage[doctorId].includes('nac_acebrophylline')){
|
||||
doctorCoverage[doctorId].push('nac_acebrophylline');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('.doctor-row').each(function(){
|
||||
|
||||
let doctorId = $(this).find('.doctor-select').val();
|
||||
|
||||
if(!doctorId){
|
||||
return;
|
||||
}
|
||||
|
||||
let coverage = doctorCoverage[doctorId] || [];
|
||||
|
||||
let ddl = $(this).find('.other-molecule-select');
|
||||
let currentValue = ddl.val();
|
||||
|
||||
ddl.find('option').each(function(){
|
||||
|
||||
let option = $(this);
|
||||
let originalText = option.data('original-text') || option.text();
|
||||
|
||||
option.data('original-text', originalText);
|
||||
|
||||
option.prop('disabled', false);
|
||||
option.text(originalText);
|
||||
|
||||
let optionValue = option.val();
|
||||
|
||||
let targetCategory = '';
|
||||
|
||||
switch(optionValue){
|
||||
|
||||
case 'Erdosteine Prescriber':
|
||||
targetCategory = 'erdosteine';
|
||||
break;
|
||||
|
||||
case 'Erdosteine + Acebrophylline':
|
||||
targetCategory = 'erdosteine_acebrophylline';
|
||||
break;
|
||||
|
||||
case 'NAC + Acebrophylline':
|
||||
targetCategory = 'nac_acebrophylline';
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if(
|
||||
coverage.includes(targetCategory) &&
|
||||
optionValue !== currentValue
|
||||
){
|
||||
option.prop('disabled', true);
|
||||
option.text(originalText + ' (Already Covered)');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
function updateOtherMoleculeDropdowns($tbody) {
|
||||
let sectionMolecule = $tbody.data('molecule-use');
|
||||
|
||||
|
|
@ -785,9 +1083,16 @@ select option:disabled {
|
|||
/*$(document).on('change', '.doctor-select', function() {
|
||||
updateDoctorDropdowns($(this).closest('.doctor-table-body'));
|
||||
});*/
|
||||
/* $(document).on('change', '.doctor-select', function() {
|
||||
updateDoctorDropdowns();
|
||||
}); */
|
||||
$(document).on('change', '.doctor-select', function() {
|
||||
updateDoctorDropdowns();
|
||||
});
|
||||
updateOtherMoleculeOptions();
|
||||
});
|
||||
$(document).on('change', '.other-molecule-select', function() {
|
||||
updateDoctorDropdowns();
|
||||
});
|
||||
|
||||
$('.doctor-select').select2({
|
||||
width: '100%',
|
||||
|
|
|
|||
Loading…
Reference in New Issue