Skip to content

Commit

Permalink
Update date format and add Goal resource template
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellrgn committed Feb 13, 2025
1 parent 2768a67 commit 601270a
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 55 deletions.
6 changes: 3 additions & 3 deletions src/lib/components/resource-templates/AdvanceDirective.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { base64toBlob } from '$lib/utils/util';
import { base64toBlob, formatDate } from '$lib/utils/util';
import type { DocumentReferencePOLST, ResourceTemplateParams } from '$lib/utils/types';
export let content: ResourceTemplateParams<DocumentReferencePOLST>; // Define a prop to pass the data to the component
Expand Down Expand Up @@ -161,11 +161,11 @@ Text:
<!-- 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)}
<b>Created:</b> {formatDate(resource.content[0].attachment.creation)}
<br/>
{/if}
{#if resource.pdfSignedDate}
<b>Digitally signed:</b> {new Date(resource.pdfSignedDate).toISOString().slice(0,10)}
<b>Digitally signed:</b> {formatDate(resource.pdfSignedDate)}
<br/>
{/if}
{#each resource.content as content}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { formatDate } from '$lib/utils/util';
import { Badge } from 'sveltestrap';
import type { AllergyIntolerance } from 'fhir/r4';
import type { ResourceTemplateParams } from '$lib/utils/types';
Expand Down Expand Up @@ -47,4 +48,4 @@
<strong>{resource.code.text}</strong><br>
{/if}
{/if}
{resource.onsetDateTime ? `Since ${resource.onsetDateTime.split("T")[0]}` : ''}
{resource.onsetDateTime ? `Since ${formatDate(resource.onsetDateTime)}` : ''}
5 changes: 3 additions & 2 deletions src/lib/components/resource-templates/Condition.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { formatDate } from '$lib/utils/util';
import { Badge } from 'sveltestrap';
import type { Condition } from 'fhir/r4';
import type { ResourceTemplateParams } from '$lib/utils/types';
Expand Down Expand Up @@ -64,8 +65,8 @@
Site: {resource.bodySite[0]?.coding?.[0]?.display}<br>
{/if}
{#if resource.onsetDateTime}
Since: {resource.onsetDateTime.split("T")[0]}<br>
Since: {formatDate(resource.onsetDateTime)}<br>
{/if}
{#if resource.recordedDate}
Recorded: {resource.recordedDate.split("T")[0]}<br>
Recorded: {formatDate(resource.recordedDate)}<br>
{/if}
16 changes: 10 additions & 6 deletions src/lib/components/resource-templates/DiagnosticReport.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { BundleEntry, DiagnosticReport, Observation } from 'fhir/r4';
import ObservationTemplate from './Observation.svelte';
import type { ResourceTemplateParams } from '$lib/utils/types';
import { getEntry } from '$lib/utils/util';
import { getEntry, formatDate } from '$lib/utils/util';
export let content: ResourceTemplateParams<DiagnosticReport>; // Define a prop to pass the data to the component
Expand Down Expand Up @@ -55,12 +55,16 @@
{/if}
<br>
{#if resource.effectivePeriod}
Effective: {resource.effectivePeriod.start ? resource.effectivePeriod.start : ''}{resource
.effectivePeriod.end
? ` - ${resource.effectivePeriod.end}`
: ''}
Effective: {resource.effectivePeriod.start
? formatDate(resource.effectivePeriod.start)
: '??'
} - {
resource.effectivePeriod.end
? formatDate(resource.effectivePeriod.end)
: '??'
}
{:else if resource.effectiveDateTime}
Date: {resource.effectiveDateTime.split('T')[0]}
Date: {formatDate(resource.effectiveDateTime)}
{/if}
<br>
{#if resource.result}
Expand Down
15 changes: 10 additions & 5 deletions src/lib/components/resource-templates/Encounter.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { formatDate } from '$lib/utils/util';
import { Badge } from 'sveltestrap';
import type { Encounter } from 'fhir/r4';
import type { ResourceTemplateParams } from '$lib/utils/types';
Expand All @@ -8,11 +9,15 @@
let resource: Encounter = content.resource;
</script>

{#if resource.period?.start}
Effective {resource.period.start}{resource.period.end
? ` - ${resource.period.end}`
: ''}
{/if}
Effective {
resource.period?.start
? formatDate(resource.period.start)
: '??'
} - {
resource.period?.end
? formatDate(resource.period.end)
: '??'
}
<br>
{#if resource.status}
Status: {resource.status}
Expand Down
96 changes: 96 additions & 0 deletions src/lib/components/resource-templates/Goal.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<script lang="ts">
import { formatDate } from '$lib/utils/util';
import { Badge } from 'sveltestrap';
import type { Goal } from 'fhir/r4';
import type { ResourceTemplateParams } from '$lib/utils/types';
export let content: ResourceTemplateParams<Goal>;
let resource: Goal = content.resource;
// Extract start and due dates
let startDate = '??';
if (resource.startDate) {
startDate = formatDate(resource.startDate);
} else if (resource.startCodeableConcept?.text) {
startDate = resource.startCodeableConcept.text;
}
// Get first available due date or duration from targets
let dueDate = '??';
if (resource.target && resource.target.length > 0) {
const target = resource.target[0];
if (target.dueDate) {
dueDate = formatDate(target.dueDate);
} else if (target.dueDuration) {
dueDate = `in ${target.dueDuration.value} ${target.dueDuration.unit}`;
}
}
</script>

<!-- Display resource type and lifecycle status -->
<Badge color="primary">
{`${resource.resourceType} (${resource.lifecycleStatus})`}
</Badge>

<!-- Display priority if available -->
{#if resource.priority}
<Badge color="primary">
priority:
{#if resource.priority.text}
{resource.priority.text}
{:else if resource.priority.coding}
{#each resource.priority.coding as code}
{code.system} : {code.code}
{#if code.display}
({code.display})
{/if}
{/each}
{/if}
</Badge>
{/if}

<!-- Display achievementStatus if available -->
{#if resource.achievementStatus}
<Badge color="primary">
achievement:
{#if resource.achievementStatus.text}
{resource.achievementStatus.text}
{:else if resource.achievementStatus.coding}
{#each resource.achievementStatus.coding as status}
{status.system} : {status.code}
{#if status.display}
({status.display})
{/if}
{/each}
{/if}
</Badge>
{/if}

{#if resource.priority || resource.achievementStatus}
<br />
{/if}

<!-- Display description -->
{#if resource.description}
{#if resource.description.text}
<strong>{resource.description.text}</strong>
{:else if resource.description.coding}
{#each resource.description.coding as code}
{code.system} : {code.code}
{#if code.display}
<strong>({code.display})</strong>
{/if}
{/each}
{/if}
{:else}
<em>No Description Provided</em>
{/if}

<!-- Display timeline -->
<br />
{#if startDate === '??' && dueDate === '??'}
<em>No timeline available.</em>
{:else}
<strong>Timeline:</strong> {startDate} ➔ {dueDate}
{/if}
3 changes: 2 additions & 1 deletion src/lib/components/resource-templates/Immunization.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { formatDate } from '$lib/utils/util';
import { Badge } from 'sveltestrap';
import type { Immunization } from 'fhir/r4';
import type { ResourceTemplateParams } from '$lib/utils/types';
Expand All @@ -22,7 +23,7 @@
{/if}

{#if resource.occurrenceDateTime}
Date: {resource.occurrenceDateTime.split("T")[0]}
Date: {formatDate(resource.occurrenceDateTime)}
{:else if resource.occurrenceString}
Date: {resource.occurrenceString}
{/if}
23 changes: 13 additions & 10 deletions src/lib/components/resource-templates/MedicationRequest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { ResourceTemplateParams } from '$lib/utils/types';
import Dosage from '$lib/components/resource-templates/Dosage.svelte';
import MedicationTemplate from '$lib/components/resource-templates/Medication.svelte';
import { getEntry } from '$lib/utils/util';
import { getEntry, formatDate } from '$lib/utils/util';
export let content: ResourceTemplateParams<MedicationRequest>; // Define a prop to pass the data to the component
Expand Down Expand Up @@ -43,9 +43,10 @@
{/if}
{#if resource.medicationCodeableConcept.coding[0].display}
<strong>{resource.medicationCodeableConcept.coding[0].display}</strong><br />
{:else if resource.medicationCodeableConcept.text}
<strong>{resource.medicationCodeableConcept.text}</strong><br />
{/if}
{/if}
{#if resource.medicationCodeableConcept.text}
{:else if resource.medicationCodeableConcept.text}
<strong>{resource.medicationCodeableConcept.text}</strong><br />
{/if}
{/if}
Expand All @@ -60,12 +61,14 @@
{#if resource.authoredOn}
Authored: {resource.authoredOn.split('T')[0]}<br>
{/if}
{#if resource.dispenseRequest?.validityPeriod}
Valid: {resource.dispenseRequest?.validityPeriod.start}{resource.dispenseRequest
?.validityPeriod.end
? ` - ${resource.dispenseRequest?.validityPeriod.end}`
: ''}
<br />
{/if}
Valid: {resource.dispenseRequest?.validityPeriod?.start
? formatDate(resource.dispenseRequest.validityPeriod.start)
: '??'
} - {
resource.dispenseRequest?.validityPeriod?.end
? formatDate(resource.dispenseRequest.validityPeriod.end)
: '??'
}
<br />

<Dosage dosage={resource.dosageInstruction?.[0]} />
24 changes: 17 additions & 7 deletions src/lib/components/resource-templates/MedicationStatement.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { BundleEntry, Medication, MedicationStatement } from "fhir/r4";
import Dosage from '$lib/components/resource-templates/Dosage.svelte';
import MedicationTemplate from '$lib/components/resource-templates/Medication.svelte';
import { getEntry } from '$lib/utils/util';
import { getEntry, formatDate } from '$lib/utils/util';
import type { ResourceTemplateParams } from '$lib/utils/types';
export let content: ResourceTemplateParams<MedicationStatement>; // Define a prop to pass the data to the component
Expand Down Expand Up @@ -36,9 +36,13 @@
<br>
{#if resource.medicationCodeableConcept.coding[0].display}
<strong>{resource.medicationCodeableConcept.coding[0].display}</strong><br>
{:else if resource.medicationCodeableConcept.text}
<strong>{resource.medicationCodeableConcept.text}</strong><br>
{/if}
{:else if resource.medicationCodeableConcept.text}
{#if resource.status}
<br>
{/if}
{/if}
{#if resource.medicationCodeableConcept.text}
<strong>{resource.medicationCodeableConcept.text}</strong><br>
{/if}
{/if}
Expand All @@ -57,9 +61,15 @@
<Dosage dosage={resource.dosage?.[0]} />

{#if resource.effectivePeriod}
Effective: {resource.effectivePeriod.start ? resource.effectivePeriod.start : ''}{resource.effectivePeriod.end
? ` - ${resource.effectivePeriod.end}`
: ''}
Effective: {
resource.effectivePeriod.start
? formatDate(resource.effectivePeriod.start)
: '??'
} - {
resource.effectivePeriod.end
? formatDate(resource.effectivePeriod.end)
: '??'
}
{:else if resource.effectiveDateTime}
Date: {resource.effectiveDateTime.split("T")[0]}
Date: {formatDate(resource.effectiveDateTime)}
{/if}
4 changes: 2 additions & 2 deletions src/lib/components/resource-templates/Observation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Badge } from 'sveltestrap';
import type { BundleEntry, Observation } from "fhir/r4";
import type { ResourceTemplateParams } from '$lib/utils/types';
import { getEntry } from '$lib/utils/util';
import { getEntry, formatDate } from '$lib/utils/util';
export let content: ResourceTemplateParams<Observation>; // Define a prop to pass the data to the component
export let contained: Boolean = false;
Expand Down Expand Up @@ -105,5 +105,5 @@ $: {
</table>
{/if}
{#if resource.effectiveDateTime}
Date: {resource.effectiveDateTime.split("T")[0]}
Date: {formatDate(resource.effectiveDateTime)}
{/if}
17 changes: 9 additions & 8 deletions src/lib/components/resource-templates/OccupationalData.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { formatDate } from '$lib/utils/util';
import { Badge } from 'sveltestrap';
import type { Observation } from "fhir/r4";
import type { ResourceTemplateParams } from '$lib/utils/types';
Expand All @@ -16,12 +17,12 @@
<br>
{#if resource.effectivePeriod?.start}
{#if resource.effectivePeriod.end}
From {resource.effectivePeriod.start} - {resource.effectivePeriod.end}
From {formatDate(resource.effectivePeriod.start)} - {formatDate(resource.effectivePeriod.end)}
{:else}
Since {resource.effectivePeriod.start}
Since {formatDate(resource.effectivePeriod.start)}
{/if}
{:else if resource.effectiveDateTime}
Since {resource.effectiveDateTime.split("T")[0]}
Since {formatDate(resource.effectiveDateTime)}
{/if}
{:else if resource.code.coding[0].code === "87510-4"}
<strong>Retirement Date</strong>
Expand All @@ -34,21 +35,21 @@
{#if resource.valuePeriod?.start}
<br>
{#if resource.valuePeriod.end}
From {resource.valuePeriod.start} - {resource.valuePeriod.end}
From {formatDate(resource.valuePeriod.start)} - {formatDate(resource.valuePeriod.end)}
{:else}
Since {resource.valuePeriod.start}
Since {formatDate(resource.valuePeriod.start)}
{/if}
{/if}
{:else if resource.code.coding[0].code === "11341-5"}
<strong>Job History</strong>
{#if resource.effectivePeriod?.start}
{#if resource.effectivePeriod.end}
From {resource.effectivePeriod.start} - {resource.effectivePeriod.end}
From {formatDate(resource.effectivePeriod.start)} - {formatDate(resource.effectivePeriod.end)}
{:else}
Since {resource.effectivePeriod.start}
Since {formatDate(resource.effectivePeriod.start)}
{/if}
{:else if resource.effectiveDateTime}
Since {resource.effectiveDateTime.split("T")[0]}
Since {formatDate(resource.effectiveDateTime)}
{/if}
{#if resource.valueCodeableConcept}
{#if resource.valueCodeableConcept.coding}
Expand Down
Loading

0 comments on commit 601270a

Please sign in to comment.