This commit is contained in:
Grahame Grieve 2022-02-12 08:37:02 +11:00
commit a570ef08a6
13 changed files with 59 additions and 36 deletions

View File

@ -52,11 +52,6 @@
</dependency>
<!-- HTTP Client -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>

View File

@ -104,13 +104,6 @@
<optional>true</optional>
</dependency>
<!-- HTTP Client -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<optional>true</optional>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>

View File

@ -58,11 +58,6 @@
</dependency>
<!-- HTTP Client -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>

View File

@ -997,7 +997,6 @@ public class Utilities {
return s.substring(0, 1).toLowerCase() + s.substring(1);
}
public static int charCount(String s, char c) {
int res = 0;
for (char ch : s.toCharArray())
@ -1006,12 +1005,10 @@ public class Utilities {
return res;
}
public static boolean isOid(String cc) {
return cc.matches(OID_REGEX) && cc.lastIndexOf('.') >= 5;
return cc.matches(OID_REGEX);
}
public static boolean equals(String one, String two) {
if (one == null && two == null)
return true;

View File

@ -231,6 +231,9 @@ public class VersionUtilities {
return false;
}
String[] p = version.split("\\.");
if (p[2].contains("-")) {
p[2] = p[2].substring(0, p[2].indexOf("-"));
}
return Utilities.isInteger(p[0]) && Utilities.isInteger(p[1]) && Utilities.isInteger(p[2]);
}

View File

@ -199,7 +199,7 @@ Type_Specific_Checks_DT_Integer_LT0 = value is less than permitted minimum value
Type_Specific_Checks_DT_Integer_LT1 = value is less than permitted minimum value of 1
Type_Specific_Checks_DT_Integer_Valid = The value ''{0}'' is not a valid integer
Type_Specific_Checks_DT_OID_Start = OIDs must start with urn:oid:
Type_Specific_Checks_DT_OID_Valid = OIDs must be valid
Type_Specific_Checks_DT_OID_Valid = OIDs must be valid ({0})
Type_Specific_Checks_DT_Primitive_Length = value is longer than permitted maximum length of {0}
Type_Specific_Checks_DT_Primitive_NotEmpty = @value cannot be empty
Type_Specific_Checks_DT_Primitive_Regex = Element value ''{0}'' does not meet regex ''{1}''
@ -643,7 +643,7 @@ SD_ED_SHOULD_BIND_WITH_VS = The element {0} has a type that should have a bindin
SD_ED_BIND_UNKNOWN_VS = The valueSet reference {1} on element {0} could not be resolved
SD_ED_BIND_NOT_VS = The valueSet reference {1} on element {0} points to something that is not a value set ({2})
SD_ED_BIND_NO_BINDABLE = The element {0} has a binding, but no bindable types are present {1}
SD_ED_BIND_MULTIPLE_TYPES = The element {0} has a binding, and has multiple types ({1}). The binding will apply to all the types
SD_ED_BIND_MULTIPLE_TYPES = The element {0} has a binding, and has multiple types subject to bindings ({1}). The binding will apply to all the types
DISCRIMINATOR_BAD_PATH = Error processing path expression for discriminator: {0} (src = ''{1}'')
SLICING_CANNOT_BE_EVALUATED = Slicing cannot be evaluated: {0}
TYPE_SPECIFIC_CHECKS_DT_CANONICAL_RESOLVE = Canonical URL ''{0}'' does not resolve

View File

@ -6,6 +6,13 @@ import static org.junit.jupiter.api.Assertions.*;
public class VersionUtilitiesTest {
@Test
public void isValidSemVer() {
assertTrue(VersionUtilities.isSemVer("0.1.1"));
assertTrue(VersionUtilities.isSemVer("0.1.1-ballot1"));
assertFalse(VersionUtilities.isSemVer("0.1.a"));
}
@Test
public void isThisOrLater_Simple() {
assertTrue(VersionUtilities.isThisOrLater("0.1", "0.2"));

View File

@ -76,7 +76,7 @@
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludes>**/module-info.class</excludes>
<excludes>**/module-info.class,META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA</excludes>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
@ -121,7 +121,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<version>1.6.0</version>
<executions>
<execution>
<id>default-cli</id>
@ -134,7 +134,7 @@
<workingDirectory>/tmp</workingDirectory>
<arguments>
<argument>-jar</argument>
<argument>${basedir}/target/org.hl7.fhir.validation.cli-${project.version}.jar</argument>
<argument>${project.basedir}/target/org.hl7.fhir.validation.cli-${project.version}.jar</argument>
</arguments>
</configuration>
</execution>

View File

@ -217,7 +217,12 @@
<version>${junit_jupiter_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>
<!-- End to end -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
@ -245,11 +250,6 @@
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes combine.children="override">
<exclude>org/hl7/fhir/validation/cli/services/ValidationServiceTest.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>

View File

@ -2109,7 +2109,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.isValidUUID(url.substring(9)), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_UUID_VALID);
}
if (url != null && url.startsWith("urn:oid:")) {
rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.isOid(url.substring(8)), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_OID_VALID);
String cc = url.substring(8);
// OIDs shorter than 5 chars are almost never valid for namespaces, except for the special OID 1.3.88
rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.isOid(cc) && (cc.lastIndexOf('.') >= 5 || "1.3.88".equals(cc)), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_OID_VALID, cc);
}
if (isCanonicalURLElement(e)) {

View File

@ -211,7 +211,10 @@ public class StructureDefinitionValidator extends BaseValidator {
private void validateBinding(List<ValidationMessage> errors, Element binding, NodeStack stack, Set<String> typeCodes, boolean snapshot, String path) {
rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), !snapshot || bindableType(typeCodes) != null, I18nConstants.SD_ED_BIND_NO_BINDABLE, path, typeCodes.toString());
hint(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), typeCodes.size() <= 1, I18nConstants.SD_ED_BIND_MULTIPLE_TYPES, path, typeCodes.toString());
if (!snapshot) {
Set<String> bindables = getListofBindableTypes(typeCodes);
hint(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), bindables.size() <= 1, I18nConstants.SD_ED_BIND_MULTIPLE_TYPES, path, typeCodes.toString());
}
if (binding.hasChild("valueSet")) {
Element valueSet = binding.getNamedChild("valueSet");
@ -230,6 +233,16 @@ public class StructureDefinitionValidator extends BaseValidator {
}
}
private Set<String> getListofBindableTypes(Set<String> types) {
Set<String> res = new HashSet<>();
for (String s : types) {
if (Utilities.existsInList(s, "code", "string", "url", "uri", "Coding", "CodeableConcept", "Quantity", "CodeableReference")) {
res.add(s);
}
}
return res;
}
private boolean serverSupportsValueSet(String ref) {
ValidationResult vr = context.validateCode(new ValidationOptions().checkValueSetOnly().setVsAsUrl().noClient(), new Coding("http://loinc.org", "5792-7", null), new ValueSet().setUrl(ref));
return vr.getErrorClass() == null;

View File

@ -0,0 +1,11 @@
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://medcomfhir.dk/fhir/core/1.0/CodeSystem/medcom-messaging-activityCodes",
"code" : "new-message"
}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"true"}####
v: {
"severity" : "error",
"error" : "The code system 'http://medcomfhir.dk/fhir/core/1.0/CodeSystem/medcom-messaging-activityCodes' is not known (encountered paired with code = 'new-message'); The code provided (http://medcomfhir.dk/fhir/core/1.0/CodeSystem/medcom-messaging-activityCodes#new-message) is not valid in the value set 'All codes known to the system' (from http://tx.fhir.org/r4)",
"class" : "CODESYSTEM_UNSUPPORTED"
}
-------------------------------------------------------------------------------------

11
pom.xml
View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>5.1.0</version>
<version>5.4.0</version>
</parent>
<!--
@ -18,7 +18,7 @@
<packaging>pom</packaging>
<properties>
<hapi_fhir_version>5.1.0</hapi_fhir_version>
<hapi_fhir_version>5.4.0</hapi_fhir_version>
<validator_test_case_version>1.1.88</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
@ -27,6 +27,7 @@
<jacoco_version>0.8.7</jacoco_version>
<info_cqframework_version>1.5.1</info_cqframework_version>
<lombok_version>1.18.22</lombok_version>
<byte_buddy_version>1.10.21</byte_buddy_version>
</properties>
<name>HL7 Core Artifacts</name>
@ -139,6 +140,12 @@
<version>${junit_jupiter_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${byte_buddy_version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>