diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java index b7a3932ca..d3386f7ee 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java @@ -185,6 +185,7 @@ import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.CodeSystemNavigator; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument; +import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; @@ -1126,6 +1127,7 @@ public class NarrativeGenerator implements INarrativeGenerator { private boolean noSlowLookup; private List codeSystemPropList = new ArrayList<>(); private ProfileUtilities profileUtilities; + private XVerExtensionManager xverManager; public NarrativeGenerator(String prefix, String basePath, IWorkerContext context) { super(); @@ -1396,6 +1398,16 @@ public class NarrativeGenerator implements INarrativeGenerator { Extension ex = (Extension) v.getBase(); String url = ex.getUrl(); StructureDefinition ed = context.fetchResource(StructureDefinition.class, url); + if (ed == null) { + if (xverManager == null) { + xverManager = new XVerExtensionManager(context); + } + if (xverManager.matchingUrl(url) && xverManager.status(url) == XVerExtensionStatus.Valid) { + ed = xverManager.makeDefinition(url); + context.generateSnapshot(ed); + context.cacheResource(ed); + } + } if (p.getName().equals("modifierExtension") && ed == null) throw new DefinitionException("Unknown modifier extension "+url); PropertyWrapper pe = map.get(p.getName()+"["+url+"]"); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XVerExtensionManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java similarity index 97% rename from org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XVerExtensionManager.java rename to org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java index ef658c4de..f7f04adf5 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/XVerExtensionManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.validation; +package org.hl7.fhir.r5.utils; import java.io.IOException; import java.util.Date; @@ -7,6 +7,7 @@ import java.util.Map; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.model.Constants; import org.hl7.fhir.r5.model.ElementDefinition; import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent; import org.hl7.fhir.r5.model.Enumerations.FHIRVersion; @@ -38,6 +39,9 @@ public class XVerExtensionManager { public XVerExtensionStatus status(String url) throws FHIRException { String v = url.substring(20, 23); + if ("5.0".equals(v)) { + v = Constants.VERSION_MM; + } String e = url.substring(54); if (!lists.containsKey(v)) { if (context.getBinaries().containsKey("xver-paths-"+v+".json")) { @@ -68,6 +72,9 @@ public class XVerExtensionManager { public StructureDefinition makeDefinition(String url) { String verSource = url.substring(20, 23); + if ("5.0".equals(verSource)) { + verSource = Constants.VERSION_MM; + } String verTarget = VersionUtilities.getMajMin(context.getVersion()); String e = url.substring(54); JsonObject root = lists.get(verSource); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index 9f18f133b..ed8f93a6a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -341,7 +341,7 @@ public class ValidationEngine implements IValidatorResourceFetcher { context = SimpleWorkerContext.fromDefinitions(source, loaderForVersion(), new PackageVersion(src)); context.setAllowLoadingDuplicates(true); // because of Forge context.setExpansionProfile(makeExpProfile()); - NpmPackage npm = pcm.loadPackage("hl7.fhir.xver-extensions", "0.0.2"); + NpmPackage npm = pcm.loadPackage("hl7.fhir.xver-extensions", "0.0.3"); context.loadFromPackage(npm, null); grabNatives(source, "http://hl7.org/fhir"); } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index e6de73840..e0cffc8c5 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -134,13 +134,13 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.IResourceValidator; import org.hl7.fhir.r5.utils.NarrativeGenerator; import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.r5.utils.XVerExtensionManager; import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.validation.BaseValidator; import org.hl7.fhir.validation.TimeTracker; import org.hl7.fhir.validation.instance.EnableWhenEvaluator.QStack; import org.hl7.fhir.validation.instance.type.MeasureValidator; import org.hl7.fhir.validation.instance.type.QuestionnaireValidator; -import org.hl7.fhir.validation.XVerExtensionManager; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities.DecimalStatus;