handle naming system URLs when resolving URLs

This commit is contained in:
Grahame Grieve 2021-10-21 07:02:48 +11:00
parent b60afcb608
commit e62f3a3c6c
3 changed files with 28 additions and 4 deletions

View File

@ -1722,6 +1722,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
transforms.listAllM(result);
plans.listAllM(result);
questionnaires.listAllM(result);
systems.listAllM(result);
return result;
}
}

View File

@ -28,6 +28,8 @@ import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType;
import org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent;
import org.hl7.fhir.r5.renderers.RendererFactory;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
@ -760,6 +762,13 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
if (Utilities.existsInList(url, "http://loinc.org", "http://unitsofmeasure.org", "http://snomed.info/sct")) {
return true;
}
for (CanonicalResource cr : context.allConformanceResources()) {
if (cr instanceof NamingSystem) {
if (hasURL((NamingSystem) cr, url)) {
return true;
}
}
}
if (url.contains("example.org") || url.contains("acme.com")) {
return false; // todo... how to access settings from here?
}
@ -773,6 +782,15 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
return false;
}
private boolean hasURL(NamingSystem ns, String url) {
for (NamingSystemUniqueIdComponent uid : ns.getUniqueId()) {
if (uid.getType() == NamingSystemIdentifierType.URI && uid.hasValue() && uid.getValue().equals(url)) {
return true;
}
}
return false;
}
@Override
public CanonicalResource fetchCanonicalResource(IResourceValidator validator, String url) throws URISyntaxException {
Resource res = context.fetchResource(Resource.class, url);

View File

@ -8,6 +8,7 @@ import org.hl7.fhir.r5.formats.IParser;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.renderers.spreadsheets.CodeSystemSpreadsheetGenerator;
import org.hl7.fhir.r5.renderers.spreadsheets.ConceptMapSpreadsheetGenerator;
@ -315,15 +316,19 @@ public class ValidationService {
if (issue.hasExpression()) {
int line = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_LINE, -1);
int col = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_COL, -1);
loc = issue.getExpression().get(0).asStringValue() + (line >= 0 && col >= 0 ? " (line " + Integer.toString(line) + ", col" + Integer.toString(col) + ")" : "");
loc = " @ "+issue.getExpression().get(0).asStringValue() + (line >= 0 && col >= 0 ? " (line " + Integer.toString(line) + ", col" + Integer.toString(col) + ")" : "");
} else if (issue.hasLocation()) {
loc = issue.getLocation().get(0).asStringValue();
loc = " @ "+issue.getLocation().get(0).asStringValue();
} else {
int line = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_LINE, -1);
int col = ToolingExtensions.readIntegerExtension(issue, ToolingExtensions.EXT_ISSUE_COL, -1);
loc = (line >= 0 && col >= 0 ? "line " + Integer.toString(line) + ", col" + Integer.toString(col) : "??");
if (issue.getSeverity() == IssueSeverity.INFORMATION && (line == -1 || col == -1)) {
loc = "";
} else {
loc = " @ "+(line >= 0 && col >= 0 ? "line " + Integer.toString(line) + ", col" + Integer.toString(col) : "??");
}
return " " + issue.getSeverity().getDisplay() + " @ " + loc + " : " + issue.getDetails().getText();
}
return " " + issue.getSeverity().getDisplay() + loc + ": " + issue.getDetails().getText();
}
public String determineVersion(CliContext cliContext) throws Exception {