make sure snapshots are generated when fetching types

This commit is contained in:
Grahame Grieve 2023-10-09 17:44:03 +11:00
parent f598ade02c
commit 33776523ae
2 changed files with 26 additions and 3 deletions

View File

@ -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;
}

View File

@ -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