${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/WompHealthSearch"; 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); } } } } catch (err) { console.error(err); }