Improve message for when elements are out of order

This commit is contained in:
Grahame Grieve 2024-09-03 21:26:17 +08:00
parent 88075e6ac9
commit 00f4f0998f
1 changed files with 6 additions and 1 deletions

View File

@ -3463,6 +3463,11 @@ public class ProfileUtilities {
public void sortDifferential(StructureDefinition base, StructureDefinition diff, String name, List<String> errors, boolean errorIfChanges) throws FHIRException { public void sortDifferential(StructureDefinition base, StructureDefinition diff, String name, List<String> errors, boolean errorIfChanges) throws FHIRException {
int index = 0;
for (ElementDefinition ed : diff.getDifferential().getElement()) {
ed.setUserData("ed.index", Integer.toString(index));
index++;
}
List<ElementDefinition> original = new ArrayList<>(); List<ElementDefinition> original = new ArrayList<>();
original.addAll(diff.getDifferential().getElement()); original.addAll(diff.getDifferential().getElement());
final List<ElementDefinition> diffList = diff.getDifferential().getElement(); final List<ElementDefinition> diffList = diff.getDifferential().getElement();
@ -3520,7 +3525,7 @@ public class ProfileUtilities {
ElementDefinition e = diffList.get(i); ElementDefinition e = diffList.get(i);
ElementDefinition n = newDiff.get(i); ElementDefinition n = newDiff.get(i);
if (!n.getPath().equals(e.getPath())) { if (!n.getPath().equals(e.getPath())) {
errors.add("The element "+e.getPath()+" is out of order (and maybe others after it)"); errors.add("The element "+(e.hasId() ? e.getId() : e.getPath())+" @diff["+e.getUserString("ed.index")+"] is out of order (and maybe others after it)");
return; return;
} }
} }