Use File Service to send files to BPL
This is an InterSystems IRIS Interoperability solution for HTTP calls
This sample was cloned from iris-interoperability-template. I have reconfigured the interoperability Production with an Inbound HTTP Adapter which is used by a HTTP Business Service.
I configured Call Interval setting to call HTTPServer once every hour. You can change both the URL and frequency in the service’s settings.
Originally the HTTP Service had two targets. The response body from each call was sent as a HTTP Generic Message to a BPL business process and also a file operation which saved data to a folder iris-http-calls.
Now the HTTP Service sends a HTTP Generic Message to a file operation. Then a file service sends the file to a BPL business process.
Make sure you have git and Docker desktop installed.
Open IRIS Namespace with Interoperability Enabled.
Open Terminal and call:
USER>zpm “install iris-http-calls”
Clone/git pull the repo into any local directory
git clone https://github.com/oliverwilms/iris-http-calls.git
Open the terminal in this directory and run:
docker-compose build
docker-compose up -d
Open the production and start it if it is not already running. It makes HTTP calls to HTTPServer using URL.
This repository is ready to code in VSCode with the ObjectScript plugin.
Install VSCode, Docker and ObjectScript plugin and open the folder in VSCode.
Use the handy VSCode menu to access the production and business rule editor and run a terminal:
this example shows how you can introduce env variables in your dev environment.
Suppose you need to setup the production with some secret token to access a limited access API.
Of course you don’t want to expose the secret to GitHub.
In this case Env variables mechanism could be helpful.
First introduce .env file and setup .gitignore to filter .env from git.
Then add the secret token in .env in a form ENV_VARIABLE=“TOKEN VALUE”
Next introduce make environment variables be imported to dockerfile. to make it work add the environment section into docker-compose.yml, .e.g:
environment:
- SAMPLE_TOKEN=${SAMPLE_TOKEN}
Then you’ll be able to init the running container with the data from env variables e.g. with the following call, which uses the value from .env file as a setting of the production:
USER> d ##class(dc.Demo.Setup).Init($system.Util.GetEnviron("SAMPLE_TOKEN"))
Users of this module can use parameters to pass data to the module during installation and customize the File Path for the file operation and file service as well as modify URL.
it can be useful when setup parameters are secret tokens to access particular API.
You as a developer can provide such parameters with default tag in module.xml.
<Default Name="FilePath" Value="iris_http_calls" />
<Default Name="UrlModify" Value="/Patient?_id=egqBHVfQlt4Bw3XGXoxVxHg3" />
These default parameters enable users to call the installation of the package with the option of passing of parameters. E.g. the installation call could be run as:
zpm "install iris-http-calls -D FilePath=iris_http_calls -D UrlModify=/MedicationStatement?patient=egqBHVfQlt4Bw3XGXoxVxHg3"
USER>zpm "install iris-http-calls -D FilePath=iris_http_calls -D UrlModify=/MedicationStatement?patient=egqBHVfQlt4Bw3XGXoxVxHg3"
[USER|iris-http-calls] Reload START (/usr/irissys/mgr/.modules/USER/iris-http-calls/0.3.37/)
[USER|iris-http-calls] Reload SUCCESS
[iris-http-calls] Module object refreshed.
[USER|iris-http-calls] Validate START
[USER|iris-http-calls] Validate SUCCESS
[USER|iris-http-calls] Compile START
[USER|iris-http-calls] Compile SUCCESS
[USER|iris-http-calls] Activate START
[USER|iris-http-calls] Configure START
[USER|iris-http-calls] Configure SUCCESS
[USER|iris-http-calls] Activate SUCCESS
The default parameters are used to setup the production in the following call:
<Invoke Class="dc.Demo.Setup" Method="Init" >
<Arg>${FilePath}</Arg>
<Arg>${UrlModify}</Arg>
</Invoke>
Method Init in dc.Demo.Setup class configures File Service and File Operation using the FilePath parameter. The UrlModify parameter is used to modify the URL setting of the HTTP service.