Add logging for value set validation performance

This commit is contained in:
Grahame Grieve 2020-08-16 06:48:33 +10:00
parent cbf70365f1
commit 4e30cd7849
2 changed files with 18 additions and 7 deletions

View File

@ -3645,7 +3645,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} else if (element.getType().equals("StructureDefinition")) { } else if (element.getType().equals("StructureDefinition")) {
new StructureDefinitionValidator(context, timeTracker, fpe).validateStructureDefinition(errors, element, stack); new StructureDefinitionValidator(context, timeTracker, fpe).validateStructureDefinition(errors, element, stack);
} else if (element.getType().equals("ValueSet")) { } else if (element.getType().equals("ValueSet")) {
new ValueSetValidator(context, timeTracker).validateValueSet(errors, element, stack); new ValueSetValidator(context, timeTracker, this).validateValueSet(errors, element, stack);
} }
} }

View File

@ -21,6 +21,7 @@ import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
import org.hl7.fhir.utilities.validation.ValidationOptions; import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.hl7.fhir.validation.BaseValidator; import org.hl7.fhir.validation.BaseValidator;
import org.hl7.fhir.validation.TimeTracker; import org.hl7.fhir.validation.TimeTracker;
import org.hl7.fhir.validation.instance.InstanceValidator;
import org.hl7.fhir.validation.instance.type.ValueSetValidator.VSCodingValidationRequest; import org.hl7.fhir.validation.instance.type.ValueSetValidator.VSCodingValidationRequest;
import org.hl7.fhir.validation.instance.utils.NodeStack; import org.hl7.fhir.validation.instance.utils.NodeStack;
@ -41,10 +42,13 @@ public class ValueSetValidator extends BaseValidator {
} }
public ValueSetValidator(IWorkerContext context, TimeTracker timeTracker) { private InstanceValidator parent;
public ValueSetValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent) {
super(context); super(context);
source = Source.InstanceValidator; source = Source.InstanceValidator;
this.timeTracker = timeTracker; this.timeTracker = timeTracker;
this.parent = parent;
} }
public void validateValueSet(List<ValidationMessage> errors, Element vs, NodeStack stack) { public void validateValueSet(List<ValidationMessage> errors, Element vs, NodeStack stack) {
@ -52,28 +56,28 @@ public class ValueSetValidator extends BaseValidator {
List<Element> composes = vs.getChildrenByName("compose"); List<Element> composes = vs.getChildrenByName("compose");
int cc = 0; int cc = 0;
for (Element compose : composes) { for (Element compose : composes) {
validateValueSetCompose(errors, compose, stack.push(compose, cc, null, null)); validateValueSetCompose(errors, compose, stack.push(compose, cc, null, null), vs.getNamedChildValue("url"));
cc++; cc++;
} }
} }
} }
private void validateValueSetCompose(List<ValidationMessage> errors, Element compose, NodeStack stack) { private void validateValueSetCompose(List<ValidationMessage> errors, Element compose, NodeStack stack, String vsid) {
List<Element> includes = compose.getChildrenByName("include"); List<Element> includes = compose.getChildrenByName("include");
int ci = 0; int ci = 0;
for (Element include : includes) { for (Element include : includes) {
validateValueSetInclude(errors, include, stack.push(include, ci, null, null)); validateValueSetInclude(errors, include, stack.push(include, ci, null, null), vsid);
ci++; ci++;
} }
List<Element> excludes = compose.getChildrenByName("exclude"); List<Element> excludes = compose.getChildrenByName("exclude");
int ce = 0; int ce = 0;
for (Element exclude : excludes) { for (Element exclude : excludes) {
validateValueSetInclude(errors, exclude, stack.push(exclude, ce, null, null)); validateValueSetInclude(errors, exclude, stack.push(exclude, ce, null, null), vsid);
ce++; ce++;
} }
} }
private void validateValueSetInclude(List<ValidationMessage> errors, Element include, NodeStack stack) { private void validateValueSetInclude(List<ValidationMessage> errors, Element include, NodeStack stack, String vsid) {
String system = include.getChildValue("system"); String system = include.getChildValue("system");
String version = include.getChildValue("version"); String version = include.getChildValue("version");
List<Element> valuesets = include.getChildrenByName("valueSet"); List<Element> valuesets = include.getChildrenByName("valueSet");
@ -111,7 +115,14 @@ public class ValueSetValidator extends BaseValidator {
cc++; cc++;
} }
if (batch.size() > 0) { if (batch.size() > 0) {
long t = System.currentTimeMillis();
if (parent.isDebug()) {
System.out.println(" : Validate "+batch.size()+" codes from "+system+" for "+vsid);
}
context.validateCodeBatch(ValidationOptions.defaults(), batch, null); context.validateCodeBatch(ValidationOptions.defaults(), batch, null);
if (parent.isDebug()) {
System.out.println(" : .. "+(System.currentTimeMillis()-t)+"ms");
}
for (VSCodingValidationRequest cv : batch) { for (VSCodingValidationRequest cv : batch) {
if (version == null) { if (version == null) {
warning(errors, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE, system, cv.getCoding().getCode()); warning(errors, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE, system, cv.getCoding().getCode());