Zenova Form Changes - Glipiq & Sitazit Tracker
This commit is contained in:
parent
24cb3e0c41
commit
12cf281a28
|
|
@ -239,7 +239,20 @@
|
|||
$('#field-contact_id').html('')
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",'').text('-- Select --'));
|
||||
for (let itm of data) {
|
||||
$('#field-contact_id').append($("<option></option>").attr("value",itm.value).text(itm.display).attr("msl_code", itm.contact.msl_code).attr('speciality',itm.contact.speciality).attr("absi_camp", itm.contact.absi_camp || ''));
|
||||
|
||||
let absiCamp = itm.contact.absi_camp;
|
||||
|
||||
console.log("Doctor:", itm.display);
|
||||
console.log("ABSI from API:", absiCamp);
|
||||
|
||||
$('#field-contact_id').append(
|
||||
$("<option></option>")
|
||||
.attr("value", itm.value)
|
||||
.text(itm.display)
|
||||
.attr("msl_code", itm.contact.msl_code || '')
|
||||
.attr("speciality", itm.contact.speciality || '')
|
||||
.attr("absi_camp", absiCamp || '')
|
||||
);
|
||||
}
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
|
|
@ -297,10 +310,30 @@
|
|||
})
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-absi_camp').val(
|
||||
$('option:selected', this).attr('absi_camp') || ''
|
||||
);
|
||||
|
||||
const selectedDoctor = $('option:selected', this);
|
||||
|
||||
let absiCamp = selectedDoctor.attr('absi_camp') || '';
|
||||
|
||||
console.log("Selected doctor:", selectedDoctor.text());
|
||||
console.log("ABSI attribute:", absiCamp);
|
||||
|
||||
// Convert 1/0 to Yes/No if required
|
||||
if (absiCamp == 1 || absiCamp === '1') {
|
||||
absiCamp = 'Yes';
|
||||
}
|
||||
else if (absiCamp == 0 || absiCamp === '0') {
|
||||
absiCamp = 'No';
|
||||
}
|
||||
|
||||
$('#field-absi_camp').val(absiCamp);
|
||||
|
||||
// This will show/hide No of Patients Screened
|
||||
toggleAbsiPatientsField();
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#field-contact_id').change(function() {
|
||||
$('#field-h1_cardio_conference').val(
|
||||
$('option:selected', this).attr('h1_cardio_conference') || ''
|
||||
|
|
@ -361,12 +394,20 @@
|
|||
}
|
||||
})
|
||||
|
||||
$('#field-absi_camp').on('change',function(){
|
||||
let value=$(this).val();
|
||||
if(value=='Yes'){
|
||||
$('#report-form').append('<input type="hidden" name="absi_camp_count" value="1">')
|
||||
$('#field-absi_camp').on('change', function(){
|
||||
|
||||
let value = $(this).val();
|
||||
|
||||
if(value == 'Yes'){
|
||||
$('#report-form input[name="absi_camp_count"]').val(1);
|
||||
} else {
|
||||
$('#report-form input[name="absi_camp_count"]').val(0);
|
||||
}
|
||||
})
|
||||
|
||||
toggleAbsiPatientsField();
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('#field-h1_cardio_conference').on('change',function(){
|
||||
let value=$(this).val();
|
||||
|
|
@ -393,19 +434,59 @@
|
|||
].join(',');
|
||||
|
||||
function toggleFields(selector, show) {
|
||||
$(selector).parent().toggle(show);
|
||||
$(selector).prop('required', show);
|
||||
$(selector).parent().toggle(show);
|
||||
$(selector).prop('required', show);
|
||||
}
|
||||
|
||||
function toggleAbsiPatientsField() {
|
||||
|
||||
let absiCamp = $('#field-absi_camp').val();
|
||||
const brand = $('#field-select_brand').val();
|
||||
|
||||
// Convert stored 1/0 values to Yes/No
|
||||
if (absiCamp == 1 || absiCamp === '1') {
|
||||
absiCamp = 'Yes';
|
||||
$('#field-absi_camp').val('Yes');
|
||||
}
|
||||
else if (absiCamp == 0 || absiCamp === '0') {
|
||||
absiCamp = 'No';
|
||||
$('#field-absi_camp').val('No');
|
||||
}
|
||||
|
||||
const $patientsField = $('#field-no_of_patients_screened');
|
||||
const $patientsWrapper = $patientsField.closest('.col-md-12');
|
||||
|
||||
console.log("Brand:", brand);
|
||||
console.log("ABSI:", absiCamp);
|
||||
|
||||
if (brand === 'Glipiq' && absiCamp === 'Yes') {
|
||||
|
||||
$patientsWrapper.show();
|
||||
$patientsField.prop('required', true);
|
||||
|
||||
} else {
|
||||
|
||||
$patientsField.val('');
|
||||
$patientsWrapper.hide();
|
||||
$patientsField.prop('required', false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Initial hide
|
||||
toggleFields(glipiFields, false);
|
||||
toggleFields(sitazitFields, false);
|
||||
|
||||
$('#field-no_of_patients_screened').parent().hide();
|
||||
$('#field-no_of_patients_screened').prop('required', false);
|
||||
|
||||
|
||||
$('#field-select_brand').on('change', function () {
|
||||
const brand = $(this).val();
|
||||
console.log("Brand is :",brand);
|
||||
toggleFields(glipiFields, brand === 'Glipiq');
|
||||
toggleFields(sitazitFields, brand === 'Sitazit');
|
||||
toggleAbsiPatientsField();
|
||||
|
||||
if(brand==='Glipiq'){
|
||||
/* $('#report-form').append('<input type="hidden" name="glipiq_rx_total" value="0" >');
|
||||
|
|
@ -456,6 +537,7 @@
|
|||
|
||||
$('#field-absi_camp').val("");
|
||||
$('#field-h1_cardio_conference').val("");
|
||||
toggleAbsiPatientsField();
|
||||
$('#report-form input[name="glipiq_new_conversion"]').val(0);
|
||||
$('#report-form input[name="glipiq_existing_conversion"]').val(0);
|
||||
$('#report-form input[name="glipiq_rx_total"]').val(0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue