Fix bug checking of mixing snomed display types

This commit is contained in:
Grahame Grieve 2023-09-21 12:42:18 +10:00
parent 66b69deb37
commit 9ef82e7e23
1 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package org.hl7.fhir.validation.codesystem;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.r5.context.IWorkerContext;
@ -13,7 +14,9 @@ import org.hl7.fhir.validation.instance.utils.NodeStack;
public class SnomedCTChecker extends CodeSystemChecker {
private boolean noTag = false;
private List<String> noTags = new ArrayList<>();
private boolean hasTag = false;
private List<String> tags = new ArrayList<>();
public SnomedCTChecker(IWorkerContext context, XVerExtensionManager xverManager, boolean debug, List<ValidationMessage> errors) {
super(context, xverManager, debug, errors);
@ -22,16 +25,24 @@ public class SnomedCTChecker extends CodeSystemChecker {
public void checkConcept(String code, String display) {
super.checkConcept(code, display);
if (!Utilities.noString(display)) {
boolean tagged = display.endsWith(")") && display.indexOf("(") > display.length() - 20;
int s = display.lastIndexOf("(");
int e = display.lastIndexOf(")");
boolean tagged = e == display.length() - 1 && s > -1 && s > display.length() - 20;
if (tagged) {
hasTag = true;
if (tags.size() < 5) {
tags.add(display);
}
} else {
noTag = true;
if (noTags.size() < 5) {
noTags.add(display);
}
}
}
}
public void finish(Element inc, NodeStack stack) {
super.finish(inc, stack);
hint(errors, "2023-07-21", IssueType.BUSINESSRULE, inc.line(), inc.col(), stack.getLiteralPath(), !(noTag && hasTag), I18nConstants.VALUESET_CONCEPT_DISPLAY_SCT_TAG_MIXED);
hint(errors, "2023-07-21", IssueType.BUSINESSRULE, inc.line(), inc.col(), stack.getLiteralPath(), !(noTag && hasTag), I18nConstants.VALUESET_CONCEPT_DISPLAY_SCT_TAG_MIXED, tags.toString(), noTags.toString());
}
}