more fixing for language handling issues
This commit is contained in:
parent
81d26c5160
commit
02bd1d8ce7
|
@ -534,8 +534,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
|
|
||||||
private void setTerminologyOptions(ValidationOptions options, Parameters pIn) {
|
private void setTerminologyOptions(ValidationOptions options, Parameters pIn) {
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
if (options.hasLanguages()) {
|
for (String s : options.getLanguages()) {
|
||||||
pIn.addParameter("displayLanguage", options.getLanguages().get(0));
|
pIn.addParameter("displayLanguage", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1007,8 +1007,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTerminologyOptions(ValidationOptions options, Parameters pIn) {
|
private void setTerminologyOptions(ValidationOptions options, Parameters pIn) {
|
||||||
if (options.hasLanguages()) {
|
for (String s : options.getLanguages()) {
|
||||||
pIn.addParameter("displayLanguage", options.getLanguages().get(0));
|
pIn.addParameter("displayLanguage", s);
|
||||||
}
|
}
|
||||||
if (options.getValueSetMode() != ValueSetMode.ALL_CHECKS) {
|
if (options.getValueSetMode() != ValueSetMode.ALL_CHECKS) {
|
||||||
pIn.addParameter("valueSetMode", options.getValueSetMode().toString());
|
pIn.addParameter("valueSetMode", options.getValueSetMode().toString());
|
||||||
|
|
|
@ -1084,8 +1084,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
} catch (VSCheckerException e) {
|
} catch (VSCheckerException e) {
|
||||||
localError = e.getMessage();
|
localError = e.getMessage();
|
||||||
issues.addAll(e.getIssues());
|
if (e.getIssues() != null) {
|
||||||
|
issues.addAll(e.getIssues());
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
localError = e.getMessage();
|
localError = e.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -858,6 +858,7 @@ public class I18nConstants {
|
||||||
public static final String UNKNOWN_CODESYSTEM = "UNKNOWN_CODESYSTEM";
|
public static final String UNKNOWN_CODESYSTEM = "UNKNOWN_CODESYSTEM";
|
||||||
public static final String UNKNOWN_CODESYSTEM_VERSION = "UNKNOWN_CODESYSTEM_VERSION";
|
public static final String UNKNOWN_CODESYSTEM_VERSION = "UNKNOWN_CODESYSTEM_VERSION";
|
||||||
public static final String VALUESET_TOO_COSTLY = "VALUESET_TOO_COSTLY";
|
public static final String VALUESET_TOO_COSTLY = "VALUESET_TOO_COSTLY";
|
||||||
|
public static final String NO_VALID_DISPLAY_FOUND = "NO_VALID_DISPLAY_FOUND";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package org.hl7.fhir.utilities.validation;
|
package org.hl7.fhir.utilities.validation;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class ValidationOptions {
|
public class ValidationOptions {
|
||||||
public enum ValueSetMode {
|
public enum ValueSetMode {
|
||||||
ALL_CHECKS, CHECK_MEMERSHIP_ONLY, NO_MEMBERSHIP_CHECK
|
ALL_CHECKS, CHECK_MEMERSHIP_ONLY, NO_MEMBERSHIP_CHECK
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> languages = new ArrayList<>();
|
private Set<String> languages = new HashSet<>();
|
||||||
private boolean useServer = true;
|
private boolean useServer = true;
|
||||||
private boolean useClient = true;
|
private boolean useClient = true;
|
||||||
private boolean guessSystem = false;
|
private boolean guessSystem = false;
|
||||||
|
@ -36,7 +39,7 @@ public class ValidationOptions {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> getLanguages() {
|
public Set<String> getLanguages() {
|
||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +124,9 @@ public class ValidationOptions {
|
||||||
|
|
||||||
|
|
||||||
public ValidationOptions withLanguage(String language) {
|
public ValidationOptions withLanguage(String language) {
|
||||||
|
if (language == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
ValidationOptions n = this.copy();
|
ValidationOptions n = this.copy();
|
||||||
n.languages.add(language);
|
n.languages.add(language);
|
||||||
return n;
|
return n;
|
||||||
|
@ -249,6 +255,14 @@ public class ValidationOptions {
|
||||||
"\"guessSystem\":\""+Boolean.toString(guessSystem)+"\", \"valueSetMode\":\""+valueSetMode.toString()+"\", \"versionFlexible\":\""+Boolean.toString(versionFlexible)+"\"";
|
"\"guessSystem\":\""+Boolean.toString(guessSystem)+"\", \"valueSetMode\":\""+valueSetMode.toString()+"\", \"versionFlexible\":\""+Boolean.toString(versionFlexible)+"\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String langSummary() {
|
||||||
|
if (languages.size() == 0) {
|
||||||
|
return "--";
|
||||||
|
} else {
|
||||||
|
return String.join("|", Utilities.sorted(languages));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -462,8 +462,8 @@ Version_mismatch_The_context_has_version__loaded_and_the_new_content_being_loade
|
||||||
Error_reading__from_package__ = Error reading {0} from package {1}#{2}: {3}
|
Error_reading__from_package__ = Error reading {0} from package {1}#{2}: {3}
|
||||||
Error_parsing_ = Error parsing {0}:{1}
|
Error_parsing_ = Error parsing {0}:{1}
|
||||||
Unable_to_connect_to_terminology_server_Use_parameter_tx_na_tun_run_without_using_terminology_services_to_validate_LOINC_SNOMED_ICDX_etc_Error__ = Unable to connect to terminology server. Use parameter ''-tx n/a'' to run without using terminology services to validate LOINC, SNOMED, ICD-X etc. Error = {0}
|
Unable_to_connect_to_terminology_server_Use_parameter_tx_na_tun_run_without_using_terminology_services_to_validate_LOINC_SNOMED_ICDX_etc_Error__ = Unable to connect to terminology server. Use parameter ''-tx n/a'' to run without using terminology services to validate LOINC, SNOMED, ICD-X etc. Error = {0}
|
||||||
Display_Name_for__should_be_one_of__instead_of_one = Wrong Display Name ''{4}'' for {1}#{2} - should be ''{3}'',
|
Display_Name_for__should_be_one_of__instead_of_one = Wrong Display Name ''{4}'' for {1}#{2} - should be ''{3}'' (for the language(s) ''{5}'')
|
||||||
Display_Name_for__should_be_one_of__instead_of_other = Wrong Display Name ''{4}'' for {1}#{2} - should be one of {0} choices: ''{3}''
|
Display_Name_for__should_be_one_of__instead_of_other = Wrong Display Name ''{4}'' for {1}#{2} - should be one of {0} choices: ''{3}'' for the language(s) ''{5}''
|
||||||
Unknown_Code__in_ = Unknown Code ''{0}'' in the system ''{1}''
|
Unknown_Code__in_ = Unknown Code ''{0}'' in the system ''{1}''
|
||||||
UNKNOWN_CODE__IN_FRAGMENT = Unknown Code ''{0}'' in the system ''{1}'' - note that the code system is labeled as a fragment, so the code may be valid in some other fragment
|
UNKNOWN_CODE__IN_FRAGMENT = Unknown Code ''{0}'' in the system ''{1}'' - note that the code system is labeled as a fragment, so the code may be valid in some other fragment
|
||||||
Code_found_in_expansion_however_ = Code found in expansion, however: {0}
|
Code_found_in_expansion_however_ = Code found in expansion, however: {0}
|
||||||
|
@ -910,5 +910,8 @@ UNKNOWN_CODESYSTEM = The CodeSystem {0} is unknown
|
||||||
UNKNOWN_CODESYSTEM_VERSION = The CodeSystem {0} version {1} is unknown. ValidVersions: {2}
|
UNKNOWN_CODESYSTEM_VERSION = The CodeSystem {0} version {1} is unknown. ValidVersions: {2}
|
||||||
UNABLE_TO_INFER_CODESYSTEM = The System URI could not be determined for the code {0} in the ValueSet {1}
|
UNABLE_TO_INFER_CODESYSTEM = The System URI could not be determined for the code {0} in the ValueSet {1}
|
||||||
VALUESET_TOO_COSTLY = The value set {0} has too many codes to display ({1})
|
VALUESET_TOO_COSTLY = The value set {0} has too many codes to display ({1})
|
||||||
|
NO_VALID_DISPLAY_FOUND_one = No valid Display Names found for {1}#{2} in the language {3}
|
||||||
|
NO_VALID_DISPLAY_FOUND_other = No valid Display Names found for {1}#{2} in the languages {3}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6386,7 +6386,14 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
|
|
||||||
// no delay on this one?
|
// no delay on this one?
|
||||||
public ValidationResult checkCodeOnServer(NodeStack stack, String code, String system, String version, String display, boolean checkDisplay) {
|
public ValidationResult checkCodeOnServer(NodeStack stack, String code, String system, String version, String display, boolean checkDisplay) {
|
||||||
return context.validateCode(baseOptions.withLanguage(stack.getWorkingLang()), system, version, code, checkDisplay ? display : null);
|
String lang = stack.getWorkingLang();
|
||||||
|
if (lang == null) {
|
||||||
|
lang = validationLanguage;
|
||||||
|
}
|
||||||
|
if (lang == null) {
|
||||||
|
lang = "en"; // ubiquitious default languauge
|
||||||
|
}
|
||||||
|
return context.validateCode(baseOptions.withLanguage(lang), system, version, code, checkDisplay ? display : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValidationResult checkCodeOnServer(NodeStack stack, ValueSet valueset, Coding c, boolean checkMembership) {
|
public ValidationResult checkCodeOnServer(NodeStack stack, ValueSet valueset, Coding c, boolean checkMembership) {
|
||||||
|
|
|
@ -159,16 +159,22 @@ public class ValueSetValidator extends BaseValidator {
|
||||||
if (parent.isDebug()) {
|
if (parent.isDebug()) {
|
||||||
System.out.println(" : Validate "+batch.size()+" codes from "+system+" for "+vsid);
|
System.out.println(" : Validate "+batch.size()+" codes from "+system+" for "+vsid);
|
||||||
}
|
}
|
||||||
context.validateCodeBatch(ValidationOptions.defaults(), batch, null);
|
try {
|
||||||
if (parent.isDebug()) {
|
context.validateCodeBatch(ValidationOptions.defaults(), batch, null);
|
||||||
System.out.println(" : .. "+(System.currentTimeMillis()-t)+"ms");
|
if (parent.isDebug()) {
|
||||||
}
|
System.out.println(" : .. "+(System.currentTimeMillis()-t)+"ms");
|
||||||
for (VSCodingValidationRequest cv : batch) {
|
|
||||||
if (version == null) {
|
|
||||||
ok = warningOrHint(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), !retired, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE, system, cv.getCoding().getCode()) && ok;
|
|
||||||
} else {
|
|
||||||
ok = warningOrHint(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), !retired, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER, system, version, cv.getCoding().getCode()) && ok;
|
|
||||||
}
|
}
|
||||||
|
for (VSCodingValidationRequest cv : batch) {
|
||||||
|
if (version == null) {
|
||||||
|
ok = warningOrHint(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), !retired, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE, system, cv.getCoding().getCode()) && ok;
|
||||||
|
} else {
|
||||||
|
ok = warningOrHint(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), !retired, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER, system, version, cv.getCoding().getCode()) && ok;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
ok = false;
|
||||||
|
VSCodingValidationRequest cv = batch.get(0);
|
||||||
|
rule(errors, NO_RULE_DATE, IssueType.EXCEPTION, cv.getStack().getLiteralPath(), false, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +221,9 @@ public class ValueSetValidator extends BaseValidator {
|
||||||
} else {
|
} else {
|
||||||
boolean ok = vv.isOk();
|
boolean ok = vv.isOk();
|
||||||
warning(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, stack.getLiteralPath(), ok, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER, system, version, code);
|
warning(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, stack.getLiteralPath(), ok, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER, system, version, code);
|
||||||
|
if (vv.getMessage() != null) {
|
||||||
|
hint(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, stack.getLiteralPath(), false, vv.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue