Here's a method that might get you close to what you want:

ClassMethod GetHostsByAdapter(pProduction As %String, pAdapterName As %String) As %List
{
        Set tPrd = ##class(Ens.Config.Production).%OpenId(pProduction)
        Return:'$ISOBJECT(tPrd) "Production does not exist!"
        Set tItems = tPrd.Items
        Set tItemCnt = tItems.Count()
        Set tHostList = ""
        Set tCnt = 1
        For i=1:1:tItemCnt
        {
            Set tItem = tItems.GetAt(i)
            If $CLASSMETHOD(tItem.ClassName,"%GetParameter","ADAPTER") = pAdapterName
            {
                Set $LIST(tHostList,tCnt) = tItem.Name
                Set tCnt = tCnt + 1
            }
        }
        Return tHostList
}

Call it with:

Set hosts=##class(<classname>).GetHostsByAdapter("<production name>","EnsLib.HTTP.InboundAdapter")

The variable hosts will contain the list (in $LIST form) of business hosts that have the adapter specified as the 2nd argument.

ClassMethod TestObj() As %DynamicObject

{
        Set oM = {}
        Set mMode = ["down","up","click"]
        Set iter = mMode.%GetIterator()
        While iter.%GetNext(,.val)
        {
            Do oM.%Set(val,{"id":"","type":""})
        }
        Quit oM
}

USER> set oM = ##class(User.DynObj).TestObj()
USER> write oM.%ToJSON()
{"down":{"id":"","type":""},"up":{"id":"","type":""},"click":{"id":"","type":""}}
USER> zwrite oM.down.id
""
USER> zwrite oM.up.type
""
USER> set oM.click.type = "double"
USER> write oM.click.type
double
USER> write oM.%ToJSON()
{"down":{"id":"","type":""},"up":{"id":"","type":""},"click":{"id":"","type":"double"}}

This might get you closer to what you want, perhaps called from OnProcessMessage() in the service:

ClassMethod QueueGetOldest(pQueueName As %String, Output pStatus As %Status) As %String
{
    If ##class(Ens.Queue).GetCount(pQueueName) > 0
    {
        Set tStmt = ##class(%SQL.Statement).%New()                                          
        set qSC = tStmt.%PrepareClassQuery("Ens.Queue","EnumerateItem")
        Set tRS = tStmt.%Execute(pQueueName,"")                        
        Do tRS.%Next()                                                
        Set tHdrid = tRS.%Get("MessageId")
        Set tMsghdr = ##class(Ens.MessageHeader).%OpenId(tHdrid)
        Set pStatus = $$$OK
        Return tMsghdr.TimeCreated
    }
    Set pStatus = $$$ERROR($$$GeneralError,"Not found")
    Return ""
}

It returns the time created of the oldest entry in the queue, or the empty string if the queue is empty or doesn't exist.

You could create a variant that would accept a duration argument and return true/false if the duration between the current time and the time of the oldest entry exceeds that.

The tilde character ("~") has special meaning in HL7; it is normally used as the field repetition character. If it is being included in a field value as a literal character, it is often converted to an "escape sequence" so that it can be delivered to a downstream system intact rather than interpreted as a delimiter; the escape sequence for the field repetition character is \R\.

Is your intended use of the ~ character to function as a repetition delimiter, or is it actually a verbatim part of a field value?

Are you inserting these values into an EnsLib.HL7.Message object? If yes, the standard way of doing this is to first make sure the SPM field you're working with is defined as repeating in the message schema (DocType), then iterate through your list of field values to be inserted.

Assuming your message object is tMsg:

Do tMsg.SetValueAt(Modifier1,"SPM:9(1)")
Do tMsg.SetValueAt(Modifier2,"SPM:9(2)")
Do tMsg.SetValueAt(Modifier3,"SPM:9(3)")

This will automatically use the repetition separator to delimit the values in SPM field 9. Note that the path supplied for the SPM segment/field will vary based on your specific schema definition.

I'm thinking that the value you provided for ElementName  in the service's configuration is incorrect. Your class definition also needs to match the structure of the repeating element, not the entire XML document.

Here's an example XML structure:

<Persons>
    <Person>
        <LastName>Drumm</LastName>
        <FirstName>Jeff</FirstName>
        <FavoriteColor>Red</FavoriteColor>
    </Person>
    <Person>
        <LastName>Herlick</LastName>
        <FirstName>Blakely</FirstName>
        <FavoriteColor>Teal</FavoriteColor>
    </Person>
</Persons>

The classname you'd create would be something like User.Custom.Person, with properties FirstName, LastName and FavoriteColor.

In the service's ElementName field, you'd enter Person. When the file is read, each Person element from the XML would end up in a separate message. You can then filter in the routing rule by using the variables Document.FirstName, Document.LastName, etc. and transform it in the DTL by selecting the Persistent Class User.Custom.Person as the source and your HL7 schema as the target.

Make sense?

Hi Blake,

Can you provide a bit more detail? If you need to create an individual HL7 message for each repeating element in the XML document, my answer here is probably the easiest way to get there. If there's a "master/detail" relationship within the XML, though, you'll need to handle that in a BPL, and perhaps still "chunk" the XML before handing it off to the BPL if there are multiple elements with master/detail relationships. You'd do that with the XML Object file service mentioned in the link (assuming you're getting these XML documents as local files ... there's also an FTP version of the service).

There are tutorials on BPLs in ISC's Learning library.

Hi Nora! Long time laugh

Something like this should do the trick, assuming the file to be appended to is named "spoo.txt" and the file from which you're appending is named "fleem.txt":

    Set tOut = ##class(%File).%New()
    Set tIn = ##class(%File).%New()
    Set tSC = 1
    Set tOut.Name = "spoo.txt"
    Set tIn.Name = "fleem.txt"
    Set sc = tOut.Open("WA")
    Set:$$$ISERR(sc) tSC=$$$ADDSC(tSC,sc)
    Set sc = tIn.Open()
    Set:$$$ISERR(sc) tSC=$$$ADDSC(tSC,sc)
    Quit:$$$ISERR(tSC) tSC
    While 'tIn.AtEnd
    {
        Set sc=tOut.Write(tIn.Read())
        Return:$$$ISERR(sc) sc
    }
    Do tIn.Close()
    Do tOut.Close()
    Return $$$OK

Here's a method that, once created and compiled, will appear in your dropdown list of functions in the rule editor:

Class User.Util.DateTime Extends Ens.Rule.FunctionSet
{

ClassMethod DaysPrior(pDays As %Integer) As %String
{
    Return $ZDATE($H - pDays,8)
}

}

You'd use it in your rule like this:

Caveat: The birthdate is assumed to be valid and 8 characters in length. If there's a possibility that you would get an invalid or missing date, the ">" comparison will not be valid.