Add support for R5 version extensions and using cross version extensions when generating narrative

This commit is contained in:
Grahame Grieve 2020-04-12 22:04:57 +10:00
parent 4bd0d60e5c
commit 979bad6af1
4 changed files with 22 additions and 3 deletions

View File

@ -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<String> 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+"]");

View File

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

View File

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

View File

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