Example #1
0
        public void SliceSize(ElementTreeSlice slice,
                              ValueSet units)
        {
            // Fix component code
            ElementTreeNode valueXNode = this.SliceValueXByType(slice,
                                                                new string[] { "Quantity", "Range" });
            {
                Hl7.Fhir.Model.Quantity q = new Hl7.Fhir.Model.Quantity
                {
                    System = units.Url
                };

                ElementDefinition valueX = new ElementDefinition
                {
                    Path      = $"{slice.ElementDefinition.Path}.value[x]",
                    ElementId = $"{slice.ElementDefinition.ElementId}.value[x]:valueQuantity",
                    SliceName = $"valueQuantity",
                    Min       = 0,
                    Max       = "1"
                }
                .Pattern(q)
                .Type("Quantity")
                ;
                valueXNode.CreateSlice($"valueQuantity", valueX);
            }

            {
                Hl7.Fhir.Model.Range r = new Hl7.Fhir.Model.Range
                {
                    Low = new SimpleQuantity
                    {
                        System = units.Url,
                    },
                    High = new SimpleQuantity
                    {
                        System = units.Url,
                    }
                };
                ElementDefinition valueX = new ElementDefinition
                {
                    Path      = $"{slice.ElementDefinition.Path}.value[x]",
                    ElementId = $"{slice.ElementDefinition.ElementId}.value[x]:valueRange",
                    SliceName = $"valueRange",
                    Min       = 0,
                    Max       = "1"
                }
                .Pattern(r)
                .Type("Range")
                ;
                valueXNode.CreateSlice($"valueRange", valueX);
            }
        }
Example #2
0
            ElementTreeSlice SliceSection(ElementTreeNode sliceElementDef,
                                          String sliceName,
                                          String title,
                                          Coding code,
                                          out ElementDefinition entry)
            {
                ElementTreeSlice slice = sliceElementDef.CreateSlice(sliceName);

                CreateElement(slice, "title")
                .Single()
                .Fixed(new FhirString(title))
                ;
                CreateElement(slice, "code")
                .Single()
                .Pattern(code.ToCodeableConcept().ToPattern())
                .DefaultValueExtension(code.ToCodeableConcept())
                ;
                CreateElement(slice, "focus")
                .Zero()
                ;
                entry = CreateElement(slice, "entry")
                ;

                CreateElement(slice, "section")
                .Zero()
                ;
                return(slice);
            }
Example #3
0
        public ElementTreeSlice ApplyExtension(ElementTreeNode extDef,
                                               String name,
                                               String extensionUrl)
        {
            String sliceName = name.UncapFirstLetter();

            this.ConfigureSliceByUrlDiscriminator(extDef, true);


            ElementTreeSlice slice = extDef.CreateSlice(sliceName);

            slice.ElementDefinition.Min = 0;
            slice.ElementDefinition.Max = "*";

            slice.ElementDefinition
            .SetShort($"{name} extension.")
            .SetDefinition(new Markdown()
                           .Paragraph($"This extension slice contains the {name} extension."))
            .SetComment(ResourcesMaker.componentDefinition)
            ;

            slice.ElementDefinition.IsModifier = false;
            slice.ElementDefinition.Type.Add(new ElementDefinition.TypeRefComponent
            {
                Code    = "Extension",
                Profile = new String[] { extensionUrl }
            });
            return(slice);
        }
Example #4
0
        public ElementDefinition SliceSelfByPattern(String path,
                                                    String sliceName,
                                                    Element pattern)
        {
            ElementTreeNode elementDef = ApplySliceSelf(path);

            sliceName = sliceName.UncapFirstLetter();
            ElementTreeSlice codingSlice = elementDef.CreateSlice(sliceName);

            codingSlice.ElementDefinition.Pattern = pattern;
            return(codingSlice.ElementDefinition);
        }
Example #5
0
        public ElementTreeSlice AppendSlice(String elementName,
                                            String sliceName,
                                            Int32 min  = 0,
                                            String max = "*")
        {
            ElementTreeNode  elementDef = this.Get(elementName);
            ElementTreeSlice retVal     = elementDef.CreateSlice(sliceName);

            retVal.ElementDefinition.Min = min;
            retVal.ElementDefinition.Max = max;
            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);
            }
        }
Example #7
0
        public ElementTreeSlice SliceByUrlTarget(ElementTreeNode sliceElementDef,
                                                 String profileUrl,
                                                 Int32 min,
                                                 String max)
        {
            String           sliceName = profileUrl.LastUriPart().UncapFirstLetter();
            ElementTreeSlice slice     = sliceElementDef.CreateSlice(sliceName);

            slice.ElementDefinition.SetCardinality(min, max);
            slice.ElementDefinition.Type.Clear();
            slice.ElementDefinition.Type.Add(new ElementDefinition.TypeRefComponent
            {
                Code          = "Reference",
                TargetProfile = new String[] { profileUrl }
            });
            return(slice);
        }