(function (ng) { moment.lang('it-IT'); var apiUrl = baseApiUrl + 'api/'; ng.module('frontoffice.controllers', ['ui.bootstrap', 'ngSanitize']) .constant('apiUrl', apiUrl); ng.module('frontoffice.directives', []) .directive('clickHandler', function () { return { restrict: 'A', scope: { clickHandler: '&' }, link: function (scope, $elm, attr) { $elm.on('click', function () { if (scope.clickHandler !== null) scope.clickHandler(); }); } } }); ng.module('frontoffice.services', ['ngResource']) .constant('apiUrl', apiUrl); ng.module('frontoffice.filters', []); ng.module('frontoffice', [ 'frontoffice.controllers', 'frontoffice.directives', 'frontoffice.services', 'frontoffice.filters', 'ui.bootstrap', 'ui.select', 'ngRoute', 'ngSanitize', 'ngAnimate', 'liquidpixels' ]) .constant('apiUrl', apiUrl) .run(["$templateCache", function ($templateCache) { $templateCache.put('alertdialog.html', ''); $templateCache.put('loginportal.html', ''); $templateCache.put('otp-sing-referti.html', ''); $templateCache.put('cancbooking-popover.html', '

Se annulli la prenotazione fino a 24 ore prima, ti verrà restituito l\'intero importo

'); }]); })(angular); (function (ng, ngmodule, $, _) { ngmodule.controller('AccountController', ['$scope', '$modalInstance', '$http', 'apiUrl', '$q', '$window', 'sourceData', function ($scope, $modalInstance, $http, apiUrl, $q, $window, sourceData) { $scope.searchText = ''; $scope.status = 'loading'; $scope.access_referti = ($window.location.href.indexOf("/Referti") > 0); $scope.me = sourceData.me; $scope.activeUser = sourceData.selected; $scope.change = false; $scope.minors = []; $scope.delegates = []; $scope.hasdelega = true; $scope.hasDelega = function () { return $scope.hasdelega; }; var getDataGigiya = setInterval(function () { if ($window.gigya !== undefined) { $window.gigya.accounts.getAccountInfo({ callback: function (e) { if (e.status === "OK") { $scope.minors = e.data.minors || []; $scope.delegates = e.data.confirmedDelegating || []; $scope.hasdelega = $scope.minors.length > 0 || $scope.delegates.length > 0; clearInterval(getDataGigiya); } } }); } }, 1000); $scope.getUserType = function () { return ($scope.activeUser.fiscalCode === $scope.me.fiscalCode) ? "" : ("Stai agendo per conto di " + $scope.activeUser.firstName + " " + $scope.activeUser.lastName + ""); }; $scope.changeAccountActive = function () { var cf = (_.filter($scope.minors, { checked: true }).length > 0) ? _.filter($scope.minors, { checked: true })[0].fiscalCode : _.filter($scope.delegates, { checked: true }).length > 0 ? _.filter($scope.delegates, { checked: true })[0].fiscalCode : ''; $(".row.block.x-loader-div").removeClass("ng-hide"); $window.gigya.accounts.setAccountInfo({ data: { activeUser: cf }, callback: function () { setTimeout(function () { $window.gigya.accounts.getJWT({ fields: "data.activeUser", callback: function (data) { var returnUrl = getParameterByName("ReturnUrl") || window.location.href; //se non ho il parametro return url, ricarico solo la pagina window.location.href = window.baseApiUrl + "Account/LoginSSO?jwt=" + data.id_token + "&ReturnUrl=" + returnUrl; } }); }, 1500) } }); }; $scope.choose = function (selected) { $scope.termSelected = { title: selected.label, value: selected.label, url: (selected.value) ? selected.value : "", type: selected.type, search: $scope.searchText, code: (selected.code) ? selected.code : "" }; $modalInstance.close($scope.termSelected); $("input[type='submit']").focus(); } $scope.close = function () { $modalInstance.close(-1); } }]); })(angular, angular.module('frontoffice.controllers'), jQuery, _); (function (ng, ngmodule, $, _) { ngmodule.controller('AlertDialogController', ['$scope', '$modalInstance', 'title', 'message', 'buttons', 'bodyhtml', function ($scope, $modalInstance, title, message, buttons, bodyhtml) { $scope.title = title; $scope.message = message; $scope.buttons = buttons; $scope.bodyhtml = bodyhtml; $scope.close = function (value) { $modalInstance.close(value); } $scope.modal = $modalInstance; }]); })(angular, angular.module('frontoffice.controllers'), jQuery, _); (function (ng, ngmodule, $, _) { ngmodule.controller('BadgeController', ['$scope', 'apiUrl', '$http', '$interval', '$modal', '$window', '$timeout', function ($scope, apiUrl, $http, $interval, $modal, $window,$timeout) { $scope.badge = 0; $scope.status = ''; $scope.updateBadge = function () { $http.get(apiUrl + '/preservation/') .then(function (response) { if (response.data !== null && response.data.length > 0) { $scope.status = 'has_results'; $scope.badge = response.data.length; if ($window.location.href === "https://" + window.location.hostname + "/Basket") { var lastrequest = $window.sessionStorage.getItem("reservation_guid"); var external_guid = response.data[0].external_guid; if (response.data[0].is_from_portal) return; if (lastrequest === null || external_guid !== lastrequest) { $window.gigya.accounts.getAccountInfo({ callback: function (e) { if (e.status === "OK") { var fullname = ""; if (e.data.activeUser === "" || e.data.activeUser === e.profile.username) { fullname = e.profile.firstName + " " + e.profile.lastName; } else { var minors = _.filter(e.data.minors || [], { 'fiscalCode': e.data.activeUser }); var delegating = _.filter(e.data.confirmedDelegating || [], { 'fiscalCode': e.data.activeUser }); fullname = (minors.length > 0) ? (minors[0].firstName + " " + minors[0].lastName) : (delegating[0].firstName + " " + delegating[0].lastName); } if (e.data.minors || e.data.confirmedDelegating) { $window.sessionStorage.setItem("reservation_guid", external_guid); var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Prenotazione'; }, message: function () { return '' }, bodyhtml: function () { return 'Stai prenotando per conto di ' + fullname; }, buttons: function () { return [ { label: 'Prosegui ', value: -1, cssClass: ' success-humanitas' }, { label: 'Cambia profilo', value: 0, cssClass: 'booknow widthunset' }]; } } }).result.then(function (result) { if (result == 0) { $(".sidepanel-servizi.account.sidepanel-trigger-container.sidepanel-trigger-container").click(); setTimeout(function () { $(".button-cambia").click() }, 1000); } }); } } } }); $window.sessionStorage.setItem("askdelegate", external_guid); } } if (response.data[0].is_paid) { /*$timeout(function () { window.location.href = window.baseApiUrl + "Loading/PaymentLoading"; }, 500); */ } } else { $scope.status = ''; $scope.badge = 0; } }); }; $interval(function () { $scope.updateBadge(); }, 60000*5); $scope.updateBadge(); }]); })(angular, angular.module('frontoffice.controllers'), jQuery, _); (function (ng, ngmodule, $, _, moment) { ngmodule.controller('BookDoctorWithExamSingleController', ['$scope', 'apiUrl', '$http', '$log', '$location', '$timeout', '$modal', '$window', function ($scope, apiUrl, $http, $log, $location, $timeout, $modal, $window) { $scope.doctor_id = null; $scope.status = ''; var calendar = null; $scope.currentTimeId = null; $scope.currentDay = null; $scope.doctorDays = []; $scope.wDoctorSelected = null; $scope.wDoctorSelectedText = null; $scope.exams = []; $scope.examTimes = []; $scope.exam_name = ""; $scope.exam_id = ""; $scope.standards_of_preparation = ""; $scope.docexam = {}; $scope.getStrutturaName = function () { var struttura = $scope.$parent.docexam.struttura; return (struttura && struttura !== "") ? $window.hospitalName[struttura.toLowerCase()].name : ""; }; $scope.scrollHorizontal = function (slide) { var jqueryElement = $(".flex-container.choose-date"); if (slide > 0) { jqueryElement.animate({ scrollLeft: '+=150' }, 1000, "swing"); } else { jqueryElement.animate({ scrollLeft: '-=150' }, 1000, "swing"); } } $scope.hasMorning = function (items) { return _.filter(items, function (dt) { return moment(dt.first_occurrance).format('HH:mm') <= "13:59" }).length > 0; }; $scope.hasAfternoon = function (items) { return _.filter(items, function (dt) { return moment(dt.first_occurrance).format('HH:mm') > "13:59" }).length > 0; }; function isValidURL(string) { var res = string.match(/^(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g); return (res !== null) }; function decodeHTMLEntities(text) { if (isValidURL(text)) { return "Clicca qui per conoscere le norme di preparazione"; } else { var textArea = document.createElement('textarea'); textArea.innerHTML = text; return textArea.value; } } $scope.trackAddToCart = function (wData) { var date = moment(wData.first_occurrance); var hours = date.diff(moment(), 'hours'); var days = date.diff(moment(), 'hours'); var _learnq = $window._learnq || []; _learnq.push(["track", "Added to Cart", { "$value": wData.exam_price, "AddedItemProductName": wData.exam_name, "AddedItemProductID": wData.exam_code, "AddedItemSKU": wData.exam_code, "AddedItemCategories": ["Exam", "Doctor", $window.hospitalName[wData.struttura.toLowerCase()].name], "AddedItemImageURL": "", "AddedItemURL": $window.location.href, "AddedItemPrice": wData.exam_price, "AddedItemQuantity": 1, "ItemNames": [wData.exam_code], "CheckoutURL": "", "Items": [] }]); $window.track('Appointment', 'Visit Selected', { }, { 'currencyCode': 'EUR', 'add': { 'products': [{ name: wData.exam_name, id: wData.exam_code, price: wData.exam_price, brand: $window.hospitalName[wData.struttura.toLowerCase()].name, category: 'Dottori', doctorId: (wData.doctor_unique_code && wData.doctor_unique_code!=='') ? wData.doctor_unique_code:"MEDICAL_EQUIPE", doctorName: (wData.doctor_unique_code && wData.doctor_unique_code !== '') ? wData.doctor_fullname : "Medical Equipe", quantity: 1 }] } } ); } $scope.ngOnSubmit = function (formName, event, standards_of_preparation) { $scope.standards_of_preparation = standards_of_preparation; $scope.standards_of_preparation = (!_.isUndefined($scope.agendaMap)) ? $scope.agendaMap.day.standards_of_preparation : $scope.standards_of_preparation; if (!$scope.standards_of_preparation) { $scope.status = 'isloading'; $scope.trackAddToCart($scope.wDoctorSelected); return true; } $scope.standards_of_preparation_text = decodeHTMLEntities($scope.standards_of_preparation.replace(/(<([^>]+)>)/ig, "")); event.preventDefault(); event.stopPropagation(); var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Norme di Preparazione'; }, message: function () { return '' }, bodyhtml: function () { return decodeHTMLEntities($scope.standards_of_preparation).replace(/(]*)(>)/gi, '$1 target="_blank" $2'); }, buttons: function () { return [{ label: 'Ho letto le norme', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { if (result == 0) { $scope.status = 'isloading'; $scope.trackAddToCart($scope.wDoctorSelected); document[formName].submit(); } }); } $scope.hasHorizontalScrollbar = false; $scope.dataResponse = []; $scope.$watch('$parent.docexam', function (newVal) { function showData(r) { { console.log("Modified DocExam"); $scope.docexam = $scope.$parent.docexam; $scope.struttura = $scope.$parent.struttura; if (ng.isDefined(r.data) && r.data.length > 0) { calendar = r.data; var doctorDays = _.map( _.keys(_.groupBy(calendar, 'basedate1000')), function (basedate) { var date = moment(parseInt(basedate)); return { date: date.format('DD MMM'), dayname: date.format('dddd'), basedate: parseInt(basedate), wkday: date.format("ddd").toUpperCase() }; }); $scope.doctorDays = _.sortBy(doctorDays, 'basedate'); var exams = _.map( calendar , function (day) { return { exam_id: day.exam_id, exam_name: day.exam_name, exam_description: day.exam_description, exam_price: day.price_string, exam_room: day.room, day: day, standards_of_preparation: day.standards_of_preparation }; }); exams = _.uniq(exams, function (e) { return e.exam_id + e.day.struttura; }); $scope.$parent.type_pay = exams[0].provider_code; $scope.$parent.docexam.exam_price = (exams[0].provider_code != 'D') ? '€ ' + exams[0].exam_price : ''; $scope.exams = exams; if ($scope.doctorDays.length > 0) $scope.currentDay = $scope.doctorDays[0]; populateDoctorsTimes(); $scope.status = 'hasresults'; $timeout(function () { $flexvisible = $(".flex-row:visible"); if ($flexvisible.length > 0 && $(".btn-day:last-child", $flexvisible).length > 0) $scope.hasHorizontalScrollbar = $flexvisible.width() < $(".btn-day:last-child", $flexvisible).offset().left; else $scope.hasHorizontalScrollbar = false; }, 500); } else { $scope.doctorDays = null; $scope.status = 'nodata'; $scope.$parent.status = 'nodata'; $scope.$parent.docexam.exam_price = ''; } } }; $scope.showForm = function (ssn) { var controller = 'ChooseFormHospitalController'; var template = ''; template = 'conventions'; $modal.open({ windowClass: 'sidepanel hospitals-container right', template: $('#' + template).html(), controller: controller, resolve: { selected: function () { return ""; }, sourceData: function () { return { "exam_name": $scope.$parent.exam_name, "exam_code": $scope.$parent.exam_code, "exam_seo": $scope.$parent.exam_seo, }; } } }).result.then(function () { }, function () { })['finally'](function () { $scope.modalInstance = undefined // <--- This fixes }); }; if (!_.isUndefined(newVal) && !_.isNull(newVal) && !_.isUndefined(newVal.idcontract) && !_.isNull(newVal.idcontract)) { console.log($scope.$parent.docexam.exam_id + $scope.$parent.docexam.struttura + $scope.$parent.docexam.idcontract); console.log($scope.docexam.exam_id + $scope.docexam.struttura + $scope.docexam.idcontract); { $scope.status = 'isloading'; var url = apiUrl + 'doctor/' + $scope.$parent.doctor_id + '/calendar/' + $scope.$parent.docexam.exam_id + '/contract/' + $scope.$parent.docexam.struttura + '/' + $scope.$parent.docexam.idcontract; if ($scope.dataResponse[url]) { showData($scope.dataResponse[url]); } else { $http({ method: 'GET', url: url, params: { weekDays: getParameterByName("Weekdays"), hours: getParameterByName("Hours") } }).then(function (r) { showData(r); $scope.dataResponse[url] = r; }, function (e) { $log.error(e.message); }); } } } }, true); $scope.changeDay = function (item) { if (ng.isDefined(item)) { $scope.currentDay = item; populateDoctorsTimes(); if (!$scope.$$phase) $scope.$apply(); } } var populateDoctorsTimes = function () { var examTimes = []; _.forEach($scope.exams, function (exam) { var times = []; _.forEach(calendar, function (day) { if (day.exam_id == exam.exam_id && day.basedate1000 == $scope.currentDay.basedate) { day.id = day.exam_id + '_' + moment(day.datetime).valueOf(); times.push(day); } }); examTimes[exam.exam_id] = _.sortBy(times, 'datetime'); }); $scope.examTimes = examTimes; } $scope.selectDateTime = function (item) { $scope.wDoctorSelected = item; $scope.exam_name = item.exam_name; $scope.currentTimeId = item.exam_id + '_' + moment(item.datetime).valueOf(); $scope.standards_of_preparation = $scope.$parent.standards_of_preparation;; if (!$scope.$$phase) $scope.$apply(); } $scope.$watch('wDoctorSelected', function (newVal) { if (!_.isUndefined(newVal) && !_.isNull(newVal)) { var date = moment($scope.wDoctorSelected.first_occurrance); $scope.wDoctorSelectedText = 'Stai per prenotare:
' + $scope.exam_name + '
' + date.format('dddd DD MMMM') + ' alle ore ' + date.format('HH.mm'); if (!$scope.$$phase) $scope.$apply(); //var top = $('.booking-form .booknow').offset().top - 200; $('html, body').animate({ scrollTop: ($('.booknow:visible').first().offset().top - 200) }, 500); } }); } ]); })(angular, angular.module('frontoffice.controllers'), jQuery, _, moment); (function (ng, ngmodule, $, _, moment) { ngmodule.controller('BookDoctorPDWithExamController', ['$scope', '$q', '$http', '$log', '$location', '$modal', '$timeout', '$window', 'apiUrl', function ($scope, $q, $http, $log, $location, $modal, $timeout, $window, apiUrl) { $scope.doctor_id = null; $scope.status = 'isloading'; $scope.exam_id = null; var calendar = null; $scope.currentTimeId = null; $scope.currentDay = null; $scope.doctorDays = []; $scope.wDoctorSelected = null; $scope.wDoctorSelectedText = null; $scope.exams = []; $scope.allexams = []; $scope.examTimes = []; $scope.exam_name = ""; $scope.struttura = ""; $scope.type_pay = "I"; $scope.fondo_not_avail = false; $scope.dati = {}; $scope.products = []; $scope.dati.exam_selected = ""; $scope.selectedStrutture = []; $scope.insurances = []; $scope.selectedInsuranceCode = getParameterByName("Insurance") || ""; $scope.docexam = { type_pay: $scope.selectedInsuranceCode !== '' ? 'I' : 'LP' }; $scope.selectedInsurance = { 'title': 'Nessuna assicurazione', 'value': '', 'code': '', 'type': 'LP', 'idcontract': '' }; if (!($window.insurances)) { $timeout(function () { $http.get(apiUrl + '/insurance', { }).then(function (response) { var data = response.data; $window.insurances = data; }); }); } $scope.getExamPrice = function () { var selectedInsurance = _.filter($scope.insurances, { checked: true, type: $scope.docexam.type_pay })[0]; return ($scope.docexam && $scope.docexam.exam_price && $scope.docexam.type_pay !== 'D') ? $scope.docexam.exam_price : ""; } $scope.showContract = function (type) { var insurance = _.filter($window.insurances, { code: $scope.selectedInsuranceCode })[0]; if (type === "D") type = "F"; var contract = _.filter(insurance.contracts, { contract_form_code: type })[0]; var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Informazioni convenzione'; }, message: function () { return '' }, bodyhtml: function () { return decodeHTMLEntities(contract.channel_note || "").replace(/(
]*)(>)/gi, '$1 target="_blank" $2'); }, buttons: function () { return [{ label: 'Ho letto le norme', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { }); }; var oldexam = ""; function updateData() { var exam = _.filter($scope.exams, { checked: true })[0]; $scope.exam_name = (exam) ? exam.exam_name : ""; if ($scope.exams.length > 0 && exam && exam.structurelist && exam.structurelist.length > 0) { if (oldexam.external_code !== exam.external_code) { oldexam = exam; var selectedStrutture = _.map(exam.structurelist, function (s) { s.title = $window.hospitalName[s.code.toLowerCase()].name; s.name = s.title; s.subtitle = ""; s.struttura = s.code; s.value = s.code; s.checked = false; s.results = true; return s; }); selectedStrutture[0].checked = true; $scope.selectedStrutture = selectedStrutture; $scope.selectedStructures = selectedStrutture[0]; } else { $scope.selectedStructures = _.filter($scope.selectedStrutture, { checked: true })[0]; if (!$scope.selectedStructures) { $scope.selectedStructures = $scope.selectedStrutture[0]; } } var insurances = []; var selectedInsurance = _.filter($scope.insurances, { checked: true, type: $scope.docexam.type_pay })[0]; if (!selectedInsurance) { selectedInsurance = _.filter($scope.insurances, { checked: true })[0]; } if ($scope.selectedStructures) { for (var i = 0; i < $scope.selectedStructures.contracts.length; i++) { console.log("Contract of Insurance " + $scope.selectedStructures.code) var contract = $scope.selectedStructures.contracts[i]; contract.title = contract.name; contract.subtitle = ""; contract.checked = (selectedInsurance && selectedInsurance.title === contract.title); contract.value = (contract.type === "LP") ? "" : contract.code; if (contract.type === "LP") { contract.title = 'Nessuna assicurazione'; } if (!selectedInsurance) { if (contract.value === $scope.selectedInsuranceCode && $scope.docexam.type_pay === contract.type) { contract.checked = true; } } insurances.push(contract); } insurances.push({ title: 'ALTRO FONDO/ASSICURAZIONE', subtitle: '', value: 'ALTRO', type: 'LP', code: '', checked: false }); selectedInsurance = _.filter($scope.insurances, { checked: true, type: $scope.docexam.type_pay })[0]; if (!selectedInsurance) { selectedInsurance = _.filter($scope.insurances, { checked: true })[0]; } if (selectedInsurance) $scope.selectedInsuranceCode = selectedInsurance.value; $scope.insurances = insurances; console.log($scope.insurances); if (!selectedInsurance) { selectedInsurance = _.filter($scope.insurances, { checked: true })[0]; if (selectedInsurance) $scope.selectedInsuranceCode = selectedInsurance.value; } if (!selectedInsurance) { $scope.status = ''; if ($scope.selectedInsuranceCode === "ALTRO") { $scope.showForm(); } else if ($scope.selectedInsuranceCode !== "") { if ($scope.docexam.type_pay === "I") { $scope.docexam.type_pay = "D"; return; } if ($scope.fondo_not_avail === false) var html = "

Il fondo selezionato non è disponibile.

"; $scope.fondo_not_avail = true; var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Attenzione'; }, message: function () { return '' }, bodyhtml: function () { return html; }, buttons: function () { return [{ label: 'OK', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { $scope.fondo_not_avail = false; let fondo = $scope.insurances[0]; let newurl = $window.location.href.split("?")[0] + "?Hospital=" + getParameterByName("Hospital") + "&Hours=" + getParameterByName("Hours") + "&Insurance=" + ((fondo && fondo.type === "LP") ? "" : fondo.code); $window.location.href = newurl; }); } else { if ($scope.fondo_not_avail === false) var html2 = "

Il professionista puo' essere prenotato solo tramite la scelta di un'assicurazione.

"; $scope.fondo_not_avail = true; var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Attenzione'; }, message: function () { return '' }, bodyhtml: function () { return html2; }, buttons: function () { return [{ label: 'OK', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { //console.log($scope.insurances[0]); $scope.fondo_not_avail = false; let fondo = $scope.insurances[0]; let newurl = $window.location.href.split("?")[0] + "?Hospital=" + getParameterByName("Hospital") + "&Hours=" + getParameterByName("Hours") + "&Insurance=" + fondo.code; $window.location.href = newurl }); return; } } if (selectedInsurance) { $scope.type_pay = selectedInsurance.type; $scope.selectedInsurance = selectedInsurance; console.log($scope.selectedInsurance); $scope.status = 'hasresults'; var docexam = _.filter($scope.exams, { checked: true })[0]; docexam.type_pay = selectedInsurance.type; $scope.struttura = _.filter($scope.selectedStrutture, { checked: true })[0].code; docexam.struttura = $scope.struttura; docexam.idcontract = $scope.selectedInsurance.idcontract; docexam.type_pay = $scope.selectedInsurance.type; docexam.insurance = selectedInsurance; $scope.bookingCollapseDoctor(docexam); } } } } var opdate=new Date(); var trytimes = 3; $scope.getProducts= function(opdate){ $timeout(function () { trytimes--; opdate = new Date().toString(); var doctorId = $scope.doctor_id; $http.get(`${apiUrl}doctor/${doctorId}/products?${opdate}`, {}).then(function (response) { var data = response.data; if (ng.isDefined(data) && data.length > 0) { $scope.products = data; var exams = _.map( $scope.products , function (product) { product.exam_name = product.name; product.exam_seo = product.seo; product.exam_description = product.description; product.title = product.name; product.subtitle = ""; product.price = ""; product.value = product.exam_id; product.checked = false; product.order = -product.order; return product; }); exams[0].checked = true; $scope.exams = exams; if (getParameterByName("Hospital") && getParameterByName("Hospital") !== "") { exams = _.filter(exams, function (ex) { return _.intersection(_.map(ex.structurelist, function (s) { return s.code.toUpperCase(); }), getParameterByName("Hospital").split("|")).length > 0; }); if (exams.length > 0) { exams[0].checked = true; } $scope.exams = exams; } if ($scope.exams && $scope.exams.length > 0) { $scope.selectedExams = _.filter($scope.exams, { 'checked': true })[0]; $scope.selectedStrutture = _.map($scope.exams[0].structurelist, function (s) { s.title = $window.hospitalName[s.code.toLowerCase()].name; s.name = s.title; s.subtitle = ""; s.struttura = s.code; s.value = s.code; s.checked = false; s.results = true; return s; }); updateData(true); } else { $scope.products = []; $scope.exams = []; $scope.status = 'nodata'; } } else { $scope.products = []; $scope.exams = []; $scope.status = 'nodata'; } }, function () { $scope.products = []; $scope.exams = []; $scope.status = 'nodata'; }); }); } $scope.getProducts(""); function isValidURL(string) { var res = string.match(/^(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g); return (res !== null) }; function decodeHTMLEntities(text) { if (isValidURL(text)) { return "
Clicca qui per conoscere le norme di preparazione"; } else { var textArea = document.createElement('textarea'); textArea.innerHTML = text; return textArea.value; } } /** * Number.prototype.format(n, x, s, c) * * @param integer n: length of decimal * @param integer x: length of whole part * @param mixed s: sections delimiter * @param mixed c: decimal delimiter */ Number.prototype.format = function (n, x, s, c) { var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')', num = this.toFixed(Math.max(0, ~~n)); return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ',')); }; $scope.ngOnSubmit = function (formName, event, standards_of_preparation) { $scope.standards_of_preparation = standards_of_preparation; if (!$scope.standards_of_preparation) { $scope.status = 'isloading'; return true; } event.preventDefault(); event.stopPropagation(); var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Norme di Preparazione'; }, message: function () { return '' }, bodyhtml: function () { return decodeHTMLEntities($scope.standards_of_preparation).replace(/(]*)(>)/gi, '$1 target="_blank" $2'); }, buttons: function () { return [{ label: 'Ho letto le norme', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { if (result === 0) { $scope.status = 'isloading'; document[formName].submit(); } }); } $scope.shownForm = false; $scope.showForm = function (ssn) { var controller = 'ChooseFormHospitalController'; var template = ''; template = 'conventions'; if ($scope.shownForm) return; $scope.shownForm = true; $modal.open({ windowClass: 'sidepanel hospitals-container right', template: $('#' + template).html(), controller: controller, resolve: { selected: function () { return ""; }, sourceData: function () { return { "exam_name": $scope.exam_name, "exam_code": $scope.exam_code, "exam_seo": $scope.exam_seo, }; } } }).result.then(function () { }, function () { })['finally'](function () { $scope.shownForm = false; $scope.modalInstance = undefined // <--- This fixes }); }; $scope.formatExamDate = function (examDate) { return moment(examDate).format('ddd D MMM. [ore:] HH:mm'); }; $scope.filtershide = false; $scope.filtershideToggle = function () { $scope.filtershide = !$scope.filtershide; }; $scope.selectExam = function (examselect) { var examsel = _.filter($scope.exams, function (ex) { return ex.exam_name == examselect.exam_name }); if (examsel.length > 0) { examsel[0].checked = true; $scope.dati.exam_selected = "SELECTED"; $scope.filtershideToggle(); } }; $scope.strutturaFilter = function (item) { var letFilteredStruttura = _.filter($scope.selectedStrutture, function (s) { return s.checked === true; }); if (letFilteredStruttura.length > 0) { if (_.findWhere(letFilteredStruttura, { 'struttura': item.day.struttura }) !== undefined) return item; } else { return item; } }; $scope.examFilter = function (item) { { var letFilteredExam = _.filter($scope.exams, function (s) { return s.checked === true; }); if (letFilteredExam.length > 0) { if (_.findWhere(letFilteredExam, { 'exam_name': item.exam_name }) !== undefined) return item; } else { return item; }; } }; $scope.resetFilters = function () { $scope.exams.forEach(function (e) { e.checked = false; }); $scope.selectedStrutture.forEach(function (s) { s.checked = false; }); $scope.data.nodoctor = false; } $scope.getWeekDay = function (examDate) { return moment(examDate).format('ddd').toUpperCase(); } $scope.getMonth = function (examDate) { return moment(examDate).format('MMM').toUpperCase(); } $scope.getDay = function (examDate) { return moment(examDate).format('DD'); } $scope.getHour = function (examDate) { return moment(examDate).format('HH:mm'); } $scope.getWellFormatDate = function (examDate) { var date = moment(examDate); var today = moment().endOf('day'); var tomorrow = moment().add(1, 'day').endOf('day'); var weekday = moment().add(7, 'day').endOf('day'); var stringDay = ""; if (date < today) stringDay = 'Oggi'; else if (date < tomorrow) stringDay = 'Domani'; else if (date < weekday) stringDay = date.format('[Prossimo] dddd'); else stringDay = date.format('ddd D MMM'); return stringDay + " " + moment(examDate).format('[ore] HH:mm'); } $scope.bookingCollapseDoctor = function (docexam) { if (docexam === undefined) { return; } else { if ($scope.booktype !== docexam.exam_id + docexam.struttura + docexam.idcontract) { $scope.exam_id = docexam.exam_id; $scope.struttura = docexam.struttura; $scope.standards_of_preparation = docexam.standards_of_preparation; $scope.booktype = docexam.exam_id + docexam.struttura + docexam.idcontract; $scope.docexam = docexam; console.log("ATTIVA ASYNC " + $scope.booktype); } } } $scope.changeDay = function (item) { if (ng.isDefined(item)) { $scope.currentDay = item; populateDoctorsTimes(); if (!$scope.$$phase) $scope.$apply(); } } var populateDoctorsTimes = function () { var examTimes = []; _.forEach($scope.exams, function (exam) { var times = []; _.forEach(calendar, function (day) { if (day.exam_id == exam.exam_id && day.basedate1000 == $scope.currentDay.basedate) { day.id = day.exam_id + '_' + moment(day.datetime).valueOf(); times.push(day); } }); examTimes[exam.exam_id] = _.sortBy(times, 'datetime'); }); $scope.examTimes = examTimes; } $scope.selectDateTime = function (item) { $scope.wDoctorSelected = item; $scope.exam_name = item.exam_name; $scope.currentTimeId = item.exam_id + '_' + moment(item.datetime).valueOf(); $scope.$broadcast('lpsly-updatecurrent-id', { currentId: $scope.currentTimeId }); if (!$scope.$$phase) $scope.$apply(); } $scope.$watch('exams', function (newVal) { if (!_.isUndefined(newVal) && !_.isNull(newVal)) { updateData(true); } }, true); $scope.showLP = function () { var selectedInsurance = _.filter($scope.insurances, { checked: true })[0]; return (selectedInsurance) ? (_.filter($scope.insurances, { type: 'LP', title: selectedInsurance.title }).length > 0 && $scope.docexam.exam_price !== '') : false; }; $scope.showIndiretta = function () { var selectedInsurance = _.filter($scope.insurances, { checked: true })[0]; return (selectedInsurance) ? (_.filter($scope.insurances, { type: 'I', title: selectedInsurance.title }).length > 0) : false; } $scope.showDiretta = function () { var selectedInsurance = _.filter($scope.insurances, { checked: true })[0]; return (selectedInsurance) ? (_.filter($scope.insurances, { type: 'D', title: selectedInsurance.title }).length > 0) : false; } $scope.$watch('wDoctorSelected', function (newVal) { if (!_.isUndefined(newVal) && !_.isNull(newVal)) { var date = moment($scope.wDoctorSelected.first_occurrance); $scope.wDoctorSelectedText = 'Stai per prenotare:
' + $scope.exam_name + '
' + date.format('dddd DD MMMM') + ' alle ore ' + date.format('HH.mm'); if (!$scope.$$phase) $scope.$apply(); var top = $('.booking-form .booknow').offset().top - 200; $("html, body").animate({ scrollTop: top }, 1000); } }); var trackletFilteredExam = _.filter($scope.exams, { 'checked': true }); if (trackletFilteredExam.length > 0) { var doctorTrack = trackletFilteredExam[0].day; $window.track$window.track('Appointment', 'Doctor Details Viewed', {}, { 'detail': { 'actionField': { list: 'Doctor list' }, 'products': [{ name: doctorTrack.doctor_fullname, id: doctorTrack.room, brand: 'notselected', category: 'Doctor', }] } } ); } } ]); })(angular, angular.module('frontoffice.controllers'), jQuery, _, moment); (function (ng, ngmodule, $, _, moment) { ngmodule.controller('BookingCalendarAgendaController', ['$scope', 'apiUrl', '$http', '$timeout', '$modal', function ($scope, apiUrl, $http, $timeout, $modal) { //$scope.exam_id inizializzato nel dom $scope.status = ''; $scope.generalPrice = null; $scope.cal = null; $scope.arraycalendar = []; $scope.range = 0; $scope.generalCalendar = null; $scope.generalSelected = null; $scope.generalSelectedText = null; $scope.generalFirstAvailability = null; $scope.currentDayDoctors = null; $scope.doctors = []; $scope.doctorDays = []; $scope.doctorsCalendar = null; $scope.doctorTimes = []; $scope.wDoctorSelected = null; $scope.wDoctorSelectedText = null; $scope.agendaMap = {}; $scope.standards_of_preparation = $scope.$parent.standards_of_preparation; function isValidURL(string) { var res = string.match(/^(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g); return (res !== null) }; function decodeHTMLEntities(text) { if (isValidURL(text)) { return "
Clicca qui per conoscere le norme di preparazione"; } else { var textArea = document.createElement('textarea'); textArea.innerHTML = text; return textArea.value; } } $scope.ngOnSubmit = function (formName, event) { if (!$scope.standards_of_preparation) { $scope.status = 'isloading'; return true; } event.preventDefault(); event.stopPropagation(); var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Norme di Preparazione'; }, message: function () { return '' }, bodyhtml: function () { return decodeHTMLEntities($scope.standards_of_preparation).replace(/(]*)(>)/gi, '$1 target="_blank" $2'); }, buttons: function () { return [{ label: 'Ho letto le norme', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { if (result == 0) { $scope.status = 'isloading'; document[formName].submit(); } }); } $scope.scrollHorizontal = function (slide) { var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); var jqueryElement = $(".flex-container.choose-date"); if (slide > 0) { jqueryElement.animate({ scrollLeft: '+=150' }, 1000, "swing"); } else { jqueryElement.animate({ scrollLeft: '-=150' }, 1000, "swing"); } if (isSafari) { $(".flex-row-mobile .choose-date").css("overflow-x", "auto"); } } $scope.hasHorizontalScrollbar = false; $scope.currentDoctorTimeId = null; $scope.getWeekDayWell = function (examDate) { var date = moment(examDate); var today = moment().endOf('day'); var tomorrow = moment().add(1, 'day').endOf('day'); var stringDay = ""; if (date < today) stringDay = 'Oggi'; else if (date < tomorrow) stringDay = 'Domani'; else stringDay = date.format('ddd'); return stringDay; } $scope.$watch('$parent.agendaMap', function (newVal) { $scope.agendaMap = $scope.$parent.agendaMap; if ($scope.status !== 'isloading' && !_.isUndefined(newVal) && !_.isNull(newVal) && !_.isEmpty(newVal) && ($scope.exam_ist && $scope.$parent.room == "IST" || !$scope.exam_ist && $scope.$parent.room != "IST")) { $scope.status = 'isloading'; $timeout(function () { var serviceUrl = apiUrl + 'examdetail/' + $scope.$parent.exam_id + '/calendar/' + $scope.$parent.room + '/' + $scope.$parent.struttura; $http({ method: 'GET', url: serviceUrl }) .success(function (data) { if (!_.isUndefined(data) && !_.isNull(data) && _.isArray(data) && (data.length > 0)) { $scope.status = 'hasresults'; // prepare istitutional calendar var dayGroups = _.filter(data, function (day) { //return day.provider_type !== 'L'; // escludo le visite dei dottori // IST price doctor handler return day.tipo_contratto == 'IST' && day.struttura == $scope.$parent.struttura; }); dayGroups = _.sortBy(dayGroups, "datetime_double"); dayGroups = _.groupBy(dayGroups, 'basedate1000'); var generalCalendar = []; _.forEach(dayGroups, function (group, key) { var date = moment(parseInt(key)); generalCalendar.push({ calendarday: date.format('DD MMM YYYY'), date: date.format('DD MMM'), dayname: date.format('dddd'), wkDay: $scope.getWeekDayWell(date), items: group }); }); $scope.generalCalendar = generalCalendar; if (ng.isDefined($scope.generalCalendar) && $scope.generalCalendar.length > 0 && $scope.generalCalendar[0].items.length > 0) { $scope.generalPrice = $scope.generalCalendar[0].items[0].price_string; $scope.cal = $scope.generalCalendar[0]; } // IST price doctor handler $scope.doctorsCalendar = _.filter(data, function (day) { return day.tipo_contratto == 'LP'; }); if ($scope.doctorsCalendar.length === 0 && $scope.doctorsCalendar) { $scope.doctorsCalendar = null; } $scope.doctorsCalendar = _.sortBy($scope.doctorsCalendar, "datetime_double"); var doctors = _.map( $scope.doctorsCalendar , function (day) { var date = moment(parseInt(day.basedate1000)); return { doctor_fullname: day.doctor_fullname, doctor_description: (day.doctor_description == "") ? " " : day.doctor_description, doctor_id: day.doctor_id, day: day, price_string: day.price_string, wkDay: $scope.getWeekDayWell(date), first_availability: parseInt(day.datetime_double) }; }); doctors = _.uniq(doctors, function (d) { return d.doctor_id; }); $scope.doctors = doctors; var doctorDays = _.map( _.keys(_.groupBy($scope.doctorsCalendar, 'basedate1000')), function (basedate) { var date = moment(parseInt(basedate)); return { date: date.format('DD MMM'), dayname: date.format('dddd'), basedate: parseInt(basedate), wkDay: $scope.getWeekDayWell(date), items: _.where($scope.doctorsCalendar, { 'basedate1000': parseInt(basedate) }) }; }); $scope.doctorDays = _.sortBy(doctorDays, 'basedate1000'); if ($scope.doctorDays.length > 0) $scope.currentDayDoctors = $scope.doctorDays[0]; populateDoctorsTimes(); $timeout(function () { $flexvisible = $(".flex-row:visible"); if ($flexvisible.length > 0 && $(".btn-day:last-child", $flexvisible).length > 0) $scope.hasHorizontalScrollbar = $flexvisible.width() < $(".btn-day:last-child", $flexvisible).offset().left + 100; else $scope.hasHorizontalScrollbar = false; }, 500); } else $scope.status = 'nodata'; }) .error(function (e) { $scope.status = 'nodata'; }); }, 100); } }); $scope.changeDay = function (item) { if (ng.isDefined(item)) { $scope.currentDayDoctors = item; populateDoctorsTimes(); if (!$scope.$$phase) $scope.$apply(); } } $scope.changeGeneralDate = function (item) { if (ng.isDefined(item)) { $scope.cal = item; if (!$scope.$$phase) $scope.$apply(); } } var populateDoctorsTimes = function () { var doctorsTimes = []; _.forEach($scope.doctors, function (doc) { var calendar = []; _.forEach($scope.doctorsCalendar, function (item) { if (item.doctor_id === doc.doctor_id && item.basedate1000 === $scope.currentDayDoctors.basedate) { item.id = item.doctor_id + '_' + moment(item.datetime).valueOf(); calendar.push(item); } }); doctorsTimes[doc.doctor_id] = _.sortBy(calendar, 'datetime'); }); $scope.doctorsTimes = doctorsTimes; //setTimeout(function () { // var top = $('#doctorSection').offset().top - 250; // $("html, body").animate({ scrollTop: top }, 1000); //}, 700); } $scope.formatExamDate = function (examDate) { return moment(examDate).format('ddd D MMM. [ore:] HH:mm'); } $scope.getWeekDay = function (examDate) { return moment(examDate).format('ddd').toUpperCase(); } $scope.getMonth = function (examDate) { return moment(examDate).format('MMM').toUpperCase(); } $scope.getDay = function (examDate) { return moment(examDate).format('D'); } $scope.getHour = function (examDate) { return moment(examDate).format('HH:mm'); } $scope.hasMorning = function (items) { return _.filter(items, function (dt) { return moment(dt.first_occurrance).format('HH:mm') <= "13:59" }).length > 0; } $scope.hasAfternoon = function (items) { return _.filter(items, function (dt) { return moment(dt.first_occurrance).format('HH:mm') > "13:59" }).length > 0; } $scope.selectDateTime = function (item) { $scope.wDoctorSelected = item; $scope.standards_of_preparation = $scope.$parent.standards_of_preparation;; $scope.currentDoctorTimeId = item.doctor_id + '_' + moment(item.datetime).valueOf(); //$scope.$broadcast('lpsly-updatecurrent-id', { currentId: $scope.currentDoctorTimeId }); if (!$scope.$$phase) $scope.$apply(); } $scope.setGeneralSelected = function (selected) { $scope.generalSelected = selected; if (!$scope.$$phase) $scope.$apply(); } $scope.$watch('wDoctorSelected', function (newVal) { if (!_.isUndefined(newVal) && !_.isNull(newVal)) { var date = moment($scope.wDoctorSelected.first_occurrance); $scope.wDoctorSelectedText = 'Stai per prenotare:
' + $scope.exam_name + '
' + date.format('dddd DD MMMM') + ' alle ore ' + date.format('HH.mm'); if (!$scope.$$phase) $scope.$apply(); $('html, body').animate({ scrollTop: ($('.booknow:visible').first().offset().top - 200) }, 500); } }); $scope.$watch('generalSelected', function (newVal) { if (!_.isUndefined(newVal) && !_.isNull(newVal)) { var date = moment($scope.generalSelected.first_occurrance); $scope.generalSelectedText = 'Stai per prenotare:
' + $scope.exam_name + '
' + date.format('dddd DD MMMM') + ' alle ore ' + date.format('HH.mm'); if (!$scope.$$phase) $scope.$apply(); //var top = $('.booking-form .booknow').offset().top - 200; $('html, body').animate({ scrollTop: ($('.booknow:visible').first().offset().top - 200) }, 500); } }); } ]); })(angular, angular.module('frontoffice.controllers'), jQuery, _, moment); (function (ng, ngmodule, $, _,moment) { ngmodule.controller('BookingCalendarAgendaSidePanelController', ['$scope', 'apiUrl', '$http', '$timeout', '$modal', 'sourceData', '$window', '$modalInstance', function ($scope, apiUrl, $http, $timeout, $modal, sourceData, $window, $modalInstance) { //$scope.exam_id inizializzato nel dom var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); $scope.status = ''; $scope.agendaMap = sourceData; $scope.agendaMap.struttura = $scope.agendaMap.day.struttura; $scope.exam_ist = $scope.agendaMap.exam_ist; $scope.agendaMap.room = ($scope.exam_ist) ? 'IST' : $scope.agendaMap.day.room; $scope.exam_name = $scope.agendaMap.exam_name; $scope.exam_code = $scope.agendaMap.exam_code; $scope.struttura = $scope.agendaMap.day.struttura; $scope.locationMap = $window.hospitalName[$scope.agendaMap.struttura.toLowerCase()]; $scope.agendaMap.location = ($window.isMobile) ? $scope.locationMap.name : $scope.locationMap.place + " - " + $scope.locationMap.name; $scope.generalPrice = null; $scope.cal = null; $scope.arraycalendar = []; $scope.range = 0; $scope.generalCalendar = null; $scope.generalSelected = null; $scope.generalSelectedText = null; $scope.generalFirstAvailability = null; $scope.currentDayDoctors = null; $scope.doctors = []; $scope.doctorDays = []; $scope.doctorsCalendar = null; $scope.doctorTimes = []; $scope.wDoctorSelected = null; $scope.wDoctorSelectedText = null; function isValidURL(string) { if (string && string !== null) { var res = string.match(/^(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g); return (res !== null) } else { return false; } }; function decodeHTMLEntities(text) { if (isValidURL(text)) { return "
Clicca qui per conoscere le norme di preparazione"; } else { var textArea = document.createElement('textarea'); textArea.innerHTML = text; return textArea.value; } } $scope.standards_of_preparation = ($scope.agendaMap.day.standards_of_preparation && $scope.agendaMap.day.standards_of_preparation !== null) ? $scope.agendaMap.day.standards_of_preparation : ""; $scope.standards_of_preparation_text = isValidURL($scope.standards_of_preparation) ? $scope.standards_of_preparation : decodeHTMLEntities($scope.standards_of_preparation.replace(/(<([^>]+)>)/ig, "")); if ($scope.standards_of_preparation) { var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Norme di Preparazione'; }, message: function () { return '' }, bodyhtml: function () { return decodeHTMLEntities($scope.standards_of_preparation).replace(/(]*)(>)/gi, '$1 target="_blank" $2'); }, buttons: function () { return [{ label: 'Ho letto le norme', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { }); } $scope.close = function () { $modalInstance.close(-1); } /* $scope.booktype = general.day.struttura; $scope.struttura = general.day.struttura; $scope.room = 'IST'; $scope.standards_of_preparation = general.day.standards_of_preparation; $scope.agendaMap = general.day.struttura + 'IST';*/ $scope.checskSOP = function () { return $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Norme di Preparazione'; }, message: function () { return '' }, bodyhtml: function () { return decodeHTMLEntities($scope.standards_of_preparation).replace(/(]*)(>)/gi, '$1 target="_blank" $2'); }, buttons: function () { return [{ label: 'Ho letto le norme', value: 0, cssClass: 'success-humanitas' }]; } } }) } $scope.ngOnSubmit = function (formName, event) { $scope.status = 'isloading'; $scope.trackAddToCart($scope.wDoctorSelected); return true; if (!$scope.standards_of_preparation) { $scope.status = 'isloading'; return true; } event.preventDefault(); event.stopPropagation(); var modalInstance = $modal.open({ templateUrl: 'alertdialog.html', controller: 'AlertDialogController', resolve: { title: function () { return 'Norme di Preparazione'; }, message: function () { return '' }, bodyhtml: function () { return decodeHTMLEntities($scope.standards_of_preparation).replace(/(]*)(>)/gi, '$1 target="_blank" $2'); }, buttons: function () { return [{ label: 'Ho letto le norme', value: 0, cssClass: 'success-humanitas' }]; } } }).result.then(function (result) { if (result == 0) { $scope.status = 'isloading'; document[formName].submit(); } }); } $scope.scrollHorizontal = function (slide) { var jqueryElement = $(".flex-container.choose-date"); if (slide > 0) { jqueryElement.animate({ scrollLeft: '+=150' }, 1000, "swing"); } else { jqueryElement.animate({ scrollLeft: '-=150' }, 1000, "swing"); } if (isSafari) { $(".flex-row-mobile .choose-date").css("overflow-x", "auto"); } } $scope.hasHorizontalScrollbar = false; $scope.currentDoctorTimeId = null; $scope.getWeekDayWell = function (examDate) { var date = moment(examDate); var today = moment().endOf('day'); var tomorrow = moment().add(1, 'day').endOf('day'); var stringDay = ""; if (date < today) stringDay = 'Oggi'; else if (date < tomorrow) stringDay = 'Domani'; else stringDay = date.format('ddd'); return stringDay; } if ($scope.status !== 'isloading') { $scope.status = 'isloading'; $timeout(function () { var serviceUrl = apiUrl + 'examdetail/' + $scope.agendaMap.exam_id + '/calendar/' + btoa($scope.agendaMap.room) + '/' + $scope.agendaMap.struttura; $http({ method: 'GET', url: serviceUrl, params: { "weekdays": getParameterByName("Weekdays"), "hours": getParameterByName("Hours"), "insurance": $window.insurance, "idContract": ($scope.agendaMap.type === "D" || $scope.agendaMap.type === "I") ? $scope.agendaMap.day["day" + $scope.agendaMap.type].idcontract : $scope.agendaMap.day.idcontract } }) .success(function (data) { if (!_.isUndefined(data) && !_.isNull(data) && _.isArray(data) && (data.length > 0)) { $scope.status = 'hasresults'; data = _.uniq(data, function (d) { return d.basedate1000 + d.datetime_double; }); // prepare istitutional calendar var dayGroups = _.filter(data, function (day) { //return day.provider_type !== 'L'; // escludo le visite dei dottori // IST price doctor handler return day.tipo_contratto == 'IST' && day.struttura == $scope.agendaMap.struttura; }); dayGroups = _.sortBy(dayGroups, "datetime_double"); dayGroups = _.groupBy(dayGroups, 'basedate1000'); var generalCalendar = []; _.forEach(dayGroups, function (group, key) { var date = moment(parseInt(key)); generalCalendar.push({ calendarday: date.format('DD MMM YYYY'), date: date.format('DD MMM'), dayname: date.format('dddd'), wkDay: $scope.getWeekDayWell(date), items: group }); }); $scope.generalCalendar = generalCalendar; if (ng.isDefined($scope.generalCalendar) && $scope.generalCalendar.length > 0 && $scope.generalCalendar[0].items.length > 0) { $scope.generalPrice = $scope.generalCalendar[0].items[0].price_string; $scope.cal = $scope.generalCalendar[0]; } // IST price doctor handler $scope.doctorsCalendar = _.filter(data, function (day) { return day.tipo_contratto == 'LP'; }); if ($scope.doctorsCalendar.length === 0 && $scope.doctorsCalendar) { $scope.doctorsCalendar = null; } $scope.doctorsCalendar = _.sortBy($scope.doctorsCalendar, "datetime_double"); var doctors = _.map( $scope.doctorsCalendar , function (day) { var date = moment(parseInt(day.basedate1000)); return { doctor_fullname: day.doctor_fullname, doctor_description: (day.doctor_description == "") ? " " : day.doctor_description, doctor_id: day.doctor_id, day: day, price_string: day.price_string, wkDay: $scope.getWeekDayWell(date), first_availability: parseInt(day.datetime_double) }; }); doctors = _.uniq(doctors, function (d) { return d.doctor_id; }); $scope.doctors = doctors; var doctorDays = _.map( _.keys(_.groupBy($scope.doctorsCalendar, 'basedate1000')), function (basedate) { var date = moment(parseInt(basedate)); return { exam_ist: false, exam_id: $scope.exam_id, exam_name: $scope.exam_name, date: date.format('DD MMM'), dayname: date.format('dddd'), basedate: parseInt(basedate), wkDay: $scope.getWeekDayWell(date), items: _.where($scope.doctorsCalendar, { 'basedate1000': parseInt(basedate) }) }; }); $scope.doctorDays = _.sortBy(doctorDays, 'basedate1000'); if ($scope.doctorDays.length > 0) $scope.currentDayDoctors = $scope.doctorDays[0]; populateDoctorsTimes(); if (_.isUndefined($scope.agendaMap.doctor_fullname)) { $scope.doctorDays = $scope.generalCalendar; } $timeout(function () { var wData = $scope.doctorDays[0].items[0]; $window.track('Appointment', 'Visit Dates Selected', { }, { 'currencyCode': 'EUR', 'add': { 'actionField': { 'list': 'Appointment Search' }, 'products': [{ name: $scope.exam_name, id: $scope.exam_code, price: wData.exam_price, brand: $window.hospitalName[$scope.agendaMap.struttura.toLowerCase()].name, category: 'Appointment', doctorId: (wData.doctor_unique_code && wData.doctor_unique_code !== '') ? wData.doctor_unique_code : "MEDICAL_EQUIPE", doctorName: (wData.doctor_unique_code && wData.doctor_unique_code !== '') ? wData.doctor_fullname : "Medical Equipe", quantity: 1 }] } } ); $flexvisible = $(".flex-row:visible"); if ($flexvisible.length > 0 && $(".btn-day:last-child", $flexvisible).length > 0) $scope.hasHorizontalScrollbar = $flexvisible.width() < $(".btn-day:last-child", $flexvisible).offset().left + 100; else $scope.hasHorizontalScrollbar = false; $(".flex-row:visible .choose-date:visible").off("scroll").on("scroll", function () { $(".flex-row-mobile .choose-date:visible").scrollLeft($(".flex-row .choose-date:visible").scrollLeft()); }); $(".flex-row-mobile .choose-date:visible").off("scroll").on("scroll",function () { $(".flex-row .choose-date:visible").scrollLeft($(".flex-row-mobile .choose-date:visible").scrollLeft()); }); $(".flex-row:visible .choose-date:visible").off("touchmove scroll").on("touchmove scroll", function () { $(".flex-row-mobile .choose-date:visible").scrollLeft($(".flex-row .choose-date:visible").scrollLeft()); }); $(".flex-row-mobile .choose-date:visible").off("touchmove scroll").on("touchmove scroll", function () { $(".flex-row .choose-date:visible").scrollLeft($(".flex-row-mobile .choose-date:visible").scrollLeft()); }); /* $(".flex-row-mobile .choose-date > .btn.btn-none.btn-day.flex-item").on("touchmove scroll", function () { $(".flex-row-mobile .choose-date > .btn.btn-none.btn-day.flex-item").scrollTop($(this).scrollTop()); }); $(".flex-row-mobile .choose-date > .btn.btn-none.btn-day.flex-item").scroll(function () { $(".flex-row-mobile .choose-date > .btn.btn-none.btn-day.flex-item").scrollTop($(this).scrollTop()); }); */ }, 500); } else $scope.status = 'nodata'; }) .error(function (e) { $scope.status = 'nodata'; }); }, 100); } var populateDoctorsTimes = function () { var doctorsTimes = []; _.forEach($scope.doctors, function (doc) { var calendar = []; _.forEach($scope.doctorsCalendar, function (item) { if (item.doctor_id === doc.doctor_id && item.basedate1000 === $scope.currentDayDoctors.basedate) { item.id = item.doctor_id + '_' + moment(item.datetime).valueOf(); calendar.push(item); } }); doctorsTimes[doc.doctor_id] = _.sortBy(calendar, 'datetime'); }); $scope.doctorsTimes = doctorsTimes; //setTimeout(function () { // var top = $('#doctorSection').offset().top - 250; // $("html, body").animate({ scrollTop: top }, 1000); //}, 700); } $scope.formatExamDate = function (examDate) { return moment(examDate).format('ddd D MMM. [ore:] HH:mm'); } $scope.getWeekDay = function (examDate) { return moment(examDate).format('ddd').toUpperCase(); } $scope.getMonth = function (examDate) { return moment(examDate).format('MMM').toUpperCase(); } $scope.getDay = function (examDate) { return moment(examDate).format('D'); } $scope.getHour = function (examDate) { return moment(examDate).format('HH:mm'); } $scope.hasMorning = function (items) { return _.filter(items, function (dt) { return moment(dt.first_occurrance).format('HH:mm') <= "13:59" }).length > 0; } $scope.hasAfternoon = function (items) { return _.filter(items, function (dt) { return moment(dt.first_occurrance).format('HH:mm') > "13:59" }).length > 0; } $scope.setSelectDate = function (val) { var date = moment(val.datetime); let insurance = _.filter($window.insurances, { "code": $window.insurance })[0]; $scope.wDoctorSelected = val; $scope.wDoctorSelectedText = 'Stai per prenotare:
' + $scope.exam_name + '
' + ((insurance) ? `Con assicurazione ${insurance.name}
in forma ${(val.provider_code === "I") ? "INDIRETTA" : "DIRETTA"}
` : "") + date.format('dddd DD MMMM') + ' alle ore ' + date.format('HH.mm'); }; $scope.trackAddToCart = function (wData) { var date = moment(wData.first_occurrance); var hours = date.diff(moment(), 'hours'); var days = date.diff(moment(), 'hours'); var _learnq = $window._learnq || []; _learnq.push(["track", "Added to Cart", { "$value": wData.exam_price, "AddedItemProductName": wData.exam_name, "AddedItemProductID": wData.exam_code, "AddedItemSKU": wData.exam_code, "AddedItemCategories": ["Exam", "Doctor", $window.hospitalName[wData.struttura.toLowerCase()].name], "AddedItemImageURL": "", "AddedItemURL": window.location.href.split("?")[0], "AddedItemPrice": wData.exam_price, "AddedItemQuantity": 1, "ItemNames": [wData.exam_code], "CheckoutURL": "", "Items": [] }]); $window.track('Appointment', 'Visit Selected', { }, { 'currencyCode': 'EUR', 'add': { 'actionField': { 'list': 'Appointment Search' }, 'products': [{ name: $scope.exam_name, id: $scope.exam_code, price: wData.exam_price, brand: $window.hospitalName[wData.struttura.toLowerCase()].name, category: 'Appointment', doctorId: (wData.doctor_unique_code && wData.doctor_unique_code !== '') ? wData.doctor_unique_code : "MEDICAL_EQUIPE", doctorName: (wData.doctor_unique_code && wData.doctor_unique_code !== '') ? wData.doctor_fullname : "Medical Equipe", quantity: 1 }] } } ); } } ]); })(angular, angular.module('frontoffice.controllers'), jQuery, _, moment); (function (ng, ngmodule, $, _, moment) { ngmodule.controller('BookingCalendarPDController', ['$scope', 'apiUrl', '$http', '$timeout', '$window', '$modal', function ($scope, apiUrl, $http, $timeout, $window, $modal) { //$scope.exam_id inizializzato nel dom $scope.status = 'isloading'; $scope.room = ''; $scope.agendaMap = {}; $scope.generalPrice = null; $scope.generalCalendar = null; $scope.generalSelected = null; $scope.generalSelectedText = null; $scope.filterdata = {}; $scope.searchForm = {}; $scope.searchForm.hour_selected = 'qualsiasi'; $scope.searchForm.hours = ['qualsiasi', '08-10', '10-12', '12-14', '14-16', '16-18', 'dopo le 18']; $window.insurance = getParameterByName("Insurance"); $window.ssn = getParameterByName("SSN") !== null ? getParameterByName("SSN") == 'true' : false; $scope.IsSSN = function () { return $window.ssn; }; $scope.currentDayDoctors = null; $scope.doctors = []; $scope.doctorDays = []; $scope.doctorsCalendar = null; $scope.doctorTimes = []; $scope.wDoctorSelected = null; $scope.wDoctorSelectedText = null; $scope.monthsAvailDates = []; $scope.doctorId = null; $scope.data = {}; $scope.data.nodoctor = false; $scope.standards_of_preparation = ""; $scope.filtershide = true; $scope.dayMonths = []; /** * Number.prototype.format(n, x, s, c) * * @param integer n: length of decimal * @param integer x: length of whole part * @param mixed s: sections delimiter * @param mixed c: decimal delimiter */ Number.prototype.format = function (n, x, s, c) { var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')', num = this.toFixed(Math.max(0, ~~n)); return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ',')); }; for (var i = 1; i <= 31; i++) { $scope.dayMonths.push((i < 10) ? "0" + i : "" + i); } $scope.getHospitalName = function (code) { return $window.hospitalName[code.toLowerCase()].name; } $scope.getWeekDayWell = function (examDate) { var date = moment(examDate); var today = moment().endOf('day'); var tomorrow = moment().add(1, 'day').endOf('day'); var stringDay = ""; if (date < today) stringDay = 'Oggi'; else if (date < tomorrow) stringDay = 'Domani'; else stringDay = date.format('ddd'); return stringDay; } if (!($window.insurances)) { $timeout(function () { $http.get(apiUrl + '/insurance', { }).then(function (response) { var data = response.data; $window.insurances = data; }); }); } $scope.getOrariPrelievo = function (hosp) { switch (hosp) { case "ICHPFI": { if ($scope.IsSSN()) return "dalle 10:00 alle 11:00"; else return "dalle 07:30 alle 11:00"; } case "ICHPIO": return "dalle 07:30 alle 10:00"; case "ICHPAS": case "ICHPPO": case "ICHPPR": case "ICHPLI": return "dalle 07:30 alle 10:30"; default: return "dalle 07:00 alle 10:30"; } } $scope.getNotePrelievo = function (hosp) { let orario = $scope.getOrariPrelievo(hosp.toUpperCase()); switch (hosp.toUpperCase()) { case "ICHPIO": { return "L’accesso libero presso il Punto Prelievi è " + orario + "\nE’ possibile accedere con l’impegnativa del medico senza prenotazione ed effettuare tutti i principali esami di laboratorio per adulti." + "\nE’ possibile prenotare ed effettuare esami di laboratorio per bambini e neonati " + "\nI campioni verranno analizzati presso il laboratorio di Humanitas San Pio X"; } case "ICHPPO": { if ($scope.IsSSN()) { return "

Orari Centro Prelievi

" + "
Lunedì - Venerdì
" + "