Assigning a Home Facility
Create a new Business Rules File
/// <reference path="../.ref/js/santedb-bre.js" />
/// <reference path="../.ref/js/santedb-model.js" />
/// <reference path="../.ref/js/santedb.js" />
/**
* Elbonia MPI / SanteMPI Rules for Assigning Facility
* --
*/
Write Assignment Code
/**
* Business rule - Append facility on registration
*/
function appendRegisteringFacility(patient) {
// Only run when not running in master server
if (SanteDBBre.Environment != ExecutionEnvironment.Server) {
// Prepare relationship
try {
if (!patient.relationship)
patient.relationship = {};
// Get the configured facilities
var facility = SanteDBDcg.GetFacilities().resource[0];
// Assign the facility as the SDL
patient.relationship.ServiceDeliveryLocation = new EntityRelationship({
target: facility.id
});
}
catch (e) {
console.error("Error assigning facility: " + e);
}
}
return patient;
};Attach the Business Rule
Last updated
Was this helpful?