(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', '
{{message}}
{{message}}
{{message}}
' + '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:\nE’ necessario essere in possesso di prescrizione medica." + "\n Alcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" + " https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/"; } else { return "Il punto prelievi è accessibile senza prenotazione dal lunedì al sabato dalle 7:30 - 10:30" + "\nE’ necessario essere in possesso di prescrizione medica." + "\n Alcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" + " https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/"; } } case "ICHPAS": { if ($scope.IsSSN()) { return "
\nE’ necessario essere in possesso di prescrizione medica." + "\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" + " https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/"; } else { return "Il punto prelievi è accessibile senza prenotazione dal lunedì al sabato dalle 7:30 - 10:30" + "\nE’ necessario essere in possesso di prescrizione medica." + "\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" + " https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/"; } } case "ICHPFI": { if ($scope.IsSSN()) { return "
\nE’ necessario essere in possesso di prescrizione medica." +
"\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" +
" https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/";
} else
{
return "Il punto prelievi è accessibile senza prenotazione dal lunedì al sabato dalle 7:30 - 11:00" +
"\nE’ necessario essere in possesso di prescrizione medica." +
"\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" +
" https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/";
}
}
case "ICHPRE": return "Il punto prelievi è accessibile senza prenotazione dal lunedì al sabato dalle 7:30 - 10:30" +
"\nE’ necessario essere in possesso di prescrizione medica." +
"\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" +
" https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/";
case "ICHPPR":
return "Il punto prelievi è accessibile senza prenotazione dal lunedì al sabato dalle 7:30 - 10:30" +
"\nE’ necessario essere in possesso di prescrizione medica." +
"\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" +
" https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/";
case "ICHPLI":
return "Il punto prelievi è accessibile senza prenotazione dal lunedì al sabato dalle 7:30 - 10:30" +
"\nE’ necessario essere in possesso di prescrizione medica." +
"\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" +
" https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/";
default:
return "L’accesso libero presso il Punto Prelievi è " + orario +
"\nAlcuni esami sono eseguibili con limitazione di giorno e orario. E' possibile consultare il dettaglio alla pagina:" +
" https://www.humanitas-care.it/esami-di-laboratorio-eccezioni-di-disponibilita-orario-e-accesso/";
}
}
$scope.showHospital = function (hosp, prelievo)
{
var controller = 'ChooseFormHospitalController';
var template = 'singleHospitalInfoDialog';
var orario = $scope.getOrariPrelievo(hosp);
var datainfo = (prelievo === 'true')? $scope.getNotePrelievo(hosp) : "";
$modal.open({
windowClass: 'sidepanel hospitals-container right',
template: $('#' + template).html(),
controller: controller,
resolve: {
selected: function ()
{
return hosp;
},
sourceData: function ()
{
return {
"exam_name": $scope.exam_name,
"exam_code": $scope.exam_code,
"exam_seo": $scope.exam_seo,
"hospital": hosp,
"datainfo": datainfo
};
}
}
}).result.then(function ()
{
}, function ()
{
})['finally'](function ()
{
$scope.modalInstance = undefined; // <--- This fixes
});
};
$scope.showContract = function (type)
{
var insurance = _.filter($window.insurances, { code: getParameterByName("Insurance") })[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)
{
});
};
$scope.showForm = function (ssn)
{
var controller = 'ChooseFormHospitalController';
var template = '';
if (ssn === true)
{
template = 'formssn'
} else
{
template = 'formlp';
}
$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.modalInstance = undefined // <--- This fixes
});
};
$scope.filtershideToggle = function ()
{
$scope.filtershide = !$scope.filtershide;
}
$scope.isFieldValid = function (a) { return $scope.reservForm[a].$valid; }
$scope.isFormValid = function ()
{
return $scope.reservForm.$valid;
}
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, 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.forms[formName].submit();
}
});
}
$scope.changeStatus = function (status) { $scope.status = status;; }
$scope.reservation = { is_chronic: false, read_standard_preparation: false, privacy: false };
$scope.currentDoctorTimeId = null;
$scope.GetFirstAvailability = function (hours)
{
$timeout(function ()
{
var serviceUrl = apiUrl + 'examdetail/' + $scope.exam_id + '/calendarpd';
$http({
method: 'GET',
url: serviceUrl,
params: {
'hours': getParameterByName("Hours"), 'weekdays': getParameterByName("Weekdays"),
"doctGender": getParameterByName("doctGender"),
"doctAge": getParameterByName("doctAge"),
"insurance": $window.insurance, 'hospital': $window.hospital, 'SSN': $window.ssn
}
})
.success(function (calendarData)
{
var minprice = null;
data = calendarData.items;
$scope.searchForm.hour_selected = calendarData.hours_selected;
$scope.hours_selected = calendarData.hours_selected;
if (!_.isUndefined(data) && !_.isNull(data) && _.isArray(data) && (data.length > 0))
{
var dataByPrice = _.sortBy(data, 'datetime_double');
minprice = dataByPrice[0].price;
}
var _learnq = $window._learnq || [];
var item = {
"ProductName": $scope.exam_name,
"ProductID": $scope.exam_code,
"SKU": $scope.exam_code,
"Categories": ["Exam"],
"ImageUrl": 'https://stage-prenota.humanitas.it/Content/Images/referti.png',
"Url": $window.location.href,
"Brand": "Exam",
"Price": minprice,
"CompareAtPrice": 0.00,
};
_learnq.push(["track", "Viewed Product", item]);
$window.track('Appointment', 'Visit Details Viewed', {},
{
'detail': {
'actionField': { list: 'Appointment Search' },
'products': [{
name: $scope.exam_name,
id: $scope.exam_code,
brand: 'notselected',
category: 'Exam',
price: minprice
}]
}
});
if (!_.isUndefined(data) && !_.isNull(data) && _.isArray(data) && (data.length > 0))
{
// prepare istitutional calendar
data = _.map(data, function (d) { d.price_string = Number(d.price).format(2, 3, '.', ','); return d; });
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';
});
//dayGroups = _.sortBy(dayGroups , "datetime_double");
dayGroups = _(dayGroups).chain().sortBy(function (dayG)
{
return dayG.struttura;
}).sortBy(function (dayG)
{
return dayG.datetime_double;
}).value();
$scope.generalFirstAvailabilities = [];
_.forEach(_.groupBy(dayGroups, 'struttura'), function (e, key)
{
var date = moment(parseInt(e[0].basedate1000));
e[0].dayI = _.filter(e, { "provider_code": "I" })[0];
e[0].dayD = _.filter(e, { "provider_code": "D" })[0];
$scope.generalFirstAvailabilities.push({
name: "",
description: "",
exam_ist: true,
exam_id: $scope.exam_id,
exam_name: $scope.exam_name,
exam_code: $scope.exam_code,
price_string: Number(e[0].price).format(2, 3, '.', ','),
first_availability: parseInt(e[0].datetime_double),
struttura:key,
month: date.format('MMMM YYYY'),
wkDay: date.format('ddd'),
day_of_month: date.format('DD'),
day: e[0]
});
});
if ($scope.generalFirstAvailabilities.length > 0 &&
$scope.generalFirstAvailabilities[0].day.is_chronic)
{
$scope.status = 'ischronic';
$scope.reservation.is_chronic = true;
/*setTimeout(function () {
$("#gensubmitbutton").click();
//console.log('genSubmit');
},100);*/
}
dayGroups = _.groupBy(dayGroups, function (v) { return v.struttura + v.basedate1000 });
var generalCalendar = [];
_.forEach(dayGroups, function (group, key)
{
var date = moment(parseInt(group[0].basedate1000));
generalCalendar.push({
exam_ist: true,
exam_id: $scope.exam_id,
exam_code: $scope.exam_code,
exam_name: $scope.exam_name,
struttura: group[0].struttura,
date: date.format('DD MMM'),
items: group,
wkDay: date.format('ddd'),
month: date.format('MMMM YYYY'),
day_of_month: date.format('DD'),
});
});
$scope.generalCalendar = generalCalendar;
if (ng.isDefined($scope.generalCalendar) && $scope.generalCalendar.length > 0 && $scope.generalCalendar[0].items.length > 0)
{
$scope.generalPrice = Number($scope.generalCalendar[0].items[0].price).format(2, 3, '.', ',');
}
// IST price doctor handler
$scope.doctorsCalendar = _.filter(data, function (day) { return day.tipo_contratto == 'LP';; });
if ($window.insurance !== "")
{
$scope.doctorsCalendar = _.map(_.groupBy($scope.doctorsCalendar, function (d)
{
return d.struttura + d.doctor_id;
}), function (e, key)
{
var date = moment(parseInt(e[0].basedate1000));
e[0].dayI = _.filter(e, { "provider_code": "I" })[0];
e[0].dayD = _.filter(e, { "provider_code": "D" })[0];
return e[0];
});
}
if ($scope.doctorsCalendar.length === 0 && $scope.doctorsCalendar) { $scope.doctorsCalendar = null; }
$scope.doctorsCalendar = _($scope.doctorsCalendar).chain().sortBy(function (dayG)
{
return dayG.struttura;
}).sortBy(function (dayG)
{
return dayG.datetime_double;
}).value();
$scope.struttureS = _.keys(_.groupBy(_.union($scope.generalCalendar, $scope.doctorsCalendar), 'struttura'));
$scope.selectedstrutture_bknd = (window.hospital != "") ? window.hospital.split("|") : [];
// $scope.strutture = _.uniq(_.union($scope.struttureS, _.map(_.groupBy(window.hospitalName, 'name'), function (h) { return h[0].key })));
$scope.strutture = $scope.struttureS;
$scope.selectedstrutture = _.map($scope.strutture, function (s)
{
return { before: (_.contains($scope.struttureS, s)) ? 0 : 1, results: _.contains($scope.struttureS, s), checked: ((_.contains($scope.selectedstrutture_bknd, s) && _.contains($scope.struttureS, s) && window.hospital != "") ? true : false), struttura: s, name: window.hospitalName[s.toLowerCase()].place + " - " + window.hospitalName[s.toLowerCase()].name };
});
if ($scope.exam_code === 'COV19G')
{
$scope.strutture = _.filter($scope.strutture, function (s) { return (s !== "ICH"); });
}
if ($scope.selectedstrutture_bknd.length < $scope.selectedstrutture.length
&& _.filter($scope.selectedstrutture, { checked: true }).length == 0)
{
//
if (!$scope.exam_isrestricted)
{
try
{
var hospitalNameSel = _.map($scope.selectedstrutture_bknd, function (strutt)
{
return window.hospitalName[strutt.toLowerCase()].name;
});
var modalInstanceS = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return 'Attenzione'; },
message: function () { return '' },
bodyhtml: function ()
{
return 'Nessuna disponiblilità per la prestazione selezionata per ' + (($scope.selectedstrutture_bknd.lenght > 1) ? 'le strutture selezionate' : 'la struttura selezionata') +
' ' + hospitalNameSel.join(', ') + ' di seguito vengono mostrate le disponibilità per le altre strutture.'
},
buttons: function ()
{
return [{
label: 'Ok',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result === 0)
{
//$scope.status = 'isloading';
}
});
} catch (e)
{
console.error(e);
}
$scope.selectedstrutture = _.map($scope.selectedstrutture, function (s)
{
s.checked = false;
return s;
});
} else
{
$scope.generalCalendar = [];
$scope.doctorsCalendar = [];
$scope.status = 'nodata';
return;
}
}
function convertToNumbers(str)
{
if (!str) return "0";
var arr = "abcdefghijklmnopqrstuvwxyz".split("");
var strAtt = [];
str = str.toLowerCase();
for (var intch = 0; intch < str.length; intch++)
{
var charat = str.charAt(intch);
if (arr.indexOf(charat) >= 0)
{
charat = arr.indexOf(charat) + 1;
}
strAtt.push(charat);
}
return strAtt.join("-");
}
var doctors = _.map(
$scope.doctorsCalendar
, function (day)
{
var date = moment(parseInt(day.basedate1000));
return {
doctor_fullname: day.doctor_fullname,
code: day.doctor_id + day.struttura,
doctor_unique_code: day.doctor_unique_code,
doctor_description: (day.doctor_description === "") ? " " : day.doctor_description,
doctor_id: day.doctor_id,
day: day,
exam_ist: false,
exam_id: $scope.exam_id,
exam_name: $scope.exam_name,
exam_code: $scope.exam_code,
price_string: Number(day.price).format(2, 3, '.', ','),
first_availability: parseInt(day.datetime_double),
month: date.format('MMMM YYYY'),
day_of_month: date.format('DD'),
wkDay: date.format('ddd'),
checked: false,
img: convertToNumbers(day.doctor_vatcode),
doctor_name: day.doctor_fullname.replace("Dott.ssa", "").replace("Dott.", "").replace("Prof.", "").replace(".ssa", "").trim()
};
});
doctors = _.uniq(doctors, function (d)
{
return d.doctor_id + d.day.struttura;
});
$scope.doctors = doctors;
$scope.refreshAvail = function ()
{
var genFiltered = $scope.generalCalendar;
genFiltered.forEach(function (g) { g.day = g.items[0]; });
genFiltered = _.filter(genFiltered, $scope.strutturaFilter);
var docFiltered = _.filter($scope.doctors, $scope.doctorFilter);
docFiltered = _.filter(docFiltered, $scope.strutturaFilter);
$scope.monthsAvailDates = _.map(_.keys(_.groupBy(_.union(($scope.IsDoctorSelected()) ? [] : genFiltered, docFiltered), 'month')),
function (m)
{
var dateM = moment(m, 'MMMM YYYY');
return {
month: dateM.format('MMMM YYYY'),
monthNumber: dateM.format('YYYY-MM')
}
});
};
$scope.$watch('selectedstrutture', function ()
{
$scope.refreshAvail();
}, true);
$scope.$watch('doctors', function ()
{
$scope.refreshAvail();
}, true);
$scope.refreshAvail();
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: date.format('ddd'),
items: _.where($scope.doctorsCalendar, { 'basedate1000': parseInt(basedate) })
};
});
$scope.doctorDays = _.sortBy(doctorDays, 'basedate1000');
if ($scope.doctorDays.length > 0)
$scope.currentDayDoctors = $scope.doctorDays[0];
$scope.status = 'hasresults';
populateDoctorsTimes();
} else
{
if (!calendarData.is_empty && ($scope.generalCalendar == null && $scope.doctorsCalendar == null || $scope.generalCalendar.length == 0 && $scope.doctorsCalendar.length == 0))
{
var urlParams = new URLSearchParams(window.location.search.split("#")[0]);
var doctAge = urlParams.get("doctAge").split('-');
$scope.filterdata = {
doctgender: (urlParams.get('doctGender') && urlParams.get('doctGender') !== "all") ? true : false,
hours: (urlParams.get('Hours') && urlParams.get('Hours') !== "all" && urlParams.get('Hours') !== "qualsiasi") ? true : false,
doctage: (urlParams.get('doctAge') && urlParams.get('doctAge') !== "all") ? true : false,
}
var html = " Il codice è stato inviato al numero Il codice non è stato trovato in anagrafica: Non sono presenti disponibilità di appuntamento
";
if ($scope.filterdata.hours) html+="per l’orario selezionato: " + calendarData.hours_selected + "
";
if ($scope.filterdata.doctage) html += "per dottore di eta' da " + doctAge[0] + ((doctAge[1]==="100")?" anni in su'":(" a " + doctAge[1]+ " anni") )+ "
";
if ($scope.filterdata.doctgender) html += "per dottore di sesso : " + ((urlParams.get('doctGender')==="M")?"Maschile":"Femminile") + "
";
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: 'Vedi altre disponibilità',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
$window.location = $window.location.href.split("?")[0];
});
$scope.status = 'nodata_per_filters';
} else
{
$scope.status = 'nodata';
}
}
})
.error(function (e)
{
$scope.status = 'nodata';
});
}, 100);
}
$scope.GetFirstAvailability("");
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 + '_' + item.struttura + '_' + moment(item.datetime).valueOf();
calendar.push(item);
}
});
doctorsTimes[doc.code] = _.sortBy(calendar, 'datetime');
});
$scope.doctorsTimes = doctorsTimes;
}
$scope.formatExamDate = function (examDate)
{
return moment(examDate).format('ddd D MMM. [ore:] HH:mm');
}
$scope.strutturaFilter = function (item)
{
var letFilteredStruttura = _.filter($scope.selectedstrutture, function (s) { return s.checked === true; });
if (letFilteredStruttura.length > 0 && item.day !== undefined)
{
if (_.findWhere(letFilteredStruttura, { 'struttura': item.day.struttura }) !== undefined) return item;
} else
{
return item;
}
};
$scope.IsDoctorSelected = function ()
{
var letFilteredDoctor = _.filter($scope.doctors, function (s) { return s.checked === true; });
return (letFilteredDoctor.length > 0 && $scope.data.nodoctor == false);
}
$scope.doctorFilter = function (item)
{
if ($scope.data.nodoctor === false)
{
var letFilteredDoctor = _.filter($scope.doctors, function (s) { return s.checked === true; });
if (letFilteredDoctor.length > 0)
{
if (_.findWhere(letFilteredDoctor, { 'doctor_name': item.doctor_name }) !== undefined) return item;
} else
{
return item;
};
}
};
$scope.resetFilters = function ()
{
$scope.doctors.forEach(function (d) { d.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.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('dddd');
else stringDay = date.format('ddd D MMM');
return stringDay + " " + moment(examDate).format('[ore] HH:mm');
}
$scope.GetOtherDescription4Exam = function (hospital, exam_code)
{
switch (hospital.toUpperCase())
{
case "MCHMON":
case "MCHDEA":
{
switch (exam_code.toUpperCase())
{
case "RMNCAVD0":
case "RMNCAVS0":
case "RMNCER00":
case "RMNDOR00":
case "RMNGNOD0":
case "RMNGNOS0":
case "RMNGOMD0":
case "RMNGOMS0":
case "RMNLOM00":
case "RMNPOLD0":
case "RMNPOLS0":
case "RMNSPAD0":
case "RMNSPAS0":
case "PK2RMN0CD":
case "PK2RMN0CL":
case "PK2RMN0DL":
case "RMNADI00":
case "RMNADS00":
case "RMNBAC00":
case "RMNMAX00":
case "RMNENC00":
case "RMNTOR00":
case "RMNCLL00":
case "RMNFEMD0":
case "RMNFEMS0":
case "ROURMNADD":
case "ROURMNCTO00":
{
return " TARIFFA NUOVO CENTRO ";
}
default: return "";
}
}
default:
return "";
}
}
$scope.getDay = function (examDate)
{
return moment(examDate).format('DD');
}
$scope.getHour = function (examDate)
{
return moment(examDate).format('HH:mm');
}
$scope.getHour4Digit = function (examDate)
{
return moment(examDate).format('HHmm');
}
$scope.countStrutturaSelected = function ()
{
var letFilteredStruttura = _.filter($scope.selectedstrutture, function (s) { return s.checked === true; });
if (letFilteredStruttura.length == 0 || letFilteredStruttura.length == $scope.selectedstrutture)
{
return "Tutto (" + $scope.selectedstrutture.length + ")";
} else
{
return "Selezione (" + letFilteredStruttura.length + ")";
}
}
$scope.countDoctorSelected = function ()
{
var uniqueDoctors = _.uniq($scope.doctors, function (d)
{
return d.doctor_name;
});
var letFilteredDoctor = _.filter($scope.uniqueDoctors, function (s) { return s.checked === true; });
if (letFilteredDoctor.length == 0 || letFilteredDoctor.length == $scope.doctors)
{
return "Tutto (" + uniqueDoctors.length + ")";
} else
{
return "Selezione (" + letFilteredDoctor.length + ")";
}
}
$scope.bookingCollapseGeneral = function (general)
{
if (window.innerWidth <= 767 || true)
{
if ($("body").hasClass("modal-open"))
{
$("body").removeClass("modal-open");
} else
{
$("body").addClass("modal-open");
}
}
if ($scope.booktype == general.day.struttura)
{
$scope.booktype = '';
} else
{
$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';
}
// $("html, body").animate({ scrollTop: 0 }, 1000);
}
$scope.bookingCollapseDoctor = function (doctor)
{
if (window.innerWidth <= 767 || true)
{
if ($("body").hasClass("modal-open"))
{
$("body").removeClass("modal-open");
} else
{
$("body").addClass("modal-open");
}
}
if ($scope.booktype === doctor.doctor_id + doctor.day.struttura)
{
$scope.booktype = '';
} else
{
$scope.booktype = doctor.doctor_id + doctor.day.struttura;
$scope.doctorId = doctor.doctor_id;
$scope.struttura = doctor.day.struttura;
$scope.room = doctor.day.room;
$scope.standards_of_preparation = doctor.day.standards_of_preparation;
$scope.agendaMap = doctor.day.struttura + doctor.day.room;
}
}
}
]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _, moment);
(function (ng, ngmodule, $, _) {
ngmodule.controller('ChooseDoctorsController', ['$scope', '$modalInstance', 'sourceData', function ($scope, $modalInstance, sourceData) {
$scope.doctors = sourceData;
$scope.selectAll = function () {
$scope.doctors.forEach(function (d) {
d.checked = true;
})
};
$scope.deselectAll = function () {
$scope.doctors.forEach(function (d) {
d.checked = false;
})
};
$scope.apply = function () {
var counter = 0;
ng.forEach($scope.doctors, function (item) {
if (item.checked) ++counter;
});
var sizeuniq = _.uniq(sourceData, function (d) { return d.doctor_name }).length;
if (counter === 0) {
counter = sizeuniq;
}
$modalInstance.close({
'title': 'Dottori: ',
'subtitle': (sizeuniq === counter ? 'Tutto' : 'Selezione') + ' (' + counter + ')'
});
}
$scope.close = function () {
$scope.apply();
//$modalInstance.close(-1);
}
$scope.$on('modal.closing', function (event, reason, closed) {
if (!closed)
$scope.apply();
});
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('ChooseFormHospitalController', ['$scope', '$modalInstance', 'apiUrl', 'sourceData', '$window', 'Utils','$sce',
function ($scope, $modalInstance, apiUrl, sourceData, $window, Utils, $sce) {
$scope.sourceData = sourceData;
// Removing object from
// associative array
$scope.status = "";
$scope.title = $scope.sourceData.title || "Convezioni ";
$scope.datainfo = $sce.trustAsHtml($scope.sourceData.datainfo || "");
$scope.subtitle = $scope.sourceData.subtitle || "";
$scope.hospital = $scope.sourceData.hospital || "";
$scope.hospitals = Utils.getHospitalsFormUrl($scope.sourceData.exam_name, $scope.sourceData.exam_seo, $scope.sourceData.exam_code);
$scope.hospitals = _.filter($scope.hospitals, function (h) { return new RegExp(window.hospital).test(h.key); });
//delete $scope.hospitals['MCHMON'];
delete $scope.hospitals['ICHPLI'];
delete $scope.hospitals['ICHPPO'];
$scope.dove = _.keys($window.hospitalName).join("|");
$scope.apply = function () {
$scope.close(-1);
}
$scope.close = function () {
$modalInstance.close(-1);
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('ChooseHospitalController', ['$scope', '$modalInstance', '$window', function ($scope, $modalInstance, $window) {
//$scope.hospitals = [{
// title: 'Milano Sud',
// subtitle: 'Rozzano',
// value: 'ICH'
//}, {
// title: 'Milano Sud',
// subtitle: 'Fiordaliso',
// value: 'ICHFIO'
//}, {
// title: 'Milano Città',
// subtitle: 'Premuda',
// value: 'ICHPRE'
//}, {
// title: 'Milano Città',
// subtitle: 'San Pio X',
// value: 'ICHFIO'
//}
//, {
// title: 'Milano Città',
// subtitle: 'De Angeli',
// value: 'MCHDEA'
//}, {
// title: 'Milano Nord',
// subtitle: 'Bresso',
// value: 'ICHBRE'
//}, {
// title: 'Milano Nord',
// subtitle: 'Arese',
// value: 'ARS'
//}, {
// title: 'Milano Nord',
// subtitle: 'Lainate',
// value: 'LAI'
//}, {
// title: 'Varese',
// subtitle: 'Busto Arsizio',
// value: 'BUS'
//}, {
// title: 'Varese',
// subtitle: 'Varese Città',
// value: 'CDV|CDVDIA'
//}];
$scope.athome = false;
var citiesMap =
{
'Albizzate': 'VA',
'Arcisate': 'VA',
'Arese': 'mi',
'Arluno': 'mi',
'Arsago Seprio': 'VA',
'Azzate': 'VA',
'Azzio': 'VA',
'Baranzate': 'mi',
'Barasso': 'VA',
'Bardello': 'VA',
'Bareggio': 'mi',
'Bedero Valcuvia': 'VA',
'Besano': 'VA',
'Besnate': 'VA',
'Biandronno': 'VA',
'Bisuschio': 'VA',
'Bodio Lomnago': 'VA',
'Bollate': 'mi',
'Bovisio-Masciago': 'MB',
'Bregano': 'VA',
'Brenta': 'VA',
'Bresso': 'mi',
'Brinzio': 'VA',
'Brunello': 'VA',
'Buguggiate': 'VA',
'Busto Arsizio': 'VA',
'Cadrezzate': 'VA',
'Cairate': 'VA',
'Canegrate': 'mi',
'Cantello': 'VA',
'Caravate': 'VA',
'Cardano al Campo': 'VA',
'Carnago': 'VA',
'Caronno Pertusella': 'VA',
'Caronno Varesino': 'VA',
'Casale Litta': 'VA',
'Casalzuigno': 'VA',
'Casciago': 'VA',
'Casorate Sempione': 'VA',
'Casorezzo': 'mi',
'Cassano Magnago': 'VA',
'Cassano Valcuvia': 'VA',
'Castellanza': 'VA',
'Castello Cabiaglio': 'VA',
'Castelseprio': 'VA',
'Castiglione Olona': 'VA',
'Castronno': 'VA',
'Cavaria con Premezzo': 'VA',
'Cazzago Brabbia': 'VA',
'Ceriano Laghetto': 'MB',
'Cerro Maggiore': 'mi',
'Cesate': 'mi',
'Cinisello Balsamo': 'mi',
'Cislago': 'VA',
'Clivio': 'VA',
'Cocquio-Trevisago': 'VA',
'Comabbio': 'VA',
'Comerio': 'VA',
'Cormano': 'mi',
'Cornaredo': 'mi',
'Crosio della Valle': 'VA',
'Cuasso al Monte': 'VA',
'Cusano Milanino': 'VA',
'Cuveglio': 'VA',
'Cuvio': 'VA',
'Daverio': 'VA',
'Duno': 'VA',
'Fagnano Olona': 'VA',
'Ferno': 'VA',
'Gallarate': 'VA',
'Galliate Lombardo': 'VA',
'Garbagnate Milanese': 'VA',
'Gavirate': 'VA',
'Gazzada Schianno': 'VA',
'Gemonio': 'VA',
'Gerenzano': 'VA',
'Golasecca': 'VA',
'Gorla Maggiore': 'VA',
'Gorla Minore': 'VA',
'Gornate Olona': 'VA',
'Inarzo': 'VA',
'Induno Olona': 'VA',
'Jerago con Orago': 'VA',
'Lainate': 'VA',
'Legnano': 'VA',
'Limbiate': 'MB',
'Lonate Ceppino': 'VA',
'Lonate Pozzolo': 'VA',
'Lozza': 'VA',
'Luvinate': 'VA',
'Malgesso': 'VA',
'Malnate': 'VA',
'Marnate': 'VA',
'Masciago Primo': 'VA',
'Mercallo': 'VA',
'Morazzone': 'VA',
'Mornago': 'VA',
'Nerviano': 'VA',
'Nova Milanese': 'MB',
'Novate Milanese': 'mi',
'Oggiona con Santo Stefano': 'VA',
'Olgiate Olona': 'VA',
'Origgio': 'VA',
'Orino': 'VA',
'Osmate': 'VA',
'Paderno Dugnano': 'mi',
'Parabiago': 'mi',
'Pero': 'mi',
'Pogliano Milanese': 'mi',
'Porto Ceresio': 'VA',
'Pregnana Milanese': 'mi',
'Rancio Valcuvia': 'VA',
'Rescaldina': 'mi',
'Rho': 'mi',
'Saltrio': 'VA',
'Samarate': 'VA',
'San Giorgio Su Legnano': 'mi',
'San Vittore Olona': 'mi',
'Saronno': 'VA',
'Sedriano': 'mi',
'Senago': 'mi',
'Sesto Calende': 'VA',
'Solaro': 'mi',
'Solbiate Arno': 'VA',
'Solbiate Olona': 'VA',
'Somma Lombardo': 'VA',
'Sumirago': 'VA',
'Ternate': 'VA',
'Tradate': 'VA',
'Travedona-Monate': 'VA',
'Uboldo': 'VA',
'Valganna': 'VA',
'Vanzago': 'mi',
'Varano Borghi': 'VA',
'Varedo': 'MB',
'Varese': 'VA',
'Vedano Olona': 'VA',
'Venegono Inferiore': 'VA',
'Venegono Superiore': 'VA',
'Vergiate': 'VA',
'Viggiù': 'VA',
'Vittuone': 'mi',
'Vizzola Ticino': 'VA',
"Albano Sant'Alessandro": "BG",
"Albino": "BG",
"Almè": "BG",
"Almenno San Bartolomeo": "BG",
"Almenno San Salvatore": "BG",
"Alzano Lombardo": "BG",
"Ambivere": "BG",
"Antegnate": "BG",
"Arcene": "BG",
"Ardesio": "BG",
"Arzago d'Adda": "BG",
"Azzano San Paolo": "BG",
"Bagnatica": "BG",
"Barbata": "BG",
"Bariano": "BG",
"Barzana": "BG",
"Bergamo": "BG",
"Bolgare": "BG",
"Boltiere": "BG",
"Bonate Sopra": "BG",
"Bonate Sotto": "BG",
"Borgo di Terzo": "BG",
"Bossico": "BG",
"Bottanuco": "BG",
"Brembate": "BG",
"Brembate di Sopra": "BG",
"Brignano Gera d'Adda": "BG",
"Brusaporto": "BG",
"Calcinate": "BG",
"Calcio": "BG",
"Calusco d'Adda": "BG",
"Calvenzano": "BG",
"Canonica d'Adda": "BG",
"Capriate San Gervasio": "BG",
"Caprino Bergamasco": "BG",
"Caravaggio": "BG",
"Carobbio degli Angeli": "BG",
"Carvico": "BG",
"Casirate d'Adda": "BG",
"Castel Rozzone": "BG",
"Castelli Calepio": "BG",
"Cavernago": "BG",
"Cenate Sopra": "BG",
"Cenate Sotto": "BG",
"Chignolo d'Isola": "BG",
"Chiuduno": "BG",
"Cisano Bergamasco": "BG",
"Ciserano": "BG",
"Cividate al Piano": "BG",
"Cologno al Serio": "BG",
"Comun Nuovo": "BG",
"Cortenuova": "BG",
"Costa di Mezzate": "BG",
"Covo": "BG",
"Curno": "BG",
"Dalmine": "BG",
"Entratico": "BG",
"Fara Gera d'Adda": "BG",
"Fara Olivana con Sola": "BG",
"Filago": "BG",
"Fino del Monte": "BG",
"Fontanella": "BG",
"Fornovo San Giovanni": "BG",
"Gandosso": "BG",
"Ghisalba": "BG",
"Gorlago": "BG",
"Gorle": "BG",
"Grassobbio": "BG",
"Grone": "BG",
"Grumello del Monte": "BG",
"Isso": "BG",
"Lallio": "BG",
"Levate": "BG",
"Lurano": "BG",
"Luzzana": "BG",
"Madone": "BG",
"Mapello": "BG",
"Martinengo": "BG",
"Medolago": "BG",
"Misano di Gera d'Adda": "BG",
"Montello": "BG",
"Morengo": "BG",
"Mornico al Serio": "BG",
"Mozzanica": "BG",
"Mozzo": "BG",
"Nembro": "BG",
"Orio al Serio": "BG",
"Osio Sopra": "BG",
"Osio Sotto": "BG",
"Pagazzano": "BG",
"Paladina": "BG",
"Palazzago": "BG",
"Palosco": "BG",
"Pedrengo": "BG",
"Pognano": "BG",
"Ponte San Pietro": "BG",
"Ponteranica": "BG",
"Pontida": "BG",
"Pontirolo Nuovo": "BG",
"Pradalunga": "BG",
"Presezzo": "BG",
"Pumenengo": "BG",
"Ranica": "BG",
"Romano di Lombardia": "BG",
"San Paolo d'Argon": "BG",
"Sant'Omobono Terme": "BG",
"Scanzorosciate": "BG",
"Seriate": "BG",
"Sorisole": "BG",
"Sotto il Monte Giovanni XXIII": "BG",
"Spirano": "BG",
"Stezzano": "BG",
"Suisio": "BG",
"Telgate": "BG",
"Terno d'Isola": "BG",
"Torre Boldone": "BG",
"Torre de' Roveri": "BG",
"Torre Pallavicina": "BG",
"Trescore Balneario": "BG",
"Treviglio": "BG",
"Treviolo": "BG",
"Urgnano": "BG",
"Valbrembo": "BG",
"Verdellino": "BG",
"Verdello": "BG",
"Villa d'Adda": "BG",
"Villa d'Almè": "BG",
"Villa di Serio": "BG",
"Zandobbio": "BG",
"Zanica": "BG",
//"MILANO": "MI",
"Assago": { "pv": "MI", "hospital": "ICH" },
"Basiglio": { "pv": "MI", "hospital": "ICH" },
"Binasco": { "pv": "MI", "hospital": "ICH" },
"Buccinasco": { "pv": "MI", "hospital": "ICH" },
"Casarile": { "pv": "MI", "hospital": "ICH" },
"Cesano Boscone": { "pv": "MI", "hospital": "ICH" },
"Corsico": { "pv": "MI", "hospital": "ICH" },
"Cusago": { "pv": "MI", "hospital": "ICH" },
"Lacchiarella": { "pv": "MI", "hospital": "ICH" },
"Locate di Triulzi": { "pv": "MI", "hospital": "ICH" },
"Noviglio": { "pv": "MI", "hospital": "ICH" },
"Opera": { "pv": "MI", "hospital": "ICH" },
"Pieve Emanuele": { "pv": "MI", "hospital": "ICH" },
"Rozzano": { "pv": "MI", "hospital": "ICH" },
"Trezzano sul Naviglio": { "pv": "MI", "hospital": "ICH" },
"Zibido San Giacomo": { "pv": "MI", "hospital": "ICH" },
"Carpiano": { "pv": "MI", "hospital": "ICH" },
"Cerro al Lambro": { "pv": "MI", "hospital": "ICH" },
"Colturano": { "pv": "MI", "hospital": "ICH" },
"Dresano": { "pv": "MI", "hospital": "ICH" },
"Mediglia": { "pv": "MI", "hospital": "ICH" },
"Melegnano": { "pv": "MI", "hospital": "ICH" },
"Pantigliate": { "pv": "MI", "hospital": "ICH" },
"Paullo": { "pv": "MI", "hospital": "ICH" },
"Peschiera Borromeo": { "pv": "MI", "hospital": "ICH" },
"San Colombano al Lambro": { "pv": "MI", "hospital": "ICH" },
"San Donato Milanese": { "pv": "MI", "hospital": "ICH" },
"San Giuliano Milanese": { "pv": "MI", "hospital": "ICH" },
"San Zenone al Lambro": { "pv": "MI", "hospital": "ICH" },
"Tribiano": { "pv": "MI", "hospital": "ICH" },
"Vizzolo Predabissi": { "pv": "MI", "hospital": "ICH" },
"Abbiategrasso": { "pv": "MI", "hospital": "ICH" },
"Albairate": { "pv": "MI", "hospital": "ICH" },
"Arconate": { "pv": "MI", "hospital": "ICHPIO" },
"Basiano": { "pv": "MI", "hospital": "ICHPIO" },
"Bellinzago Lombardo": { "pv": "MI", "hospital": "ICHPIO" },
"Bernate Ticino": { "pv": "MI", "hospital": "ICHPIO" },
"Besate": { "pv": "MI", "hospital": "ICH" },
"Boffalora sopra Ticino": { "pv": "MI", "hospital": "ICHPIO" },
"Bubbiano": { "pv": "MI", "hospital": "ICH" },
"Buscate": { "pv": "MI", "hospital": "ICHPIO" },
"Bussero": { "pv": "MI", "hospital": "ICHPIO" },
"Busto Garolfo": { "pv": "MI", "hospital": "ICHPIO" },
"Calvignasco": { "pv": "MI", "hospital": "ICH" },
"Cambiago": { "pv": "MI", "hospital": "ICHPIO" },
"Carugate": { "pv": "MI", "hospital": "ICH" },
"Cassano d'Adda": { "pv": "MI", "hospital": "ICH" },
"Cassina de' Pecchi": { "pv": "MI", "hospital": "ICHPIO" },
"Cassinetta di Lugagnano": { "pv": "MI", "hospital": "ICH" },
"Castano Primo": { "pv": "MI", "hospital": "ICHPIO" },
"Cernusco sul Naviglio": { "pv": "MI", "hospital": "ICHPIO" },
"Cisliano": { "pv": "MI", "hospital": "ICH" },
"Cologno Monzese": { "pv": "MI", "hospital": "ICHPIO" },
"Corbetta": { "pv": "MI", "hospital": "ICHPIO" },
"Cuggiono": { "pv": "MI", "hospital": "ICHPIO" },
"Dairago": { "pv": "MI", "hospital": "ICHPIO" },
"Gaggiano": { "pv": "MI", "hospital": "ICH" },
"Gessate": { "pv": "MI", "hospital": "ICHPIO" },
"Gorgonzola": { "pv": "MI", "hospital": "ICHPIO" },
"Grezzago": { "pv": "MI", "hospital": "ICHPIO" },
"Gudo Visconti": { "pv": "MI", "hospital": "ICH" },
"Inveruno": { "pv": "MI", "hospital": "ICHPIO" },
"Inzago": { "pv": "MI", "hospital": "ICHPIO" },
"Liscate": { "pv": "MI", "hospital": "ICHPIO" },
"Magenta": { "pv": "MI", "hospital": "ICH" },
"Magnago": { "pv": "MI", "hospital": "ICHPIO" },
"Marcallo con Casone": { "pv": "MI", "hospital": "ICHPIO" },
"Masate": { "pv": "MI", "hospital": "ICHPIO" },
"Melzo": { "pv": "MI", "hospital": "ICHPIO" },
"Mesero": { "pv": "MI", "hospital": "ICHPIO" },
"Milano": { "pv": "MI", "hospital": "ICHPIO" },
"Morimondo": { "pv": "MI", "hospital": "ICH" },
"Motta Visconti": { "pv": "MI", "hospital": "ICH" },
"Nosate": { "pv": "MI", "hospital": "ICHPIO" },
"Ossona": { "pv": "MI", "hospital": "ICHPIO" },
"Ozzero": { "pv": "MI", "hospital": "ICH" },
"Pessano con Bornago": { "pv": "MI", "hospital": "ICHPIO" },
"Pioltello": { "pv": "MI", "hospital": "ICHPIO" },
"Pozzo d'Adda": { "pv": "MI", "hospital": "ICHPIO" },
"Pozzuolo Martesana": { "pv": "MI", "hospital": "ICHPIO" },
"Robecchetto con Induno": { "pv": "MI", "hospital": "ICHPIO" },
"Robecco sul Naviglio": { "pv": "MI", "hospital": "ICH" },
"Rodano": { "pv": "MI", "hospital": "ICHPIO" },
"Rosate": { "pv": "MI", "hospital": "ICH" },
"Santo Stefano Ticino": { "pv": "MI", "hospital": "ICHPIO" },
"Segrate": { "pv": "MI", "hospital": "ICHPIO" },
"Sesto San Giovanni": { "pv": "MI", "hospital": "ICHPIO" },
"Settala": { "pv": "MI", "hospital": "ICHPIO" },
"Settimo Milanese": { "pv": "MI", "hospital": "ICHPIO" },
"Trezzano Rosa": { "pv": "MI", "hospital": "ICHPIO" },
"Trezzo sull'Adda": { "pv": "MI", "hospital": "ICHPIO" },
"Truccazzano": { "pv": "MI", "hospital": "ICHPIO" },
"Turbigo": { "pv": "MI", "hospital": "ICHPIO" },
"Vaprio d'Adda": { "pv": "MI", "hospital": "ICHPIO" },
"Vernate": { "pv": "MI", "hospital": "ICH" },
"Vignate": { "pv": "MI", "hospital": "ICHPIO" },
"Vimodrone": { "pv": "MI", "hospital": "ICHPIO" },
"Villa Cortese": { "pv": "MI", "hospital": "ICHPIO" },
"Vanzaghello": { "pv": "MI", "hospital": "ICHPIO" },
"Vermezzo con Zelo": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20121": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20122": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20123": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20124": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20125": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20126": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20127": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20128": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20129": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20131": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20132": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20133": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20134": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20135": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20136": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20137": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20138": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20139": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20141": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20142": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20143": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20144": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20145": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20146": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20147": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20148": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20149": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20151": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20152": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20153": { "pv": "MI", "hospital": "ICH" },
"MILANO cap 20154": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20155": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20156": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20157": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20158": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20159": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20161": { "pv": "MI", "hospital": "ICHPIO" },
"MILANO cap 20162": { "pv": "MI", "hospital": "ICHPIO" },
};
$scope.searchText = "";
var milano = 'ARS|LAI|PPARS|PPLAI|CHGTRE|ICH|ICHFIO|ICHASS|ICHPAS|ICHPRE|ICHPLI|ICHPPO|ICHPIO|MCHDEA|HMCDOM|MCHMUR|MCHMON|MCHBRE|ICHPDE|ICHPDO|ICHPFI|ICHPLI|ICHPMO|ICHPMU|ICHPPO|ICHPPR|ICHPBR';
var varese = 'CDV|CDVDIA|BUS|HMD|PPBUS|PPVAR';
var bergamo = 'MCHBCA|CHGPCA|CHG|CHGALM|CHGPAZ|CHGCAS|CHGTRE';
var allh = _.map(_.keys(window.hospitalName), function (m) { return m.toUpperCase(); }).join("|");
$scope.hospitals =
[
{ title: 'Televisita Online', subtitle: '', check: false, rightarrow: true, value: allh, startcode: 'TLC', athome: false },
{ title: 'Humanitas a domicilio ( MI, BG, VA)', check: false, rightarrow: true, subtitle: '', value: allh, startcode: '', athome: true },
{ title: 'Lombardia', parent: 'Lombardia', subtitle: '', checked: false, check: true, value: milano + '|' + varese + '|' + bergamo, startcode: '', athome: false },
{ title: ' Milano, Monza e Provincia', parent: 'Lombardia', pv: 'MI', indent: true, checked: false, check: true, subtitle: '', startcode: '', value: milano, athome: false },
{ title: ' Varese e Provincia', parent: 'Lombardia', pv: 'VA', indent: true, checked: false, check: true, subtitle: '', value: varese, startcode: '', athome: false },
{ title: ' Bergamo e Provincia', parent: 'Lombardia', pv: 'BG', indent: true, checked: false, check: true, subtitle: '', value: bergamo, startcode: '', athome: false },
];
//if (window.location.href.indexOf("stage") >= 0 || window.location.href.indexOf("preprod") >= 0)
{
var torino = 'MLT|GRA|CEL|MPO|SLU';
var fornaca = 'CDF|FOR';
$scope.hospitals.push({ title: 'Piemonte', parent: 'Piemonte', subtitle: '', checked: false, check: true, arrow: false, value: torino, startcode: '', athome: false });
$scope.hospitals.push({ title: ' Torino e Provincia', parent: 'Piemonte', indent: true, subtitle: "", value: 'MLT|GRA|CEL|MPO|SLU|CDF|FOR', checked: false, check: true, startcode: '', athome: false });
// $scope.hospitals.push({ title: ' Fornaca ', parent: 'Piemonte', indent: true, subtitle: "", value: 'CDF|FOR', checked: false, check: true, startcode: '', athome: false });
}
function isObject(objValue) {
return objValue && typeof objValue === 'object' && objValue.constructor === Object;
}
$scope.cities = _.sortBy(_.map(_.keys(citiesMap), function (c) {
var pv = "";
if (isObject(citiesMap[c])) {
let city = citiesMap[c];
pv = city.pv;
h = city.hospital;
} else {
pv = citiesMap[c];
pvtemp = pv;
if (pv === "mi" && c !== "MILANO") {
pvtemp = "VA";
}
pv = pv.toUpperCase();
pvtemp = pvtemp.toUpperCase();
var ch = _.filter($scope.hospitals, { pv: pvtemp });
var h = (ch.length > 0) ? ch[0].value : allh;
if (pvtemp === "MI") h = h.split("|").filter(function (osp) { return osp !== "ARS" && osp !== "PPARS"; }).join("|");
if (pvtemp === "VA") h = h.split("|").concat(["ARS", "PPARS"]).join("|");
}
return { title: c + " (" + pv.toUpperCase() + ")", subtitle: '', value: h, startcode: ' ', athome: true };
}), 'title');
$scope.searchOnKeyUp = function (e) {
$scope.searchText = e.target.value;
};
$scope.getHospitalName = function (code) {
try {
return _.filter($scope.hospitals, { 'value': code })[0].subtitle;
} catch (ex) {
console.error(ex);
return "";
}
};
$scope.filterCity = function (str, index) {
var txt = str.title.toLowerCase();
if ($scope.searchText === "")
return true;
else
return txt.indexOf($scope.searchText.toLowerCase()) >= 0;
};
$scope.choose = function (selected) {
if (!selected) {
selected = _.filter($scope.hospitals, { title: 'Lombardia' })[0];
if (selected.checked === false) {
var val = _.map(_.filter($scope.hospitals, { checked: true }), function (h) { return h.value; }).join("|");
var title = _.map(_.filter($scope.hospitals, { checked: true }), function (h) { return h.title }).join(", ");
selected.value = val;
selected.title = title;
}
window.startcode = selected.startcode;
window.athome = selected.athome;
window.hospital = selected.value;
$modalInstance.close(selected);
return;
}
if (selected.check) {
if (selected.title === "Lombardia") {
$scope.hospitals = _.map($scope.hospitals, function (h) {
if (h.check && (h.parent === selected.title || selected.title === h.title)) h.checked = selected.checked;
if (h.check && (h.title === "Piemonte")) h.checked = (_.filter($scope.hospitals, { check: true, checked: false, parent: "Piemonte" }).length > 0) ? false : true;
if (h.check && (h.parent !== selected.parent)) h.checked = false;
return h;
});
}
else if (selected.title === "Piemonte") {
$scope.hospitals = _.map($scope.hospitals, function (h) {
if (h.check && (h.parent === selected.title || selected.title === h.title)) h.checked = selected.checked;
if (h.check && (h.title === "Lombardia")) h.checked = (_.filter($scope.hospitals, { check: true, checked: false, parent: "Lombardia" }).length > 0) ? false : true;
if (h.check && (h.parent !== selected.parent)) h.checked = false;
return h;
});
}
else {
$scope.hospitals = _.map($scope.hospitals, function (h) {
if (h.check && selected.title == h.title) h.checked = selected.checked;
return h;
});
$scope.hospitals = _.map($scope.hospitals, function (h) {
if (h.check && (h.title === "Lombardia")) h.checked = (_.filter($scope.hospitals, { check: true, checked: false, parent: "Lombardia" }).length > 0) ? false : true;
if (h.check && (h.title === "Piemonte")) h.checked = (_.filter($scope.hospitals, { check: true, checked: false, parent: "Piemonte" }).length > 0) ? false : true;
if (h.check && (h.parent !== selected.parent)) h.checked = false;
return h;
});
}
window.athome = false;
window.startcode = "";
return;
}
window.hospital = selected.value;
window.startcode = selected.startcode;
window.athome = selected.athome;
if (window.athome && selected.startcode === '') {
$scope.athome = window.athome;
setTimeout(function () {
document.getElementById("comunesearch").focus();
}, 500);
}
else {
$modalInstance.close(selected);
}
}
$scope.close = function () {
$modalInstance.close(-1);
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('ChooseHospitalsController', ['$scope', '$modalInstance', 'sourceData', function ($scope, $modalInstance, sourceData) {
$scope.hospitals = sourceData;
$scope.selectAll = function () {
$scope.hospitals.forEach(function (h) {
if (h.results)
h.checked = true;
})
};
$scope.deselectAll = function () {
$scope.hospitals.forEach(function (h) {
h.checked = false;
})
};
$scope.apply = function (hosp) {
var counter = 0;
if (screen.width <= 480) {
$modalInstance.close({
'title': 'Fitro',
'subtitle': ''
});
}
if (hosp === undefined) {
counter = 0;
ng.forEach($scope.hospitals, function (item) {
if (item.checked) ++counter;
});
if (counter === 0) counter = sourceData.length;
$modalInstance.close({
'title': 'Strutture:',
'subtitle': (sourceData.length === counter ? 'Tutto' : 'Selezione') + ' (' + counter + ')'
});
} else {
counter = 0;
ng.forEach($scope.hospitals, function (item) {
if (item.checked) ++counter;
});
$modalInstance.close({
'title': hosp
});
}
}
$scope.close = function () {
$scope.apply();
//$modalInstance.close(-1);
}
$scope.$on('modal.closing', function (event, reason, closed) {
if (!closed)
$scope.apply();
});
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('ChooseInsuranceController', ['$scope', '$modalInstance', 'Utils', '$http', 'apiUrl', '$q', 'sourceData',
function ($scope, $modalInstance, Utils, $http, apiUrl, $q, sourceData) {
if (sourceData) {
$scope.insurances = sourceData;
$scope.status = '';
}
else {
$scope.selectedInsurance = {
title: 'Nessuna assicurazione',
subtitle: '',
value: ''
};
$http.get(apiUrl + '/insurance', {
}).then(function (response) {
var data = response.data;
var resultsdata = [];
if (response.data.length == 0) {
resultsdata = [{
title: 'AON',
subtitle: '',
value: 'AON'
}, {
title: 'BLUE ASSISTANCE',
subtitle: '',
value: 'BLUE ASSISTANCE'
},
{
title: 'MUTUA COMMERCIANTI',
subtitle: '',
value: 'ENTE MUTUO REGIONALE'
},
{
title: 'FASCHIM',
subtitle: '',
value: 'FASCHIM'
},
{
title: 'FASDAC',
subtitle: '',
value: 'FASDAC'
}
,
{
title: 'GENERALI',
subtitle: '',
value: 'GENERALI'
}, {
title: 'IWS - FASI',
subtitle: '',
value: 'IWS - FASI'
}, {
title: 'IWS OPEN - FASI OPEN',
subtitle: '',
value: 'IWS OPEN - FASI OPEN'
}
, {
title: 'MY ASSISTANCE',
subtitle: '',
value: 'MY ASSISTANCE'
}
, {
title: 'PREVIMEDICAL',
subtitle: '',
value: 'PREVIMEDICAL'
}];
}
for (var i = 0; i < data.length; i++) {
resultsdata.push({ 'title': data[i].name, 'subtitle': '', 'value': data[i].code });
}
resultsdata.push({
title: 'ALTRO FONDO/ASSICURAZIONE',
subtitle: '',
value: 'ALTRO'
});
resultsdata.push({
title: 'Nessuna assicurazione',
subtitle: '',
value: ''
});
$scope.insurances = resultsdata;
$scope.status = '';
});
}
$scope.choose = function (selected) {
$scope.insurances.forEach(function (i) { i.checked = (selected.title === i.title); });
$scope.selectedInsurance = selected;
$modalInstance.close(selected);
}
$scope.close = function () {
$modalInstance.close(-1);
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('ChooseSingleHospitalController', ['$scope', '$modalInstance', 'sourceData', function ($scope, $modalInstance, sourceData) {
$scope.hospitals = sourceData;
$scope.apply = function (hosp) {
var selectelement = {};
var title = "";
var code = "";
if (hosp === undefined) {
selectelement = _.filter($scope.hospitals, function (h) { return h.results })[0];
} else {
selectelement = _.filter($scope.hospitals, { 'struttura': hosp })[0];
}
title = selectelement.name;
code = selectelement.struttura;
$scope.hospitals.forEach(function (s) { s.checked = (code == s.struttura); });
$modalInstance.close({
'title': title,
'subtitle': ' '
});
}
$scope.close = function () {
$scope.apply();
//$modalInstance.close(-1);
}
$scope.$on('modal.closing', function (event, reason, closed) {
if (!closed)
$scope.apply();
});
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('ChooseVisitsController', ['$scope', '$modalInstance', '$http', 'apiUrl', '$q', '$window','$interval',
function ($scope, $modalInstance, $http, apiUrl, $q, $window,$interval) {
$scope.searchText = '';
$scope.status = 'loading';
$scope.athometype = $window.athometype || "";
$window.athometype = "";
$scope.athome = $window.athome;
$window.ssn = '';
$scope.ssn = $window.ssn;
$scope.typing = false;
$scope.lastselected = null;
$scope.defaultresult = [
// { "type": "PiuPrenotati", "code": "VACINF", "label":"Somministrazione Vaccino Antinfluenzale"},
{ "type": "PiuPrenotati", "code": "COV19AG ", "label": "Tampone Rinofaringeo COVID-19 (ANTIGENICO)" },
{ "type": "PiuPrenotati", "code": "COV19TN ", "label": "Tampone Rinofaringeo Sars-Cov-2(COVID 19)" },
{ "type": "PiuPrenotati", "code": "TRIMERIC", "label": "Prelievo Sierologico COVID-19 - monitoraggio stato immunologico - anticorpi Neutralizzanti" },
{ "type": "PiuPrenotati", "code": "VISPSI01", "label": "Visita Psicologica" },
{ "type": "PiuPrenotati", "code": "TLCPSI", "label": "Televisita Psicologia" },
{ "type": "PiuPrenotati", "code": "VISDER01", "label": "Visita Dermatologica" },
{ "type": "PiuPrenotati", "code": "VCARECG1", "label": "Visita Cardiologica + ECG" },
//{ "type": "PiuPrenotati", "code": "VISCAR01", "label": "Visita Cardiologica" },
{ "type": "PiuPrenotati", "code": "VISGAE01", "label": "Visita Gastroenterologica" },
{ "type": "PiuPrenotati", "code": "PKGIN3", "label": "Visita Ginecologica con ecografia transvaginale" },
{ "type": "PiuPrenotati", "code": "VISOCU01", "label": "Visita Oculistica" },
{ "type": "PiuPrenotati", "code": "VISORT01", "label": "Visita Ortopedica" },
{ "type": "PiuPrenotati", "code": "VISORL01", "label": "Visita Otorinolaringoiatrica" },
{ "type": "PiuPrenotati", "code": "VISURO01", "label": "Visita Urologica" },
{ "type": "PiuPrenotati", "code": "ECOADD", "label": "Ecografia Addome" },
{ "type": "PiuPrenotati", "code": "RXNTOR", "label": "RX Torace" },
{ "type": "PiuPrenotati", "code": "RXNMAMBI", "label": "Mammografia bilaterale" },
{ "type": "PiuPrenotati", "code": "ECOMAMBI", "label": "Ecografia Mammaria bilaterale" },
{ "type": "PiuPrenotati", "code": "PKECOMA", "label": "Mammografia ed Ecografia Mammaria" },
];
$scope.televisite = [{ "type": "Televisite", "code": "TLCPSI", "label": "TELEVISITA PSICOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCORT", "label": "TELEVISITA ORTOPEDIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCGAE", "label": "TELEVISITA GASTROENTEROLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCURO", "label": "TELEVISITA UROLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCGIN", "label": "TELEVISITA GINECOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCEMA ", "label": "TELEVISITA EMATOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCPSH", "label": "TELEVISITA PSICHIATRICA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCALL", "label": "TELEVISITA ALLERGOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCPNE", "label": "TELEVISITA PNEUMOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCNUT", "label": "TELEVISITA VALUTAZIONE NUTRIZIONISTICA -DIETOLOGICA (VALUTAZ" },
{ "type": "Televisite", "code": "TLCDER", "label": "TELEVISITA DERMATOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCCAR", "label": "TELEVISITA CARDIOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCONC", "label": "TELEVISITA ONCOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCREU", "label": "TELEVISITA REUMATOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCEND", "label": "TELEVISITA ENDOCRINOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCFST02", "label": "TELEVISITA FISIOTERAPICA" },
{ "type": "Televisite", "code": "TLCNEF ", "label": "TELEVISITA NEFROLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCORL", "label": "TELEVISITA OTORINOLARINGOIATRIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCSEN", "label": "TELEVISITA SENOLOGICA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCAND", "label": "TELEVISITA ANDROLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCOCU", "label": "TELEVISITA OCULISTICA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCEPA", "label": "TELEVISITA EPATOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCMED", "label": "TELEVISITA MEDICINA INTERNA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCDIE", "label": "TELEVISITA VISITA DIETOLOGICA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCDIA", "label": "TELEVISITA DIABETOLOGIA (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCNEI", "label": "TELEVISITA NEUROPSICHIATRIA INFANTILE (VALUTAZIONE INIZIALE)" },
{ "type": "Televisite", "code": "TLCLOG", "label": "TELEVISITA TRATTAMENTO LOGOPEDICO" },
{ "type": "Televisite", "code": "TLCNEU", "label": "TELEVISITA NEUROLOGIA (VALUTAZIONE INIZIALE)" }];
$scope.prelievissn = [{ "type": "Prelievi", "code": "PRELIEVO", "label": "Prelievo SSN (generico)" },
{ "type": "Prelievi", "code": "PRELIEVO_ONC", "label": "Cancer Center (percorso dedicato)" },
{ "type": "Prelievi", "code": "PRELIEVO_TAO", "label": "TAO (percorso dedicato)" }];
$scope.updateExams = function () {
var params = {};
$scope.defaultresult = []
$scope.status = 'loading';
params['q'] = '';
params['hospital'] = $window.hospital;
params['startcode'] = $window.startcode;
params['athome'] = $window.athome;
params['athometype'] = $window.athometype;
$http.get(apiUrl + 'common/exams-more-booked/', {
params: params
}).then(function (response) {
var data = response.data;
var resultsdata = [];
//for (var i = 0; i < data.length; i++) {
// resultsdata.push({ 'type': 'Esami', 'label': data[i].name, 'code': data[i].external_code });
//}
if ($window.startcode === "TLC") {
$scope.televisite = _.map($scope.televisite, function (v, index) {
v.order = 10000000 - index;
return v;
});
data = $scope.televisite.concat(_.filter(data, function (e) { return !_.has($scope.televisite, { "code": e.code }); }));
}
$scope.results = data;
$scope.defaultresult = data;
$scope.status = '';
});
};
if ($window.startcode != '' || $window.athome || $window.hospital.split('|').length < 7) {
$scope.updateExams();
}
else {
$scope.results = $scope.defaultresult;
$scope.status = '';
}
var results = $scope.defaultresult;
var stringcode = _.map($scope.results, function (r) { return r.code }).join(",");
var values = [];
var lastQuery = null;
$window.searchExams = [];
var _search = function (val) {
var params = {};
lastQuery = val;
params['q'] = val;
params['hospital'] = $window.hospital;
params['startcode'] = $window.startcode;
params['athome'] = $window.athome;
params['athometype'] = $window.athometype;
return new Promise(function (resolve, reject) {
var paramsArr = Object.values(params);
if ($window.searchExams[val] ) {
resolve($window.searchExams[val]);
}
else {
$http.get(apiUrl + 'smartsearch/area/all', {
params: params
}).then(function (response) {
values = [];
if (ng.isDefined(response)) {
values = response.data;
values = _.groupBy(values, 'type');
values = _.map(values, function (g) { g[0].firstInGroup = true; return g; });
values = _.flatten(values);
}
$window.searchExams[val] = values;
resolve(values);
});
}
});
};
var _timer, _timeOut = 100;
$scope.changeAthomeType = function (athome, athometype) {
$scope.athome = athome;
$window.athome = athome;
$scope.athometype = athometype;
$window.athometype = athometype;
$scope.updateExams();
};
$scope.searchOnKeyUp = function (e) {
$scope.typing = true;
$scope.searchText = e.target.value.replace(/[^a-zA-Z0-9\ ]+/g, " ").replace(/\s+/g," ");
if (!$scope.searchText || $scope.searchText.length < 2)
{
$scope.results = $scope.defaultresult;
return;
}
if (e.keyCode === 13)
{ // close on ENTER key
$scope.search($scope.searchText);
}
}
$interval(function () {
if ($scope.searchText && $scope.searchText.length > 2) {
if (!$scope.typing && lastQuery !== $scope.searchText)
$scope.search($scope.searchText);
}
if ($scope.status !== 'loading') $scope.typing = false;
},1000);
$scope.search = function (val) {
if (val==="") val = $scope.searchText;
val = val.replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"');
if (!val || val.length < 2) {
return;
}
$scope.results = [];
$scope.status = 'loading';
try {
_search(val)
.then(function (data) {
var position = 1;
$scope.results = data;
$scope.status = '';
if (data.length > 0) {
setTimeout(function () {
$window.track('Appointment', 'Search Submitted', { search: { keyword: val } },
{
'impressions': _.map(data, function (d) {
return {
name: d.label,
id: d.code,
brand: 'unselected',
category: d.type,
list: 'Appointment Search',
position: position++
}
})
}
);
}, 100);
}
});
} catch (e) {
$scope.status = '';
//console.log(e)
}
}
$scope.changeSSN = function (ssn)
{
$scope.ssn = ssn;
}
$scope.choose = function (selected,ssn=false) {
$scope.lastselected = 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 : "",
ssn: ssn
};
if (selected.code.substr(0, 8) === "PRELIEVO") {
if ($scope.ssn === "") {
$scope.ssn = 'ssn';
$scope.results = [];
return;
} else {
$scope.termSelected.title += (ssn) ? " in ssn" : " in privato";
}
}
$window.ssn = ssn;
$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('ChooseWeekDaysController', ['$scope', '$modalInstance', 'sourceData', function ($scope, $modalInstance, sourceData)
{
$scope.weekDays = sourceData;
$scope.selectAll = function ()
{
$scope.weekDays.forEach(function (h)
{
h.checked = true;
})
};
$scope.deselectAll = function ()
{
$scope.weekDays.forEach(function (h)
{
h.checked = false;
})
};
$scope.apply = function (hosp)
{
{
var counter = 0;
ng.forEach($scope.weekDays, function (item)
{
if (item.checked) ++counter;
});
if (counter === 0) counter = sourceData.length;
$modalInstance.close({
'title': (counter === sourceData.length) ? 'Nessuna preferenza' : _.map(_.filter($scope.weekDays, { checked: true }), function (w) { return w.title; }).join(", "),
'value': _.map(_.filter($scope.weekDays, { checked: true }), function (w) { return w.value; }).join(",")
});
}
}
$scope.close = function ()
{
$scope.apply();
//$modalInstance.close(-1);
}
$scope.$on('modal.closing', function (event, reason, closed)
{
if (!closed)
$scope.apply();
});
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);;
(function (ng, ngmodule, $, _) {
ngmodule.controller('ExamReviewsController', ['$scope', '$http', 'apiUrl', '$timeout',
function ($scope, $http, apiUrl, $timeout) {
$scope.status = '';
$scope.reviews = {};
$scope.load = function () {
$http.get(apiUrl + 'review/summary/' + $scope.examId)
.then(function (response) {
if (ng.isDefined(response.data.rate)) {
$scope.status = 'has_results';
$scope.reviews = response.data;
}
},
function (response) {
$scope.status = '';
});
}
$timeout($scope.load, 1000);
}
]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('FilterExamsController', ['$scope', '$modalInstance', 'sourceData', function ($scope, $modalInstance, sourceData) {
$scope.data = sourceData;
$scope.apply = function (item) {
for (var i = 0; i < $scope.data.length; i++) {
if (item.exam_name == $scope.data[i].exam_name &&
item.struttura == $scope.data[i].struttura) {
$scope.data[i].checked = true;
} else {
$scope.data[i].checked = false;
}
}
var counter = 0;
$scope.data = sourceData;
$modalInstance.close({
'title': item.exam_name,
'subtitle': '' //'€' + item.exam_price
});
}
$scope.close = function () {
var exam = _.filter($scope.data, { 'checked': true });
if (exam.length > 0) {
$scope.apply(exam[0]);
}
else {
$modalInstance.close();
}
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('FormLpController', ['$scope', 'apiUrl', '$http', '$interval','$modal', function ($scope, apiUrl, $http, $interval,$modal) {
$scope.status = "";
$.fn.serializeObject = function () {
var o = {};
var a = this.serializeArray();
$.each(a, function () {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
$scope.form = { area: '', eseguitoich: 'no', terapiafarmacologica: 'no' };
function uuidv4() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
}
);
};
File.prototype.convertToBase64 = function (callback) {
var reader = new FileReader();
var fileName = this.name;
var fileType = this.type;
reader.onload = function (e) {
if (!fileName ||fileName === "") fileName = "file" + uuidv4 + "." + fileType;
callback(e.target.result, fileName, fileType);
};
reader.onerror = function (e) {
callback(null, e);
};
if (this.size < 5120000) {
reader.readAsDataURL(this);
} else {
alert('File troppo grande, massimo 5MB');
}
};
$('div.fileupload').each(function () {
var blockEl = $(this);
var previewEl = $('#' + blockEl.data('preview'), blockEl);
var filenameEl = $('#' + blockEl.data('filename'), blockEl);
var uploadBtn = $("input[type=file]", blockEl);
var removeBtn = $('button.remove', blockEl);
var inputNamePrefix = uploadBtn.attr('name');
previewEl.hide();
uploadBtn
.off('change')
.on('change', function () {
var inputEl = $(this);
var selectedFile = this.files[0];
selectedFile.convertToBase64(function (base64, fileName, fileType) {
if ((fileType.indexOf('png') > 0
|| fileType.indexOf('jpg') > 0
|| fileType.indexOf('jpeg') > 0
|| fileType.indexOf('gif') > 0
|| fileType.indexOf('pdf') > 0 )
) {
if (base64.indexOf("iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg") === -1) {
$('input[name*="' + inputNamePrefix + '_"]').remove();
$('', {
type: 'hidden',
name: inputNamePrefix + '_base64',
value: base64
}).appendTo(inputEl.parent());
$('', {
type: 'hidden',
name: inputNamePrefix + '_filename',
value: fileName
}).appendTo(inputEl.parent());
$('', {
type: 'hidden',
name: inputNamePrefix + '_filetype',
value: fileType
}).appendTo(inputEl.parent());
if (previewEl) {
previewEl.attr('src', base64);
previewEl.slideDown('fast');
}
if (filenameEl)
filenameEl.val(fileName);
removeBtn.attr('disabled', false);
$('#medical_recipe').slideUp('fast', function () { $(this).addClass('validation-skip'); });
}
} else {
alert('Formato file errato.');
}
});
});
removeBtn
.off('click')
.on('click', function () {
removeBtn.attr('disabled', 'disabled');
$('#medical_recipe').slideDown('fast', function () { $(this).removeClass('validation-skip'); });
$('input[name*="' + inputNamePrefix + '_"]').remove();
$([filenameEl]).each(function () {
$(this).val('');
});
previewEl.slideUp('fast', function () { previewEl.attr('src', ''); previewEl.hide(); })
});
});
// inputmasks
$('[data-maskdate]').inputmask("d/m/y", { "placeholder": "gg/mm/aaaa" });
// privacy accordion
$('.privacy-zippy a.privacy-link').click(function (e) {
e.preventDefault();
var privacyText = $(this).next('.privacy-text');
if (privacyText.is(':visible')) {
privacyText.slideUp('slow');
}
else {
privacyText.slideDown('slow');
}
});
$('select[name="convention"]').change(function (e) {
if ($(this).val() == 'true') {
$('.form-group.convention-type').show().addClass("required");
$('input', '.form-group.convention-type').removeClass("no-send");
} else {
$('.form-group.convention-type').hide().removeClass("required");
$('input', '.form-group.convention-type').addClass("no-send");
}
});
$('#mobile_nav_toggle').click(function (e) {
e.preventDefault();
$('.mobile-dropdown').slideToggle(400);
});
$('#business-data-trigger').click(function (e) {
e.preventDefault();
/*Custombox.open({
target: '.modal_business_data',
effect: 'slit',
overlayColor: '#FFF',
overlayOpacity: 0.7,
speed: 1200,
width: 420,
height: 215
});*/
});
// informativa cookie
var cookiebar = $('div.cookiebar');
if ($.cookie("cookiebar") === undefined) {
cookiebar.show();
$('button', cookiebar).click(function () {
$.cookie("cookiebar", "yes");
cookiebar.hide('slow', cookiebar.remove());
});
}
var onesubmitattime = false;
// form prenotazione
$('form.x-form.ajax')
.off()
.on('focus click', 'input, textarea, div.checkbox', function (e) {
$(this).parent().removeClass('has-error');
})
.on('submit', function (e) {
e.preventDefault();
e.stopPropagation();
var formEl = $(this);
var formLogEl = $('.formlog', formEl);
// validazione dei campi
formEl.removeClass('error').removeClass('success').addClass('wait');
var isValid = 1;
var inputs = $('input, textarea, select', formEl);
inputs.prop('disabled', 'disabled');
inputs.each(function () {
if ($(this).attr('type') != 'submit') {
var isCurValid = 1;
if ($(this).parents('div.form-group').hasClass('required')) {
if (($(this).attr('type') == 'checkbox') && !$(this).is(':checked')) {
isCurValid = 0;
} else if ($(this).val() == '') {
isCurValid = 0;
}
if (isCurValid && $(this).attr('type') == 'date') {
var date = new Date($(this).val());
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear();
isCurValid = (year > 1910 && month >= 1 && month <= 12 && day > 0 && day <= 31);
}
}
if ($(this).val() != '' && !$(this).hasClass('no-send')) {
var regex = new RegExp();
switch ($(this).attr('type')) {
case 'tel': {
regex = /^\+?\d[0-9 .]{7,12}\d$/;
break;
}
case 'email': {
regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
break;
}
case 'password': {
regex = /^([a-zA-Z0-9_-]){6,}$/;
break;
}
}
isCurValid = isCurValid & regex.test($(this).val());
}
isValid = isValid & isCurValid;
if (!isCurValid)
$(this).parents('.form-group').addClass('has-error');
else
$(this).parents('.form-group').removeClass('has-error');
}
});
// controllo se flaggato donation
// var donations = $('[name="donation[]"]:checked', formEl);
// isValid = isValid && donations.length > 0;
inputs.prop('disabled', false);
if (!isValid) {
formEl.removeClass('wait').addClass('error');
inputs.prop('disabled', false);
return;
}
$('', {
class: 'full-loader'
}).appendTo(formEl);
var data = formEl.find(":not('.no-send')").serializeObject();
data.contract_category = (data['convention_type'] && data['convention_type'] != null && data['convention_type'] !== '') ? "ASSICURATO" : "SOLVENTE";
if (!(data.hospital)) data.hospital = "ICH";
data.hospital_name = window.hospitalName[data.hospital.toLowerCase()].name;
if (window.webpage !== "mail") {
// $.post(URL_FORM_POST2, { JsonString: JSON.stringify(data) }, function (d) {
// });
if (data.donation)
data.donation = data.donation.filter(function (d) { return d !== ""; }).join(",");
}
$scope.status = 'isloading';
//if (!onesubmitattime)
{
onesubmitattime = true;
$.post(URL_FORM_POST, { JsonString: JSON.stringify(data) }, function (d) {
$('div.full-loader').remove();
if (d.status == 'KO') {
onesubmitattime = false;
formEl.removeClass('wait');
formEl.addClass("error");
inputs.prop('disabled', false);
$scope.status = '';
} else
{
setTimeout(function () {
$scope.status = '';
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return 'Dati inviati correttamente!' },
bodyhtml: function () { return ''},
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
window.location.href = apiUrl + "../Form/Newsletter";
}
});
onesubmitattime = false;
}, 1000);
formEl.removeClass('wait');
formEl.addClass("success");
/*Custombox.open({
target: '.modal_form_ok',
effect: 'slit',
overlayColor: '#FFF',
overlayOpacity: 0.7,
speed: 1200,
width: 420,
height: 215
});*/
inputs.prop('disabled', false);
inputs.each(function () {
if ($(this).attr('type') != 'submit') {
$(this).val('');
}
});
setTimeout(function () {
$scope.status = '';
formEl.removeClass("success");
}, 5000);
}
}, 'json');
}
return false;
});
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var exam = "";
if (getParameterByName('exam_name') != null) {
exam = getParameterByName('exam_name') + " - [" + getParameterByName('exam_code') + "]";
if (getParameterByName('exam_code') === "PROMOCANCER") {
exam = getParameterByName('exam_name');
$("[name='page']").val("promo_cancer");
}
$(".exam-title").html(getParameterByName('exam_name'));
$("[name='free_text']").val(exam);
if ($("[name='required_exam']").length > 0)
$("[name='required_exam']").val(exam);
}
if (getParameterByName('nome') != null )
{
$("[name='name']").val(getParameterByName('nome'));
}
if (getParameterByName('cognome')!=null)
{
$("[name='surname']").val(getParameterByName('cognome'));
}
if (getParameterByName('cf') != null)
{
$("[name='vatcode']").val(getParameterByName('cf'));
}
if (getParameterByName('email') != null)
{
$("[name='email']").val(getParameterByName('email'));
}
if (getParameterByName('tel') != null)
{
$("[name='phone']").val(getParameterByName('tel'));
}
if (getParameterByName('lista') != null)
{
$("[name='lista']").val(getParameterByName('lista'));
}
if (getParameterByName('num_pratica') != null)
{
$("[name='num_pratica']").val(getParameterByName('num_pratica'));
}
if (getParameterByName('datadinascita') != null)
{
$("[name='birthday']").val(getParameterByName('datadinascita'));
}
if ($(".card-wrapper").length > 0) {
var card = new Card({
form: 'form',
container: '.card-wrapper',
// Default placeholders for rendered fields - optional
placeholders: {
number: '**** **** **** ****',
name: 'Nome Completo',
expiry: 'MM/AAAA',
cvc: '***'
},
messages: {
validDate: 'expire\ndate',
monthYear: 'mm/yy'
}
});
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('FormSsnController', ['$scope', 'apiUrl', '$http', '$interval', '$window', function ($scope, apiUrl, $http, $interval, $window) {
$scope.status = "";
$scope.form = { 'recipe_type': 'imp-rossa' };
$.fn.serializeObject = function () {
var o = {};
var a = this.serializeArray();
$.each(a, function () {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
File.prototype.convertToBase64 = function (callback) {
var reader = new FileReader();
var fileName = this.name;
var fileType = this.type;
reader.onload = function (e) {
callback(e.target.result, fileName, fileType);
};
reader.onerror = function (e) {
callback(null, e);
};
if (this.size < 5120000) {
reader.readAsDataURL(this);
} else {
alert('File troppo grande, massimo 5MB');
}
};
$('div.fileupload').each(function () {
var blockEl = $(this);
var previewEl = $('#' + blockEl.data('preview'), blockEl);
var filenameEl = $('#' + blockEl.data('filename'), blockEl);
var uploadBtn = $("input[type=file]", blockEl);
var removeBtn = $('button.remove', blockEl);
var inputNamePrefix = uploadBtn.attr('name');
previewEl.hide();
uploadBtn
.off('change')
.on('change', function () {
var inputEl = $(this);
var selectedFile = this.files[0];
selectedFile.convertToBase64(function (base64, fileName, fileType) {
if (fileType.indexOf('png') > 0
|| fileType.indexOf('jpg') > 0
|| fileType.indexOf('jpeg') > 0
|| fileType.indexOf('gif') > 0
) {
$('input[name*="' + inputNamePrefix + '_"]').remove();
$('', {
type: 'hidden',
name: inputNamePrefix + '_base64',
value: base64
}).appendTo(inputEl.parent());
$('', {
type: 'hidden',
name: inputNamePrefix + '_filename',
value: fileName
}).appendTo(inputEl.parent());
$('', {
type: 'hidden',
name: inputNamePrefix + '_filetype',
value: fileType
}).appendTo(inputEl.parent());
if (previewEl) {
previewEl.attr('src', base64);
previewEl.slideDown('fast');
}
if (filenameEl)
filenameEl.val(fileName);
removeBtn.attr('disabled', false);
$('#medical_recipe').slideUp('fast', function () { $(this).addClass('validation-skip'); });
} else {
alert('Formato file errato.');
}
});
});
removeBtn
.off('click')
.on('click', function () {
removeBtn.attr('disabled', 'disabled');
$('#medical_recipe').slideDown('fast', function () { $(this).removeClass('validation-skip'); });
$('input[name*="' + inputNamePrefix + '_"]').remove();
$([filenameEl]).each(function () {
$(this).val('');
});
previewEl.slideUp('fast', function () { previewEl.attr('src', ''); previewEl.hide(); })
});
});
// inputmasks
$('[data-maskdate]').inputmask("d/m/y", { "placeholder": "gg/mm/aaaa" });
// informativa cookie
var cookiebar = $('div#cookiesdirective');
if ($.cookie("cookiebar") === undefined) {
cookiebar.show();
$('input[type=checkbox]', cookiebar).change(function () {
$.cookie("cookiebar", "yes");
cookiebar.slideUp('slow', function () {
cookiebar.remove();
});
});
}
var requiredExamEl = $('div#required_exams_container');
var createRequireExamEl = function () {
var containerEl = $('', {
}).addClass('input-group series');
var inputEl = $('', {
type: 'text',
name: 'required_exam[]'
}).addClass('form-control');
var groupEl = $('', {
}).addClass('input-group-btn');
/* REQUIRED DISABLED FROM HUMANITAS 8/6/2018*/
if ($('.series', requiredExamEl).length < 6) {
if ($('.series', requiredExamEl).length < 1 && getParameterByName('exam_name') != ' ') inputEl.attr("readonly", "true")
var buttonEl = $('', {
type: 'button'
})
.addClass('btn btn-default bg-green')
.append($('').addClass('glyphicon glyphicon-plus'));
groupEl.append(buttonEl);
buttonEl.on('click', function () {
$(this).remove();
containerEl.removeClass('input-group');
requiredExamEl.append(createRequireExamEl());
});
}
containerEl.append(inputEl);
containerEl.append(groupEl);
return containerEl;
}
requiredExamEl.append(createRequireExamEl());
$window.onesubmitattime = false;
// form prenotazione
$('form.x-form.booking')
.off()
.on('focus click', 'input, textarea, div.checkbox', function (e) {
$(this).parents('.form-group').removeClass('has-error');
})
.on('submit', function (e) {
e.preventDefault();
e.stopPropagation();
var formEl = $(this);
var formLogEl = $('.formlog', formEl);
formLogEl.text('Invio dati in corso...').removeClass('error');
// validazione dei campi
formEl.removeClass('error').removeClass('success').addClass('wait');
var inputs = $('input, textarea, select', formEl).not($('input, textarea, select', $('.validation-skip', formEl)));
inputs.prop('disabled', 'disabled');
inputs.each(function () {
if ($(this).attr('type') != 'submit') {
var isCurValid = 1;
if ($(this).parents('div.form-group').hasClass('required')) {
if (($(this).attr('type') == 'checkbox' && !$(this).is(':checked')) || $(this).val() == '') {
isCurValid = 0;
}
}
if ($(this).val() != '') {
// check content correctness
var regex = new RegExp();
switch ($(this).attr('type')) {
case 'tel': {
regex = /^\+?\d[0-9 .]{7,12}\d$/;
break;
}
case 'email': {
regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
break;
}
case 'password': {
regex = /^([a-zA-Z0-9_-]){6,}$/;
break;
}
case 'file': {
regex = /^[a-zA-Z0-9]+.*$/;
break;
}
default: {
if ($(this).data('maskdate') !== undefined)
regex = /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/;
}
}
isCurValid = isCurValid & regex.test($(this).val());
}
if (!isCurValid)
$(this).parents('.form-group').addClass('has-error');
else
$(this).parents('.form-group').removeClass('has-error');
}
});
// validate imp-rossa e imp-elett
if ($('#imp-rossa.has-error', formEl).length == 0) $('#imp-elett', formEl).removeClass('has-error');
else if ($('#imp-elett.has-error', formEl).length == 0) $('#imp-rossa', formEl).removeClass('has-error');
// controllo se ha inserito request_exams
var requestExams = $('[name="required_exam[]"]', formEl);
var isValid = requestExams.length > 0 && $('.has-error', formEl).length == 0;
inputs.prop('disabled', false);
if (!isValid) {
formEl.removeClass('wait').addClass('error');
inputs.prop('disabled', false);
formLogEl.text('Errore! Controlla i dati e riprova').addClass('error');
return;
}
$('', {
class: 'full-loader'
}).appendTo(formEl);
var data = formEl.serializeObject();
if (sessionStorage.getItem('exam_area') != '') {
data["interest_area"] = sessionStorage.getItem("exam_area");
}
$('', {
class: 'full-loader'
}).appendTo(formEl);
data.contract_category = "SSN";
if (!(data.hospital)) data.hospital = "ICH";
data.hospital_name = window.hospitalName[data.hospital.toLowerCase()].name;
if (window.webpage !== "mail") {
// $.post(URL_FORM_POST2, { JsonString: JSON.stringify(data) }, function (d) {
// });
if (data.donation)
data.donation = data.donation.filter(function (d) { return d !== ""; }).join(",");
}
$scope.status = 'isloading';
if ($window.onesubmitattime == false) {
$window.onesubmitattime = true;
$.post(URL_FORM_POST, { JsonString: JSON.stringify(data) }, function (d) {
if (d.status == 'KO') {
$('div.full-loader').remove();
formLogEl.text('Errore! Controlla i dati e riprova').addClass('error');
$window.onesubmitattime = true;
$scope.status = '';
} else {
if (sessionStorage.getItem("urlback") && sessionStorage.getItem("urlback") != '')
$.getJSON(sessionStorage.getItem("urlback"), function (result) {
if (result.esito) {
formLogEl.text('Successo! Dati inviati');
setTimeout(function () {
location.href = apiUrl + "../Form/Newsletter";
}, 3000);
}
});
else {
$scope.status = '';
formLogEl.text('Successo! Dati inviati');
setTimeout(function () {
location.href = apiUrl + "../Form/Newsletter";
}, 3000);
}
}
}, 'json')
.fail(function () {
onesubmitattime = false;
formLogEl.text('Errore! Controlla i dati e riprova').addClass('error');
});
}
return false;
});
var exam = "";
var now = new Date();
String.prototype.alphaNumeric = function () {
return this.replace(/[^a-z0-9]/gi, '');
}
if (getParameterByName('exam_name') != null) {
exam = getParameterByName('exam_name') + " - [" + getParameterByName('exam_code') + "] ";
$(".exam-title").html(getParameterByName('exam_name'));
if (getParameterByName('exam_name') != ' ') $("[name='required_exam[]']").val(exam);
}
try {
sessionStorage.setItem('urlback', getParameterByName('urlback'));
sessionStorage.setItem('exam_area', getParameterByName('exam_area'));
var token = getParameterByName('token');
var token2valid = getParameterByName('exam_code') + now.getDate() + (now.getMonth() + 1);
if (token === null || !(atob(token).indexOf(token2valid) > 0)) {
window.history.replaceState({}, document.title, window.location.href.split("?")[0]);
setTimeout(function () { window.location = "https://prenota.humanitas.it/" });
}
} catch (e) {
window.history.replaceState({}, document.title, window.location.href.split("?")[0]);
setTimeout(function () { window.location = "https://prenota.humanitas.it/" });
}
window.history.replaceState({}, document.title, window.location.href.split("?")[0]);
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('OtpDialogController', ['$scope', '$modalInstance', 'title', 'message', 'buttons', 'bodyhtml', 'data',function ($scope, $modalInstance, title, message, buttons, bodyhtml,data) {
$scope.title = title;
$scope.message = message;
$scope.buttons = buttons;
$scope.bodyhtml = bodyhtml;
$scope.data = data;
$scope.close = function (value) {
$modalInstance.close(value);
}
$scope.modal = $modalInstance;
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('PaymentFormController', ['$scope',
function ($scope) {
//window.onbeforeunload = null;
}
]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('PlannedReservationController', ['$scope', 'apiUrl', '$http', '$modal', '$window',
function ($scope, apiUrl, $http, $modal, $window) {
$scope.removeReservation = function (actionUrl) {
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return 'Attenzione'; },
message: function () { return 'Sei sicuro di voler annullare la prenotazione?'; },
bodyhtml: function () { return ''; },
buttons: function () {
return [{
label: 'Annulla',
value: -1,
cssClass: 'clear-humanitas'
}, {
label: 'Conferma',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
});
modalInstance.result.then(function (value) {
if (value === 0) $window.location.href = actionUrl;
}, function () {
});
}
$scope.showPlanner = function (reservation_id, exam_id, booking_date, doctor_id, is_ssn, provider_type, hospital, room) {
var modalInstance = $modal.open({
size: 'lg',
controller: 'ReplanReservationController',
template: function () {
return $('#planner').html();
},
resolve: {
reservation_id: function () {
return reservation_id;
},
exam_id: function () {
return exam_id;
},
booking_date: function () {
return booking_date;
},
doctor_id: function () {
return doctor_id;
},
is_ssn: function () {
return is_ssn;
},
provider_type: function () {
return provider_type;
},
hospital: function () {
return hospital;
},
room: function () {
return room;
}
}
});
}
}
]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('PortalCheckinController', ['$scope', '$modalInstance', 'sourceData', 'apiUrl', '$http', '$timeout', '$modal', 'PortalReservationProvider', '$window',
function ($scope, $modalInstance, sourceData, apiUrl, $http, $timeout, $modal, PortalReservationProvider, $window) {
//$scope.exam_id inizializzato nel dom
$scope.status = 'isloading';
$scope.qractivated = false;
$scope.preventCharError = function (s) {
s = s.replace(/(l)[^\x00-\x7F]([aeiou])/gi, "$1'$2");
s = s.replace(/(pi)[^\x00-\x7F]/gi, 'più');
s = s.replace(/[^\x00-\x7F]/g, '');
return s;
};
$(".scancam").hide();
$(".scanfile").hide();
$scope.order = sourceData;
$scope.apply = function () {
$scope.close(-1);
}
$scope.close = function () {
$scope.qrcode.stop();
$modalInstance.close(-1);
}
if ($window.isMobile) {
if ($scope.order.ticket == null || $scope.order.ticket === '') {
$scope.status = 'noticket';
$(".scancam").show();
$(".scanfile").hide();
$scope.formatDate = function (examDate) {
return moment(examDate).format('ddd D MMM. [ore:] HH:mm');
}
var getbyfile = function () {
//if ($scope.cameraId !== "") return;
$(".scancam").hide();
$(".scanfile").show();
var fileinput = document.getElementById('qr-input-file');
fileinput.addEventListener('change', function (e) {
if (e.target.files.length == 0) {
// No file selected, ignore
return;
}
const imageFile = e.target.files[0];
// Scan QR Code
$scope.qrcode.scanFile(imageFile, true)
.then(onsuccessqrcode)
.catch(function (err) {
// failure, handle it.
console.log("Error scanning file. Reason: " + err)
});
});
}
var onsuccessqrcode = function (qrcode) {
var o = $scope.order;
var qrxb = {
'BLD2': 'sELiIkwMPXWd',
'BLD3': 'bhGQhwJMVMFz',
'BLD4': 'lI7F8_LF6X0z',
'BLD5': 'C7L8oFeDZ39N',
'BLD8': 'yQhsE4lq925f',
'BLDFIO': 'kgy4mfIHUtby',
'BLDVS': '92aqqkyFowA8',
'BLD1PIOX': 'y2dr7wzZaNVE',
'BLD2PIOX': '35tBeemPnGWh',
'BLD3PIOX': 'eEfWn4NQQsRU',
'BLD4PIOX': 'ZkvgEGcL7ps4',
'BLD5PIOX': 'WQfiyqJ3YbIC',
'BDLBRE': 'TxYXhi6i2PeK',
'BDLDEA': '2VG271b3vI1t',
'BLDDOM': 'tPsOZo_HTlBn',
'BLDMON': 'Dhqg22bRNxbW',
'BDLMUR': 'gSeTrCdOSoi4',
'BLDPRE': 'gyJLDBh46lkK',
};
$scope.qrcode.stop();
$(".scancam").hide();
if (qrxb[o.locations[0].building.code] !== qrcode) {
var msg = "Gentile utente, sta eseguendo il check-in nella struttura errata, la prego di verificare di essere presso " + o.locations[0].building.name;
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return 'Attenzione'; },
message: function () { return '' },
bodyhtml: function () { return '
e a partire da 30 minuti prima dell'orario indicato nella prenotazione",
"videochiamata": "Start VideoCall",
"invia-file": "Send File",
"file-ricevuti": "Files Received",
"file-inviati": "Files Sent",
},
"it": {
"messaggio": "E` possibile accedere alla videochiamata una volta saldato l'importo dell'appuntamento
e a partire da 30 minuti prima dell'orario indicato nella prenotazione",
"videochiamata": "Inizia Videochiamata",
"invia-file": "Invia Documenti",
"file-ricevuti": "Scarica Documenti",
"file-inviati": "Documenti Inviati",
},
"ru": {
"messaggio": "E` possibile accedere alla videochiamata una volta saldato l'importo dell'appuntamento
e a partire da 30 minuti prima dell'orario indicato nella prenotazione",
"videochiamata": "видеозвонок",
"invia-file": "Отправить файлы",
"file-ricevuti": "полученные файлы",
"file-inviati": "файлы отправлены",
}
};
$scope.language = navigator.language.substr(0, 2).toLowerCase();
$scope.status = 'isloading';
$scope.qractivated = false;
$scope.preventCharError = function (s) {
s = s.replace(/(l)[^\x00-\x7F]([aeiou])/gi, "$1'$2");
s = s.replace(/(pi)[^\x00-\x7F]/gi, 'più');
s = s.replace(/[^\x00-\x7F]/g, '');
return s;
};
$scope.formatDate = function (examDate) {
return moment(examDate).format('ddd D MMM. [ore:] HH:mm');
}
$scope.showTicket = function (order) {
$scope.showCheckin(order);
}
$scope.isToday = function (date)
{
return moment(date).isSame(new Date(), 'day');
}
$scope.isAfterToday = function (date)
{
return moment(date).isSame(new Date(), 'day');
}
$scope.showTelevisita = function (functione, order)
{
var ordernumber = order.orders[0].number;
var urlViewer = $sce.trustAsResourceUrl(`https://test-mc-portal-teleconsulto.humanitas.it/${functione}?nrOrdine=${ordernumber}`);
if (true&&!$scope.isToday(order.scheduledon) && functione==="meet")
{
$modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return $scope.buttonTele[$scope.language]["messaggio"]; },
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
// no op
}
});
return;
}
if (functione === 'meet')
{
window.open(`https://test-mc-portal-teleconsulto.humanitas.it/${functione}?nrOrdine=${ordernumber}`);
return;
}
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return $sce.trustAsHtml(``); },
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
// no op
}
});
};
$scope.showCheckin = function (order) {
var controller = 'PortalCheckinController';
var template = 'CheckinDialog';
var ticket = order.ticket;
$modal.open({
windowClass: 'sidepanel hospitals-container right',
template: $('#' + template).html(),
controller: controller,
resolve: {
selected: function () {
return "";
},
sourceData: function () {
return order;
}
}
}).result.then(function () {
if (ticket !== order.ticket) {
var msg = "ACCETTAZIONE CONCLUSA! Recati presso " + o.locations[0].room.name + " e attendi la chiamata in ambulatorio. Verra chiamato dal medico con il numero " + o.ticket;
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return '
';
},
buttons: function () {
return [{
label: 'VERIFICA',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result) {
if (result == 0) {
$scope.status = 'isloading';
$("#verify-cf").click();
}
});
} else {
$scope.status = '';
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
scope: $scope,
resolve: {
title: function () { return 'Attenzione'; },
message: function () { return '' },
vatcode: function () { return data.vatcode },
bodyhtml: function () {
return '
Si prega di ricontrollare la correttezza del codice e il numero telefonico associato.';
},
buttons: function () {
return [{
label: 'Ok',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result) {
if (result === 0) {
$scope.status = '';
}
});
}
});
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('PortalReservationSidepanelController', ['$scope', '$modalInstance', 'apiUrl', 'sourceData', '$window', function ($scope, $modalInstance, apiUrl, sourceData, $window) {
$scope.sourceData = sourceData;
// Removing object from
// associative array
$scope.status = "";
$scope.hospitals = _.map($window.hospitalName, function (v, k) {
/*
switch (k.toUpperCase()) {
case 'ARS':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Arese";;
v.ssn_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC Arese";
break;
case 'LAI':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Lainate";;
v.ssn_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC Lainate";
break;
case 'BUS':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Busto Arsizio";;
v.ssn_url = "";
break;
case 'HMD':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "Mater Domini";;
v.ssn_url = apiUrl + "../Error/SSNError?message=%C3%88%20stato%20raggiunto%20il%20numero%20massimo%20di%20prenotazioni%20on%20line%20previste%20per%20la%20giornata.%20%20Per%20prenotare%20chiamare%20il%20numero%200331%20476210%20dal%20luned%C3%AC%20al%20venerd%C3%AC%20dalle%208.30%20alle%2017.%20%20E%20il%20sabato%20dalle%208.30%20alle%2012.30.";
// "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital="+"Mater Domini";
break;
case 'MCHDEA':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC De Angeli";;
v.ssn_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC De Angeli";
break;
case 'MCHMUR':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Milano Murat";;
v.ssn_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC Milano Murat";
break;
case 'MCHMON':
v.ssn_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Monza";;
v.lp_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC Monza";
break;
case 'MCHBRE':
v.ssn_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Monza";;
v.lp_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC Monza";
break;
case 'HMCDOM':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Domodossola";;
v.ssn_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC Domodossola";
break;
case 'CDVDIA':
case 'CDV':
v.lp_url = "https://www.humanitas-care.it/prenota/?hospital=" + "HMC Varese";;
v.ssn_url = "https://www.humanitas-care.it/prenotazione-in-ssn/?hospital=" + "HMC Varese";
break;
/*
case '':
break;
default:
v.ssn_url = "";
v.lp_url = "";
}
*/ {
switch (k.toUpperCase()) {
case 'ARS':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'LAI':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'BUS':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = "";
break;
case 'HMD':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../error/ssnerror?message=%c3%88%20stato%20raggiunto%20il%20numero%20massimo%20di%20prenotazioni%20on%20line%20previste%20per%20la%20giornata.%20%20per%20prenotare%20chiamare%20il%20numero%200331%20476210%20dal%20luned%c3%ac%20al%20venerd%c3%ac%20dalle%209.30%20alle%2016.30%20%20e%20il%20sabato%20dalle%208.30%20alle%2012.30.";
// "/form/ssn?hospital="+k.toUpperCase();
break;
case 'MCHDEA':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'MCHMUR':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'MCHMON':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'MCHBRE':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'ICHPRE':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = "";
break;
case 'HMCDOM':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'CDVDIA':
case 'CDV':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/" + k.toUpperCase();
break;
case 'ICHFIO':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = "";
break;
case 'ICH':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/ICH";
break;
case 'ICHPIO':
v.lp_url = apiUrl + "../Form/lp?exam_name=" + $scope.sourceData.exam_name + "&exam_code=" + $scope.sourceData.exam_code + "&price=0,00&hospital=" + k.toUpperCase();
v.ssn_url = apiUrl + "../prestazioni/" + $scope.sourceData.exam_seo + "/ssn/ICHPIO";
break;
case '':
break;
default:
v.ssn_url = "";
v.lp_url = "";
}
}
return v;
});
$scope.order = $scope.sourceData;
$scope.dove = _.keys($window.hospitalName).join("|");
$scope.apply = function () {
$scope.close(-1);
}
$scope.close = function () {
$modalInstance.close(-1);
}
$scope.formatDate = function (examDate) {
return moment(examDate).format('ddd D MMM. [ore:] HH:mm');
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('RefertiMenuController', ['$scope', '$http', 'apiUrl', '$window',
function ($scope, $http, apiUrl, $window)
{
$scope.refertidata = { type_switch: "", type_switch_to:"",account_id: "", AuthorizedPatients: [] };
$scope.status = "no_data";
$http({
method: "GET",
url: apiUrl + "referti/me",
params: {},
}).then(function (response)
{
$scope.status = 'has_results';
$scope.refertidata = response.data;
if ($scope.refertidata)
{
if ($scope.refertidata.type_switch === "OSPITE")
{
$scope.refertidata.type_switch_to = $scope.refertidata.type_switch;
$scope.refertidata.type_switch = "delegato di";
} else
{
$scope.refertidata.type_switch_to = $scope.refertidata.type_switch;
$scope.refertidata.type_switch = "paziente";
}
} else
{
$scope.refertidata = { type_switch: "", account_id: "", AuthorizedPatients:[] };
}
});
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _) {
ngmodule.controller('RefertiHospitalController', ['$scope', '$modalInstance', 'apiUrl', 'sourceData', '$window', function ($scope, $modalInstance, apiUrl, sourceData, $window) {
$scope.sourceData = sourceData;
// Removing object from
// associative array
$scope.status = "";
$scope.hospitals = $window.hospitalName;
$scope.changeStatus = function (status) {
$scope.status = status;
}
$scope.apply = function () {
$scope.close(-1);
}
$scope.close = function () {
$modalInstance.close(-1);
}
}]);
})(angular, angular.module('frontoffice.controllers'), jQuery, _);
(function (ng, ngmodule, $, _, moment)
{
ngmodule.controller('RefertiController', ['$scope', 'apiUrl', '$http', '$timeout', '$modal', 'PortalReservationProvider', '$window', '$sce',
function ($scope, apiUrl, $http, $timeout, $modal, PortalReservationProvider, $window, $sce)
{
//$scope.exam_id inizializzato nel dom
$scope.status = '';
$scope.refertidata = {};
$scope.documentTypes = [];
$scope.fullname = "";
$scope.patientData = {};
$scope.signdata = {};
$scope.windowreload = function (url)
{
setTimeout(function ()
{
if (url) window.location.href = url;
else window.location.reload();
}, 1000);
}
$scope.consent = {
"CNSPPT01": false,
"CNSPPE01": false
};
$scope.token = '';
$scope.qractivated = false;
$scope.preventCharError = function (s)
{
s = s.replace(/(l)[^\x00-\x7F]([aeiou])/gi, "$1'$2");
s = s.replace(/(pi)[^\x00-\x7F]/gi, 'più');
s = s.replace(/[^\x00-\x7F]/g, '');
return s;
};
$scope.configs = {};
$scope.formatDate = function (examDate)
{
return moment(examDate).format('ddd D MMM. [ore:] HH:mm');
}
$scope.showTicket = function (order)
{
$scope.showCheckin(order);
}
$http({
method: "GET",
url: apiUrl + "referti/me",
params: {},
}).then(function (response)
{
$scope.refertidata = response.data;
if ($scope.mode !== "consent" && $scope.refertidata.consent === '')
{
var account = _.filter($scope.refertidata.AuthorizedPatients, { "vatcode": $scope.PatientVATCode });
if ($scope.block)
{
return;
} else
{
if (account.length > 0 && $scope.refertidata.type_switch !== "")
{
window.location.href = window.url + `/Referti/Switch?account_id=&vatcode=${account[0].vatcode}`;
} else
{
window.location.reload();
}
}
}
if ($scope.refertidata)
{
if ($scope.refertidata.type_switch === "OSPITE" || $scope.refertidata.type_switch ==="")
{
$scope.refertidata.type_switch_to = "delegato";
$http({
method: "GET",
url: apiUrl + "referti/configs",
params: {},
}).then(function (response)
{
if (response.status == 500) { window.location.reload() }
else
{
$scope.status = 'has_results';
$scope.configs = response.data;
$scope.configs = {
"enabled": (response.data.enabled && response.data.enabled !== null) ? response.data.enabled : false,
"email": (response.data.email && response.data.email !== null) ? response.data.email : false,
"sms": (response.data.sms && response.data.sms !== null) ? response.data.sms : false,
"period": (response.data.period && response.data.period !== null) ? response.data.period : "instant",
"notificationStatus": response.data.notificationStatus
};
if ($scope.configs.period == "weekly") // new user
{
$scope.configs.enabled = true;
$scope.configs.email = true;
$scope.configs.sms = true;
$scope.configs.period = "instant";
$scope.saveSettings();
}
if ($scope.documents.length == 0) $scope.status = 'no_results';
}
$scope.status = 'has_results';
}, function (response)
{
window.location.reload();
});
} else
{
$scope.refertidata.type_switch_to = "paziente";
}
$scope.fullname = $scope.refertidata.fullname;
$scope.refertidata.patient_data.birthDateIso = $scope.refertidata.patient_data.birthDate;
$scope.refertidata.patient_data.birthDate = moment($scope.refertidata.patient_data.birthDate).format('DD/MM/YYYY');
$scope.patientData = $scope.refertidata.patient_data;
//$scope.patientData = $scope.userData;
} else
{
$scope.refertidata = { type_switch: "", account_id: "", AuthorizedPatients: [] };
}
});
$scope.showCheckin = function (order)
{
var controller = 'PortalCheckinController';
var template = 'CheckinDialog';
var ticket = order.ticket;
$modal.open({
windowClass: 'sidepanel hospitals-container right',
template: $('#' + template).html(),
controller: controller,
resolve: {
selected: function ()
{
return "";
},
sourceData: function ()
{
return order;
}
}
}).result.then(function ()
{
if (ticket !== order.ticket)
{
var msg = "ACCETTAZIONE CONCLUSA! Recati presso " + o.locations[0].room.name + " e attendi la chiamata in ambulatorio. Verra chiamato dal medico con il numero " + o.ticket;
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return '
La visualizzazione è possibile con la funzione 'Richiesta Documentazione Clinica'
`); },
buttons: function ()
{
return [
{
label: 'Richiedi Documentazione Clinica',
value: 0,
cssClass: 'success-humanitas'
}
,{
label: 'ANNULLA',
value: -1,
cssClass: 'clear-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
window.open("/Referti/CartellaClinica/?op=clinicalrequest", "_blank");
}
});
}
$scope.showDocumentImage = function (accessionNumber, docProv)
{
if (window.isMobile)
{
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return `Attenzione`; },
message: function ()
{
return "Le immagini diagnostiche sono consultabili accedendo al sito www.humanitasconte.it esclusivamente da PC, non da cellulare.";
},
bodyhtml: function ()
{
return ""
},
buttons: function ()
{
return [{
label: 'OK',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
// no op
}
});
return;
}
if(accessionNumber.indexOf("|")>0){
var studies=accessionNumber.split("|");
for(var i=0;i< studies.length;i++){
$http({
method: "GET",
url: apiUrl + `referti/studies?accessionNumber=${studies[i]}&docProv=${docProv}`,
params: {},
}).then(function (response) {
if(response.data){
var study=response.data.studies;
$("#acc"+study.accessionNumber).html(`${study.accessionNumber} - ${study.studyDescription}`);
}
$("#acc"+study.accessionNumber).on("click",function(){
$scope.showDocumentImage(study.accessionNumber,docProv);
});
});
}
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return `Scegli l'immagine da visualizzare / scaricare:`; },
message: function () { return '' },
bodyhtml: function () { return $sce.trustAsHtml(`
${studies.map(function(s){
return ``;
}).join("")}
`); },
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
// no op
}
});
}else {
var urlViewer = $sce.trustAsResourceUrl(`https://${$window.location.hostname}/${apiUrl}/referti/documents/viewer?accessionNumber=${accessionNumber}&docProv=${docProv}`);
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return $sce.trustAsHtml(``); },
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
// no op
}
});
}
};
$scope.printPDF = function (documentid,status,d)
{
$scope.showDocument(documentid,status, true,d);
}
$scope.consentSign = function ()
{
let patientData = $scope.patientData;
let userData = $scope.userData;
var documentId = "accetta";
if ($scope.documentId && $scope.documentId !== "")
{
documentId = $scope.documentId;
$scope.consent.CNSPPE01 = "false";
$scope.consent.CNSPPT01 = "false";
} else
{
$scope.consent.CNSPPE01 = "true";
$scope.consent.CNSPPT01 = "true";
}
var requestData = {
"values":
{
"constraints": {
"variables": { "examExecutionDate": "" },
"consensusConstraints": {
"CNSPPE01": "" + $scope.consent.CNSPPE01,
"CNSPPT01": "" + $scope.consent.CNSPPT01
}
},
"agent": {
"patient":
{
"patientId": patientData.patient_id,
"fiscalCode": patientData.vatcode,
"name": patientData.name,
"lastName": patientData.lastname,
"birthDate": patientData.birth_date
},
"authenticator":
{
"name": userData.firstname,
"surname": userData.lastname,
"fiscalCode": userData.vatcode,
"sex": (userData.vatcode.substring(9, 11) >= "40") ? "Maschio" : "Femmina",
"role": $scope.refertidata.type_switch ?? "Paziente"
},
"operator": {
"name": userData.firstname,
"surname": userData.lastname,
"fiscalCode": userData.vatcode,
}
}
},
"otp": {
}
}
$http({
method: "GET",
url: apiUrl + "referti/consent/sign-type",
params: {},
}).then(function (response)
{
if (response.status == 500) { window.location.reload() }
else
{
$scope.signdata = response.data;
//if (patientData.registration_method === "AUTOREGISTRATION" || patientData.registration_method !== 'SECURE')
if ($scope.signdata && $scope.signdata.certificates.length===0)
{
$scope.status = 'isloading';
if ($scope.documentId && $scope.documentId !== "")
{
documentId = $scope.documentId;
requestData["values"]["constraints"]["consensusConstraints"]["CNSPPE01|start_date"] = moment().utc().format().replace(/\+00:00/, "Z");
requestData["values"]["constraints"]["consensusConstraints"]["CNSPPT01|start_date"] = moment().utc().format().replace(/\+00:00/, "Z");
}
$scope.status = 'isloading';
$http({
method: "POST",
url: apiUrl + "/referti/consensus/" + documentId + "/contract",
data: requestData,
}).then(function (response)
{
if (_.isUndefined(response))
{
$scope.status = 'has_results';
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return "Errore imprevisto!"; },
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
window.location.reload();
}
});
} else
if (response && response.data && response.data?.code === 442)
{
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return "Errore imprevisto!"; },
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
window.location.reload();
}
});
} else
{
window.location.href="/Referti/Documents";
}
}, function (response)
{
$scope.status = 'nodata';
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function () { return "Errore imprevisto!"; },
buttons: function ()
{
return [{
label: 'CHIUDI',
value: 0,
cssClass: 'success-humanitas'
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
// no op
}
});
});
}
else
{
var pin = "";
var pinRequestDialog = $modal.open({
templateUrl: 'otp-sing-referti.html',
controller: 'OtpDialogController',
windowClass: 'center-modal ',
backdrop: 'static',
keyboard: true,
resolve: {
title: function () { return 'Firma del consenso'; },
message: function ()
{
return "";
},
data: function ()
{
return { 'otp': false, 'pin': true };
},
bodyhtml: function ()
{
return "E’ necessario firmare il consenso per poter accedere all’area referti.
" +
"Inserire il PIN personale e in seguito richiedere l’invio via SMS del codice OTP";
},
buttons: function ()
{
return [{
label: 'Richiedi codice OTP',
value: 0,
functionButton: function ($modalInstance)
{
pin = $("#pin").val();
if (pin !== '')
{
$scope.status = 'isloading';
$http({
method: "POST",
url: apiUrl + "/referti/consensus/contract/get-otp",
data: { "ssn": userData.vatcode, "pin": pin },
}).then(function (response)
{
$scope.status = 'has_results';
var otp = "";
if (response.data.code === 422)
{
$("#pin").css("border", "1px solid red");
$("#otp-error").html(response.data.message);
return true;
}
$modalInstance.close(0);
function otgsubmit()
{
requestData["otp"] = { "ssn": userData.vatcode, "pin": pin, "otp": otp };
requestData["documentId"] = documentId;
$scope.status = 'isloading';
$http({
method: "POST",
url: apiUrl + "/referti/consensus/contract/sign-otp",
data: requestData,
}).then(function (response)
{
if (response.data.code === 422)
{
$scope.status = 'has_results';
$("#otp").css("border", "1px solid red");
$("#otp-error").html(response.data.message);
return true;
}
setTimeout(function ()
{
window.location.href = window.url + '/Referti';
}, 500);
});
}
var otpRequestDialog = $modal.open({
templateUrl: 'otp-sing-referti.html',
controller: 'OtpDialogController',
windowClass: 'center-modal ',
resolve: {
title: function () { return `Firma del consenso`; },
message: function () { return '' },
data: function () { return { 'otp': true, 'pin': false }; },
bodyhtml: function () { return "" },
buttons: function ()
{
return [{
label: 'Firma e concludi',
value: 0,
functionButton: function ($modalInstance)
{
otp = $("#otp").val();
if (otp !== '')
{
otgsubmit();
} else
{
$("#otp").css("border", "1px solid red");
}
},
cssClass: 'success-humanitas'
}, {
label: 'Annulla',
value: -1,
cssClass: 'clear-humanitas',
functionButton: function ($modalInstance)
{
$modalInstance.close(-1);
},
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
// window.location.reload();
}
});
$("#otp").on("keydown", function (event)
{
if(event.key === "Enter") {
otgsubmit();
}
})
});
} else
{
$("#pin").css("border", "1px solid red");
}
},
cssClass: 'success-humanitas'
}, {
label: 'Annulla',
value: -1,
cssClass: 'clear-humanitas',
functionButton: function ($modalInstance)
{
$modalInstance.close(-1);
},
}];
}
}
}).result.then(function (result)
{
if (result == 0)
{
}
});
}
}
}, function (response)
{
window.location.reload();
});
}
$scope.closePreviousVersions = function (documentid)
{
$scope.alldocuments = _.map($scope.alldocuments, function (d)
{
if (d.id === documentid || d.documentId === documentid)
{
d.previousVersions = [];
}
return d;
});
$scope.applyfilters();
};
$scope.showDocumentVersions = function (documentid)
{
$http({
method: "GET",
url: apiUrl + "/referti/documents/versions",
params: { documentid: documentid },
}).then(function (response)
{
if (response.status == 500) { window.location.reload() }
else
{
$scope.alldocuments = _.map($scope.alldocuments, function (d)
{
if (d.status === "OFFLINE")
{
d.icon = "/images/custom/" + d.documentType.code +"-20.svg";
}
if (d.id === documentid )
{
d.previousVersions = _.filter(_.map(response.data.documents, function (dv)
{
if (dv.status === "OFFLINE")
{
dv.icon = "/images/custom/" + dv.documentType.code + "-20.svg";
}
return dv;
}), function (pv)
{
return pv.id !== documentid;
});
}
return d;
});
$scope.applyfilters();
setTimeout(function ()
{
$('html, body').animate(
{
scrollTop: $("#" + documentid).offset().top,
},
500,
'linear'
);
},300); // fast
}
}, function (response)
{
window.location.reload();
});
};
$scope.showDowloadLinks = function (d, status,docformat, print = false) {
var downloadurl = apiUrl + `/referti/documents/download?documentid=${d.id}&status=${d.status}`;
var modalInstance = $modal.open({
templateUrl: 'alertdialog.html',
controller: 'AlertDialogController',
resolve: {
title: function () { return ''; },
message: function () { return '' },
bodyhtml: function ()
{
var links = `Clicca sul formato con cui vuoi scaricare il documento :
- PDF
- File ZIP
- File ${docformat.replace("application/","")}