Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#114): Create OpenMRS Mediator #115

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5e4451f
feat(#114): Create OpenMRS Mediator for Patient resource
witash Mar 14, 2024
4e3de0f
feat(#114): add endpoints for openmrs and cht
witash Apr 7, 2024
534b1fd
feat(#114): add missing routes
witash Apr 8, 2024
50a3f3f
feat(#114): add openmrs poller
witash Apr 16, 2024
494ae3d
feat(#114): id exchange and sms forms
witash Apr 22, 2024
8c3c4fe
feat(#114): add patient to bundle from openmrs
witash Apr 23, 2024
6ed106d
feat(#114): allow palce id in name
witash Apr 29, 2024
76e9012
feat(#124): remove openmrs endpoints, add mappers for cht, openmrs
witash May 20, 2024
ffaa7e0
feat(#124): add openmrs sync
witash May 20, 2024
9b7978d
feat(#114): add sequence diagrams for document endpoints
witash May 21, 2024
ac83b03
feat(#125): sequence diagrams for outgoing patients
witash May 21, 2024
1fb1351
feat(#114): fix uit tests
witash May 22, 2024
d9e1c13
feat(#125): sequence diagrams for incoming patients and forms
witash May 23, 2024
449de72
feat(#114): sonar fixes
witash May 24, 2024
613bf6b
feat(#114): add openmrs channel to configurator
witash May 24, 2024
6d03a4f
feat(#114): fix bundle format
witash May 27, 2024
aba7c95
feat(#114): get observations and patients together with encounters
witash May 31, 2024
fda229f
feat(#114): configurator changes
witash May 31, 2024
f7a834d
feat(#114): add openmrs to startup
witash May 31, 2024
dfe749d
feat(#114): add timeout, fix timing issues
witash Jun 4, 2024
6c3ff27
feat(#114): pagination for openmrs sync
witash Jun 6, 2024
3eab817
feat(#114): fix reference for encounters and don't allow updates
witash Jun 10, 2024
0e38c83
feat(#114): fix unit tests
witash Jun 10, 2024
d05968e
feat(#114): fix unit tests
witash Jun 10, 2024
70aee07
feat(#114): remove cht from main startup script
witash Jun 11, 2024
6141ce8
feat(#114): adding source ot prevent infinite loops
witash Jun 21, 2024
5bb2eae
feat(#114): don't save encounters until complete
witash Jun 21, 2024
12e2a53
feat(#114): boundary conditions for sync
witash Jun 24, 2024
88f1014
feat(#114): add sync_interval to index
witash Jun 24, 2024
7a5243c
feat(#114): fix tests
witash Jun 24, 2024
3db5945
feat(#114): fix defualt sync_interval
witash Jun 24, 2024
82e29ec
feat(#114): fix unit tests for default sync_interval
witash Sep 9, 2024
ee8e8dd
feat: add platform to failing containers
njuguna-n Sep 18, 2024
6d2c7d2
no service line in compose files, pin to cht core 4.10, improve start…
mrjones-plip Sep 18, 2024
e91be25
fix(#138): change ltfu mediator to cht mediator and add openmrs mediator
witash Oct 2, 2024
c1cc023
fix(#138): env.template changes and small fixes
witash Oct 3, 2024
f325edd
chore (#123): openmrs mediator e2e test (#128)
lorerod Oct 4, 2024
7470359
fix(#123): fixing tests
witash Oct 8, 2024
a0fc96b
fix(#123): fixing tests
witash Oct 8, 2024
86bdc31
chore(#142): adding tests to increase coverage
witash Oct 18, 2024
59f607b
Merge branch 'main' into openmrs-mediator
witash Oct 21, 2024
1a5be52
chore(#142): sonar fixes
witash Oct 22, 2024
d6db1d6
chore(#142): sonar fixes
witash Oct 22, 2024
7d279c1
chore(#142): adding tests to increase coverage (#143)
witash Oct 23, 2024
d5b0252
fix: fixing startup script
witash Oct 23, 2024
ef558a2
chore(#136): skipping e2e-tests until rate limiting is fixed
witash Oct 23, 2024
d8cb295
feat(#138): move polling to openhim channel config (#139)
witash Oct 25, 2024
e3f1a4c
chore(#142): add tests and small fixes
witash Oct 28, 2024
dfe2107
Merge branch '142-unit-tests' into openmrs-mediator
witash Oct 28, 2024
59bf494
fix(#123): use up-test command in retry_startup
Oct 31, 2024
0f7ef52
fix(#123): remove conditional to enable E2E tests in CI
Oct 31, 2024
61ccd62
fix(#123): remove conditional to enable E2E tests in CI
Oct 31, 2024
5be2b00
fix: convert sync period to milliseconds before subtracting from the …
njuguna-n Nov 1, 2024
8abfa10
fix(#123): remove conditional to enable E2E tests in CI
Nov 1, 2024
3cc6a55
fix(#123): revert remove conditional to enable E2E tests in CI
Nov 1, 2024
3216ce7
fix(#123): add wait time before asserting fhir response
Nov 6, 2024
71df8de
fix(#123): add logic to retry image pulls
Nov 6, 2024
1ec5181
fix(#123): enable e2e test in ci
Nov 6, 2024
670f3a5
feat: make encounter requests idempotent by using the identifier
njuguna-n Nov 8, 2024
0bca7ae
feat: get fhir resource by identifier
njuguna-n Nov 11, 2024
dcb5e61
feat(#147): adding value types (#149)
witash Nov 13, 2024
40716e8
chore: adding sample forms
witash Nov 19, 2024
1de75e4
fix: removing date check
witash Nov 19, 2024
c9354ff
chore: address sonarlint issues
njuguna-n Nov 25, 2024
7b89788
chore: remove unused variable
andrablaj Nov 28, 2024
f361ca4
fix: adding postman collection
witash Jan 9, 2025
9290c0f
fix: app setting changes for testing
witash Jan 10, 2025
85d0484
Merge branch 'main' into openmrs-mediator
witash Jan 10, 2025
539f03e
feat: separating test and openmrs job
witash Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions configurator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
FROM node:16-alpine

RUN apk add g++ make py3-pip git curl chromium
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also still needed @witash

Copy link
Member

@binokaryg binokaryg Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am getting this error without it:

148.7 /bin/sh: python: not found
------
failed to solve: process "/bin/sh -c npm install && npm install -g cht-conf && python -m pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic" did not complete successfully: exit code: 127


WORKDIR /scripts/configurator

COPY ./configurator ./
COPY ./configurator/package.json ./package.json
COPY ./configurator/package-lock.json ./package-lock.json

RUN npm install

WORKDIR /scripts/cht-config

COPY ../cht-config ./

RUN npm install && npm install -g cht-conf && python -m pip install git+https://github.com/medic/[email protected]#egg=pyxform-medic
witash marked this conversation as resolved.
Show resolved Hide resolved
RUN npm install && npm install -g cht-conf

WORKDIR /scripts/configurator

COPY ./configurator ./

WORKDIR /scripts

Expand Down
16 changes: 15 additions & 1 deletion configurator/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ const OPENHIM_API_USERNAME =
const OPENHIM_CLIENT_PASSWORD = process.env.OPENHIM_CLIENT_PASSWORD || 'interop-password';
const OPENHIM_USER_PASSWORD = process.env.OPENHIM_USER_PASSWORD || 'interop-password';

const OPENMRS_HOST = process.env.OPENMRS || 'openmrs';
const OPENMRS_PORT = process.env.OPENMRS_PORT || 8090;
const OPENMRS_USERNAME =
process.env.OPENMRS_USERNAME || 'admin';
const OPENMRS_PASSWORD =
process.env.OPENMRS_PASSWORD || 'Admin123';
const OPENMRS_PROTOCOL = process.env.OPENMRS_PROTOCOL || 'http'

module.exports = {
OPENHIM_API_HOSTNAME,
OPENHIM_API_PASSWORD,
OPENHIM_API_PORT,
OPENHIM_API_USERNAME,
OPENHIM_CLIENT_PASSWORD,
OPENHIM_USER_PASSWORD
OPENHIM_USER_PASSWORD,

OPENMRS_HOST,
OPENMRS_PORT,
OPENMRS_USERNAME,
OPENMRS_PASSWORD,
OPENMRS_PROTOCOL
};
4 changes: 3 additions & 1 deletion configurator/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {OPENHIM_USER_PASSWORD, OPENHIM_CLIENT_PASSWORD} = require('./config');
const {OPENMRS_USERNAME, OPENMRS_PASSWORD, OPENMRS_HOST, OPENMRS_PORT, OPENMRS_PROTOCOL} = require('./config');
const {generateApiOptions, generateAuthHeaders} = require('./libs/authentication');
const {generateUser, generateClient, generateHapiFihrChannel} = require('./libs/generators');
const {generateUser, generateClient, generateHapiFihrChannel, generateOpenMRSChannel} = require('./libs/generators');
const {fetch} = require('./utils');
const logger = require('./logger');

Expand All @@ -16,6 +17,7 @@ async function handleConfiguration () {
metadata.Users.push(await generateUser(OPENHIM_USER_PASSWORD));
metadata.Clients.push(await generateClient(OPENHIM_CLIENT_PASSWORD));
metadata.Channels.push(await generateHapiFihrChannel());
metadata.Channels.push(await generateOpenMRSChannel(OPENMRS_HOST, OPENMRS_PORT, OPENMRS_USERNAME, OPENMRS_PASSWORD, OPENMRS_PROTOCOL));

const data = JSON.stringify(metadata);
const apiOptions = generateApiOptions('/metadata');
Expand Down
63 changes: 62 additions & 1 deletion configurator/libs/generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,69 @@ async function generateHapiFihrChannel () {
};
}

async function generateOpenMRSChannel (host, port, username, password, type) {
return {
methods: [
'GET',
'POST',
'DELETE',
'PUT',
'OPTIONS',
'HEAD',
'TRACE',
'CONNECT',
'PATCH'
],
type: type,
allow: CLIENT_ROLES,
whitelist: [],
authType: 'private',
matchContentTypes: [],
properties: [],
txViewAcl: [],
txViewFullAcl: [],
txRerunAcl: [],
status: 'enabled',
rewriteUrls: false,
addAutoRewriteRules: true,
autoRetryEnabled: false,
autoRetryPeriodMinutes: 60,
routes: [
{
type: type,
status: 'enabled',
forwardAuthHeader: false,
name: 'OpenMRS',
secured: false,
host: host,
port: port,
path: '',
pathTransform: 's/openmrs/openmrs\/ws\/fhir2\/R4/g',
primary: true,
username: username,
password: password
}
],
requestBody: true,
responseBody: true,
rewriteUrlsConfig: [],
name: 'OpenMRS',
description: 'OpenMRS',
urlPattern: '^/openmrs/.*$',
priority: 1,
matchContentRegex: null,
matchContentXpath: null,
matchContentValue: null,
matchContentJson: null,
pollingSchedule: null,
tcpHost: null,
tcpPort: null,
alerts: []
};
}
module.exports = {
generateClient,
generateUser,
generateHapiFihrChannel
generateHapiFihrChannel,
generateOpenMRSChannel
};
49 changes: 49 additions & 0 deletions docker/docker-compose.openmrs.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add this to the startup.sh?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing about openmrs when testing locally it is now working.
A call to POST localhost:5001/mediator/cht/sync retutrn socket hang up
In OpenHIM transaction logs also:
GET openhim-core:5001/openmrs/Patient/?_lastUpdated=gt2024-05-27T16:41:02.989Z
getaddrinfo ENOTFOUND openmrs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest commit should fix the error. but if openmrs is not running, sync doesn't do anything
also added it to startup.sh temporarily, although not every deployment will want a local copy of openmrs

the next problem is that this image has a very old version of the fhir module that doesn't work right, and its missing the cht identifier types; I fixed that locally by downloading the latest fhir omod from https://addons.openmrs.org/show/org.openmrs.module.openmrs-fhir2-module and running ocker cp ~/Downloads/fhir2-2.1.0.omod chis-interop-openmrs-1:/usr/local/tomcat/.OpenMRS/modules/fhir2-2.1.0.omod and manually creating the identifier types in the UI but need to dockerize somehow

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '2.1'

services:
openmrs-mysql:
restart: "always"
image: mysql:5.6
command: "mysqld --character-set-server=utf8 --collation-server=utf8_general_ci"
environment:
MYSQL_DATABASE: ${MYSQL_DB:-openmrs}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-Admin123}
MYSQL_USER: ${MYSQL_USER:-openmrs}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-Admin123}
ports:
- "3306:3306"
healthcheck:
test: "exit 0"
volumes:
- openmrs-referenceapplication-mysql-data:/var/lib/mysql
networks:
- cht-net

openmrs:
restart: "always"
image: openmrs/openmrs-reference-application-distro:demo
depends_on:
- openmrs-mysql
ports:
- "8090:8080"
environment:
DB_DATABASE: ${MYSQL_DB:-openmrs}
DB_HOST: openmrs-referenceapplication-mysql
DB_USERNAME: ${MYSQL_USER:-openmrs}
DB_PASSWORD: ${MYSQL_PASSWORD:-Admin123}
DB_CREATE_TABLES: 'true'
DB_AUTO_UPDATE: 'true'
MODULE_WEB_ADMIN: 'true'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/openmrs/"]
timeout: 20s
volumes:
- openmrs-referenceapplication-data:/usr/local/tomcat/.OpenMRS/
- /usr/local/tomcat/.OpenMRS/modules/ # do not store modules in data
- /usr/local/tomcat/.OpenMRS/owa/ # do not store owa in data
networks:
- cht-net

volumes:
openmrs-referenceapplication-mysql-data:
openmrs-referenceapplication-data:
Loading