Xplain.Db.Session

Xplain.Db.Session()

Xplain.Db.Session reflects an analysis session used on the Xplain backend.

clearSelection

clearSelection([settings][, selectionSet=globalSelections])

Clears a selection.

Warning

This method id deprecated! Use clearSelection in Xplain.Db.Attribute instead.

Parameters
  • (optional) (function selectionSet=globalSelections) – A set of key/value pairs that configure the clearSelection request. All settings are optional. A default can be set using the Xplain.Db.Configuration.setDefaults() method.

  • (optional) – defines if the request sent to the backend should be asynchronous or synchronous.

  • (optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).

  • (optional) – The URL used for this request.

  • (optional) – number of milliseconds until a timeout will be triggered.

  • (optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be the resulting data.

  • (optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.

  • (optional) – the selectionSet for which the selections should be cleared. Defaults to globalSelections

closeAllQueries

closeAllQueries([settings])

Closes all currently opened queries.

Parameters
  • (optional) (function settings.error=f(data){throw new Xplain.Db.Exception}) – A set of key/value pairs that configure the closeAllRequests method. All settings are optional. A default can be set using the Xplain.Db.Configuration.setDefaults() method.

  • (optional) – defines if the request sent to the backend should be asynchronous or synchronous.

  • (optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).

  • (optional) – The URL used for this request.

  • (optional) – number of milliseconds until a timeout will be triggered.

  • (optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be the resulting data.

  • (optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.

execute

execute()

This is a synonym for request the request method.

find

find(target)

This is a synonym for get the get method.

Parameters

target (string|object) – The element you are looking for

Returns

{Xplain.Db.Object | Xplain.Db.Dimension | Xplain.Db.Attribute} the object, dimension, attribute or null.

findGlobalSelection

findGlobalSelection(attribute)

Checks if there is a global selection defined for the attribute given. If so, this selection will returned. Otherwise, false will be returned. The attribute may be specified in any format (object- or string notation).

Parameters

attribute (Xplain.Db.Attribute|PlainObject|String) – The attribute for which you would like to find global selections. May be specified as string or as object, e.g. "Patients.Gender.Gender" or {object: "Patients", dimension: "Gender", attribute: "Gender"}

Returns

{Xplain.Db.Selection|Boolean} the global selection found or false if no selection could be found.

findObject

findObject(objID)

(Recursively) find and return an object by it’s ID

Parameters

objID (string) – the ID of the object

Returns

{Xplain.Db.Object|false} the object with the corresponding ID or false if object does not exist

findPredictiveModel

findPredictiveModel(targetName)

Find and return a predictive models by its name.

Parameters

targetName (string) – The name of the PredictiveModel, i.e. the name of its target

Returns

{PredictiveModel | false} An instance of PredictiveModel. false if no pred. model could be found.

findQuery

findQuery(querID)

Find a query by it’s id.

Parameters

querID (string) – the id of the query to be fetched. The id is case sensitive.

Returns

{Xplain.Db.Query|boolean} the found query or boolean false if no query with the corresponding id could be found.

findSelection

findSelection(attribute, selectionSet)

Checks if there is a selection defined for the attribute and the selectionSet given. If so, this selection will returned. Otherwise, false will be returned. The attribute may be specified in any format (object- or string notation).

Parameters
  • attribute (Xplain.Db.Attribute|PlainObject|String) – The attribute for which you would like to find global selections. May be specified as string or as object, e.g. "Patients.Gender.Gender" or {object: "Patients", dimension: "Gender", attribute: "Gender"}

  • selectionSet (string) – Name of the selectionSet. Defaults to globalSelections

Returns

{Xplain.Db.Selection|Boolean} the global selection found or false if no selection could be found.

findSequence

findSequence(sequName)

Returns the sequence (as plain JSON Object) with name sequName or false if corresponding sequence could not be found.

Parameters

sequName (string) – The name of the sequence to find.

Returns

{plainObject|boolean} the plain JSON representation of the sequence of false if sequence could not be found.

get

get(target)

Find an object, dimension or attribute. The input parameter describes the object / dimension / attribute you are looking for either as string (in Dot-Notation) or as object (a JSON object). The parameter may contain of up to three parts. If the input contains of one part, an object with the corresponding ID will be returned (or null if no object could be found). If the input contains of two parts, a dimension will be returned where the first part contains the ID of the object and the second part contains the ID of the dimension. If the input contains of three parts, an attribute will be returned - 1. part = object, 2. part = dimension and 3. part = attribute.

Examples:

...
// returns the object with ID Patient
// (or null if no object could be found)
var myObj = mySession.get('Patient');

// returns the dimension with ID Birthdate
// within the object Patient
var myDim = mySession.get('Patient.Birthdate');

// returns the attribute with ID Age within the
// dimension Birthdate within the object Patient
var myAttr = mySession.get('Patient.Birthdate.Age');

// returns the same attribute as the request above
// but input is given in JSON notation
var myAttr2 = mySession.get({object:'Patient', dimension:'Birthdate', attribute:'Age'});

// BTW: these statements would return the same attribute
var sameAttr1 = myDim.get('Age');
var sameAttr2 = myObj.get('Birthdate.Age');

NOTE: instead of passing a string, you may also pass an object with consists of three properties (object, dimension and attribute) to this method. For instance:

// returns the attribute with ID Age within the
// dimension Birthdate within the object Patient
var myAttr = mySession.get({object: 'Patient', dimension: 'Birthdate', attribute: 'Age'});
Parameters

target (string|object) – The element you are looking for (see description for details)

Returns

{Xplain.Db.Object | Xplain.Db.Dimension | Xplain.Db.Attribute} the object, dimension, attribute or null.

getAllObjects

getAllObjects()

returns an array of all objects that this session consists of.

Returns

{Array} an array of Xplain.Db.Object instances

getCurrentXStartup

getCurrentXStartup()

Returns the filename of the XStartup currently being used @returns {string} the filename of the XStartup

getGlobalSelections

getGlobalSelections()

Returns an array of all selections set in the globalSections selectionSet, i.e. an array of Xplain.Db.Selection instances. This is basically a short hand method for getSelections("globalSelections").

Returns

{Array} of all currently set global selections.

getNamedPathToObject

getNamedPathToObject(objID)

Returns the path to an object as a set of strings, i.e. a set of object IDs like [“Patient”,”Prescriptions”].

Parameters

objID (string) – the ID of the object

Returns

{Array|boolean} An array of object IDs, i.e. the path to the object. false if object does not exist

getObjects

getObjects()

This is a synonym for getAllObjects the getAllObjects method.

Returns

{Array} an array of Xplain.Db.Object instances

getPathToObject

getPathToObject(objID)

Returns the path to an object that is needed to navigate the raw data returned from the backend. May return something like [“focusObject”, “childObjects”, 0]

Parameters

objID (string) – the ID of the object

Returns

{Array|boolean} An array to navigate raw data. false if object does not exist

getPredictiveModels

getPredictiveModels(options)

Returns an object that consist of several predictive models created so far. Each predictive model is represented as an object.

Parameters

options (object) – Currently only one option is supported: if format is set to raw, the predictiveModels object is returned as provided by the backend.

Returns

{object | false} An object that consist of several predictive models created so far. false if no pred. model has been created so far.

getProgress

getProgress([settings])

Returns the progress of the request currently being executed by the backend..

Parameters
  • (optional) (function settings.error=f(data){throw new Xplain.Db.Exception}) – A set of key/value pairs that configure the getProgress method. All settings are optional. A default can be set using the Xplain.Db.Configuration.setDefaults() method.

  • (optional) – defines if the request sent to the backend should be asynchronous or synchronous.

  • (optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).

  • (optional) – The URL used for this request.

  • (optional) – number of milliseconds until a timeout will be triggered.

  • (optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be the resulting data.

  • (optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.

getQueries

getQueries()

Returns an array of all queries defined in this session.

Returns

{Array} an array of Xplain.Db.Query instances.

getRawData

getRawData()

returns this session’s data as it has been returned by the backend.

Returns

{PlainObject} the data as returned from the backend.

getRootObject

getRootObject()

returns the root object of this session

Returns

{Xplain.Db.Object} the root object

getSelectionSets

getSelectionSets()

Returns an array of all names of all selection sets, e.g. [“globalSelections”,”selectionSet1”]

Returns

{Array} of all selection set names

getSelections

getSelections(selectionSet)

Returns an array of all selections set in a given selectionSet, i.e. an array of Xplain.Db.Selection instances.

Parameters

selectionSet (string) – name of the selectionSet for which you would like to get all selections

Returns

{Array} of all currently selections set in the given selectionSet. Defaults to globalSelections

getSequences

getSequences()

Returns a array with all names of all available sequences.

Returns

{array} The array with all names of all available sequences.

isCachedEnabled

isCachedEnabled()

returns the current status of the “cachingEnabled” flag for this session.

Returns

{boolean} the current status of the “cachingEnabled” flag for this session.

refetch

refetch([settings])

Refetch the current session from the backend.

Parameters
  • (optional) (function settings.error=f(data){throw new Xplain.Db.Exception}) – A set of key/value pairs that configure the request method. All settings are optional. A default can be set using the Xplain.Db.Configuration.setDefaults() method.

  • (optional) – defines if the request sent to the backend should be asynchronous or synchronous.

  • (optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).

  • (optional) – The URL used for this request.

  • (optional) – number of milliseconds until a timeout will be triggered.

  • (optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be the resulting data.

  • (optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.

request

request([request][, settings])

If you would like to use one of Xplains Web API functions directly, you may use this method to send a generic request to the backend.

For instance, you may call the backends WebAPI method removeObject. To do so, set the first parameter request to something like this:

{
    "method": "removeObject",
    "objectName": "Prescription"
}

More details regarding the Web API can be [found here](Web_API).

NOTE: This method accepts additional parameters in the settings object: method and contentType. Both parameters are described in more detail below. In addition, the url parameter, if set, is not extended by the suffix xplainsession.

Parameters
  • (optional) (function settings.then=f(data){}) – the method object you would like to send to the backend.

  • (optional) – A set of key/value pairs that configure the request method. All settings are optional. A default can be set using the Xplain.Db.Configuration.setDefaults() method.

  • (optional) – defines the AJAX method used for this request. Has to be either POST or GET. Defaults to POST.

  • (optional) – defines the contentType used for this AJAX request. Defaults to text/plain.

  • (optional) – defines if the request sent to the backend should be asynchronous or synchronous.

  • (optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).

  • (optional) – The URL used for this request.

  • (optional) – number of milliseconds until a timeout will be triggered.

  • (optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be the resulting data.

  • (optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.

  • (optional) – function what will be triggered if request finishes (no matter if successful or with an error). The first parameter passed to this function will be the resulting data.

select

select([settings])

Sets and executes a selection or a set of selections. These selections will be global-selections and will therefore influence the result of each query executed later on.

Warning

This method id deprecated! Use select in Xplain.Db.Attribute instead.

Parameters
  • (optional) (function settings.error=f(data){throw new Xplain.Db.Exception}) – A set of key/value pairs that configure the select request. All settings are optional. A default can be set using the Xplain.Db.Configuration.setDefaults() method.

  • (optional) – defines if the request sent to the backend should be asynchronous or synchronous.

  • (optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).

  • (optional) – The URL used for this request.

  • (optional) – number of milliseconds until a timeout will be triggered.

  • (optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be the resulting data.

  • (optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.