Hi Chip,

I believe you need to create a function that extends Ens.Rule.FunctionSet which should then give you the option to select this function within the UI or for usage within the DTL as well depending on your preference of course.  Let me see if I can find an example for you.  Note: I simplified my code to fit closer to your ask, but I did not test it.

Thanks,

Chris

Appendix)

Figure 1) SimplePid3Filter Function call within when clause

Figure 2) SimplePid3Filter function being called via DTL where the return type is As %String (clipped from screenshot)

Within the %SYS namespace the OAuth2 package can be leveraged.  I don't know if there is already a method within that package to accomplish a simple export and import.  However, you can absolutely program the autocreation of the OAuth configurations.  In one of my implementations I was asked to setup a framework to auto create everything via a JSON "settings" file.  To implement I simply looped the OAuth portion of the settings file and then for each OAuth config I set the following p variables:

Set tClient=##class(OAuth2.Client).Open(pApplicationName)
If '$isobject(tClient) {
Set tClient = ##class(OAuth2.Client).%New()
Set tClient.ApplicationName = pApplicationName
}
Set tClient.AuthenticationType ="basic"
Set tClient.ClientId=pClientID
Set tClient.ClientSecret=pClientSecret
Set tClient.ClientType="confidential"
Set tClient.Enabled=1
Set tClient.EncryptionAlgorithm=""
Set tClient.KeyAlgorithm=""
Set tClient.RedirectionEndpoint.Host=pHostName
Set tClient.SSLConfiguration=pSslConfiguration
Set tClient.ServerDefinition=pServerConfig
Set tClient.SigningAlgorithm=""
Set tSC=tClient.%Save()
If $$$ISERR(tSC) quit
Set tClient=##class(OAuth2.Client).Open(pApplicationName)
Set metadata = tClient.Metadata
Set metadata."grant_types"=$lb("authorization_code")
Set tClient.Metadata = metadata
Set tSC=tClient.%Save()

When we save classes in studio or VSCode the files are automatically saved inside cache as well as the dev's local master folder.  This is setup using TortoiseSVN.  Based on Dmitriy's comment I imagine the export as .CLS.xml is setup via this source control setup, TortoiseSVN, instead of the way my individual settings are setup in VSCode.  Here are my settings for reference:

I was able to run the following commands on my local HS 2018 %SYS namespace to create an application:

Set tWebAppName = "/csp/healthshare/samples/myapp"
Set tProperties("NameSpace") = "samples"
Set tProperties("CookiePath") = "/csp/healthshare/samples/myapp/"
Set tProperties("MatchRoles") = "%DB_CACHE:%All"
Set tSC = ##class(Security.Applications).Create(tWebAppName, .tProperties)

The above code works to assign the MatchRoles, but don't know if that answers your question.  I'd suggest running the delete command between attempts via: Set tSC = ##class(Security.Applications).Delete(tWebAppName) until you programmatically get exactly what you are looking to create.

You need to have the inbound message sent to this function.  Let's call it pRequest

#dim tMshSeg As EnsLib.HL7.Segment
#dim tPidSeg As EnsLib.HL7.Segment
Set tNewMsg = ##class(EnsLib.HL7.Message).%New()
Set tNewMsg.DocType = "2.3.1:DFT_P03"
Set tMshSeg = pRequest.getSegmentByPath("MSH", .tStatus) $$$ThrowOnError(tStatus)
Set tPidSeg = pRequest.getSegmentByPath("PID", .tStatus) $$$ThrowOnError(tStatus)
Set tStatus = tNewMsg.setSegmentByPath(tMshSeg, "MSH") $$$ThrowOnError(tStatus)
Set tStatus = tNewMsg.setSegmentByPath(tPidSeg, "PID") $$$ThrowOnError(tStatus)

I believe you are missing parentheses for this particular field:  

<assign value='##class(ClassName.FunctionSet).illnessConv(source.{OBX():ObservationValue()})' property='target.{OBX():ObservationValue()}' action='set' />

Generally, I switch over the field names to numbers as that is easier for me to read:

<assign value='##class(ClassName.FunctionSet).illnessConv(source.{OBX():5})' property='target.{OBX():5}' action='set' />

I'm not sure what schema you are using, but if you are using a schema with repeating OBR or OBX fields then you may also need to loop those as well, respectfully:

<foreach property='source.{OBXgrp()}' key='k1' >
<foreach property='source.{OBXgrp(k1).OBX()}' key='k2' >
<assign value='source.{OBXgrp(k1).OBX(k2):5}' property='target.{OBXgrp(k1).OBX(k2):5}' action='set' />
</foreach>
</foreach> 

You could create the complete SQL string prior to the prepare statement.  There are similiar examples in the documentation here as well: https://docs.intersystems.com/csp/documatic/%25CSP.Documatic.cls?CLASSNAME=%25SQL.Statement
 

set tStatement = ##class(%SQL.Statement).%New()
set tTableName = "" 
for {  
  set tTableName = $O(tCounterAry(tTableName))  
  quit:tTableName="" 
  Set tSqlString = "SELECT COUNT(*) AS ObservedRowCount FROM "_tTableName     set tSC = tStatement.%Prepare(.tSqlString)  
  $$$ThrowOnError(tSC)
  set tResult = tStatement.%Execute()
  // ...
}