diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/StructureDefinitionHacker.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/StructureDefinitionHacker.java index 69e231200..8e4c92e26 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/StructureDefinitionHacker.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/StructureDefinitionHacker.java @@ -8,7 +8,7 @@ import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.utilities.VersionUtilities; /** - * This doesn't do anythign at this time + * This works around known issues in struture definitions * * @author graha * @@ -48,7 +48,7 @@ public class StructureDefinitionHacker { ed.setComment("e.g. The patient is a pregnant, has congestive heart failure, has an Adenocarcinoma, and is allergic to penicillin."); } } - } + } return sd; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index dd2ec8995..49a2e9f26 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -2472,7 +2472,30 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte return res; } } - return typeManager.fetchTypeDefinition(typeName); + StructureDefinition p = typeManager.fetchTypeDefinition(typeName); + if (p != null && !p.isGeneratedSnapshot()) { + if (p.isGeneratingSnapshot()) { + throw new FHIRException("Attempt to fetch the profile "+p.getVersionedUrl()+" while generating the snapshot for it"); + } + try { + if (logger.isDebugLogging()) { + System.out.println("Generating snapshot for "+p.getVersionedUrl()); + } + p.setGeneratingSnapshot(true); + try { + new ContextUtilities(this).generateSnapshot(p); + } finally { + p.setGeneratingSnapshot(false); + } + } catch (Exception e) { + // not sure what to do in this case? + System.out.println("Unable to generate snapshot @4 for "+p.getVersionedUrl()+": "+e.getMessage()); + if (logger.isDebugLogging()) { + e.printStackTrace(); + } + } + } + return p; } @Override