diff --git a/src/lib/components/app/FetchAD.svelte b/src/lib/components/app/FetchAD.svelte index 0c26c26a..d1ab3d35 100644 --- a/src/lib/components/app/FetchAD.svelte +++ b/src/lib/components/app/FetchAD.svelte @@ -284,12 +284,13 @@ const contentResponse = await fetchAdvanceDirective(patient.id); content = await contentResponse.json(); hostname = sources[selectedSource].url; - processing = false; let resources: Array = content.entry ? content.entry.map((e: BundleEntry) => { return e.resource; }) : []; if (resources.length === 0) { console.warn("No advance directives found for patient "+patient.id); + processing = false; + return; } // Filter out DR's with 'status' == 'superseded'. In May '24 we included these, @@ -335,7 +336,7 @@ // if one of the DR's const isPolst = (dr: DocumentReferencePOLST) => dr.type && dr.type.coding && dr.type.coding.some(coding => coding.system === 'http://loinc.org' && coding.code === '100821-8'); - resources.forEach(async (dr: DocumentReferencePOLST) => { + for (let dr of resources) { // If this DR is a POLST, add the following chain of queries: if (isPolst(dr)){ dr.isPolst = true; @@ -395,16 +396,18 @@ ); } } - }); - resources.forEach(async (dr: DocumentReferencePOLST) => { + } + + for (let dr of resources) { if (hasPdfContent(dr)) { const pdfContent = dr.content.find(content => content.attachment && content.attachment.contentType === 'application/pdf'); if (pdfContent && pdfContent.attachment && pdfContent.attachment.url) { await injectPdfIntoDocRef (pdfContent.attachment.url, pdfContent.attachment); } } - }); - + } + + processing = false; let result:ResourceRetrieveEvent = { resources: resources, sectionKey: sectionKey, diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 02537b65..5c98723c 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -79,13 +79,27 @@ $isOpen = false; } + let navOpening = false; document.addEventListener('click', (event) => { + // Ignore clicks on the navbar toggler + if (event.target?.className?.includes('navbar-toggler')) return; + // Ignore clicks on the dropdown toggle menu items + if (event.target?.className?.includes('nav-link') && event.target?.className?.includes('dropdown-toggle')) { + navOpening = true; + setTimeout(() => { + navOpening = false; + }, 100); + return; + } closeNav(); }); document.addEventListener('keydown', (event) => { closeNav(); }); + window.addEventListener('scroll', (event) => { + if (document.getElementsByClassName('navbar-collapse collapsing').length > 0) return; + if (navOpening) return; closeNav(); });