Skip to content

Commit

Permalink
Fix up AD section/template name and POLST ADI PMO bundle parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellrgn committed Oct 17, 2024
1 parent 77a6fc8 commit 74672c8
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 91 deletions.
12 changes: 8 additions & 4 deletions src/lib/FetchAD.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
} from 'sveltestrap';
import { createEventDispatcher } from 'svelte';
import type { DocumentReferencePOLST, ResourceRetrieveEvent } from './types';
import type { Attachment, BundleEntry, CodeableConcept, Resource, ServiceRequest } from 'fhir/r4';
import type { Attachment, BundleEntry, ServiceRequest } from 'fhir/r4';
export let sectionKey: string = "Advance Directive";
export let sectionKey: string = "Advance Directives";
const resourceDispatch = createEventDispatcher<{'update-resources': ResourceRetrieveEvent}>();
Expand Down Expand Up @@ -340,15 +340,19 @@
if (isPolst(dr)){
dr.isPolst = true;
// In the POLST find the content[] with format.code = "urn:hl7-org:pe:adipmo-structuredBody:1.1" (ADIPMO Structured Body Bundle),
const contentAdipmoBundleRef = dr.content.find(content => content.format && content.format.code && content.format.code === 'urn:hl7-org:pe:adipmo-structuredBody:1.1' && content.attachment && content.attachment.url && content.attachment.url.includes('Bundle'));
const contentAdipmoBundleRef = dr.content.find((content) => {
return (content.format?.code === 'urn:hl7-org:pe:adipmo-structuredBody:1.1' && content.attachment?.url?.includes('Bundle'));
});
// look in that content's attachment.url, that will point at a Bundle (e.g. https://qa-rr-fhir2.maxmddirect.com/Bundle/10f4ff31-2c24-414d-8d70-de3a86bed808?_format=json)
const adipmoBundleUrl = contentAdipmoBundleRef?.attachment.url;
if (adipmoBundleUrl) {
// Pull that Bundle.
let adipmoBundle = await fetchResourceByUrl(adipmoBundleUrl);
let adipmoBundleJson = await adipmoBundle.json();
let serviceRequests = adipmoBundleJson.entry.filter((entry: BundleEntry) => entry.resource?.resourceType === 'ServiceRequest');
let serviceRequests = adipmoBundleJson.entry.filter((entry: BundleEntry) => {
return entry.resource?.resourceType === 'ServiceRequest'
}).map((entry: BundleEntry) => entry.resource);
// That bundle will include ServiceRequest resources; look for the one for CPR (loinc 100822-6)
// then set the appropriate flags in the DR
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ResourceSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"Practitioner": Practitioner,
"Procedure": Procedure,
"Occupational Data": OccupationalData,
"Advance Directive": AdvanceDirective
"Advance Directives": AdvanceDirective
};
const ipsDispatch = createEventDispatcher<{ 'ips-retrieved': IPSRetrieveEvent }>();
Expand Down
166 changes: 80 additions & 86 deletions src/lib/resource-templates/AdvanceDirective.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
let isRevoked = false;
// Reactive declaration to update isRevoked when resource.extension changes
$: if (resource.extension) {
isRevoked = resource.extension.some(
ext => ext.url === 'http://hl7.org/fhir/us/pacio-adi/StructureDefinition/adi-document-revoke-status-extension' && ext.valueCoding?.code === 'cancelled'
);
$: {
if (resource.extension) {
isRevoked = resource.extension.some(
ext => ext.url === 'http://hl7.org/fhir/us/pacio-adi/StructureDefinition/adi-document-revoke-status-extension'
&& ext.valueCoding?.code === 'cancelled'
);
}
}
</script>
Expand All @@ -39,51 +42,51 @@ Text:
<br />
-->

<b>Category:</b>
{resource.category?.[0].coding?.[0].display} (LOINC {resource.category?.[0].coding?.[0].code})
<br />
<b>Type:</b>
<!-- 42348-3 is for "Advance Directive"; per cthon, it's presence here is redundant w/ category above. -->
{#if resource.type?.coding?.[0]}
{resource.type?.coding?.[0].display} (LOINC {resource.type?.coding?.[0].code})
{#if resource.category}
<b>Category:</b>
{resource.category?.[0].coding?.[0].display} (LOINC {resource.category?.[0].coding?.[0].code})
<br />
{/if}
{#if resource.type?.coding?.[1]}
{resource.type?.coding?.[1].display} (LOINC {resource.type?.coding?.[1].code})
{#if resource.type?.coding}
<b>Type:</b>
<!-- 42348-3 is for "Advance Directive"; per cthon, it's presence here is redundant w/ category above. -->
{#if resource.type?.coding?.[0]}
{resource.type?.coding?.[0].display} (LOINC {resource.type?.coding?.[0].code})
{/if}
{#if resource.type?.coding?.[1]}
{resource.type?.coding?.[1].display} (LOINC {resource.type?.coding?.[1].code})
{/if}
<br />
{/if}
<br />
<b>Description:</b>
{#if resource.description}
{resource.description}
<b>Description:</b> {resource.description}
<br />
{/if}
<br />
<b>Author:</b>
{#if resource.author && resource.author[0] && resource.author[0].display}
{resource.author?.[0].display}
{#if resource.author?.[0].display}
<b>Author:</b> {resource.author[0].display}
<br />
{/if}
<br />
<b>setId:</b>
{#if resource.identifier?.[0].system == 'https://mydirectives.com/standards/terminology/namingSystem/setId'}
{resource.identifier[0].value}
<b>setId:</b> {resource.identifier[0].value}
<br />
{/if}
<br />
<b>Version number:</b>
{#if resource.extension?.[0].url == 'http://hl7.org/fhir/us/ccda/StructureDefinition/VersionNumber'}
<!-- As of the July '24 this is now a unix time stamp -->
{resource.extension[0].valueInteger}
<b>Version number:</b> {resource.extension[0].valueInteger}
<br />
{/if}
<br />
<!-- This is the date that the DocumentReference resource was created, not of interest.
<b>Date:</b>
{#if resource.date}
{resource.date}
{/if}
<br />
-->
<b>Status:</b>

{#if resource.status}
{resource.status}
<b>Status:</b> {resource.status}
<br />
{/if}
<br />

<!-- Revoke Status -->
{#if resource.extension}
Expand All @@ -95,86 +98,77 @@ Text:
{/each}
{/if}

<b>docStatus:</b>
{#if resource.docStatus}
{resource.docStatus}
<b>docStatus:</b> {resource.docStatus}
<br />
{/if}
{#if resource.description}
<br />
{resource.description}
<br/>
{/if}
<br/>

{#if resource.isPolst}
<br/>
{#if resource.isPolst && (resource.isCpr || resource.isComfortTreatments || resource.isAdditionalTx || resource.isMedicallyAssisted)}
<br/>
<b>
POLST Details:
<br/>
<br/>
POLST Details:
<ul>
{#if resource.isCpr}
<ol>
{#if resource.doNotPerformCpr}
This includes an order to NOT perform CPR.
{:else}
This includes an order to perform CPR.
{/if}
{#if resource.doNotPerformCpr}
This includes an order to NOT perform CPR.
{:else}
This includes an order to perform CPR.
{/if}
</ol>
{/if}
<br/>
{/if}

{#if resource.isComfortTreatments}
{#if resource.isComfortTreatments}
<ol>
{#if resource.doNotPerformComfortTreatments}
This includes an order to NOT perform comfort-focused treatments: {@html resource.detailComfortTreatments}
{:else}
This includes an order to perform comfort-focused treatments: {@html resource.detailComfortTreatments}
{/if}
{#if resource.doNotPerformComfortTreatments}
This includes an order to NOT perform comfort-focused treatments: {@html resource.detailComfortTreatments}
{:else}
This includes an order to perform comfort-focused treatments: {@html resource.detailComfortTreatments}
{/if}
</ol>
{/if}
<br/>
{/if}

{#if resource.isAdditionalTx}
{#if resource.isAdditionalTx}
<ol>
{#if resource.doNotPerformAdditionalTx}
This includes an order to NOT perform additional treatments: {@html resource.detailAdditionalTx}
{:else}
This includes an order to perform additional treatments: {@html resource.detailAdditionalTx}
{/if}
{#if resource.doNotPerformAdditionalTx}
This includes an order to NOT perform additional treatments: {@html resource.detailAdditionalTx}
{:else}
This includes an order to perform additional treatments: {@html resource.detailAdditionalTx}
{/if}
</ol>
{/if}
<br/>
{/if}

{#if resource.isMedicallyAssisted}
{#if resource.isMedicallyAssisted}
<ol>
{#if resource.doNotPerformMedicallyAssisted}
This includes an order to NOT perform medically assisted nutrition: {@html resource.detailMedicallyAssisted}
{:else}
This includes an order to perform medically assisted nutrition: {@html resource.detailMedicallyAssisted}
{/if}
{#if resource.doNotPerformMedicallyAssisted}
This includes an order to NOT perform medically assisted nutrition: {@html resource.detailMedicallyAssisted}
{:else}
This includes an order to perform medically assisted nutrition: {@html resource.detailMedicallyAssisted}
{/if}
</ol>
{/if}
{/if}
</ul>
</b>
<br/>
{/if}

{#if resource.content}
<!-- FIXME This iteration not ideal - should iterate whether pdf present or not, as created & pdfSignedDate (ill-named) actually refer to the larget context of the DR, not the pdf... as it stands the Personal Advance Care Plan Document won't show created/signed (bug), tho we don't care so much about that one in IPS.
<!-- FIXME This iteration not ideal - should iterate whether pdf present or not, as created & pdfSignedDate (ill-named) actually refer to the larger context of the DR, not the pdf... as it stands the Personal Advance Care Plan Document won't show created/signed (bug), tho we don't care so much about that one in IPS.
-->
{#if resource.content[0].attachment.creation}
<b>Created:</b> {new Date(resource.content[0].attachment.creation).toISOString().slice(0,10)}
<br/>
{/if}
{#if resource.pdfSignedDate}
<b>Digitally signed:</b> {new Date(resource.pdfSignedDate).toISOString().slice(0,10)}
<br/>
{/if}
{#each resource.content as content}
{#if content.attachment.contentType === "application/pdf" && content.attachment.data}
{#await base64toBlob(content.attachment.data, content.attachment.contentType) then url}
{#if content.attachment && content.attachment.creation}
<b>Created:</b> {new Date(content.attachment.creation).toISOString().slice(0,10)}
<br/>
{/if}
{#if resource.pdfSignedDate}
<!--
<b>Digitally signed:</b> {new Date(resource.pdfSignedDate).toISOString().slice(0,10)}
<br/>
-->
{/if}
<b>PDF present:</b>
<a href={url} target="_blank" rel="noopener noreferrer">View</a>
{/await}
Expand All @@ -190,12 +184,12 @@ Text:
padding: 10px;
border-radius: 5px;
background-image:
linear-gradient(135deg, rgba(255,255,255,0.3) 25%, transparent 25%),
linear-gradient(225deg, rgba(255,255,255,0.3) 25%, transparent 25%),
linear-gradient(45deg, rgba(255,255,255,0.3) 25%, transparent 25%),
linear-gradient(315deg, rgba(255,255,255,0.3) 25%, transparent 25%);
linear-gradient(135deg, rgba(255,255,255,0.5) 25%, transparent 25%),
linear-gradient(225deg, rgba(255,255,255,0.5) 25%, transparent 25%),
linear-gradient(45deg, rgba(255,255,255,0.5) 25%, transparent 25%),
linear-gradient(315deg, rgba(255,255,255,0.5) 25%, transparent 25%);
background-size: 40px 40px; /* Adjusts the size of the pattern */
background-position: 10px 10px; /* Adjusts the offset of the pattern */
background-position: 15px 15px; /* Adjusts the offset of the pattern */
opacity: 0.95; /* Slight transparency for a more subtle effect */
}
</style>

0 comments on commit 74672c8

Please sign in to comment.