Skip to content

Commit

Permalink
Apply common elements to resource templates; include OccupationalData…
Browse files Browse the repository at this point in the history
… template option in Observation for viewer support
  • Loading branch information
daniellrgn committed Nov 7, 2024
1 parent adc15dc commit 3fd9727
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 454 deletions.
15 changes: 2 additions & 13 deletions src/lib/components/resource-templates/AllergyIntolerance.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { Badge } from 'sveltestrap';
import type { AllergyIntolerance } from 'fhir/r4';
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource: AllergyIntolerance; // Define a prop to pass the data to the component
Expand Down Expand Up @@ -31,17 +32,5 @@
{resource.type ? `${resource.type} - ` : ''}
criticality: {resource.criticality ?? 'unknown'}
</Badge>
{#if resource.code}
{#if resource.code.coding}
<Badge color="primary">{resource.code.coding[0].system} : {resource.code.coding[0].code}</Badge>
<br />
{#if resource.code.coding[0].display}
<strong>{resource.code.coding[0].display}</strong><br>
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{/if}
<CodeableConcept codeableConcept={resource.code} />
{resource.onsetDateTime ? `Since ${resource.onsetDateTime.split("T")[0]}` : ''}
32 changes: 3 additions & 29 deletions src/lib/components/resource-templates/Condition.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { Badge } from 'sveltestrap';
import type { Condition } from 'fhir/r4';
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource : Condition; // Define a prop to pass the data to the component
Expand Down Expand Up @@ -28,35 +29,8 @@
</Badge>
{/if}
<Badge color={badgeColor(resource.severity?.text ?? '')}>severity: {resource.severity?.text ?? 'unknown'}</Badge>
<br>
{#if resource.category?.[0]}
{#if resource.category[0].coding}
<Badge color="primary">{resource.category[0].coding[0].system} : {resource.category[0].coding[0].code}</Badge>
<br />
{#if resource.category[0].coding[0].display}
<strong>{resource.category[0].coding[0].display}</strong>
{:else if resource.category[0].text}
<strong>{resource.category[0].text}</strong>
{/if}
<br>
{:else if resource.category[0].text}
<strong>{resource.category[0].text}</strong>
<br>
{/if}
{/if}
{#if resource.code}
{#if resource.code.coding}
<Badge color="primary">{resource.code.coding[0].system} : {resource.code.coding[0].code}</Badge>
<br />
{#if resource.code.coding[0].display}
<strong>{resource.code.coding[0].display}</strong><br>
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{/if}
<CodeableConcept codeableConcept={resource.category?.[0]} />
<CodeableConcept codeableConcept={resource.code} />
{#if resource.bodySite}
Site: {resource.bodySite}<br>
{/if}
Expand Down
36 changes: 13 additions & 23 deletions src/lib/components/resource-templates/DiagnosticReport.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
<script lang="ts">
import { Badge } from 'sveltestrap';
import type { DiagnosticReport } from 'fhir/r4';
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource: DiagnosticReport; // Define a prop to pass the data to the component
</script>

{#if resource.code}
{#if resource.code.coding}
<Badge color="primary">{resource.code.coding[0].system} : {resource.code.coding[0].code}</Badge>
<br />
{#if resource.code.coding[0].display}
<strong>{resource.code.coding[0].display}</strong><br>
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{/if}
<CodeableConcept codeableConcept={resource.code} />
{#if resource.effectivePeriod?.start}
Effective {resource.effectivePeriod.start}{resource.effectivePeriod.end
? ` - ${resource.effectivePeriod.end}`
Expand All @@ -27,16 +15,18 @@
{/if}
<br>
{#if resource.result}
<div class="ips-section-table">
<table class="table table-bordered table-sm">
<thead>
<thead>
<tr><th colspan="5">Result(s)</th></tr>
</thead>
{#each resource.result as result}
{#if result.display}
<tr>
<td>{result.display}</td>
</tr>
{/if}
{/each}
</thead>
{#each resource.result as result}
{#if result.display}
<tr>
<td>{result.display}</td>
</tr>
{/if}
{/each}
</table>
</div>
{/if}
16 changes: 2 additions & 14 deletions src/lib/components/resource-templates/Encounter.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script lang="ts">
import { Badge } from 'sveltestrap';
import type { Encounter } from 'fhir/r4';
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource: Encounter; // Define a prop to pass the data to the component
</script>

<CodeableConcept codeableConcept={resource.reasonCode?.[0]} />
{#if resource.period?.start}
Effective {resource.period.start}{resource.period.end
? ` - ${resource.period.end}`
Expand All @@ -14,16 +15,3 @@ Effective {resource.period.start}{resource.period.end
{#if resource.status}
Status: {resource.status}
{/if}
{#if resource.reasonCode}
{#if resource.reasonCode[0].coding}
<Badge color="primary">{resource.reasonCode[0].coding[0].system} : {resource.reasonCode[0].coding[0].code}</Badge>
<br />
{#if resource.reasonCode[0].coding[0].display}
<strong>{resource.reasonCode[0].coding[0].display}: </strong>
{:else if resource.reasonCode[0].text}
<strong>{resource.reasonCode[0].text}: </strong>
{/if}
{:else if resource.reasonCode[0].text}
<strong>{resource.reasonCode[0].text}: </strong>
{/if}
{/if}
16 changes: 2 additions & 14 deletions src/lib/components/resource-templates/Immunization.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
<script lang="ts">
import { Badge } from 'sveltestrap';
import type { Immunization } from 'fhir/r4';
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource: Immunization; // Define a prop to pass the data to the component
</script>
{#if resource.vaccineCode}
{#if resource.vaccineCode.coding}
<Badge color="primary">{resource.vaccineCode.coding[0].system} : {resource.vaccineCode.coding[0].code}</Badge>
<br />
{#if resource.vaccineCode.coding[0].display}
<strong>{resource.vaccineCode.coding[0].display}</strong><br>
{:else if resource.vaccineCode.text}
<strong>{resource.vaccineCode.text}</strong><br>
{/if}
{:else if resource.vaccineCode.text}
<strong>{resource.vaccineCode.text}</strong><br>
{/if}
{/if}
<CodeableConcept codeableConcept={resource.vaccineCode} />

{#if resource.occurrenceDateTime}
Date: {resource.occurrenceDateTime.split("T")[0]}
Expand Down
39 changes: 4 additions & 35 deletions src/lib/components/resource-templates/Location.svelte
Original file line number Diff line number Diff line change
@@ -1,44 +1,13 @@
<script lang="ts">
import type { Location } from "fhir/r4";
import Address from "./Address.svelte";
import ContactPoint from "./ContactPoint.svelte";
export let resource: Location; // Define a prop to pass the data to the component
</script>

<strong>{resource.name ?? ""}</strong>
<br />
{#if resource.telecom}
<table class="table table-bordered table-sm">
<thead>
<tr><th colspan="3">Contact Information</th></tr>
</thead>
<tr>
{#each resource.telecom as telecom}
<td>{telecom.system ?? ""}</td>
<td>{telecom.use ?? ""}</td>
<td>{telecom.value ?? ""}</td>
{/each}
</tr>
</table>
{/if}
{#if resource.address}
{#if resource.address.line}
{#if resource.address.line.length > 0}
{#each resource.address.line as line}
{#if line !== ""}
{line}<br />
{/if}
{/each}
{:else}
{resource.address.line}
{/if}
{/if}
{resource.address.city ?? ""
}{resource.address.state
? `, ${resource.address.state}`
: ''
}{resource.address.country
? `, ${resource.address.country}`
: ''}
{resource.address.postalCode ?? ""}
{/if}
<ContactPoint contactPoint={resource.telecom} />
<Address address={resource.address} />

60 changes: 25 additions & 35 deletions src/lib/components/resource-templates/Medication.svelte
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
<script lang="ts">
import { Badge} from 'sveltestrap';
import type { Medication } from "fhir/r4";
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource: Medication; // Define a prop to pass the data to the component
</script>

{#if resource.code}
{#if resource.code.coding}
<Badge color="primary">{resource.code.coding[0].system} : {resource.code.coding[0].code}</Badge>
<br />
{#if resource.code.coding[0].display}
<strong>{resource.code.coding[0].display}</strong><br>
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{:else if resource.code.text}
<strong>{resource.code.text}</strong><br>
{/if}
{/if}
<CodeableConcept codeableConcept={resource.code} />
{#if resource.ingredient}
<table class="table table-bordered table-sm">
<thead>
<tr><th colspan="5">Composition</th></tr>
<tr>
<th scope="col">Ingredient</th>
<th scope="col">Strength Numerator Qty</th>
<th scope="col">Unit</th>
<th scope="col">Strength Denominator Qty</th>
<th scope="col">Strength Denominator Unit</th>
</tr>
</thead>
{#each resource.ingredient as ingredient}
<tr>
<td>{ingredient.itemCodeableConcept?.coding?.[0].display}</td>
<td>{ingredient.strength?.numerator?.value}</td>
<td>{ingredient.strength?.numerator?.unit}</td>
<td>{ingredient.strength?.denominator?.value}</td>
<td>{ingredient.strength?.denominator?.unit}</td>
</tr>
{/each}
</table>
<div class="ips-section-table">
<table class="table table-bordered table-sm">
<thead>
<tr><th colspan="5">Composition</th></tr>
<tr>
<th scope="col">Ingredient</th>
<th scope="col">Strength Numerator Qty</th>
<th scope="col">Unit</th>
<th scope="col">Strength Denominator Qty</th>
<th scope="col">Strength Denominator Unit</th>
</tr>
</thead>
{#each resource.ingredient as ingredient}
<tr>
<td>{ingredient.itemCodeableConcept?.coding?.[0].display}</td>
<td>{ingredient.strength?.numerator?.value}</td>
<td>{ingredient.strength?.numerator?.unit}</td>
<td>{ingredient.strength?.denominator?.value}</td>
<td>{ingredient.strength?.denominator?.unit}</td>
</tr>
{/each}
</table>
</div>
{/if}
20 changes: 3 additions & 17 deletions src/lib/components/resource-templates/MedicationRequest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,14 @@
import { Badge } from 'sveltestrap';
import type { MedicationRequest } from "fhir/r4";
import Dosage from '$lib/components/resource-templates/Dosage.svelte';
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource: MedicationRequest; // Define a prop to pass the data to the component
</script>

<Badge color="secondary">{resource.intent ? resource.intent : ''}</Badge>
<Badge color={resource.status === "stopped" ? "secondary" : "primary"}>{resource.status ? `${resource.status}` : ''}</Badge>
<br>
{#if resource.medicationCodeableConcept}
{#if resource.medicationCodeableConcept.coding}
{#if resource.medicationCodeableConcept.coding[0].system && resource.medicationCodeableConcept.coding[0].code}
<Badge color="primary">{resource.medicationCodeableConcept.coding[0].system} : {resource.medicationCodeableConcept.coding[0].code}</Badge>
<br>
{/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}
{:else if resource.medicationCodeableConcept.text}
<strong>{resource.medicationCodeableConcept.text}</strong><br>
{/if}
{/if}
<Badge color="secondary">{resource.intent ? resource.intent : ''}</Badge>
<CodeableConcept codeableConcept={resource.medicationCodeableConcept} />
{#if resource.dispenseRequest?.validityPeriod}
Valid from {resource.dispenseRequest?.validityPeriod.start}{resource.dispenseRequest?.validityPeriod.end
? ` - ${resource.dispenseRequest?.validityPeriod.end}`
Expand Down
33 changes: 5 additions & 28 deletions src/lib/components/resource-templates/MedicationStatement.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,17 @@
import { Badge } from 'sveltestrap';
import type { MedicationStatement } from "fhir/r4";
import Dosage from '$lib/components/resource-templates/Dosage.svelte';
import CodeableConcept from '$lib/components/resource-templates/CodeableConcept.svelte';
export let resource: MedicationStatement; // Define a prop to pass the data to the component
</script>
{#if resource.status}
<Badge color={resource.status === "unknown" ? "secondary" : "primary"}>{resource.status}</Badge>
<br>
{/if}

{#if resource.medicationCodeableConcept}
{#if resource.medicationCodeableConcept.coding}
<Badge color="primary">{resource.medicationCodeableConcept.coding[0].system} : {resource.medicationCodeableConcept?.coding[0].code}</Badge>
<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}
<strong>{resource.medicationCodeableConcept.text}</strong><br>
{/if}
{#if resource.medicationCodeableConcept.coding}
<Badge color="primary">{resource.medicationCodeableConcept.coding[0].system} : {resource.medicationCodeableConcept?.coding[0].code}</Badge>
<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}
<strong>{resource.medicationCodeableConcept.text}</strong><br>
{/if}
{/if}
<Badge color={resource.status === "stopped" ? "secondary" : "primary"}>{resource.status ? `${resource.status}` : ''}</Badge>

<CodeableConcept codeableConcept={resource.medicationCodeableConcept} />

{#if resource.medicationReference?.display}
<br>
<strong>{resource.medicationReference?.display}</strong>
<br>
{/if}
Expand Down
Loading

0 comments on commit 3fd9727

Please sign in to comment.