Data Plug-ins
Data plug-ins enable manipulation of incoming data before they are saved to the storage service or outgoing data right before they are exported.
Using Data Plug-ins
The Informatics Gateway allows you to configure data plug-ins in the following services:
- (DIMSE) MONAI Deploy DICOM Listener: Configure each listening AE Title with zero or more data plug-ins via the CLI or via the Configuration API.
- (DIMSE) DICOM Export: configure the
Plug-inAssemblies
with one or more data plug-ins in the ExportRequestEvent. - (DICOMWeb) STOW-RS:
- The Virtual AE endpoints (
/dicomweb/vae/...
) can be configured similarly to the DICOM listener using the DICOMWeb STOW API. - For the default
/dicomweb/...
endpoints, set zero or more plug-ins underInformaticsGateway>dicomWeb>plug-ins
in theappsettings.json
configuration file.
- The Virtual AE endpoints (
- (DICOMWeb) Export: configure the
Plug-inAssemblies
with one or more data plug-ins in the ExportRequestEvent.
Note
When one or more plug-ins are defined, the plug-ins are executed in the order as they are listed.
Available Plug-ins
The following plug-ins are available:
Name | Description | Fully Qualified Assembly Name |
---|---|---|
DicomDeidentifier | A plug-in that de-identifies a set of configurable DICOM tags with random data before DICOM data is exported. | Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution.DicomDeidentifier, Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution |
DicomReidentifier | A plug-in to be used together with the DicomDeidentifier plug-in to restore the original DICOM metadata. |
Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution.DicomReidentifier, Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution |
Creating a Plug-in
To create an input data plug-in, implement the IInputDataPlugin interface and
put the dynamic link library (DLL) in
the plug-ins/
directories. Similarly, for output data plug-ins, implement the IOutputDataPlugin
interface.
Refer to the Configuration API page to retrieve available input and output data plug-ins.
Database Extensions
If a plug-in requires presistent data in the database, extend the DatabaseRegistrationBase class to register your database context and repositories.
Refer to the Monai.Deploy.InformaticsGateway.PlugIns.RemoteAppExecution
plug-in as a reference.
Important
The Informatics Gateway requires all plug-ins to extend both the Entity Framework (SQLite) and MongoDB databases.
Entity Framework
Implement the IDatabaseMigrationManagerForPlugIns interface to
register your Entity Framework (EF) database context. A connectionString
is provided to the Configure(...)
function when you extend the
DatabaseRegistrationBase class, allowing you to create your
code-first EF database context and generate your
migration code using the dotnet ef CLI tool.
The following example extends the DatabaseRegistrationBase class
to register a new EF database context named RemoteAppExecutionDbContext
.
In the method, you first register the database context, then register your Migration Manager by implementing the
IDatabaseMigrationManagerForPlugIns interface.
Lastly, you register your repository for the RemoteAppExecutions
table.
public class DatabaseRegistrar : DatabaseRegistrationBase
{
public override IServiceCollection Configure(IServiceCollection services, DatabaseType databaseType, string? connectionString)
{
Guard.Against.Null(services, nameof(services));
switch (databaseType)
{
case DatabaseType.EntityFramework:
Guard.Against.Null(connectionString, nameof(connectionString));
services.AddDbContext<EntityFramework.RemoteAppExecutionDbContext>(options => options.UseSqlite(connectionString), ServiceLifetime.Transient);
services.AddScoped<IDatabaseMigrationManagerForPlugIns, EntityFramework.MigrationManager>();
services.AddScoped(typeof(IRemoteAppExecutionRepository), typeof(EntityFramework.RemoteAppExecutionRepository));
break;
...
}
return services;
}
}
MongoDB
Similar to the Entity Framework section above, for MongoDB you first register your Migration Manager by implementing
the IDatabaseMigrationManagerForPlugIns interface
and then register your repository for the RemoteAppExecutions
collection.
public class DatabaseRegistrar : DatabaseRegistrationBase
{
public override IServiceCollection Configure(IServiceCollection services, DatabaseType databaseType, string? connectionString)
{
Guard.Against.Null(services, nameof(services));
switch (databaseType)
{
case DatabaseType.MongoDb:
services.AddScoped<IDatabaseMigrationManagerForPlugIns, MongoDb.MigrationManager>();
services.AddScoped(typeof(IRemoteAppExecutionRepository), typeof(MongoDb.RemoteAppExecutionRepository));
break;
...
}
return services;
}
}
In the MigrationManager
, configure the RemoteAppExecutions
collection.
public class MigrationManager : IDatabaseMigrationManagerForPlugIns
{
public IHost Migrate(IHost host)
{
RemoteAppExecutionConfiguration.Configure();
return host;
}
}