-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from jembi/PLAT-641-update-mpi-mediator-package
Plat 641 update mpi mediator package
- Loading branch information
Showing
7 changed files
with
305 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: '3.9' | ||
|
||
services: | ||
# container for executing config import scripts for creating the OpenHIM channels used by the Mediator | ||
mpi-mediator-config-importer: | ||
image: node:erbium-alpine | ||
environment: | ||
OPENHIM_CORE_SERVICE_NAME: ${OPENHIM_CORE_SERVICE_NAME} | ||
OPENHIM_MEDIATOR_API_PORT: ${OPENHIM_MEDIATOR_API_PORT} | ||
OPENHIM_API_USERNAME: ${OPENHIM_USERNAME} | ||
OPENHIM_API_PASSWORD: ${OPENHIM_PASSWORD} | ||
# Reject unauthorised is only needed if the OpenHIM's SSL is not setup | ||
NODE_TLS_REJECT_UNAUTHORIZED: 0 | ||
command: sh -c "node openhimConfig.js" | ||
configs: | ||
- source: mpi-mediator-config-importer-openhimConfig.js | ||
target: /openhimConfig.js | ||
- source: mpi-mediator-config-importer-openhim-import.json | ||
target: /openhim-import.json | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: none | ||
|
||
configs: | ||
mpi-mediator-config-importer-openhimConfig.js: | ||
file: ./volume/openhimConfig.js | ||
name: mpi-mediator-config-importer-openhimConfig.js-${mpi_mediator_config_importer_openhimConfig_js_DIGEST:?err} | ||
labels: | ||
name: mpi-mediator | ||
mpi-mediator-config-importer-openhim-import.json: | ||
file: ./volume/openhim-import.json | ||
name: mpi-mediator-config-importer-openhim-import.json-${mpi_mediator_config_importer_openhim_import_js_DIGEST:?err} | ||
labels: | ||
name: mpi-mediator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
{ | ||
"Users": [ | ||
{ | ||
"groups": [ | ||
"admin" | ||
], | ||
"firstname": "Super", | ||
"surname": "User", | ||
"email": "[email protected]", | ||
"passwordAlgorithm": "sha512", | ||
"passwordHash": "ea3824f17cf1379eb118a36bc7c8cf0f45712e2af7748567fca5313dec6fa66d61064e82a5e5cb88e998486ee3c7d0dac235bbeda8c341d6edc1c77406be2ab6", | ||
"passwordSalt": "d4f622c0404f09bd959bfb263efa3452", | ||
"expiry": null, | ||
"locked": false, | ||
"token": null, | ||
"tokenType": null | ||
} | ||
], | ||
"Clients": [ | ||
{ | ||
"roles": [ | ||
"instant" | ||
], | ||
"customTokenID": "test", | ||
"clientID": "test", | ||
"name": "Test Client" | ||
} | ||
], | ||
"Channels": [ | ||
{ | ||
"methods": [ | ||
"GET", | ||
"POST" | ||
], | ||
"type": "http", | ||
"allow": [ | ||
"instant" | ||
], | ||
"whitelist": [], | ||
"authType": "private", | ||
"matchContentTypes": [], | ||
"properties": [], | ||
"txViewAcl": [], | ||
"txViewFullAcl": [], | ||
"txRerunAcl": [], | ||
"status": "enabled", | ||
"rewriteUrls": false, | ||
"addAutoRewriteRules": true, | ||
"autoRetryEnabled": false, | ||
"autoRetryPeriodMinutes": 60, | ||
"routes": [ | ||
{ | ||
"type": "http", | ||
"status": "enabled", | ||
"forwardAuthHeader": false, | ||
"name": "MPI Mediator", | ||
"secured": false, | ||
"host": "mpi-mediator", | ||
"port": 3000, | ||
"path": "", | ||
"pathTransform": "", | ||
"primary": true, | ||
"username": "", | ||
"password": "" | ||
} | ||
], | ||
"requestBody": true, | ||
"responseBody": true, | ||
"rewriteUrlsConfig": [], | ||
"name": "MPI Orchestrations - Create/Read operations for patients and their clinical data", | ||
"urlPattern": "^/fhir.*$", | ||
"priority": null, | ||
"matchContentRegex": null, | ||
"matchContentXpath": null, | ||
"matchContentValue": null, | ||
"matchContentJson": null, | ||
"pollingSchedule": null, | ||
"tcpHost": null, | ||
"tcpPort": null, | ||
"updatedBy": { | ||
"id": "63cd5092c962240014b87c59", | ||
"name": "Super User" | ||
}, | ||
"alerts": [], | ||
"description": "" | ||
}, | ||
{ | ||
"methods": [ | ||
"POST" | ||
], | ||
"type": "http", | ||
"allow": [ | ||
"instant" | ||
], | ||
"whitelist": [], | ||
"authType": "private", | ||
"matchContentTypes": [], | ||
"properties": [], | ||
"txViewAcl": [], | ||
"txViewFullAcl": [], | ||
"txRerunAcl": [], | ||
"status": "enabled", | ||
"rewriteUrls": false, | ||
"addAutoRewriteRules": true, | ||
"autoRetryEnabled": false, | ||
"autoRetryPeriodMinutes": 60, | ||
"updatedBy": { | ||
"id": "63cd5092c962240014b87c59", | ||
"name": "Super User" | ||
}, | ||
"routes": [ | ||
{ | ||
"type": "http", | ||
"status": "enabled", | ||
"forwardAuthHeader": false, | ||
"name": "MPI Mediator", | ||
"secured": false, | ||
"host": "mpi-mediator", | ||
"port": 3000, | ||
"path": "", | ||
"pathTransform": "", | ||
"primary": true, | ||
"username": "", | ||
"password": "" | ||
} | ||
], | ||
"requestBody": true, | ||
"responseBody": true, | ||
"rewriteUrlsConfig": [], | ||
"urlPattern": "^/async/fhir/?$", | ||
"priority": null, | ||
"matchContentRegex": null, | ||
"matchContentXpath": null, | ||
"matchContentValue": null, | ||
"matchContentJson": null, | ||
"pollingSchedule": null, | ||
"tcpHost": null, | ||
"tcpPort": null, | ||
"alerts": [], | ||
"name": "MPI Orchestration for fhir bundles - Asynchronous flow" | ||
} | ||
], | ||
"Mediators": [ | ||
{ | ||
"urn": "urn:mediator:mpi-mediator", | ||
"version": "1.0.0", | ||
"name": "MPI mediator", | ||
"description": "A mediator handling interactions between the OpenHIM Core service, Sante MPI, Hapi-FHIR, and Kafka", | ||
"defaultChannelConfig": [ | ||
{ | ||
"methods": [ | ||
"POST", | ||
"GET" | ||
], | ||
"type": "http", | ||
"allow": [ | ||
"instant" | ||
], | ||
"whitelist": [], | ||
"authType": "private", | ||
"matchContentTypes": [], | ||
"properties": [], | ||
"txViewAcl": [], | ||
"txViewFullAcl": [], | ||
"txRerunAcl": [], | ||
"status": "enabled", | ||
"rewriteUrls": false, | ||
"addAutoRewriteRules": true, | ||
"autoRetryEnabled": false, | ||
"autoRetryPeriodMinutes": 60, | ||
"name": "MPI mediator", | ||
"urlPattern": "^(/async)?/fhir.*$", | ||
"routes": [ | ||
{ | ||
"type": "http", | ||
"status": "enabled", | ||
"forwardAuthHeader": false, | ||
"name": "MPI Endpoint", | ||
"host": "mpi-mediator", | ||
"port": 3000, | ||
"primary": true | ||
} | ||
], | ||
"alerts": [], | ||
"rewriteUrlsConfig": [] | ||
} | ||
], | ||
"endpoints": [ | ||
{ | ||
"type": "http", | ||
"status": "enabled", | ||
"forwardAuthHeader": false, | ||
"name": "MPI Endpoint", | ||
"host": "mpi-mediator", | ||
"path": "/fhir", | ||
"port": 3000, | ||
"primary": true | ||
} | ||
], | ||
"configDefs": [], | ||
"_lastHeartbeat": "2023-01-23T09:40:21.368Z", | ||
"_uptime": 52784.4956787 | ||
} | ||
], | ||
"ContactGroups": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const https = require('https') | ||
const path = require('path') | ||
|
||
const OPENHIM_CORE_SERVICE_NAME = process.env.OPENHIM_CORE_SERVICE_NAME || 'openhim-core' | ||
const OPENHIM_API_PASSWORD = | ||
process.env.OPENHIM_API_PASSWORD || 'openhim-password' | ||
const OPENHIM_MEDIATOR_API_PORT = process.env.OPENHIM_MEDIATOR_API_PORT || 8080 | ||
const OPENHIM_API_USERNAME = | ||
process.env.OPENHIM_API_USERNAME || '[email protected]' | ||
|
||
const authHeader = new Buffer.from( | ||
`${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}` | ||
).toString('base64') | ||
|
||
const jsonData = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, 'openhim-import.json')) | ||
) | ||
|
||
const data = JSON.stringify(jsonData) | ||
|
||
const options = { | ||
protocol: 'https:', | ||
hostname: OPENHIM_CORE_SERVICE_NAME, | ||
port: OPENHIM_MEDIATOR_API_PORT, | ||
path: '/metadata', | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Content-Length': data.length, | ||
Authorization: `Basic ${authHeader}` | ||
} | ||
} | ||
|
||
const req = https.request(options, res => { | ||
if (res.statusCode == 401) { | ||
throw new Error(`Incorrect OpenHIM API credentials`) | ||
} | ||
|
||
if (res.statusCode != 201) { | ||
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`) | ||
} | ||
|
||
console.log('Successfully Imported OpenHIM Config') | ||
}) | ||
|
||
req.on('error', error => { | ||
throw new Error(`Failed to import OpenHIM config: ${error}`) | ||
}) | ||
|
||
req.write(data) | ||
req.end() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
"TRUST_SELF_SIGNED": "true", | ||
"OPENHIM_USERNAME": "[email protected]", | ||
"OPENHIM_PASSWORD": "instant101", | ||
"OPENHIM_CORE_SERVICE_NAME": "openhim-core", | ||
"OPENHIM_MEDIATOR_API_PORT": 8080, | ||
"REGISTER_MEDIATOR": "true", | ||
"MPI_CLIENT_ID": "fiddler", | ||
"MPI_CLIENT_SECRET": "fiddler", | ||
|
@@ -30,6 +32,7 @@ | |
"KAFKA_ERROR_TOPIC": "errors", | ||
"FHIR_DATASTORE_PROTOCOL": "http", | ||
"FHIR_DATASTORE_HOST": "hapi-fhir", | ||
"FHIR_DATASTORE_PORT": 8080 | ||
"FHIR_DATASTORE_PORT": 8080, | ||
"DISABLE_VALIDATION": "false" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters