Business Rules Service
Last updated
Last updated
IBusinessRulesService<TModel>
in assembly SanteDB.Core.Api version 3.0.1980.0
Represents a service that executes business rules based on triggers which happen in the IRepositoryService layer
When a business rules implementation is attached to the service context, or via the AddBusinessRule
method, the SanteDB server call the appropiate Before/After functions on the implementation, before checking the Next
property to follow the next business rule in the chain.
The JavaScript Business Rules Engine which loads data from installed applets is an example of an implementation of this service which translates events into Javascript callbacks. Implementers can use this service to:
Generate unique identifiers or other data and affix it to data
Intercept queries and write requests and perform re-writes
Log, catalog, or update external indexes of data
Cancel or interrupt the default flow of a persistence or query operation
Note: This can be done, instead with events on the persistence layer on the SanteDB datalayer, however there may come a time when a rule is fired without persistence occurring
Property | Type | Access | Description |
---|---|---|---|
Wrapper for IBusinessRulesService which calls one or more JavaScript functions
This implementation of the business rules wrapper is used to interface with business rules written in SanteDB's JavaScript Business Rules Engine and allows implementers to customize the behavior of the iCDR or dCDR with JavaScript within their applets. Whenever a call to the SanteDBBre.AddBusinessRule()
interface is called from applet initialization, a new instance of this class is chained into the execution pipeline. From there, the events raised for before/after insert/update/obsolete/query are translated to JavaScript and the provided callback is executed.
This service implementation is abstract or is a generic definition. It is intended to be implemented or constructed at runtime from other services and cannot be used directly
A business rule for Bundle instances which performs a look-ahead on bundles
Whenever a Bundle is submitted for processing to a SanteDB iCDR or dCDR server, it is important that any JavaScript based business rules for object WITHIN the bundle are executed. However, we don't want to implement this in JavaScript itself since, everytime a bundle is sent to the server, the entire bundle would be prepared (in JSON), passed to the JavaScript JavascriptEngineBridge and then parsed back out regardless of whether there were any rules or not
This business rule prevents this behavior by performing a look-ahead. It will scan the incoming bundle's objects to determine whether a JavaScript based business rule has been registered for the item, if it has, it will then serialize the bundle, and call the appropriate rule for each object.
Represents a business rules service with no behavior, but intended to help in the implementation of another business rules service
This service implementation is abstract or is a generic definition. It is intended to be implemented or constructed at runtime from other services and cannot be used directly
Business rule that calls other DataQualityBusinessRule`1 based on the contents of a bundle
This business rule wraps the insertion or update of a Bundle and calls individual data quality validation rules for each of the objects contained withing the bundle provided.
A business rule that applies user defined data quality rules from the IDataQualityConfigurationProviderService
This business rule template allows users to describe data quality rules (for example, using the application configuration for data quality rules) to be applied to incoming data. This service uses the data quality extension to then flag any warnings or informational issues (error issues result in the object being rejected). These extensions are cleaned by the DataQualityExtensionCleanJob if the object no longer fails the quality rules.
This service implementation is abstract or is a generic definition. It is intended to be implemented or constructed at runtime from other services and cannot be used directly
# Example Implementation ```csharp /// Example Implementation using SanteDB.Core.Services; /// Other usings here public class MyBusinessRulesService : SanteDB.Core.Services.IBusinessRulesService { public String ServiceName => "My own IBusinessRulesService`1 service"; ////// Gets or sets the rule to be run after this rule (for chained rules) ///public IBusinessRulesService Next { get; set; } ////// Called after an insert occurs. ///public TModel AfterInsert(TModel data){ throw new System.NotImplementedException(); } ////// Called after obsolete has been committed ///public TModel AfterDelete(TModel data){ throw new System.NotImplementedException(); } ////// Called after a query has been executed ///public IQueryResultSet AfterQuery(IQueryResultSet results){ throw new System.NotImplementedException(); } ////// Called after retrieve of an object ///public TModel AfterRetrieve(TModel result){ throw new System.NotImplementedException(); } ////// Called after update has been committed ///public TModel AfterUpdate(TModel data){ throw new System.NotImplementedException(); } ////// Called before an insert occurs ///public TModel BeforeInsert(TModel data){ throw new System.NotImplementedException(); } ////// Called before obsolete occurs ///public TModel BeforeDelete(TModel data){ throw new System.NotImplementedException(); } ////// Called before an update occurs ///public TModel BeforeUpdate(TModel data){ throw new System.NotImplementedException(); } ////// Called to validate the data provided ///public List Validate(TModel data){ throw new System.NotImplementedException(); } } ```
Operation | Response/Return | Input/Parameter | Description |
---|---|---|---|
Next
IBusinessRulesService<TModel>
RW
Gets or sets the rule to be run after this rule (for chained rules)
AfterInsert
TModel
TModel data
Called after an insert occurs.
AfterDelete
TModel
TModel data
Called after obsolete has been committed
AfterQuery
IQueryResultSet<TModel>
IQueryResultSet<TModel> results
Called after a query has been executed
AfterRetrieve
TModel
TModel result
Called after retrieve of an object
AfterUpdate
TModel
TModel data
Called after update has been committed
BeforeInsert
TModel
TModel data
Called before an insert occurs
BeforeDelete
TModel
TModel data
Called before obsolete occurs
BeforeUpdate
TModel
TModel data
Called before an update occurs
Validate
List<DetectedIssue>
TModel data
Called to validate the data provided