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.




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:

You can extract the values you want using $EXTRACT (or $E for short) where * represents the length of your string:

Set tValue = "0003EMRNameC"
Set tValueToLookup = $EXTRACT(tValue,5,*)


You should be able to put it on within the single function call if you prefer as well, but that's up to you.

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)