${location.Address.City}, ${location.Address.Region ?? 'TX'} ${location.Address.PostalCode}`; const googleAddress = encodeURIComponent(location.Address.Full); if (address) { address.innerHTML = addressContent; } if (addressBlock) { addressBlock.ariaLabel = location.Address.Full; } if (locationLink) { locationLink.href = location.Url; locationLink.dataset.varsLocationLink = location.Url; } if (moreCareTeamLink) { const params = new URL(moreCareTeamLink.href).searchParams; const doctor = params.get('doctor'); moreCareTeamLink.href = `${location.Url}?doctor=${doctor}&providers=`; } if (moreProvidersLink) { const params = new URL(moreProvidersLink.href).searchParams; const doctor = params.get('doctor'); const providers = params.get('providers'); moreCareTeamLink.href = `${location.Url}?doctor=${doctor}&providers=${providers}`; } if (phoneLink) { if (location.Phone) { phoneLink.innerHTML = location.Phone; phoneLink.href = 'tel:' + location.Phone; phoneLink.parentElement.parentElement.classList.remove('hidden'); } else { phoneLink.parentElement.parentElement.classList.add('hidden'); } } if (directions) { directions.href = "https://maps.google.com/maps/dir//" + googleAddress; } if (careTeamLink) { careTeamLink.href = `/Doctors?LocationId=${location.id}`; } if (primaryTimeslots) { primaryTimeslots.setAttribute('location', location.Address.Full); primaryTimeslots.setAttribute('phone', location.Phone); primaryTimeslots.outerHTML = primaryTimeslots.outerHTML; } } async function updateSimilarProvider(location) { try { let widgetOther = document.querySelector('#widgetOther'); let similarProvEl = document.querySelector('#similarProv'); let similarProvCTA = document.querySelector('#similarCTA'); if (!similarProvEl) { widgetOther.outerHTML = `
`; widgetOther = document.querySelector('#widgetOther'); similarProvEl = document.querySelector('#similarProv'); similarProvCTA = document.querySelector('#similarCTA'); } similarProvEl.innerHTML = ` `; const requiredDegrees = ['MD', 'DO', 'md', 'do']; let providers = await fetch(`https://womphealthapi.azurewebsites.net/api/WompHealthSearch?locations=false&type=search&brand=thr&search=&top=100&LocationId=${location.id}`); providers = await returnJSON(providers) .then(res => { let results = res.results .filter(x => x.Npi !== location.primaryProvider && x.Degrees.some((deg) => requiredDegrees.includes(deg))) .sort((a, b) => { if (a.BookingFlow?.toLowerCase() === 'flow' && b.BookingFlow?.toLowerCase() !== 'flow') { return -1; } if (b.BookingFlow?.toLowerCase() === 'flow' && a.BookingFlow?.toLowerCase() !== 'flow') { return 1; } return 0; }); if (results && results.length) { if (!location.careTeam.length) { if (results.some((prov) => prov.CareTeam.includes(location.primaryProvider.toString()))) { results = results.filter((provider) => { return provider.CareTeam.includes(location.primaryProvider.toString()); }); }; }; } else { console.error('No similar providers in results'); }; return results; }); if (providers[0]) { widgetOther.classList.remove('hidden'); const provider = providers[0]; const similarProviderTemplate = ` ${provider.PrimarySpecialties ? `
${provider.PrimarySpecialties?.map(x => x)}
` : ''} ${provider.Rating ? `
${provider.Rating.toFixed(1)} ` : ''} ${provider.VirtualCare ? `
Offers Video Visits
` : ''}
`; similarProvEl.outerHTML = similarProviderTemplate; switch (provider.BookingFlow.toLowerCase()) { case 'flow': const similarProviderTimeslots = ` `; similarProvCTA.innerHTML = similarProviderTimeslots; return; case 'form': const uriEncodedName = encodeURIComponent(provider.Name); const isStaging = window.location.hostname.includes('uat') || window.location.hostname.includes('texashealthstaging') ? true : false; const formCTA = ` `; similarProvCTA.innerHTML = formCTA; return; case 'call': const callCTA = ` Call For Appointment
`; if (provider.Phones[0]) { similarProvCTA.innerHTML = callCTA; } return; default: similarProvCTA.innerHTML = ''; return; } } else { widgetOther.classList.add('hidden'); similarProvEl.innerHTML = ''; similarProvCTA.innerHTML = ''; } } catch (err) { console.error('Error building similar provider: ', err); } } function toggleHidden(el) { if (el.classList.contains('hidden')) { el.classList.remove('hidden'); } else { el.classList.add('hidden') } } async function returnJSON(res) { if (res.status === 200 || res.ok) { const response = await res.json(); if (response && !/(undefined|false|null)/.test(response)) { return response; } else { console.error('Unexpected response when fetching wompHealth api'); }; } else { console.error('Failure fetching wompHealth api'); }; }; } catch (err) { console.error(err) } machine: ampifyvm4; highPriority: false; fromSitemap: false; fromPortal: false;