Ejemplo n.º 1
0
        ResourceMap.Node CreateMapNode(DomainResource r)
        {
            String structureName = r.TypeName;
            String resourceUrl;
            String baseName = null;
            String title;

            switch (r)
            {
            case ValueSet vs:
                resourceUrl = vs.Url;
                title       = vs.Title;
                break;

            case StructureDefinition sd:
                resourceUrl = sd.Url;
                baseName    = sd.BaseDefinition.LastUriPart();
                title       = sd.Title;
                break;

            default:
                return(null);
            }

            string mapName = r.GetStringExtension(Global.ResourceMapNameUrl);

            if (String.IsNullOrEmpty(mapName) == true)
            {
                throw new Exception($"Mapname missing from {resourceUrl}");
            }
            String[] mapNameArray = mapName.Split('/');

            Extension isFragmentExtension = r.GetExtension(Global.IsFragmentExtensionUrl);

            ResourceMap.Node retVal = this.CreateMapNode(resourceUrl,
                                                         title,
                                                         mapNameArray,
                                                         structureName,
                                                         isFragmentExtension != null);

            foreach (Extension link in r.GetExtensions(Global.ResourceMapLinkUrl))
            {
                FhirString s = (FhirString)link.Value;

                dynamic mapLink = JObject.Parse(s.Value);
                mapLink.LinkSource = resourceUrl;
                this.links.Add(mapLink);
                retVal.AddLink(mapLink);
            }

            return(retVal);
        }