Merge pull request #872 from hapifhir/gg-202207-bug-fixes
Gg 202207 bug fixes
This commit is contained in:
commit
78c372961e
|
@ -4229,14 +4229,16 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
Row currRow = row;
|
||||
List<ElementChoiceGroup> groups = readChoices(element, children);
|
||||
boolean isExtension = Utilities.existsInList(tail(element.getPath()), "extension", "modifierExtension");
|
||||
for (ElementDefinition child : children) {
|
||||
if (!child.hasSliceName()) {
|
||||
currRow = row;
|
||||
}
|
||||
Row childRow = chooseChildRowByGroup(gen, currRow, groups, child, element, isConstraintMode);
|
||||
|
||||
if (logicalModel || !child.getPath().endsWith(".id") || (child.getPath().endsWith(".id") && (profile != null) && (profile.getDerivation() == TypeDerivationRule.CONSTRAINT))) {
|
||||
currRow = genElement(defPath, gen, childRow.getSubRows(), child, all, profiles, showMissing, profileBaseFileName, isExtension, snapshot, corePath, imagePath, false, logicalModel, isConstraintMode, allInvariants, currRow, mustSupport, rc);
|
||||
if (!element.prohibited()) {
|
||||
for (ElementDefinition child : children) {
|
||||
if (!child.hasSliceName()) {
|
||||
currRow = row;
|
||||
}
|
||||
Row childRow = chooseChildRowByGroup(gen, currRow, groups, child, element, isConstraintMode);
|
||||
|
||||
if (logicalModel || !child.getPath().endsWith(".id") || (child.getPath().endsWith(".id") && (profile != null) && (profile.getDerivation() == TypeDerivationRule.CONSTRAINT))) {
|
||||
currRow = genElement(defPath, gen, childRow.getSubRows(), child, all, profiles, showMissing, profileBaseFileName, isExtension, snapshot, corePath, imagePath, false, logicalModel, isConstraintMode, allInvariants, currRow, mustSupport, rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!snapshot && (extensions == null || !extensions))
|
||||
|
@ -4349,7 +4351,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
res.add(addCell(row, gen.new Cell(null, null, "?gen-e1? "+element.getType().get(0).getProfile(), null, null)));
|
||||
res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, profile == null ? "" : profile.getUrl(), eurl, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows, rc));
|
||||
} else {
|
||||
String name = urltail(eurl);
|
||||
String name = element.hasSliceName() ? element.getSliceName() : urltail(eurl);
|
||||
nameCell.getPieces().get(0).setText(name);
|
||||
// left.getPieces().get(0).setReference((String) extDefn.getExtensionStructure().getTag("filename"));
|
||||
nameCell.getPieces().get(0).setHint(translate("sd.table", "Extension URL")+" = "+extDefn.getUrl());
|
||||
|
|
|
@ -45,6 +45,7 @@ public class R5ExtensionsLoader {
|
|||
JsonParser json = new JsonParser();
|
||||
for (PackageResourceInformation pri : pck.listIndexedResources(types)) {
|
||||
CanonicalResource r = (CanonicalResource) json.parse(pck.load(pri));
|
||||
r.setUserData("path", Utilities.pathURL(pck.getWebLocation(), r.fhirType().toLowerCase()+ "-"+r.getId().toLowerCase()+".html"));
|
||||
if (r instanceof CodeSystem) {
|
||||
codeSystems.put(r.getUrl(), (CodeSystem) r);
|
||||
} else if (r instanceof ValueSet) {
|
||||
|
@ -75,7 +76,7 @@ public class R5ExtensionsLoader {
|
|||
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
if (ed.hasBinding() && ed.getBinding().hasValueSet()) {
|
||||
String vs = ed.getBinding().getValueSet();
|
||||
if (!context.hasResource(StructureDefinition.class, vs)) {
|
||||
if (!context.hasResource(ValueSet.class, vs)) {
|
||||
loadValueSet(vs, context, valueSets, codeSystems, pd);
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ public class R5ExtensionsLoader {
|
|||
|
||||
private void loadValueSet(String url, IWorkerContext context, Map<String, ValueSet> valueSets, Map<String, CodeSystem> codeSystems, PackageVersion pd) {
|
||||
if (valueSets.containsKey(url)) {
|
||||
ValueSet vs = valueSets.get(url);
|
||||
ValueSet vs = valueSets.get(url);
|
||||
context.cacheResourceFromPackage(vs, pd);
|
||||
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
|
||||
for (CanonicalType t : inc.getValueSet()) {
|
||||
|
|
|
@ -55,8 +55,8 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
|||
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||
import org.hl7.fhir.utilities.ElementDecoration;
|
||||
import org.hl7.fhir.utilities.ElementDecoration.DecorationType;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
|
||||
/**
|
||||
|
@ -360,9 +360,12 @@ public class Element extends Base {
|
|||
if (childMap == null) {
|
||||
childMap = new HashMap<>();
|
||||
for (Element child : children) {
|
||||
String n = child.getName();
|
||||
if (n.endsWith("[x]")) {
|
||||
String n;
|
||||
if (child.getProperty().getName().endsWith("[x]")) {
|
||||
n = child.getProperty().getName();
|
||||
n = n.substring(0, n.length()-3);
|
||||
} else {
|
||||
n = child.getName();
|
||||
}
|
||||
List<Element> l = childMap.get(n);
|
||||
if (l == null) {
|
||||
|
|
|
@ -54,8 +54,8 @@ import org.hl7.fhir.r5.formats.JsonCreator;
|
|||
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.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
|
@ -477,16 +477,19 @@ public class JsonParser extends ParserBase {
|
|||
}
|
||||
|
||||
private void compose(String path, Element e, Set<String> done, Element child) throws IOException {
|
||||
boolean isList = child.hasElementProperty() ? child.getElementProperty().isList() : child.getProperty().isList();
|
||||
if (!isList) {// for specials, ignore the cardinality of the stated type
|
||||
compose(path, child);
|
||||
} else if (!done.contains(child.getName())) {
|
||||
done.add(child.getName());
|
||||
List<Element> list = e.getChildrenByName(child.getName());
|
||||
composeList(path, list);
|
||||
if (wantCompose(path, child)) {
|
||||
boolean isList = child.hasElementProperty() ? child.getElementProperty().isList() : child.getProperty().isList();
|
||||
if (!isList) {// for specials, ignore the cardinality of the stated type
|
||||
compose(path, child);
|
||||
} else if (!done.contains(child.getName())) {
|
||||
done.add(child.getName());
|
||||
List<Element> list = e.getChildrenByName(child.getName());
|
||||
composeList(path, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void composeList(String path, List<Element> list) throws IOException {
|
||||
// there will be at least one element
|
||||
String name = list.get(0).getName();
|
||||
|
|
|
@ -40,7 +40,6 @@ 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.ParserBase.NamedElement;
|
||||
import org.hl7.fhir.r5.formats.FormatUtilities;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
|
@ -55,6 +54,18 @@ import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
|
|||
|
||||
public abstract class ParserBase {
|
||||
|
||||
public enum IdRenderingPolicy {
|
||||
All, None, RootOnly, NotRoot;
|
||||
|
||||
boolean forRoot() {
|
||||
return this == All || this == RootOnly;
|
||||
}
|
||||
|
||||
boolean forInner() {
|
||||
return this == All || this == NotRoot;
|
||||
}
|
||||
}
|
||||
|
||||
public class NamedElement {
|
||||
private String name;
|
||||
private Element element;
|
||||
|
@ -92,6 +103,7 @@ public abstract class ParserBase {
|
|||
protected List<ValidationMessage> errors;
|
||||
protected ILinkResolver linkResolver;
|
||||
protected boolean showDecorations;
|
||||
protected IdRenderingPolicy idPolicy = IdRenderingPolicy.All;
|
||||
|
||||
public ParserBase(IWorkerContext context) {
|
||||
super();
|
||||
|
@ -194,4 +206,23 @@ public abstract class ParserBase {
|
|||
}
|
||||
|
||||
|
||||
public IdRenderingPolicy getIdPolicy() {
|
||||
return idPolicy;
|
||||
}
|
||||
|
||||
public void setIdPolicy(IdRenderingPolicy idPolicy) {
|
||||
this.idPolicy = idPolicy;
|
||||
}
|
||||
|
||||
protected boolean wantCompose(String path, Element e) {
|
||||
if (!"id".equals(e.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (path.contains(".")) {
|
||||
return idPolicy.forInner();
|
||||
} else {
|
||||
return idPolicy.forRoot();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,6 @@ import java.util.Map.Entry;
|
|||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
|
@ -22,15 +21,14 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
|||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.json.JsonUtilities;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser.LocationData;
|
||||
import org.hl7.fhir.utilities.json.JsonUtilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
|
|
|
@ -34,13 +34,11 @@ package org.hl7.fhir.r5.elementmodel;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
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.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
|
|
@ -43,7 +43,6 @@ 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.Element.SpecialElement;
|
||||
import org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
|
@ -395,6 +394,10 @@ public class TurtleParser extends ParserBase {
|
|||
// (element.getProperty().getDefinition().getIsModifier()? "modifierExtension" : "extension") ;
|
||||
String en = getFormalName(element);
|
||||
|
||||
if (!wantCompose(parent == null ? "" : parent.getPath(), element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Complex t;
|
||||
if (element.getSpecial() == SpecialElement.BUNDLE_ENTRY && parent != null && parent.getNamedChildValue("fullUrl") != null) {
|
||||
String url = "<"+parent.getNamedChildValue("fullUrl")+">";
|
||||
|
|
|
@ -43,7 +43,6 @@ 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.ParserBase.NamedElement;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
|
|||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element.SpecialElement;
|
||||
import org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement;
|
||||
import org.hl7.fhir.r5.formats.FormatUtilities;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.DateTimeType;
|
||||
|
@ -702,7 +701,7 @@ public class XmlParser extends ParserBase {
|
|||
} else {
|
||||
setXsiTypeIfIsTypeAttr(xml, element);
|
||||
for (Element child : element.getChildren()) {
|
||||
if (isAttr(child.getProperty())) {
|
||||
if (isAttr(child.getProperty()) && wantCompose(element.getPath(), child)) {
|
||||
if (linkResolver != null)
|
||||
xml.link(linkResolver.resolveType(child.getType()));
|
||||
String av = child.getValue();
|
||||
|
@ -720,12 +719,14 @@ public class XmlParser extends ParserBase {
|
|||
xml.enter(element.getProperty().getXmlNamespace(),element.getType());
|
||||
}
|
||||
for (Element child : element.getChildren()) {
|
||||
if (isText(child.getProperty())) {
|
||||
if (linkResolver != null)
|
||||
xml.link(linkResolver.resolveProperty(element.getProperty()));
|
||||
xml.text(child.getValue());
|
||||
} else if (!isAttr(child.getProperty()))
|
||||
composeElement(xml, child, child.getName(), false);
|
||||
if (wantCompose(element.getPath(), child)) {
|
||||
if (isText(child.getProperty())) {
|
||||
if (linkResolver != null)
|
||||
xml.link(linkResolver.resolveProperty(element.getProperty()));
|
||||
xml.text(child.getValue());
|
||||
} else if (!isAttr(child.getProperty()))
|
||||
composeElement(xml, child, child.getName(), false);
|
||||
}
|
||||
}
|
||||
if (!root && element.getSpecial() != null)
|
||||
xml.exit(element.getProperty().getXmlNamespace(),element.getType());
|
||||
|
|
|
@ -167,6 +167,9 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
}
|
||||
|
||||
private ResourceWrapper resolveReference(List<BaseWrapper> entries, Base base) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||
if (base == null) {
|
||||
return null;
|
||||
}
|
||||
Property prop = base.getChildByName("reference");
|
||||
if (prop.hasValues()) {
|
||||
String ref = prop.getValues().get(0).primitiveValue();
|
||||
|
@ -195,7 +198,7 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
Resource subject = resolveReference(b, comp.getSubject());
|
||||
if (subject != null) {
|
||||
XhtmlNode nx = (subject instanceof DomainResource) ? ((DomainResource) subject).getText().getDiv() : null;
|
||||
if (nx != null) {
|
||||
if (nx != null && !nx.isEmpty()) {
|
||||
x.addChildren(nx);
|
||||
} else {
|
||||
RendererFactory.factory(subject, context).render(x, subject);
|
||||
|
|
|
@ -159,9 +159,9 @@ public class ConceptMapRenderer extends TerminologyRenderer {
|
|||
else {
|
||||
if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
|
||||
String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
|
||||
tr.td().ah(eqpath+"#"+code).tx(presentEquivalenceCode(code));
|
||||
tr.td().ah(eqpath+"#"+code, code).tx(presentEquivalenceCode(code));
|
||||
} else {
|
||||
tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode()));
|
||||
tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode(), ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode()));
|
||||
}
|
||||
}
|
||||
td = tr.td();
|
||||
|
@ -192,7 +192,7 @@ public class ConceptMapRenderer extends TerminologyRenderer {
|
|||
if (hasRelationships) {
|
||||
tr.td().b().tx("Relationship");
|
||||
}
|
||||
tr.td().colspan(Integer.toString(1+targets.size())).b().tx("Destination Concept Details");
|
||||
tr.td().colspan(Integer.toString(1+targets.size())).b().tx("Target Concept Details");
|
||||
if (comment) {
|
||||
tr.td().b().tx("Comment");
|
||||
}
|
||||
|
@ -299,9 +299,9 @@ public class ConceptMapRenderer extends TerminologyRenderer {
|
|||
else {
|
||||
if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
|
||||
String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
|
||||
tr.td().ah(eqpath+"#"+code).tx(presentEquivalenceCode(code));
|
||||
tr.td().ah(eqpath+"#"+code, code).tx(presentEquivalenceCode(code));
|
||||
} else {
|
||||
tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode()));
|
||||
tr.td().ah(eqpath+"#"+ccm.getRelationship().toCode(), ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5094,6 +5094,9 @@ public class FHIRPathEngine {
|
|||
int i2 = -1;
|
||||
if (exp.parameterCount() == 2) {
|
||||
List<Base> n2 = execute(context, focus, exp.getParameters().get(1), true);
|
||||
if (n2.isEmpty()|| !n2.get(0).isPrimitive() || !Utilities.isInteger(n2.get(0).primitiveValue())) {
|
||||
return new ArrayList<Base>();
|
||||
}
|
||||
i2 = Integer.parseInt(n2.get(0).primitiveValue());
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.hl7.fhir.r5.context.IWorkerContext.ICanonicalResourceLocator;
|
|||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.terminologies.TerminologyClient;
|
||||
|
@ -152,7 +153,7 @@ public class StandAloneValidatorFetcher implements IValidatorResourceFetcher, IV
|
|||
}
|
||||
if (pi != null) {
|
||||
context.loadFromPackage(pi, null);
|
||||
return pi.hasCanonical(url);
|
||||
return pi.hasCanonical(url) || context.fetchResource(Resource.class, url) != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2402,7 +2402,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
r = loadContainedResource(errors, path, hostContext.getRootResource(), url.substring(1), Resource.class);
|
||||
}
|
||||
if (r == null) {
|
||||
fetcher.fetchCanonicalResource(this, url);
|
||||
r = fetcher.fetchCanonicalResource(this, url);
|
||||
}
|
||||
if (r == null) {
|
||||
r = this.context.fetchResource(Resource.class, url);
|
||||
|
@ -5660,7 +5660,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
msg = fpe.forLog();
|
||||
} catch (Exception ex) {
|
||||
ok = false;
|
||||
msg = ex.getMessage();
|
||||
msg = ex.getClass().getName()+": "+ex.getMessage();
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (!ok) {
|
||||
if (!Utilities.noString(msg)) {
|
||||
|
|
Loading…
Reference in New Issue