Business Rules Service
Last updated
Was this helpful?
Last updated
Was this helpful?
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 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 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
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
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
# 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(); } } ```
Wrapper for which calls one or more JavaScript functions
This implementation of the business rules wrapper is used to interface with business rules written in 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.
A business rule for instances which performs a look-ahead on bundles
Whenever a 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 and then parsed back out regardless of whether there were any rules or not
Business rule that calls other based on the contents of a bundle
This business rule wraps the insertion or update of a 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
This business rule template allows users to describe data quality rules (for example, using ) 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 if the object no longer fails the quality rules.