diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 4ceb1f27a..661d7f566 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -1038,8 +1038,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte for (CanonicalType c : inc.getValueSet()) { ValueSet vs = fetchResource(ValueSet.class, c.getValue()); if (vs != null) { + pin.addParameter().setName("tx-resource").setResource(vs); if (isTxCaching && cacheId == null || !cached.contains(vs.getVUrl())) { - pin.addParameter().setName("tx-resource").setResource(vs); cached.add(vs.getVUrl()); cache = true; } @@ -1048,8 +1048,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } CodeSystem cs = fetchResource(CodeSystem.class, inc.getSystem()); if (cs != null) { + pin.addParameter().setName("tx-resource").setResource(cs); if (isTxCaching && cacheId == null || !cached.contains(cs.getVUrl())) { - pin.addParameter().setName("tx-resource").setResource(cs); cached.add(cs.getVUrl()); cache = true; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/UnsignedIntType.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/UnsignedIntType.java index 853e4930c..6cab2e4a9 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/UnsignedIntType.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/UnsignedIntType.java @@ -89,7 +89,8 @@ public class UnsignedIntType extends IntegerType { @Override public UnsignedIntType copy() { - UnsignedIntType ret = new UnsignedIntType(getValue()); + Integer value = getValue(); + UnsignedIntType ret = value == null ? new UnsignedIntType() : new UnsignedIntType(value.intValue()); copyValues(ret); return ret; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CanonicalSpreadsheetGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CanonicalSpreadsheetGenerator.java index 8145fc7d2..4a5cd4e22 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CanonicalSpreadsheetGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CanonicalSpreadsheetGenerator.java @@ -21,7 +21,7 @@ public class CanonicalSpreadsheetGenerator extends SpreadsheetGenerator { } protected Sheet renderCanonicalResource(CanonicalResource cr) { - Sheet sheet = wb.createSheet("Metadata"); + Sheet sheet = makeSheet("Metadata"); Row headerRow = sheet.createRow(0); addCell(headerRow, 0, "Property", styles.get("header")); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CodeSystemSpreadsheetGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CodeSystemSpreadsheetGenerator.java index 78556a167..9097fc8dc 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CodeSystemSpreadsheetGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/CodeSystemSpreadsheetGenerator.java @@ -68,7 +68,7 @@ public class CodeSystemSpreadsheetGenerator extends CanonicalSpreadsheetGenerato } private void addFilters(List filters) { - Sheet sheet = wb.createSheet("Filters"); + Sheet sheet = makeSheet("Filters"); addHeaders(sheet, "Code", "Description", "Operators", "Value"); for (CodeSystemFilterComponent f : filters) { CommaSeparatedStringBuilder cs = new CommaSeparatedStringBuilder(); @@ -80,7 +80,7 @@ public class CodeSystemSpreadsheetGenerator extends CanonicalSpreadsheetGenerato } private void addProperties(List properties) { - Sheet sheet = wb.createSheet("Properties"); + Sheet sheet = makeSheet("Properties"); addHeaders(sheet, "Code", "Uri", "Description", "Type"); for (PropertyComponent p : properties) { addRow(sheet, p.getCode(), p.getUri(), p.getDescription(), p.getTypeElement().asStringValue()); @@ -88,7 +88,7 @@ public class CodeSystemSpreadsheetGenerator extends CanonicalSpreadsheetGenerato } private void addConcepts(List concepts) { - Sheet sheet = wb.createSheet("Concepts"); + Sheet sheet = makeSheet("Concepts"); addHeaders(sheet, "Level", "Code", "Display", "Definition"); //todo: properties and designations addConcepts(sheet, 1, concepts); } @@ -103,7 +103,7 @@ public class CodeSystemSpreadsheetGenerator extends CanonicalSpreadsheetGenerato } private void genExpansionParams(List params) { - Sheet sheet = wb.createSheet("Expansion Parameters"); + Sheet sheet = makeSheet("Expansion Parameters"); addHeaders(sheet, "Parameter", "Value"); for (ValueSetExpansionParameterComponent p : params) { addRow(sheet, p.getName(), dr.display(p.getValue())); @@ -111,7 +111,7 @@ public class CodeSystemSpreadsheetGenerator extends CanonicalSpreadsheetGenerato } private void genExpansion(List list) { - Sheet sheet = wb.createSheet("Expansion"); + Sheet sheet = makeSheet("Expansion"); addHeaders(sheet, "Level", "System", "version", "Code", "Display", "Abstract", "Inactive"); genExpansionEntry(1, list, sheet); } @@ -129,12 +129,12 @@ public class CodeSystemSpreadsheetGenerator extends CanonicalSpreadsheetGenerato return value ? "" : "false"; } - private void genInclude(ValueSet vs, ConceptSetComponent inc, String mode) { - if (inc.hasSystem()) { - genIncludeSystem(vs, inc, mode); - } else { - genIncludeValueSets(vs, inc, mode); - } +// private void genInclude(ValueSet vs, ConceptSetComponent inc, String mode) { +// if (inc.hasSystem()) { +// genIncludeSystem(vs, inc, mode); +// } else { +// genIncludeValueSets(vs, inc, mode); +// } // String subname = inc.hasSystem() ? : "ValueSets"; // // @@ -152,33 +152,33 @@ public class CodeSystemSpreadsheetGenerator extends CanonicalSpreadsheetGenerato // processElement(sheet, sd, child); // } // configureSheet(sheet, sd); - } +// } - private void genIncludeValueSets(ValueSet vs, ConceptSetComponent inc, String mode) { - Sheet sheet = wb.createSheet(mode+" ValueSets"); - addValueSets(sheet, inc.getValueSet()); - configureSheet(sheet); - } - - private void genIncludeSystem(ValueSet vs, ConceptSetComponent inc, String mode) { - Sheet sheet = wb.createSheet(mode+" from "+dr.displaySystem(inc.getSystem())); - if (inc.hasValueSet()) { - addValueSets(sheet, inc.getValueSet()); - } - if (inc.hasFilter()) { - addFilters(sheet, inc.getFilter()); - } - if (inc.hasConcept()) { - addConcepts(sheet, inc.getConcept()); - } - if (!inc.hasConcept() && !inc.hasFilter()) { - addAllCodes(sheet); - } - addRow(sheet, "", ""); - addRow(sheet, "System URI", inc.getSystem()); - - configureSheet(sheet); - } +// private void genIncludeValueSets(ValueSet vs, ConceptSetComponent inc, String mode) { +// Sheet sheet = makeSheet(mode+" ValueSets"); +// addValueSets(sheet, inc.getValueSet()); +// configureSheet(sheet); +// } +// +// private void genIncludeSystem(ValueSet vs, ConceptSetComponent inc, String mode) { +// Sheet sheet = makeSheet(mode+" from "+dr.displaySystem(inc.getSystem())); +// if (inc.hasValueSet()) { +// addValueSets(sheet, inc.getValueSet()); +// } +// if (inc.hasFilter()) { +// addFilters(sheet, inc.getFilter()); +// } +// if (inc.hasConcept()) { +// addConcepts(sheet, inc.getConcept()); +// } +// if (!inc.hasConcept() && !inc.hasFilter()) { +// addAllCodes(sheet); +// } +// addRow(sheet, "", ""); +// addRow(sheet, "System URI", inc.getSystem()); +// +// configureSheet(sheet); +// } private void addAllCodes(Sheet sheet) { addHeaders(sheet, "Codes"); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ConceptMapSpreadsheetGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ConceptMapSpreadsheetGenerator.java index d30849373..64cb58ad6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ConceptMapSpreadsheetGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ConceptMapSpreadsheetGenerator.java @@ -38,7 +38,7 @@ public class ConceptMapSpreadsheetGenerator extends CanonicalSpreadsheetGenerato } private void renderGroup(ConceptMapGroupComponent grp, int i) { - Sheet sheet = wb.createSheet("Mapping Table "+Integer.toString(i)); + Sheet sheet = makeSheet("Mapping Table "+Integer.toString(i)); addHeaders(sheet, "Source", "Display", "Relationship", "Target", "Display"); addRow(sheet, grp.getSource(), "", "", grp.getTarget(), ""); for (SourceElementComponent s : grp.getElement()) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/SpreadsheetGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/SpreadsheetGenerator.java index 3eddf8fb4..1e62d3416 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/SpreadsheetGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/SpreadsheetGenerator.java @@ -2,7 +2,9 @@ package org.hl7.fhir.r5.renderers.spreadsheets; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.apache.poi.ss.usermodel.BorderStyle; @@ -58,6 +60,7 @@ public class SpreadsheetGenerator { protected Map styles; protected DataRenderer dr; + private List sheetNames = new ArrayList<>(); public SpreadsheetGenerator(IWorkerContext context) { super(); @@ -72,6 +75,19 @@ public class SpreadsheetGenerator { outStream.close(); } + protected Sheet makeSheet(String name) { + String s = name; + if (sheetNames.contains(s)) { + int i = 1; + do { + i++; + s = name+" "+Integer.toString(i); + } while (sheetNames.contains(s)); + } + sheetNames.add(s); + return wb.createSheet(s); + } + private static Map createStyles(Workbook wb){ Map styles = new HashMap<>(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/StructureDefinitionSpreadsheetGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/StructureDefinitionSpreadsheetGenerator.java index 09d06ad0b..1d10c3f97 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/StructureDefinitionSpreadsheetGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/StructureDefinitionSpreadsheetGenerator.java @@ -96,7 +96,7 @@ public class StructureDefinitionSpreadsheetGenerator extends CanonicalSpreadshee throw new DefinitionException(context.formatMessage(I18nConstants.NEEDS_A_SNAPSHOT)); } addStructureDefinitionMetadata(renderCanonicalResource(sd), sd); - Sheet sheet = wb.createSheet("Elements"); + Sheet sheet = makeSheet("Elements"); Row headerRow = sheet.createRow(0); for (int i = 0; i < titles.length; i++) { @@ -115,6 +115,7 @@ public class StructureDefinitionSpreadsheetGenerator extends CanonicalSpreadshee return this; } + private void addStructureDefinitionMetadata(Sheet sheet, StructureDefinition sd) { for (Coding k : sd.getKeyword()) { addMetadataRow(sheet, "Keyword", dr.display(k)); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ValueSetSpreadsheetGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ValueSetSpreadsheetGenerator.java index a72bdb93a..dec177b1a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ValueSetSpreadsheetGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/spreadsheets/ValueSetSpreadsheetGenerator.java @@ -56,7 +56,7 @@ public class ValueSetSpreadsheetGenerator extends CanonicalSpreadsheetGenerator } private void genExpansionParams(List params) { - Sheet sheet = wb.createSheet("Expansion Parameters"); + Sheet sheet = makeSheet("Expansion Parameters"); addHeaders(sheet, "Parameter", "Value"); for (ValueSetExpansionParameterComponent p : params) { addRow(sheet, p.getName(), dr.display(p.getValue())); @@ -64,7 +64,7 @@ public class ValueSetSpreadsheetGenerator extends CanonicalSpreadsheetGenerator } private void genExpansion(List list) { - Sheet sheet = wb.createSheet("Expansion"); + Sheet sheet = makeSheet("Expansion"); addHeaders(sheet, "Level", "System", "version", "Code", "Display", "Abstract", "Inactive"); genExpansionEntry(1, list, sheet); } @@ -108,13 +108,13 @@ public class ValueSetSpreadsheetGenerator extends CanonicalSpreadsheetGenerator } private void genIncludeValueSets(ValueSet vs, ConceptSetComponent inc, String mode) { - Sheet sheet = wb.createSheet(mode+" ValueSets"); + Sheet sheet = makeSheet(mode+" ValueSets"); addValueSets(sheet, inc.getValueSet()); configureSheet(sheet); } private void genIncludeSystem(ValueSet vs, ConceptSetComponent inc, String mode) { - Sheet sheet = wb.createSheet(mode+" from "+dr.displaySystem(inc.getSystem())); + Sheet sheet = makeSheet(mode+" from "+dr.displaySystem(inc.getSystem())); if (inc.hasValueSet()) { addValueSets(sheet, inc.getValueSet()); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetChecker.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetChecker.java index 7d0d01329..d51437863 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetChecker.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetChecker.java @@ -1,5 +1,7 @@ package org.hl7.fhir.r5.terminologies; +import java.util.List; + /* Copyright (c) 2011+, HL7, Inc. All rights reserved. @@ -36,6 +38,6 @@ import org.hl7.fhir.r5.utils.EOperationOutcome; public interface ValueSetChecker { - Boolean codeInValueSet(String system, String code) throws ETooCostly, EOperationOutcome, Exception; + Boolean codeInValueSet(String system, String code, List warnings) throws ETooCostly, EOperationOutcome, Exception; } \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java index 709886004..fb1c2a48a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java @@ -102,7 +102,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe if (valueset != null && options.getValueSetMode() != ValueSetMode.NO_MEMBERSHIP_CHECK) { Boolean result = false; for (Coding c : code.getCoding()) { - Boolean ok = codeInValueSet(c.getSystem(), c.getCode()); + Boolean ok = codeInValueSet(c.getSystem(), c.getCode(), warnings); if (ok == null && result == false) { result = null; } else if (ok) { @@ -151,7 +151,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe if (cs == null) { warningMessage = "Unable to resolve system "+system; if (!inExpansion) { - if (valueset.hasExpansion()) { + if (valueset != null && valueset.hasExpansion()) { return new ValidationResult(IssueSeverity.ERROR, context.formatMessage(I18nConstants.CODESYSTEM_CS_UNK_EXPANSION, valueset.getUrl(), code.getCode().toString(), code.getSystem())); } else { throw new FHIRException(warningMessage); @@ -187,10 +187,12 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe inInclude = checkInclude(code); } + List warnings = new ArrayList<>(); + // then, if we have a value set, we check it's in the value set if (valueset != null && options.getValueSetMode() != ValueSetMode.NO_MEMBERSHIP_CHECK) { if ((res==null || res.isOk())) { - Boolean ok = codeInValueSet(system, code.getCode()); + Boolean ok = codeInValueSet(system, code.getCode(), warnings); if (ok == null || !ok) { if (res == null) { res = new ValidationResult((IssueSeverity) null, null); @@ -549,13 +551,17 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } @Override - public Boolean codeInValueSet(String system, String code) throws FHIRException { + public Boolean codeInValueSet(String system, String code, List warnings) throws FHIRException { + if (valueset == null) { + return false; + } Boolean result = false; + if (valueset.hasExpansion()) { return checkExpansion(new Coding(system, code, null)); } else if (valueset.hasCompose()) { for (ConceptSetComponent vsi : valueset.getCompose().getInclude()) { - Boolean ok = inComponent(vsi, system, code, valueset.getCompose().getInclude().size() == 1); + Boolean ok = inComponent(vsi, system, code, valueset.getCompose().getInclude().size() == 1, warnings); if (ok == null && result == false) { result = null; } else if (ok) { @@ -564,10 +570,10 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } } for (ConceptSetComponent vsi : valueset.getCompose().getExclude()) { - Boolean nok = inComponent(vsi, system, code, valueset.getCompose().getInclude().size() == 1); + Boolean nok = inComponent(vsi, system, code, valueset.getCompose().getInclude().size() == 1, warnings); if (nok == null && result == false) { result = null; - } else if (nok) { + } else if (nok != null && nok) { result = false; } } @@ -576,7 +582,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe return result; } - private Boolean inComponent(ConceptSetComponent vsi, String system, String code, boolean only) throws FHIRException { + private Boolean inComponent(ConceptSetComponent vsi, String system, String code, boolean only, List warnings) throws FHIRException { for (UriType uri : vsi.getValueSet()) { if (inImport(uri.getValue(), system, code)) { return true; @@ -607,6 +613,9 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe vs.getCompose().addInclude(vsi); ValidationResult res = context.validateCode(options.noClient(), new Coding(system, code, null), vs); if (res.getErrorClass() == TerminologyServiceErrorClass.UNKNOWN || res.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED || res.getErrorClass() == TerminologyServiceErrorClass.VALUESET_UNSUPPORTED) { + if (warnings != null && res.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED) { + warnings.add(context.formatMessage(I18nConstants.TERMINOLOGY_TX_SYSTEM_NOTKNOWN, system)); + } return null; } if (res.getErrorClass() == TerminologyServiceErrorClass.NOSERVICE) { @@ -705,7 +714,13 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } private boolean inImport(String uri, String system, String code) throws FHIRException { - return getVs(uri).codeInValueSet(system, code); + ValueSetCheckerSimple vs = getVs(uri); + if (vs == null) { + return false; + } else { + Boolean ok = vs.codeInValueSet(system, code, null); + return ok != null && ok; + } } } \ No newline at end of file diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java index dbc9d6a23..f32a740f3 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java @@ -228,11 +228,14 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple public String getLatestVersion(String id) throws IOException { for (String nextPackageServer : getPackageServers()) { - CachingPackageClient pc = new CachingPackageClient(nextPackageServer); - try { - return pc.getLatestVersion(id); - } catch (IOException e) { - ourLog.info("Failed to determine latest version of package {} from server: {}", id, nextPackageServer); + // special case: + if (!("hl7.fhir.pubpack".equals(id) && PRIMARY_SERVER.equals(nextPackageServer))) { + CachingPackageClient pc = new CachingPackageClient(nextPackageServer); + try { + return pc.getLatestVersion(id); + } catch (IOException e) { + ourLog.info("Failed to determine latest version of package {} from server: {}", id, nextPackageServer); + } } } @@ -474,6 +477,13 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple id = id.substring(0, id.indexOf("#")); } + if (version == null) { + try { + version = getLatestVersion(id); + } catch (Exception e) { + version = null; + } + } NpmPackage p = loadPackageFromCacheOnly(id, version); if (p != null) { if ("current".equals(version)) { @@ -704,7 +714,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple String pv = Utilities.pathURL(url, v, "package.tgz"); try { aurl = pv; - InputStreamWithSrc src = new InputStreamWithSrc(fetchFromUrlSpecific(pv, true), pv, v); + InputStreamWithSrc src = new InputStreamWithSrc(fetchFromUrlSpecific(pv, false), pv, v); return src; } catch (Exception e1) { throw new FHIRException("Error fetching package directly (" + pv + "), or fetching package list for " + id + " from " + pu + ": " + e1.getMessage(), e1); diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 11b382064..19c6d4a89 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -603,7 +603,7 @@ BUNDLE_RULE_NONE = No Rule BUNDLE_RULE_UNKNOWN = Bundle Rule refers to invalid resource {0} BUNDLE_RULE_INVALID_INDEX = Bundle Rules index is invalid ({0}) BUNDLE_RULE_PROFILE_UNKNOWN = Bundle Rules profile {1} is unknown for {0} -UNABLE_TO_CHECK_IF_THE_PROVIDED_CODES_ARE_IN_THE_VALUE_SET_ = Unable to determine whether the provided codes are in the value set {0} because the value set or code system is not known to the validator +UNABLE_TO_CHECK_IF_THE_PROVIDED_CODES_ARE_IN_THE_VALUE_SET_ = Unable to determine whether the provided codes are in the value set {0} because the value set or a code system it depends on is not known to the validator TERMINOLOGY_TX_SYSTEM_WRONG_HTML = The code system reference {0} is wrong - the code system reference cannot be to an HTML page. This may be the correct reference: {1} TERMINOLOGY_TX_SYSTEM_WRONG_BUILD = The code system reference {0} is wrong - the code system reference cannot be a reference to build.fhir.org. This may be the correct reference: {1} FHIRPATH_BAD_DATE = Unable to parse Date {0} diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/PackageCacheTests.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/PackageCacheTests.java index a20d5f382..a75d1c75a 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/PackageCacheTests.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/tests/PackageCacheTests.java @@ -53,7 +53,14 @@ public class PackageCacheTests { FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); cache.clear(); Assertions.assertEquals(cache.loadPackage("KBV.Basis", "1.1.3").version(), "1.1.3"); - Assertions.assertEquals(cache.loadPackage("kbv.basis", "1.1.3").version(), "1.1.3"); - + Assertions.assertEquals(cache.loadPackage("kbv.basis", "1.1.3").version(), "1.1.3"); + } + + @Test + public void testLastReleasedVersion() throws IOException { + FilesystemPackageCacheManager cache = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); + cache.clear(); + Assertions.assertEquals("0.0.8", cache.loadPackage("hl7.fhir.pubpack", "0.0.8").version()); + Assertions.assertEquals("0.0.9", cache.loadPackage("hl7.fhir.pubpack").version()); } } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java index 5a081dde6..773f93485 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java @@ -90,7 +90,9 @@ public class ValueSetValidator extends BaseValidator { Resource rs = context.fetchResource(Resource.class, v); if (rs != null) { warning(errors, IssueType.BUSINESSRULE, ns.getLiteralPath(), false, I18nConstants.VALUESET_REFERENCE_INVALID_TYPE, v, rs.fhirType()); - } else { + } else { + // todo: it's possible, at this point, that the txx server knows the value set, but it's not in scope + // should we handle this case? warning(errors, IssueType.BUSINESSRULE, ns.getLiteralPath(), false, I18nConstants.VALUESET_REFERENCE_UNKNOWN, v); } } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java index 5e6051690..30ee70d92 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java @@ -213,12 +213,12 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe } if (content.has("profiles")) { for (JsonElement je : content.getAsJsonArray("profiles")) { - String filename = je.getAsString(); + String filename = je.getAsString(); String contents = TestingUtilities.loadTestResource("validator", filename); StructureDefinition sd = loadProfile(filename, contents, messages); val.getContext().cacheResource(sd); } - } + } List errors = new ArrayList(); if (content.getAsJsonObject("java").has("debug")) { val.setDebug(content.getAsJsonObject("java").get("debug").getAsBoolean()); @@ -249,6 +249,11 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe if (content.has("profile")) { System.out.print("** Profile: "); JsonObject profile = content.getAsJsonObject("profile"); + if (profile.has("packages")) { + for (JsonElement e : profile.getAsJsonArray("packages")) { + igLoader.loadIg(vCurr.getIgs(), vCurr.getBinaries(), e.getAsString(), true); + } + } if (profile.getAsJsonObject("java").has("debug")) { val.setDebug(profile.getAsJsonObject("java").get("debug").getAsBoolean()); } @@ -263,12 +268,17 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe } } } + StructureDefinition sd = null; String filename = profile.get("source").getAsString(); - String contents = TestingUtilities.loadTestResource("validator", filename); - System.out.println("Name: " + name + " - profile : " + profile.get("source").getAsString()); - version = content.has("version") ? content.get("version").getAsString() : Constants.VERSION; - StructureDefinition sd = loadProfile(filename, contents, messages); - val.getContext().cacheResource(sd); + if (Utilities.isAbsoluteUrl(filename)) { + sd = val.getContext().fetchResource(StructureDefinition.class, filename); + } else { + String contents = TestingUtilities.loadTestResource("validator", filename); + System.out.println("Name: " + name + " - profile : " + profile.get("source").getAsString()); + version = content.has("version") ? content.get("version").getAsString() : Constants.VERSION; + sd = loadProfile(filename, contents, messages); + val.getContext().cacheResource(sd); + } val.setAssumeValidRestReferences(profile.has("assumeValidRestReferences") ? profile.get("assumeValidRestReferences").getAsBoolean() : false); List errorsProfile = new ArrayList(); if (JSONUtil.str(content, "file").endsWith(".json")) diff --git a/pom.xml b/pom.xml index ae76821e5..80bc326f2 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.1.0 - 1.1.67 + 1.1.68-SNAPSHOT 5.7.1 1.7.1 3.0.0-M4