Merge pull request #480 from hapifhir/gg-202104-bugfixes
Gg 202104 bugfixes
This commit is contained in:
commit
ab9698d5bc
|
@ -0,0 +1,5 @@
|
||||||
|
* Breaking Change: Fix issue where primitive elements with required bindings must have a value, but this wasn't be checked
|
||||||
|
* Fix bug with value set imports not working
|
||||||
|
* Fix bug with base definitions not working properly for logical models
|
||||||
|
* Better memory tracking for validator
|
||||||
|
* Get code generator compiling
|
|
@ -996,7 +996,7 @@ private void generatePropertyMaker(Analysis analysis, TypeInfo ti, String indent
|
||||||
private List<TypeRefComponent> getTypes(List<TypeRefComponent> types) {
|
private List<TypeRefComponent> getTypes(List<TypeRefComponent> types) {
|
||||||
if (types.size() == 1 && types.get(0).getName().equals("*")) {
|
if (types.size() == 1 && types.get(0).getName().equals("*")) {
|
||||||
List<TypeRefComponent> t = new ArrayList<TypeRefComponent>();
|
List<TypeRefComponent> t = new ArrayList<TypeRefComponent>();
|
||||||
for (String s : TypesUtilities.wildcardTypes()) {
|
for (String s : TypesUtilities.wildcardTypes("5.0")) {
|
||||||
t.add(new TypeRefComponent(s));
|
t.add(new TypeRefComponent(s));
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -13,8 +13,8 @@ import org.hl7.fhir.r5.model.Resource;
|
||||||
import org.hl7.fhir.r5.model.SearchParameter;
|
import org.hl7.fhir.r5.model.SearchParameter;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
import org.hl7.fhir.r5.model.ValueSet;
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
import org.hl7.fhir.utilities.cache.NpmPackage;
|
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||||
import org.hl7.fhir.utilities.cache.ToolsVersion;
|
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||||
|
|
||||||
public class DefinitionsLoader {
|
public class DefinitionsLoader {
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ import org.hl7.fhir.r5.model.SearchParameter;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
import org.hl7.fhir.utilities.TextFile;
|
import org.hl7.fhir.utilities.TextFile;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
|
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||||
import org.hl7.fhir.utilities.cache.NpmPackage;
|
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||||
import org.hl7.fhir.utilities.cache.ToolsVersion;
|
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||||
|
|
||||||
public class JavaCoreGenerator {
|
public class JavaCoreGenerator {
|
||||||
|
|
||||||
|
|
|
@ -2989,7 +2989,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
StructureDefinition sdt = context.fetchTypeDefinition(tt);
|
StructureDefinition sdt = context.fetchTypeDefinition(tt);
|
||||||
if (sdt != null && sdt.getAbstract()) {
|
if (sdt != null && (sdt.getAbstract() || sdt.getKind() == StructureDefinitionKind.LOGICAL)) {
|
||||||
StructureDefinition sdb = context.fetchTypeDefinition(t);
|
StructureDefinition sdb = context.fetchTypeDefinition(t);
|
||||||
while (sdb != null && !ok) {
|
while (sdb != null && !ok) {
|
||||||
ok = sdb.getType().equals(sdt.getType());
|
ok = sdb.getType().equals(sdt.getType());
|
||||||
|
|
|
@ -923,13 +923,21 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
li.tx("Import all the codes that are contained in ");
|
li.tx("Import all the codes that are contained in ");
|
||||||
boolean first = true;
|
if (inc.getValueSet().size() < 4) {
|
||||||
for (UriType vs : inc.getValueSet()) {
|
boolean first = true;
|
||||||
if (first)
|
for (UriType vs : inc.getValueSet()) {
|
||||||
first = false;
|
if (first)
|
||||||
else
|
first = false;
|
||||||
li.tx(", ");
|
else
|
||||||
AddVsRef(vs.asStringValue(), li);
|
li.tx(", ");
|
||||||
|
AddVsRef(vs.asStringValue(), li);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
XhtmlNode xul = li.ul();
|
||||||
|
for (UriType vs : inc.getValueSet()) {
|
||||||
|
AddVsRef(vs.asStringValue(), xul.li());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hasExtensions;
|
return hasExtensions;
|
||||||
|
|
|
@ -510,10 +510,31 @@ public class ValueSetExpanderSimple implements ValueSetExpander {
|
||||||
if (!existsInParams(exp.getParameter(), p.getName(), p.getValue()))
|
if (!existsInParams(exp.getParameter(), p.getName(), p.getValue()))
|
||||||
exp.getParameter().add(p);
|
exp.getParameter().add(p);
|
||||||
}
|
}
|
||||||
|
copyExpansion(vso.getValueset().getExpansion().getContains());
|
||||||
canBeHeirarchy = false; // if we're importing a value set, we have to be combining, so we won't try for a heirarchy
|
canBeHeirarchy = false; // if we're importing a value set, we have to be combining, so we won't try for a heirarchy
|
||||||
return vso.getValueset();
|
return vso.getValueset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void copyExpansion(List<ValueSetExpansionContainsComponent> list) {
|
||||||
|
for (ValueSetExpansionContainsComponent cc : list) {
|
||||||
|
ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
|
||||||
|
n.setSystem(cc.getSystem());
|
||||||
|
n.setCode(cc.getCode());
|
||||||
|
n.setAbstract(cc.getAbstract());
|
||||||
|
n.setInactive(cc.getInactive());
|
||||||
|
n.setDisplay(cc.getDisplay());
|
||||||
|
n.getDesignation().addAll(cc.getDesignation());
|
||||||
|
|
||||||
|
String s = key(n);
|
||||||
|
if (!map.containsKey(s) && !excludeKeys.contains(s)) {
|
||||||
|
codes.add(n);
|
||||||
|
map.put(s, n);
|
||||||
|
total++;
|
||||||
|
}
|
||||||
|
copyExpansion(cc.getContains());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addErrors(List<String> errs) {
|
private void addErrors(List<String> errs) {
|
||||||
for (String s : errs) {
|
for (String s : errs) {
|
||||||
if (!allErrors.contains(s)) {
|
if (!allErrors.contains(s)) {
|
||||||
|
|
|
@ -54,9 +54,9 @@ public class OperationOutcomeUtilities {
|
||||||
issue.addExpression(message.getLocation());
|
issue.addExpression(message.getLocation());
|
||||||
}
|
}
|
||||||
// pass through line/col if they're present
|
// pass through line/col if they're present
|
||||||
if (message.getLine() != 0)
|
if (message.getLine() >= 0)
|
||||||
issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_LINE).setValue(new IntegerType(message.getLine()));
|
issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_LINE).setValue(new IntegerType(message.getLine()));
|
||||||
if (message.getCol() != 0)
|
if (message.getCol() >= 0)
|
||||||
issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_COL).setValue(new IntegerType(message.getCol()));
|
issue.addExtension().setUrl(ToolingExtensions.EXT_ISSUE_COL).setValue(new IntegerType(message.getCol()));
|
||||||
issue.setSeverity(convert(message.getLevel()));
|
issue.setSeverity(convert(message.getLevel()));
|
||||||
CodeableConcept c = new CodeableConcept();
|
CodeableConcept c = new CodeableConcept();
|
||||||
|
|
|
@ -1346,6 +1346,21 @@ public class Utilities {
|
||||||
return length + BT;
|
return length + BT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String describeSize(long length) {
|
||||||
|
if (length < 0) throw new IllegalArgumentException("File length of < 0 passed in...");
|
||||||
|
|
||||||
|
if (length > Math.pow(ONE_MB, 3)) {
|
||||||
|
return length / ((long) Math.pow(ONE_MB, 3)) + GB;
|
||||||
|
}
|
||||||
|
if (length > Math.pow(ONE_MB, 2)) {
|
||||||
|
return length / ((long) Math.pow(ONE_MB, 2)) + MB;
|
||||||
|
}
|
||||||
|
if (length > ONE_MB) {
|
||||||
|
return length / (ONE_MB) + KB;
|
||||||
|
}
|
||||||
|
return length + BT;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<byte[]> splitBytes(byte[] array, byte[] delimiter) {
|
public static List<byte[]> splitBytes(byte[] array, byte[] delimiter) {
|
||||||
List<byte[]> byteArrays = new LinkedList<byte[]>();
|
List<byte[]> byteArrays = new LinkedList<byte[]>();
|
||||||
if (delimiter.length == 0)
|
if (delimiter.length == 0)
|
||||||
|
|
|
@ -386,6 +386,7 @@ public class I18nConstants {
|
||||||
public static final String TERMINOLOGY_TX_CODE_NOTVALID = "Terminology_TX_Code_NotValid";
|
public static final String TERMINOLOGY_TX_CODE_NOTVALID = "Terminology_TX_Code_NotValid";
|
||||||
public static final String TERMINOLOGY_TX_CODE_UNKNOWN = "Terminology_TX_Code_Unknown";
|
public static final String TERMINOLOGY_TX_CODE_UNKNOWN = "Terminology_TX_Code_Unknown";
|
||||||
public static final String TERMINOLOGY_TX_CODE_VALUESET = "Terminology_TX_Code_ValueSet";
|
public static final String TERMINOLOGY_TX_CODE_VALUESET = "Terminology_TX_Code_ValueSet";
|
||||||
|
public static final String Terminology_TX_Code_ValueSet_MISSING = "Terminology_TX_Code_ValueSet_MISSING";
|
||||||
public static final String TERMINOLOGY_TX_CODE_VALUESETMAX = "Terminology_TX_Code_ValueSetMax";
|
public static final String TERMINOLOGY_TX_CODE_VALUESETMAX = "Terminology_TX_Code_ValueSetMax";
|
||||||
public static final String TERMINOLOGY_TX_CODE_VALUESET_EXT = "Terminology_TX_Code_ValueSet_Ext";
|
public static final String TERMINOLOGY_TX_CODE_VALUESET_EXT = "Terminology_TX_Code_ValueSet_Ext";
|
||||||
public static final String TERMINOLOGY_TX_CODING_COUNT = "Terminology_TX_Coding_Count";
|
public static final String TERMINOLOGY_TX_CODING_COUNT = "Terminology_TX_Coding_Count";
|
||||||
|
|
|
@ -164,6 +164,9 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
|
||||||
public boolean isError() {
|
public boolean isError() {
|
||||||
return this == FATAL || this == ERROR;
|
return this == FATAL || this == ERROR;
|
||||||
}
|
}
|
||||||
|
public boolean isHint() {
|
||||||
|
return this == INFORMATION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum IssueType {
|
public enum IssueType {
|
||||||
|
|
|
@ -130,6 +130,7 @@ Terminology_TX_Binding_NoSource2 = Binding has no source, so can''t be checked
|
||||||
Terminology_TX_Code_NotValid = Code {0} is not a valid code in code system {1}
|
Terminology_TX_Code_NotValid = Code {0} is not a valid code in code system {1}
|
||||||
Terminology_TX_Code_Unknown = Unknown Code ({0}#{1})
|
Terminology_TX_Code_Unknown = Unknown Code ({0}#{1})
|
||||||
Terminology_TX_Code_ValueSet = No code provided, and a code is required from the value set {0} ({1})
|
Terminology_TX_Code_ValueSet = No code provided, and a code is required from the value set {0} ({1})
|
||||||
|
Terminology_TX_Code_ValueSet_MISSING = No code provided, and a code is required from the value set
|
||||||
Terminology_TX_Code_ValueSetMax = No code provided, and a code must be provided from the value set {0} (max value set {1})
|
Terminology_TX_Code_ValueSetMax = No code provided, and a code must be provided from the value set {0} (max value set {1})
|
||||||
Terminology_TX_Code_ValueSet_Ext = No code provided, and a code should be provided from the value set {0} ({1})
|
Terminology_TX_Code_ValueSet_Ext = No code provided, and a code should be provided from the value set {0} ({1})
|
||||||
Terminology_TX_Coding_Count = Expected {0} but found {1} coding elements
|
Terminology_TX_Coding_Count = Expected {0} but found {1} coding elements
|
||||||
|
|
|
@ -61,6 +61,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
import org.hl7.fhir.r5.model.ImplementationGuide;
|
import org.hl7.fhir.r5.model.ImplementationGuide;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
import org.hl7.fhir.utilities.TimeTracker;
|
import org.hl7.fhir.utilities.TimeTracker;
|
||||||
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.VersionUtilities;
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
import org.hl7.fhir.validation.cli.model.CliContext;
|
import org.hl7.fhir.validation.cli.model.CliContext;
|
||||||
import org.hl7.fhir.validation.cli.services.ComparisonService;
|
import org.hl7.fhir.validation.cli.services.ComparisonService;
|
||||||
|
@ -238,6 +239,6 @@ public class ValidatorCli {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
System.out.println("Done. " + tt.report());
|
System.out.println("Done. " + tt.report()+". Max Memory = "+Utilities.describeSize(Runtime.getRuntime().maxMemory()));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,8 @@ import org.hl7.fhir.validation.cli.utils.EngineMode;
|
||||||
import org.hl7.fhir.validation.cli.utils.VersionSourceInformation;
|
import org.hl7.fhir.validation.cli.utils.VersionSourceInformation;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.lang.management.MemoryMXBean;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -66,6 +68,7 @@ public class ValidationService {
|
||||||
messages.forEach(outcome::addMessage);
|
messages.forEach(outcome::addMessage);
|
||||||
response.addOutcome(outcome);
|
response.addOutcome(outcome);
|
||||||
}
|
}
|
||||||
|
System.out.println(" Max Memory: "+Runtime.getRuntime().maxMemory());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +90,8 @@ public class ValidationService {
|
||||||
List<ValidationRecord> records = new ArrayList<>();
|
List<ValidationRecord> records = new ArrayList<>();
|
||||||
Resource r = validator.validate(cliContext.getSources(), cliContext.getProfiles(), records);
|
Resource r = validator.validate(cliContext.getSources(), cliContext.getProfiles(), records);
|
||||||
int ec = 0;
|
int ec = 0;
|
||||||
System.out.println("Done. " + validator.getContext().clock().report());
|
MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
|
||||||
|
System.out.println("Done. " + validator.getContext().clock().report()+". Memory = "+Utilities.describeSize(mbean.getHeapMemoryUsage().getUsed()+mbean.getNonHeapMemoryUsage().getUsed()));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
if (cliContext.getOutput() == null) {
|
if (cliContext.getOutput() == null) {
|
||||||
|
@ -211,7 +215,9 @@ public class ValidationService {
|
||||||
public String initializeValidator(CliContext cliContext, String definitions, TimeTracker tt, String sessionId) throws Exception {
|
public String initializeValidator(CliContext cliContext, String definitions, TimeTracker tt, String sessionId) throws Exception {
|
||||||
tt.milestone();
|
tt.milestone();
|
||||||
if (!sessionCache.sessionExists(sessionId)) {
|
if (!sessionCache.sessionExists(sessionId)) {
|
||||||
System.out.println("No such cached session exists for session id " + sessionId + ", re-instantiating validator.");
|
if (sessionId != null) {
|
||||||
|
System.out.println("No such cached session exists for session id " + sessionId + ", re-instantiating validator.");
|
||||||
|
}
|
||||||
System.out.print(" Load FHIR v" + cliContext.getSv() + " from " + definitions);
|
System.out.print(" Load FHIR v" + cliContext.getSv() + " from " + definitions);
|
||||||
ValidationEngine validator = new ValidationEngine(definitions, cliContext.getSv(), tt);
|
ValidationEngine validator = new ValidationEngine(definitions, cliContext.getSv(), tt);
|
||||||
sessionId = sessionCache.cacheSession(validator);
|
sessionId = sessionCache.cacheSession(validator);
|
||||||
|
|
|
@ -1907,6 +1907,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.hasChildren(), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_PRIMITIVE_NOTEMPTY);
|
rule(errors, IssueType.INVALID, e.line(), e.col(), path, e.hasChildren(), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_PRIMITIVE_NOTEMPTY);
|
||||||
else if (StringUtils.isWhitespace(e.primitiveValue()))
|
else if (StringUtils.isWhitespace(e.primitiveValue()))
|
||||||
warning(errors, IssueType.INVALID, e.line(), e.col(), path, e.hasChildren(), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_PRIMITIVE_WS);
|
warning(errors, IssueType.INVALID, e.line(), e.col(), path, e.hasChildren(), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_PRIMITIVE_WS);
|
||||||
|
if (context.hasBinding()) {
|
||||||
|
rule(errors, IssueType.CODEINVALID, e.line(), e.col(), path, context.getBinding().getStrength() != BindingStrength.REQUIRED, I18nConstants.Terminology_TX_Code_ValueSet_MISSING);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String regex = context.getExtensionString(ToolingExtensions.EXT_REGEX);
|
String regex = context.getExtensionString(ToolingExtensions.EXT_REGEX);
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<hapi_fhir_version>5.1.0</hapi_fhir_version>
|
<hapi_fhir_version>5.1.0</hapi_fhir_version>
|
||||||
<validator_test_case_version>1.1.59</validator_test_case_version>
|
<validator_test_case_version>1.1.60-SNAPSHOT</validator_test_case_version>
|
||||||
<junit_jupiter_version>5.7.1</junit_jupiter_version>
|
<junit_jupiter_version>5.7.1</junit_jupiter_version>
|
||||||
<junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
|
<junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
|
||||||
<maven_surefire_version>3.0.0-M4</maven_surefire_version>
|
<maven_surefire_version>3.0.0-M4</maven_surefire_version>
|
||||||
|
|
Loading…
Reference in New Issue