示例#1
0
        public static TabularMappingDefinition BuildMappingDefinition(TabularTable tabularTable, Dictionary <string, PropertiesGroup> propertiesGroups, int maxDepth)
        {
            TabularMappingDefinition result = new TabularMappingDefinition(tabularTable.Name)
            {
                ResourceType = tabularTable.ResourceType,
                Unrollpath   = tabularTable.UnrollPath
            };

            ResolveDefinitionNode(result.Root, tabularTable.Properties, propertiesGroups, new LinkedList <string>(), new HashSet <string>(), maxDepth);

            return(result);
        }
示例#2
0
        public Dictionary <string, (object valueObj, object typeObj)> ToTabular(ElementNode fhirElement, TabularMappingDefinition defination)
        {
            IEnumerable <(string name, object valueObj, object typeObj)> result = ToTabularInternal(fhirElement, defination.Root);

            Dictionary <string, (object valueObj, object typeObj)> output = result.ToDictionary(k => k.name, v => (v.valueObj, v.typeObj));

            return(output);
        }
示例#3
0
        public IEnumerable <Dictionary <string, (object valueObj, object typeObj)> > ToTabular(Resource resource, TabularMappingDefinition defination)
        {
            ElementNode root = ElementNode.FromElement(resource.ToTypedElement());

            if (string.IsNullOrEmpty(defination.Unrollpath))
            {
                IEnumerable <(string name, object valueObj, object typeObj)> result = ToTabularInternal(root, defination.Root);
                Dictionary <string, (object valueObj, object typeObj)>       output = result.ToDictionary(k => k.name, v => (v.valueObj, v.typeObj));

                output[ReservedColumnName.ResourceId] = (resource.Id, FhirTypeNames.String);
                yield return(output);
            }
            else
            {
                foreach (var node in root.Select(defination.Unrollpath))
                {
                    IEnumerable <(string name, object valueObj, object typeObj)> result = ToTabularInternal(ElementNode.FromElement(node), defination.Root);
                    Dictionary <string, (object valueObj, object typeObj)>       output = result.ToDictionary(k => k.name, v => (v.valueObj, v.typeObj));

                    output[ReservedColumnName.RowId]      = (IdGenerator(), FhirTypeNames.String);
                    output[ReservedColumnName.ResourceId] = (resource.Id, FhirTypeNames.String);
                    output[ReservedColumnName.FhirPath]   = (node.Location, FhirTypeNames.String);
                    output[ReservedColumnName.ParentPath] = (GetParentLocation(node), FhirTypeNames.String);

                    yield return(output);
                }
            }
        }