diff --git a/modules/frontend/package-lock.json b/modules/frontend/package-lock.json index bb9d286ff..42b5fccbb 100644 --- a/modules/frontend/package-lock.json +++ b/modules/frontend/package-lock.json @@ -19,7 +19,7 @@ "@sveltejs/vite-plugin-svelte": "7.3.0", "@tailwindcss/vite": "4.3.3", "@types/dom-view-transitions": "1.0.6", - "@types/fhir": "0.0.41", + "@types/fhir": "0.0.44", "@types/humanize-duration": "3.27.4", "@types/node": "24.13.3", "change-case": "5.4.4", @@ -1586,9 +1586,9 @@ "license": "MIT" }, "node_modules/@types/fhir": { - "version": "0.0.41", - "resolved": "https://registry.npmjs.org/@types/fhir/-/fhir-0.0.41.tgz", - "integrity": "sha512-MAQAFufNZBZ6V0F94Nhknmmh/E3iMXFK4n/L8RkSNjKtOJnvaAJERivNOj35VVx9VCQBJbE0BHSzikfBahoRhA==", + "version": "0.0.44", + "resolved": "https://registry.npmjs.org/@types/fhir/-/fhir-0.0.44.tgz", + "integrity": "sha512-RhqRUNcUFeQSbEK9cOEYQ98sfsUFFRCUKbgozHvryiUfEAPiXuhgk2wqYV3MoD1T1qHp0gztrHDywU68bN7KYQ==", "dev": true, "license": "MIT" }, diff --git a/modules/frontend/package.json b/modules/frontend/package.json index d6940286b..eeab5cecd 100644 --- a/modules/frontend/package.json +++ b/modules/frontend/package.json @@ -21,7 +21,7 @@ "@sveltejs/vite-plugin-svelte": "7.3.0", "@tailwindcss/vite": "4.3.3", "@types/dom-view-transitions": "1.0.6", - "@types/fhir": "0.0.41", + "@types/fhir": "0.0.44", "@types/humanize-duration": "3.27.4", "@types/node": "24.13.3", "change-case": "5.4.4", diff --git a/modules/frontend/src/lib/resource/resource-card.test.ts b/modules/frontend/src/lib/resource/resource-card.test.ts index c8a2f94e3..0c09a3328 100644 --- a/modules/frontend/src/lib/resource/resource-card.test.ts +++ b/modules/frontend/src/lib/resource/resource-card.test.ts @@ -1,4 +1,4 @@ -import type { Bundle, ElementDefinition, StructureDefinition } from 'fhir/r4'; +import type { Bundle, ElementDefinition, Patient, StructureDefinition } from 'fhir/r4'; import { describe, expect, it } from 'vitest'; import { calcPropertiesDeep, type FhirObject, getTypeElements } from './resource-card.js'; import { readFileSync } from 'fs'; @@ -214,6 +214,10 @@ describe('calcPropertiesDeep test', () => { }); }); it('contained resource', () => { + const containedPatient: Patient = { + resourceType: 'Patient', + gender: 'female' + }; expect( calcPropertiesDeep( readStructureDefinition, @@ -221,12 +225,7 @@ describe('calcPropertiesDeep test', () => { structureDefinitionPatient, { resourceType: 'Patient', - contained: [ - { - resourceType: 'Patient', - gender: 'female' - } - ] + contained: [containedPatient] } ) ).toStrictEqual({ diff --git a/modules/frontend/src/lib/resource/resource-card.ts b/modules/frontend/src/lib/resource/resource-card.ts index e5f176197..58a161875 100644 --- a/modules/frontend/src/lib/resource/resource-card.ts +++ b/modules/frontend/src/lib/resource/resource-card.ts @@ -28,11 +28,11 @@ export function isPrimitive(type: Type) { return type.code[0].toLowerCase() == type.code[0]; } -export interface FhirObjectBundle extends Bundle { +export interface FhirObjectBundle extends Bundle { fhirObjectEntry?: FhirObjectBundleEntry[]; } -export interface FhirObjectBundleEntry extends BundleEntry { +export interface FhirObjectBundleEntry extends BundleEntry { fhirObject?: FhirObject; } @@ -82,13 +82,13 @@ export interface FhirPrimitive extends FhirType { export async function transformBundle( fetch: typeof window.fetch, - bundle: Bundle + bundle: Bundle ): Promise { return bundle.entry !== undefined ? { ...bundle, fhirObjectEntry: await Promise.all( - bundle.entry.map(async (e: BundleEntry) => + bundle.entry.map(async (e: BundleEntry) => e.resource !== undefined ? { ...e, fhirObject: await fhirObject(e.resource, fetch) } : e ) )