Merge pull request #1157 from hapifhir/gg-202303-qa-sm-validation-5
Gg 202303 qa sm validation 5
This commit is contained in:
commit
6870c7a32c
|
@ -1,7 +1,8 @@
|
|||
## Validator Changes
|
||||
|
||||
* no changes
|
||||
* Fix up issues validating whitespace
|
||||
* Multiple fixes to StructureMap and ConceptMap validation
|
||||
|
||||
## Other code changes
|
||||
|
||||
* no changes
|
||||
* rename ig-r4.json to ig-r4.jsonx in IGs
|
||||
|
|
|
@ -170,6 +170,9 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
|
|||
if (ed.hasBinding()) {
|
||||
ed.getBinding().setValueSet(patchUrl(ed.getBinding().getValueSet(), "ValueSet"));
|
||||
}
|
||||
if (ed.hasContentReference()) {
|
||||
ed.setContentReference(patchUrl(ed.getContentReference(), "StructureDefinition"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -273,6 +273,7 @@ public class FmlParser extends ParserBase {
|
|||
lexer.token("<");
|
||||
if (lexer.hasToken("types")) {
|
||||
group.makeElement("typeMode").markLocation(lexer.getCurrentLocation()).setValue(StructureMapGroupTypeMode.TYPES.toCode());
|
||||
lexer.token("types");
|
||||
} else {
|
||||
group.makeElement("typeMode").markLocation(lexer.getCurrentLocation()).setValue(StructureMapGroupTypeMode.TYPEANDTYPES.toCode());
|
||||
lexer.token("type");
|
||||
|
|
|
@ -1912,6 +1912,16 @@ public class Utilities {
|
|||
'\u2028', '\u2029', '\u202F', '\u205F', '\u3000');
|
||||
}
|
||||
|
||||
public static boolean stringsEqual(String s1, String s2) {
|
||||
if (s1 == null && s2 == null) {
|
||||
return true;
|
||||
} else if (s1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
return s1.equals(s2);
|
||||
}
|
||||
}
|
||||
|
||||
//public static boolean !isWhitespace(String s) {
|
||||
//boolean ok = true;
|
||||
//for (int i = 0; i < s.length(); i++)
|
||||
|
|
|
@ -832,6 +832,7 @@ public class I18nConstants {
|
|||
public static final String SM_TARGET_TRANSLATE_BINDING_VS_TARGET = "SM_TARGET_TRANSLATE_BINDING_VS_TARGET";
|
||||
public static final String SM_TARGET_TRANSLATE_BINDING_VSE_TARGET = "SM_TARGET_TRANSLATE_BINDING_VSE_TARGET";
|
||||
public static final String SM_TARGET_TRANSLATE_BINDING_TARGET_WRONG = "SM_TARGET_TRANSLATE_BINDING_TARGET_WRONG";
|
||||
public static final String SM_DEPENDENT_PARAM_TYPE_MISMATCH_DUPLICATE = "SM_DEPENDENT_PARAM_TYPE_MISMATCH_DUPLICATE";
|
||||
public static final String CONCEPTMAP_GROUP_SOURCE_MISSING = "CONCEPTMAP_GROUP_SOURCE_MISSING";
|
||||
public static final String CONCEPTMAP_GROUP_SOURCE_UNKNOWN = "CONCEPTMAP_GROUP_SOURCE_UNKNOWN";
|
||||
public static final String CONCEPTMAP_GROUP_TARGET_MISSING = "CONCEPTMAP_GROUP_TARGET_MISSING";
|
||||
|
|
|
@ -865,7 +865,7 @@ SM_IMPORT_NOT_FOUND = No maps were found to match {0} - validation may be wrong
|
|||
SM_TARGET_TYPE_MULTIPLE_POSSIBLE = Multiple types are possible here ({0}) so further type checking is not possible
|
||||
SM_DEPENDENT_PARAM_MODE_MISMATCH = The parameter {0} refers to the variable {1} but it''s mode is {2} which is not the same as the mode required for the group {3}
|
||||
SM_DEPENDENT_PARAM_TYPE_MISMATCH = The parameter {0} refers to the variable {1} but it''s type is {2} which is not compatible with the type required for the group {3}
|
||||
SM_ORPHAN_GROUP = This group is not called from within this mapping script, and does not have types on it's inputs, so type verification is not possible
|
||||
SM_ORPHAN_GROUP = The group {0} is not called from within this mapping script, and does not have types on it's inputs, so type verification is not possible
|
||||
SM_SOURCE_TYPE_NOT_FOUND = No source type was found, so the default group for this implied dependent rule could not be determined
|
||||
SM_TARGET_TYPE_NOT_FOUND = No target type was found, so the default group for this implied dependent rule could not be determined
|
||||
SM_MATCHING_RULEGROUP_NOT_FOUND = Unable to find a default rule for the type pair source={0} and target={1}
|
||||
|
@ -895,5 +895,5 @@ CONCEPTMAP_GROUP_TARGET_PROPERTY_TYPE_MISMATCH = The type of this property shoul
|
|||
CONCEPTMAP_GROUP_TARGET_PROPERTY_TYPE_NO_SYSTEM = Since no system has been provided, a plain code cannot be used
|
||||
CONCEPTMAP_GROUP_TARGET_PROPERTY_CODE_INVALID = The code {0} is invalid in the system {1}
|
||||
CONCEPTMAP_GROUP_TARGET_PROPERTY_TYPE_UNKNOWN_SYSTEM = The system {0} is unknown, so code values can''t be checked
|
||||
|
||||
SM_DEPENDENT_PARAM_TYPE_MISMATCH_DUPLICATE = The group {0} has already been used with different parameters, so the type checking may be incorrect (other = [{1}]; this = [{2}])
|
||||
|
|
@ -176,6 +176,22 @@ public class StructureMapValidator extends BaseValidator {
|
|||
return null;
|
||||
}
|
||||
|
||||
public String summary() {
|
||||
return mode+" "+getWorkingType()+" "+name;
|
||||
}
|
||||
|
||||
public boolean matches(VariableDefn other) {
|
||||
if (!(name.equals(other.name) && mode.equals(other.mode))) {
|
||||
return false;
|
||||
}
|
||||
if (sd == null && other.sd == null) {
|
||||
return true;
|
||||
} else if (sd == null || other.sd == null) {
|
||||
return false;
|
||||
}
|
||||
return sd.getUrl().equals(other.sd.getUrl()) && ed.getPath().equals(other.ed.getPath()) && Utilities.stringsEqual(type, other.type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class VariableSet {
|
||||
|
@ -234,6 +250,26 @@ public class StructureMapValidator extends BaseValidator {
|
|||
vn.name = pname;
|
||||
list.add(vn);
|
||||
}
|
||||
|
||||
public String summary() {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
for (VariableDefn v : list) {
|
||||
b.append(v.summary());
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public boolean matches(VariableSet other) {
|
||||
if (list.size() != other.list.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (!list.get(i).matches(other.list.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static final boolean SOURCE = true;
|
||||
|
@ -285,7 +321,7 @@ public class StructureMapValidator extends BaseValidator {
|
|||
cc = 0;
|
||||
for (Element group : groups) {
|
||||
if (!group.hasUserData("structuremap.validated")) {
|
||||
hint(errors, "2023-03-01", IssueType.INFORMATIONAL, group.line(), group.col(), stack.getLiteralPath(), ok, I18nConstants.SM_ORPHAN_GROUP);
|
||||
hint(errors, "2023-03-01", IssueType.INFORMATIONAL, group.line(), group.col(), stack.push(group, cc, null, null).getLiteralPath(), ok, I18nConstants.SM_ORPHAN_GROUP, group.getName());
|
||||
ok = validateGroup(errors, src, group, stack.push(group, cc, null, null)) && ok;
|
||||
}
|
||||
cc++;
|
||||
|
@ -485,7 +521,7 @@ public class StructureMapValidator extends BaseValidator {
|
|||
cc++;
|
||||
}
|
||||
|
||||
// process the targets
|
||||
// process the nested rules
|
||||
List<Element> rules = rule.getChildrenByName("rule");
|
||||
cc = 0;
|
||||
for (Element child : rules) {
|
||||
|
@ -901,7 +937,23 @@ public class StructureMapValidator extends BaseValidator {
|
|||
} else {
|
||||
for (ElementDefinition t : children) {
|
||||
if (t.getNameBase().equals(element)) {
|
||||
result.add(new ElementDefinitionSource(sd, t));
|
||||
if (t.hasContentReference()) {
|
||||
String url = t.getContentReference().substring(0, t.getContentReference().indexOf("#"));
|
||||
String path = t.getContentReference().substring(t.getContentReference().indexOf("#")+1);
|
||||
StructureDefinition sdt = "".equals(url) || url.equals(sd.getUrl()) ? sd : context.fetchResource(StructureDefinition.class, url);
|
||||
if (sdt == null) {
|
||||
throw new Error("Unable to resolve "+url);
|
||||
} else {
|
||||
ElementDefinition t2 = sdt.getSnapshot().getElementByPath(path);
|
||||
if (t2 == null) {
|
||||
throw new Error("Unable to resolve "+path+" in "+url);
|
||||
} else {
|
||||
result.add(new ElementDefinitionSource(sdt, t2));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.add(new ElementDefinitionSource(sd, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -987,7 +1039,8 @@ public class StructureMapValidator extends BaseValidator {
|
|||
if (ok && grp.hasUserData("element.source")) {
|
||||
Element g = (Element) grp.getUserData("element.source");
|
||||
if (g.hasUserData("structuremap.parameters")) {
|
||||
throw new Error("bang! - this situation is not handled");
|
||||
VariableSet pvars = (VariableSet) g.getUserData("structuremap.parameters");
|
||||
rule(errors, "2023-03-01", IssueType.INVALID, dependent.line(), dependent.col(), stack.getLiteralPath(), pvars.matches(lvars), I18nConstants.SM_DEPENDENT_PARAM_TYPE_MISMATCH_DUPLICATE, grp.getName(), pvars.summary(), lvars.summary());
|
||||
} else {
|
||||
g.setUserData("structuremap.parameters", lvars);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue