Merge remote-tracking branch 'origin/master' into i18n

This commit is contained in:
patrick-werner 2020-03-09 14:12:04 +01:00
commit 41e9b0e9fa
3 changed files with 80 additions and 45 deletions

View File

@ -587,6 +587,13 @@ public class ProfileUtilities extends TranslatingUtilities {
else else
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR)); messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url, msg, ValidationMessage.IssueSeverity.ERROR));
} }
// hack around a problem in R4 definitions (somewhere?)
for (ElementDefinition ed : derived.getSnapshot().getElement()) {
for (ElementDefinitionMappingComponent mm : ed.getMapping()) {
mm.setMap(mm.getMap().trim());
}
}
if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) { if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
for (ElementDefinition ed : derived.getSnapshot().getElement()) { for (ElementDefinition ed : derived.getSnapshot().getElement()) {
if (!ed.hasBase()) { if (!ed.hasBase()) {
@ -2492,16 +2499,19 @@ public class ProfileUtilities extends TranslatingUtilities {
for (ElementDefinitionMappingComponent d : base.getMapping()) { for (ElementDefinitionMappingComponent d : base.getMapping()) {
found = found || (d.getIdentity().equals(s.getIdentity()) && d.getMap().equals(s.getMap())); found = found || (d.getIdentity().equals(s.getIdentity()) && d.getMap().equals(s.getMap()));
} }
if (!found) if (!found) {
base.getMapping().add(s); base.getMapping().add(s);
} }
} }
else if (trimDifferential) }
else if (trimDifferential) {
derived.getMapping().clear(); derived.getMapping().clear();
else } else {
for (ElementDefinitionMappingComponent t : derived.getMapping()) for (ElementDefinitionMappingComponent t : derived.getMapping()) {
t.setUserData(DERIVATION_EQUALS, true); t.setUserData(DERIVATION_EQUALS, true);
} }
}
}
for (ElementDefinitionMappingComponent m : base.getMapping()) { for (ElementDefinitionMappingComponent m : base.getMapping()) {
if (m.hasMap()) { if (m.hasMap()) {
m.setMap(m.getMap().trim()); m.setMap(m.getMap().trim());
@ -2511,9 +2521,10 @@ public class ProfileUtilities extends TranslatingUtilities {
// todo: constraints are cumulative. there is no replacing // todo: constraints are cumulative. there is no replacing
for (ElementDefinitionConstraintComponent s : base.getConstraint()) { for (ElementDefinitionConstraintComponent s : base.getConstraint()) {
s.setUserData(IS_DERIVED, true); s.setUserData(IS_DERIVED, true);
if (!s.hasSource()) if (!s.hasSource()) {
s.setSource(srcSD.getUrl()); s.setSource(srcSD.getUrl());
} }
}
if (derived.hasConstraint()) { if (derived.hasConstraint()) {
for (ElementDefinitionConstraintComponent s : derived.getConstraint()) { for (ElementDefinitionConstraintComponent s : derived.getConstraint()) {
if (!base.hasConstraint(s.getKey())) { if (!base.hasConstraint(s.getKey())) {
@ -2523,19 +2534,22 @@ public class ProfileUtilities extends TranslatingUtilities {
} }
} }
for (IdType id : derived.getCondition()) { for (IdType id : derived.getCondition()) {
if (!base.hasCondition(id)) if (!base.hasCondition(id)) {
base.getCondition().add(id); base.getCondition().add(id);
} }
}
// now, check that we still have a bindable type; if not, delete the binding - see task 8477 // now, check that we still have a bindable type; if not, delete the binding - see task 8477
if (dest.hasBinding() && !hasBindableType(dest)) if (dest.hasBinding() && !hasBindableType(dest)) {
dest.setBinding(null); dest.setBinding(null);
}
// finally, we copy any extensions from source to dest // finally, we copy any extensions from source to dest
for (Extension ex : derived.getExtension()) { for (Extension ex : derived.getExtension()) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, ex.getUrl()); StructureDefinition sd = context.fetchResource(StructureDefinition.class, ex.getUrl());
if (sd == null || sd.getSnapshot() == null || sd.getSnapshot().getElementFirstRep().getMax().equals("1")) if (sd == null || sd.getSnapshot() == null || sd.getSnapshot().getElementFirstRep().getMax().equals("1")) {
ToolingExtensions.removeExtension(dest, ex.getUrl()); ToolingExtensions.removeExtension(dest, ex.getUrl());
}
dest.addExtension(ex.copy()); dest.addExtension(ex.copy());
} }
} }
@ -2624,18 +2638,21 @@ public class ProfileUtilities extends TranslatingUtilities {
private boolean hasBindableType(ElementDefinition ed) { private boolean hasBindableType(ElementDefinition ed) {
for (TypeRefComponent tr : ed.getType()) { for (TypeRefComponent tr : ed.getType()) {
if (Utilities.existsInList(tr.getWorkingCode(), "Coding", "CodeableConcept", "Quantity", "uri", "string", "code")) if (Utilities.existsInList(tr.getWorkingCode(), "Coding", "CodeableConcept", "Quantity", "uri", "string", "code")) {
return true; return true;
} }
}
return false; return false;
} }
private boolean isLargerMax(String derived, String base) { private boolean isLargerMax(String derived, String base) {
if ("*".equals(base)) if ("*".equals(base)) {
return false; return false;
if ("*".equals(derived)) }
if ("*".equals(derived)) {
return true; return true;
}
return Integer.parseInt(derived) > Integer.parseInt(base); return Integer.parseInt(derived) > Integer.parseInt(base);
} }
@ -2647,22 +2664,26 @@ public class ProfileUtilities extends TranslatingUtilities {
private boolean codesInExpansion(List<ValueSetExpansionContainsComponent> contains, ValueSetExpansionComponent expansion) { private boolean codesInExpansion(List<ValueSetExpansionContainsComponent> contains, ValueSetExpansionComponent expansion) {
for (ValueSetExpansionContainsComponent cc : contains) { for (ValueSetExpansionContainsComponent cc : contains) {
if (!inExpansion(cc, expansion.getContains())) if (!inExpansion(cc, expansion.getContains())) {
return false; return false;
if (!codesInExpansion(cc.getContains(), expansion)) }
if (!codesInExpansion(cc.getContains(), expansion)) {
return false; return false;
} }
}
return true; return true;
} }
private boolean inExpansion(ValueSetExpansionContainsComponent cc, List<ValueSetExpansionContainsComponent> contains) { private boolean inExpansion(ValueSetExpansionContainsComponent cc, List<ValueSetExpansionContainsComponent> contains) {
for (ValueSetExpansionContainsComponent cc1 : contains) { for (ValueSetExpansionContainsComponent cc1 : contains) {
if (cc.getSystem().equals(cc1.getSystem()) && cc.getCode().equals(cc1.getCode())) if (cc.getSystem().equals(cc1.getSystem()) && cc.getCode().equals(cc1.getCode())) {
return true; return true;
if (inExpansion(cc, cc1.getContains())) }
if (inExpansion(cc, cc1.getContains())) {
return true; return true;
} }
}
return false; return false;
} }
@ -2709,33 +2730,38 @@ public class ProfileUtilities extends TranslatingUtilities {
private int findEnd(List<ElementDefinition> list, ElementDefinition ed, int cursor) { private int findEnd(List<ElementDefinition> list, ElementDefinition ed, int cursor) {
String path = ed.getPath()+"."; String path = ed.getPath()+".";
while (cursor < list.size() && list.get(cursor).getPath().startsWith(path)) while (cursor < list.size() && list.get(cursor).getPath().startsWith(path)) {
cursor++; cursor++;
}
return cursor; return cursor;
} }
private ElementDefinition getMatchInDerived(ElementDefinition ed, List<ElementDefinition> list) { private ElementDefinition getMatchInDerived(ElementDefinition ed, List<ElementDefinition> list) {
for (ElementDefinition t : list) for (ElementDefinition t : list) {
if (t.getPath().equals(ed.getPath())) if (t.getPath().equals(ed.getPath())) {
return t; return t;
}
}
return null; return null;
} }
private ElementDefinition getMatchInDerived(ElementDefinition ed, List<ElementDefinition> list, int start, int end) { private ElementDefinition getMatchInDerived(ElementDefinition ed, List<ElementDefinition> list, int start, int end) {
for (int i = start; i < end; i++) { for (int i = start; i < end; i++) {
ElementDefinition t = list.get(i); ElementDefinition t = list.get(i);
if (t.getPath().equals(ed.getPath())) if (t.getPath().equals(ed.getPath())) {
return t; return t;
} }
}
return null; return null;
} }
private boolean isImmediateChild(ElementDefinition ed) { private boolean isImmediateChild(ElementDefinition ed) {
String p = ed.getPath(); String p = ed.getPath();
if (!p.contains(".")) if (!p.contains(".")) {
return false; return false;
}
p = p.substring(p.indexOf(".")+1); p = p.substring(p.indexOf(".")+1);
return !p.contains("."); return !p.contains(".");
} }
@ -3305,8 +3331,10 @@ public class ProfileUtilities extends TranslatingUtilities {
s = "@"+s; s = "@"+s;
String hint = ""; String hint = "";
hint = checkAdd(hint, (element.hasSliceName() ? translate("sd.table", "Slice")+" "+element.getSliceName() : "")); hint = checkAdd(hint, (element.hasSliceName() ? translate("sd.table", "Slice")+" "+element.getSliceName() : ""));
if (hasDef && element.hasDefinition()) {
hint = checkAdd(hint, (hasDef && element.hasSliceName() ? ": " : "")); hint = checkAdd(hint, (hasDef && element.hasSliceName() ? ": " : ""));
hint = checkAdd(hint, !hasDef ? null : gt(element.getDefinitionElement())); hint = checkAdd(hint, !hasDef ? null : gt(element.getDefinitionElement()));
}
Cell left = gen.new Cell(null, ref, s, hint, null); Cell left = gen.new Cell(null, ref, s, hint, null);
row.getCells().add(left); row.getCells().add(left);
Cell gc = gen.new Cell(); Cell gc = gen.new Cell();

View File

@ -3476,10 +3476,10 @@ public class NarrativeGenerator implements INarrativeGenerator {
return false; return false;
} }
private void generateCopyright(XhtmlNode x, ValueSet vs) { private void generateCopyright(XhtmlNode x, ValueSet vs) throws FHIRFormatError, DefinitionException, IOException {
XhtmlNode p = x.para(); XhtmlNode p = x.para();
p.b().tx("Copyright Statement:"); p.b().tx("Copyright Statement:");
smartAddText(p, " " + vs.getCopyright()); addMarkdown(x, vs.getCopyright());
} }
private XhtmlNode addTableHeaderRowStandard(XhtmlNode t, boolean hasHierarchy, boolean hasDisplay, boolean definitions, boolean comments, boolean version, boolean deprecated, String lang, List<PropertyComponent> properties) { private XhtmlNode addTableHeaderRowStandard(XhtmlNode t, boolean hasHierarchy, boolean hasDisplay, boolean definitions, boolean comments, boolean version, boolean deprecated, String lang, List<PropertyComponent> properties) {
@ -3887,10 +3887,13 @@ public class NarrativeGenerator implements INarrativeGenerator {
if (vs.hasCopyrightElement()) if (vs.hasCopyrightElement())
generateCopyright(x, vs); generateCopyright(x, vs);
} }
XhtmlNode p = x.para();
p.tx("This value set includes codes from the following code systems:");
XhtmlNode ul = x.ul(); XhtmlNode ul = x.ul();
if (vs.getCompose().getInclude().size() == 1 && vs.getCompose().getExclude().size() == 0) {
hasExtensions = genInclude(rcontext, ul, vs.getCompose().getInclude().get(0), "Include", langs, maps) || hasExtensions;
} else {
XhtmlNode p = x.para();
p.tx("This value set includes codes based on the following rules:");
XhtmlNode li; XhtmlNode li;
for (ConceptSetComponent inc : vs.getCompose().getInclude()) { for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
hasExtensions = genInclude(rcontext, ul, inc, "Include", langs, maps) || hasExtensions; hasExtensions = genInclude(rcontext, ul, inc, "Include", langs, maps) || hasExtensions;
@ -3898,6 +3901,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
for (ConceptSetComponent exc : vs.getCompose().getExclude()) { for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs, maps) || hasExtensions; hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs, maps) || hasExtensions;
} }
}
// now, build observed languages // now, build observed languages
@ -4000,6 +4004,10 @@ public class NarrativeGenerator implements INarrativeGenerator {
if (inc.getConcept().size() > 0) { if (inc.getConcept().size() > 0) {
li.addText(type+" these codes as defined in "); li.addText(type+" these codes as defined in ");
addCsRef(inc, li, e); addCsRef(inc, li, e);
if (inc.hasVersion()) {
li.addText(" version ");
li.code(inc.getVersion());
}
XhtmlNode t = li.table("none"); XhtmlNode t = li.table("none");
boolean hasComments = false; boolean hasComments = false;

View File

@ -106,19 +106,15 @@ POSSIBILITY OF SUCH DAMAGE.
* *
* 1/ Initialize * 1/ Initialize
* ValidationEngine validator = new ValidationEngine(src); * ValidationEngine validator = new ValidationEngine(src);
* - this must refer to the igpack.zip for the version of the spec against which you want to validate * - this must be the packageId of the relevant core specification
* it can be a url or a file reference. It can nominate the igpack.zip directly, * for the version you want to validate against (e.g. hl7.fhir.r4.core)
* or it can name the container alone (e.g. just the spec URL).
* The validation engine does not cache igpack.zip. the user must manage that if desired
* *
* validator.connectToTSServer(txServer); * validator.connectToTSServer(txServer);
* - this is optional; in the absence of a terminology service, snomed, loinc etc will not be validated * - this is optional; in the absence of a terminology service, snomed, loinc etc will not be validated
* *
* validator.loadIg(src); * validator.loadIg(src);
* - call this any number of times for the Implementation Guide(s) of interest. This is a reference * - call this any number of times for the Implementation Guide(s) of interest.
* to the igpack.zip for the implementation guide - same rules as above * - See https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator for documentation about the src parameter (-ig parameter)
* the version of the IGPack must match that of the spec
* Alternatively it can point to a local folder that contains conformance resources.
* *
* validator.loadQuestionnaire(src) * validator.loadQuestionnaire(src)
* - url or filename of a questionnaire to load. Any loaded questionnaires will be used while validating * - url or filename of a questionnaire to load. Any loaded questionnaires will be used while validating
@ -136,7 +132,8 @@ POSSIBILITY OF SUCH DAMAGE.
* if the source is provided as byte[] or stream, you need to provide a format too, though you can * if the source is provided as byte[] or stream, you need to provide a format too, though you can
* leave that as null, and the validator will guess * leave that as null, and the validator will guess
* *
* 3. Or, instead of validating, transform * 3. Or, instead of validating, transform (see documentation and use in Validator.java)
*
* @author Grahame Grieve * @author Grahame Grieve
* *
*/ */
@ -549,8 +546,10 @@ public class ValidationEngine implements IValidatorResourceFetcher {
} }
private boolean isIgnoreFile(File ff) { private boolean isIgnoreFile(File ff) {
return Utilities.existsInList(ff.getName(), ".DS_Store") || Utilities.existsInList(Utilities.getFileExtension(ff.getName()).toLowerCase(), "md", "css", "js", "png", "gif", "jpg", "html", "tgz", "pack", "zip"); if (ff.getName().startsWith(".")|| ff.getAbsolutePath().contains(".git")){
return true;
}
return Utilities.existsInList(Utilities.getFileExtension(ff.getName()).toLowerCase(), "md", "css", "js", "png", "gif", "jpg", "html", "tgz", "pack", "zip");
} }
private Map<String, byte[]> loadPackage(InputStream stream, String name) throws Exception { private Map<String, byte[]> loadPackage(InputStream stream, String name) throws Exception {