Merge pull request #735 from hapifhir/gg-202202-last-windows-commit

Gg 202202 last windows commit
This commit is contained in:
Grahame Grieve 2022-02-10 12:18:35 +11:00 committed by GitHub
commit 9f2d9f9dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 8 deletions

View File

@ -995,7 +995,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())
@ -1004,12 +1003,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

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