Yone, what is the data type of the property "datos" in Mensajes.Response.HistoriaClinica.ConsultaCitasResponse. I assume it's a list of a custom class that has two properties named fecha and hora?

Property datos as List of my.class.dato;

If so, you would do something like this:

set dato=##class(my.class.dato).%New()
set dato.fecha=fecha
set dato.hora=hora
do target.datos.InsertAt(dato,indice)

When the delay expires, Ens.Alarm will send a message back to the business process. You can query to find any messages that have been sent to Ens.Alarm but for which it hasn't sent a message back. This is based on the value of status: the status will be "Delivered" until Ens.Alarm sends the message back to the BP, at which point it will change to "Completed".

SELECT * FROM ens.messageheader WHERE status='Delivered' AND sourceconfigname='MyBPL' AND targetconfigname='Ens.Alarm'

As Eduard mentioned, it would be good to understand the use case as there may be another way to accomplish it.

You're right, this code will not work as-is with fields that exceed the max string size (~ 3 MB). If you expect large fields/segments (such as attachments in OBX:5), there are stream-handling methods that you can use.

If OBX:5 is smaller than the max string size then I don't see any problem regardless of what type of data it contains as the OBX:5 content shouldn't include "^".