ACTIVITY_INSERT()
Prototype
ACTIVITY_INSERT(activity,[task_ref],[condition],[position], [insert_closed], [parameters])
Insert an activity into a TASK in the current ADMISSION.
Input Parameters
Parameter | Type | Default Value | Required | Description |
---|---|---|---|---|
|
| Yes | A TASK code referring to the activity to be inserted | |
|
| No | Supported values:
| |
| true | No | The activity will only be inserted if this parameter has a true value | |
| "LAST" | No | A number indicating the position in the TASK where the activity will be inserted. Additionally, it is possible to indicate one of the following options:
Since API Version 2.7.26 it is possible to indicate a negative value, which is interpreted as the position counting backwards from the last existing FORM | |
| null | No | if 'YES' close the form after insert, otherwise keep it open (formula does not consider CLOSED property of workplan of the task) if there are PARAMETERS set, it can provoke form_close() | |
| null | No | The parameter called parameters allows to provide a list of values that will be assigned to the ITEMS inserted It must be a JSON string representing an array of objects with initial values that will be applied to the ITEMS of the ACTIVITIES. Each array item must be an object with 2 properties:
The values can be either simple values or arrays. The values assigned to each parameter will be stored in the newly created ACTIVITY into the ITEMS whose ITEM_CODE matches the property "code" See the following examples: Example of passing 2 parameters with simple values:
[
{"code":"PARAMETER.RELATIVE", "value":"RELATIVE.PARENT(M)"},
{"code":"PARAMETER.DIAGNOSE.ICD10", "value":"H60.20"}
]
Note that if the TEMPLATE of the new ACTIVITY does not contain an ITEM with a ITEM_CODE named as any of the parameters provided, then a new ITEM will be created (hidden) Example of passing 2 parameters with array values: [
{"code":"HEART_RATE", "value":[87, 97]},
{"code":"HEART_RATE_TIME", "value":["12:00:00","16:00:00"]}
]
If the TEMPLATE of the new ACTIVITY already contains an array of ITEM with ITEM_CODE that match the parameter names, then the necessary rows will be added to fit as many values as provided. Otherwise, a new array of ITEMs will be created (hidden) for each parameter with multiple values
|
Output
As a result of an ACTIVITY_INSERT () formula the "ANSWER" property of the QUESTION will be a reference to the FORM or the REPORT created by the formula.
Execution
on form close (by default)
Examples
Formula | Description |
---|---|
| Conditioned insert: Inserts a an activity (the one with TASK_CODE="F3" in the PROGRAM TEMPLATE) into the current TASK if the reference $1 is equal to 1 or true |
| Inserts a an activity (the one with TASK_CODE="F3" in the PROGRAM TEMPLATE) into the task with task code SPIRO_TASK. The inserted ACTIVITY will be placed the first into the TASK |
| Inserts a an activity (the one with TASK_CODE="F3" in the PROGRAM TEMPLATE) into the task with task code SPIRO_TASK. The inserted ACTIVITY will be placed the first into the TASK and will be closed via form_close |
| generates an activity with task_code SPIRO.TECHASS.PBD in the task with task code SPIRO.TECHASS.BAS and inserts in created form questions with ITEM_CODE = TECHASSCOMM1 and value = result of formula GET_VALUE (TASK, TIME, SCHEDULED), ITEM_CODE = TECHASSQP1 and value with answer of reference question with id = 3 of form where the formula ACTIVITY_INSERT was executed |