Dockerized OpenHIM Mediators

Hello All,

We are trying to include OpenHIM in an environment where they preferably use Docker. After talking with a few folks from Jembi we were able to locate a docker compose file for the basic OpenHIM install with
openhim-core and openhim-console.

But we need to include a couple mediators as well in the install. I am pretty new to docker and have only conceptual knowledge. After discussing with people working with Docker and giving a brief idea of how
a mediator and openhim core work their suggestion was to use Volumes in docker compose to copy mediator files (usually stored in /usr/share/ and available in github) and a separate volume for implementation specific scripts or resources like shell scripts
(one of the mediator we are using is the Shell script mediator).

I am reaching out to see if anyone in the community have experience with dockerizing mediators or have an idea/best practice examples for this architecture(OpenHIM/Mediators) or how a similar example in docker
would be.

— Thanks and Regards,

**Sri Maurya Kummamuru |Systems Engineer

Tel 317-640-2458 | Skype srimaurya23

image001.png

1101 West Tenth Street

Indianapolis, IN 46202

Web and email addresses, and phone numbers will remain the same.

Tel 317-274-9234 | Fax 317-274-9303

Twitter: @Regenstrief | Facebook.com/regenstriefinstitute

www.regenstrief.org

Confidentiality Notice: The contents of this message and any files transmitted with it may contain confidential and/or privileged information and are intended solely
for the use of the named addressee(s). Additionally, the information contained herein may have been disclosed to you from medical records with confidentiality protected by federal and state laws. Federal regulations and State laws prohibit you from making
further disclosure of such information without the specific written consent of the person to whom the information pertains or as otherwise permitted by such regulations. A general authorization for the release of medical or other information is not sufficient
for this purpose.

If you have received this message in error, please notify the sender by return e-mail and delete the original message. Any retention, disclosure, copying, distribution
or use of this information by anyone other than the intended recipient is strictly prohibited.

Hello @maurya , At openmrs with PLIR andHAPI fHIR we are trying to implement such kind of work, Am also facing this scenario setting up docker environments for openhim mediators,Did you finally succeed with this, is there any documentation that you can share please thanks

1 Like

Hi, We ended up going another route of implementing openhim and its mediators using Ansible roles. There isn’t any documentation and the code is in private repos but this is an example ansible role of how you can deploy the mediators. You need to tweak them to work for your environment or use case. Also, this can be used as a reference of what you need to do to implement in docker -

  - name: download file-queue mediator
get_url:
  url: https://github.com/jembi/openhim-mediator-file-queue/archive/{{ file_queue_mediator_branch_or_tag }}.tar.gz
  dest: /tmp/file-queue-mediator.tar.gz
  timeout: 60
tags: file-queue-mediator

  - name: creates file-queue mediator directory
file: path=/usr/share/openhim-mediator-file-queue state=directory
tags: openhim

  - name: unarchive file-queue mediator
unarchive:
  src: /tmp/file-queue-mediator.tar.gz
  dest: /usr/share/openhim-mediator-file-queue
  extra_opts: --strip-components=1
  remote_src: yes
tags: file-queue-mediator

  - name: add file-queue mediator config
template: src=config.json.j2 dest=/usr/share/openhim-mediator-file-queue/config/config.json
tags: file-queue-mediator

  - name: install git for use in npm install
yum: name=git state=present
tags: file-queue-mediator

  - name: install file-queue mediator dependencies
command: npm install chdir=/usr/share/openhim-mediator-file-queue
tags: file-queue-mediator

  - name: add file-queue mediator service
template: src=openhim-mediator-file-queue.service.j2 dest=/etc/systemd/system/openhim-mediator-file-queue.service
tags: file-queue-mediator

     - name: read new service
command: systemctl daemon-reload
tags: file-queue-mediator

 - name: run file-queue mediator
service: name=openhim-mediator-file-queue state=started enabled=yes
tags: file-queue-mediator

and the service file template used to register the mediator with OpenHIM core and restart it is

[Unit]
Description=File Queue OpenHIM Mediator

[Service]
WorkingDirectory=/usr/share/openhim-mediator-file-queue
ExecStart=/usr/bin/npm start
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=file-queue-mediator
Environment=NODE_ENV=production {{ 'NODE_TLS_REJECT_UNAUTHORIZED=0 ' if (allow_self_signed == 'true') else '' }}

[Install]
WantedBy=multi-user.target

@ryan or @daniel.futerman might have more experience working with docker implementations of OpenHIM and its mediators.

2 Likes

@maurya and @sharfspace

We have released a new tutorial video on YouTube on setting up the Mapping Mediator within a Docker environment. Perhaps this will help you?

Regards,
Matt

3 Likes

Thanks @mattdickie for sharing that :slight_smile:
@sharfspace We’ve started Dockerizing new mediators that we develop, with the Mapping Mediator an example of the approach taken. The Mapping Mediator has been developed as a generic mediator that supports data validation, mapping, and orchestration, and is intended to be adapted based on specific use cases. More details are available here:


3 Likes

Thanks so much @mattdickie , for your response , will surely follow the vedio however it seems its specifically using node js for creating mediator mappings we are looking at a use case of creating a java mediator use scenarios thanks will keep you up to date of findings

2 Likes

Thanks so much @daniel.futerman, will surely deep dive into these links , will update you of my progress about mediator use case

2 Likes

@daniel.futerman , I followed Building a Basic Mediator | OpenHIM
step by step
However, when I run

curl -v -X  GET http://localhost:5001/scaffold -H "Authorization: Basic $(echo -n test:test | base64)"

I am getting

2023-09-02 17:36:01.104 - error: [worker1] [64f32529c416130692d281db] Internal server error occured: Error: getaddrinfo EAI_AGAIN scaffold
2023-09-02 17:36:01.110 - info: [worker1] All routes completed for transaction: 64f32529c416130692d281db
2023-09-02 17:36:01.110 - error: [worker1] Error: getaddrinfo EAI_AGAIN scaffold
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26)
2023-09-02 17:36:01.114 - info: [worker1] Final status for transaction 64f32529c416130692d281db : Failed

I have my question and setup available on this stackoverflow question

Any idea why ?

@ryan @richard.langford could someone from your team help assist @satyadeep with his techincal question?

Thanks a lot @jthomas . Looking forward to hear from @ryan or @richard.langford

Thanks again.

Satyadeep

1 Like

I’m new to OpenHIM/OpenHIE and currently working on a project involving OpenMRS. We’re trying to develop a FHIR profile for a patient’s clinical note. During the installation of a scaffold mediator, I encountered an error. I would greatly appreciate any assistance or suggestions on how to resolve this. Thank you!

 => ERROR [4/4] RUN npm install                                                                                                                                                                      257.3s
------                                                                                                                                                                                                      
 > [4/4] RUN npm install:                                                                                                                                                                                   
1.356 npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!                         
132.4 npm WARN newproject@1.0.0 No description                                                                                                                                                              
132.4 npm WARN newproject@1.0.0 No repository field.                                                                                                                                                        
132.4 
132.4 npm ERR! code EAI_AGAIN
132.4 npm ERR! errno EAI_AGAIN
132.4 npm ERR! request to https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.23.5.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443
257.3 
257.3 npm ERR! A complete log of this run can be found in:
257.3 npm ERR!     /root/.npm/_logs/2024-03-05T10_19_16_053Z-debug.log
------
Dockerfile:6
--------------------
   4 |     COPY . /app
   5 |     
   6 | >>> RUN npm install
   7 |     
   8 |     CMD npm start
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
santosh@santosh-ThinkPad-T14-Gen-1:~/newproject$ 

@santosh_paudel which npm version are you running ?

1 Like

Hi @tmkmart
I am using npm version 8.5.1

i used this command to resolve this issue:

npm config set registry http://registry.npmjs.org/

However, during the installation of scaffold mediator, I got another error:


> openhim-bootstrap-mediator@1.0.0 start /app
> babel-node index.js

/app/node_modules/axios/index.js:1
import axios from './lib/axios.js';
       ^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Module._compile (/app/node_modules/pirates/lib/index.js:117:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.newLoader [as .js] (/app/node_modules/pirates/lib/index.js:121:7)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/app/node_modules/openhim-mediator-utils/auth.js:3:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! openhim-bootstrap-mediator@1.0.0 start: `babel-node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the openhim-bootstrap-mediator@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-03-07T18_49_22_109Z-debug.log

Does anyone have a solution to this? Any suggestion will be helpful, Thank you
cc @tmkmart @daniel.futerman