private boolean tailMatches(ElementDefinition t, String d) { String tail = tail(t.getPath()); if (d.contains("[")) return tail.startsWith(d.substring(0, d.indexOf('['))); else return tail.equals(d); }
protected ElementDefinition findElement(StructureDefinition profile, String name) { for (ElementDefinition c : profile.getSnapshot().getElement()) { if (c.getPath().equals(name)) { return c; } } return null; }
private NodeStack push(Element element, int count, ElementDefinition definition, ElementDefinition type) { NodeStack res = new NodeStack(); res.parent = this; res.element = element; res.definition = definition; res.literalPath = getLiteralPath() + "." + element.getName(); if (count > -1) res.literalPath = res.literalPath + "[" + Integer.toString(count) + "]"; res.logicalPaths = new ArrayList<String>(); if (type != null) { // type will be bull if we on a stitching point of a contained resource, or if.... res.type = type; String t = tail(definition.getPath()); for (String lp : getLogicalPaths()) { res.logicalPaths.add(lp + "." + t); if (t.endsWith("[x]")) res.logicalPaths.add(lp + "." + t.substring(0, t.length() - 3) + type.getPath()); } res.logicalPaths.add(type.getPath()); } else if (definition != null) { for (String lp : getLogicalPaths()) res.logicalPaths.add(lp + "." + element.getName()); } else res.logicalPaths.addAll(getLogicalPaths()); // CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); // for (String lp : res.logicalPaths) // b.append(lp); // System.out.println(res.literalPath+" : "+b.toString()); return res; }
private Set<String> listExtensionTypes(StructureDefinition ex) { ElementDefinition vd = null; for (ElementDefinition ed : ex.getSnapshot().getElement()) { if (ed.getPath().startsWith("Extension.value")) { vd = ed; break; } } Set<String> res = new HashSet<String>(); if (vd != null && !"0".equals(vd.getMax())) { for (TypeRefComponent tr : vd.getType()) { res.add(tr.getCode()); } } return res; }
private void checkExtensions(StructureDefinition profile, List<ValidationMessage> errors, String kind, ElementDefinition ec) { if (!ec.getType().isEmpty() && "Extension".equals(ec.getType().get(0).getCode()) && ec.getType().get(0).hasProfile()) { String url = ec.getType().get(0).getProfile(); StructureDefinition defn = context.fetchResource(StructureDefinition.class, url); rule(errors, IssueType.BUSINESSRULE, profile.getId(), defn != null, "Unable to find Extension '"+url+"' referenced at "+profile.getUrl()+" "+kind+" "+ec.getPath()+" ("+ec.getSliceName()+")"); } }
public void checkAllInvariants(){ for (StructureDefinition sd : context.allStructures()) { if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) { for (ElementDefinition ed : sd.getSnapshot().getElement()) { for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) { if (inv.hasExpression()) { try { ExpressionNode n = (ExpressionNode) inv.getUserData("validator.expression.cache"); if (n == null) { n = fpe.parse(inv.getExpression()); inv.setUserData("validator.expression.cache", n); } fpe.check(null, sd.getKind() == StructureDefinitionKind.RESOURCE ? sd.getType() : "DomainResource", ed.getPath(), n); } catch (Exception e) { System.out.println("Error processing structure ["+sd.getId()+"] path "+ed.getPath()+":"+inv.getKey()+" (\""+inv.getExpression()+"\"): "+e.getMessage()); } } } } } } }
if (c.getPath().endsWith(".url") && c.hasFixed() && c.getFixed() instanceof UriType && ((UriType)c.getFixed()).equals(qualifier)) { found = true; break; if (c.getPath().endsWith(".url") && c.hasFixed() && c.getFixed() instanceof UriType && ((UriType)c.getFixed()).equals(qualifier)) { found = true; ed = t;
if (s.getType() == DiscriminatorType.TYPE) { String type = null; if (!criteriaElement.getPath().contains("[") && discriminator.contains("[")) { discriminator = discriminator.substring(0, discriminator.indexOf('[')); String lastNode = tail(discriminator); type = tail(criteriaElement.getPath()).substring(lastNode.length()); type = type.substring(0,1).toLowerCase() + type.substring(1); } else if (!criteriaElement.hasType() || criteriaElement.getType().size()==1) {
boolean process = true; if (ed.hasSlicing() && !ed.getSlicing().getOrdered()) slicingPath = ed.getPath(); else if (slicingPath!=null && ed.getPath().equals(slicingPath)) else if (slicingPath != null && !ed.getPath().startsWith(slicingPath)) slicingPath = null; if (slicer != null && slicer.getPath().equals(ed.getPath())) throw new DefinitionException("Slice encountered midway through path on " + slicer.getPath()); slicer = ed; process = false; sliceOffset = i; } else if (slicer != null && !slicer.getPath().equals(ed.getPath())) slicer = null; boolean match = false; if (slicer == null || slicer == ed) { match = nameMatches(ei.name, tail(ed.getPath())); } else { if (nameMatches(ei.name, tail(ed.getPath()))) try { match = sliceMatches(appContext, ei.element, ei.path, slicer, ed, profile, errors, stack); problematicPaths.add(ed.getPath()); String sliceInfo = ""; if (slicer != null)
public ElementDefinitionHolder(ElementDefinition self) { super(); this.self = self; this.name = self.getPath(); children = new ArrayList<ElementDefinitionHolder>(); }
if (forBuild) { if (!inExemptList(inv.getKey())) { if (rule(errors, IssueType.BUSINESSRULE, profile.getId()+"::"+ed.getPath()+"::"+inv.getKey(), inv.hasExpression(), "The invariant has no FHIR Path expression ("+inv.getXpath()+")")) { try { new FHIRPathEngine(context).check(null, profile.getType(), ed.getPath(), inv.getExpression()); // , inv.hasXpath() && inv.getXpath().startsWith("@value") } catch (Exception e) {
public ElementDefinition getExtensionValueDefinition() { int i = defn.getSnapshot().getElement().indexOf(element)+1; while (i < defn.getSnapshot().getElement().size()) { ElementDefinition ed = defn.getSnapshot().getElement().get(i); if (ed.getPath().equals(element.getPath())) return null; if (ed.getPath().startsWith(element.getPath()+".value")) return ed; i++; } return null; }
private String getRowColor(ElementDefinition element, boolean isConstraintMode) { switch (element.getUserInt(UD_ERROR_STATUS)) { case STATUS_HINT: return ROW_COLOR_HINT; case STATUS_WARNING: return ROW_COLOR_WARNING; case STATUS_ERROR: return ROW_COLOR_ERROR; case STATUS_FATAL: return ROW_COLOR_FATAL; } if (isConstraintMode && !element.getMustSupport() && !element.getIsModifier() && element.getPath().contains(".")) return null; // ROW_COLOR_NOT_MUST_SUPPORT; else return null; }
org.hl7.fhir.instance.model.ElementDefinition tgt = new org.hl7.fhir.instance.model.ElementDefinition(); copyElement(src, tgt); tgt.setPath(src.getPath()); for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation> t : src.getRepresentation()) tgt.addRepresentation(convertPropertyRepresentation(t.getValue()));
org.hl7.fhir.dstu2016may.model.ElementDefinition tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition(); copyElement(src, tgt); tgt.setPath(src.getPath()); for (org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation> t : src.getRepresentation()) tgt.addRepresentation(convertPropertyRepresentation(t.getValue()));