public static List<ElementDefinition> getSliceList(StructureDefinition profile, ElementDefinition element) throws DefinitionException { if (!element.hasSlicing()) throw new Error("getSliceList should only be called when the element has slicing"); List<ElementDefinition> res = new ArrayList<ElementDefinition>(); List<ElementDefinition> elements = profile.getSnapshot().getElement(); String path = element.getPath(); for (int index = elements.indexOf(element) + 1; index < elements.size(); index++) { ElementDefinition e = elements.get(index); if (e.getPath().startsWith(path + ".") || e.getPath().equals(path)) { // We want elements with the same path (until we hit an element that doesn't start with the same path) if (e.getPath().equals(element.getPath())) res.add(e); } else break; } return res; }
sdTime = sdTime + (System.nanoTime() - t1); ed = sd.getSnapshot().getElementFirstRep(); continue; } else if (ed.getType().get(0).hasProfile()) { childDefinitions = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
public StructureDefinitionSnapshotComponent copy() { StructureDefinitionSnapshotComponent dst = new StructureDefinitionSnapshotComponent(); copyValues(dst); if (element != null) { dst.element = new ArrayList<ElementDefinition>(); for (ElementDefinition i : element) dst.element.add(i.copy()); }; return dst; }
ElementDefinition currentBase = base.getElement().get(baseCursor); String cpath = fixedPath(contextPathSrc, currentBase.getPath()); else if (!outcome.getPath().startsWith(resultPathBase)) throw new DefinitionException("Adding wrong path"); result.getElement().add(outcome); if (hasInnerDiffMatches(differential, cpath, diffCursor, diffLimit, base.getElement())) { while (differential.getElement().size() > diffCursor && pathStartsWith(differential.getElement().get(diffCursor).getPath(), cpath+".")) diffCursor++; processPaths(indent+" ", result, dt.getSnapshot(), differential, 1 /* starting again on the data type, but skip the root */, start, dt.getSnapshot().getElement().size()-1, diffCursor-1, url, profileName, cpath, outcome.getPath(), trimDifferential, contextName, resultPathBase, false); template = sd.getSnapshot().getElement().get(0).copy().setPath(currentBase.getPath()); template.setSliceName(null); else if (!outcome.getPath().startsWith(resultPathBase)) throw new DefinitionException("Adding wrong path"); result.getElement().add(outcome); baseCursor++; diffCursor = differential.getElement().indexOf(diffMatches.get(0))+1; if (differential.getElement().size() > diffCursor && outcome.getPath().contains(".") && (isDataType(outcome.getType()) || outcome.hasContentReference())) { // don't want to do this for the root, since that's base, and we're already processing it if (pathStartsWith(differential.getElement().get(diffCursor).getPath(), diffMatches.get(0).getPath()+".") && !baseWalksInto(base.getElement(), baseCursor)) { if (outcome.getType().size() > 1) { for (TypeRefComponent t : outcome.getType()) { diffCursor++; if (outcome.hasContentReference()) { ElementDefinition tgt = getElementById(base.getElement(), outcome.getContentReference());
throw new DefinitionException("Unable to resolve actual type " + actualType); childDefinitions = ProfileUtilities.getChildMap(dt, dt.getSnapshot().getElement().get(0)); if (rule(errors, IssueType.STRUCTURE, ei.line(), ei.col(), ei.path, p != null, "Unknown profile " + typeProfile)) { List<ValidationMessage> profileErrors = new ArrayList<ValidationMessage>(); validateElement(appContext, profileErrors, p, p.getSnapshot().getElement().get(0), profile, ei.definition, resource, ei.element, type, localStack, thisIsCodeableConcept); boolean hasError = false; for (ValidationMessage msg : profileErrors) { validateElement(appContext, errors, p, p.getSnapshot().getElement().get(0), profile, ei.definition, resource, ei.element, type, localStack, thisIsCodeableConcept); int index = profile.getSnapshot().getElement().indexOf(ei.definition); if (index < profile.getSnapshot().getElement().size() - 1) { String nextPath = profile.getSnapshot().getElement().get(index+1).getPath(); if (!nextPath.equals(ei.definition.getPath()) && nextPath.startsWith(ei.definition.getPath())) validateElement(appContext, errors, profile, ei.definition, null, null, resource, ei.element, type, localStack, thisIsCodeableConcept);
ElementDefinition e = profile.getSnapshot().getElement().get(0); base.setDefinition(e.getDefinition()); base.setShort(e.getShort()); if (sd == null || sd.getSnapshot() == null || sd.getSnapshot().getElementFirstRep().getMax().equals("1")) ToolingExtensions.removeExtension(dest, ex.getUrl()); dest.addExtension(ex);
ElementDefinition ed = getElementByName(profile.getSnapshot().getElement(), definition.getContentReference()); if (ed == null) c.getPieces().add(gen.new Piece(null, translate("sd.table", "Unknown reference to %s", definition.getContentReference()), null));
sdTime = sdTime + (System.nanoTime() - t1); ed = sd.getSnapshot().getElementFirstRep(); continue; } else if (ed.getType().get(0).hasProfile()) { childDefinitions = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
String path = sdi.getSnapshot().getElement().get(0).getPath() + tail + "."; if (name.equals("**")) { assert (result.getCollectionStatus() == CollectionStatus.UNORDERED); for (ElementDefinition ed : sdi.getSnapshot().getElement()) { if (ed.getPath().startsWith(path)) for (TypeRefComponent t : ed.getType()) { for (ElementDefinition ed : sdi.getSnapshot().getElement()) { if (ed.getPath().startsWith(path) && !ed.getPath().substring(path.length()).contains(".")) for (TypeRefComponent t : ed.getType()) { path = sdi.getSnapshot().getElement().get(0).getPath() + tail + "." + name;
ElementDefinition ed = getElementByName(profile.getSnapshot().getElement(), definition.getContentReference()); if (ed == null) c.getPieces().add(gen.new Piece(null, "Unknown reference to "+definition.getContentReference(), null));
this.snapshot = new StructureDefinitionSnapshotComponent(); return this.snapshot;
String m = ""; boolean vdeep = false; if (ed.getSnapshot().getElementFirstRep().getIsModifier()) m = "modifier_"; for (ElementDefinition eld : ed.getSnapshot().getElement()) { deep = deep || eld.getPath().contains("Extension.extension."); vdeep = vdeep || eld.getPath().contains("Extension.extension.extension."); r.getCells().add(gen.new Cell(null, defFile == null ? "" : defFile+"-definitions.html#extension."+ed.getName(), ed.getSnapshot().getElement().get(0).getIsModifier() ? "modifierExtension" : "extension", null, null)); r.getCells().add(gen.new Cell()); r.getCells().add(gen.new Cell(null, null, describeCardinality(ed.getSnapshot().getElement().get(0), null, new UnusedTracker()), null, null)); List<ElementDefinition> children = getChildren(ed.getSnapshot().getElement(), ed.getSnapshot().getElement().get(0)); for (ElementDefinition child : children) if (!child.getPath().endsWith(".id")) genElement(defFile == null ? "" : defFile+"-definitions.html#extension.", gen, r.getSubRows(), child, ed.getSnapshot().getElement(), null, true, defFile, true, full, corePath, imagePath, true, false, false, false); } else if (deep) { List<ElementDefinition> children = new ArrayList<ElementDefinition>(); for (ElementDefinition ted : ed.getSnapshot().getElement()) { if (ted.getPath().equals("Extension.extension")) children.add(ted); for (ElementDefinition ted : ed.getSnapshot().getElement()) { if (ted.getPath().startsWith("Extension.value")) ved = ted;
dst.baseDefinition = baseDefinition == null ? null : baseDefinition.copy(); dst.derivation = derivation == null ? null : derivation.copy(); dst.snapshot = snapshot == null ? null : snapshot.copy(); dst.differential = differential == null ? null : differential.copy(); return dst;
tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential())); if (tgt.hasSnapshot()) tgt.getSnapshot().getElementFirstRep().getType().clear(); if (tgt.hasDifferential()) tgt.getDifferential().getElementFirstRep().getType().clear();
if (src.hasSnapshot()) { tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot())); tgt.getSnapshot().getElementFirstRep().getType().clear();
if (sd == null) throw new DefinitionException("Unable to find type '"+t+"' for name '"+elementName+"' on property "+definition.getPath()); children = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElement().get(0));
if (sdn == null) throw new FHIRException("Unable to find definition for "+type.getType()); ElementDefinition edn = sdn.getSnapshot().getElementFirstRep(); PropertyWithType pn = createProfile(map, profiles, new PropertyWithType(sdn.getId(), new Property(worker, edn, sdn), null, type), sliceName, tgt);
derived.setSnapshot(new StructureDefinitionSnapshotComponent()); processPaths("", derived.getSnapshot(), base.getSnapshot(), derived.getDifferential(), baseCursor, diffCursor, base.getSnapshot().getElement().size()-1, derived.getDifferential().hasElement() ? derived.getDifferential().getElement().size()-1 : -1, url, derived.getId(), null, null, false, base.getUrl(), null, false); if (!derived.getSnapshot().getElementFirstRep().getType().isEmpty()) throw new Error("type on first snapshot element for "+derived.getSnapshot().getElementFirstRep().getPath()+" in "+derived.getUrl()+" from "+base.getUrl()); updateMaps(base, derived); setIds(derived, false); System.out.println(" "+ed.getPath()+" : "+typeSummary(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" id = "+ed.getId()); System.out.println("Snapshot: "); for (ElementDefinition ed : derived.getSnapshot().getElement()) System.out.println(" "+ed.getPath()+" : "+typeSummary(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" id = "+ed.getId()); throw new DefinitionException("Snapshot for "+derived.getUrl()+" does not contain differential element with id: " + e.getId());
ccmp = new ElementDefinitionComparer(true, profile.getSnapshot().getElement(), ed.getType().get(0).getCode(), child.getSelf().getPath().length(), cmp.name); } else if (ed.getType().size() == 1 && !ed.getType().get(0).getCode().equals("*")) { StructureDefinition profile = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+ed.getType().get(0).getCode()); if (profile==null) throw new FHIRException("Unable to resolve profile " + "http://hl7.org/fhir/StructureDefinition/"+ed.getType().get(0).getCode() + " in element " + ed.getPath()); ccmp = new ElementDefinitionComparer(false, profile.getSnapshot().getElement(), ed.getType().get(0).getCode(), child.getSelf().getPath().length(), cmp.name); } else if (child.getSelf().getType().size() == 1) { StructureDefinition profile = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+child.getSelf().getType().get(0).getCode()); if (profile==null) throw new FHIRException("Unable to resolve profile " + "http://hl7.org/fhir/StructureDefinition/"+ed.getType().get(0).getCode() + " in element " + ed.getPath()); ccmp = new ElementDefinitionComparer(false, profile.getSnapshot().getElement(), child.getSelf().getType().get(0).getCode(), child.getSelf().getPath().length(), cmp.name); } else if (ed.getPath().endsWith("[x]") && !child.getSelf().getPath().endsWith("[x]")) { String edLastNode = ed.getPath().replaceAll("(.*\\.)*(.*)", "$2"); if (sd == null) throw new Error("Unable to find profile "+p); ccmp = new ElementDefinitionComparer(false, sd.getSnapshot().getElement(), p, child.getSelf().getPath().length(), cmp.name); } else { throw new Error("Not handled yet (sortElements: "+ed.getPath()+":"+typeCode(ed.getType())+")");
throw new Error("not handled yet"); boolean found = false; for (ElementDefinition d : structure.getSnapshot().getElement()) { if (d.hasId() && d.getId().equals(definition.getContentReference().substring(1))) { found = true;