diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/R5ExtensionsLoader.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/R5ExtensionsLoader.java index 8ad0e5d10..76de4113f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/R5ExtensionsLoader.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/R5ExtensionsLoader.java @@ -20,6 +20,7 @@ import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent; import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; +import org.hl7.fhir.r5.utils.ResourceSorters; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.npm.BasePackageCacheManager; @@ -59,12 +60,15 @@ public class R5ExtensionsLoader { r.setUserData("path", Utilities.pathURL(pck.getWebLocation(), r.fhirType().toLowerCase()+ "-"+r.getId().toLowerCase()+".html")); if (r instanceof CodeSystem) { codeSystems.put(r.getUrl(), (CodeSystem) r); + codeSystems.put(r.getUrl()+"|"+r.getVersion(), (CodeSystem) r); } else if (r instanceof ValueSet) { valueSets.put(r.getUrl(), (ValueSet) r); + valueSets.put(r.getUrl()+"|"+r.getVersion(), (ValueSet) r); } else if (r instanceof StructureDefinition) { structures.add((StructureDefinition) r); } } + structures.sort(new ResourceSorters.CanonicalResourceSortByUrl()); } public void loadR5Extensions() throws FHIRException, IOException { @@ -76,8 +80,8 @@ public class R5ExtensionsLoader { if (survivesStrippingTypes(sd, context, typeNames)) { count++; sd.setUserData("path", Utilities.pathURL(pck.getWebLocation(), "extension-"+sd.getId().toLowerCase()+".html")); - context.cacheResourceFromPackage(sd, pd); registerTerminologies(sd); + context.cacheResourceFromPackage(sd, pd); } } } @@ -85,12 +89,12 @@ public class R5ExtensionsLoader { } public void loadR5SpecialTypes(List types) throws FHIRException, IOException { - for (StructureDefinition sd : structures) { + for (StructureDefinition sd : structures) { if (Utilities.existsInList(sd.getType(), types)) { count++; sd.setUserData("path", Utilities.pathURL(pck.getWebLocation(), sd.getId().toLowerCase()+".html")); - context.cacheResourceFromPackage(sd, pd); registerTerminologies(sd); + context.cacheResourceFromPackage(sd, pd); } } } @@ -98,13 +102,15 @@ public class R5ExtensionsLoader { private void registerTerminologies(StructureDefinition sd) { for (ElementDefinition ed : sd.getSnapshot().getElement()) { if (ed.hasBinding() && ed.getBinding().hasValueSet()) { - String vs = ed.getBinding().getValueSet(); - if (!context.hasResource(ValueSet.class, vs)) { - loadValueSet(vs, context, valueSets, codeSystems, pd); + String vsu = ed.getBinding().getValueSet(); + ValueSet vs = context.fetchResource(ValueSet.class, vsu); + if (vs == null) { + loadValueSet(vsu, context, valueSets, codeSystems, pd); + } else if (vs.hasVersion()) { + ed.getBinding().setValueSet(vs.getUrl()+"|"+vs.getVersion()); } } } - } private void loadValueSet(String url, IWorkerContext context, Map valueSets, Map codeSystems, PackageVersion pd) { @@ -115,8 +121,12 @@ public class R5ExtensionsLoader { for (CanonicalType t : inc.getValueSet()) { loadValueSet(t.asStringValue(), context, valueSets, codeSystems, pd); } - if (inc.hasSystem()) { - if (!context.hasResource(CodeSystem.class, inc.getSystem()) && codeSystems.containsKey(inc.getSystem())) { + if (inc.hasSystem() && !inc.hasVersion()) { + if (codeSystems.containsKey(inc.getSystem())) { + CodeSystem cs = codeSystems.get(inc.getSystem()); + inc.setVersion(cs.getVersion()); + context.cacheResourceFromPackage(cs, pd); + } else if (!context.hasResource(CodeSystem.class, inc.getSystem()) && codeSystems.containsKey(inc.getSystem())) { context.cacheResourceFromPackage(codeSystems.get(inc.getSystem()), pd); } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/ContextUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/ContextUtilities.java index 35b01f060..428f0cfb3 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/ContextUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/ContextUtilities.java @@ -282,9 +282,9 @@ public class ContextUtilities implements ProfileKnowledgeProvider { } @Override - public boolean isDatatype(String typeSimple) { - // TODO Auto-generated method stub - return false; + public boolean isDatatype(String type) { + StructureDefinition sd = context.fetchTypeDefinition(type); + return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE; } @Override @@ -331,5 +331,10 @@ public class ContextUtilities implements ProfileKnowledgeProvider { return false; } + public boolean isPrimitiveDatatype(String type) { + StructureDefinition sd = context.fetchTypeDefinition(type); + return sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE; + } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java index 0bfcf8f90..81614275a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java @@ -40,6 +40,7 @@ import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; import org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.model.StructureDefinition; @@ -83,8 +84,15 @@ public class Manager { } return null; } - - + public static FhirFormat readFromMimeType(String mt) { + if (mt.contains("/xml") || mt.contains("+xml")) { + return FhirFormat.XML; + } + if (mt.contains("/json") || mt.contains("+json")) { + return FhirFormat.JSON; + } + return null; + } } public static List parse(IWorkerContext context, InputStream source, FhirFormat inputFormat) throws FHIRFormatError, DefinitionException, IOException, FHIRException { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Property.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Property.java index 7078203a5..55454c57a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Property.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Property.java @@ -34,6 +34,7 @@ package org.hl7.fhir.r5.model; import java.util.ArrayList; import java.util.List; +import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.utilities.MergedList.IMatcher; /** @@ -187,5 +188,5 @@ public class Property { public String toString() { return name; } - + } \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java index 88e3819ee..d89e34c01 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DirectWrappers.java @@ -224,7 +224,7 @@ public class DirectWrappers { return s; } else { // it might be a human name? - throw new Error("What to do?"); + throw new Error("What to do? Type is "+b.fhirType()); } } return null; 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 85df79322..6cc314bad 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 @@ -53,6 +53,6 @@ public interface ValueSetChecker { return warnings; } } - Boolean codeInValueSet(String system, String code, ValidationProcessInfo info) throws ETooCostly, EOperationOutcome, Exception; + Boolean codeInValueSet(String system, String version, String code, ValidationProcessInfo info) 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 2f62fdb26..5149e2a48 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 @@ -68,6 +68,7 @@ import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier; import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier.ValidationContextResourceProxy; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.npm.PackageInfo; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; @@ -136,7 +137,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe if (!c.hasSystem()) { info.getWarnings().add(context.formatMessage(I18nConstants.CODING_HAS_NO_SYSTEM__CANNOT_VALIDATE)); } - CodeSystem cs = resolveCodeSystem(c.getSystem()); + CodeSystem cs = resolveCodeSystem(c.getSystem(), c.getVersion()); ValidationResult res = null; if (cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) { res = context.validateCode(options.noClient(), c, null); @@ -154,7 +155,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(), info); + Boolean ok = codeInValueSet(c.getSystem(), c.getVersion(), c.getCode(), info); if (ok == null && result == false) { result = null; } else if (ok) { @@ -179,19 +180,23 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } } - public CodeSystem resolveCodeSystem(String system) { + public CodeSystem resolveCodeSystem(String system, String version) { for (CodeSystem t : localSystems) { - if (t.getUrl().equals(system)) { + if (t.getUrl().equals(system) && versionsMatch(version, t.getVersion())) { return t; } } - CodeSystem cs = context.fetchCodeSystem(system); + CodeSystem cs = context.fetchCodeSystem(system, version); if (cs == null) { - cs = findSpecialCodeSystem(system); + cs = findSpecialCodeSystem(system, version); } return cs; } + private boolean versionsMatch(String versionTest, String versionActual) { + return versionTest == null && VersionUtilities.versionsMatch(versionTest, versionActual); + } + public ValidationResult validateCode(Coding code) throws FHIRException { String warningMessage = null; // first, we validate the concept itself @@ -212,7 +217,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } inExpansion = checkExpansion(code); inInclude = checkInclude(code); - CodeSystem cs = resolveCodeSystem(system); + CodeSystem cs = resolveCodeSystem(system, code.getVersion()); if (cs == null) { warningMessage = "Unable to resolve system "+system; if (!inExpansion) { @@ -257,7 +262,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe // 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(), info); + Boolean ok = codeInValueSet(system, code.getVersion(), code.getCode(), info); if (ok == null || !ok) { if (res == null) { res = new ValidationResult((IssueSeverity) null, null); @@ -311,7 +316,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe return false; } - private CodeSystem findSpecialCodeSystem(String system) { + private CodeSystem findSpecialCodeSystem(String system, String version) { if ("urn:ietf:rfc:3986".equals(system)) { CodeSystem cs = new CodeSystem(); cs.setUrl(system); @@ -588,7 +593,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe if (vsi.hasFilter()) { return false; } - CodeSystem cs = resolveCodeSystem(vsi.getSystem()); + CodeSystem cs = resolveCodeSystem(vsi.getSystem(), vsi.getVersion()); if (cs != null && cs.getContent() == CodeSystemContentMode.COMPLETE) { if (vsi.hasConcept()) { @@ -646,7 +651,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } @Override - public Boolean codeInValueSet(String system, String code, ValidationProcessInfo info) throws FHIRException { + public Boolean codeInValueSet(String system, String version, String code, ValidationProcessInfo info) throws FHIRException { if (valueset == null) { return false; } @@ -657,7 +662,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } else if (valueset.hasCompose()) { int i = 0; for (ConceptSetComponent vsi : valueset.getCompose().getInclude()) { - Boolean ok = inComponent(vsi, i, system, code, valueset.getCompose().getInclude().size() == 1, info); + Boolean ok = inComponent(vsi, i, system, version, code, valueset.getCompose().getInclude().size() == 1, info); i++; if (ok == null && result == false) { result = null; @@ -668,7 +673,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } i = valueset.getCompose().getInclude().size(); for (ConceptSetComponent vsi : valueset.getCompose().getExclude()) { - Boolean nok = inComponent(vsi, i, system, code, valueset.getCompose().getInclude().size() == 1, info); + Boolean nok = inComponent(vsi, i, system, version, code, valueset.getCompose().getInclude().size() == 1, info); i++; if (nok == null && result == false) { result = null; @@ -681,22 +686,22 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe return result; } - private Boolean inComponent(ConceptSetComponent vsi, int vsiIndex, String system, String code, boolean only, ValidationProcessInfo info) throws FHIRException { + private Boolean inComponent(ConceptSetComponent vsi, int vsiIndex, String system, String version, String code, boolean only, ValidationProcessInfo info) throws FHIRException { boolean ok = true; if (vsi.hasValueSet()) { if (isValueSetUnionImports()) { ok = false; for (UriType uri : vsi.getValueSet()) { - if (inImport(uri.getValue(), system, code)) { + if (inImport(uri.getValue(), system, version, code)) { return true; } } } else { - ok = inImport(vsi.getValueSet().get(0).getValue(), system, code); + ok = inImport(vsi.getValueSet().get(0).getValue(), system, version, code); for (int i = 1; i < vsi.getValueSet().size(); i++) { UriType uri = vsi.getValueSet().get(i); - ok = ok && inImport(uri.getValue(), system, code); + ok = ok && inImport(uri.getValue(), system, version, code); } } } @@ -717,7 +722,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe if (!system.equals(vsi.getSystem())) return false; // ok, we need the code system - CodeSystem cs = resolveCodeSystem(system); + CodeSystem cs = resolveCodeSystem(system, version); if (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT)) { // make up a transient value set with ValueSet vs = new ValueSet(); @@ -836,12 +841,12 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe return vsc; } - private boolean inImport(String uri, String system, String code) throws FHIRException { + private boolean inImport(String uri, String system, String version, String code) throws FHIRException { ValueSetCheckerSimple vs = getVs(uri); if (vs == null) { return false; } else { - Boolean ok = vs.codeInValueSet(system, code, null); + Boolean ok = vs.codeInValueSet(system, version, code, null); return ok != null && ok; } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ResourceLanguageFileBuilder.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ResourceLanguageFileBuilder.java new file mode 100644 index 000000000..9ac593816 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ResourceLanguageFileBuilder.java @@ -0,0 +1,103 @@ +package org.hl7.fhir.r5.utils; + +import java.io.IOException; + +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.context.ContextUtilities; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.elementmodel.Element; +import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.model.ElementDefinition; +import org.hl7.fhir.r5.model.Extension; +import org.hl7.fhir.r5.model.Property; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.StructureDefinition; +import org.hl7.fhir.utilities.i18n.LanguageFileProducer; + +public class ResourceLanguageFileBuilder { + + + private LanguageFileProducer file; + private String source; + private String target; + private IWorkerContext context; + StructureDefinition sd = null; + + public void prepare(LanguageFileProducer file, IWorkerContext context, String source, String target) { + this.file = file; + this.source = source; + this.target = target; + this.context = context; + } + + public void build(Resource res) throws IOException { + String id = res.fhirType(); + String path = res.fhirType() +"-"+res.getIdBase(); + + if (!source.equals(res.getLanguage())) { + throw new FHIRException("Language mismatch"); + } + sd = context.fetchTypeDefinition(res.fhirType()); + if (sd == null) { + throw new FHIRException("profile"); + } + file.start(path, path, res.getUserString("path"), source, target); + + for (Property p : res.children()) { + process(p, id, path); + } + + file.finish(); + } + + + private void process(Property p, String id, String path) throws IOException { + if (p.hasValues()) { + int i = 0; + for (Base b : p.getValues()) { + String pid = id+"."+p.getName(); + String ppath = path+"."+p.getName()+(p.isList() ? "["+i+"]" : ""); + i++; + if (isTranslatable(p, b, id)) { + file.makeEntry(ppath, null, null, b.primitiveValue(), getTranslation(b, target)); + } + for (Property pp : b.children()) { + process(pp, pid, ppath); + } + } + } + } + + private boolean isTranslatable(Property p, Base b, String id) { + if (new ContextUtilities(context).isPrimitiveDatatype(b.fhirType())) { // never any translations for non-primitives + ElementDefinition ed = null; + for (ElementDefinition t : sd.getSnapshot().getElement()) { + if (t.getId().equals(id)) { + ed = t; + } + } + if (ed != null && ed.hasExtension(ToolingExtensions.EXT_TRANSLATABLE)) { + return true; + } + } + return false; + } + + private String getTranslation(Base b, String target2) { + if (b instanceof org.hl7.fhir.r5.model.Element) { + org.hl7.fhir.r5.model.Element e = (org.hl7.fhir.r5.model.Element) b; + for (Extension ext : e.getExtensionsByUrl(ToolingExtensions.EXT_TRANSLATION)) { + String lang = ext.hasExtension("lang") ? ext.getExtensionString("lang") : null; + if (target.equals(lang)) { + return ext.getExtensionString("content"); + } + } + } + return null; + } + + public void build(Element res) { + + } + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index ba80290ef..fcbed22af 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -135,6 +135,7 @@ public class ToolingExtensions { public static final String EXT_IGP_CONTAINED_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/contained-resource-information"; public static final String EXT_BINARY_FORMAT_OLD = "http://hl7.org/fhir/StructureDefinition/implementationguide-resource-format"; public static final String EXT_BINARY_FORMAT_NEW = "http://hl7.org/fhir/tools/StructureDefinition/implementationguide-resource-format"; + public static final String EXT_BINARY_LOGICAL = "http://hl7.org/fhir/tools/StructureDefinition/implementationguide-resource-logical"; public static final String EXT_IGP_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/resource-information"; public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion"; public static final String EXT_LIST_PACKAGE = "http://hl7.org/fhir/StructureDefinition/list-packageId"; diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/LanguageFileProducer.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/LanguageFileProducer.java new file mode 100644 index 000000000..b86c34e26 --- /dev/null +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/LanguageFileProducer.java @@ -0,0 +1,22 @@ +package org.hl7.fhir.utilities.i18n; + +import java.io.IOException; + +public abstract class LanguageFileProducer { + + private String folder; + + public LanguageFileProducer(String folder) { + super(); + this.folder = folder; + } + + public String getFolder() { + return folder; + } + + public abstract void start(String fileName, String contextId, String contextDesc, String baseLang, String targetLang) throws IOException; + public abstract void makeEntry(String id, String ref, String context, String source, String dest) throws IOException; + public abstract void finish() throws IOException; + +} diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/PoGetTextProducer.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/PoGetTextProducer.java new file mode 100644 index 000000000..9d00878c4 --- /dev/null +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/PoGetTextProducer.java @@ -0,0 +1,44 @@ +package org.hl7.fhir.utilities.i18n; + +import java.io.IOException; + +import org.hl7.fhir.utilities.TextFile; + +public class PoGetTextProducer extends LanguageFileProducer { + + + public PoGetTextProducer(String folder) { + super(folder); + } + + private String fileName; + private StringBuilder po; + int i = 0; + + @Override + public void start(String fileName, String contextId, String contextDesc, String baseLang, String targetLang) { + this.fileName = fileName; + po = new StringBuilder(); + } + + @Override + public void makeEntry(String id, String ref, String context, String source, String target) { + ln("#: "+id); + if (context != null) { + ln("#. "+context); + } + ln("msgid \""+source+"\""); + ln("msgstr \""+target+"\""); + ln(""); + } + + @Override + public void finish() throws IOException { + ln(""); + TextFile.stringToFile(po.toString(), fileName); + } + + protected void ln(String line) { + po.append(line+"\r\n"); + } +} diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/XLIFFProducer.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/XLIFFProducer.java new file mode 100644 index 000000000..72667092b --- /dev/null +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/XLIFFProducer.java @@ -0,0 +1,57 @@ +package org.hl7.fhir.utilities.i18n; + +import java.io.IOException; + +import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.Utilities; + +public class XLIFFProducer extends LanguageFileProducer { + + + public XLIFFProducer(String folder) { + super(folder); + } + + private String fileName; + private StringBuilder xml; + int i = 0; + + @Override + public void start(String fileName, String contextId, String contextDesc, String baseLang, String targetLang) { + this.fileName = fileName; + xml = new StringBuilder(); + ln(""); + ln(" "); + ln(" "); + ln(" "+Utilities.escapeXml(contextDesc)+""); + ln(" "); + } + + @Override + public void makeEntry(String id, String ref, String context, String source, String target) { + i++; + ln(" "); + if (context != null) { + ln(" "); + ln(" "+Utilities.escapeXml(context)+""); + ln(" "); + } + ln(" "); + ln(" "+Utilities.escapeXml(source)+""); + ln(" "+Utilities.escapeXml(target)+""); + ln(" "); + ln(" "); + } + + @Override + public void finish() throws IOException { + ln(" "); + ln(""); + TextFile.stringToFile(xml.toString(), Utilities.path(getFolder(), fileName+".xliff")); + } + + protected void ln(String line) { + xml.append(line+"\r\n"); + } +} 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 476e4698b..f2a6380d0 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 @@ -327,7 +327,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple if (f.equals(id + "#" + version) || (Utilities.noString(version) && f.startsWith(id + "#"))) { return loadPackageInfo(Utilities.path(cacheFolder, f)); } - if (version != null && (version.endsWith(".x") || Utilities.charCount(version, '.') < 2) && f.contains("#")) { + if (version != null && !version.equals("current") && (version.endsWith(".x") || Utilities.charCount(version, '.') < 2) && f.contains("#")) { String[] parts = f.split("#"); if (parts[0].equals(id) && VersionUtilities.isMajMinOrLaterPatch((foundVersion!=null ? foundVersion : version),parts[1])) { foundVersion = parts[1]; diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 0d13c04fe..114af80fb 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -10,6 +10,7 @@ Bundle_BUNDLE_Entry_NoFullUrl = Bundle entry missing fullUrl BUNDLE_BUNDLE_ENTRY_FULLURL_REQUIRED = Except for transactions and batches, each entry in a Bundle must have a fullUrl which is the identity of the resource in the entry Bundle_BUNDLE_Entry_NoProfile_TYPE = No profile found for {0} resource of type ''{1}'' Bundle_BUNDLE_Entry_NoProfile_EXPL = Specified profile {2} not found for {0} resource of type ''{0}'' +Bundle_BUNDLE_Entry_NO_LOGICAL_EXPL = Specified logical model {1} not found for resource ''Binary/{0}'' Bundle_BUNDLE_Entry_NotFound = Can''t find ''{0}'' in the bundle ({1}) Bundle_BUNDLE_Entry_Orphan = Entry {0} isn''t reachable by traversing from first Bundle entry BUNDLE_BUNDLE_ENTRY_REVERSE = Entry {0} isn''t reachable by traversing forwards from first Bundle entry, and isn''t a resource type that is typically used that way - check this is not missed somewhere diff --git a/org.hl7.fhir.validation/src/test/resources/txCache/org.hl7.fhir.validation/4.0.1/condition-clinical.cache b/org.hl7.fhir.validation/src/test/resources/txCache/org.hl7.fhir.validation/4.0.1/condition-clinical.cache new file mode 100644 index 000000000..2560c0bd1 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/txCache/org.hl7.fhir.validation/4.0.1/condition-clinical.cache @@ -0,0 +1,34 @@ +------------------------------------------------------------------------------------- +{"code" : { + "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical", + "code" : "active" +}, "url": "http://hl7.org/fhir/ValueSet/condition-clinical--0", "version": "4.0.1", "lang":"null", "useServer":"true", "useClient":"false", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}#### +v: { + "display" : "Active", + "code" : "active", + "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical" +} +------------------------------------------------------------------------------------- +{"code" : { + "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical", + "version" : "4.0.1", + "code" : "active", + "display" : "Active" +}, "url": "http://hl7.org/fhir/ValueSet/condition-clinical", "version": "4.0.1", "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"NO_MEMBERSHIP_CHECK", "versionFlexible":"false"}#### +v: { + "display" : "Active", + "code" : "active", + "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical" +} +------------------------------------------------------------------------------------- +{"code" : { + "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical", + "version" : "4.0.1", + "code" : "active" +}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}#### +v: { + "display" : "Active", + "code" : "active", + "system" : "http://terminology.hl7.org/CodeSystem/condition-clinical" +} +------------------------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index fcb882a61..32ee2750f 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - 1.1.116 + 1.1.117-SNAPSHOT 5.7.1 1.8.2 3.0.0-M5