public void DiscoverExtensionsInFolderXml()
        {
            string        sourcePath    = Configuration.GetValue <string>("sourcePath");
            string        outputPath    = Configuration.GetValue <string>("outputPath");
            string        canonicalBase = Configuration.GetValue <string>("defaults:baseurl");
            string        publisher     = Configuration.GetValue <string>("defaults:publisher");
            ScanResources processor     = new ScanResources(sourcePath, outputPath,
                                                            canonicalBase, publisher);

            string exampleResourcesPath = Configuration.GetValue <string>("scanExamplesInPath");

            foreach (string file in Directory.EnumerateFiles(exampleResourcesPath, "*.xml", SearchOption.AllDirectories))
            {
                try
                {
                    var resource = new FhirXmlParser().Parse <Resource>(File.ReadAllText(file));
                    System.Diagnostics.Trace.WriteLine($"{file} {resource.TypeName}/{resource.Id}");
                    if (resource is Bundle bundle)
                    {
                        foreach (var entry in bundle.Entry.Select(e => e.Resource))
                        {
                            if (entry != null)
                            {
                                System.Diagnostics.Trace.WriteLine($"  -->{entry.TypeName}/{entry.Id}");
                                processor.ScanForExtensions(null, entry.ToTypedElement(), null);
                            }
                        }
                    }
                    else
                    {
                        processor.ScanForExtensions(null, resource.ToTypedElement(), null);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine($"{file}");
                    System.Diagnostics.Trace.WriteLine($"  ==> Exception {ex.Message}");
                }
            }

            // Next pass was to update the type profile - including the generated extensions.
            // - while merging the profile
            // -- if it is sliced, but not slice for the value, suggest a new one?
            // -- with observations - based on a common profile, then train it on a folder to learn what they should look like
        }
        public void DiscoverExtensionsOnFhirServer()
        {
            string        sourcePath    = Configuration.GetValue <string>("sourcePath");
            string        outputPath    = Configuration.GetValue <string>("outputPath");
            string        canonicalBase = Configuration.GetValue <string>("defaults:baseurl");
            string        publisher     = Configuration.GetValue <string>("defaults:publisher");
            ScanResources processor     = new ScanResources(sourcePath, outputPath,
                                                            canonicalBase, publisher);

            var settings = Configuration.GetSection("scanserver").Get <ScanServerSettings>();
            var server   = new FhirClient(settings.baseurl, new FhirClientSettings()
            {
                VerifyFhirVersion = false
            });

            int createdResources = 0;

            foreach (var query in settings.queries)
            {
                try
                {
                    Bundle batch = server.Get(server.Endpoint + query) as Bundle;
                    do
                    {
                        foreach (var entry in batch.Entry.Select(e => e.Resource))
                        {
                            if (entry != null)
                            {
                                System.Diagnostics.Trace.WriteLine($"  -->{entry.TypeName}/{entry.Id}");
                                processor.ScanForExtensions(null, entry.ToTypedElement(), null);
                                createdResources++;
                            }
                        }
                        // if (batch.NextLink == null)
                        break;
                        batch = server.Continue(batch);
                    }while (true);
                }
                catch (FhirOperationException ex)
                {
                    DebugDumpOutputXml(ex.Outcome);
                }
            }
        }