${location.address.city}, ${location.address.region} ${location.address.postal} `; if (locationsInfo.length) { locationsInfo.forEach(loc => { if (loc.id !== location.id) { loc.classList.add('hidden'); } else { loc.classList.remove('hidden'); } }); } if (address) { address.innerHTML = addressContent; } if (addressBlock) { addressBlock.ariaLabel = location.address.full; } if (locationLink) { if(!location.url || location.hasUrl==0) { locationLink.classList.add('hidden'); } else { locationLink.classList.remove('hidden'); } locationLink.href = location.url; locationLink.dataset.varsUrlLink = location.url; } if (phoneLink) { if(!location.phone) { phoneIcon.classList.add('hidden'); phoneLink.classList.add('hidden'); } else { phoneIcon.classList.remove('hidden'); phoneLink.classList.remove('hidden'); phoneLink.innerHTML = `${location.phone}`; phoneLink.href = 'tel:' + location.phone; phoneLink.dataset.varsPhoneLink = location.phone; phoneLink.dataset.eventVars = JSON.stringify({phone_number: location.phone}); } } if (primaryTimeslots) { primaryTimeslots.setAttribute('location', location.address.full); primaryTimeslots.setAttribute('phone', location.phone); primaryTimeslotsParent.style.minHeight = primaryTimeslots.offsetHeight.toString() + 'px'; primaryTimeslots.outerHTML = primaryTimeslots.outerHTML; setTimeout(() => { primaryTimeslotsParent.style.minHeight = "auto"; }, 200); } } async function updateSimilarProvider(location) { const similarProvEl = document.querySelector('#provsWrapper'); const origin = "https://womphealthapi.azurewebsites.net/api/OmniSearch"; try { if (similarProvEl) { similarProvEl.innerHTML = `
Specialties: ${specialty}
`; }); const formattedImageUrl = "https://www.ssmhealth.com" + prepSSMProvImg(provider.ImageUrl); const specialtiesString = provider.Specialties.join(", "); similarProvidersTemplate += `${provider.PrimaryNetwork ? provider.PrimaryNetwork : ''}
${SpecialtiesString}
No similar providers at this location were found.
`; console.error('Error building similar provider: ', err); } } function updateCareTeam(location) { const visibleCareTeamMembers = document.querySelectorAll(`.card-body.provider[data-locations]:not(.hidden)`); const allCareTeamMembers = document.querySelectorAll(`.card-body.provider[data-locations]`); const careTeamAtThisLoc = Array.from(allCareTeamMembers).filter(n => n.dataset.locations.includes(location.id)); const careTeamWrapper = document.querySelector('#similarProvs'); if(careTeamAtThisLoc.length < 1 && !careTeamWrapper.classList.contains('hidden')) { careTeamWrapper.classList.add('hidden'); } else if(careTeamAtThisLoc.length > 0 && careTeamWrapper.classList.contains('hidden')) { careTeamWrapper.classList.remove('hidden'); } visibleCareTeamMembers.forEach(el => { toggleHidden(el); }); careTeamAtThisLoc.forEach(el => { const timeslots = el.querySelector('provider-timeslots'); toggleHidden(el); const provImg = el.querySelector('amp-img'); const provCareTile = el.querySelector('amp-list'); nudgeAmpElementLayout(provImg); nudgeAmpElementLayout(provCareTile); if (timeslots) { timeslots.setAttribute('dep-id', location.id); timeslots.setAttribute('location', location.address.full); timeslots.setAttribute('phone', location.phone); timeslots.setAttribute('loc-specialty', location.specialty); timeslots.outerHTML = timeslots.outerHTML; } }); } function toggleHidden(el) { if (el.classList.contains('hidden')) { el.classList.remove('hidden'); } else { el.classList.add('hidden'); } } function nudgeAmpElementLayout(ampElement) { if (!ampElement) return; if (ampElement.hasAttribute('data-no-nudge')) return; if (ampElement['__AMP__RESOURCE'] && ampElement['__AMP__RESOURCE'].isLayoutPending && ampElement['__AMP__RESOURCE'].isLayoutPending() && ampElement['__AMP__RESOURCE'].startLayout) { try { console.log('Manually called layout for ' + ampElement.tagName.toLowerCase()); ampElement['__AMP__RESOURCE'].layoutScheduled(Date.now()); ampElement['__AMP__RESOURCE'].startLayout(); } catch (ex) { console.error('Unable to start layout on AMP element\n', ampElement, ex); } } } function getSelectedLocation(locationEl) { if (!locationEl?.classList?.contains('location-select')) return; return { id: locationEl.value, name: locationEl.name, phone: locationEl.dataset.phone, fax: locationEl.dataset.fax, url: locationEl.dataset.url, hasUrl: locationEl.dataset.hasurl, address: { street1: locationEl.dataset.street, street2: locationEl.dataset.suite, city: locationEl.dataset.city, region: locationEl.dataset.region, postal: locationEl.dataset.postal, full: locationEl.dataset.address }, distance: parseFloat(locationEl.dataset.distance).toFixed(2) || null, specialty: locationEl.dataset.specialty, schedulable: locationEl.dataset.schedulable != 'false' }; } function checkAMPState(location) { if (typeof AMP !== 'undefined' && typeof AMP.setState === 'function') { const selectedLocation = getSelectedLocation(location); AMP.setState({providerCareTileInfo: { selectedLocation: selectedLocation.address, selectedLocationId: selectedLocation.id, selectedLocationPhone: selectedLocation.phone, selectedLocationSchedulable: selectedLocation.schedulable }}); return; } else { setTimeout(checkAMPState, 100, location); } } const profilePath = window.location.pathname; const cgProfilePath = /\/cardinal-glennon/i.test(profilePath) ? profilePath.split('/cardinal-glennon')[1] : profilePath; const searchLocation = window.localStorage.getItem(`${cgProfilePath}-SearchLocation`); if (searchLocation) { const LocationEl = Array.from(document.querySelectorAll('.location-select')).find(el => el.value == searchLocation); if (LocationEl) { setLocation(LocationEl); checkAMPState(LocationEl); } } } catch (err) { console.error(err); }