validation fixes (#397)

* Fix validation issues for StructureDefinitions

* Don't try to validate URLs outside HL7 space

* Fix document rendering

* fix failing tests
This commit is contained in:
Grahame Grieve 2020-12-05 08:13:53 +11:00 committed by GitHub
parent 7de14f172e
commit 3f9c87ab63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 5 deletions

View File

@ -62,7 +62,7 @@ public class BundleRenderer extends ResourceRenderer {
public boolean render(XhtmlNode x, ResourceWrapper b) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { public boolean render(XhtmlNode x, ResourceWrapper b) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
List<BaseWrapper> entries = b.children("entry"); List<BaseWrapper> entries = b.children("entry");
if ("document".equals(b.get("type").primitiveValue())) { if ("document".equals(b.get("type").primitiveValue())) {
if (entries.isEmpty() || (entries.get(0).has("resource") && "Composition".equals(entries.get(0).get("resource").fhirType()))) if (entries.isEmpty() || (entries.get(0).has("resource") && !"Composition".equals(entries.get(0).get("resource").fhirType())))
throw new FHIRException("Invalid document '"+b.getId()+"' - first entry is not a Composition ('"+entries.get(0).get("resource").fhirType()+"')"); throw new FHIRException("Invalid document '"+b.getId()+"' - first entry is not a Composition ('"+entries.get(0).get("resource").fhirType()+"')");
return renderDocument(x, b, entries); return renderDocument(x, b, entries);
} else if ("collection".equals(b.get("type").primitiveValue()) && allEntriesAreHistoryProvenance(entries)) { } else if ("collection".equals(b.get("type").primitiveValue()) && allEntriesAreHistoryProvenance(entries)) {

View File

@ -78,7 +78,7 @@ public class StandAloneValidatorFetcher implements IValidatorResourceFetcher {
String ver = null; String ver = null;
String base = findBaseUrl(url); String base = findBaseUrl(url);
if (base == null) { if (base == null) {
return false; return !url.startsWith("http://hl7.org/fhir") && !type.equals("canonical");
} }
if (base.equals("http://terminology.hl7.org")) { if (base.equals("http://terminology.hl7.org")) {
@ -89,7 +89,7 @@ public class StandAloneValidatorFetcher implements IValidatorResourceFetcher {
pid = pcm.findCanonicalInLocalCache(base); pid = pcm.findCanonicalInLocalCache(base);
} }
ver = url.contains("|") ? url.substring(url.indexOf("|")+1) : null; ver = url.contains("|") ? url.substring(url.indexOf("|")+1) : null;
if (pid == null) { if (pid == null && Utilities.startsWithInList(url, "http://hl7.org/fhir", "http://terminology.hl7.org")) {
return false; return false;
} }
@ -113,7 +113,66 @@ public class StandAloneValidatorFetcher implements IValidatorResourceFetcher {
// we don't bother with urls outside fhir space in the standalone validator - we assume they are valid // we don't bother with urls outside fhir space in the standalone validator - we assume they are valid
return !url.startsWith("http://hl7.org/fhir"); return !url.startsWith("http://hl7.org/fhir") && !type.equals("canonical");
}
private boolean isMappingUri(String url) {
if (mappingsUris.isEmpty()) {
JsonObject json;
try {
json = JsonTrackingParser.fetchJson("http://hl7.org/fhir/mappingspaces.json");
for (JsonObject ms : JSONUtil.objects(json, "spaces")) {
mappingsUris.add(JSONUtil.str(ms, "url"));
}
} catch (IOException e) {
// frozen R4 list
mappingsUris.add("http://hl7.org/fhir/fivews");
mappingsUris.add("http://hl7.org/fhir/workflow");
mappingsUris.add("http://hl7.org/fhir/interface");
mappingsUris.add("http://hl7.org/v2");
mappingsUris.add("http://loinc.org");
mappingsUris.add("http://snomed.org/attributebinding");
mappingsUris.add("http://snomed.info/conceptdomain");
mappingsUris.add("http://hl7.org/v3/cda");
mappingsUris.add("http://hl7.org/v3");
mappingsUris.add("http://nema.org/dicom");
mappingsUris.add("http://w3.org/vcard");
mappingsUris.add("http://ihe.net/xds");
mappingsUris.add("http://www.w3.org/ns/prov");
mappingsUris.add("http://ietf.org/rfc/2445");
mappingsUris.add("http://www.omg.org/spec/ServD/1.0/");
mappingsUris.add("http://metadata-standards.org/11179/");
mappingsUris.add("http://ihe.net/data-element-exchange");
mappingsUris.add("http://openehr.org");
mappingsUris.add("http://siframework.org/ihe-sdc-profile");
mappingsUris.add("http://siframework.org/cqf");
mappingsUris.add("http://www.cdisc.org/define-xml");
mappingsUris.add("http://www.cda-adc.ca/en/services/cdanet/");
mappingsUris.add("http://www.pharmacists.ca/");
mappingsUris.add("http://www.healthit.gov/quality-data-model");
mappingsUris.add("http://hl7.org/orim");
mappingsUris.add("http://hl7.org/fhir/w5");
mappingsUris.add("http://hl7.org/fhir/logical");
mappingsUris.add("http://hl7.org/fhir/auditevent");
mappingsUris.add("http://hl7.org/fhir/provenance");
mappingsUris.add("http://hl7.org/qidam");
mappingsUris.add("http://cap.org/ecc");
mappingsUris.add("http://fda.gov/UDI");
mappingsUris.add("http://hl7.org/fhir/object-implementation");
mappingsUris.add("http://github.com/MDMI/ReferentIndexContent");
mappingsUris.add("http://ncpdp.org/SCRIPT10_6");
mappingsUris.add("http://clinicaltrials.gov");
mappingsUris.add("http://hl7.org/fhir/rr");
mappingsUris.add("http://www.hl7.org/v3/PORX_RM020070UV");
mappingsUris.add("https://bridgmodel.nci.nih.gov");
mappingsUris.add("http://hl7.org/fhir/composition");
mappingsUris.add("http://hl7.org/fhir/documentreference");
mappingsUris.add("https://en.wikipedia.org/wiki/Identification_of_medicinal_products");
mappingsUris.add("urn:iso:std:iso:11073:10201");
mappingsUris.add("urn:iso:std:iso:11073:10207");
}
}
return mappingsUris.contains(url);
} }
private boolean isMappingUri(String url) { private boolean isMappingUri(String url) {

View File

@ -19,7 +19,7 @@
<properties> <properties>
<hapi_fhir_version>5.1.0</hapi_fhir_version> <hapi_fhir_version>5.1.0</hapi_fhir_version>
<validator_test_case_version>1.1.55</validator_test_case_version> <validator_test_case_version>1.1.56-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.6.2</junit_jupiter_version> <junit_jupiter_version>5.6.2</junit_jupiter_version>
<maven_surefire_version>3.0.0-M4</maven_surefire_version> <maven_surefire_version>3.0.0-M4</maven_surefire_version>
<jacoco_version>0.8.5</jacoco_version> <jacoco_version>0.8.5</jacoco_version>