SDefEditor CreateFragment(String name, String title, String mapName, String baseDefinition) { SDefEditor retVal = this.CreateEditor(name, title, mapName, baseDefinition, $"Fragment/{name}"); retVal.SetIsFrag(); retVal.SDef.Abstract = true; retVal.IntroDoc = new IntroDoc(); retVal.IntroDoc.TryAddUserMacro("FragPath", FragmentMapMaker.FragmentMapName(retVal.SDef.Url.LastUriPart())); retVal.IntroDoc.TryAddUserMacro("TitleArticle", this.Article(title)); retVal.IntroDoc.TryAddUserMacro("Title", title); retVal.IntroDoc.Load("Fragment", Path.Combine(this.pageDir, $"StructureDefinition-{name}-intro.xml")); retVal.SDef.Version = "Fragment"; // this will get stripped out when unfrag'd. return(retVal); }
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); } }
void SliceAndBindUrl(SDefEditor e, ElementTreeNode extensionNode, String sliceName, String bindName, String shortText, Markdown definition, out ElementTreeSlice extensionSlice, out ElementTreeNode valueXNode) { this.Slice(e, extensionNode, sliceName, shortText, definition, out extensionSlice, out valueXNode); valueXNode.ElementDefinition .Type("CodeableConcept") .Binding(bindName, BindingStrength.Required) .Single() ; }
ElementDefinition SliceAndBindVS(SDefEditor e, ElementTreeNode extensionNode, String sliceName, ValueSet binding, String shortText, Markdown definition) { this.SliceAndBindUrl(e, extensionNode, sliceName, binding.Url, shortText, definition, out ElementTreeSlice extensionSlice, out ElementTreeNode valueXNode); return(extensionSlice.ElementDefinition); }
SDefEditor CreateEditor(String name, String title, String mapName, String baseDefinition, String groupPath, String docTemplateName) { title = title.Trim(); SDefEditor retVal = this.CreateEditor(name, title, mapName, baseDefinition, groupPath); retVal.IntroDoc = new IntroDoc(); retVal.IntroDoc.TryAddUserMacro("FocusPath", FocusMapMaker.FocusMapName(retVal.SDef.Url.LastUriPart())); retVal.IntroDoc.TryAddUserMacro("TitleArticle", this.Article(title)); retVal.IntroDoc.TryAddUserMacro("Title", title); retVal.IntroDoc.Load(docTemplateName, Path.Combine(this.pageDir, $"StructureDefinition-{name}-intro.xml")); return(retVal); }
// 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); }
SDefEditor CreateEditor(String name, String title, String mapName, String baseDefinition, String groupPath) { if (name.Contains(" ", new StringComparison())) { throw new Exception("Structure Def name can not contains spaces"); } title = title.Trim(); SDefEditor retVal = new SDefEditor(this, name, CreateUrl(name), baseDefinition, mapName, this.resourceDir, this.pageDir) .Title(title) .Derivation(StructureDefinition.TypeDerivationRule.Constraint) .Abstract(false) .Type(baseDefinition.LastUriPart()) .Kind(StructureDefinition.StructureDefinitionKind.Resource) .Status(PublicationStatus.Draft) ; retVal.SDef.FhirVersion = FHIRVersion.N4_0_1; this.Editors.Add(retVal.SDef.Url, retVal); // store groupPath as an extension. This is an unregistered extension that will be removed before // processing is complete. retVal.SDef.Extension.Add(new Extension { Url = Global.GroupExtensionUrl, Value = new FhirString(groupPath) }); return(retVal); }