Finalizing search
In the previous steps you have created search support for the _id parameter on a Patient resource type. In order to test if your Facade implementation works correctly, you will need to perform a couple of steps:
Create a configuration class for the ASP .Net Core pipeline
Plug the Facade into the Firely Server
Configure the Firely Server to use your repository
1. Add configuration class
To add your repository service to the Firely Server pipeline, you will need to add a configuration class that sets the order of inclusion, and adds to the services. For background information, see Configuration classes.
Add a static class to your project called
ViSiConfiguration
Add the following code to it:
[VonkConfiguration(order: 210)] public static class ViSiConfiguration { public static IServiceCollection AddViSiServices(this IServiceCollection services, IConfiguration configuration) { services.AddDbContext<ViSiContext>(); services.TryAddSingleton<ResourceMapper>(); services.TryAddScoped<ISearchRepository, ViSiRepository>(); services.Configure<DbOptions>(configuration.GetSection(nameof(DbOptions))); return services; } }
Note
As of Firely Server version 4.4.0, your Facade should not have an order greater than or equal to 211. The reason for this is that upon configuring the administration database, Firely Server checks whether an ISearchRepository is registered. The earliest of these configurations is at order 211.
Note
Should you need to register any other classes or interface, please see Register a service in your plugin for more background.
2. Create your Facade plugin
First, build your project
Find the resulting dll and copy that to the
plugins
folder in the working directory of your Firely Server
Note
If your Firely Server working directory does not contain a plugins folder yet, you can create one. Within it, you can create subfolders, which can be useful if you work with multiple plugins.
You can also configure the name and location of this folder with the PipelineOptions.PluginDirectory
setting
in the appsettings file.
3. Configure your Firely Server Facade
Create an appsettings.instance.json file in your Firely Server working directory.
Tip
See Firely Server settings for more information about the hierarchy of the
appsettings(.*).json
files and the settings that can be configured.Add a setting for the connectionstring to the appsettings.instance.json file:
"DbOptions" : { "ConnectionString" : "<paste the connection string to your ViSi database here>" },
Add the
SupportedInteractions
section. You can look at Enable or disable interactions to check what this section should contain. For now you only need"WholeSystemInteractions": "capabilities"
,"InstanceLevelInteractions": "read"
and"TypeLevelInteractions": "search"
:"SupportedInteractions": { "InstanceLevelInteractions": "read", "TypeLevelInteractions": "search", "WholeSystemInteractions": "capabilities" },
Add the
SupportedModel
section to indicate which resource types and search parameters you support in your Facade implementation:"SupportedModel": { "RestrictToResources": [ "Patient" ], "RestrictToSearchParameters": ["Resource._id", "StructureDefinition.url"] },
You will need to add your repository to the Firely Server pipeline, and remove the existing repository implementations. The standard settings for the pipeline configuration can be found in the appsettings.default.json file, or see Configure the pipeline for an example.
Copy the whole PipelineOptions section to your appsettings.instance.json file (both
/
and/administration
)To the
Include
part of the branch with"Path":"/"
add your namespace, and remove the Vonk.Repository.* lines from it:{ "Path": "/", "Include": [ "Vonk.Core", "Vonk.Fhir.R3", "Vonk.Subscriptions", "Vonk.Plugin.Smart", "Vonk.UI.Demo", "ViSiProject" // fill in (a prefix of) the namespace of your project here ] },
Remove the PipelineOptions from appsettings.default.json, because of the warning mentioned on the Hierarchy of settings.
Test your work
Proceed to the next section to test your Facade, and for some helpful tips about debugging your code.