Looking for a sample Ensemble BusinessService that uses the adapter to download data. Initially I'd like to just build a passthrough service, but I would also like to create an inbound HL7 service and a Record Mapper service.
/// https://docs.intersystems.com/irisforhealth20231/csp/docbook/Doc.View.cls?KEY=EGIN_options_connectivity\
/// https://docs.intersystems.com/irisforhealth20231/csp/docbook/DocBook.UI.Page.cls?KEY=ECLOUD_inbound
/// https://docs.intersystems.com/irisforhealth20231/csp/documatic/%25CSP.Documatic.cls?LIBRARY=ENSLIB&CLASSNAME=EnsLib.CloudStorage.InboundAdapter
Class ARTIS.Adapter.CloudStorage.PassthroughService Extends Ens.BusinessService
{
Parameter ADAPTER = "EnsLib.CloudStorage.InboundAdapter";
/// Configuration item(s) to which to send file stream messages
Property TargetConfigNames As %String(MAXLEN = 1000);
Parameter SETTINGS = "TargetConfigNames:Basic:selector?multiSelect=1&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}";
Parameter CONTAINERCLASS = "Ens.StreamContainer";
/// Wrap the input stream object in a StreamContainer message object and send it. <p>
/// https://docs.intersystems.com/irisforhealth20231/csp/docbook/DocBook.UI.Page.cls?KEY=ECLOUD_inbound#ECLOUD_inbound_bs
/// based on EnsLib.File.PassthroughService but [at least initially] without archive and work folders.<p>
/// We assume our InboundAdapter has the DeleteAfterDownload to prevent pulling the same over and over.
Method OnProcessInput(pInput As EnsLib.CloudStorage.InboundInput, Output pOutput As %RegisteredObject) As %Status
{
// https://docs.intersystems.com/irisforhealth20231/csp/docbook/DocBook.UI.Page.cls?KEY=ECLOUD_inbound#ECLOUD_inbound_bs
#dim tContent As %GlobalBinaryStream = pInput.Content //a stream that contains the data from cloud storage
#dim tMeta As %String = pInput.Meta // metadata associated with the cloud storage blob
#dim tName As %String = pInput.Name // the name of cloud storage blob
#dim tSC,tSC1 As %Status = $$$OK
#dim tSource, iTarget, tOneTarget As %String
#dim tSyncCommit As %Integer
Set tSource=$G(tName) _ $C(10)_$G(tMeta)
// Do I need to convert tContent from binary stream to character stream first?? https://docs.intersystems.com/irisforhealth20242/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_fzconvert#RCOS_fzconvert_handle
Set pInput=$classmethod(..#CONTAINERCLASS,"%New",tContent)
$$$SyncCommitSet(tSyncCommit)
For iTarget=1:1:$L(..TargetConfigNames, ",") { Set tOneTarget=$ZStrip($P(..TargetConfigNames,",",iTarget),"<>W") Continue:""=tOneTarget
$$$sysTRACE("Sending input Stream "_pInput.Stream_"("_pInput.Stream.Size_")"_" from '"_tSource_"' to '"_tOneTarget_"'")
Set tSC1=..SendRequestAsync(tOneTarget,pInput) Set:$$$ISERR(tSC1) tSC=$$$ADDSC(tSC,tSC1)
}
$$$SyncCommitClear(tSyncCommit)
Quit tSC
}
/// Return an array of connections for drawing lines on the config diagram
ClassMethod OnGetConnections(Output pArray As %String, pItem As Ens.Config.Item)
{
Do ##super(.pArray,pItem)
If pItem.GetModifiedSetting("TargetConfigNames",.tValue) {
For i=1:1:$L(tValue,",") { Set tOne=$ZStrip($P(tValue,",",i),"<>W") Continue:""=tOne Set pArray(tOne)="" }
}
}
}
To make it easy to get the SessionId from DTL, BPL, or rules, where the $$$JobCurrentHeaderId macro is not defined, add methods like these to your extended function class that Extends Ens.Rule.FunctionSet:
ClassMethod XCurrentMessageHeaderId() As %String [ CodeMode = expression ]
{
$GET($$$JobCurrentHeaderId)
}
/// Return the current SessionId
ClassMethod XSessionId() As %String [ CodeMode = expression ]
{
$GET($$$JobSessionId)
}
/// Return the current SuperSession
ClassMethod XSuperSession() As %String [ CodeMode = expression ]
{
$GET($$$JobSuperSession)
}
![Open Sesame!](https://community.intersystems.com/sites/default/files/badges/303371180-6de11138-f4e7-4113-b5cc-836269f07693.png)
![1,000 Points](https://community.intersystems.com/sites/default/files/badges/290121674-53216c4b-fe0c-44e7-9d75-2f24390135ed.png)
![Challenge Starter](https://community.intersystems.com/sites/default/files/badges/295959213-b83dd91a-663f-4f07-8e0e-e3287b7c2309.png)
![Curious Member](https://community.intersystems.com/sites/default/files/badges/curious_member_badge.png)
![Thorough Member](https://community.intersystems.com/sites/default/files/badges/thorough_member_badge.png)
![DC Commenter](https://community.intersystems.com/sites/default/files/badges/dc_commenter_1.png)
![DC Problem Solver](https://community.intersystems.com/sites/default/files/badges/dc_problem_solver_1.png)
Nice work! The Docker version ran perfect. I then tried to install and run it on my local IRIS instance with ZPM and I get the execution error:
ERROR <Ens>ErrException: <THROW>CreateFolder+9^dc.samba.SambaBusinessOperation.1 *%Exception.PythonException <PYTHON EXCEPTION> 246 <class 'ModuleNotFoundError'>: No module named 'smbclient' -- logged as '-' number - @' Set sc = ##class(dc.samba.SambaService).CreateFolder(server, port, share, username, password, folder)'
I had run irispip to load smbprotocol, which seemed to run fine:
..\bin\irispip install --target \InterSystems\IRISHealth\python smbprotocol
but the smbclient module still seems to be missing.
What am I missing?
Thanks!!