Launch Cares
To Launch Cares only.
Add OpenHIM configs
'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 || 'root@openhim.org' 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 => { console.error('Failed to import OpenHIM config: ', error) }) req.write(data) req.end(){ "Users": [ { "groups": ["admin"], "firstname": "Super", "surname": "User", "email": "root@openhim.org", "passwordAlgorithm": "sha512", "passwordHash": "ea3824f17cf1379eb118a36bc7c8cf0f45712e2af7748567fca5313dec6fa66d61064e82a5e5cb88e998486ee3c7d0dac235bbeda8c341d6edc1c77406be2ab6", "passwordSalt": "d4f622c0404f09bd959bfb263efa3452", "expiry": null, "locked": false, "token": null, "tokenType": null } ], "Clients": [ { "roles": ["instant"], "customTokenID": "test", "clientID": "instant-client", "name": "Instant Client" } ], "Channels": [ { "methods": ["POST", "DELETE"], "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": "FHIR Server", "secured": false, "host": "hapi-proxy", "port": 18080, "path": "", "pathTransform": "", "primary": true, "username": "", "password": "" } ], "requestBody": true, "responseBody": true, "rewriteUrlsConfig": [], "name": "FHIR Server", "description": "A FHIR server (HAPI FHIR)", "urlPattern": "^/fhir.*$", "priority": 1, "matchContentRegex": null, "matchContentXpath": null, "matchContentValue": null, "matchContentJson": null, "pollingSchedule": null, "tcpHost": null, "tcpPort": null, "updatedBy": { "id": "5e2eca110bb0420011f0cd84", "name": "Super User" }, "alerts": [] }, { "methods": ["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": "Reprocess Endpoint", "secured": false, "host": "reprocess-mediator", "port": 3000, "path": "/reprocess", "pathTransform": "", "primary": true, "username": "", "password": "" } ], "requestBody": true, "responseBody": true, "rewriteUrlsConfig": [], "name": "Reprocess Mediator", "description": "Monitor reprocessed data triggered by this mediator", "urlPattern": "^/reprocess$", "matchContentRegex": null, "matchContentXpath": null, "matchContentValue": null, "matchContentJson": null, "pollingSchedule": null, "tcpHost": null, "tcpPort": null, "updatedBy": { "id": "6128a65ed529a100137ab88b", "name": "Super User" }, "alerts": [] }, { "methods": ["GET"], "type": "http", "allow": ["instant"], "whitelist": [], "authType": "private", "matchContentTypes": [], "properties": [], "txViewAcl": [], "txViewFullAcl": [], "txRerunAcl": [], "status": "enabled", "rewriteUrls": false, "addAutoRewriteRules": true, "autoRetryEnabled": false, "autoRetryPeriodMinutes": 60, "updatedBy": { "id": "6180fecba6295300160c5319", "name": "Super User" }, "routes": [ { "type": "http", "status": "enabled", "forwardAuthHeader": false, "name": "FHIR Server", "secured": false, "host": "hapi-fhir", "port": 8080, "path": "", "pathTransform": "", "primary": true, "username": "", "password": "" } ], "requestBody": true, "responseBody": true, "rewriteUrlsConfig": [], "description": "A channel to allow queries on the FHIR Server directly", "urlPattern": "^/fhir.*$", "priority": 2, "matchContentRegex": null, "matchContentXpath": null, "matchContentValue": null, "matchContentJson": null, "pollingSchedule": null, "tcpHost": null, "tcpPort": null, "alerts": [], "name": "FHIR Server Direct" } ] }services: ... // Add the openHIM config importer service: cares-openhim-config-importer: image: jembi/instantohie-config-importer deploy: restart_policy: condition: none environment: OPENHIM_API_HOSTNAME: 'openhim-core' OPENHIM_API_PORT: 8080 OPENHIM_API_USERNAME: 'root@openhim.org' OPENHIM_API_PASSWORD: 'instant101' # Reject unauthorised is only needed if the OpenHIM's SSL is not setup NODE_TLS_REJECT_UNAUTHORIZED: 0 configs: - source: cares-openhim-config-openhimConfig.js target: /openhimConfig.js - source: cares-openhim-config-openhim-import.json target: /openhim-import.json # This command will only attempt to import the OpenHIM config when the heartbeat responds with a 2xx command: sh -c "wait-on -t 60000 https-get://openhim-core:8080/heartbeat && node /openhimConfig.js" configs: ... // Add the openHIM configs cares-openhim-config-openhimConfig.js: file: ./openhim/openhimConfig.js name: cares-openhim-config-openhimConfig.js-${cares_openhim_config_openhimConfig_js_DIGEST:?err} labels: name: cares cares-openhim-config-openhim-import.json: file: ./openhim/openhim-import.json name: cares-openhim-config-openhim-import.json-${cares_openhim_config_openhim_import_json_DIGEST:?err} labels: name: cares... config::remove_config_importer cares-superset-config-importer // Next line should be added config::remove_config_importer cares-openhim-config-importer ... config::await_service_removed instant_cares-superset-config-importer // Next line should be added config::await_service_removed instant_cares-openhim-config-importer ..."dependencies": [ ..., // Add the following "interoperability-layer-openhim", "message-bus-helper-hapi-proxy" ],
Edit & check your Environment Variables
Launch Cares
Last updated