window.AREA_PAZIENTI=window.AREA_PAZIENTI||{};
if(!document.body.classList.contains("area-pazienti-loaded") &&
document.body.classList.contains("area-pazienti-dashboard")
){
document.body.classList.add("area-pazienti-loaded");
var userData=sessionStorage.getItem("userData");
if(userData==null){
window.location.href="/area-pazienti/?login";
}else{
const searchInputBox=document.querySelector(".search-input-box");
const searchInputBoxMobile=document.querySelector(".search-input-box-mobile"
);
searchInputBox
.querySelector("form")
.addEventListener("submit", function (event){
var value=event.target.elements.s.value;
getSearch(value);
event.preventDefault();
});
searchInputBoxMobile
.querySelector("form")
.addEventListener("submit", function (event){
var value=event.target.elements.s.value;
getSearch(value);
event.preventDefault();
});
var debug=document.querySelectorAll(".debug .icon-Close");
for (let i=0; i < debug.length; i++){
debug[i].addEventListener("click", function (){
this.parentNode.remove();
});
}
var logouts=document.querySelectorAll(".logout");
for (let i=0; i < logouts.length; i++){
logouts[i].addEventListener("click", function (e){
logout();
e.preventDefault();
});
}
var sidebarLinks=document.querySelectorAll("#main .sidebar a, .prenota-link"
);
var tabs=document.querySelectorAll("#main .content > div");
document
.querySelector(".messages-link")
.addEventListener("click", function (e){
if(this.classList.contains("active")){
this.classList.remove("active");
document.querySelector('.sidebar a[href="#home"]').click();
}else{
this.classList.add("active");
for (let x=0; x < sidebarLinks.length; x++){
sidebarLinks[x].classList.remove("active");
}
for (let x=0; x < tabs.length; x++){
tabs[x].classList.remove("active");
}
document.getElementById("notifiche").classList.add("active");
}
window.scrollTo(0, 0);
e.preventDefault();
});
document.querySelector(".gohome").addEventListener("click", function (e){
document.querySelector('.sidebar a[href="#home"]').click();
e.preventDefault();
});
document
.querySelector(".search-link")
.addEventListener("click", function (e){
if(document.body.classList.contains("search-opened")){
document.body.classList.remove("search-opened");
}else{
document.body.classList.add("search-opened");
document
.querySelector("#header .account-link")
.classList.remove("active");
}
e.preventDefault();
});
document.addEventListener("click", function (event){
var isClickInside=event.target.closest(".search-input-box, .search-link"
);
if(!isClickInside&&document.body.classList.contains("search-opened")){
document.body.classList.remove("search-opened");
}
var isClickInside=event.target.closest("#header .account-link.active, #header .account-link.active .submenu"
);
if(!isClickInside){
document
.querySelector("#header .account-link")
.classList.remove("active");
}});
for (let i=0; i < sidebarLinks.length; i++){
sidebarLinks[i].addEventListener("click", function (e){
if(!this.classList.contains("disabled")){
document.querySelector(".messages-link").classList.remove("active");
var tab=this.getAttribute("href").split("#")[1];
for (let x=0; x < sidebarLinks.length; x++){
sidebarLinks[x].classList.remove("active");
}
this.classList.add("active");
for (let x=0; x < tabs.length; x++){
tabs[x].classList.remove("active");
if(tabs[x].getAttribute("id")==tab){
tabs[x].classList.add("active");
}}
resetAnagrafica();
document.body.classList.remove("menu-opened");
var allTabs=document.querySelectorAll(".nav.nav-tabs");
for (let e=0; e < allTabs.length; e++){
allTabs[e].querySelector(".nav-link").click();
}
window.scrollTo(0, 0);
}
e.preventDefault();
});
}
document.querySelector(".menu").addEventListener("click", function (e){
if(document.body.classList.contains("menu-opened")){
document.body.classList.remove("menu-opened");
}else{
document.body.classList.add("menu-opened");
}
e.preventDefault();
});
document
.querySelector(".menu-close")
.addEventListener("click", function (e){
document.body.classList.remove("menu-opened");
e.preventDefault();
});
userData=JSON.parse(userData);
var master=sessionStorage.getItem("PublicWebMasterTables");
master=JSON.parse(master);
var isProspect=false;
if(userData.PatientWebCard==null){
isProspect=true;
var decodedToken=getDecodedToken(
sessionStorage.getItem("access_token")
);
var birthdate=decodedToken.birthdate.split("-");
userData.PatientWebCard={
ParentId: decodedToken.profile,
Paziente: {
ParentId: decodedToken.profile,
PazienteId: decodedToken.profile,
PazienteCodice: decodedToken.profile,
PazienteCognome: decodedToken.family_name,
PazienteNome: decodedToken.given_name,
PazienteIndirizzo: "",
PazienteCap: "",
PazienteLocalita: "",
PazienteProvincia: "",
PazienteCodiceFiscale: "",
PazienteEmail: decodedToken.email,
PazienteTelefono: decodedToken.telephone,
PazienteTelefono2: null,
PazienteTelefono3: null,
PazienteSesso: "",
PazienteDataNascita:
birthdate[2] +
"-" +
birthdate[1] +
"-" +
birthdate[0] +
"T00:00:00",
PazienteNote: null,
PazienteLocalitaNascita: "",
PazienteProvinciaNascita: "",
PazienteProfessione: null,
PazienteNazione: "",
NazioneDescrizione: "",
PazientiPrivacy_1_Informativa: false,
PazientiPrivacy_2_DirittiModifica: false,
PazientiPrivacy_4_Profilazione:
typeof decodedToken.profiling_consent==="undefined"
? false
: decodedToken.profiling_consent.toLowerCase()!="false",
PazientiPrivacy_3_Marketing:
typeof decodedToken.market_consent==="undefined"
? false
: decodedToken.market_consent.toLowerCase()!="false",
},
Correlati: [],
Appuntamenti: [],
Medici: [],
Preventivi: [],
Fatture: [],
Questionari: [],
EsamiObiettivi: [],
Consensi: [],
};
document
.querySelector('.sidebar a[href="#anagrafica"]')
.classList.add("disabled");
document
.querySelector('.sidebar a[href="#appuntamenti"]')
.classList.add("disabled");
document
.querySelector('.sidebar a[href="#piani"]')
.classList.add("disabled");
document
.querySelector('.sidebar a[href="#documenti"]')
.classList.add("disabled");
document
.querySelector('.sidebar a[href="#dentista"]')
.classList.add("disabled");
document.querySelector(".next-app").classList.add("hide");
document.querySelector(".search-link").classList.add("hide");
document
.querySelector(".prospect-notice-container")
.classList.remove("hide");
}
var currentUser=userData.PatientWebCard.Paziente.PazienteId;
var currentParentId=currentUser;
var currentRelUser=null;
var currentClinic=null;
document
.querySelector(".delete-account-link")
.setAttribute("data-id", userData.PatientWebCard.Paziente.PazienteEmail);
var prenotaLinks=document.querySelectorAll(".prenota-link");
for (let i=0; i < prenotaLinks.length; i++){
prenotaLinks[i].addEventListener("click", function (e){
if(userData.PatientWebCard.Correlati.length){
document
.querySelector(".booking-section.section-0 .changesection")
.click();
document.querySelector("#booking_customer_account_main").click();
}else{
document
.querySelector(".booking-section.section-1 .changesection")
.click();
}
document.querySelector(".booking-section.section-2.tab-yes .address"
).value="";
document
.querySelector(".booking-section.section-2.tab-yes .locator-results-mine"
)
.classList.remove("hide");
document.querySelector(".booking-section.section-2.tab-yes .locator-results"
).innerHTML="";
var checkboxOrari=document.querySelectorAll('.booking-section.section-3 input[type="checkbox"]'
);
for (let x=0; x < checkboxOrari.length; x++){
checkboxOrari[x].checked=false;
}
document.querySelector(".booking-section.section-3 .row.times"
).style.display="none";
document
.querySelector(".booking-section.section-3 .bordered")
.classList.remove("line-bordered");
e.preventDefault();
});
}
var accounts=document.querySelectorAll(".account-link");
for (let i=0; i < accounts.length; i++){
var accountName=document.querySelectorAll(".account-name.current-name");
for (let e=0; e < accountName.length; e++){
accountName[e].innerHTML =
userData.PatientWebCard.Paziente.PazienteNome;
}
var accountSurname=document.querySelectorAll(".account-surname.current-name"
);
for (let e=0; e < accountSurname.length; e++){
accountSurname[e].innerHTML =
userData.PatientWebCard.Paziente.PazienteCognome;
}
if(userData.PatientWebCard.Correlati.length){
var htmlAccounts =
'<a href="#" data-account="' +
userData.PatientWebCard.Paziente.PazienteId +
'" data-master="1" class="hide"><span class="account-name">' +
userData.PatientWebCard.Paziente.PazienteNome +
'</span> <span class="account-name account-surname">' +
userData.PatientWebCard.Paziente.PazienteCognome +
"</span></a>";
for (let e=0; e < userData.PatientWebCard.Correlati.length; e++){
if(typeof userData.PatientWebCard.Correlati[e].PazienteCorrelatoId!=null
){
userData.PatientWebCard.Correlati[e].PazienteId =
userData.PatientWebCard.Correlati[e].PazienteCorrelatoId;
}
htmlAccounts +=
'<a href="#" data-account="' +
userData.PatientWebCard.Correlati[e].PazienteId +
'"><span class="account-name"><span class="icon icona-Profili-correlati"></span> ' +
userData.PatientWebCard.Correlati[e].PazienteNome +
'</span> <span class="account-name account-surname">' +
userData.PatientWebCard.Correlati[e].PazienteCognome +
"</span></a>";
}
accounts[i]
.querySelector(".submenu .accounts p")
.insertAdjacentHTML("afterend", htmlAccounts);
var accountNumsText =
userData.PatientWebCard.Correlati.length==1
? "Hai 1 profilo associato"
: "Hai " +
userData.PatientWebCard.Correlati.length +
" profili associati";
var accountNums=document.querySelectorAll(".account-nums");
for (let e=0; e < accountNums.length; e++){
accountNums[e].innerHTML=accountNumsText;
}}else{
accounts[i].querySelector(".submenu .accounts").classList.add("hide");
document
.querySelector("#home .intro .account-link")
.classList.add("hide");
}
accounts[i].addEventListener("click", function (e){
if(this.classList.contains("active")){
this.classList.remove("active");
}else{
this.classList.add("active");
document.body.classList.remove("search-opened");
}
e.preventDefault();
});
}
var accountsRelated=document.querySelectorAll(".accounts-related");
for (let e=0; e < accountsRelated.length; e++){
for (let x=0; x < userData.PatientWebCard.Correlati.length; x++){
accountsRelated[e].innerHTML +=
'<span class="account-related" data-account="' +
userData.PatientWebCard.Correlati[x].PazienteId +
'"><span class="icona-Erase"></span> ' +
userData.PatientWebCard.Correlati[x].PazienteNome +
"</span>";
}}
window.addEventListener("click", function (e){
setTimeout(function (){
var accountsRelated=document.querySelectorAll(".accounts-related");
for (let x=0; x < accountsRelated.length; x++){
if(accountsRelated[x].contains(e.target) &&
!e.target.classList.contains("account-related") &&
!e.target.classList.contains("icona-Erase") &&
!accountsRelated[x].classList.contains("showrel")
){
accountsRelated[x].classList.add("showrel");
accountsRelated[x].parentNode
.querySelector(".choose-dropdown")
.classList.add("active");
}else{
accountsRelated[x].classList.remove("showrel");
accountsRelated[x].parentNode
.querySelector(".choose-dropdown")
.classList.remove("active");
}}
}, 100);
});
var accountRelated=document.querySelectorAll(".account-related");
for (let e=0; e < accountRelated.length; e++){
accountRelated[e].addEventListener("click", function (){
if(this.classList.contains("disabled")){
this.classList.remove("disabled");
disabled=false;
}else{
this.classList.add("disabled");
disabled=true;
}
var tab=this.parentNode.classList.contains("history")
? "app-2"
: "app-1";
var appRelated=tab=="app-1" ? "app-related":"app-related-history";
var appointments=document.querySelectorAll("#appuntamenti #" + tab + " .appuntamenti-container .row"
);
for (let i=0; i < appointments.length; i++){
if(document.getElementById(appRelated).checked){
appointments[i].classList.remove("hide");
}
appointments[i].classList.add("hide");
}
for (let i=0; i < appointments.length; i++){
if(appointments[i].classList.contains("is-checkin-info")){
continue;
}
var appPersonsEnabled=document.querySelectorAll("#" + tab + " .accounts-related .account-related:not(.disabled)"
);
for (let x=0; x < appPersonsEnabled.length; x++){
if(appPersonsEnabled[x].getAttribute("data-account")==appointments[i]
.querySelector(".person")
.getAttribute("data-account")
){
appointments[i].classList.remove("hide");
}}
if(!currentRelUser &&
appointments[i]
.querySelector(".person")
.getAttribute("data-account")==userData.PatientWebCard.Paziente.ParentId
){
appointments[i].classList.remove("hide");
}}
var countActived=0;
var countDisabled=0;
var appAccountsPlaceholder=document.querySelector("#" + tab + " .accounts-related"
);
var appAccountList=document.querySelectorAll("#" + tab + " .account-related"
);
var appAccountRemoveAll=document.querySelector("#" + tab + " .remove-all"
);
var appAccountChooseDropdown=document.querySelector("#" + tab + " .choose-dropdown"
);
for (let i=0; i < appAccountList.length; i++){
if(!appAccountList[i].classList.contains("disabled")){
countActived++;
}else{
countDisabled++;
}}
if(countActived==0){
appAccountsPlaceholder.classList.add("show-placeholder");
appAccountRemoveAll.classList.add("hide");
appAccountChooseDropdown.classList.remove("hide");
document.getElementById("app-related").checked=false;
}else{
appAccountsPlaceholder.classList.remove("show-placeholder");
appAccountRemoveAll.classList.remove("hide");
appAccountChooseDropdown.classList.add("hide");
document.getElementById("app-related").checked=true;
}
if(countActived==0){
document
.querySelector("#" + tab + " .accounts-related")
.classList.remove("nodisabled");
}else{
document
.querySelector("#" + tab + " .accounts-related")
.classList.add("nodisabled");
}});
}
var chooseDropdowns=document.querySelectorAll(".choose-dropdown");
for (let e=0; e < chooseDropdowns.length; e++){
chooseDropdowns[e].addEventListener("click", function (){
var drop=this;
if(!drop.parentNode
.querySelector(".accounts-related")
.classList.contains("showrel")
){
setTimeout(function (){
drop.classList.add("active");
drop.parentNode
.querySelector(".accounts-related")
.classList.add("showrel");
}, 200);
}
});
}
var removeAll=document.querySelectorAll(".remove-all .icona-Erase");
for (let e=0; e < removeAll.length; e++){
removeAll[e].addEventListener("click", function (){
if(this.parentNode.parentNode.querySelector(".account-related:not(.disabled) .icona-Erase"
)
){
this.parentNode.parentNode
.querySelector(".account-related:not(.disabled) .icona-Erase")
.click();
}});
}
var stepBoxLinks=document.querySelectorAll(".step-box a");
for (let e=0; e < stepBoxLinks.length; e++){
stepBoxLinks[e].addEventListener("click", function (){
var step=this.getAttribute("data-step");
document.querySelector('.sidebar a[href="#anagrafica"]').click();
document.getElementById(step).click();
window.scrollTo(0, 0);
});
}
var documentiLinks=document.querySelectorAll(".documenti a");
for (let e=0; e < documentiLinks.length; e++){
documentiLinks[e].addEventListener("click", function (x){
document.getElementById("ci").click();
x.preventDefault();
});
}
/*
var clinicLinks=document.querySelectorAll('.clinic-location a');
for (let i=0; i < clinicLinks.length; i++){
clinicLinks[i].addEventListener('click', function(e){
document.querySelector('.sidebar a[href="#dentista"]').click();
e.preventDefault();
});
}
*/
updateClinics();
document
.querySelector("#location-search-button")
.addEventListener("click", function (e){
if(!this.classList.contains("cta-loading")){
this.classList.add("cta-loading");
var inputPos =
this.previousElementSibling.querySelector('input[type="text"]');
if(inputPos==null){
inputPos=this.parentNode.querySelector('input[type="text"]');
if(inputPos==null){
inputPos =
this.parentNode.parentNode.querySelector('input[type="text"]');
}}
inputPos.disabled=true;
getClinics(inputPos);
}
e.preventDefault();
});
document
.querySelector("#findCenter .choose-clinic-btn")
.addEventListener("click", function (e){
updateClinics(getUserCliniche());
e.preventDefault();
});
var resetBtns=document.querySelectorAll(".reset-btn");
for (let i=0; i < resetBtns.length; i++){
resetBtns[i].addEventListener("click", function (e){
var parent=this.parentNode;
var inputField=parent.querySelector('input[type="text"]');
if(inputField){
inputField.value="";
}
var submitField=parent.querySelector('button[type="submit"]');
if(submitField){
submitField.click();
}else{
document
.querySelector(".section-2.tab-yes .locator-results-mine")
.classList.remove("hide");
document.querySelector(".section-2.tab-yes .locator-results"
).innerHTML="";
}
e.preventDefault();
});
}
updateDoctors();
updateDocuments();
updateDocumentsOrder();
updatePlans();
updateDati();
document
.querySelector('#signConsentModal button[data-dismiss="signconsent-data-modal"]'
)
.addEventListener("click", function (e){
checkUpConsensoId=this.getAttribute("data-id");
if(checkUpConsensoId&&checkUpConsensoId!=""){
signConsent(checkUpConsensoId);
}
e.preventDefault();
});
document
.querySelector('#signSurveyModal button[data-dismiss="signsurvey-data-modal"]'
)
.addEventListener("click", function (e){
dataid=this.getAttribute("data-id");
clinicaid=this.getAttribute("data-clinicaid");
ownerid=this.getAttribute("data-ownerid");
if(dataid&&dataid!=""){
signSurvey(dataid, clinicaid, ownerid);
}
e.preventDefault();
});
document
.querySelector('#confirmAppModal button[data-dismiss="confirm-data-modal"]'
)
.addEventListener("click", function (e){
dataid=this.getAttribute("data-id");
clinicaid=this.getAttribute("data-clinicaid");
if(dataid&&clinicaid&&dataid!=""&&clinicaid!=""){
confirmAppointment(dataid, clinicaid);
}
e.preventDefault();
});
document
.querySelector('#rejectAppModal button[data-dismiss="reject-data-modal"]')
.addEventListener("click", function (e){
dataid=this.getAttribute("data-id");
clinicaid=this.getAttribute("data-clinicaid");
if(dataid&&clinicaid&&dataid!=""&&clinicaid!=""){
var message=document.getElementById("reject-message").value;
rejectAppointment(dataid, clinicaid, message);
}
e.preventDefault();
});
document
.querySelector('#deleteAccountModal button[data-dismiss="delete-account-modal"]'
)
.addEventListener("click", function (e){
dataid=this.getAttribute("data-id");
if(dataid&&dataid!=""){
deleteAccount(dataid);
}
e.preventDefault();
});
document
.querySelector("#input-delete-account")
.addEventListener("change", function (){
if(this.checked){
document
.querySelector("#deleteAccountModal .btn-primary")
.classList.remove("disabled");
}else{
document
.querySelector("#deleteAccountModal .btn-primary")
.classList.add("disabled");
}});
if(sessionStorage.getItem("justLoggedIn")){
sessionStorage.removeItem("justLoggedIn");
}else if(!isProspect){
updateCache();
updateClinics();
updateDoctors();
updateDocuments();
updatePlans();
updateDati();
updateAppointments();
updateDots();
compileAnamnesi();
checkDataAnamnesi();
updateProgress();
updateMessages();
var confirmDelete=function (){
if(!this.checked){
if(!confirm(
"Eliminando il consenso verrà richiesta la cancellazione dei tuoi dati personali. Potrai continuare ad accedere alla tua Area Pazienti ma non saranno più visibili i tuoi dati."
)
){
this.checked=true;
}}
};
document
.getElementById("input-privacy-1")
.addEventListener("click", confirmDelete);
document
.getElementById("input-privacy-2")
.addEventListener("click", confirmDelete);
}
updateAppointments();
updateDots();
compileAnamnesi();
updateProgress();
var switchAccountLinks=document.querySelectorAll(".accounts a[data-account]"
);
if(!switchAccountLinks.length){
var appFilters=document.querySelectorAll(".app-filter");
for (let i=0; i < appFilters.length; i++){
appFilters[i].classList.add("hide");
}}
for (let i=0; i < switchAccountLinks.length; i++){
switchAccountLinks[i].addEventListener("click", function (e){
switchAccount(this.getAttribute("data-account"));
updateBar(this);
document.querySelector('.sidebar a[href="#home"]').click();
e.preventDefault();
});
}
var stars=document.querySelectorAll(".stars span[data-value]");
for (let i=0; i < stars.length; i++){
stars[i].addEventListener("click", function (){
var value=this.getAttribute("data-value");
for (let e=0; e < stars.length; e++){
if(stars[e].getAttribute("data-value") > value){
stars[e].classList.remove("active");
}else{
stars[e].classList.add("active");
}}
document.querySelector('input[name="stars"]').value=value;
});
stars[i].addEventListener("mouseover", function (){
var value=this.getAttribute("data-value");
for (let e=0; e < stars.length; e++){
if(stars[e].getAttribute("data-value") > value){
stars[e].classList.remove("hover");
}else{
stars[e].classList.add("hover");
}}
});
stars[i].addEventListener("mouseout", function (){
for (let e=0; e < stars.length; e++){
stars[e].classList.remove("hover");
}});
}
document
.querySelector("#review-submit")
.addEventListener("click", function (e){
alert("Da implementare..");
});
document
.querySelector("#preventivo .back-plans")
.addEventListener("click", function (e){
document.querySelector('.sidebar a[href="#piani"]').click();
e.preventDefault();
});
document.querySelector(".show-app").addEventListener("click", function (e){
document
.querySelector('.sidebar a[href="#appuntamenti"]:not(.disabled)')
.click();
e.preventDefault();
});
var numstep=document.getElementById("numstep");
document
.getElementById("dati-generalita")
.addEventListener("click", function (){
numstep.innerHTML=1;
resetAnagrafica();
});
document
.getElementById("dati-contatti")
.addEventListener("click", function (){
numstep.innerHTML=2;
resetAnagrafica();
});
document
.getElementById("dati-privacy")
.addEventListener("click", function (){
numstep.innerHTML=3;
resetAnagrafica();
});
document
.getElementById("dati-anamnesi")
.addEventListener("click", function (){
numstep.innerHTML=4;
resetAnagrafica();
});
document
.getElementById("app-related")
.addEventListener("change", function (){
var accountRelated=document.querySelectorAll("#app-1 .account-related"
);
var disabled=true;
for (let e=0; e < accountRelated.length; e++){
if(accountRelated[e].classList.contains("disabled")){
disabled=true;
}else{
disabled=false;
}}
for (let e=0; e < accountRelated.length; e++){
if(this.checked){
accountRelated[e].classList.remove("disabled");
disabled=false;
}else{
accountRelated[e].classList.add("disabled");
disabled=true;
}}
var appointments=document.querySelectorAll("#appuntamenti #app-1 .appuntamenti-container .row"
);
for (let i=0; i < appointments.length; i++){
if(appointments[i].classList.contains("is-checkin-info")){
continue;
}
var dataAccount=appointments[i]
.querySelector(".person")
.getAttribute("data-account");
if(this.checked){
appointments[i].classList.remove("hide");
if(disabled&&dataAccount!=currentUser){
appointments[i].classList.add("hide");
}}else{
if(dataAccount==currentUser){
appointments[i].classList.remove("hide");
}else{
appointments[i].classList.add("hide");
}}
}
if(this.checked){
document
.querySelector("#app-1 .accounts-related")
.classList.remove("show-placeholder");
}else{
document
.querySelector("#app-1 .accounts-related")
.classList.add("show-placeholder");
}});
document
.getElementById("app-related-history")
.addEventListener("change", function (){
var disabled=false;
var accountRelated=document.querySelectorAll("#app-2 .account-related"
);
for (let e=0; e < accountRelated.length; e++){
if(accountRelated[e].classList.contains("disabled")){
disabled=true;
}else{
disabled=false;
}}
for (let e=0; e < accountRelated.length; e++){
if(this.checked){
accountRelated[e].classList.remove("disabled");
disabled=false;
}else{
accountRelated[e].classList.add("disabled");
disabled=true;
}}
var appointments=document.querySelectorAll("#appuntamenti #app-2 .appuntamenti-container .row"
);
for (let i=0; i < appointments.length; i++){
var dataAccount=appointments[i]
.querySelector(".person")
.getAttribute("data-account");
if(this.checked){
appointments[i].classList.remove("hide");
if(disabled&&dataAccount!=currentUser){
appointments[i].classList.add("hide");
}}else{
if(dataAccount==currentUser){
appointments[i].classList.remove("hide");
}else{
appointments[i].classList.add("hide");
}}
}
if(this.checked){
document
.querySelector("#app-2 .accounts-related")
.classList.remove("show-placeholder");
}else{
document
.querySelector("#app-2 .accounts-related")
.classList.add("show-placeholder");
}});
document
.querySelector(".save-data")
.addEventListener("click", function (e){
if(!savePazienteDataValidate()){
return;
}
jQuery("#dataModal").modal("show");
document
.querySelector('button[data-dismiss="save-data-modal"]')
.addEventListener("click", function (e){
savePazienteData(e, true);
jQuery("#dataModal").modal("hide");
});
e.preventDefault();
});
document
.querySelector(".save-contacts")
.addEventListener("click", function (e){
jQuery("#contactsModal").modal("show");
document
.querySelector('button[data-dismiss="save-contacts-modal"]')
.addEventListener("click", function (e){
savePazienteContacts(e, true);
jQuery("#contactsModal").modal("hide");
});
e.preventDefault();
});
document
.querySelector(".save-privacy")
.addEventListener("click", function (e){
jQuery("#privacyModal").modal("show");
document
.querySelector('button[data-dismiss="save"]')
.addEventListener("click", function (e){
savePazientePrivacy(e, true);
jQuery("#privacyModal").modal("hide");
});
e.preventDefault();
});
document
.querySelector("#dati-3 .cta")
.addEventListener("click", function (e){
var steps=document.querySelectorAll("#dati-3 .steps .col-12");
var currentStep=this.getAttribute("data-current");
if(currentStep==1){
document.querySelector("#dati-3 .back-plans").classList.add("hide");
}
if(currentStep==master.Anamnesi.SurveyQuestions.length - 1){
document.querySelector("#dati-3 .cta").innerHTML="Salva";
}
if(currentStep < master.Anamnesi.SurveyQuestions.length){
var answers=document.querySelectorAll("#dati-3 .step-" +
currentStep +
' input[type="checkbox"], #dati-3 .step-' +
currentStep +
' input[type="radio"]'
);
var checked=Array.from(answers).some(function (answer){
return answer.checked;
});
var notes=document.querySelector("#input-anamnesi-" + currentStep
).value;
var notes_id=document
.querySelector("#input-anamnesi-" + currentStep)
.getAttribute("data-id");
if(checked ||
(notes&&notes_id) ||
document
.querySelector("#dati-3 .steps .step-" + currentStep)
.getAttribute("data-required")=="false"
){
currentStep++;
for (let x=0; x < steps.length; x++){
if(!steps[x].classList.contains("hide")){
steps[x].classList.add("hide");
}
if(steps[x].classList.contains("step-" + currentStep)){
steps[x].classList.remove("hide");
}}
document.getElementById("currentstep-p").value=currentStep;
document.getElementById("currentstep-d").innerHTML=currentStep;
this.setAttribute("data-current", currentStep);
document
.querySelector("#dati-3 .back-plans")
.classList.remove("hide");
}else{
alert("Seleziona una risposta per continuare");
}}else{
jQuery("#anamnesiModal").modal("show");
document
.querySelector('#anamnesiModal button[data-dismiss="save-anamnesi"]'
)
.addEventListener("click", function (e){
submitAnamnesi();
jQuery("#anamnesiModal").modal("hide");
e.preventDefault();
});
}
e.preventDefault();
});
document
.querySelector("#dati-3 .back-plans")
.addEventListener("click", function (e){
var steps=document.querySelectorAll("#dati-3 .steps .col-12");
var currentStep=document
.querySelector("#dati-3 .cta")
.getAttribute("data-current");
currentStep--;
if(currentStep==1){
this.classList.add("hide");
}
for (let x=0; x < steps.length; x++){
if(!steps[x].classList.contains("hide")){
steps[x].classList.add("hide");
}
if(steps[x].classList.contains("step-" + currentStep)){
steps[x].classList.remove("hide");
}}
document.getElementById("currentstep-p").value=currentStep;
document.getElementById("currentstep-d").innerHTML=currentStep;
document
.querySelector("#dati-3 .cta")
.setAttribute("data-current", currentStep);
document.querySelector("#dati-3 .cta").innerHTML="Conferma";
e.preventDefault();
});
var ctaCancel=document.querySelectorAll(".cta-cancel");
for (let i=0; i < ctaCancel.length; i++){
ctaCancel[i].addEventListener("click", function (e){
resetAnagrafica();
e.preventDefault();
});
}
var news=jQuery(".ar-news");
if(news.length){
news.owlCarousel({
autoplay: false,
loop: true,
margin: 20,
dots: true,
nav: true,
slideTransition: "linear",
responsive: {
0: {
items: 1,
stagePadding: 70,
},
768: {
items: 2,
stagePadding: 0,
},
992: {
items: 3,
},
},
navText: [
`<span class="icon-arrow_left"></span>`,
`<span class="icon-arrow_right"></span>`,
],
});
}
var dismissModal=document.querySelectorAll('button[data-dismiss="modal"]'
);
for (let i=0; i < dismissModal.length; i++){
dismissModal[i].addEventListener("click", function (){
jQuery("#anamnesiModal").modal("hide");
jQuery("#dataModal").modal("hide");
jQuery("#contactsModal").modal("hide");
jQuery("#privacyModal").modal("hide");
jQuery("#signModal").modal("hide");
jQuery("#signConsentModal").modal("hide");
jQuery("#signSurveyModal").modal("hide");
jQuery("#calendarModal").modal("hide");
jQuery("#confirmAppModal").modal("hide");
jQuery("#rejectAppModal").modal("hide");
jQuery("#deleteAccountModal").modal("hide");
jQuery("#thankyouModal").modal("hide");
document.querySelector("#input-delete-account").checked=false;
document
.querySelector("#deleteAccountModal .btn-primary")
.classList.add("disabled");
});
}
var googleInterval;
googleInterval=setInterval(function (){
if(typeof google!=="undefined"){
clearInterval(googleInterval);
var cliniche=getLastClinic();
if(typeof cliniche!=="undefined"){
var lat=convertCoordinate(cliniche.ClinicaLatitudine);
var lng=convertCoordinate(cliniche.ClinicaLongitudine);
dashboardInitMap(lat, lng);
}}
}, 200);
selectSearch();
document.body.classList.remove("overlay-loading-show");
/*function getDecodedTokenOld(token){
token=token.split('.');
token=token[1];
token=token.split('-').join('+');
token=token.split('_').join('/');
token=atob(token);
token=JSON.parse(token);
return token;
}*/
function getDecodedToken(token){
var base64Url=token.split(".")[1];
var base64=base64Url.replace(/-/g, "+").replace(/_/g, "/");
var jsonPayload=decodeURIComponent(
window
.atob(base64)
.split("")
.map(function (c){
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
})
.join("")
);
return JSON.parse(jsonPayload);
}
function logout(){
document.body.classList.add("overlay-loading-show");
id_token=sessionStorage.getItem("id_token");
sessionStorage.removeItem("userData");
sessionStorage.removeItem("access_token");
sessionStorage.removeItem("id_token");
window.location.href =
"https://ssopazienti.dentalpro.it/connect/endsession?id_token_hint=" +
id_token +
"&post_logout_redirect_uri=" +
encodeURIComponent(location.origin);
}
function getLastClinic(){
var lastClinicaId=0;
if(currentRelUser!=null){
lastClinicaId=currentRelUser.LastClinicaId;
}else{
lastClinicaId=userData.PatientWebCard.Paziente.LastClinicaId;
}
if(lastClinicaId){
return getClinica(lastClinicaId);
}else{
var cliniche=getUserCliniche();
return cliniche[0];
}}
function updateClinics(clinics_obj=false, valueInput=false){
var cliniche=clinics_obj ? clinics_obj:getUserCliniche();
var clinics=document.querySelectorAll(".intro .clinic, .clinic-row");
if(cliniche.length){
for (let i=0; i < clinics.length; i++){
clinics[i].classList.remove("hide");
}
if(!clinics_obj){
currentClinic=getLastClinic();
var offcanvas=document.getElementById("findCenter");
offcanvas.querySelector("#findCenterLabel").innerHTML =
currentClinic.ClinicaAlias
? currentClinic.ClinicaAlias
: currentClinic.ClinicaDescrizione;
offcanvas.querySelector(".address").innerHTML =
currentClinic.ClinicaIndirizzo +
", " +
currentClinic.ClinicaCap +
" " +
currentClinic.ClinicaLocalita +
" (" +
currentClinic.ClinicaProvincia +
")";
offcanvas.querySelector(".doctor").innerHTML =
currentClinic.ClinicaDirettoreSanitario;
offcanvas
.querySelector(".cta-phone")
.setAttribute("href", "tel:" + currentClinic.ClinicaTelefono);
offcanvas.querySelector(".phonenumber").innerHTML =
currentClinic.ClinicaTelefono;
offcanvas
.querySelector(".cta-email")
.setAttribute("href", "mailto:" + currentClinic.ClinicheEmail);
offcanvas.querySelector(".clinic-email").innerHTML =
currentClinic.ClinicheEmail;
offcanvas
.querySelector(".clinic-link")
.setAttribute("href", currentClinic.ClinicaWebSite);
var myClinic={
name: currentClinic.ClinicaAlias
? currentClinic.ClinicaAlias
: currentClinic.ClinicaDescrizione,
phone: currentClinic.ClinicaTelefono,
};
var clinicsLocation=document.querySelectorAll(".clinic-location .clinic-name"
);
var clinicsPhone=document.querySelectorAll(".clinic-phone .clinic-phone-num"
);
for (let i=0; i < clinicsLocation.length; i++){
clinicsLocation[i].innerHTML=myClinic.name;
}
for (let i=0; i < clinicsPhone.length; i++){
clinicsPhone[i].innerHTML=myClinic.phone;
clinicsPhone[i].parentNode.setAttribute("href",
"tel:" + myClinic.phone
);
}
var teasers=document.querySelectorAll(".intro .teaser");
for (let i=0; i < teasers.length; i++){
if(teasers[i].querySelector(".clinic")!=null){
if(myClinic==null){
if(!teasers[i].classList.contains("single")){
teasers[i].classList.add("single");
teasers[i].querySelector(".clinic").classList.add("hide");
}}else{
if(teasers[i].classList.contains("single")){
teasers[i].classList.remove("single");
teasers[i].querySelector(".clinic").classList.remove("hide");
}}
}}
var clinicBox=document.querySelector(".current-clinic-box");
var clinicAddress =
currentClinic.ClinicaIndirizzo +
", " +
currentClinic.ClinicaCap +
" " +
currentClinic.ClinicaLocalita +
" (" +
currentClinic.ClinicaProvincia +
")";
clinicBox.querySelector("h4").innerHTML=currentClinic.ClinicaAlias
? currentClinic.ClinicaAlias
: currentClinic.ClinicaDescrizione;
clinicBox.querySelector(".address").innerHTML=clinicAddress;
clinicBox
.querySelector(".phonenumber")
.setAttribute("href", "tel:" + currentClinic.ClinicaTelefono);
clinicBox.querySelector(".phonenumber").innerHTML =
currentClinic.ClinicaTelefono;
clinicBox
.querySelector(".clemail")
.setAttribute("href", "mailto:" + currentClinic.ClinicheEmail);
clinicBox.querySelector(".clemail").innerHTML =
currentClinic.ClinicheEmail;
clinicBox.querySelector(".dirsan").innerHTML =
currentClinic.ClinicaDirettoreSanitario;
clinicBox
.querySelector(".maps-link")
.setAttribute("href",
"https://www.google.com/maps/place/" +
clinicAddress.split(" ").join("+")
);
clinicBox
.querySelector(".clinic-link")
.setAttribute("href", currentClinic.ClinicaWebSite);
}
var locatorTemplate=document
.querySelector(".locator-template")
.cloneNode(true);
locatorTemplate=locatorTemplate.innerHTML;
var locHtml="";
var locTemp="";
var listClinics="";
for (let i=0; i < cliniche.length; i++){
var clinica=cliniche[i];
var clinicName=clinica.ClinicaAlias
? clinica.ClinicaAlias
: clinica.ClinicaDescrizione;
locTemp=locatorTemplate;
locTemp=locTemp.split("[[ID]]").join(clinica.ClinicaId);
locTemp=locTemp.split("[[NAME]]").join(clinicName);
locTemp=locTemp
.split("[[ADDRESS]]")
.join(clinica.ClinicaIndirizzo +
", " +
clinica.ClinicaCap +
" " +
clinica.ClinicaLocalita +
" (" +
clinica.ClinicaProvincia +
")"
);
locTemp=locTemp.split("[[PHONE]]").join(clinica.ClinicaTelefono);
locTemp=locTemp
.split("[[DOCTOR]]")
.join(clinica.ClinicaDirettoreSanitario);
locTemp=locTemp
.split("[[PIVA]]")
.join("P.IVA " + clinica.ClinicaPartitaIva);
locHtml +=locTemp;
listClinics +=
'<li><a class="dropdown-item" href="#" data-value="' +
clinicName +
'">' +
clinicName +
"</a></li>";
}
document.querySelector(".locator-results-off").innerHTML=locHtml;
document.querySelector("#review-clinic + .dropdown-menu").innerHTML =
listClinics;
var changeClinics=document.querySelectorAll(".change-clinic");
for (let i=0; i < changeClinics.length; i++){
changeClinics[i].addEventListener("click", function (e){
var clinicaId=this.getAttribute("data-clinica");
changeClinic(clinicaId);
e.preventDefault();
});
}
var bootstrapDropdowns=document.querySelectorAll("#reviewsTabsContent .dropdown-menu li a"
);
for (let i=0; i < bootstrapDropdowns.length; i++){
bootstrapDropdowns[i].addEventListener("click", function (e){
var dropdown=findAncestor(this, ".dropdown");
dropdown.querySelector(".btn").innerHTML=this.innerHTML;
dropdown.querySelector(".btn").value =
this.getAttribute("data-value");
e.preventDefault();
});
}
document
.querySelector("#reviewsTabsContent .dropdown-menu li a")
.click();
if(typeof google!=="undefined"){
currentClinic = !clinics_obj ? getLastClinic():cliniche[0];
var lat=convertCoordinate(currentClinic.ClinicaLatitudine);
var lng=convertCoordinate(currentClinic.ClinicaLongitudine);
dashboardInitMap(lat, lng);
}}else{
document.querySelector(".locator-results-off").innerHTML="";
for (let i=0; i < clinics.length; i++){
clinics[i].classList.add("hide");
}}
if(!valueInput){
document.querySelector("#location-search-input").value="";
}
var myClinic=getUserCliniche();
var clinicHtml="";
for (let i=0; i < myClinic.length; i++){
var clinicName=myClinic[i].ClinicaAlias
? myClinic[i].ClinicaAlias
: myClinic[i].ClinicaDescrizione;
clinicHtml +='<div class="col-lg-6">';
clinicHtml +=
'    <div class="box-location" data-code="' +
myClinic[i].ClinicaId +
'">';
clinicHtml +=
'        <span class="box-location-title">' + clinicName + "</span>";
clinicHtml +=
'        <span class="box-location-address location-address">' +
myClinic[i].ClinicaIndirizzo +
", " +
myClinic[i].ClinicaLocalita +
" (" +
myClinic[i].ClinicaProvincia +
")</span>";
clinicHtml +=
'        <span class="box-location-address dp-text-xs-important"><span class="icon-Emoji me-1"></span>Dir. Sanitario centro Dentistico: Dott. ' +
myClinic[i].ClinicaDirettoreSanitario +
"</span>";
clinicHtml +="    </div>";
clinicHtml +="</div>";
}
document.querySelector(".section-2.tab-yes .locator-results-mine"
).innerHTML=clinicHtml;
var step2locations=document.querySelectorAll(".section-2.tab-yes .box-location"
);
for (let i=0; i < step2locations.length; i++){
step2locations[i].addEventListener("click", function (e){
document.querySelector(".section-2.tab-yes .details .col-7"
).innerHTML =
"<p>" +
this.querySelector(".box-location-title").innerHTML +
"<br>" +
this.querySelector(".location-address").innerHTML +
"</p>";
document
.querySelector(".section-2.tab-yes")
.classList.remove("active");
document.querySelector(".section-2.tab-yes").classList.add("done");
var isDirectBooking=(typeof window.selectedCardDirectBooking!=="undefined" ? window.selectedCardDirectBooking:(typeof selectedCardDirectBooking!=="undefined" ? selectedCardDirectBooking:null))==="1";
if(isDirectBooking&&document.querySelector(".section-3")!=null){
document.querySelector(".section-3").classList.add("active");
}else{
var section3=document.querySelector(".booking-section.section-3");
var section4=document.querySelector(".booking-section.section-4");
if(section3) section3.classList.remove("active");
if(section4) section4.classList.add("active");
if(typeof bookingData!=="undefined") bookingData.times=[];
}
e.preventDefault();
});
}
bookingBoxes();
}
function getClinics(input){
if(input.value==""){
input.disabled=false;
input.classList.remove("input-loading");
input.parentNode.parentNode
.querySelector(".cta")
.classList.remove("cta-loading");
updateClinics();
}else{
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
let myData=JSON.stringify({
"g-recaptcha-response": token,
address: input.value,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
var clinics=xhttp.responseText;
input.disabled=false;
input.classList.remove("input-loading");
input.parentNode.parentNode
.querySelector(".cta")
.classList.remove("cta-loading");
compileClinics(clinics, input);
} /*else {
input.disabled=false;
input.classList.remove('input-loading');
input.parentNode.parentNode.querySelector('.cta').classList.remove('cta-loading');
document.body.classList.remove('overlay-loading-show');
setTimeout(function(){ jQuery('#noInternetConnectionModal').modal('show'); }, 1000);
}*/
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_get_clinics");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myData);
});
});
}}
function compileClinics(locations, input){
const resultsContainerEl=input.parentNode.parentNode.querySelector(".locator-results-off"
);
if(resultsContainerEl!=null){
var clinics=[];
locations=JSON.parse(locations);
var masterCliniche=master.Cliniche;
for (let i=0; i < locations.length; i++){
for (let e=0; e < masterCliniche.length; e++){
if(locations[i].cod==masterCliniche[e].ClinicaCodice){
clinics.push(masterCliniche[e]);
}}
}
updateClinics(clinics, true);
}}
function changeClinic(id){
var clinica=getClinica(id);
if(clinica){
currentClinic=clinica;
var offcanvas=document.getElementById("findCenter");
offcanvas.querySelector("#findCenterLabel").innerHTML =
clinica.ClinicaAlias
? clinica.ClinicaAlias
: clinica.ClinicaDescrizione;
offcanvas.querySelector(".address").innerHTML =
clinica.ClinicaIndirizzo +
", " +
clinica.ClinicaCap +
" " +
clinica.ClinicaLocalita +
" (" +
clinica.ClinicaProvincia +
")";
offcanvas.querySelector(".doctor").innerHTML =
clinica.ClinicaDirettoreSanitario;
offcanvas
.querySelector(".cta-phone")
.setAttribute("href", "tel:" + clinica.ClinicaTelefono);
offcanvas.querySelector(".phonenumber").innerHTML =
clinica.ClinicaTelefono;
offcanvas
.querySelector(".cta-email")
.setAttribute("href", "mailto:" + clinica.ClinicheEmail);
offcanvas.querySelector(".clinic-email").innerHTML =
clinica.ClinicheEmail;
offcanvas
.querySelector(".clinic-link")
.setAttribute("href", clinica.ClinicaWebSite);
var myClinic={
name: clinica.ClinicaAlias
? clinica.ClinicaAlias
: clinica.ClinicaDescrizione,
phone: clinica.ClinicaTelefono,
};
var clinicsLocation=document.querySelectorAll(".clinic-location .clinic-name"
);
var clinicsPhone=document.querySelectorAll(".clinic-phone .clinic-phone-num"
);
for (let i=0; i < clinicsLocation.length; i++){
clinicsLocation[i].innerHTML=myClinic.name;
}
for (let i=0; i < clinicsPhone.length; i++){
clinicsPhone[i].innerHTML=myClinic.phone;
clinicsPhone[i].parentNode.setAttribute("href",
"tel:" + myClinic.phone
);
}
var clinicBox=document.querySelector(".current-clinic-box");
var clinicAddress =
clinica.ClinicaIndirizzo +
", " +
clinica.ClinicaCap +
" " +
clinica.ClinicaLocalita +
" (" +
clinica.ClinicaProvincia +
")";
clinicBox.querySelector("h4").innerHTML=clinica.ClinicaAlias
? clinica.ClinicaAlias
: clinica.ClinicaDescrizione;
clinicBox.querySelector(".address").innerHTML=clinicAddress;
clinicBox
.querySelector(".phonenumber")
.setAttribute("href", "tel:" + clinica.ClinicaTelefono);
clinicBox.querySelector(".phonenumber").innerHTML =
clinica.ClinicaTelefono;
clinicBox
.querySelector(".clemail")
.setAttribute("href", "mailto:" + clinica.ClinicheEmail);
clinicBox.querySelector(".clemail").innerHTML=clinica.ClinicheEmail;
clinicBox.querySelector(".dirsan").innerHTML =
clinica.ClinicaDirettoreSanitario;
clinicBox
.querySelector(".maps-link")
.setAttribute("href",
"https://www.google.com/maps/place/" +
clinicAddress.split(" ").join("+")
);
clinicBox
.querySelector(".clinic-link")
.setAttribute("href", clinica.ClinicaWebSite);
var lat=convertCoordinate(clinica.ClinicaLatitudine);
var lng=convertCoordinate(clinica.ClinicaLongitudine);
dashboardInitMap(lat, lng);
updateDoctors();
}}
function updateDoctors(){
document.querySelector(".doctor-list").innerHTML="";
if(currentClinic){
var doctorTemplate=document
.querySelector(".doctor-template")
.cloneNode(true);
doctorTemplate=doctorTemplate.innerHTML;
var docHtml="";
var docTemp="";
var enableDoctors=[];
enableDoctors.push({
OperatoreDescrizione: currentClinic.ClinicaDirettoreSanitario,
TipoOperatoreDescrizione: "Direttore sanitario",
ProfiloClinicoDescrizione: "",
});
for (let x=0; x < userData.PatientWebCard.Medici.length; x++){
if(userData.PatientWebCard.Medici[x].hasOwnProperty("ClinicaId")){
if(userData.PatientWebCard.Medici[x].ClinicaId==currentClinic.ClinicaId
){
var tipoMedico =
userData.PatientWebCard.Medici[
x
].OperatoreDescrizione.toLowerCase();
if(tipoMedico.indexOf("seconda poltrona")===-1 &&
tipoMedico.indexOf("sistemazione contabile")===-1
){
enableDoctors.push(userData.PatientWebCard.Medici[x]);
}}
}}
for (let i=0; i < enableDoctors.length; i++){
var medico=enableDoctors[i];
docTemp=doctorTemplate;
docTemp=docTemp.split("[[LG]]").join(i==0 ? "12":"6");
docTemp=docTemp
.split("[[NODOCTOR]]")
.join(medico.TipoOperatoreDescrizione
? medico.TipoOperatoreDescrizione.toLowerCase()=="medico" ||
medico.TipoOperatoreDescrizione.toLowerCase()=="direttore sanitario"
? ""
: "nodoctor"
: "nodoctor"
);
docTemp=docTemp
.split("[[NAME]]")
.join(medico.OperatoreDescrizione ? medico.OperatoreDescrizione:""
);
docTemp=docTemp
.split("[[JOB]]")
.join(medico.TipoOperatoreDescrizione
? medico.TipoOperatoreDescrizione.toLowerCase()=="tutor"
? "Resp. assistenza pazienti"
: medico.TipoOperatoreDescrizione
: ""
);
docTemp=docTemp
.split("[[SPEC]]")
.join(medico.ProfiloClinicoDescrizione
? medico.ProfiloClinicoDescrizione
: ""
);
docTemp=docTemp
.split("[[ICON]]")
.join(i==0 ? "":"icona-Doctor");
docTemp=docTemp.split("[[SVG]]").join(i==0 ? "":"hide");
docHtml +=docTemp;
}
document.querySelector(".doctor-list").innerHTML=docHtml;
}}
function updateDocuments(){
var temp=null;
var lines=document.querySelectorAll("#documentsTabsContent table tr:not(:first-child)"
);
for (let i=0; i < lines.length; i++){
lines[i].remove();
}
var template=document.querySelector(".documents-clinici-template table tr"
);
var table=document.querySelector("#documents-1 table tr");
var dataClinici=userData.PatientWebCard.Preventivi.concat(userData.PatientWebCard.Questionari
);
dataClinici.sort((a, b)=> {
let dataA=a.DataPreventivo||a.DataQuestionario;
let dataB=b.DataPreventivo||b.DataQuestionario;
return new Date(dataA) - new Date(dataB);
});
for (let i=0; i < dataClinici.length; i++){
if(currentUser==dataClinici[i].PazienteId ||
currentUser==dataClinici[i].ParentId
){
var temp=template.cloneNode(true);
var originalDate=new Date(
dataClinici[i].DataPreventivo||dataClinici[i].DataQuestionario
);
var month=originalDate.getMonth() + 1;
month=month < 10 ? "0" + month:month;
var day=originalDate.getDate();
day=day < 10 ? "0" + day:day;
var date =
day +
"/" +
month +
"/" +
originalDate.getFullYear().toString().substr(-2);
var statoPreventivo =
dataClinici[i].StatoPreventivoId==20
? "Consegnato al paziente"
: dataClinici[i].StatoPreventivoDescrizione
? dataClinici[i].StatoPreventivoDescrizione
: "";
var color =
dataClinici[i].StatoPreventivoId==50 ||
dataClinici[i].StatoPreventivoId==51
? "color-red"
: dataClinici[i].StatoPreventivoId==30 ||
dataClinici[i].StatoPreventivoId==60
? "color-green"
: "";
statoPreventivo =
'<span class="' + color + '">' + statoPreventivo + "</span>";
temp.querySelector("td:nth-child(1) .desc").innerHTML=dataClinici[i]
.TipoQuestionarioDescrizione
? dataClinici[i].TipoQuestionarioDescrizione
: "Preventivo";
temp.querySelector("td:nth-child(1) .doc-num").innerHTML =
dataClinici[i].PreventivoNumero
? "N° " + dataClinici[i].PreventivoNumero
: "";
temp.querySelector("td:nth-child(2)").innerHTML=date;
temp.querySelector("td:nth-child(3) .others").innerHTML =
statoPreventivo;
temp.querySelector("td:nth-child(4) h5").innerHTML=dataClinici[i]
.TotalePreventivo
? "&euro;" +
(Math.floor(dataClinici[i].TotalePreventivo)!==dataClinici[i].TotalePreventivo
? dataClinici[i].TotalePreventivo.toFixed(2).replace(".", ",")
: dataClinici[i].TotalePreventivo)
: "";
temp.querySelector("td:nth-child(4) .others").innerHTML=dataClinici[
i
].TotalePreventivo
? "Importo totale"
: "";
temp.querySelector("td:nth-child(5)").innerHTML =
'<span class="person" data-account="' +
dataClinici[i].PazienteId +
'">' +
dataClinici[i].PazienteNome +
"</span>";
var href =
dataClinici[i].PublicUrlDocument!=null
? dataClinici[i].PublicUrlDocument
: "#";
temp
.querySelector("td:nth-child(6) .cta-call:not(.cta-care-plan)")
.setAttribute("href", href);
var carePlanBtn=temp.querySelector("td:nth-child(6) .cta-care-plan");
var preventivoBtn=temp.querySelector("td:nth-child(6) .cta-call:not(.cta-care-plan)");
if(carePlanBtn){
var carePlanHref =
dataClinici[i].PublicUrlCarePlanDocument!=null &&
dataClinici[i].PublicUrlCarePlanDocument!==""
? dataClinici[i].PublicUrlCarePlanDocument
: "#";
carePlanBtn.setAttribute("href", carePlanHref);
if(carePlanHref!=="#"&&dataClinici[i].PreventivoNumero){
carePlanBtn.classList.remove("hide");
if(preventivoBtn) preventivoBtn.appendChild(document.createTextNode(" Scarica preventivo"));
carePlanBtn.appendChild(document.createTextNode(" Scarica piano di cura"));
}else{
carePlanBtn.classList.add("hide");
}}
temp
.querySelector("td:nth-child(6) .cta")
.setAttribute("data-type",
dataClinici[i].TipoQuestionarioDescrizione
? dataClinici[i].TipoQuestionarioDescrizione.toLowerCase()
: "preventivo"
);
temp
.querySelector("td:nth-child(6) .cta")
.setAttribute("data-id",
dataClinici[i].QuestionarioId ? dataClinici[i].QuestionarioId:""
);
temp
.querySelector("td:nth-child(6) .cta")
.setAttribute("data-clinicaid",
dataClinici[i].ClinicaId ? dataClinici[i].ClinicaId:""
);
temp
.querySelector("td:nth-child(6) .cta")
.setAttribute("data-ownerid",
dataClinici[i].OwnerId ? dataClinici[i].OwnerId:""
);
temp
.querySelector("td:nth-child(6) .cta")
.setAttribute("data-tosign",
dataClinici[i].ToSignByPatient
? dataClinici[i].ToSignByPatient
: ""
);
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}}
var downloadBtn=document.querySelectorAll("#documents-1 .cta-call");
for (let i=0; i < downloadBtn.length; i++){
if(downloadBtn[i].getAttribute("href")=="#"){
downloadBtn[i].classList.add("disabled");
}}
var signSurvey=document.querySelectorAll("#documents-1 .cta");
for (let i=0; i < signSurvey.length; i++){
signSurvey[i].addEventListener("click", function (e){
if(!this.classList.contains("disabled")){
var dataid=this.getAttribute("data-id");
var clinicaid=this.getAttribute("data-clinicaid");
var ownerid=this.getAttribute("data-ownerid");
jQuery("#signSurveyModal").modal("show");
document
.querySelector('#signSurveyModal button[data-dismiss="signsurvey-data-modal"]'
)
.setAttribute("data-id", dataid);
document
.querySelector('#signSurveyModal button[data-dismiss="signsurvey-data-modal"]'
)
.setAttribute("data-clinicaid", clinicaid);
document
.querySelector('#signSurveyModal button[data-dismiss="signsurvey-data-modal"]'
)
.setAttribute("data-ownerid", ownerid);
}
e.preventDefault();
});
if(signSurvey[i].getAttribute("data-tosign")==""){
signSurvey[i].classList.add("disabled");
signSurvey[i].innerHTML="Firmato";
}}
var template=document.querySelector(".documents-consensi-template table tr"
);
var table=document.querySelector("#documents-2 table tr");
for (let i=userData.PatientWebCard.Consensi.length - 1; i >=0; i--){
if(currentUser==userData.PatientWebCard.Consensi[i].PazienteId ||
currentUser==userData.PatientWebCard.Consensi[i].ParentId
){
temp=template.cloneNode(true);
if(userData.PatientWebCard.Consensi[i].DataConsenso!=null){
var originalDate=new Date(
userData.PatientWebCard.Consensi[i].DataConsenso
);
var month=originalDate.getMonth() + 1;
month=month < 10 ? "0" + month:month;
var day=originalDate.getDate();
day=day < 10 ? "0" + day:day;
var date =
day +
"/" +
month +
"/" +
originalDate.getFullYear().toString().substr(-2);
}else{
var date="";
}
temp.querySelector("td:nth-child(1) h5").innerHTML =
userData.PatientWebCard.Consensi[i].ConsensoDescrizione.replace(/\s\d{4}$/,
""
);
temp.querySelector("td:nth-child(1) .doc-num").innerHTML =
"N° " + userData.PatientWebCard.Consensi[i].CheckUpConsensoId;
temp.querySelector("td:nth-child(2)").innerHTML=date;
temp.querySelector("td:nth-child(3)").innerHTML =
'<span class="person" data-account="' +
userData.PatientWebCard.Consensi[i].PazienteId +
'">' +
userData.PatientWebCard.Consensi[i].PazienteNome +
"</span>";
temp
.querySelector("td:nth-child(4) .cta-call")
.setAttribute("href",
userData.PatientWebCard.Consensi[i].PublicUrlDocument!=null
? userData.PatientWebCard.Consensi[i].PublicUrlDocument
: "#"
);
if(userData.PatientWebCard.Consensi[i].ToSignByPatient){
temp
.querySelector("td:nth-child(4) .cta")
.classList.remove("disabled");
temp
.querySelector("td:nth-child(4) .cta")
.setAttribute("data-id",
userData.PatientWebCard.Consensi[i].CheckUpConsensoId
);
}else{
temp
.querySelector("td:nth-child(4) .cta-call")
.classList.remove("disabled");
temp.querySelector("td:nth-child(4) .cta").innerHTML="Firmato";
temp
.querySelector("td:nth-child(4) .cta")
.classList.add("disabled");
}
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}}
var signConsents=document.querySelectorAll("#documents-2 .cta");
for (let i=0; i < signConsents.length; i++){
signConsents[i].addEventListener("click", function (e){
if(!this.classList.contains("disabled")){
var checkUpConsensoId=this.getAttribute("data-id");
jQuery("#signConsentModal").modal("show");
document
.querySelector('#signConsentModal button[data-dismiss="signconsent-data-modal"]'
)
.setAttribute("data-id", checkUpConsensoId);
}
e.preventDefault();
});
}
var template=document.querySelector(".documents-contabili-template table tr"
);
var table=document.querySelector("#documents-3 table tr");
for (let i=userData.PatientWebCard.Fatture.length - 1; i >=0; i--){
if(currentUser==userData.PatientWebCard.Fatture[i].PazienteId ||
currentUser==userData.PatientWebCard.Fatture[i].ParentId
){
temp=template.cloneNode(true);
var originalDate=new Date(
userData.PatientWebCard.Fatture[i].DataFattura
);
var month=originalDate.getMonth() + 1;
month=month < 10 ? "0" + month:month;
var day=originalDate.getDate();
day=day < 10 ? "0" + day:day;
var date =
day +
"/" +
month +
"/" +
originalDate.getFullYear().toString().substr(-2);
temp.querySelector("td:nth-child(1) h5").innerHTML =
"Fattura N° " + userData.PatientWebCard.Fatture[i].NumFattura;
temp.querySelector("td:nth-child(1) .doc-num").innerHTML =
"Piano di cura N° " +
userData.PatientWebCard.Fatture[i].PreventivoNumero;
temp.querySelector("td:nth-child(2)").innerHTML=date;
temp.querySelector("td:nth-child(3) h5").innerHTML =
"&euro;" +
(Math.floor(userData.PatientWebCard.Fatture[i].FatturaImportoTotale
)!==userData.PatientWebCard.Fatture[i].FatturaImportoTotale
? userData.PatientWebCard.Fatture[i].FatturaImportoTotale.toFixed(2
).replace(".", ",")
: userData.PatientWebCard.Fatture[i].FatturaImportoTotale);
temp.querySelector("td:nth-child(4)").innerHTML =
'<span class="person" data-account="' +
userData.PatientWebCard.Fatture[i].PazienteId +
'">' +
userData.PatientWebCard.Fatture[i].PazienteNome +
"</span>";
temp
.querySelector("td:nth-child(5) a")
.setAttribute("href",
userData.PatientWebCard.Fatture[i].PublicUrlDocument!=null
? userData.PatientWebCard.Fatture[i].PublicUrlDocument
: "#"
);
if(userData.PatientWebCard.Fatture[i].PublicUrlDocument==null){
temp.querySelector("td:nth-child(5) a").classList.add("disabled");
}
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
temp.querySelector("td:nth-child(5) a").classList.remove("disabled");
}}
var ctaCallDisabled=document.querySelectorAll("#documenti .cta-call");
for (let i=0; i < ctaCallDisabled.length; i++){
ctaCallDisabled[i].addEventListener("click", function (e){
if(this.classList.contains("disabled")){
e.preventDefault();
}});
}}
function updateDocumentsOrder(){
var docs1=document.querySelectorAll("#documents-1 th:not(:last-child)");
var docs2=document.querySelectorAll("#documents-2 th:not(:last-child)");
var docs3=document.querySelectorAll("#documents-3 th:not(:last-child)");
for (let i=0; i < docs1.length; i++){
docs1[i].addEventListener("click", function (){
var index=Array.from(docs1).indexOf(this);
var docs1_tr=document.querySelectorAll("#documents-1 tr:has(td)");
var docs1_array=[];
for (let e=0; e < docs1_tr.length; e++){
var date=docs1_tr[e].querySelector("td:nth-child(2)").innerHTML;
if(date=="-"){
var date_ex="-";
}else{
var date_ex=date.split("/");
var date_ex=date_ex[2] + "-" + date_ex[1] + "-" + date_ex[0];
}
docs1_array.push({
0: docs1_tr[e].querySelector("td:nth-child(1)").innerHTML,
1: date_ex,
2: docs1_tr[e].querySelector("td:nth-child(3)").innerHTML,
3: docs1_tr[e].querySelector("td:nth-child(4)").innerHTML,
4: docs1_tr[e].querySelector("td:nth-child(5)").innerHTML,
5: docs1_tr[e].querySelector("td:nth-child(6)").innerHTML,
});
}
for (let e=0; e < docs1_tr.length; e++){
docs1_tr[e].remove();
}
docs1_array.sort(function (a, b){
var planA=a[index].toLowerCase();
var planB=b[index].toLowerCase();
if(/<h5>/.test(planA)){
if(/<h5>\s*<\/h5>/.test(planA)){
planA=0;
}else{
var matches=planA.match(/€(\d+)/);
if(matches&&matches.length > 1){
planA=parseInt(matches[1]);
}else{
var match=planA.match(/fattura n° (\d+)/);
if(match&&match.length > 1){
planA=parseInt(match[1]);
}}
}}
if(/<h5>/.test(planB)){
if(/<h5>\s*<\/h5>/.test(planB)){
planB=0;
}else{
var matches=planB.match(/€(\d+)/);
if(matches&&matches.length > 1){
planB=parseInt(matches[1]);
}else{
var match=planB.match(/fattura n° (\d+)/);
if(match&&match.length > 1){
planB=parseInt(match[1]);
}}
}}
if(document.getElementById("documents-1").classList.contains("asc")
){
if(planA==0) planA=999999;
if(planB==0) planB=999999;
if(planA > planB){
return -1;
}else if(planA < planB){
return 1;
}else{
return 0;
}}else{
if(planA < planB){
return -1;
}else if(planA > planB){
return 1;
}else{
return 0;
}}
});
if(document.getElementById("documents-1").classList.contains("asc")
){
document.getElementById("documents-1").classList.remove("asc");
}else{
document.getElementById("documents-1").classList.add("asc");
}
var template=document.querySelector(".documents-clinici-template table tr"
);
var table=document.querySelector("#documents-1 table tr");
var temp;
for (let e=0; e < docs1_array.length; e++){
temp=template;
if(docs1_array[e][1]=="-"){
var date_new="-";
}else{
var date=docs1_array[e][1].split("-");
var date_new=date[2] + "/" + date[1] + "/" + date[0];
}
temp.querySelector("td:nth-child(1)").innerHTML=docs1_array[e][0];
temp.querySelector("td:nth-child(2)").innerHTML=date_new;
temp.querySelector("td:nth-child(3)").innerHTML=docs1_array[e][2];
temp.querySelector("td:nth-child(4)").innerHTML=docs1_array[e][3];
temp.querySelector("td:nth-child(5)").innerHTML=docs1_array[e][4];
temp.querySelector("td:nth-child(6)").innerHTML=docs1_array[e][5];
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}});
}
for (let i=0; i < docs2.length; i++){
docs2[i].addEventListener("click", function (){
var index=Array.from(docs2).indexOf(this);
var docs2_tr=document.querySelectorAll("#documents-2 tr:has(td)");
var docs2_array=[];
for (let e=0; e < docs2_tr.length; e++){
var date=docs2_tr[e].querySelector("td:nth-child(2)").innerHTML;
if(date=="-"){
var date_ex="-";
}else{
var date_ex=date.split("/");
var date_ex=date_ex[2] + "-" + date_ex[1] + "-" + date_ex[0];
}
docs2_array.push({
0: docs2_tr[e].querySelector("td:nth-child(1)").innerHTML,
1: date_ex,
2: docs2_tr[e].querySelector("td:nth-child(3)").innerHTML,
3: docs2_tr[e].querySelector("td:nth-child(4)").innerHTML,
});
}
for (let e=0; e < docs2_tr.length; e++){
docs2_tr[e].remove();
}
docs2_array.sort(function (a, b){
var planA=a[index].toLowerCase();
var planB=b[index].toLowerCase();
if(/<h5>/.test(planA)){
if(/<h5>\s*<\/h5>/.test(planA)){
planA=0;
}else{
var matches=planA.match(/€(\d+)/);
if(matches&&matches.length > 1){
planA=parseInt(matches[1]);
}else{
var match=planA.match(/fattura n° (\d+)/);
if(match&&match.length > 1){
planA=parseInt(match[1]);
}}
}}
if(/<h5>/.test(planB)){
if(/<h5>\s*<\/h5>/.test(planB)){
planB=0;
}else{
var matches=planB.match(/€(\d+)/);
if(matches&&matches.length > 1){
planB=parseInt(matches[1]);
}else{
var match=planB.match(/fattura n° (\d+)/);
if(match&&match.length > 1){
planB=parseInt(match[1]);
}}
}}
if(document.getElementById("documents-2").classList.contains("asc")
){
if(planA==0) planA=999999;
if(planB==0) planB=999999;
if(planA > planB){
return -1;
}else if(planA < planB){
return 1;
}else{
return 0;
}}else{
if(planA < planB){
return -1;
}else if(planA > planB){
return 1;
}else{
return 0;
}}
});
if(document.getElementById("documents-2").classList.contains("asc")
){
document.getElementById("documents-2").classList.remove("asc");
}else{
document.getElementById("documents-2").classList.add("asc");
}
var template=document.querySelector(".documents-consensi-template table tr"
);
var table=document.querySelector("#documents-2 table tr");
var temp;
for (let e=0; e < docs2_array.length; e++){
temp=template;
if(docs2_array[e][1]=="-"){
var date_new="-";
}else{
var date=docs2_array[e][1].split("-");
var date_new=date[2]
? date[2] + "/" + date[1] + "/" + date[0]
: "";
}
temp.querySelector("td:nth-child(1)").innerHTML=docs2_array[e][0];
temp.querySelector("td:nth-child(2)").innerHTML=date_new;
temp.querySelector("td:nth-child(3)").innerHTML=docs2_array[e][2];
temp.querySelector("td:nth-child(4)").innerHTML=docs2_array[e][3];
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}});
}
for (let i=0; i < docs3.length; i++){
docs3[i].addEventListener("click", function (){
var index=Array.from(docs3).indexOf(this);
var docs3_tr=document.querySelectorAll("#documents-3 tr:has(td)");
var docs3_array=[];
for (let e=0; e < docs3_tr.length; e++){
var date=docs3_tr[e].querySelector("td:nth-child(2)").innerHTML;
if(date=="-"){
var date_ex="-";
}else{
var date_ex=date.split("/");
var date_ex=date_ex[2] + "-" + date_ex[1] + "-" + date_ex[0];
}
docs3_array.push({
0: docs3_tr[e].querySelector("td:nth-child(1)").innerHTML,
1: date_ex,
2: docs3_tr[e].querySelector("td:nth-child(3)").innerHTML,
3: docs3_tr[e].querySelector("td:nth-child(4)").innerHTML,
4: docs3_tr[e].querySelector("td:nth-child(5)").innerHTML,
});
}
for (let e=0; e < docs3_tr.length; e++){
docs3_tr[e].remove();
}
docs3_array.sort(function (a, b){
var planA=a[index].toLowerCase();
var planB=b[index].toLowerCase();
if(/<h5>/.test(planA)){
if(/<h5>\s*<\/h5>/.test(planA)){
planA=0;
}else{
var matches=planA.match(/€(\d+)/);
if(matches&&matches.length > 1){
planA=parseInt(matches[1]);
}else{
var match=planA.match(/fattura n° (\d+)/);
if(match&&match.length > 1){
planA=parseInt(match[1]);
}}
}}
if(/<h5>/.test(planB)){
if(/<h5>\s*<\/h5>/.test(planB)){
planB=0;
}else{
var matches=planB.match(/€(\d+)/);
if(matches&&matches.length > 1){
planB=parseInt(matches[1]);
}else{
var match=planB.match(/fattura n° (\d+)/);
if(match&&match.length > 1){
planB=parseInt(match[1]);
}}
}}
if(document.getElementById("documents-3").classList.contains("asc")
){
if(planA==0) planA=999999;
if(planB==0) planB=999999;
if(planA > planB){
return -1;
}else if(planA < planB){
return 1;
}else{
return 0;
}}else{
if(planA < planB){
return -1;
}else if(planA > planB){
return 1;
}else{
return 0;
}}
});
if(document.getElementById("documents-3").classList.contains("asc")
){
document.getElementById("documents-3").classList.remove("asc");
}else{
document.getElementById("documents-3").classList.add("asc");
}
var template=document.querySelector(".documents-contabili-template table tr"
);
var table=document.querySelector("#documents-3 table tr");
var temp;
for (let e=0; e < docs3_array.length; e++){
temp=template;
if(docs3_array[e][1]=="-"){
var date_new="-";
}else{
var date=docs3_array[e][1].split("-");
var date_new=date[2] + "/" + date[1] + "/" + date[0];
}
temp.querySelector("td:nth-child(1)").innerHTML=docs3_array[e][0];
temp.querySelector("td:nth-child(2)").innerHTML=date_new;
temp.querySelector("td:nth-child(3)").innerHTML=docs3_array[e][2];
temp.querySelector("td:nth-child(4)").innerHTML=docs3_array[e][3];
temp.querySelector("td:nth-child(5)").innerHTML=docs3_array[e][4];
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}});
}}
function padZero(num){
return num < 10 ? "0" + num:num;
}
function updatePlans(){
var temp=null;
var lines=document.querySelectorAll("#plansTabsContent table tr:not(:first-child)"
);
for (let i=0; i < lines.length; i++){
lines[i].remove();
}
var template=document.querySelector(".plans-sospeso-template table tr");
var table=document.querySelector("#plans-1 table tr");
for (let i=userData.PatientWebCard.Preventivi.length - 1; i >=0; i--){
if(currentUser==userData.PatientWebCard.Preventivi[i].PazienteId ||
currentUser==userData.PatientWebCard.Preventivi[i].ParentId
){
if(userData.PatientWebCard.Preventivi[i].StatoPreventivoId==10 ||
userData.PatientWebCard.Preventivi[i].StatoPreventivoId==20
){
temp=template.cloneNode(true);
var originalDate=new Date(
userData.PatientWebCard.Preventivi[i].DataPreventivo
);
var month=padZero(originalDate.getMonth() + 1);
var day=padZero(originalDate.getDate());
var date =
day +
"/" +
month +
"/" +
originalDate.getFullYear().toString().substr(-2);
temp.querySelector("td:nth-child(1) h5").innerHTML =
"N° " + userData.PatientWebCard.Preventivi[i].PreventivoNumero;
temp.querySelector("td:nth-child(1) .dates").innerHTML=date;
temp.querySelector("td:nth-child(1) .others span").innerHTML =
userData.PatientWebCard.Preventivi[i].OperatoreMedicoDescrizione;
temp.querySelector("td:nth-child(1) .others u").innerHTML=userData
.PatientWebCard.Preventivi[i].ClinicaAlias
? userData.PatientWebCard.Preventivi[i].ClinicaAlias
: userData.PatientWebCard.Preventivi[i].ClinicaDescrizione;
temp.querySelector("td:nth-child(2) h5").innerHTML =
"&euro;" + userData.PatientWebCard.Preventivi[i].TotalePreventivo;
temp.querySelector("td:nth-child(3)").innerHTML =
'<span class="person" data-account="' +
userData.PatientWebCard.Preventivi[i].PazienteId +
'">' +
userData.PatientWebCard.Preventivi[i].PazienteNome +
"</span>";
var links=temp.querySelectorAll("a");
for (let e=0; e < links.length; e++){
links[e].setAttribute("data-id",
userData.PatientWebCard.Preventivi[i].PreventivoNumero
);
}
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}}
}
var template=document.querySelector(".plans-corso-template table tr");
var table=document.querySelector("#plans-2 table tr");
for (let i=userData.PatientWebCard.Preventivi.length - 1; i >=0; i--){
if(currentUser==userData.PatientWebCard.Preventivi[i].PazienteId ||
currentUser==userData.PatientWebCard.Preventivi[i].ParentId
){
if(userData.PatientWebCard.Preventivi[i].StatoPreventivoId==30){
temp=template.cloneNode(true);
var originalDate=new Date(
userData.PatientWebCard.Preventivi[i].DataPreventivo
);
var month=padZero(originalDate.getMonth() + 1);
var day=padZero(originalDate.getDate());
var date =
day +
"/" +
month +
"/" +
originalDate.getFullYear().toString().substr(-2);
var pagato =
userData.PatientWebCard.Preventivi[i].TotalePrestazioniEseguite ||
0;
for (
let x=0;
x < userData.PatientWebCard.Preventivi[i].PianiPagamento.length;
x++
){
if(userData.PatientWebCard.Preventivi[i].PianiPagamento[x]
.PagamentoGestito
){
pagato +=
userData.PatientWebCard.Preventivi[i].PianiPagamento[x]
.PianoPagamentoImporto;
}}
if(pagato > userData.PatientWebCard.Preventivi[i].TotalePreventivo
){
pagato=userData.PatientWebCard.Preventivi[i].TotalePreventivo;
}
temp.querySelector("td:nth-child(1) h5").innerHTML =
"N° " + userData.PatientWebCard.Preventivi[i].PreventivoNumero;
temp.querySelector("td:nth-child(1) .dates").innerHTML=date;
temp.querySelector("td:nth-child(1) .others span").innerHTML =
userData.PatientWebCard.Preventivi[i].OperatoreMedicoDescrizione;
temp.querySelector("td:nth-child(1) .others u").innerHTML =
userData.PatientWebCard.Preventivi[i].ClinicaIndirizzo +
" - " +
userData.PatientWebCard.Preventivi[i].ClinicaLocalita +
" (" +
userData.PatientWebCard.Preventivi[i].ClinicaProvincia +
")";
temp.querySelector("td:nth-child(2) h5").innerHTML =
"&euro;" + userData.PatientWebCard.Preventivi[i].TotalePreventivo;
temp.querySelector("td:nth-child(3) h5").innerHTML =
"&euro;" +
(userData.PatientWebCard.Preventivi[i].TotalePreventivo - pagato);
temp.querySelector("td:nth-child(4) h5").innerHTML =
"&euro;" + pagato;
temp.querySelector("td:nth-child(5)").innerHTML =
'<span class="person" data-account="' +
userData.PatientWebCard.Preventivi[i].PazienteId +
'">' +
userData.PatientWebCard.Preventivi[i].PazienteNome +
"</span>";
var links=temp.querySelectorAll("a");
for (let e=0; e < links.length; e++){
links[e].setAttribute("data-id",
userData.PatientWebCard.Preventivi[i].PreventivoNumero
);
}
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}}
}
var template=document.querySelector(".plans-storico-template table tr");
var table=document.querySelector("#plans-3 table tr");
for (let i=userData.PatientWebCard.Preventivi.length - 1; i >=0; i--){
if(currentUser==userData.PatientWebCard.Preventivi[i].PazienteId ||
currentUser==userData.PatientWebCard.Preventivi[i].ParentId
){
if(userData.PatientWebCard.Preventivi[i].StatoPreventivoId==60){
temp=template.cloneNode(true);
var originalDate=new Date(
userData.PatientWebCard.Preventivi[i].DataPreventivo
);
var month=padZero(originalDate.getMonth() + 1);
var day=padZero(originalDate.getDate());
var date =
day +
"/" +
month +
"/" +
originalDate.getFullYear().toString().substr(-2);
temp.querySelector("td:nth-child(1) h5").innerHTML =
"N° " + userData.PatientWebCard.Preventivi[i].PreventivoNumero;
temp.querySelector("td:nth-child(1) .dates").innerHTML=date;
temp.querySelector("td:nth-child(1) .others span").innerHTML =
userData.PatientWebCard.Preventivi[i].OperatoreMedicoDescrizione;
temp.querySelector("td:nth-child(1) .others u").innerHTML =
userData.PatientWebCard.Preventivi[i].ClinicaIndirizzo +
" - " +
userData.PatientWebCard.Preventivi[i].ClinicaLocalita +
" (" +
userData.PatientWebCard.Preventivi[i].ClinicaProvincia +
")";
temp.querySelector("td:nth-child(2) h5").innerHTML =
"&euro;" + userData.PatientWebCard.Preventivi[i].QuotaPaziente;
temp.querySelector("td:nth-child(3)").innerHTML =
'<span class="person" data-account="' +
userData.PatientWebCard.Preventivi[i].PazienteId +
'">' +
userData.PatientWebCard.Preventivi[i].PazienteNome +
"</span>";
var links=temp.querySelectorAll("a");
for (let e=0; e < links.length; e++){
links[e].setAttribute("data-id",
userData.PatientWebCard.Preventivi[i].PreventivoNumero
);
}
table.insertAdjacentHTML("afterend",
"<tr>" + temp.innerHTML + "</tr>"
);
}}
}
var links=document.querySelectorAll("#plansTabsContent table a");
for (let i=0; i < links.length; i++){
links[i].addEventListener("click", function (e){
var currentPreventivo=this.getAttribute("data-id");
for (let x=0; x < userData.PatientWebCard.Preventivi.length; x++){
if(currentPreventivo==userData.PatientWebCard.Preventivi[x].PreventivoNumero
){
currentPreventivo=userData.PatientWebCard.Preventivi[x];
}}
if(this.classList.contains("cta")){
jQuery("#signModal").modal("show");
document
.querySelector('button[data-dismiss="sign-data-modal"]')
.addEventListener("click", function (e){
acceptAndSign(currentPreventivo);
jQuery("#signModal").modal("hide");
});
e.preventDefault();
}else if(this.classList.contains("cta-call")){
var originalDate=new Date(currentPreventivo.DataPreventivo);
var month=padZero(originalDate.getMonth() + 1);
var day=padZero(originalDate.getDate());
var date =
day +
"/" +
month +
"/" +
originalDate.getFullYear().toString().substr(-2);
var versionDate="-";
if(currentPreventivo.DataVersione!=null){
var versionDateObj=new Date(currentPreventivo.DataVersione);
var versionMonth=padZero(versionDateObj.getMonth() + 1);
var versionDay=padZero(versionDateObj.getDate());
versionDate =
versionDay +
"/" +
versionMonth +
"/" +
versionDateObj.getFullYear().toString().substr(-2);
}
var color =
currentPreventivo.StatoPreventivoId==50 ||
currentPreventivo.StatoPreventivoId==51
? "color-red"
: currentPreventivo.StatoPreventivoId==30 ||
currentPreventivo.StatoPreventivoId==60
? "color-green"
: "";
var originalDateScadenza=new Date(
currentPreventivo.DataScadenzaPreventivo
);
var monthScadenza=padZero(originalDateScadenza.getMonth() + 1);
var dayScadenza=padZero(originalDateScadenza.getDate());
var scadenza =
dayScadenza +
"/" +
monthScadenza +
"/" +
originalDateScadenza.getFullYear().toString().substr(-2);
var pagato=currentPreventivo.TotalePrestazioniEseguite||0;
for (let x=0; x < currentPreventivo.PianiPagamento.length; x++){
if(currentPreventivo.PianiPagamento[x].PagamentoGestito){
pagato +=
currentPreventivo.PianiPagamento[x].PianoPagamentoImporto;
}}
if(pagato > currentPreventivo.TotalePreventivo){
pagato=currentPreventivo.TotalePreventivo;
}
var statoPreventivo =
currentPreventivo.StatoPreventivoId==20
? "Consegnato al paziente"
: currentPreventivo.StatoPreventivoDescrizione;
var preventivo=document.querySelector("#preventivo");
preventivo.querySelector("h1 span").innerHTML =
currentPreventivo.PreventivoNumero;
preventivo.querySelector(".generics .row:nth-child(2) .col-6:last-child"
).innerHTML =
currentPreventivo.PazienteNome +
" " +
currentPreventivo.PazienteCognome;
preventivo.querySelector(".generics .row:nth-child(3) .col-6:last-child"
).innerHTML=currentPreventivo.PreventivoNumero;
preventivo.querySelector(".generics .row:nth-child(4) .col-6:last-child"
).innerHTML=date;
preventivo.querySelector(".generics .row:nth-child(5) .col-6:last-child"
).innerHTML =
'<span class="' + color + '">' + statoPreventivo + "</span>";
preventivo.querySelector(".generics .row:nth-child(6) .col-6:last-child"
).innerHTML=currentPreventivo.OperatoreMedicoDescrizione;
preventivo.querySelector(".generics .row:nth-child(7) .col-6:last-child"
).innerHTML =
currentPreventivo.OperatoreCommercialeDescrizione!=null
? currentPreventivo.OperatoreCommercialeDescrizione
: "-";
preventivo.querySelector(".generics .row:nth-child(8) .col-6:last-child"
).innerHTML =
currentPreventivo.QuotaFondo!=null &&
currentPreventivo.QuotaFondo > 0
? currentPreventivo.QuotaFondo + " &euro;"
: "-";
preventivo.querySelector(".generics .row:nth-child(9) .col-6:last-child"
).innerHTML=scadenza;
preventivo.querySelector(".generics .row:nth-child(10) .col-6:last-child"
).innerHTML=versionDate;
preventivo.querySelector(".payment .row:nth-child(2) .col-6:last-child"
).innerHTML=currentPreventivo.TotalePreventivo + " &euro;";
preventivo.querySelector(".payment .row:nth-child(3) .col-6:last-child"
).innerHTML="-";
preventivo.querySelector(".payment .row:nth-child(4) .col-6:last-child"
).innerHTML =
currentPreventivo.QuotaFondo==0
? "-"
: currentPreventivo.QuotaFondo + " &euro;";
preventivo.querySelector(".payment .row:nth-child(5) .col-6:last-child"
).innerHTML=currentPreventivo.QuotaPaziente + " &euro;";
preventivo.querySelector(".payment .row:nth-child(6) .col-6:last-child"
).innerHTML=pagato + " &euro;";
preventivo.querySelector(".payment .row:nth-child(7) .col-6:last-child"
).innerHTML =
currentPreventivo.TotalePreventivo -
currentPreventivo.QuotaFondo +
" &euro;";
var preventivoDownloadBtn=preventivo.querySelector(".cta-call:not(.cta-care-plan)");
var carePlanDetailBtn=preventivo.querySelector(".cta-care-plan");
if(preventivoDownloadBtn){
if(currentPreventivo.PublicUrlDocument!=null){
preventivoDownloadBtn.classList.remove("hide");
}else{
preventivoDownloadBtn.classList.add("hide");
}
preventivoDownloadBtn.setAttribute("href",
currentPreventivo.PublicUrlDocument!=null
? currentPreventivo.PublicUrlDocument
: "#"
);
}
if(carePlanDetailBtn){
var carePlanHref =
currentPreventivo.PublicUrlCarePlanDocument!=null &&
currentPreventivo.PublicUrlCarePlanDocument!==""
? currentPreventivo.PublicUrlCarePlanDocument
: "#";
carePlanDetailBtn.setAttribute("href", carePlanHref);
if(carePlanHref!=="#"){
carePlanDetailBtn.classList.remove("hide");
if(!carePlanDetailBtn.textContent.trim()) carePlanDetailBtn.appendChild(document.createTextNode("Scarica piano di cura"));
}else{
carePlanDetailBtn.classList.add("hide");
}}
var preventivoHtml="";
if(currentPreventivo.PianiPagamento!=null){
for (
let x=0;
x < currentPreventivo.PianiPagamento.length;
x++
){
var pagatore =
currentPreventivo.PianiPagamento[x].TipoPagatoreId==1
? currentPreventivo.PianiPagamento[x]
.TipoPagatoreDescrizione
: currentPreventivo.TerzoPagatoreDescrizione;
var originalDatePagamento=new Date(
currentPreventivo.PianiPagamento[x].DataPrevistaFatturazione
);
var monthPagamento=padZero(
originalDatePagamento.getMonth() + 1
);
var dayPagamento=padZero(originalDatePagamento.getDate());
var datePagamento =
dayPagamento +
"/" +
monthPagamento +
"/" +
originalDatePagamento.getFullYear().toString().substr(-2);
var gestito=currentPreventivo.PianiPagamento[x]
.PagamentoGestito
? '<strong class="color-green">&#10003;</strong>'
: '<strong class="color-red">&#10007;</strong>';
preventivoHtml +='<div class="row thin">';
preventivoHtml +=
'<div class="col-4">' + datePagamento + "</div>";
preventivoHtml +=
'<div class="col-3">' +
currentPreventivo.PianiPagamento[x].PianoPagamentoImporto +
" &euro;</div>";
preventivoHtml +='<div class="col-2">' + gestito + "</div>";
preventivoHtml +='<div class="col-3">' + pagatore + "</div>";
preventivoHtml +="</div>";
}}
var paymentPlans=preventivo.querySelectorAll(".payment-plans .row.thin"
);
for (let y=0; y < paymentPlans.length; y++){
paymentPlans[y].remove();
}
preventivo.querySelector(".payment-plans").innerHTML +=
preventivoHtml;
document.querySelector("#piani").classList.remove("active");
document.querySelector("#preventivo").classList.add("active");
window.scrollTo(0, 0);
}else{
var parentTr=this.parentNode.parentNode.parentNode;
parentTr.classList.toggle("active");
}
e.preventDefault();
});
}}
function updateDati(){
var user=getCurrentData();
document.querySelector(".updated-info").classList.add("hide");
var nazioni =
'<li><a class="dropdown-item" href="#" data-value="IT">ITALIA</a></li>';
for (let i=0; i < master.Nazioni.length; i++){
if(master.Nazioni[i].SiglaNazione!="IT"){
nazioni +=
'<li><a class="dropdown-item" href="#" data-value="' +
master.Nazioni[i].SiglaNazione +
'">' +
master.Nazioni[i].Nazione +
"</a></li>";
}}
document.querySelector("#input-residenzafiscale + .dropdown-menu"
).innerHTML=nazioni;
updateProvinces();
resetAssicurazione();
setTimeout(function (){
var bootstrapDropdowns=document.querySelectorAll("#anagrafica .dropdown-menu li a"
);
for (let i=0; i < bootstrapDropdowns.length; i++){
bootstrapDropdowns[i].addEventListener("click", function (e){
var dropdown=findAncestor(this, ".dropdown");
dropdown.querySelector(".btn").innerHTML=this.innerHTML;
dropdown.querySelector(".btn").value =
this.getAttribute("data-value");
e.preventDefault();
});
}}, 1000);
var originalDate=new Date(user.PazienteDataNascita);
var month=originalDate.getMonth() + 1;
month=month < 10 ? "0" + month:month;
var day=originalDate.getDate();
day=day < 10 ? "0" + day:day;
var date=originalDate.getFullYear() + "-" + month + "-" + day;
document.querySelector("#input-cod").value=user.PazienteCodice;
document.querySelector(".account-type").innerHTML =
currentRelUser==null
? '<span class="icona-Verification-badge"><span class="path1"></span><span class="path2"></span><span class="path3"></span></span> Paziente verificato'
: "Paziente non verificato";
document.querySelector("#input-cognome").value =
user.PazienteCognome!=null ? user.PazienteCognome:"";
document.querySelector("#input-nome").value =
user.PazienteNome!=null ? user.PazienteNome:"";
document.querySelector("#input-sesso").innerHTML =
user.PazienteSesso!=null ? user.PazienteSesso:"";
document.querySelector("#input-sesso").value =
user.PazienteSesso!=null ? user.PazienteSesso:"";
document.querySelector("#input-cf").value =
user.PazienteCodiceFiscale!=null ? user.PazienteCodiceFiscale:"";
document.querySelector("#input-professione").value =
user.PazienteProfessione!=null ? user.PazienteProfessione:"";
document.querySelector("#input-residenzafiscale").innerHTML =
user.NazioneDescrizione!=null ? user.NazioneDescrizione:"Italia";
document.querySelector("#input-residenzafiscale").value =
user.PazienteNazione!=null ? user.PazienteNazione:"IT";
document.querySelector("#input-datanascita").value=date;
document.querySelector("#input-luogonascita").value =
user.PazienteLocalitaNascita!=null
? user.PazienteLocalitaNascita
: "";
document.querySelector("#input-provincianascita").innerHTML =
user.PazienteProvinciaNascita!=null
? getFullProvince(user.PazienteProvinciaNascita)
: "";
document.querySelector("#input-provincianascita").value =
user.PazienteProvinciaNascita!=null
? user.PazienteProvinciaNascita
: "";
document.querySelector("#input-telefono").value =
user.PazienteTelefono!=null ? user.PazienteTelefono:"";
document.querySelector("#input-mail").value =
user.PazienteEmail!=null ? user.PazienteEmail:"";
document.querySelector("#input-indirizzo").value =
user.PazienteIndirizzo!=null ? user.PazienteIndirizzo:"";
document.querySelector("#input-localita").value =
user.PazienteLocalita!=null ? user.PazienteLocalita:"";
document.querySelector("#input-provincia").value =
user.PazienteProvincia!=null ? user.PazienteProvincia:"";
document.querySelector("#input-cap").value =
user.PazienteCap!=null ? user.PazienteCap:"";
document.querySelector("#input-privacy-1").checked=true;
document.querySelector("#input-privacy-2").checked=true;
document.querySelector("#input-privacy-3").checked =
user.PazientiPrivacy_3_Marketing;
document.querySelector("#input-privacy-4").checked =
user.PazientiPrivacy_4_Profilazione;
document.querySelector("#input-privacy-5").checked =
user.PazientiPrivacy_5_FirmaGrafometrica;
var inputs=document.querySelectorAll("#dati-1 input, #dati-1 .dropdown button, #dati-2 input, #dati-2 .dropdown button"
);
for (let i=0; i < inputs.length; i++){
inputs[i].setAttribute("disabled", true);
}
document.getElementById("input-cod").setAttribute("disabled", true);
document
.querySelector(".edit-data")
.addEventListener("click", function (e){
if(!this.classList.contains("disabled")){
var inputs=document.querySelectorAll("#dati-1 input, #dati-1 .dropdown button, #dati-1 select[multiple]"
);
for (let i=0; i < inputs.length; i++){
inputs[i].removeAttribute("disabled");
}
document.getElementById("input-cod").setAttribute("disabled", true);
this.classList.add("hide");
document.querySelector(".save-data").classList.remove("hide");
document
.querySelector("#dati-1 .cta-cancel")
.classList.remove("hide");
}
e.preventDefault();
});
document
.querySelector(".edit-contacts")
.addEventListener("click", function (e){
if(!this.classList.contains("disabled")){
var inputs=document.querySelectorAll("#dati-2 input, #dati-2 .dropdown button"
);
for (let i=0; i < inputs.length; i++){
inputs[i].removeAttribute("disabled");
}
this.classList.add("hide");
document.querySelector(".save-contacts").classList.remove("hide");
document
.querySelector("#dati-2 .cta-cancel")
.classList.remove("hide");
}
e.preventDefault();
});
document
.querySelector(".edit-privacy")
.addEventListener("click", function (e){
if(!this.classList.contains("disabled")){
var inputs=document.querySelectorAll("#dati-4 input");
for (let i=0; i < inputs.length; i++){
if(inputs[i].getAttribute("id")!="input-privacy-1" &&
inputs[i].getAttribute("id")!="input-privacy-2"
){
inputs[i].removeAttribute("disabled");
}}
this.classList.add("hide");
document
.querySelector("#dati-4 .text-show")
.classList.remove("disabled");
document.querySelector(".save-privacy").classList.remove("hide");
document
.querySelector("#dati-4 .cta-cancel")
.classList.remove("hide");
}
e.preventDefault();
});
var deleteAccount=document.querySelectorAll(".delete-account-link");
for (let i=0; i < deleteAccount.length; i++){
deleteAccount[i].addEventListener("click", function (e){
var dataid=this.getAttribute("data-id");
jQuery("#deleteAccountModal").modal("show");
document
.querySelector('#deleteAccountModal button[data-dismiss="delete-account-modal"]'
)
.setAttribute("data-id", dataid);
e.preventDefault();
});
}}
function savePazienteDataValidate(){
if(document.getElementById("input-cognome").value=="" ||
document.getElementById("input-nome").value==""
){
alert("ERRORE: Compilare i dati obbligatori.");
return false;
}
if(document.getElementById("input-cf").value!=""){
if(document.getElementById("input-cf").value.length!=16){
alert("ERRORE: Inserire un codice fiscale valido.");
return false;
}}
if(!validateLuogoNascita(
document.getElementById("input-luogonascita").value
)
){
alert("ERRORE: Inserire un luogo di nascita valido.");
return false;
}
return true;
}
function validateLuogoNascita(value){
const regex=/^[a-zA-Z\s]+$/;
return regex.test(value)&&value.trim()!=="";
}
function savePazienteData(e, modalCallback=false){
e.preventDefault();
if(!savePazienteDataValidate()){
return;
}
if(document.getElementById("input-cognome").value=="" ||
document.getElementById("input-nome").value==""
){
alert("ERRORE: Compilare i dati obbligatori.");
e.preventDefault();
return;
}
if(document.getElementById("input-cf").value!=""){
if(document.getElementById("input-cf").value.length!=16){
alert("ERRORE: Inserire un codice fiscale valido.");
e.preventDefault();
return;
}}
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var assicurazione=getAssicurazioneValues();
var user=getCurrentData();
var PazienteData={
PazienteId: user.PazienteId,
ParentId: user.ParentId,
ClinicaId: user.ClinicaId,
PazienteCognome: document
.getElementById("input-cognome")
.value.toString(),
PazienteNome: document
.getElementById("input-nome")
.value.toString(),
PazienteIndirizzo: user.PazienteIndirizzo,
PazienteCap: user.PazienteCap,
PazienteLocalita: user.PazienteLocalita,
PazienteProvincia: user.PazienteProvincia,
PazienteCodiceFiscale: document
.getElementById("input-cf")
.value.toString(),
PazienteEmail: user.PazienteEmail,
PazienteTelefono: user.PazienteTelefono,
PazienteSesso: document
.getElementById("input-sesso")
.value.toString(),
PazienteDataNascita:
document.getElementById("input-datanascita").value +
"T00:00:00",
PazienteLocalitaNascita: document
.getElementById("input-luogonascita")
.value.toString(),
PazienteProvinciaNascita: document
.getElementById("input-provincianascita")
.value.toString(),
PazienteProfessione: document
.getElementById("input-professione")
.value.toString(),
PazienteNazione: document
.getElementById("input-residenzafiscale")
.value.toString(),
NazioneDescrizione: document
.getElementById("input-residenzafiscale")
.innerHTML.toString(),
PazientiPrivacy_1_Informativa: user.PazientiPrivacy_1_Informativa,
PazientiPrivacy_2_DirittiModifica:
user.PazientiPrivacy_2_DirittiModifica,
PazientiPrivacy_3_Marketing: user.PazientiPrivacy_3_Marketing,
PazientiPrivacy_4_Profilazione:
user.PazientiPrivacy_4_Profilazione,
PazientiPrivacy_5_FirmaGrafometrica:
user.PazientiPrivacy_5_FirmaGrafometrica,
PazienteFondi: assicurazione,
};
var dataContent;
if(typeof user.PazienteCorrelatoId==="undefined"){
dataContent={ Paziente: PazienteData };}else{
dataContent={
Correlati: [
{
PazienteCorrelatoId: user.PazienteCorrelatoId,
Paziente: PazienteData,
},
],
};}
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: dataContent,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
resetAnagrafica();
updateProgress();
if(modalCallback){
jQuery("#thankyouModal").modal("show");
}});
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_save_patient");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
e.preventDefault();
}
function savePazienteContacts(e, modalCallback=true){
if(document.getElementById("input-telefono").value=="" ||
document.getElementById("input-mail").value=="" ||
document.getElementById("input-indirizzo").value=="" ||
document.getElementById("input-localita").value=="" ||
document.getElementById("input-provincia").value=="" ||
document.getElementById("input-cap").value==""
){
alert("ERRORE: Compilare i dati obbligatori.");
e.preventDefault();
return;
}
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var user=getCurrentData();
var assicurazione=getAssicurazioneValues();
var PazienteData={
PazienteId: user.PazienteId,
ParentId: user.ParentId,
ClinicaId: user.ClinicaId,
PazienteCognome: user.PazienteCognome,
PazienteNome: user.PazienteNome,
PazienteIndirizzo: document
.getElementById("input-indirizzo")
.value.toString(),
PazienteCap: document
.getElementById("input-cap")
.value.toString(),
PazienteLocalita: document
.getElementById("input-localita")
.value.toString(),
PazienteProvincia: document
.getElementById("input-provincia")
.value.toString(),
PazienteCodiceFiscale: user.PazienteCodiceFiscale,
PazienteEmail: document
.getElementById("input-mail")
.value.toString(),
PazienteTelefono: document
.getElementById("input-telefono")
.value.toString(),
PazienteSesso: user.PazienteSesso,
PazienteDataNascita: user.PazienteDataNascita,
PazienteLocalitaNascita: user.PazienteLocalitaNascita,
PazienteProvinciaNascita: user.PazienteProvinciaNascita,
PazienteProfessione: user.PazienteProfessione,
PazienteNazione: user.PazienteNazione,
NazioneDescrizione: user.NazioneDescrizione,
TerzoPagatoreDescrizione: user.TerzoPagatoreDescrizione,
PazientiPrivacy_1_Informativa: user.PazientiPrivacy_1_Informativa,
PazientiPrivacy_2_DirittiModifica:
user.PazientiPrivacy_2_DirittiModifica,
PazientiPrivacy_3_Marketing: user.PazientiPrivacy_3_Marketing,
PazientiPrivacy_4_Profilazione:
user.PazientiPrivacy_4_Profilazione,
PazientiPrivacy_5_FirmaGrafometrica:
user.PazientiPrivacy_5_FirmaGrafometrica,
TerzoPagatoreDescrizione: user.TerzoPagatoreDescrizione,
PazienteFondi: assicurazione,
};
var dataContent;
if(typeof user.PazienteCorrelatoId==="undefined"){
dataContent={ Paziente: PazienteData };}else{
dataContent={
Correlati: [
{
PazienteCorrelatoId: user.PazienteCorrelatoId,
Paziente: PazienteData,
},
],
};}
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: dataContent,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
resetAnagrafica();
updateProgress();
if(modalCallback){
jQuery("#thankyouModal").modal("show");
document
.querySelector(".save-contacts")
.classList.add("hide");
document
.querySelector(".edit-contacts")
.classList.remove("hide");
var inputs=document.querySelectorAll("#dati-2 input, #dati-2 .dropdown button"
);
for (let i=0; i < inputs.length; i++){
inputs[i].setAttribute("disabled", true);
}}
});
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_save_patient");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
e.preventDefault();
}
function savePazientePrivacy(e, modalCallback=false){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var user=getCurrentData();
var assicurazione=getAssicurazioneValues();
var PazienteData={
PazienteId: user.PazienteId,
ParentId: user.ParentId,
ClinicaId: user.ClinicaId,
PazienteCognome: user.PazienteCognome,
PazienteNome: user.PazienteNome,
PazienteIndirizzo: user.PazienteIndirizzo,
PazienteCap: user.PazienteCap,
PazienteLocalita: user.PazienteLocalita,
PazienteProvincia: user.PazienteProvincia,
PazienteCodiceFiscale: user.PazienteCodiceFiscale,
PazienteEmail: user.PazienteEmail,
PazienteTelefono: user.PazienteTelefono,
PazienteSesso: user.PazienteSesso,
PazienteDataNascita: user.PazienteDataNascita,
PazienteLocalitaNascita: user.PazienteLocalitaNascita,
PazienteProvinciaNascita: user.PazienteProvinciaNascita,
PazienteProfessione: user.PazienteProfessione,
PazienteNazione: user.PazienteNazione,
NazioneDescrizione: user.NazioneDescrizione,
TerzoPagatoreDescrizione: user.TerzoPagatoreDescrizione,
PazientiPrivacy_1_Informativa: true,
PazientiPrivacy_2_DirittiModifica: true,
PazientiPrivacy_3_Marketing:
document.querySelector("#input-privacy-3").checked,
PazientiPrivacy_4_Profilazione:
document.querySelector("#input-privacy-4").checked,
PazientiPrivacy_5_FirmaGrafometrica:
document.querySelector("#input-privacy-5").checked,
TerzoPagatoreDescrizione: user.TerzoPagatoreDescrizione,
PazienteFondi: assicurazione,
};
var dataContent;
if(typeof user.PazienteCorrelatoId==="undefined"){
dataContent={ Paziente: PazienteData };}else{
dataContent={
Correlati: [
{
PazienteCorrelatoId: user.PazienteCorrelatoId,
Paziente: PazienteData,
},
],
};}
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: dataContent,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
signPazientePrivacy();
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_save_patient");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
e.preventDefault();
}
function signPazientePrivacy(){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
var user=getCurrentData();
var master=sessionStorage.getItem("PublicWebMasterTables");
master=JSON.parse(master);
let oggi=new Date();
let anno=oggi.getFullYear();
let mese=oggi.getMonth() + 1;
let giorno=oggi.getDate();
let dataFormattata=`${anno}-${mese < 10 ? "0":""}${mese}-${
giorno < 10 ? "0":""
}${giorno}T00:00:00`;
var questions=[];
for (let i=0; i < master.Privacy.SurveyQuestions.length; i++){
var surveyQuestion=master.Privacy.SurveyQuestions[i];
var surveyAnswers=[];
for (let e=0; e < surveyQuestion.SurveyAnswers.length; e++){
var surveyAnswer=surveyQuestion.SurveyAnswers[e];
var selected=false;
var isChecked=document.querySelector("#input-privacy-" + (i + 1)
).checked;
if(surveyAnswer.RispostaDescrizione.toLowerCase()=="si" &&
isChecked
){
selected=true;
}
if(surveyAnswer.RispostaDescrizione.toLowerCase()=="no" &&
!isChecked
){
selected=true;
}
if(selected){
surveyAnswers.push({
SurveyAnswerId: 0,
RispostaDescrizione: surveyAnswer.RispostaDescrizione,
RispostaId: surveyAnswer.RispostaId,
Selected: selected,
RispostaField: surveyAnswer.RispostaField,
RispostaFieldTrue: surveyAnswer.RispostaFieldTrue,
SurveyAnswerNote: surveyAnswer.SurveyAnswerNote,
});
}}
questions.push({
DomandaId: surveyQuestion.DomandaId,
DomandaDescrizione: surveyQuestion.DomandaDescrizione,
SurveyAnswers: surveyAnswers,
});
}
dataContent={
Paziente: {
PazienteId: user.PazienteId,
ClinicaId: user.ClinicaId,
},
Survey: {
SurveyNote: "",
SurveyQuestions: questions,
SurveyDate: dataFormattata,
FormularioId: master.Privacy.FormularioId,
},
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: dataContent,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
jQuery("#thankyouModal").modal("show");
document.querySelector(".save-privacy").classList.add("hide");
document
.querySelector(".edit-privacy")
.classList.remove("hide");
var inputs=document.querySelectorAll('#dati-4 input[type="checkbox"]'
);
for (let i=0; i < inputs.length; i++){
inputs[i].setAttribute("disabled", true);
}
document
.querySelector("#dati-4 .text-show")
.classList.add("disabled");
resetAnagrafica();
updateProgress();
});
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_sign_privacy");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function acceptAndSign(data){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
dataContent={
Preventivo: {
ClinicaId: data.ClinicaId,
PreventivoId: data.PreventivoId,
PazienteId: data.PazienteId,
CheckUpId: data.CheckUpId,
},
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: dataContent,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
updatePlans();
if(document.querySelector('.cta[data-id="' + data.PreventivoNumero + '"]'
)!=null
){
document
.querySelector('.cta[data-id="' + data.PreventivoNumero + '"]'
)
.classList.add("hide");
}});
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_accept_sign");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function signConsent(CheckUpConsensoId){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var signConsentObj={
CheckUpConsenso: {
ClinicaId: currentClinic.ClinicaId,
CheckUpConsensoId: parseInt(CheckUpConsensoId),
},
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: signConsentObj,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
if(document.querySelector('.cta[data-id="' + CheckUpConsensoId + '"]'
)!=null
){
document
.querySelector('.cta[data-id="' + CheckUpConsensoId + '"]'
)
.classList.add("hide");
}
jQuery("#signConsentModal").modal("hide");
jQuery("#thankyouModal").modal("show");
});
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_sign_consent");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function signSurvey(QuestionarioId, ClinicaId, OwnerId){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var signConsentObj={
Questionario: {
QuestionarioId: QuestionarioId,
ClinicaId: ClinicaId,
OwnerId: OwnerId,
},
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: signConsentObj,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
if(document.querySelector('.cta[data-type="anamnesi"][data-id="' +
QuestionarioId +
'"]'
)!=null
){
document
.querySelector('.cta[data-type="anamnesi"][data-id="' +
QuestionarioId +
'"]'
)
.classList.add("disabled");
document.querySelector('.cta[data-type="anamnesi"][data-id="' +
QuestionarioId +
'"]'
).innerHTML="Firmato";
}
jQuery("#signSurveyModal").modal("hide");
jQuery("#thankyouModal").modal("show");
});
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_sign_survey");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function deleteAccount(uname){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var deleteAccountObj={
uname: uname,
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: deleteAccountObj,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
jQuery("#deleteAccountModal").modal("hide");
logout();
}};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_delete_account");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function readMessage(msgToken){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var msgObj={
TokenSelector: msgToken,
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: msgObj,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateMessages();
document.body.classList.remove("overlay-loading-show");
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_save_notification");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function updateMessages(){
let myDataJSON=JSON.stringify({
token: sessionStorage.getItem("access_token"),
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
var response=JSON.parse(xhttp.responseText);
var notifications=response.Data.PatientNotifications;
var messages=[];
for (let i=0; i < notifications.length; i++){
var pazienteId=notifications[i].NotificationKey;
pazienteId=JSON.parse(pazienteId);
messages.push({
Entity: notifications[i].NotificationTypeDescription,
PazienteId: pazienteId.PazienteId,
ParentId: currentParentId,
DataMessaggio: notifications[i].NotifyAfter,
important: false,
TestoMessaggio: notifications[i].NotificationText,
Token: notifications[i].Token,
Viewed: typeof notifications[i].ViewedDate!=="undefined",
});
}
messages.sort((a, b)=> {
var dateA=new Date(a.DataMessaggio);
var dateB=new Date(b.DataMessaggio);
return dateB - dateA;
});
var msgs=[];
var temp=null;
var count_not_read=0;
var template=document.querySelector(".messages-template");
for (let i=0; i < messages.length; i++){
if(currentUser==messages[i].PazienteId ||
currentUser==messages[i].ParentId ||
isProspect
){
temp=template;
var originalDate=new Date(messages[i].DataMessaggio);
var month=originalDate.getMonth() + 1;
month=month < 10 ? "0" + month:month;
var date =
originalDate.getDate() +
"/" +
month +
"/" +
originalDate.getFullYear();
var text = !messages[i].Viewed
? "<strong>" + messages[i].Entity + ":</strong> "
: messages[i].Entity + ": ";
text +=messages[i].important
? "<u>" + messages[i].TestoMessaggio + "</u>"
: messages[i].TestoMessaggio;
temp
.querySelector(".icon")
.classList.remove("icona-Importanti_vuoto");
temp
.querySelector(".icon")
.classList.remove("icona-Importanti_pieno");
if(!messages[i].Viewed){
count_not_read++;
temp
.querySelector(".icon")
.classList.add("icona-Importanti_pieno");
}else{
temp
.querySelector(".icon")
.classList.add("icona-Importanti_vuoto");
}
temp.querySelector(".text").innerHTML=text;
if(messages[i].Viewed){
temp.querySelector(".msg").removeAttribute("data-token");
}else{
temp
.querySelector(".msg")
.setAttribute("data-token", messages[i].Token);
}
msgs.push({
date: date,
important: messages[i].important,
html: temp.innerHTML,
});
}}
var html="";
var htmlImportant="";
var currentDate="";
for (let i=0; i < msgs.length; i++){
if(msgs[i].date!=currentDate){
currentDate=msgs[i].date;
html +=
'<div class="date"><span>' + msgs[i].date + "</span></div>";
}
html +=msgs[i].html;
}
for (let i=0; i < msgs.length; i++){
if(msgs[i].important){
if(msgs[i].date!=currentDate){
currentDate=msgs[i].date;
htmlImportant +=
'<div class="date"><span>' + msgs[i].date + "</span></div>";
}
htmlImportant +=msgs[i].html;
}}
document.querySelector(".inbox-all").innerHTML=html;
document.querySelector(".inbox-important").innerHTML=htmlImportant;
var messages=document.querySelectorAll(".msg");
for (let i=0; i < messages.length; i++){
messages[i].addEventListener("click", function (e){
if(this.getAttribute("data-token") &&
this.getAttribute("data-token")!=""
){
readMessage(this.getAttribute("data-token"));
}
e.preventDefault();
});
}
document
.querySelector(".messages-link")
.setAttribute("data-num", count_not_read);
} /*else {
document.body.classList.remove('overlay-loading-show');
setTimeout(function(){ jQuery('#noInternetConnectionModal').modal('show'); }, 1000);
}*/
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_get_notifications");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type", "application/json; charset=UTF-8");
xhttp.send(myDataJSON);
}
function confirmAppointment(AppuntamentoPazienteId, ClinicaId){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var appObj={
Appuntamento: {
AppuntamentoPazienteId: AppuntamentoPazienteId,
ClinicaId: ClinicaId,
},
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: appObj,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
if(document.querySelector('.confirm[data-id="' + AppuntamentoPazienteId + '"]'
)!=null
){
document
.querySelector('.confirm[data-id="' + AppuntamentoPazienteId + '"]'
)
.parentNode.classList.add("hide");
document
.querySelector('.reject[data-id="' + AppuntamentoPazienteId + '"]'
)
.parentNode.classList.add("hide");
}
jQuery("#confirmAppModal").modal("hide");
jQuery("#thankyouModal").modal("show");
});
} 
};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_confirm_appointment");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function rejectAppointment(AppuntamentoPazienteId, ClinicaId, message){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var appObj={
Appuntamento: {
AppuntamentoPazienteId: AppuntamentoPazienteId,
ClinicaId: ClinicaId,
CausaleAnnullamentoDescrizione: message,
},
};
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: appObj,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
updateCache().then(function (){
if(document.querySelector('.confirm[data-id="' + AppuntamentoPazienteId + '"]'
)!=null
){
document
.querySelector('.confirm[data-id="' + AppuntamentoPazienteId + '"]'
)
.parentNode.classList.add("hide");
document
.querySelector('.reject[data-id="' + AppuntamentoPazienteId + '"]'
)
.parentNode.classList.add("hide");
}
jQuery("#rejectAppModal").modal("hide");
jQuery("#thankyouModal").modal("show");
});
}};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_reject_appointment");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function updateCache(){
document.body.classList.add("overlay-loading-show");
var updateUserDataStatus=updateUserData();
var checkDataChangesStatus=checkDataChanges();
return Promise.all([updateUserDataStatus, checkDataChangesStatus]).then(function (values){
updateAppointments();
document.body.classList.remove("overlay-loading-show");
}
);
}
function switchAccountUserData(){
userData=JSON.parse(sessionStorage.getItem("userData"));
var paziente=userData.PatientWebCard.Paziente;
if(currentUser!=currentParentId){
for (let i=0; i < userData.PatientWebCard.Correlati.length; i++){
if(userData.PatientWebCard.Correlati[i].PazienteCorrelatoId==currentUser
){
paziente=userData.PatientWebCard.Correlati[i];
}}
}
if(typeof paziente.PazienteCognome!=="undefined" &&
paziente.PazienteCognome!=null
){
document.getElementById("input-cognome").value =
paziente.PazienteCognome;
}
if(typeof paziente.PazienteNome!=="undefined" &&
paziente.PazienteNome!=null
){
document.getElementById("input-nome").value=paziente.PazienteNome;
}
if(typeof paziente.PazienteCodiceFiscale!=="undefined" &&
paziente.PazienteCodiceFiscale!=null
){
document.getElementById("input-cf").value =
paziente.PazienteCodiceFiscale;
}
if(typeof paziente.PazienteSesso!=="undefined" &&
paziente.PazienteSesso!=null
){
document.getElementById("input-sesso").value=paziente.PazienteSesso;
document.getElementById("input-sesso").innerHTML =
paziente.PazienteSesso;
}
if(typeof paziente.PazienteDataNascita!=="undefined" &&
paziente.PazienteDataNascita!=null
){
var originalDate=new Date(paziente.PazienteDataNascita);
var month=originalDate.getMonth() + 1;
month=month < 10 ? "0" + month:month;
var day=originalDate.getDate();
day=day < 10 ? "0" + day:day;
var date=originalDate.getFullYear() + "-" + month + "-" + day;
document.getElementById("input-datanascita").value=date;
}
if(typeof paziente.PazienteLocalitaNascita!=="undefined" &&
paziente.PazienteLocalitaNascita!=null
){
document.getElementById("input-luogonascita").value =
paziente.PazienteLocalitaNascita;
}
if(typeof paziente.PazienteProfessione!=="undefined" &&
paziente.PazienteProfessione!=null
){
document.getElementById("input-professione").value =
paziente.PazienteProfessione;
}
if(typeof paziente.PazienteNazione!=="undefined" &&
paziente.PazienteNazione!=null
){
document.getElementById("input-residenzafiscale").value =
paziente.PazienteNazione;
}
if(typeof paziente.NazioneDescrizione!=="undefined" &&
paziente.NazioneDescrizione!=null
){
document.getElementById("input-residenzafiscale").innerHTML =
paziente.NazioneDescrizione;
}
if(typeof paziente.PazienteProvinciaNascita!=="undefined" &&
paziente.PazienteProvinciaNascita!=null
){
document.getElementById("input-provincianascita").value =
paziente.PazienteProvinciaNascita;
document.getElementById("input-provincianascita").innerHTML =
getFullProvince(paziente.PazienteProvinciaNascita);
}
if(typeof paziente.TerzoPagatoreDescrizione!=="undefined" &&
paziente.TerzoPagatoreDescrizione!=null
){
resetAssicurazione();
}
var cancels=document.querySelectorAll(".cta-cancel");
for (let i=0; i < cancels.length; i++){
cancels[i].classList.add("hide");
}
if(typeof paziente.PazienteEmail!=="undefined" &&
paziente.PazienteEmail!=null
){
document.getElementById("input-mail").value=paziente.PazienteEmail;
}
if(typeof paziente.PazienteTelefono!=="undefined" &&
paziente.PazienteTelefono!=null
){
document.getElementById("input-telefono").value =
paziente.PazienteTelefono;
}
if(typeof paziente.PazienteIndirizzo!=="undefined" &&
paziente.PazienteIndirizzo!=null
){
document.getElementById("input-indirizzo").value =
paziente.PazienteIndirizzo;
}
if(typeof paziente.PazienteCap!=="undefined" &&
paziente.PazienteCap!=null
){
document.getElementById("input-cap").value=paziente.PazienteCap;
}
if(typeof paziente.PazienteLocalita!=="undefined" &&
paziente.PazienteLocalita!=null
){
document.getElementById("input-localita").value =
paziente.PazienteLocalita;
}
if(typeof paziente.PazientiPrivacy_1_Informativa!=="undefined"){
document.getElementById("input-privacy-1").checked =
paziente.PazientiPrivacy_1_Informativa;
}
if(typeof paziente.PazientiPrivacy_2_DirittiModifica!=="undefined"){
document.getElementById("input-privacy-2").checked =
paziente.PazientiPrivacy_2_DirittiModifica;
}
if(typeof paziente.PazientiPrivacy_3_Marketing!=="undefined"){
document.getElementById("input-privacy-3").checked =
paziente.PazientiPrivacy_3_Marketing;
}
if(typeof paziente.PazientiPrivacy_4_Profilazione!=="undefined"){
document.getElementById("input-privacy-4").checked =
paziente.PazientiPrivacy_4_Profilazione;
}
if(typeof paziente.PazientiPrivacy_5_FirmaGrafometrica!=="undefined"){
document.getElementById("input-privacy-5").checked =
paziente.PazientiPrivacy_5_FirmaGrafometrica;
}}
function updateUserData(){
return new Promise(function (resolve, reject){
let myDataJSON=JSON.stringify({
token: sessionStorage.getItem("access_token"),
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState!==4){
return;
}
if(this.status===200){
var response=xhttp.responseText;
response=JSON.parse(response);
sessionStorage.setItem("userData", JSON.stringify(response.Data));
sessionStorage.setItem("PublicWebMasterTables",
JSON.stringify(response.PublicWebMasterTables)
);
userData=JSON.parse(sessionStorage.getItem("userData"));
var paziente=userData.PatientWebCard.Paziente;
if(currentUser!=currentParentId){
for (
let i=0;
i < userData.PatientWebCard.Correlati.length;
i++
){
if(userData.PatientWebCard.Correlati[i].PazienteCorrelatoId==currentUser
){
paziente=userData.PatientWebCard.Correlati[i];
}}
}
if(typeof paziente.PazienteCognome!=="undefined" &&
paziente.PazienteCognome!=null
){
document.getElementById("input-cognome").value =
paziente.PazienteCognome;
}
if(typeof paziente.PazienteNome!=="undefined" &&
paziente.PazienteNome!=null
){
document.getElementById("input-nome").value =
paziente.PazienteNome;
}
if(typeof paziente.PazienteCodiceFiscale!=="undefined" &&
paziente.PazienteCodiceFiscale!=null
){
document.getElementById("input-cf").value =
paziente.PazienteCodiceFiscale;
}
if(typeof paziente.PazienteSesso!=="undefined" &&
paziente.PazienteSesso!=null
){
document.getElementById("input-sesso").value =
paziente.PazienteSesso;
document.getElementById("input-sesso").innerHTML =
paziente.PazienteSesso;
}
if(typeof paziente.PazienteDataNascita!=="undefined" &&
paziente.PazienteDataNascita!=null
){
var originalDate=new Date(paziente.PazienteDataNascita);
var month=originalDate.getMonth() + 1;
month=month < 10 ? "0" + month:month;
var day=originalDate.getDate();
day=day < 10 ? "0" + day:day;
var date=originalDate.getFullYear() + "-" + month + "-" + day;
document.getElementById("input-datanascita").value=date;
}
if(typeof paziente.PazienteLocalitaNascita!=="undefined" &&
paziente.PazienteLocalitaNascita!=null
){
document.getElementById("input-luogonascita").value =
paziente.PazienteLocalitaNascita;
}
if(typeof paziente.PazienteProfessione!=="undefined" &&
paziente.PazienteProfessione!=null
){
document.getElementById("input-professione").value =
paziente.PazienteProfessione;
}
if(typeof paziente.PazienteNazione!=="undefined" &&
paziente.PazienteNazione!=null
){
document.getElementById("input-residenzafiscale").value =
paziente.PazienteNazione;
}
if(typeof paziente.NazioneDescrizione!=="undefined" &&
paziente.NazioneDescrizione!=null
){
document.getElementById("input-residenzafiscale").innerHTML =
paziente.NazioneDescrizione;
}
if(typeof paziente.TerzoPagatoreDescrizione!=="undefined" &&
paziente.TerzoPagatoreDescrizione!=null
){
resetAssicurazione();
}
var cancels=document.querySelectorAll(".cta-cancel");
for (let i=0; i < cancels.length; i++){
cancels[i].classList.add("hide");
}
if(typeof paziente.PazienteEmail!=="undefined" &&
paziente.PazienteEmail!=null
){
document.getElementById("input-mail").value =
paziente.PazienteEmail;
}
if(typeof paziente.PazienteTelefono!=="undefined" &&
paziente.PazienteTelefono!=null
){
document.getElementById("input-telefono").value =
paziente.PazienteTelefono;
}
if(typeof paziente.PazienteIndirizzo!=="undefined" &&
paziente.PazienteIndirizzo!=null
){
document.getElementById("input-indirizzo").value =
paziente.PazienteIndirizzo;
}
if(typeof paziente.PazienteCap!=="undefined" &&
paziente.PazienteCap!=null
){
document.getElementById("input-cap").value=paziente.PazienteCap;
}
if(typeof paziente.PazienteLocalita!=="undefined" &&
paziente.PazienteLocalita!=null
){
document.getElementById("input-localita").value =
paziente.PazienteLocalita;
}
if(typeof paziente.PazientiPrivacy_1_Informativa!=="undefined"){
document.getElementById("input-privacy-1").checked =
paziente.PazientiPrivacy_1_Informativa;
}
if(typeof paziente.PazientiPrivacy_2_DirittiModifica!=="undefined"
){
document.getElementById("input-privacy-2").checked =
paziente.PazientiPrivacy_2_DirittiModifica;
}
if(typeof paziente.PazientiPrivacy_3_Marketing!=="undefined"){
document.getElementById("input-privacy-3").checked =
paziente.PazientiPrivacy_3_Marketing;
}
if(typeof paziente.PazientiPrivacy_4_Profilazione!=="undefined"
){
document.getElementById("input-privacy-4").checked =
paziente.PazientiPrivacy_4_Profilazione;
}
if(typeof paziente.PazientiPrivacy_5_FirmaGrafometrica!=="undefined"
){
document.getElementById("input-privacy-5").checked =
paziente.PazientiPrivacy_5_FirmaGrafometrica;
}
resolve(this.status);
}else{
reject(this.status);
}};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_get_card");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
}
function checkDataChanges(){
return new Promise(function (resolve, reject){
let myDataJSON=JSON.stringify({
token: sessionStorage.getItem("access_token"),
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState!==4){
return;
}
if(this.status===200){
sessionStorage.setItem("temp", xhttp.responseText);
checkDataAnamnesi();
updateMessages();
resolve(this.status);
}else{
reject(this.status);
}};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_get_patient_temp");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
}
function updateAppointments(){
var app=document.querySelector("#app-1 .appuntamenti-container .container-fluid"
);
var appStorico=document.querySelector("#app-2 .appuntamenti-container .container-fluid"
);
var appuntamenti=userData.PatientWebCard.Appuntamenti;
let oggi=new Date();
if(window.AREA_PAZIENTI&&window.AREA_PAZIENTI.today){
oggi=new Date(window.AREA_PAZIENTI.today);
}
var appuntamentiPassati=appuntamenti
.filter(function (app){
return new Date(app.DataAppuntamento) < oggi;
})
.sort(confrontoDecrescente);
var appuntamentiFuturi=appuntamenti
.filter(function (app){
return new Date(app.DataAppuntamento) >=oggi;
})
.sort(confrontoAscendente);
appuntamenti=appuntamentiPassati.concat(appuntamentiFuturi);
var template=document.querySelector(".appuntamenti-template");
var latests=[];
var html="";
var htmlStorico="";
var countLatests=0;
var oggiFlat=new Date(oggi.getTime());
oggiFlat.setHours(0, 0, 0, 0);
for (let i=0; i < appuntamenti.length; i++){
if(currentUser==appuntamenti[i].PazienteId ||
currentUser==appuntamenti[i].ParentId
){
if(![3, 6].includes(appuntamenti[i].StatoAppuntamentoPazienteId)){
temp=template.cloneNode(true);
var originalDate=new Date(appuntamenti[i].DataAppuntamento);
var copiedDate=new Date(originalDate.getTime());
var partiOrario=appuntamenti[i].OraInizioAppuntamento.split(":");
var ore=parseInt(partiOrario[0], 10);
var minuti=parseInt(partiOrario[1], 10);
var secondi=parseInt(partiOrario[2], 10);
originalDate.setHours(ore, minuti, secondi);
var oraInizio=appuntamenti[i].OraInizioAppuntamento.substring(0,
appuntamenti[i].OraInizioAppuntamento.length - 3
);
var oraFine=appuntamenti[i].OraFineAppuntamento.substring(0,
appuntamenti[i].OraFineAppuntamento.length - 3
);
var operatori=[];
for (
let e=0;
e < appuntamenti[i].AppuntamentiOperatori.length;
e++
){
var prefix=e > 0 ? "<span>":"";
var tipoOperatore =
appuntamenti[i].AppuntamentiOperatori[e]
.TipoOperatoreDescrizione;
tipoOperatore =
tipoOperatore.toLowerCase()=="tutor"
? "Resp. assistenza pazienti"
: tipoOperatore;
var suffix=e > 0 ? "</span>":"";
operatori.push(prefix +
appuntamenti[i].AppuntamentiOperatori[e]
.OperatoreDescrizione +
" - " +
tipoOperatore +
suffix
);
}
var tipoAppuntamento=appuntamenti[i].TipoAppuntamentoDescrizione;
tipoAppuntamento =
tipoAppuntamento.toLowerCase()=="esecuzione"
? "Trattamento"
: tipoAppuntamento;
var clinicAddress =
appuntamenti[i].ClinicaIndirizzo +
", " +
appuntamenti[i].ClinicaCap +
" " +
appuntamenti[i].ClinicaLocalita +
" (" +
appuntamenti[i].ClinicaProvincia +
")";
var mapLink =
"https://www.google.com/maps/place/" +
clinicAddress.split(" ").join("+");
temp.querySelector("h5").innerHTML=tipoAppuntamento;
temp.querySelector(".dayweek").innerHTML=giornoSettimanaItaliano(
originalDate.getDay()
);
temp.querySelector(".daynum").innerHTML=originalDate.getDate();
temp.querySelector(".daymonth").innerHTML=meseItaliano(
originalDate.getMonth()
);
temp.querySelector(".dayyear").innerHTML =
originalDate.getFullYear();
temp.querySelector("u").innerHTML=appuntamenti[i].ClinicaAlias
? '<a href="' +
mapLink +
'" target="_blank">' +
appuntamenti[i].ClinicaAlias +
"</a>"
: '<a href="' +
mapLink +
'" target="_blank">' +
appuntamenti[i].ClinicaDescrizione +
"</a>";
temp.querySelector(".address").innerHTML =
appuntamenti[i].ClinicaIndirizzo;
temp.querySelector(".doct").innerHTML=operatori.join("<br>");
temp.querySelector(".range").innerHTML =
oraInizio + " - " + oraFine;
temp.querySelector(".person").innerHTML =
appuntamenti[i].PazienteNome +
" <span>" +
appuntamenti[i].PazienteCognome +
"</span>";
temp
.querySelector(".person")
.setAttribute("data-account", appuntamenti[i].PazienteId);
temp
.querySelector(".calendar")
.setAttribute("data-start", originalDate.toISOString());
var partiOrario=appuntamenti[i].OraFineAppuntamento.split(":");
var ore=parseInt(partiOrario[0], 10);
var minuti=parseInt(partiOrario[1], 10);
var secondi=parseInt(partiOrario[2], 10);
originalDate.setHours(ore, minuti, secondi);
temp
.querySelector(".calendar")
.setAttribute("data-end", originalDate.toISOString());
temp
.querySelector(".calendar")
.setAttribute("data-location",
appuntamenti[i].ClinicaIndirizzo +
" - " +
appuntamenti[i].ClinicaLocalita +
" (" +
appuntamenti[i].ClinicaProvincia +
")"
);
temp
.querySelector(".calendar")
.setAttribute("data-alias", appuntamenti[i].ClinicaAlias);
temp
.querySelector(".calendar")
.setAttribute("data-title", tipoAppuntamento);
var confirmButton=temp.querySelector(".confirm");
var rejectButton=temp.querySelector(".reject");
var confirmTooltip=temp.querySelector(".confirm-tooltip");
var rejectTooltip=temp.querySelector(".reject-tooltip");
confirmButton.setAttribute("data-id",
appuntamenti[i].AppuntamentoPazienteId
);
confirmButton.setAttribute("data-clinicaid",
appuntamenti[i].ClinicaId
);
var millisecondsDiff=copiedDate.getTime() - oggiFlat.getTime();
const daysDiff=Math.round(millisecondsDiff / (24 * 60 * 60 * 1000)
);
if(daysDiff > 5){
confirmButton.classList.add("disabled");
if(confirmTooltip){
confirmTooltip.classList.add("disabled");
}}
rejectButton.setAttribute("data-id",
appuntamenti[i].AppuntamentoPazienteId
);
rejectButton.setAttribute("data-clinicaid",
appuntamenti[i].ClinicaId
);
var statoAppuntamento =
appuntamenti[i].StatoAppuntamentoDescrizione;
if(appuntamenti[i].StatoAppuntamentoPazienteId===2){
statoAppuntamento="Prenotato";
}
confirmButton.classList.remove("hide");
rejectButton.classList.remove("hide");
var typeApp="tooltip-holder reservation-tooltip icon-input-error";
if([1, 5, 7].includes(appuntamenti[i].StatoAppuntamentoPazienteId)
){
typeApp="icon-Input-ok";
temp.querySelector(".paybill").classList.add("is-ok");
confirmButton.parentNode.classList.add("hide");
rejectButton.parentNode.classList.add("hide");
}else if(appuntamenti[i].ToReview){
statoAppuntamento="Riprogrammato";
confirmButton.parentNode.classList.add("hide");
rejectButton.parentNode.classList.add("hide");
}
temp.querySelector(".paybill").innerHTML =
'<span class="' + typeApp + '"></span> ' + statoAppuntamento;
if(oggi <=originalDate &&
[1, 2].includes(appuntamenti[i].StatoAppuntamentoPazienteId)
){
html +=temp.innerHTML;
latests.push({
html: temp.innerHTML,
DataAppuntamento: appuntamenti[i].DataAppuntamento,
});
countLatests++;
}else if(oggi > originalDate){
htmlStorico +=temp.innerHTML;
}
temp.querySelector(".paybill").classList.remove("is-ok");
}}
}
latests.sort((a, b)=> {
let dateA=new Date(a.DataAppuntamento);
let dateB=new Date(b.DataAppuntamento);
return dateA - dateB;
});
latests=latests.slice(0, 3);
var checkinInfo=document.createElement("a");
checkinInfo.href="#";
checkinInfo.classList.add("cta-checkin");
checkinInfo.style.color="#215682";
checkinInfo.innerText="Scopri come fare il check-in";
checkinInfo.addEventListener("click", function (event){
event.preventDefault();
jQuery("#checkinModal").modal("show");
});
var checkinInfoColumn=document.createElement("div");
checkinInfoColumn.classList.add("col-12");
checkinInfoColumn.append(checkinInfo);
var checkinInfoRow=document.createElement("div");
checkinInfoRow.classList.add("row");
checkinInfoRow.classList.add("is-checkin-info");
checkinInfoRow.append(checkinInfoColumn);
app.innerHTML=html;
app.prepend(checkinInfoRow);
appStorico.innerHTML=htmlStorico;
var latests_html="";
for (let i=0; i < latests.length; i++){
latests_html +=latests[i].html;
}
document.querySelector("#home .appuntamenti-container .container-fluid"
).innerHTML =
'<div class="row"><div class="col-12 px-0"><h3 class="mb-0">Prossimi appuntamenti</h3></div></div>' +
latests_html;
if(latests.length==0){
document.querySelector(".next-app").classList.add("hide");
}else{
document.querySelector(".next-app").classList.remove("hide");
}
var calendars=document.querySelectorAll(".calendar");
for (let i=0; i < calendars.length; i++){
calendars[i].addEventListener("click", function (e){
var start=new Date(this.getAttribute("data-start"));
var end=new Date(this.getAttribute("data-end"));
var location=this.getAttribute("data-location");
var alias=this.getAttribute("data-alias");
var title="Visita odontoiatrica DentalPro " + alias;
var anno=start.getFullYear();
var mese=start.getMonth() + 1;
var giorno=start.getDate();
var ore=start.getHours();
var minuti=start.getMinutes();
mese=mese < 10 ? "0" + mese:mese;
giorno=giorno < 10 ? "0" + giorno:giorno;
ore=ore < 10 ? "0" + ore:ore;
minuti=minuti < 10 ? "0" + minuti:minuti;
var dataFormattata=giorno + "/" + mese + "/" + anno;
var minutiFormattati=ore + ":" + minuti;
var description =
"Grazie per la tua prenotazione! DentalPro " +
alias +
" ti aspetta il giorno " +
dataFormattata +
" alle ore " +
minutiFormattati +
". Grazie!";
document
.querySelector("#calendarModal .save-ios")
.addEventListener("click", function (e){
downloadICS({
uid: generateUID(),
dtstamp: new Date(),
start: start,
end: end,
summary: title,
description: description,
location: location,
});
e.preventDefault();
});
document
.querySelector("#calendarModal .save-google")
.setAttribute("href",
"https://www.google.com/calendar/render?action=TEMPLATE&text=" +
encodeURIComponent(title) +
"&dates=" +
formatDateToICS(start) +
"/" +
formatDateToICS(end) +
"&details=" +
encodeURIComponent(description) +
"&location=" +
encodeURIComponent(location) +
"&sf=true&output=xml"
);
document
.querySelector("#calendarModal .save-outlook")
.setAttribute("href",
"https://outlook.office.com/calendar/action/compose?rru=addevent&subject=" +
encodeURIComponent(title) +
"&startdt=" +
start.toISOString() +
"&enddt=" +
end.toISOString() +
"&body=" +
encodeURIComponent(description) +
"&location=" +
encodeURIComponent(location)
);
jQuery("#calendarModal").modal("show");
e.preventDefault();
});
}
setTimeout(function (){
document.getElementById("app-related").click();
if(document.getElementById("app-related").checked){
document.getElementById("app-related").click();
}
document.getElementById("app-related-history").click();
if(document.getElementById("app-related-history").checked){
document.getElementById("app-related-history").click();
}}, 200);
var confirmApp=document.querySelectorAll(".appuntamenti-container .confirm"
);
for (let i=0; i < confirmApp.length; i++){
confirmApp[i].addEventListener("click", function (e){
if(this.classList.contains("disabled")){
e.preventDefault();
return;
}
var dataid=this.getAttribute("data-id");
var clinicaid=this.getAttribute("data-clinicaid");
jQuery("#confirmAppModal").modal("show");
document
.querySelector('#confirmAppModal button[data-dismiss="confirm-data-modal"]'
)
.setAttribute("data-id", dataid);
document
.querySelector('#confirmAppModal button[data-dismiss="confirm-data-modal"]'
)
.setAttribute("data-clinicaid", clinicaid);
e.preventDefault();
});
}
var rejectApp=document.querySelectorAll(".appuntamenti-container .reject"
);
for (let i=0; i < rejectApp.length; i++){
rejectApp[i].addEventListener("click", function (e){
var dataid=this.getAttribute("data-id");
var clinicaid=this.getAttribute("data-clinicaid");
jQuery("#rejectAppModal").modal("show");
document
.querySelector('#rejectAppModal button[data-dismiss="reject-data-modal"]'
)
.setAttribute("data-id", dataid);
document
.querySelector('#rejectAppModal button[data-dismiss="reject-data-modal"]'
)
.setAttribute("data-clinicaid", clinicaid);
e.preventDefault();
});
}}
function updateBar(name){
var n=name.querySelector(".account-name:not(.d-none)").innerHTML;
document.querySelector("#home .intro h1").innerHTML=name.innerHTML;
document.querySelector("#header .account-name").innerHTML=n;
document.querySelector(".mobile-current-name").innerHTML=n;
var accountlinks=document.querySelectorAll("a[data-account]");
for (let i=0; i < accountlinks.length; i++){
if(accountlinks[i].getAttribute("data-master")!=null){
}
if(accountlinks[i].getAttribute("data-account")==currentUser &&
!accountlinks[i].classList.contains("hide")
){
accountlinks[i].classList.add("hide");
}else{
accountlinks[i].classList.remove("hide");
}}
}
function updateDots(){
var dotAccounts=document.querySelectorAll("[data-account]");
for (let i=0; i < dotAccounts.length; i++){
dotAccounts[i].classList.add("dot-" + getPazienteIndex(dotAccounts[i].getAttribute("data-account"))
);
}}
function compileAnamnesi(){
var questions=master.Anamnesi.SurveyQuestions;
var html="";
document
.querySelector("#currentstep-p")
.setAttribute("max", questions.length);
document.querySelector(".maxquestions").innerHTML=questions.length;
for (let i=0; i < questions.length; i++){
var qnum=i + 1;
var hide=qnum==1 ? "":"hide";
var note=false;
html +=
'<div class="col-12 step-' +
qnum +
" " +
hide +
'" data-required="' +
questions[i].RispostaObbligatoria +
'">';
html +="<h6>" + questions[i].DomandaDescrizione + "</h6>";
for (let x=0; x < questions[i].SurveyAnswers.length; x++){
if(questions[i].SurveyAnswers[x].RispostaDescrizione!="campo note"
){
if(questions[i].RispostaMultipla){
html +='<div class="form-check">';
html +=
'<input class="form-check-input" type="checkbox" value="' +
questions[i].SurveyAnswers[x].RispostaId +
'" name="input-anamnesi-' +
qnum +
'" id="input-anamnesi-' +
qnum +
"-" +
x +
'">';
html +=
'<label class="form-check-label" for="input-anamnesi-' +
qnum +
"-" +
x +
'">' +
questions[i].SurveyAnswers[x].RispostaDescrizione +
"</label>";
html +="</div>";
}else{
html +='<div class="form-check">';
html +=
'<input class="form-check-input" type="radio" value="' +
questions[i].SurveyAnswers[x].RispostaId +
'" name="input-anamnesi-' +
qnum +
'" id="input-anamnesi-' +
qnum +
"-" +
x +
'">';
html +=
'<label class="form-check-label" for="input-anamnesi-' +
qnum +
"-" +
x +
'">' +
questions[i].SurveyAnswers[x].RispostaDescrizione +
"</label>";
html +="</div>";
}}else{
note=questions[i].SurveyAnswers[x].RispostaId;
}}
if(note){
html +=
'<input type="text" id="input-anamnesi-' +
qnum +
'" data-id="' +
note +
'">';
}else{
html +=
'<input type="text" id="input-anamnesi-' +
qnum +
'" placeholder="Note">';
}
html +="</div>";
}
document.querySelector("#dati-3 .steps").innerHTML=html;
}
function updateProgress(){
var user=getCurrentData();
var questionari=false;
var currentProgressStep=0;
var progressStep=[];
var progress=document.querySelectorAll(".step-box .stepme");
for (let i=0; i < progress.length; i++){
progress[i].classList.remove("show");
}
for (let i=0; i < userData.PatientWebCard.Questionari.length; i++){
if(user.PazienteId==userData.PatientWebCard.Questionari[i].PazienteId
){
questionari=true;
}}
if(!questionari){
progressStep.push("dati-anamnesi");
currentProgressStep=4;
}
if(!user.PazientiPrivacy_1_Informativa ||
!user.PazientiPrivacy_2_DirittiModifica
){
progressStep.push("dati-privacy");
currentProgressStep=3;
}
if(document.getElementById("input-telefono").value=="" ||
document.getElementById("input-mail").value=="" ||
document.getElementById("input-indirizzo").value=="" ||
document.getElementById("input-localita").value=="" ||
document.getElementById("input-cap").value==""
){
progressStep.push("dati-contatti");
currentProgressStep=2;
}
if(document.getElementById("input-cognome").value=="" ||
document.getElementById("input-nome").value=="" ||
document.getElementById("input-sesso").value=="" ||
document.getElementById("input-cf").value=="" ||
document.getElementById("input-residenzafiscale").value=="" ||
document.getElementById("input-datanascita").value=="" ||
document.getElementById("input-luogonascita").value==""
){
progressStep.push("dati-generalita");
currentProgressStep=1;
}
if(currentProgressStep > 0&&currentProgressStep <=4&&!isProspect){
var accStep=document.querySelectorAll(".account-progress .steps .step"
);
for (let i=0; i < accStep.length; i++){
accStep[i].classList.remove("active");
}
for (let i=0; i < progressStep.length; i++){
if(document.getElementById(progressStep[i]).querySelector("h3 span")!=null
){
document
.getElementById(progressStep[i])
.querySelector("h3 span")
.remove();
}}
document
.querySelector(".account-progress-container")
.classList.remove("hide");
var stepMiss=progressStep.length;
document.querySelector(".account-progress .num-actions").innerHTML =
stepMiss;
stepMiss=4 - stepMiss;
for (let i=0; i < stepMiss; i++){
accStep[i].classList.add("active");
}
for (let i=0; i < progressStep.length; i++){
switch (progressStep[i]){
case "dati-anamnesi":
document.querySelector(".step-box .step-4").classList.add("show");
break;
case "dati-privacy":
document.querySelector(".step-box .step-3").classList.add("show");
break;
case "dati-contatti":
document.querySelector(".step-box .step-2").classList.add("show");
break;
case "dati-generalita":
document.querySelector(".step-box .step-1").classList.add("show");
break;
}}
}else{
document
.querySelector(".account-progress-container")
.classList.add("hide");
}
var tickAnagrafica=document.querySelectorAll("#datiTabs .nav-link");
if(!progressStep.includes("dati-anamnesi")){
if(tickAnagrafica[3].querySelector("h3 span")==null){
tickAnagrafica[3].querySelector("h3").innerHTML =
'<span class="icon-Input-ok"></span> ' +
tickAnagrafica[3].innerText;
}}
if(!progressStep.includes("dati-privacy")){
if(tickAnagrafica[2].querySelector("h3 span")==null){
tickAnagrafica[2].querySelector("h3").innerHTML =
'<span class="icon-Input-ok"></span> ' +
tickAnagrafica[2].innerText;
}}
if(!progressStep.includes("dati-contatti")){
if(tickAnagrafica[1].querySelector("h3 span")==null){
tickAnagrafica[1].querySelector("h3").innerHTML =
'<span class="icon-Input-ok"></span> ' +
tickAnagrafica[1].innerText;
}}
if(!progressStep.includes("dati-generalita")){
if(tickAnagrafica[0].querySelector("h3 span")==null){
tickAnagrafica[0].querySelector("h3").innerHTML =
'<span class="icon-Input-ok"></span> ' +
tickAnagrafica[0].innerText;
}}
}
function switchAccount(userid, skipcheck=false){
currentUser=userid;
currentParentId=userData.PatientWebCard.Paziente.ParentId;
currentRelUser=null;
for (let i=0; i < userData.PatientWebCard.Correlati.length; i++){
if(userData.PatientWebCard.Correlati[i].PazienteCorrelatoId==userid
){
currentRelUser=userData.PatientWebCard.Correlati[i];
currentParentId=userData.PatientWebCard.Correlati[i].ParentId;
}}
var appFilters=document.querySelectorAll(".app-filter");
for (let i=0; i < appFilters.length; i++){
if(currentRelUser){
appFilters[i].classList.add("hide");
}else{
appFilters[i].classList.remove("hide");
}}
var deleteAccount=document.querySelector(".delete-account");
if(currentRelUser){
deleteAccount.classList.add("hide");
}else{
deleteAccount.classList.remove("hide");
}
updateClinics();
updateDoctors();
updateDocuments();
updatePlans();
updateDati();
updateAppointments();
updateDots();
switchAccountUserData();
compileAnamnesi();
checkDataAnamnesi();
updateProgress();
updateMessages();
}
function getPazienteData(pazienteId){
if(pazienteId==userData.PatientWebCard.Paziente.PazienteId){
return userData.PatientWebCard.Paziente;
}
for (let i=0; i < userData.PatientWebCard.Correlati.length; i++){
if(pazienteId==userData.PatientWebCard.Correlati[i].PazienteCorrelatoId
){
return userData.PatientWebCard.Correlati[i];
}}
}
function getPazienteIndex(id){
if(id==userData.PatientWebCard.Paziente.PazienteId){
return 1;
}
for (let i=0; i < userData.PatientWebCard.Correlati.length; i++){
if(id==userData.PatientWebCard.Correlati[i].PazienteCorrelatoId){
return i + 2;
}}
}
function getCurrentData(){
var data =
currentRelUser!=null
? currentRelUser
: userData.PatientWebCard.Paziente;
if(Object.keys(data).length===0) return;
var required=[
"PazienteId",
"ParentId",
"ClinicaId",
"PazienteCognome",
"PazienteNome",
"PazienteIndirizzo",
"PazienteCap",
"PazienteLocalita",
"PazienteProvincia",
"PazienteCodiceFiscale",
"PazienteEmail",
"PazienteTelefono",
"PazienteSesso",
"PazienteDataNascita",
"PazienteLocalitaNascita",
"PazienteProvinciaNascita",
"PazienteProfessione",
"PazienteNazione",
"NazioneDescrizione",
"TerzoPagatoreDescrizione",
"PazientiPrivacy_1_Informativa",
"PazientiPrivacy_2_DirittiModifica",
"PazientiPrivacy_3_Marketing",
"PazientiPrivacy_4_Profilazione",
"PazientiPrivacy_5_FirmaGrafometrica",
"PazienteFondi",
];
for (let i=0; i < required.length; i++){
var req=required[i];
if(!data.hasOwnProperty(req)) data[req]=null;
}
return data;
}
function getCurrentTemp(){
var temp=JSON.parse(sessionStorage.getItem("temp"));
if(currentRelUser==null){
return temp==null
? userData.PatientWebCard
: temp.Data.PatientWebDataEntry;
}else{
if(typeof temp.Data.PatientWebDataEntry!=="undefined"){
for (
let i=0;
i < temp.Data.PatientWebDataEntry.Correlati.length;
i++
){
if(temp.Data.PatientWebDataEntry.Correlati[i].PazienteCorrelatoId==currentRelUser.PazienteId
){
return temp.Data.PatientWebDataEntry.Correlati[i];
}}
}else{
for (let i=0; i < userData.PatientWebCard.Correlati.length; i++){
if(userData.PatientWebCard.Correlati[i].PazienteCorrelatoId==currentRelUser.PazienteId
){
return userData.PatientWebCard.Correlati[i];
}}
}}
return null;
}
function giornoSettimanaItaliano(giorno){
const giorniItaliano=[
"Domenica",
"Lunedì",
"Martedì",
"Mercoledì",
"Giovedì",
"Venerdì",
"Sabato",
];
return giorniItaliano[giorno];
}
function meseItaliano(mese){
const mesiItaliano=[
"gennaio",
"febbraio",
"marzo",
"aprile",
"maggio",
"giugno",
"luglio",
"agosto",
"settembre",
"ottobre",
"novembre",
"dicembre",
];
return mesiItaliano[mese];
}
function submitAnamnesi(){
var grecaptcha_key=document
.getElementById("g-recaptcha")
.getAttribute("src")
.split("render=")[1];
grecaptcha.ready(function (){
grecaptcha
.execute(grecaptcha_key, { action: "submit" })
.then(function (token){
document.body.classList.add("overlay-loading-show");
var user=getCurrentData();
dataContent={
Questionario: {
PazienteId: user.PazienteId,
ClinicaId: user.ClinicaId,
QuestionarioNote: "",
Survey: {
OwnerId: 1,
FormularioId: master.Anamnesi.FormularioId,
FormularioCodice: master.Anamnesi.FormularioCodice,
FormularioDescrizione: master.Anamnesi.FormularioDescrizione,
TipoQuestionarioId: 1,
TemplateCodice: "ANAMNESI",
SurveyQuestions: [],
},
},
};
for (let i=0; i < master.Anamnesi.SurveyQuestions.length; i++){
var myAnswer={
OwnerId: 1,
FormularioId: master.Anamnesi.SurveyQuestions[i].FormularioId,
DomandaDescrizione:
master.Anamnesi.SurveyQuestions[i].DomandaDescrizione,
RispostaMultipla:
master.Anamnesi.SurveyQuestions[i].RispostaMultipla,
RispostaObbligatoria:
master.Anamnesi.SurveyQuestions[i].RispostaObbligatoria,
DomandaId: master.Anamnesi.SurveyQuestions[i].DomandaId,
DomandaOrderBy:
master.Anamnesi.SurveyQuestions[i].DomandaOrderBy,
SurveyAnswers: [],
};
var stepDiv=document.querySelector("#dati-3 .step-" + (i + 1));
var checkboxes=stepDiv.querySelectorAll('input[type="checkbox"]:checked, input[type="radio"]:checked'
);
var valoriSelezionati=[];
checkboxes.forEach(function (checkbox){
valoriSelezionati.push(checkbox.value);
});
if(valoriSelezionati.length==0){
valoriSelezionati.push(master.Anamnesi.SurveyQuestions[i].SurveyAnswers[0].RispostaId
);
}
for (
let x=0;
x < master.Anamnesi.SurveyQuestions[i].SurveyAnswers.length;
x++
){
let selected=false;
for (let y=0; y < valoriSelezionati.length; y++){
if(master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaId==valoriSelezionati[y] ||
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaDescrizione=="campo note"
){
selected=true;
}}
if(selected){
myAnswer.SurveyAnswers.push({
OwnerId: 1,
FormularioId:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.FormularioId,
DomandaId:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.DomandaId,
RispostaId:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaId,
RispostaDescrizione:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaDescrizione=="campo note"
? document.getElementById("input-anamnesi-" + (i + 1))
.value
: master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaDescrizione,
RispostaNoteObbligatorie:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaNoteObbligatorie,
RispostaFormatoId:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaFormatoId,
RispostaField:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaField,
RispostaFieldTrue:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaFieldTrue,
RispostaNotifica:
master.Anamnesi.SurveyQuestions[i].SurveyAnswers[x]
.RispostaNotifica,
Selected: selected,
SurveyAnswerNote: document.getElementById("input-anamnesi-" + (i + 1)
).value,
});
}}
dataContent.Questionario.Survey.SurveyQuestions.push(myAnswer);
}
let myDataJSON=JSON.stringify({
"g-recaptcha-response": token,
token: sessionStorage.getItem("access_token"),
data: dataContent,
});
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange=function (){
if(this.readyState==4&&this.status==200){
sessionStorage.setItem("temp", xhttp.responseText);
updateCache().then(function (){
checkDataAnamnesi();
resetAnagrafica();
updateProgress();
document.body.classList.remove("overlay-loading-show");
});
}};
let link=new URL(
document.getElementById("ajaxurl").getAttribute("href")
);
link.searchParams.set("action", "dp_save_anamnesi");
xhttp.open("POST", link, true);
xhttp.setRequestHeader("Content-type",
"application/json; charset=UTF-8"
);
xhttp.send(myDataJSON);
});
});
}
function checkDataAnamnesi(){
var temp=sessionStorage.getItem("temp");
if(temp!=null){
temp=JSON.parse(temp);
if(typeof temp.Data==="undefined") window.location.reload();
document
.querySelector("#dati-3 .anamnesi-pending")
.classList.remove("hide");
document.querySelector("#dati-3 .anamnesi-ok").classList.add("hide");
document
.querySelector("#dati-3 .anamnesi-preview")
.classList.add("hide");
document.querySelector("#dati-3 .update-msg").classList.remove("is-ok");
document
.querySelector("#dati-3 .update-msg")
.classList.remove("is-expired");
if(typeof temp.Data.PatientWebDataEntry!=="undefined" &&
typeof temp.Data.PatientWebDataEntry.Anamnesi!=="undefined" &&
temp.Data.PatientWebDataEntry.Anamnesi.SurveyQuestions.length &&
currentUser==currentParentId
){
document
.querySelector(".account-progress-container")
.classList.add("hide");
document.querySelector("#dati-anamnesi h3").innerHTML =
'<span class="icon-Input-ok"></span> Anamnesi';
document
.querySelector("#dati-3 .anamnesi-pending")
.classList.add("hide");
document
.querySelector("#dati-3 .anamnesi-ok")
.classList.remove("hide");
document.querySelector("#dati-3 .update-msg").classList.add("is-ok");
var previewHtml="";
var questions =
temp.Data.PatientWebDataEntry.Anamnesi.SurveyQuestions;
for (let i=0; i < questions.length; i++){
if(questions[i].SurveyAnswers.length){
var question=questions[i].DomandaDescrizione;
previewHtml +="<h6>" + (i + 1) + ". " + question + "</h6>";
for (let e=0; e < questions[i].SurveyAnswers.length; e++){
if(questions[i].SurveyAnswers[e].Selected){
var answer =
questions[i].SurveyAnswers[e].RispostaDescrizione;
var answerNote =
questions[i].SurveyAnswers[e].SurveyAnswerNote;
if(answerNote&&answerNote!=""){
previewHtml +="<p>" + answerNote + "</p>";
}else{
previewHtml +="<p>" + answer + "</p>";
}}
}}
}
document.querySelector("#dati-3 .anamnesi-preview").innerHTML =
previewHtml;
document
.querySelector("#dati-3 .anamnesi-preview")
.classList.remove("hide");
}
var newAnamnesiLink=document.querySelectorAll("#dati-3 .new");
for (let i=0; i < newAnamnesiLink.length; i++){
newAnamnesiLink[i].addEventListener("click", function (e){
this.parentNode.parentNode.classList.add("hide");
document.querySelector("#dati-3 .steps").classList.remove("hide");
document
.querySelector("#dati-3 .anamnesi-teaser")
.classList.remove("hide");
document
.querySelector("#dati-3 .anamnesi-actions")
.classList.remove("hide");
document
.querySelector("#dati-3 .cta-cancel")
.classList.remove("hide");
document
.querySelector("#dati-3 .anamnesi-preview")
.classList.add("hide");
document
.querySelector("#dati-3 .cta")
.setAttribute("data-current", 1);
document.querySelector("#currentstep-d").innerHTML=1;
document.querySelector("#currentstep-p").value=1;
e.preventDefault();
});
}
resetAnagrafica();
}}
function resetAnagrafica(){
var user=getCurrentData();
updateDati();
document.querySelector(".edit-data").classList.remove("hide");
document.querySelector(".edit-contacts").classList.remove("hide");
document.querySelector(".edit-privacy").classList.remove("hide");
document.querySelector(".save-data").classList.add("hide");
document.querySelector(".save-contacts").classList.add("hide");
document.querySelector(".save-privacy").classList.add("hide");
document.querySelector("#dati-4 .text-show").classList.add("disabled");
var inputs=document.querySelectorAll("#dati-4 .form-check-input");
for (let i=0; i < inputs.length; i++){
inputs[i].setAttribute("disabled", true);
}
var cancels=document.querySelectorAll(".cta-cancel");
for (let i=0; i < cancels.length; i++){
cancels[i].classList.add("hide");
}
document.querySelector("#dati-3 .steps").classList.add("hide");
document.querySelector("#dati-3 .anamnesi-actions").classList.add("hide");
document.querySelector("#dati-3 .anamnesi-teaser").classList.add("hide");
document.querySelector("#dati-3 .back-plans").classList.add("hide");
document.querySelector("#dati-3 .anamnesi-new").classList.remove("hide");
document
.querySelector("#dati-3 .anamnesi-preview")
.classList.remove("hide");
document.querySelector("#dati-3 .cta").setAttribute("data-current", 1);
document.querySelector("#currentstep-d").innerHTML=1;
document.querySelector("#currentstep-p").value=1;
document
.querySelector("#dati-3 .anamnesi-new p")
.classList.remove("hide");
compileAnamnesi();
document.querySelector(".last-anamnesi").classList.add("hide");
document.querySelector(".anamnesi-new").classList.remove("hide");
document.querySelector(".anamnesi-update").classList.add("hide");
document.querySelector(".anamnesi-expired").classList.add("hide");
if(userData.PatientWebCard.Questionari.length){
var qfound=false;
let recentDate=new Date(0);
for (let i=0; i < userData.PatientWebCard.Questionari.length; i++){
if(user.PazienteId==userData.PatientWebCard.Questionari[i].PazienteId
){
qfound=true;
let dataCorrente=new Date(
userData.PatientWebCard.Questionari[i].DataQuestionario
);
if(dataCorrente > recentDate){
recentDate=dataCorrente;
}}
}
if(qfound){
let giorno=recentDate.getDate().toString().padStart(2, "0");
let mese=(recentDate.getMonth() + 1).toString().padStart(2, "0");
let anno=recentDate.getFullYear().toString().substr(-2);
let dataFormattata=`${giorno}/${mese}/${anno}`;
document.querySelector(".last-anamnesi span").innerHTML =
dataFormattata;
document
.querySelector("#dati-3 .anamnesi-new p")
.classList.add("hide");
document
.querySelector("#dati-3 .anamnesi-pending")
.classList.add("hide");
document.querySelector(".anamnesi-new").classList.add("hide");
let dataCorrente=new Date();
let differenzaInMillisecondi =
dataCorrente.getTime() - recentDate.getTime();
let seiMesiInMillisecondi=6 * 30 * 24 * 60 * 60 * 1000;
if(differenzaInMillisecondi >=seiMesiInMillisecondi){
document.querySelector("#dati-3 .anamnesi-ok").innerHTML =
'<span class="tooltip-holder reservation-tooltip icon-input-error"></span> ' +
document.querySelector(".last-anamnesi").innerHTML;
document
.querySelector("#dati-3 .update-msg")
.classList.add("is-expired");
document
.querySelector(".anamnesi-expired")
.classList.remove("hide");
}else{
document.querySelector("#dati-3 .anamnesi-ok").innerHTML =
'<span class="icon-Input-ok"></span> ' +
document.querySelector(".last-anamnesi").innerHTML;
document
.querySelector("#dati-3 .update-msg")
.classList.add("is-ok");
document.querySelector(".anamnesi-update").classList.remove("hide");
}
document
.querySelector("#dati-3 .anamnesi-ok")
.classList.remove("hide");
}}
selectSearch();
/*var temp=sessionStorage.getItem('temp');
if(temp!=null){
temp=JSON.parse(temp);
if(temp.Data.EvodentNotifications){
for(let i=0; i<temp.Data.EvodentNotifications.length; i++){
if(user.PazienteId==temp.Data.EvodentNotifications[i].PazienteId&&temp.Data.EvodentNotifications[i].Message.toLowerCase()=='anamnesi aggiornata'){
var dateString=temp.Data.EvodentNotifications[i].Updated;
var isoStringWithoutOffset=dateString.slice(0, -6);
var offsetString=dateString.slice(-6);
var offsetHours=parseInt(offsetString.slice(0, 3), 10);
var offsetMinutes=parseInt(offsetString.slice(4), 10);
var dateObject=new Date(isoStringWithoutOffset);
dateObject.setHours(dateObject.getHours() - offsetHours);
dateObject.setMinutes(dateObject.getMinutes() - offsetMinutes);
if(userData.PatientWebCard.Questionari){
var questionari=userData.PatientWebCard.Questionari;
questionari.sort(function(a, b){
return new Date(b.DataQuestionario) - new Date(a.DataQuestionario);
});
var recentQuestionario=new Date(questionari[0].DataQuestionario);
}else{
var recentQuestionario=new Date("1990-01-01");
}
if(recentQuestionario < dateObject){
document.querySelector('.anamnesi-new').classList.add('hide');
document.querySelector('.anamnesi-update').classList.add('hide');
document.querySelector('.anamnesi-expired').classList.add('hide');
var day=dateObject.getDate();
var month=dateObject.getMonth() + 1;
var year=dateObject.getFullYear().toString().substr(-2);
if(day < 10){
day='0' + day;
}
if(month < 10){
month='0' + month;
}
var formattedDate=day + '/' + month + '/' + year;
document.querySelector('.anamnesi-ok .latest-anamnesi-date').innerHTML=formattedDate;
}}
}}
}*/
}
function getUserCliniche(){
if(typeof userData.PatientWebCard.Cliniche!=="undefined"){
var cliniche=userData.PatientWebCard.Cliniche;
var masterCliniche=master.Cliniche;
for (let i=0; i < cliniche.length; i++){
for (let e=0; e < masterCliniche.length; e++){
if(cliniche[i].ClinicaId==masterCliniche[e].ClinicaId){
cliniche[i]=masterCliniche[e];
}}
}
return cliniche;
}
return [];
}
function getClinica(id){
var cliniche=master.Cliniche;
for (let i=0; i < cliniche.length; i++){
if(cliniche[i].ClinicaId==id){
return cliniche[i];
}}
return false;
}
function dashboardInitMap(lat=null, lng=null){
const mapStyle=[
{
featureType: "water",
elementType: "geometry",
stylers: [
{
color: "#193341",
},
],
},
{
featureType: "landscape",
elementType: "geometry",
stylers: [
{
color: "#2c5a71",
},
],
},
{
featureType: "road",
elementType: "geometry",
stylers: [
{
color: "#29768a",
},
{
lightness: -37,
},
],
},
{
featureType: "poi",
elementType: "geometry",
stylers: [
{
color: "#406d80",
},
],
},
{
featureType: "transit",
elementType: "geometry",
stylers: [
{
color: "#406d80",
},
],
},
{
elementType: "labels.text.stroke",
stylers: [
{
visibility: "on",
},
{
color: "#3e606f",
},
{
weight: 2,
},
{
gamma: 0.84,
},
],
},
{
elementType: "labels.text.fill",
stylers: [
{
color: "#ffffff",
},
],
},
{
featureType: "administrative",
elementType: "geometry",
stylers: [
{
weight: 0.6,
},
{
color: "#1a3541",
},
],
},
{
elementType: "labels.icon",
stylers: [
{
visibility: "off",
},
],
},
{
featureType: "poi.park",
elementType: "geometry",
stylers: [
{
color: "#2c5a71",
},
],
},
];
var svg=[
'<?xml version="1.0"?>',
'<svg width="26" height="31" viewBox="0 0 26 31" fill="none" xmlns="http://www.w3.org/2000/svg">',
'<path d="M25.2329 12.6165C25.2329 22.4293 12.6165 30.8402 12.6165 30.8402C12.6165 30.8402 0 22.4293 0 12.6165C4.98607e-08 9.27036 1.32923 6.06132 3.69527 3.69527C6.06132 1.32923 9.27036 0 12.6165 0C15.9625 0 19.1716 1.32923 21.5376 3.69527C23.9037 6.06132 25.2329 9.27036 25.2329 12.6165Z" fill="#79E2D9"/>',
'<path d="M12.6166 16.822C14.9392 16.822 16.8221 14.9391 16.8221 12.6165C16.8221 10.2939 14.9392 8.41104 12.6166 8.41104C10.294 8.41104 8.41113 10.2939 8.41113 12.6165C8.41113 14.9391 10.294 16.822 12.6166 16.822Z" fill="#215682"/>',
"</svg>",
].join("\n");
var mapOptions={
zoom: 6,
center: { lat: 42.655583, lng: 12.846389 },
mapTypeId: "myStyle",
fullscreenControl: true,
mapTypeControl: false,
streetViewControl: false,
};
if(lat!=null&&lng!=null){
mapOptions.zoom=9;
mapOptions.center={ lat: lat, lng: lng };}
var map=new google.maps.Map(document.querySelector(".map-container"),
mapOptions
);
map.mapTypes.set("myStyle",
new google.maps.StyledMapType(mapStyle, { name: "Map Style" })
);
if(lat!=null&&lng!=null){
var marker=new google.maps.Marker({
position: { lat: parseFloat(lat), lng: parseFloat(lng) },
map: map,
icon: {
url: "data:image/svg+xml;charset=UTF-8," + encodeURIComponent(svg),
},
});
}}
function convertCoordinate(coordStr){
var parts=coordStr.match(/[0-9.]+/g);
var degrees=parseFloat(parts[0]);
var minutes=parseFloat(parts[1]);
var seconds=parseFloat(parts[2]);
var numericValue=degrees + minutes / 60 + seconds / 3600;
if(coordStr.includes("S")||coordStr.includes("W")){
numericValue=-numericValue;
}
return numericValue;
}
function confrontoDecrescente(a, b){
var dataA=new Date(a.DataAppuntamento);
var dataB=new Date(b.DataAppuntamento);
return dataB - dataA;
}
function confrontoAscendente(a, b){
var dataA=new Date(a.DataAppuntamento);
var dataB=new Date(b.DataAppuntamento);
return dataA - dataB;
}
function findAncestor(el, sel){
while (
(el=el.parentElement) &&
!(el.matches||el.matchesSelector).call(el, sel)
);
return el;
}
function selectSearch(){
var selectSearch=document.querySelectorAll(".dropdown-menu.live-search"
);
for (let i=0; i < selectSearch.length; i++){
selectSearch[i].innerHTML +=
'<input type="text" class="input-live-search">';
}
var liveSearchInput=document.querySelectorAll(".dropdown-menu.live-search .input-live-search"
);
for (let i=0; i < liveSearchInput.length; i++){
liveSearchInput[i].addEventListener("keyup", function (){
var searchValue=this.value.toLowerCase();
var values=this.parentNode.querySelectorAll(".dropdown-item");
for (let e=0; e < values.length; e++){
var itemValue=values[e].innerText.toLowerCase();
if(itemValue.startsWith(searchValue)){
values[e].parentNode.classList.remove("hide");
}else{
values[e].parentNode.classList.add("hide");
}}
});
}}
function downloadICS({
uid,
dtstamp,
start,
end,
summary,
description,
location,
}){
let icsContent=[
"BEGIN:VCALENDAR",
"VERSION:2.0",
"PRODID:-/[D]hacksw/handcal/[D]NONSGML v1.0/[D]EN",
"BEGIN:VEVENT",
`UID:${uid}@example.com`,
`DTSTAMP:${formatDateToICS(dtstamp)}`,
`DTSTART:${formatDateToICS(start)}`,
`DTEND:${formatDateToICS(end)}`,
`SUMMARY:${summary}`,
`DESCRIPTION:${description}`,
`LOCATION:${location}`,
"END:VEVENT",
"END:VCALENDAR",
];
for (let i=0; i < icsContent.length; i++){
icsContent[i]=icsContent[i].split("[D]").join("/");
}
icsContent=icsContent.join("\r\n");
const blob=new Blob([icsContent], {
type: "text/calendar;charset=utf-8",
});
const url=URL.createObjectURL(blob);
const link=document.createElement("a");
link.href=url;
link.download=`${summary}.ics`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}
function formatDateToICS(date){
return date
.toISOString()
.replace(/[-:]/g, "")
.replace(/\.\d{3}/, "");
}
function generateUID(){
const timestamp=Date.now().toString(36);
const randomString=Math.random().toString(36).substr(2, 9);
return `${timestamp}-${randomString}`;
}
function getSearch(s){
s=s
.trim()
.replace(/[^a-zA-Z0-9\s]/g, "")
.replace(/\s+/g, " ")
.toLowerCase();
var tab="";
switch (s){
case "home":
tab="home";
break;
case "prossimi":
tab="home";
break;
case "prossimo":
tab="home";
break;
case "news":
tab="home";
break;
case "eventi":
tab="home";
break;
case "evento":
tab="home";
break;
case "anagrafica":
tab="anagrafica";
break;
case "generalit":
tab="anagrafica";
break;
case "generalita":
tab="anagrafica";
break;
case "generalità":
tab="anagrafica";
break;
case "dati":
tab="anagrafica";
break;
case "contatti":
tab="anagrafica";
break;
case "contatto":
tab="anagrafica";
break;
case "privacy":
tab="anagrafica";
break;
case "privacy policy":
tab="anagrafica";
break;
case "consenso":
tab="anagrafica";
break;
case "consensi":
tab="anagrafica";
break;
case "informativa":
tab="anagrafica";
break;
case "informativa privacy":
tab="anagrafica";
break;
case "anamnesi":
tab="anagrafica";
break;
case "questionario":
tab="anagrafica";
break;
case "questionari":
tab="anagrafica";
break;
case "appuntamenti":
tab="appuntamenti";
break;
case "appuntamento":
tab="appuntamenti";
break;
case "storico":
tab="appuntamenti";
break;
case "storico appuntamenti":
tab="appuntamenti";
break;
case "prossimi appuntamenti":
tab="appuntamenti";
break;
case "prossimo appuntamento":
tab="appuntamenti";
break;
case "piani":
tab="piani";
break;
case "piani di":
tab="piani";
break;
case "piani di cura":
tab="piani";
break;
case "piani di cura":
tab="piani";
break;
case "preventivi":
tab="piani";
break;
case "preventivo":
tab="piani";
break;
case "in corso":
tab="piani";
break;
case "saldo":
tab="piani";
break;
case "documenti":
tab="documenti";
break;
case "documento":
tab="documenti";
break;
case "fatto":
tab="documenti";
break;
case "contabili":
tab="documenti";
break;
case "documenti contabili":
tab="documenti";
break;
case "documento contabile":
tab="documenti";
break;
case "file":
tab="documenti";
break;
case "files":
tab="documenti";
break;
case "fattura":
tab="documenti";
break;
case "fatture":
tab="documenti";
break;
case "scontrino":
tab="documenti";
break;
case "scontrini":
tab="documenti";
break;
case "ricevuta":
tab="documenti";
break;
case "ricevute":
tab="documenti";
break;
case "dentista":
tab="dentista";
break;
case "dentisti":
tab="dentista";
break;
case "il mio":
tab="dentista";
break;
case "il mio dentista":
tab="dentista";
break;
case "specialista":
tab="dentista";
break;
case "specialisti":
tab="dentista";
break;
case "professionista":
tab="dentista";
break;
case "professionisti":
tab="dentista";
break;
case "medico":
tab="dentista";
break;
case "medici":
tab="dentista";
break;
case "assistente":
tab="dentista";
break;
case "tutor":
tab="dentista";
break;
case "odontoiatra":
tab="dentista";
break;
case "odontotecnico":
tab="dentista";
break;
case "dott":
tab="dentista";
break;
case "dr":
tab="dentista";
break;
case "dottore":
tab="dentista";
break;
case "dottori":
tab="dentista";
break;
case "recensioni":
tab="recensioni";
break;
case "recensione":
tab="recensioni";
break;
case "le mie recensioni":
tab="recensioni";
break;
case "la mia recensione":
tab="recensioni";
break;
case "le tue recensioni":
tab="recensioni";
break;
case "la tua recensione":
tab="recensioni";
break;
case "commento":
tab="recensioni";
break;
case "commenta":
tab="recensioni";
break;
case "racconta":
tab="recensioni";
break;
case "racconto":
tab="recensioni";
break;
case "notifiche":
tab="notifiche";
break;
case "notifica":
tab="notifiche";
break;
case "messaggi":
tab="notifiche";
break;
case "messaggio":
tab="notifiche";
break;
case "posta":
tab="notifiche";
break;
case "mail":
tab="notifiche";
break;
case "email":
tab="notifiche";
break;
case "inbox":
tab="notifiche";
break;
}
if(tab){
document.querySelector('.sidebar a[href="#' + tab + '"]').click();
}else{
alert("La ricerca non ha prodotto alcun risultato.");
}}
function getProvinces(){
var provinces=[
{ v: "AG", n: "Agrigento" },
{ v: "AL", n: "Alessandria" },
{ v: "AN", n: "Ancona" },
{ v: "AO", n: "Aosta" },
{ v: "AR", n: "Arezzo" },
{ v: "AP", n: "Ascoli Piceno" },
{ v: "AT", n: "Asti" },
{ v: "AV", n: "Avellino" },
{ v: "BA", n: "Bari" },
{ v: "BT", n: "Barletta-Andria-Trani" },
{ v: "BL", n: "Belluno" },
{ v: "BN", n: "Benevento" },
{ v: "BG", n: "Bergamo" },
{ v: "BI", n: "Biella" },
{ v: "BO", n: "Bologna" },
{ v: "BZ", n: "Bolzano" },
{ v: "BS", n: "Brescia" },
{ v: "BR", n: "Brindisi" },
{ v: "CA", n: "Cagliari" },
{ v: "CL", n: "Caltanissetta" },
{ v: "CB", n: "Campobasso" },
{ v: "CI", n: "Carbonia-Iglesias" },
{ v: "CE", n: "Caserta" },
{ v: "CT", n: "Catania" },
{ v: "CZ", n: "Catanzaro" },
{ v: "CH", n: "Chieti" },
{ v: "CO", n: "Como" },
{ v: "CS", n: "Cosenza" },
{ v: "CR", n: "Cremona" },
{ v: "KR", n: "Crotone" },
{ v: "CN", n: "Cuneo" },
{ v: "EN", n: "Enna" },
{ v: "FM", n: "Fermo" },
{ v: "FE", n: "Ferrara" },
{ v: "FI", n: "Firenze" },
{ v: "FG", n: "Foggia" },
{ v: "FC", n: "Forlì-Cesena" },
{ v: "FR", n: "Frosinone" },
{ v: "GE", n: "Genova" },
{ v: "GO", n: "Gorizia" },
{ v: "GR", n: "Grosseto" },
{ v: "IM", n: "Imperia" },
{ v: "IS", n: "Isernia" },
{ v: "SP", n: "La Spezia" },
{ v: "AQ", n: "L'Aquila" },
{ v: "LT", n: "Latina" },
{ v: "LE", n: "Lecce" },
{ v: "LC", n: "Lecco" },
{ v: "LI", n: "Livorno" },
{ v: "LO", n: "Lodi" },
{ v: "LU", n: "Lucca" },
{ v: "MC", n: "Macerata" },
{ v: "MN", n: "Mantova" },
{ v: "MS", n: "Massa-Carrara" },
{ v: "MT", n: "Matera" },
{ v: "VS", n: "Medio Campidano" },
{ v: "ME", n: "Messina" },
{ v: "MI", n: "Milano" },
{ v: "MO", n: "Modena" },
{ v: "MB", n: "Monza e della Brianza" },
{ v: "NA", n: "Napoli" },
{ v: "NO", n: "Novara" },
{ v: "NU", n: "Nuoro" },
{ v: "OR", n: "Oristano" },
{ v: "PD", n: "Padova" },
{ v: "PA", n: "Palermo" },
{ v: "PR", n: "Parma" },
{ v: "PV", n: "Pavia" },
{ v: "PG", n: "Perugia" },
{ v: "PU", n: "Pesaro e Urbino" },
{ v: "PE", n: "Pescara" },
{ v: "PC", n: "Piacenza" },
{ v: "PI", n: "Pisa" },
{ v: "PT", n: "Pistoia" },
{ v: "PN", n: "Pordenone" },
{ v: "PZ", n: "Potenza" },
{ v: "PO", n: "Prato" },
{ v: "RG", n: "Ragusa" },
{ v: "RA", n: "Ravenna" },
{ v: "RC", n: "Reggio Calabria" },
{ v: "RE", n: "Reggio Emilia" },
{ v: "RI", n: "Rieti" },
{ v: "RN", n: "Rimini" },
{ v: "RM", n: "Roma" },
{ v: "RO", n: "Rovigo" },
{ v: "SA", n: "Salerno" },
{ v: "SS", n: "Sassari" },
{ v: "SV", n: "Savona" },
{ v: "SI", n: "Siena" },
{ v: "SR", n: "Siracusa" },
{ v: "SO", n: "Sondrio" },
{ v: "TA", n: "Taranto" },
{ v: "TE", n: "Teramo" },
{ v: "TR", n: "Terni" },
{ v: "TO", n: "Torino" },
{ v: "TP", n: "Trapani" },
{ v: "TN", n: "Trento" },
{ v: "TV", n: "Treviso" },
{ v: "TS", n: "Trieste" },
{ v: "UD", n: "Udine" },
{ v: "VA", n: "Varese" },
{ v: "VE", n: "Venezia" },
{ v: "VB", n: "Verbano-Cusio-Ossola" },
{ v: "VC", n: "Vercelli" },
{ v: "VR", n: "Verona" },
{ v: "VV", n: "Vibo Valentia" },
{ v: "VI", n: "Vicenza" },
{ v: "VT", n: "Viterbo" },
];
return provinces;
}
function updateProvinces(){
var provinces=getProvinces();
var province="";
for (let i=0; i < provinces.length; i++){
province +=
'<li><a class="dropdown-item" href="#" data-value="' +
provinces[i].v +
'">' +
provinces[i].n +
"</a></li>";
}
document.querySelector("#input-provincianascita + .dropdown-menu"
).innerHTML=province;
}
function getFullProvince(prov){
var provinces=getProvinces();
for (let i=0; i < provinces.length; i++){
if(prov.toLowerCase()==provinces[i].v.toLowerCase()){
return provinces[i].n;
}}
return "";
}
function resetAssicurazione(){
var user=getCurrentData();
var temp=getCurrentTemp();
var pagatori=false;
if(temp!=null &&
typeof temp!=="undefined" &&
typeof temp.Paziente!=="undefined" &&
typeof user.PazienteFondi!=="undefined" &&
temp.Paziente.PazienteFondi!=user.PazienteFondi
){
var pagatori=temp.Paziente.PazienteFondi;
}else if(typeof user.PazienteFondi!=="undefined" &&
user.PazienteFondi!=null &&
user.PazienteFondi.length
){
var pagatori=user.PazienteFondi;
}
var fondi="";
for (let i=0; i < master.Fondi.length; i++){
var selected="";
if(pagatori){
for (let e=0; e < pagatori.length; e++){
if(pagatori[e].TerzoPagatoreDescrizione==master.Fondi[i].TerzoPagatoreDescrizione
){
selected="selected";
}}
}
fondi +=
"<option " +
selected +
">" +
master.Fondi[i].TerzoPagatoreDescrizione +
"</option>";
}
if(pagatori){
var descrizioni=master.Fondi.map((fondo)=> fondo.TerzoPagatoreDescrizione
);
var customAssicurazioni=pagatori.filter((pagatore)=> !descrizioni.includes(pagatore.TerzoPagatoreDescrizione)
);
for (let i=0; i < customAssicurazioni.length; i++){
fondi +=
"<option selected>" +
customAssicurazioni[i].TerzoPagatoreDescrizione +
"</option>";
}}
var selectAssicurazione =
'<select class="form-select w-100" id="input-assicurazione" data-placeholder="Scegli o digita le tue assicurazioni" multiple disabled>' +
fondi +
"</select>";
document.querySelector(".container-assicurazione").innerHTML =
selectAssicurazione;
jQuery("#input-assicurazione").select2({
theme: "bootstrap-5",
width: "100%",
placeholder: jQuery(this).data("placeholder"),
closeOnSelect: false,
tags: true,
});
}
function getAssicurazioneValues(){
var values=document.querySelectorAll("#select2-input-assicurazione-container li"
);
var val=[];
for (let i=0; i < values.length; i++){
var TerzoPagatoreDescrizione=values[i].getAttribute("title");
var found=false;
for (let j=0; j < master.Fondi.length; j++){
if(master.Fondi[j].TerzoPagatoreDescrizione==TerzoPagatoreDescrizione
){
val.push({
OwnerId: master.Fondi[j].OwnerId,
ParentId: currentParentId,
PazienteId: currentUser,
TerzoPagatoreDescrizione:
master.Fondi[j].TerzoPagatoreDescrizione,
TerzoPagatoreId: master.Fondi[j].TerzoPagatoreId,
});
found=true;
break;
}}
if(!found){
val.push({
OwnerId: 1,
ParentId: currentParentId,
PazienteId: currentUser,
TerzoPagatoreDescrizione: TerzoPagatoreDescrizione,
TerzoPagatoreId: 0,
});
}}
return val;
}
function refreshPageAfterSubmit(){
setTimeout(function (){
jQuery("#refreshModal").modal("show");
window.location.reload();
}, 1000);
}}
};