new ParameterService()
Service for accessing the Pure JS analogue of the VISTA Parameter services.
Entities
Prefix Message Points to File
------- ---------- ------------------------
PKG Package Package (9.4)
SYS System Domain (4.2)
DIV Division Institution (4)
SRV Service Service/Section (49)
LOC Location Hospital Location (44)
CLS Class Usr Class (8930)
USR User New Person (200)
Methods
-
addChange(name, opts, value, cb)
-
Add or update a parameter from the parameter service data entries in the data source.
Parameters:
Name Type Description name
String Name of the parameter to query
opts
Object Query options (see 'get')
Properties
Name Type Description entity
String | Array Entity/Entities to query for. This can be:
- Entity code (see above) which will use the associated value in the session context object
- 'ALL' which specifies all entities in the parameter definition.
- Hard-coded entity IDs
- An array of all of the above
instance
String Optional instance to query for (default: '1')
value
String Value to set for this parameter
cb
function Optional asynchronous completion handler, with error-first signature. If "cb" is specified, it will be called on completion of the query. If it is not specified, a Promise object will be returned.
Returns:
If "cb" is not specified, the function will return a Promise.
- Type
- Promise
-
addChangeMultiple(parameters, cb)
-
Add or change mulitple parameters from the parameter service in one shot. This function uses the 'async' library to run multiple asynchronous write queries in a series, which obviates the need for promise chaining and closures when checking then updating or newly creat multiple named parameters.
Each parameter request can use its own unique set of query criteria. To use this method You would create an object with the following characteristics:
- key: The parameter name to request
- value: The parameter query options ('opts' in the 'get' function)
The results of the callback will be an object with the following properties:
- key: The parameter name of the results
- value: Array of results
Parameters:
Name Type Description parameters
Array Array of objects containing mulitple data sets to check for existence then write
- label: The parameter name to request
- value: The parameter write value ('opts' in the 'addChange' function)
- entity: The parameter query options ('opts' in the 'addChange' function)
- inst: The parameter query options ('opts' in the 'addChange' function)
cb
function Optional callback to call on completion ((err, result) function signature). The 'result' of the callback function will be an object with the following properties:
- key: The parameter name of the results
- value: Array of results
Returns:
Promise resolved when the parameter is returned
- Type
- Promise
Example
ParameterService.withContext(context).addChangeMultiple([{ 1: 'B^frmFrame^98,106,809,601', 2: 'W^frmProblems.pnlLeft^159', 3: 'W^frmOrders.pnlLeft^117', 4: 'W^frmNotes.pnlLeft^176', 5: 'W^frmConsults.pnlLeft^83', }]; }, (err, res) => { //Response will be copy of an array with all the JSON objects that were just updated or created in the database [ { _id: sampleMongoId value: '102,107,801,594', instance: 'frmPtSel', localStationNumber: 6100, id: 'urn:vista:6100:8989_5:2493', parameter: { label: 'ORWCH BOUNDS', id: 'urn:vista:6100:8989_51:204' }, entity: { id: 'urn:vista:6100:200:63' }, __v: 0 } ] });
-
get(name, opts, cb)
-
Get a parameter from the parameter service data entries in the data source.
Parameters:
Name Type Description name
String Name of the parameter to query
opts
Object Query options (see 'get')
Properties
Name Type Description entity
String | Array Entity/Entities to query for. This can be:
- Entity code (see above) which will use the associated value in the session context object
- 'ALL' which specifies all entities in the parameter definition.
- Hard-coded entity IDs
- An array of all of the above
instance
String Optional instance to query for (default: '1')
cb
function Optional asynchronous completion handler, with error-first signature. If "cb" is specified, it will be called on completion of the query. If it is not specified, a Promise object will be returned.
Returns:
If "cb" is not specified, the function will return a Promise.
- Type
- Promise
-
getMultiple(parameters, cb)
-
Get mulitple named parameters from the parameter service in one shot. This function uses the 'async' library to run multiple asynchronous queries in parallel, which obviates the need for promise chaining and closures when grabbing multiple named parameters.
Each parameter request can use its own unique set of query criteria. To use this method You would create an object with the following characteristics:
- key: The parameter name to request
- value: The parameter query options ('opts' in the 'get' function)
The results of the callback will be an object with the following properties:
- key: The parameter name of the results
- value: Array of results
Parameters:
Name Type Description parameters
Object Query object containing mulitple parameter query requests:
- key: The parameter name to request
- value: The parameter query options ('opts' in the 'get' function)
cb
function Optional callback to call on completion ((err, result) function signature). The 'result' of the callback function will be an object with the following properties:
- key: The parameter name of the results
- value: Array of results
Returns:
Promise resolved when the parameter is returned
- Type
- Promise
Example
ParameterService.withContext(context).getMultiple({ 'ORQQCSDR CS RANGE START': { entity: 'ALL' }, 'ORQQCSDR CS RANGE STOP': { entity: 'ALL' }, }, (err, res) => { // At this point, 'res' is an object that contains: // { // 'ORQQCSDR CS RANGE START': [{Parameter Entries}], // 'ORQQCSDR CS RANGE STOP': [{Parameter Entries}], // } });
-
remove(name, opts, cb)
-
Delete a parameter from the parameter service data entries in the data source.
Parameters:
Name Type Description name
String Name of the parameter to query
opts
Object Query options (see 'get')
Properties
Name Type Description entity
String | Array Entity/Entities to query for. This can be:
- Entity code (see above) which will use the associated value in the session context object
- 'ALL' which specifies all entities in the parameter definition.
- Hard-coded entity IDs
- An array of all of the above
instance
String Optional instance to query for (default: '1')
cb
function Optional asynchronous completion handler, with error-first signature. If "cb" is specified, it will be called on completion of the query. If it is not specified, a Promise object will be returned.
Returns:
If "cb" is not specified, the function will return a Promise.
- Type
- Promise