use of org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent in project kindling by HL7.
the class ProfileGenerator method makeExtensionSlice.
private ElementDefinition makeExtensionSlice(String extensionName, StructureDefinition p, StructureDefinitionSnapshotComponent c, ElementDefn e, String path) throws URISyntaxException, Exception {
ElementDefinition ex = createBaseDefinition(p, path, definitions.getBaseResources().get("DomainResource").getRoot().getElementByName(definitions, extensionName, false, false, null));
c.getElement().add(ex);
if (!ex.hasBase())
ex.setBase(new ElementDefinitionBaseComponent());
ex.getBase().setPath("Element.extension");
ex.getBase().setMin(0);
ex.getBase().setMax("*");
ElementDefinitionConstraintComponent inv = ex.addConstraint();
inv.setKey("ext-1");
inv.setSeverity(ConstraintSeverity.ERROR);
inv.setHuman("Must have either extensions or value[x], not both");
inv.setExpression("extension.exists() != value.exists()");
inv.setXpath("exists(f:extension)!=exists(f:*[starts-with(local-name(.), 'value')])");
inv.setSource("http://hl7.org/fhir/StructureDefinition/Extension");
return ex;
}
use of org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent in project kindling by HL7.
the class ProfileGenerator method defineAncestorElements.
private void defineAncestorElements(String type, String path, SnapShotMode snapshot, Set<String> containedSlices, StructureDefinition p, List<ElementDefinition> elements, String dt, boolean defaults) throws Exception {
ElementDefn e = definitions.getElementDefn(actualTypeName(type));
if (!Utilities.noString(e.typeCode()))
defineAncestorElements(e.typeCode(), path, snapshot, containedSlices, p, elements, dt, defaults);
if (!definitions.getBaseResources().containsKey(e.getName()) || !definitions.getBaseResources().get(e.getName()).isInterface()) {
for (ElementDefn child : e.getElements()) {
ElementDefinition ed = defineElement(null, p, elements, child, path + "." + child.getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), snapshot, false, dt, null, defaults);
if (!ed.hasBase())
ed.setBase(new ElementDefinitionBaseComponent());
ed.getBase().setPath(e.getName() + "." + child.getName());
if (child.getMinCardinality() != null)
ed.getBase().setMin(child.getMinCardinality());
if (child.getMaxCardinality() != null)
ed.getBase().setMax(child.getMaxCardinality() == Integer.MAX_VALUE ? "*" : child.getMaxCardinality().toString());
if (snapshot == SnapShotMode.DataType && ed.getPath().endsWith(".extension") && !ed.hasSlicing())
ed.getSlicing().setDescription("Extensions are always sliced by (at least) url").setRules(SlicingRules.OPEN).addDiscriminator().setType(DiscriminatorType.VALUE).setPath("url");
}
}
}
Aggregations