Skip to content

Commit

Permalink
Template updates (#62)
Browse files Browse the repository at this point in the history
* Show both medication text and code display fields

* Add device templates
  • Loading branch information
daniellrgn authored Jan 22, 2025
1 parent 0eaa826 commit f75df42
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/lib/components/app/ResourceSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import AdvanceDirective from '$lib/components/resource-templates/AdvanceDirective.svelte';
import AllergyIntolerance from '$lib/components/resource-templates/AllergyIntolerance.svelte';
import Condition from '$lib/components/resource-templates/Condition.svelte';
import Device from '$lib/components/resource-templates/Device.svelte';
import DeviceUseStatement from '../resource-templates/DeviceUseStatement.svelte';
import DiagnosticReport from '$lib/components/resource-templates/DiagnosticReport.svelte';
import Encounter from '$lib/components/resource-templates/Encounter.svelte';
import Immunization from '$lib/components/resource-templates/Immunization.svelte';
Expand All @@ -49,6 +51,8 @@
"AllergyIntolerance": AllergyIntolerance,
"Condition": Condition,
"Consent": AdvanceDirective,
"Device" : Device,
"DeviceUseStatement": DeviceUseStatement,
"DiagnosticReport": DiagnosticReport,
"DocumentReference": AdvanceDirective,
"Encounter": Encounter,
Expand Down
38 changes: 38 additions & 0 deletions src/lib/components/resource-templates/Device.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script lang="ts">
import { Badge} from 'sveltestrap';
import type { Device } from "fhir/r4";
import type { ResourceTemplateParams } from '$lib/utils/types';
export let content: ResourceTemplateParams<Device>; // Define a prop to pass the data to the component
let resource: Device = content.resource;
let codingMap = new Map();
</script>

{#if resource.type}
{#if resource.type.coding}
<Badge color="primary">{resource.type.coding[0].system} : {resource.type.coding[0].code}</Badge>
<br />
{/if}
{/if}
{#if resource.type?.text}
{(codingMap.set(resource.type.text, 1) && undefined) ?? ""}
<strong>{resource.type.text}</strong><br>
{/if}
{#if resource.type?.coding}
{#each resource.type.coding as coding, index}
{#if !resource.type?.text && index == 0}
<strong>
{#if coding.display && !codingMap.get(coding.display)}
{(codingMap.set(coding.display, 1) && undefined) ?? ""}
{coding.display}<br>
{/if}
</strong>
{:else}
{#if coding.display && !codingMap.get(coding.display)}
{(codingMap.set(coding.display, 1) && undefined) ?? ""}
{coding.display}<br>
{/if}
{/if}
{/each}
{/if}
39 changes: 39 additions & 0 deletions src/lib/components/resource-templates/DeviceUseStatement.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts">
import { Badge } from 'sveltestrap';
import type { BundleEntry, Device, DeviceUseStatement } from 'fhir/r4';
import type { ResourceTemplateParams } from '$lib/utils/types';
import DeviceTemplate from '$lib/components/resource-templates/Device.svelte';
import { getEntry } from '$lib/utils/util';
export let content: ResourceTemplateParams<DeviceUseStatement>; // Define a prop to pass the data to the component
let resource: DeviceUseStatement = content.resource;
let device: Device | undefined;
$: {
if (resource) {
if (resource.device) {
if (resource.contained?.[0]?.resourceType === 'Device') {
// If the device is contained in the resource
device = resource.contained[0];
} else if (resource.device?.reference) {
// If the device is referenced
device = getEntry(content.entries as BundleEntry[], resource.device.reference) as Device;
}
}
}
}
</script>

<Badge color={resource.status === 'stopped' ? 'secondary' : 'primary'}
>{resource.status ? `${resource.status}` : ''}</Badge
>
<br />

{#if device}
<DeviceTemplate content={{ resource: device, entries: content.entries }} />
{:else if resource.device?.display}
<strong>{resource.device?.display}</strong>
<br>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
{/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}
{/if}
{#if resource.medicationCodeableConcept.text}
<strong>{resource.medicationCodeableConcept.text}</strong><br />
{/if}
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@
<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 Down
8 changes: 7 additions & 1 deletion src/lib/components/viewer/IPSContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import AllergyIntolerance from '$lib/components/resource-templates/AllergyIntolerance.svelte';
import Condition from '$lib/components/resource-templates/Condition.svelte';
import Consent from '$lib/components/resource-templates/Consent.svelte';
import Device from '$lib/components/resource-templates/Device.svelte';
import DeviceUseStatement from '$lib/components/resource-templates/DeviceUseStatement.svelte';
import DiagnosticReport from '$lib/components/resource-templates/DiagnosticReport.svelte';
import Encounter from '$lib/components/resource-templates/Encounter.svelte';
import Immunization from '$lib/components/resource-templates/Immunization.svelte';
Expand All @@ -39,11 +41,14 @@
import Practitioner from '$lib/components/resource-templates/Practitioner.svelte';
import Procedure from '$lib/components/resource-templates/Procedure.svelte';
import OccupationalData from '$lib/components/resource-templates/OccupationalData.svelte';
import QuestionnaireResponse from '$lib/components/resource-templates/QuestionnaireResponse.svelte';
const components: Record<string, any> = {
"AllergyIntolerance": AllergyIntolerance,
"Condition": Condition,
"Consent": Consent,
"Device" : Device,
"DeviceUseStatement": DeviceUseStatement,
"DiagnosticReport": DiagnosticReport,
"DocumentReference": AdvanceDirective,
"Encounter": Encounter,
Expand All @@ -58,7 +63,8 @@
"Practitioner": Practitioner,
"Procedure": Procedure,
"Occupational Data": OccupationalData,
"Advance Directives": AdvanceDirective
"Advance Directives": AdvanceDirective,
"QuestionnaireResponse": QuestionnaireResponse
};
interface IpsContent {
Expand Down

0 comments on commit f75df42

Please sign in to comment.