commit
991978c784
|
@ -9,9 +9,9 @@ package org.hl7.fhir.dstu2.utils;
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -60,20 +60,21 @@ import org.hl7.fhir.dstu2.terminologies.ValueSetExpansionCache;
|
|||
import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nBase;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
||||
public abstract class BaseWorkerContext implements IWorkerContext {
|
||||
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext {
|
||||
|
||||
// all maps are to the full URI
|
||||
protected Map<String, ValueSet> codeSystems = new HashMap<String, ValueSet>();
|
||||
protected Map<String, ValueSet> valueSets = new HashMap<String, ValueSet>();
|
||||
protected Map<String, ConceptMap> maps = new HashMap<String, ConceptMap>();
|
||||
|
||||
|
||||
protected ValueSetExpanderFactory expansionCache = new ValueSetExpansionCache(this);
|
||||
protected boolean cacheValidation; // if true, do an expansion and cache the expansion
|
||||
private Set<String> failed = new HashSet<String>(); // value sets for which we don't try to do expansion, since the first attempt to get a comprehensive expansion was not successful
|
||||
protected Map<String, Map<String, ValidationResult>> validationCache = new HashMap<String, Map<String,ValidationResult>>();
|
||||
|
||||
|
||||
// private ValueSetExpansionCache expansionCache; //
|
||||
|
||||
protected FHIRToolingClient txServer;
|
||||
|
@ -83,7 +84,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
@Override
|
||||
public ValueSet fetchCodeSystem(String system) {
|
||||
return codeSystems.get(system);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSystem(String system) {
|
||||
|
@ -108,7 +109,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
params.put("_incomplete", "true");
|
||||
params.put("profile", "http://www.healthintersections.com.au/fhir/expansion/no-details");
|
||||
ValueSet result = txServer.expandValueset(vs, null, params);
|
||||
return new ValueSetExpansionOutcome(result);
|
||||
return new ValueSetExpansionOutcome(result);
|
||||
} catch (Exception e) {
|
||||
return new ValueSetExpansionOutcome("Error expanding ValueSet \""+vs.getUrl()+": "+e.getMessage());
|
||||
}
|
||||
|
@ -134,7 +135,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
failed.add(vs.getUrl());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
ValidationResult res = validateCode(coding, vse.getValueset());
|
||||
cache.put(cacheId, res);
|
||||
return res;
|
||||
|
@ -159,7 +160,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
}
|
||||
if (cache.containsKey(cacheId))
|
||||
return cache.get(cacheId);
|
||||
|
||||
|
||||
if (validationCache.containsKey(vs.getUrl()) && validationCache.get(vs.getUrl()).containsKey(cacheId))
|
||||
return validationCache.get(vs.getUrl()).get(cacheId);
|
||||
if (!tryCache)
|
||||
|
@ -181,16 +182,16 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
private String cacheId(Coding coding) {
|
||||
return "|"+coding.getSystem()+"|"+coding.getVersion()+"|"+coding.getCode()+"|"+coding.getDisplay();
|
||||
}
|
||||
|
||||
|
||||
private String cacheId(CodeableConcept cc) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (Coding c : cc.getCoding()) {
|
||||
b.append("#");
|
||||
b.append(cacheId(c));
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
|
||||
private ValidationResult verifyCodeExternal(ValueSet vs, Coding coding, boolean tryCache) {
|
||||
ValidationResult res = handleByCache(vs, coding, tryCache);
|
||||
if (res != null)
|
||||
|
@ -203,7 +204,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
cache.put(cacheId(coding), res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private ValidationResult verifyCodeExternal(ValueSet vs, CodeableConcept cc, boolean tryCache) {
|
||||
ValidationResult res = handleByCache(vs, cc, tryCache);
|
||||
if (res != null)
|
||||
|
@ -238,7 +239,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return new ValidationResult(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc) {
|
||||
ValueSet vs = new ValueSet();
|
||||
|
@ -251,22 +252,22 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
@Override
|
||||
public ValidationResult validateCode(String system, String code, String display) {
|
||||
try {
|
||||
if (codeSystems.containsKey(system))
|
||||
if (codeSystems.containsKey(system))
|
||||
return verifyCodeInternal(codeSystems.get(system), system, code, display);
|
||||
else
|
||||
else
|
||||
return verifyCodeExternal(null, new Coding().setSystem(system).setCode(code).setDisplay(display), true);
|
||||
} catch (Exception e) {
|
||||
return new ValidationResult(IssueSeverity.FATAL, "Error validating code \""+code+"\" in system \""+system+"\": "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ValidationResult validateCode(Coding code, ValueSet vs) {
|
||||
try {
|
||||
if (codeSystems.containsKey(code.getSystem()) || vs.hasExpansion())
|
||||
if (codeSystems.containsKey(code.getSystem()) || vs.hasExpansion())
|
||||
return verifyCodeInternal(codeSystems.get(code.getSystem()), code.getSystem(), code.getCode(), code.getDisplay());
|
||||
else
|
||||
else
|
||||
return verifyCodeExternal(vs, code, true);
|
||||
} catch (Exception e) {
|
||||
return new ValidationResult(IssueSeverity.FATAL, "Error validating code \""+code+"\" in system \""+code.getSystem()+"\": "+e.getMessage());
|
||||
|
@ -276,9 +277,9 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
@Override
|
||||
public ValidationResult validateCode(CodeableConcept code, ValueSet vs) {
|
||||
try {
|
||||
if (vs.hasCodeSystem() || vs.hasExpansion())
|
||||
if (vs.hasCodeSystem() || vs.hasExpansion())
|
||||
return verifyCodeInternal(vs, code);
|
||||
else
|
||||
else
|
||||
return verifyCodeExternal(vs, code, true);
|
||||
} catch (Exception e) {
|
||||
return new ValidationResult(IssueSeverity.FATAL, "Error validating code \""+code.toString()+"\": "+e.getMessage());
|
||||
|
@ -291,9 +292,9 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
try {
|
||||
if (system == null && vs.hasCodeSystem())
|
||||
return verifyCodeInternal(vs, vs.getCodeSystem().getSystem(), code, display);
|
||||
else if (codeSystems.containsKey(system) || vs.hasExpansion())
|
||||
else if (codeSystems.containsKey(system) || vs.hasExpansion())
|
||||
return verifyCodeInternal(vs, system, code, display);
|
||||
else
|
||||
else
|
||||
return verifyCodeExternal(vs, new Coding().setSystem(system).setCode(code).setDisplay(display), true);
|
||||
} catch (Exception e) {
|
||||
return new ValidationResult(IssueSeverity.FATAL, "Error validating code \""+code+"\" in system \""+system+"\": "+e.getMessage());
|
||||
|
@ -315,7 +316,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
public List<ConceptMap> findMapsForSource(String url) {
|
||||
List<ConceptMap> res = new ArrayList<ConceptMap>();
|
||||
for (ConceptMap map : maps.values())
|
||||
if (((Reference) map.getSource()).getReference().equals(url))
|
||||
if (((Reference) map.getSource()).getReference().equals(url))
|
||||
res.add(map);
|
||||
return res;
|
||||
}
|
||||
|
@ -335,11 +336,11 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
private ValidationResult verifyCodeInternal(ValueSet vs, String system, String code, String display) throws FileNotFoundException, ETooCostly, IOException {
|
||||
if (vs.hasExpansion())
|
||||
return verifyCodeInExpansion(vs, system, code, display);
|
||||
else if (vs.hasCodeSystem() && !vs.hasCompose())
|
||||
else if (vs.hasCodeSystem() && !vs.hasCompose())
|
||||
return verifyCodeInCodeSystem(vs, system, code, display);
|
||||
else {
|
||||
ValueSetExpansionOutcome vse = expansionCache.getExpander().expand(vs);
|
||||
if (vse.getValueset() != null)
|
||||
if (vse.getValueset() != null)
|
||||
return verifyCodeExternal(vs, new Coding().setSystem(system).setCode(code).setDisplay(display), false);
|
||||
else
|
||||
return verifyCodeInExpansion(vse.getValueset(), system, code, display);
|
||||
|
@ -407,38 +408,4 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
public StructureDefinition fetchTypeDefinition(String typeName) {
|
||||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message = theMessage;
|
||||
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,8 +61,9 @@ import org.hl7.fhir.dstu2016may.terminologies.ValueSetExpansionCache;
|
|||
import org.hl7.fhir.dstu2016may.utils.client.FHIRToolingClient;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nBase;
|
||||
|
||||
public abstract class BaseWorkerContext implements IWorkerContext {
|
||||
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext {
|
||||
|
||||
// all maps are to the full URI
|
||||
protected Map<String, CodeSystem> codeSystems = new HashMap<String, CodeSystem>();
|
||||
|
@ -446,38 +447,4 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
public StructureDefinition fetchTypeDefinition(String typeName) {
|
||||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message = theMessage;
|
||||
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,13 +86,14 @@ import org.hl7.fhir.exceptions.TerminologyServiceException;
|
|||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nBase;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
public abstract class BaseWorkerContext implements IWorkerContext {
|
||||
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext {
|
||||
|
||||
// all maps are to the full URI
|
||||
protected Map<String, CodeSystem> codeSystems = new HashMap<String, CodeSystem>();
|
||||
|
@ -1141,38 +1142,4 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return fetchResource(StructureDefinition.class,
|
||||
"http://hl7.org/fhir/StructureDefinition/" + typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)) {
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message = theMessage;
|
||||
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.hl7.fhir.r4.utils.ToolingExtensions;
|
|||
import org.hl7.fhir.utilities.OIDUtils;
|
||||
import org.hl7.fhir.utilities.TranslationServices;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nBase;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||
|
@ -65,7 +66,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class BaseWorkerContext implements IWorkerContext {
|
||||
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext {
|
||||
|
||||
private Object lock = new Object(); // used as a lock for the data that follows
|
||||
|
||||
|
@ -1179,38 +1180,4 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
return corePath+"snomed.html";
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message = theMessage;
|
||||
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -95,7 +94,7 @@ import org.hl7.fhir.r5.utils.TranslatingUtilities;
|
|||
import org.hl7.fhir.r5.utils.formats.CSVWriter;
|
||||
import org.hl7.fhir.r5.utils.formats.XLSXWriter;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||
|
@ -266,7 +265,6 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
private boolean newSlicingProcessing;
|
||||
private String defWebRoot;
|
||||
private boolean autoFixSliceNames;
|
||||
private ResourceBundle i18nMessages;
|
||||
|
||||
public ProfileUtilities(IWorkerContext context, List<ValidationMessage> messages, ProfileKnowledgeProvider pkp) {
|
||||
super();
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.hl7.fhir.r5.context;
|
|||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -32,8 +31,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -83,7 +80,8 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
|||
import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple;
|
||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.r5.utils.client.ToolingClientLogger;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nBase;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.OIDUtils;
|
||||
import org.hl7.fhir.utilities.TranslationServices;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
@ -95,10 +93,7 @@ import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public abstract class BaseWorkerContext implements IWorkerContext {
|
||||
|
||||
private ResourceBundle i18Nmessages;
|
||||
private Locale locale;
|
||||
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext{
|
||||
|
||||
public class MetadataResourceVersionComparator<T extends CanonicalResource> implements Comparator<T> {
|
||||
|
||||
|
@ -1282,37 +1277,4 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
|||
public Map<String, byte[]> getBinaries() {
|
||||
return binaries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message = theMessage;
|
||||
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,10 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -48,16 +44,13 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
|
|||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext.ILoadFilter;
|
||||
import org.hl7.fhir.r5.formats.IParser;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.ParserType;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.Bundle;
|
||||
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
||||
import org.hl7.fhir.r5.model.ImplementationGuide;
|
||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||
import org.hl7.fhir.r5.model.Questionnaire;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
|
@ -73,7 +66,7 @@ import org.hl7.fhir.r5.utils.INarrativeGenerator;
|
|||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||
import org.hl7.fhir.r5.utils.NarrativeGenerator;
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.cache.NpmPackage;
|
||||
|
@ -81,7 +74,6 @@ import org.hl7.fhir.utilities.validation.ValidationMessage;
|
|||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
|
||||
|
||||
import ca.uhn.fhir.fluentpath.IFluentPath;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
/*
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
|
@ -45,7 +44,7 @@ import org.hl7.fhir.r5.formats.JsonCreatorCanonical;
|
|||
import org.hl7.fhir.r5.formats.JsonCreatorGson;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
|||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
@ -80,7 +80,7 @@ public abstract class ParserBase {
|
|||
|
||||
public abstract void compose(Element e, OutputStream destination, OutputStyle style, String base) throws FHIRException, IOException;
|
||||
|
||||
|
||||
//FIXME: i18n should be done here
|
||||
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.hl7.fhir.r5.utils.formats.Turtle.TTLList;
|
|||
import org.hl7.fhir.r5.utils.formats.Turtle.TTLLiteral;
|
||||
import org.hl7.fhir.r5.utils.formats.Turtle.TTLObject;
|
||||
import org.hl7.fhir.r5.utils.formats.Turtle.TTLURL;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
|
|
@ -40,7 +40,6 @@ import javax.xml.transform.sax.SAXSource;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element.SpecialElement;
|
||||
|
@ -54,7 +53,7 @@ import org.hl7.fhir.r5.utils.ToolingExtensions;
|
|||
import org.hl7.fhir.r5.utils.formats.XmlLocationAnnotator;
|
||||
import org.hl7.fhir.r5.utils.formats.XmlLocationData;
|
||||
import org.hl7.fhir.utilities.ElementDecoration;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.hl7.fhir.r5.terminologies;
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -46,7 +45,7 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
|||
import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||
import org.hl7.fhir.utilities.validation.ValidationOptions.ValueSetMode;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.hl7.fhir.utilities.i18n;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
||||
/**
|
||||
* Handles the locale, ResourceBundle and String formatting for i18n
|
||||
* This abstract class should be extended when implementing a IWorkerContext Interface.
|
||||
*/
|
||||
public abstract class I18nBase {
|
||||
|
||||
|
||||
private Locale locale;
|
||||
private ResourceBundle i18Nmessages;
|
||||
|
||||
public Locale getLocale() {
|
||||
if (Objects.nonNull(locale)){
|
||||
return locale;
|
||||
} else {
|
||||
return Locale.US;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||
String message = theMessage;
|
||||
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||
} else {
|
||||
message = i18Nmessages.getString(theMessage);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setValidationMessageLanguage(Locale locale) {
|
||||
i18Nmessages = ResourceBundle.getBundle("Messages", locale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
package org.hl7.fhir.utilities;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ResourceBundle;
|
||||
package org.hl7.fhir.utilities.i18n;
|
||||
|
||||
public class I18nConstants {
|
||||
|
||||
|
@ -429,6 +426,7 @@ public class I18nConstants {
|
|||
public final static String THIS_BASE_PROPERTY_MUST_BE_AN_ARRAY_NOT_A_ = "This_base_property_must_be_an_Array_not_a_";
|
||||
public final static String THIS_PROPERTY_MUST_BE_AN_ARRAY_NOT_A_ = "This_property_must_be_an_Array_not_a_";
|
||||
public final static String DOCUMENT = "documentmsg";
|
||||
public final static String DOCUMENT_DATE_REQUIRED = "Document_Date_Missing";
|
||||
public final static String DOCUMENT_DATE_REQUIRED = "Bundle_Document_Date_Missing";
|
||||
public final static String DOCUMENT_DATE_REQUIRED_HTML = "Bundle_Document_Date_Missing_html";
|
||||
|
||||
}
|
|
@ -17,7 +17,8 @@ Bundle_BUNDLE_FullUrl_NeedVersion = Entries matching fullURL {0} should declare
|
|||
Bundle_BUNDLE_MultipleMatches = Multiple matches in bundle for reference {0}
|
||||
Bundle_BUNDLE_Not_Local = URN reference is not locally contained within the bundle {0}
|
||||
Bundle_MSG_Event_Count = Expected {0} but found {1} event elements
|
||||
Bundle_Document_Date = A document must have a date [(type = 'document') implies (meta.lastUpdated.hasValue())]
|
||||
Bundle_Document_Date_Missing = A document must have a date {0}
|
||||
Bundle_Document_Date_Missing_html = [(type = 'document') implies (meta.lastUpdated.hasValue())]
|
||||
CapabalityStatement_CS_SP_WrongType = Type mismatch - SearchParameter "{0}" type is {1}, but type here is {2}
|
||||
CodeSystem_CS_VS_IncludeDetails = CodeSystem {0} has a ''all system'' value set of {1}, but the include has extra details
|
||||
CodeSystem_CS_VS_Invalid = CodeSystem {0} has a ''all system'' value set of {1}, but doesn''t have a single include
|
||||
|
@ -427,5 +428,5 @@ Unable_to_resolve_system__no_value_set = Unable to resolve system - no value set
|
|||
This_base_property_must_be_an_Array_not_a_ = This base property must be an Array, not a {0}
|
||||
This_property_must_be_an_Array_not_a_ = This property must be an Array, not a {0}
|
||||
documentmsg = (document)
|
||||
Document_Date_Missing = A document must have a date {0}
|
||||
|
||||
|
|
@ -17,6 +17,8 @@ Bundle_BUNDLE_FullUrl_NeedVersion=Einträge, die mit fullURL {0} übereinstimmen
|
|||
Bundle_BUNDLE_MultipleMatches=Mehrere Übereinstimmungen im Bundle für reference {0}
|
||||
Bundle_BUNDLE_Not_Local=URN reference ist nicht lokal innerhalb des Bundles contained {0}
|
||||
Bundle_MSG_Event_Count=Erwartet {0}, aber gefundene {1} event Elemente
|
||||
Bundle_Document_Date_Missing=Ein Dokument muss ein Datum haben {0}
|
||||
Bundle_Document_Date_Missing_html=[(type = 'document') impliziert (meta.lastUpdated.hasValue())]
|
||||
CapabalityStatement_CS_SP_WrongType=Typabweichung - SearchParameter "{0}" sollte type {1} sein, ist aber {2}
|
||||
CodeSystem_CS_VS_IncludeDetails=CodeSystem {0} hat einen ''all system'' ValueSet von {1}, aber das Include beeinhaltet zusätzliche Details
|
||||
CodeSystem_CS_VS_Invalid=CodeSystem {0} hat einen ''all system'' ValueSet von {1}, aber keinen einzigen include
|
||||
|
@ -113,7 +115,7 @@ Reference_REF_ResourceType=Passende Referenz für Referenz {0} hat resourceType
|
|||
Reference_REF_WrongTarget=Der Typ "{0}" ist kein gültiges Ziel für dieses Element (muss einer von {1} sein)
|
||||
Resource_RES_ID_Missing=Die Ressource erfordert eine ID, aber es ist keine vorhanden
|
||||
Resource_RES_ID_Prohibited=Die Ressource hat eine ID, aber keine ist erlaubt
|
||||
Terminology_PassThrough_TX_Message = {0} for "{1}#{2}"
|
||||
Terminology_PassThrough_TX_Message = {0} für "{1}#{2}"
|
||||
Terminology_TX_Binding_CantCheck=Binding durch URI-Referenz kann nicht überprüft werden
|
||||
Terminology_TX_Binding_Missing=Binding für {0} fehlt (cc)
|
||||
Terminology_TX_Binding_Missing2=Binding für {0} fehlt
|
|
@ -49,10 +49,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
@ -70,11 +67,6 @@ public class BaseValidator {
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
// public void setContext(IWorkerContext context) {
|
||||
// this.context = context;
|
||||
// i18Nmessages = ResourceBundle.getBundle("Messages", context.getLocale() );
|
||||
// }
|
||||
|
||||
/**
|
||||
* Test a rule and add a {@link IssueSeverity#FATAL} validation message if the validation fails
|
||||
*
|
||||
|
@ -82,7 +74,7 @@ public class BaseValidator {
|
|||
* Set this parameter to <code>false</code> if the validation does not pass
|
||||
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
|
||||
*/
|
||||
//todo: remove after i18n implementation done
|
||||
@Deprecated
|
||||
protected boolean fail(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) {
|
||||
if (!thePass) {
|
||||
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL);
|
||||
|
@ -105,6 +97,7 @@ public class BaseValidator {
|
|||
* Set this parameter to <code>false</code> if the validation does not pass
|
||||
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
|
||||
*/
|
||||
@Deprecated
|
||||
protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String msg) {
|
||||
if (!thePass) {
|
||||
String path = toPath(pathParts);
|
||||
|
@ -120,6 +113,7 @@ public class BaseValidator {
|
|||
* Set this parameter to <code>false</code> if the validation does not pass
|
||||
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
|
||||
*/
|
||||
@Deprecated
|
||||
protected boolean fail(List<ValidationMessage> errors, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) {
|
||||
if (!thePass) {
|
||||
String path = toPath(pathParts);
|
||||
|
@ -135,13 +129,14 @@ public class BaseValidator {
|
|||
* Set this parameter to <code>false</code> if the validation does not pass
|
||||
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
|
||||
*/
|
||||
@Deprecated
|
||||
protected boolean fail(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg) {
|
||||
if (!thePass) {
|
||||
addValidationMessage(errors, type, -1, -1, path, msg, IssueSeverity.FATAL);
|
||||
}
|
||||
return thePass;
|
||||
}
|
||||
|
||||
//TODO: i18n
|
||||
protected boolean grammarWord(String w) {
|
||||
return w.equals("and") || w.equals("or") || w.equals("a") || w.equals("the") || w.equals("for") || w.equals("this") || w.equals("that") || w.equals("of");
|
||||
}
|
||||
|
@ -156,7 +151,7 @@ public class BaseValidator {
|
|||
protected boolean hint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) {
|
||||
if (!thePass) {
|
||||
String message = context.formatMessage(msg);
|
||||
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION);
|
||||
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION);
|
||||
}
|
||||
return thePass;
|
||||
}
|
||||
|
@ -168,7 +163,7 @@ public class BaseValidator {
|
|||
* Set this parameter to <code>false</code> if the validation does not pass
|
||||
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
|
||||
*/
|
||||
|
||||
//FIXME: formatMessage should be done here
|
||||
protected boolean slicingHint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg, String html) {
|
||||
if (!thePass) {
|
||||
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.INFORMATION).setSlicingHint(true).setSliceHtml(html);
|
||||
|
@ -323,7 +318,9 @@ public class BaseValidator {
|
|||
*/
|
||||
protected boolean rule(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, String msg, String html) {
|
||||
if (!thePass) {
|
||||
addValidationMessage(errors, type, path, msg, html, IssueSeverity.ERROR);
|
||||
msg = context.formatMessage(msg, null);
|
||||
html = context.formatMessage(html, null);
|
||||
addValidationMessage(errors, type, path, msg, html, IssueSeverity.ERROR);
|
||||
}
|
||||
return thePass;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
|||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.utilities.I18nConstants;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.validation.BaseValidator;
|
||||
import org.hl7.fhir.validation.instance.EnableWhenEvaluator.QStack;
|
||||
import org.hl7.fhir.validation.XVerExtensionManager;
|
||||
|
@ -333,8 +333,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private IWorkerContext context;
|
||||
private FHIRPathEngine fpe;
|
||||
|
||||
// configuration items
|
||||
|
@ -385,7 +383,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
|
||||
public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices) {
|
||||
super(theContext);
|
||||
this.context = theContext;
|
||||
this.externalHostServices = hostServices;
|
||||
this.profileUtilities = new ProfileUtilities(theContext, null, null);
|
||||
fpe = new FHIRPathEngine(context);
|
||||
|
@ -4295,7 +4292,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
boolean ok = bundle.hasChild(META)
|
||||
&& bundle.getNamedChild(META).hasChild(LAST_UPDATED)
|
||||
&& bundle.getNamedChild(META).getNamedChild(LAST_UPDATED).hasValue();
|
||||
rule(errors, IssueType.REQUIRED, stack.literalPath, ok, I18nConstants.DOCUMENT_DATE_REQUIRED, "[(type = 'document') implies (meta.lastUpdated.hasValue())]");
|
||||
rule(errors, IssueType.REQUIRED, stack.literalPath, ok, I18nConstants.DOCUMENT_DATE_REQUIRED, I18nConstants.DOCUMENT_DATE_REQUIRED_HTML);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue