Workflow engine is configured by zen. We do not support it and do not recommend to use it anymore. Please, use any other workflow engine e.g. Temporal .

Since the 2405 release, using Aidbox in FHIR schema validation engine is recommended, which is incompatible with zen or Entity/Attribute options.

Setup Aidbox with FHIR Schema validation engine

awf.task/subscribe

Task that will be in progress until a resource with the specified attributes would be persisted in the database. It is used for some workflow cases when the workflow should wait for resource creation.

Params

ParameterTypeRequiredDescription
select-bystringtrueRule written on subscription trigger rule DSL.

Result

ParameterTypeDescription
resourceobjectThe resource that triggered the task completion.

Example

POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.task/create-and-execute
params:
  definition: awf.task/subscribe
  params:
    select-by: 
      - get-in: 
        - resourceType
        comparator: eq
        value: Patient

awf.task/wait

Task that will wait for the indicated duration or until the indicated datetime. Used in workflow when need to be paused for some purposes.

Either duration or until parameter SHOULD be specified.

Params

ParameterTypeRequiredDescription
durationobjectfalseThe task will wait for this duration
duration.hoursintegerfalseduration value in hours
duration.minutesintegerfalseduration value in minutes
duration.secondsintegerfalseduration value in seconds
untildatetimefalse

The task will wait for until this datetime. Need to indicate in string of valid FHIR datetime -
YYYY-MM-DD or

YYYY-MM-DDThh:mm:ss+zz:zz

Example: "1905-08-23", "2015-02-07T13:28:17-05:00" or "2017-01-01T00:00:00.000Z"

Result

No result

Example

POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.task/create-and-execute
params:
  definition: awf.task/wait
  params:
    duration:
      hours: 4
      minutes: 30
{1 {:class "text-tint-12"}}

awf.workflow/decision-task

Decision tasks - special tasks that form the body of the workflow and partially execute it in certain iterations. Decision tasks are created when a workflow is started or as a response on another event to decide what action should be taken. Actions are predefined in task execution operations that are used as a response to a completed decision task. Actions are used in certain cases, such as starting a new task.

Decision tasks should also include an event that should represent the purpose of that task as a parameter.

Params

ParameterTypeRequiredDescription
eventstringtrueType of event.
Example: awf.workflow.event/workflow-init
workflow-idstringfalseId of completed workflow instance. Required only if event type is awf.workflow.event/workflow-completed
task-idstringfalseId of completed task instance. Required only if event type is awf.workflow.event/task-completed

Event types

Event typeDescription
awf.workflow.event/workflow-initFirst task execution in the context of the current workflow instance. The decision task contains this event if it was started using the awf.workflow/create-and-execute method.
awf.workflow.event/task-completedReaction to a completed task started by the current workflow. Includes the ID of the completed task instance in the decision task parameters.
awf.workflow.event/workflow-completedReaction to a completed workflow started by the current workflow. Includes the ID of the completed workflow instance in the decision task parameters.

Result

ParameterTypeRequiredDescription
actionstringtrueType of action.
Example: awf.workflow.action/schedule-task
task-requestobjectfalse

Object with task execution request. Required only if action type is awf.workflow.action/schedule-task or

awf.workflow.action/schedule-workflow

task-request.

definition

stringfalseDefinition of predefined task or
custom-defined task.
Example: aidbox.archive/create-archive
task-request.
label
stringfalseHuman- or machine-readable description of task instance. Should be unique in the context of single workflow.
Example: Import Patient resources
task-request.
params
objectfalseThe input parameters described in the task or workflow definition.

Action types

Action typeDescription
awf.workflow.action/schedule-taskUsed to schedule the execution of a new task from current workflow. Requires task request object in the response.
awf.workflow.action/schedule-workflowUsed to schedule the execution of a new workflow from current workflow. Requires workflow request object in the response.
awf.workflow.action/do-nothingUsed to wait until the next event occurs when multiple tasks have been started in parallel, but when some tasks are completed, other tasks are still in progress.
awf.workflow.action/complete-workflowUsed when all tasks have been completed to change the status of the workflow instance to done with outcome succeeded.
awf.workflow.action/failUsed when some tasks have failed to change the status of the workflow instance to done with outcome failed with handled error.
awf.workflow.action/unknown-errorUsed when some tasks have failed to change the status of the workflow instance to done with outcome failed with unknown error.
{1 {:class "text-tint-12"}}

Import resource task

Loading resource in specified format (.gzip or .ndjson) from specified url and persists it into Aidbox database.

Params

ParameterTypeRequiredDescription
idstringfalseIdentifier of the import.
If you don't provide this, the id will be auto-generated. You can check it on Content-Location header in the response
contentEncodingstringfalseSupports gzip or plain (non-gzipped .ndjson files)
inputobjecttrueResource to import
input.urlstringtrueURL from which load resources
input.resourceTypestringtrueResource type to be loaded
typestringfalseType of persisted resource
Possible values: fhir, aidbox

Example

POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.task/create-and-execute
params:
  definition: aidbox.bulk/import-resource-task
  params:
    type: aidbox
    input:
      url: https://storage.googleapis.com/aidbox-public/synthea/100/Organization.ndjson.gz
      resourceType: Organization
  
{1 {:class "text-tint-12"}}

ingestion/map-to-fhir-bundle-task

Task that applies lisp/mapping to the given context and applies the result to the database as a bundle in either fhir or aidbox formats.

Params

ParameterTypeRequiredDescription
mappingstringtrueReference to a defined lisp/mapping.
contextobjecttrueInitial data.
formatstringtrueBundle format.
Possible values: fhir, aidbox

Example

{ns     my-mappings
 import #{lisp}
 
 my-mapping
 {:zen/tags #{lisp/mapping}
  :mapping  {:resourceType "Bundle"
             :type "transaction"
             :entry [{:resource {:resourceType "Patient"}
                      :request {:method "PUT"
                                :url "/Patient/zero"}}

                     {:resource {:resourceType "Observation"
                                 :status (get :status)
                                 :code {:coding [{:system "http://loinc.org"
                                                  :code "8867-4"
                                                  :display "Respiratory rate"}]
                                        :text "Breathing Rate"}
                                 :subject {:reference "Patient/zero"}
                                 :effectiveDateTime (get-in [:br 0 :dateTime]),
                                 :valueQuantity   {
                                                   :value (get-in [:br 0 :value :breathingRate]),
                                                   :unit "breaths/minute",
                                                   :system "http://unitsofmeasure.org",
                                                   :code "/min"}}
                      :request {:method "POST"
                                :url "/Observation"}}]}}}
POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.task/create-and-execute
params:
  definition: ingestion.core/map-to-fhir-bundle-task
  params:
    format: fhir
    mapping: my-mappings/my-mapping
    context: 
      br: 
        - value: 
            breathingRate: 17.8
        - dateTime: 2021-10-25
      status: final

awf.task/clean-up-activities

Deletes AidboxTask, AidboxTaskLog and AidboxWorkflow resources that are in done state according to specified rules.

When the workflow is matched by the rule, all activities requested by that workflow as AidboxTask and AidboxWorkflow would also be deleted. If task is matched by the rule, all it's AidboxTaskLog resources would also be deleted.

When includeDefinitions is specified, only activities with listed definitions will be deleted.
When excludeDefinitions is specified, all activities are deleted except for activities with the listed definitions.
If both includeDefinitions and excludeDefinitions are not specified, deletes all resources that match retentionPolicy.

If multiple rules are listed, all rules are applied.
Can be used with the Scheduler service to automatically clean up old tasks and workflows.

Params

ParameterTypeRequiredDescription
rulesobject[]true

Array of cleanup rules.

At least 1 rule is required.

rules[].retentionPolicyobjecttrue

Policy that manages the length of time resources are kept. Resources that are not within this time period will be deleted.

Example: {"unit": "hour", "value": 1} - means that any resource updated more than 1 hour ago will be deleted.

rules[].retentionPolicy.unitstringtrueTime units.
Possible values: minute, hour, day, week, month, year
rules[].retentionPolicy.valueintegertrueNumber of time units.
rules[].includeDefinitionsstring[]false

List of task/workflow definitions that would be affected by this rule.

Example: ["aidbox.bulk/import-resource-task"]

Exclusive with rules.excludeDefinitions

rules[].excludeDefinitionsstring[]false

List of task/workflow definitions that would be ignored by this rule. In this case, the rule would be applied to all AidboxTask, AidboxTaskLog and AidboxWorkflow resources except the listed definitions.

Example: ["aidbox.bulk/import-resource-task"]

Exclusive with rules.includeDefinitions

POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.task/create-and-execute
params: 
  definition: awf.task/clean-up-activities
  params: 
    rules:
      - retentionPolicy:
          unit: minute
          value: 1
        includeDefinitions:
          - aidbox.bulk/import-resources-workflow

aidbox.task/run-sql

Executes the given SQL query. If given is array, executes given as prepared statement.
If the query result is greater than 1000 rows, an error is returned.

Params

ParameterTypeRequiredDescription
sqlstring
or
string[]
trueSQL query or prepared statement.
POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.task/create-and-execute
params: 
  definition: aidbox.task/run-sql
  params: 
    sql:
      - SELECT id FROM Patient WHERE id=? LIMIT 1;
      - 'pt-1'

aidbox.task/run-rpc

Executes the given Aidbox RPC-method with params.

Params

ParameterTypeRequiredDescription
methodstringtrueDefinition of the RPC-method.
paramsobjectfalseParams of the RPC-method.
POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.task/create-and-execute
params: 
  definition: aidbox.task/run-rpc
  params: 
    method: aidbox.pg/vacuum-table
    params:
      table: patient
      analyze: true

aidbox.validation/resource-types-bath-validation-workflow

Executes validation on given table names. Creates a task for every table.

Note: for every broken target resource creates a BatchValidationError resource.

POST /rpc
content-type: text/yaml
accept: text/yaml

method: awf.workflow/create-and-execute
params: 
  definition: aidbox.validation/resource-types-batch-validation-workflow
  params: 
    tables: ['patient', 'observation']