fix return paths when validating codes

This commit is contained in:
Grahame Grieve 2023-08-16 22:38:01 +10:00
parent 3cb9c195a0
commit 57d1a973e4
2 changed files with 19 additions and 1 deletions

View File

@ -913,7 +913,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
public ValidationResult validateCode(ValidationOptions options, String system, String version, String code, String display, ValueSet vs) {
assert options != null;
Coding c = new Coding(system, version, code, display);
return validateCode(options, "code", c, vs);
ValidationResult ret = validateCode(options, "$", c, vs);
ret.trimPath("$");
return ret;
}
@Override

View File

@ -323,6 +323,22 @@ public interface IWorkerContext {
}
public void trimPath(String prefix) {
if (issues != null) {
for (OperationOutcomeIssueComponent iss : issues) {
for (int i = iss.getLocation().size() -1; i >= 0; i--) {
var s = iss.getLocation().get(i).primitiveValue();
if (prefix.equals(s)) {
iss.getLocation().remove(i);
} else if (s.startsWith(prefix+".")) {
iss.getLocation().get(i).setValueAsString(s.substring(prefix.length()+1));
}
}
}
}
}
}
public class CodingValidationRequest {