Skip to content

Commit

Permalink
Merge branch 'main' into update-mpi-mediator-version
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelloosen authored Feb 13, 2023
2 parents 0244123 + d7e2c4b commit 7f40530
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 3 deletions.
2 changes: 1 addition & 1 deletion message-bus-kafka/package-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"KAFKA_CPU_RESERVE": "0.05",
"KAFKA_MEMORY_LIMIT": "3G",
"KAFKA_MEMORY_RESERVE": "500M",
"KAFKA_TOPICS": "2xx,reprocess,3xx,metrics:3:1",
"KAFKA_TOPICS": "2xx,2xx-async,3xx,reprocess,errors,metrics:3:1",
"KAFDROP_CPU_LIMIT": "0",
"KAFDROP_CPU_RESERVE": "0.05",
"KAFDROP_MEMORY_LIMIT": "3G",
Expand Down
1 change: 1 addition & 0 deletions mpi-mediator/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
FHIR_DATASTORE_PROTOCOL: ${FHIR_DATASTORE_PROTOCOL}
FHIR_DATASTORE_HOST: ${FHIR_DATASTORE_HOST}
FHIR_DATASTORE_PORT: ${FHIR_DATASTORE_PORT}
DISABLE_VALIDATION: ${DISABLE_VALIDATION}
deploy:
placement:
max_replicas_per_node: 1
Expand Down
35 changes: 35 additions & 0 deletions mpi-mediator/importer/docker-compose.config.yml
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
206 changes: 206 additions & 0 deletions mpi-mediator/importer/volume/openhim-import.json
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": []
}
54 changes: 54 additions & 0 deletions mpi-mediator/importer/volume/openhimConfig.js
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()
5 changes: 4 additions & 1 deletion mpi-mediator/package-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
5 changes: 4 additions & 1 deletion mpi-mediator/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ function initialize_package() {
log error "Failed to deploy package"
exit 1
}
docker::deploy_config_importer "$COMPOSE_FILE_PATH/importer/docker-compose.config.yml" "mpi-mediator-config-importer" "mpi-mediator"
}

function destroy_package() {
docker::service_destroy "${SERVICE_NAMES}"
docker::service_destroy "${SERVICE_NAMES}" "mpi-mediator-config-importer"

docker::prune_configs "mpi-mediator"
}

main() {
Expand Down

0 comments on commit 7f40530

Please sign in to comment.