Skip to content

Commit

Permalink
🐛 fix: Retrieve the profile definitions only if they have the 'snapsh…
Browse files Browse the repository at this point in the history
…ot' field because toFHIR can only process profile definitions through their snapshot definitions.
  • Loading branch information
sinaci committed Aug 17, 2022
1 parent 0ec1a1e commit 973f0bf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/store/fhirStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ const fhirStore = {
.then(res => {
const bundle = res.data as fhir.Bundle
if (bundle.total > 0) {
profileList.push(...(bundle.entry?.map(e => {
profileList.push(...(bundle.entry?.flatMap(e => {
const structure = e.resource as fhir.StructureDefinition
return {id: structure.id, title: structure.title, url: structure.url} as fhir.StructureDefinition
if (structure.snapshot) // Add this profile to the list only if it has the snapshot field.
return {id: structure.id, title: structure.title, url: structure.url} as fhir.StructureDefinition
else return []
}) || []))

Promise.all(profileList.map(profile => {
Expand All @@ -107,9 +109,11 @@ const fhirStore = {
.then(res => {
const bundle = res.data as fhir.Bundle
if (bundle.total > 0) {
subProfiles.push(...(bundle.entry?.map(e => {
subProfiles.push(...(bundle.entry?.flatMap(e => {
const structure = e.resource as fhir.StructureDefinition
return {id: structure.id, title: structure.title, url: structure.url} as fhir.StructureDefinition
if (structure.snapshot) // Add this profile to the list only if it has the snapshot field.
return {id: structure.id, title: structure.title, url: structure.url} as fhir.StructureDefinition
else return []
}) || []))
}
resolveSubProfile(true)
Expand Down

0 comments on commit 973f0bf

Please sign in to comment.