void Slice(SDefEditor e, ElementTreeNode extensionNode, String sliceName, String shortText, Markdown definition, out ElementTreeSlice extensionSlice, out ElementTreeNode valueXNode) { extensionSlice = extensionNode.CreateSlice(sliceName); extensionSlice.ElementDefinition .ElementId($"{extensionNode.ElementDefinition.Path}:{sliceName}") .SliceName(sliceName) .Short(shortText) .Definition(definition) .SetCardinality(0, "1") ; extensionSlice.ElementDefinition.Type = null; { ElementDefinition sealExtension = new ElementDefinition { ElementId = $"{extensionNode.ElementDefinition.Path}:{sliceName}.extension", Path = $"{extensionNode.ElementDefinition.Path}.extension" }; sealExtension.Zero(); extensionSlice.CreateNode(sealExtension); } { ElementDefinition elementUrl = new ElementDefinition() .Path($"{extensionNode.ElementDefinition.Path}.url") .ElementId($"{extensionNode.ElementDefinition.Path}:{sliceName}.url") .Value(new FhirUri(sliceName)) .Type("uri") .Definition(new Markdown() .Paragraph($"Url for {sliceName} complex extension item.") ) ; extensionSlice.CreateNode(elementUrl); } { ElementDefinition valueBase = e.Get("value[x]").ElementDefinition; ElementDefinition elementValue = new ElementDefinition() .Path($"{extensionNode.ElementDefinition.Path}.value[x]") .ElementId($"{extensionNode.ElementDefinition.Path}:{sliceName}.value[x]") ; valueXNode = extensionSlice.CreateNode(elementValue); } }
// Start Section Sliceing ElementTreeNode StartSectionSlicing(SDefEditor e) { ElementTreeNode sectionNode = e.Get("section"); ElementDefinition.SlicingComponent slicingComponent = new ElementDefinition.SlicingComponent { Rules = ElementDefinition.SlicingRules.Open }; slicingComponent.Discriminator.Add(new ElementDefinition.DiscriminatorComponent { Type = ElementDefinition.DiscriminatorType.Pattern, Path = "code" }); sectionNode.ApplySlicing(slicingComponent, false); return(sectionNode); }