How to interpolate (or concatenate) regex var in TICK batch query string?

I am wondering if it is possible to interpolate (or concatenate) the regex_topic var below into the batch query string, so that the regex is not duplicated? The same about dbrp.

dbrp "telegraf"."autogen"

var battery_warn_level = 15.0
var battery_crit_level = 10.0

// Health topic: OpenCH/DEVICE_TYPE/DEVICE_ID/PubHealth
var regex_topic = /^OpenCH\/(.*)\/([0-9A-Fa-f]{16})\/PubHealth$/
var get_device_type = lambda: regexReplace(regex_topic, "topic", '$1')
var get_device_id = lambda: regexReplace(regex_topic, "topic", '$2')

        SELECT * from "telegraf"."autogen"."mqtt_consumer"
        WHERE topic =~ /^OpenCH\/(.*)\/([0-9A-Fa-f]{16})\/PubHealth$/
            AND "name" = 'battery'

    |eval(get_device_type, get_device_id)
        .as('device_type', 'device_id')


        .message('{{ .Time }}
{{ .Level }} {{ index .Fields "device_type" }} {{ index .Fields "device_id" }}
{{ index .Fields "name" }} {{ index .Fields "value" }}{{ index .Fields "units" }}')

        .warn(lambda: int("value") <= battery_warn_level AND int("value") > battery_crit_level)
        .crit(lambda: int("value") <= battery_crit_level)



Thank you!