Class: ApplicationApi

SanteDBWrapper.ApplicationApi()

new ApplicationApi()

Common functions for accessing SanteDB application processes

Source:

Methods

(static) addIdentifierClassifier(domain, regexClassification)

Adds a new classification map for an identifier

Whenever a random barcode is scanned, it could contain any number of fields and information. This function allows implementers to register a regular expression which the SanteDB plugins can use to determine which domain a particular identifier scanned from an arbitrary data source might contain.
Parameters:
Name Type Description
domain string The domain which is being classified
regexClassification RegExp The classification regex
Source:
See:

(static) addIdentifierGenerator(domain, generatorCallback)

Adds a new identifier generator

An identifier generator function allows SanteDB common controls to generate new, unique identifiers based on custom identity domain logic. For example, if a user wishes to expose to users an option to auto-generate a new unique registration # or input an exisitng one, this function would allow this capability.
Parameters:
Name Type Description
domain string The domain which the generator will create identifiers for
generatorCallback function A function for the generator which returns the new identifier and (optionally) takes the entity for which the identifier is being generated
Source:

(static) addIdentifierParser(domain, parserCallback)

Adds a new identifier parser

Some identifiers scanned from barcodes may contain more than a simple identifier. For example, a WHO DDCC QR code contains other information about the patient such as basic demographics, vaccines, etc. This method allows SanteDB plugins to register and call custom parsing logic for an identity domain.
Parameters:
Name Type Description
domain string The domain to which the parser belongs
parserCallback function The callback function used to parse the identifier
Source:
See:
Example
SanteDB.application.addIdentifierParser("DLN", function(dln, context) { 
     return dln.subString(0, 10);
 });

(static) addResourceViewer(resourceType, redirectCallback)

Adds a new resource state to let other apps know where to go to view a resource

Each redirectCallback is a function which accepts a state parameter (containing the current AngularJS state service) and a series of routing parameters. The redirect callback should determine whether it can handle the passed entity and should perform the redirect and return true.
Parameters:
Name Type Description
resourceType string The type of resource which the redirectCallback should be called for
redirectCallback function A function that directs to the appropriate state. Shoudl return true
Source:
Example
Viewer for patients with no gender only
SanteDB.app.addResourceViewer("Patient", 
     function(state, parms) { 
        if(!parms.genderConcept || parms.genderConcept == NullReasonKeys.NoInformation) {
             state.transitionTo("my-view.patient". parms); 
             return true; 
         }
         return false;
     });

(static) calculatePasswordStrength(password) → {number}

Calculates the strength of the supplied password

Parameters:
Name Type Description
password * The password
Source:
Returns:
The strength of the password between 0 and 5
Type
number

(static) callResourceViewer(resourceType, parms, state) → {boolean}

Call the resource viewer(s) which are registered for the specified type

Parameters:
Name Type Description
resourceType * The type of resource to call the viewers for
parms * The parameters to pass to the viewer (testing if they can handle the resource)
state * The AngularJS state service to user
Source:
Returns:
True if the resource redirect was successful
Type
boolean
Example
Redirect to appropriate resource handler for entity

async viewEntity(id) {
 try {
     var entity = await SanteDB.resources.entity.getAsync(id);
     if(SanteDB.application.callResourceViewer(entity.$type, $state, entity))
     {
         console.info("Redirect successful!");
     }
     else {
         console.warn("Can't find a resource handler", entity);
     }    
 }
 catch(e) {
     console.error(e);
 }
}

(static) classifyIdentifier(value) → {Array}

Attempts to guess the identifier domains to which an identifier belongs based on its format

This method is useful when you're scanning an identifier and need to know which identity domain it may belong to
Parameters:
Name Type Description
value string The value of the identifier
Source:
See:
Returns:
An array of potential identity domains which the value could belong to
Type
Array

(static) close()

Closes the application or restarts it in the case of the mobile

Source:

(static) compactAsync(takeBackup) → {Promise}

Instructs the back-end service to perform a compact

Parameters:
Name Type Description
takeBackup boolean When true, instructs the back end to take a backup of data
Source:
Returns:
A promise representing the fulfillment or rejection of update
Type
Promise

(static) createBackupAsync(makePublic) → {Promise}

Create a backup of current assets on the dCDR (databases, applets, etc.)

Parameters:
Name Type Description
makePublic boolean Instruct the API to store the back in an unsecured, public location (for example, when migrating to another tablet)
Source:
Returns:
Type
Promise

(static) doUpdateAsync() → {Promise}

Instructs the back-end service to perform a system upgrade

Source:
Returns:
A promise representing the fulfillment or rejection of update
Type
Promise

(static) generatePassword() → {string}

Generates a new random password

Source:
Returns:
A new random password
Type
string

(static) getAppInfoAsync(settings) → {Promise}

Get application version information

Parameters:
Name Type Description
settings any The settings to use for the server diagnostic report
Properties
Name Type Description
updates boolean When true check for updates
remote boolean When true check the remote server
Source:
Returns:
The promise from the async representation
Type
Promise

(static) getAppletAssetAsync(appletId, assetPath) → {Promise}

Gets an applet manifest object from the server

Parameters:
Name Type Description
appletId string The identifier of the applet from which you want to fetch something
assetPath string The path within that asset to the content
Source:
Returns:
A promise representing the fetch operation
Type
Promise

(static) getAppSolutionsAsync()

Gets solutions that can be installed on this appliccation

Source:

(static) getBackupAsync() → {Promise}

Get all backups and backup information

Source:
Returns:
The promise representing the fulfillment or rejection
Type
Promise

(static) getIdentifierGenerator(domain)

Gets a generator if one is registered for the specified domain

Parameters:
Name Type Description
domain string The domain to get the generator for
Source:

(static) getIdentifierParser(domain) → {function}

Retrieve identifier parser for the specified domain

Parameters:
Name Type Description
domain string The domain to which the parser belongs
Source:
Returns:
The parser function which can be used to parse identifiers in the specified domain into their component parts
Type
function

(static) getLogInfoAsync(_id, query) → {Promise}

Gets a list of all logs and their information from the server

Parameters:
Name Type Description
_id string The id of the log file to fetch contents of
query any The query filters to use / apply
Source:
Returns:
The promise representing the async request
Type
Promise

(static) getMenusAsync(contextName) → {any}

Get all available user interface menus for the current user

Parameters:
Name Type Description
contextName string The name of the context to retrieve
Source:
Returns:
A structure of menus the user is allowed to access
Type
any

(static) getOnlineState() → {boolean}

Get the online status of the application

Source:
Returns:
True if the application is online
Type
boolean

(static) getResourceViewer(resourceType)

Gets a generator if one is registered for the specified domain

Parameters:
Name Type Description
resourceType string The type of resource to retrieve the viewer for
Source:
Example
Redirect to any resource returned by the Entity API

async viewEntity(id) {
 try {
     var entity = await SanteDB.resources.entity.getAsync(id);
     var viewer = SanteDB.application.getResourceViewer(entity.$type);
     if(viewer) {
         // we have a viewer so call it
         viewer($state, entity)
     }
     else {
         console.warn("Cannot find a viewer for this type of data");
     }
 }
 catch(e) {
     console.error(e);
 }
}

(async, static) getSubTemplates(collection, parms)

Fetches sub-templates

In some templates, sub objects will have no $type, and just a reference to a template mnemonic. This method will take a template object and will resolve these references to other templates. https://help.santesuite.org/santedb/data-and-information-architecture/conceptual-data-model#templates
Parameters:
Name Type Description
collection * The participation or relationship property to be fetched
parms * The parameters to fill the template with
Source:

(static) getTemplateContentAsync(templateId, parms) → {any}

Get a list of all installed template definitions

Parameters:
Name Type Description
templateId string The ID of the template to fetch
parms any The parameters to pass to the template
Source:
Returns:
The templated object
Type
any

(static) getTemplateDefinitionsAsync(query) → {Array.<string>}

Get a list of all installed template definitions

Parameters:
Name Type Description
query any The filter to apply to templates
Source:
Returns:
The list of template definitions
Type
Array.<string>

(static) getVersion() → {string}

Get the version of the application host

Source:
Returns:
The version of the host this applet is running in
Type
string

(static) getWidgetsAsync(context, type)

Get the specified widgets for the specified context

This function allows rendering controls to fetch the widgets registered by all plugins for a particular context.
Parameters:
Name Type Description
context The context to fetch widgets for
type The type of widget to fetch registration information for (panel or tab)
Source:
See:

(static) isAdminAvailable() → {boolean}

Indicates whether the server's AMI is available

This command actually sends a lightweight PING function to the AMI server
Source:
Returns:
True if the AMI is available
Type
boolean

(static) isClinicalAvailable() → {boolean}

Indicates whether the HDSI is available

This command actually sends a lightweight PING function to the HDSI server
Source:
Returns:
True if the HDSI is available
Type
boolean

(static) loadDataAsset(dataId) → {string}

Load a data asset from an applet's Data/ directory

Parameters:
Name Type Description
dataId string The identifier of the data asset to load
Source:
Returns:
The data asset
Type
string

(static) newGuid() → {string}

Create a new UUID

Source:
Returns:
A new unique UUID
Type
string

(static) parseException(exceptionString)

Parses an exception string into a Exception object

Parameters:
Name Type Description
exceptionString string The exception string to be parsed
Source:

(static) purgeAsync(takeBackup) → {Promise}

Instructs the back-end service to perform a purge of all data

Parameters:
Name Type Description
takeBackup boolean True if the back-end should take a backup before purge
Source:
Returns:
The promise representing the fulfillment or rejection
Type
Promise

(static) resolveTemplateForm(templateId) → {string}

Resolves the HTML input form for the specified template

This method allows a plugin to resolve a template identifier (like: entity.tanzania.child) to an actual HTML input form
Parameters:
Name Type Description
templateId string The id of the template for which HTML input should be gathered
Source:
Returns:
The HTML content of the input form for the specified template
Type
string

(static) resolveTemplateView(templateId) → {string}

Resolves the HTML view for the specified template

This method allows a plugin to resolve a template view (to display informaton from the template)
Parameters:
Name Type Description
templateId string The id of the template for which HTML view should be gathered
Source:
Returns:
The HTML content of the view for the specified template
Type
string

(static) restoreAsync() → {Promise}

Instructs the backend to restore the data from the most recent backup

Source:
Returns:
The promise representing the fulfillment or rejection
Type
Promise

(static) scanBarcode() → {string}

Launches the camera on the device to take a picture of a barcode

This method will call the local operating system's implementation of the camera function to scan and decode a barcode. If using SanteDB dCDR Web Access Gateway or dCDR Disconnected Gateway then the HTML5 camera object is used, on Android this calls the Android system camera and ZXing.
Source:
Returns:
The scanned barcode
Type
string

(static) scanIdentifierAsync() → {string}

Scans a barcode using scanBarcodeAsync however interprets the identifier rather than returning the raw data

Source:
See:
Returns:
The interpreted barcode identifier information
Type
string

(static) searchByBarcodeAsync(qrCodeData, noValidate, upstream)

Performs a search using barcode data

This method will use the barcode providers referenced to parse information from the barcode and will search the HDSI for the object which the barcode represents. This method works best with the SanteDB VRP API https://help.santesuite.org/developers/service-apis/health-data-service-interface-hdsi/digitally-signed-visual-code-api
Parameters:
Name Type Description
qrCodeData * The QR Code data already scanned
noValidate * True if the barcode should not be validated
upstream * True if search upstream
Source:

(static) submitBugReportAsync(bugReport) → {Promise}

Submits a user entered bug report

Parameters:
Name Type Description
bugReport any The structured bug report to be submitted
Source:
Returns:
The promise to fulfill or reject the request
Type
Promise

(static) this.printView()

Wraps native printing functionality for the host operating system

Source:

(static) this.ptrSearchAsync(jwsData, validateSignature, upstream)

Perform a search operation on a signed codified search.

This search operation uses signed parameter information (acquired from barcode, message, etc.) to perform a retrieve operation if the signature has not been tampered.
Parameters:
Name Type Description
jwsData * The JSON Web Signature data to search
validateSignature boolean True if the service should validate the data
upstream boolean True if the search should be performed against the upstream server
Source:
See:

(static) this.showToast(text)

Show a toast to the user

This method is used to trigger an operating system TOAST. If you're using the AngularJS interface (like in the administrative or SanteEMR framework) it is recommended to use the toastr interface.
Parameters:
Name Type Description
text string The text of the toast
Source: