This repository has been archived by the owner on Feb 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e410140
commit cb6fd9c
Showing
7 changed files
with
111 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,6 @@ CMD npm start | |
|
||
RUN npm install -g sequelize-cli | ||
|
||
EXPOSE 4000 | ||
EXPOSE 7000 | ||
|
||
VOLUME [ "/app/node_modules" ] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 @@ | ||
{ | ||
"urn": "urn:mediator:emr-mpi-mediator", | ||
"version": "1.0.0", | ||
"name": "EMR Endpoint Mediator", | ||
"description": "This mediator is intended sending request to sante mpi mediator", | ||
"defaultChannelConfig": [{ | ||
"name": "EMR Endpoint Mediator", | ||
"urlPattern": "^/emr-mpi-mediator$", | ||
"routes": [{ | ||
"name": "EMR Endpoint Mediator Route", | ||
"host": "emr-mpi-mediator", | ||
"path": "/", | ||
"port": "7000", | ||
"primary": true, | ||
"type": "http" | ||
}], | ||
"allow": ["admin"], | ||
"methods": ["GET", "PATCH","POST","PUT"], | ||
"type": "http" | ||
}], | ||
"endpoints": [{ | ||
"name": "EMR Endpoint Mediator Endpoint", | ||
"host": "emr-mpi-mediator", | ||
"path": "/", | ||
"port": "7000", | ||
"primary": false, | ||
"type": "http" | ||
}], | ||
"configDefs": [] | ||
} |
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 |
---|---|---|
@@ -1,12 +1,25 @@ | ||
const express = require("express"); | ||
const router = require("./routes"); | ||
const privateConfig = require("./config/private-config.json"); | ||
const { getQueryParameters } = require('./openHIM/initialize.js'); | ||
|
||
const config = require("./config/private-config.json") | ||
//openHIM | ||
getQueryParameters(); | ||
|
||
const app = express(); | ||
|
||
app.use('/', router); | ||
// app.use('/', router); | ||
app.use('/',router, async (req, res) => { | ||
// Starts when a new request is triggered by the polling channel | ||
res.status(res.statusCode).send(res.body); | ||
console.log(`\n---------------------------------------------------------------------------------`, | ||
`\n${new Date().toUTCString('en-GB', { timeZone: 'UTC' })} - `, | ||
`The EMR Endpoint Mediator has received a new request. \n` | ||
); | ||
}); | ||
|
||
app.listen(7000, ()=> { | ||
console.log(`Server is listening on port ${config.appConfig.PORT}`); | ||
//Server PORT | ||
app.listen(privateConfig.appConfig.PORT, (err) => { | ||
if (err) console.log(`Error: ${err}`) | ||
console.log(`${privateConfig.appConfig.mediatorName} listening on port ${privateConfig.appConfig.PORT}... \n`); | ||
}) |
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,41 @@ | ||
const privateConfig = require('../config/private-config.json'); | ||
const mediatorConfig = require('../config/mediator-config.json'); | ||
|
||
// OpenHIM | ||
const { registerMediator, activateHeartbeat, fetchConfig } = require('openhim-mediator-utils'); | ||
let queryParams; | ||
const openhimVars = privateConfig.openhimConfig; | ||
const openhimConfig = { | ||
username: openhimVars.username, | ||
password: openhimVars.password, | ||
apiURL: openhimVars.apiURL, | ||
trustSelfSigned: true, | ||
urn: mediatorConfig.urn | ||
} | ||
const emitter = activateHeartbeat(openhimConfig); | ||
|
||
registerMediator(openhimConfig, mediatorConfig, err => { | ||
if (err) { | ||
throw new Error(`Failed to register mediator. Check your Config. ${err}`) | ||
} | ||
}); | ||
|
||
fetchConfig(openhimConfig, (err, initialConfig) => { | ||
if (err) { | ||
throw new Error(`Failed to fetch initial config. ${err}`) | ||
} | ||
console.log('Initial Config: ', JSON.stringify(initialConfig)) | ||
queryParams = initialConfig.labResultsParams | ||
}); | ||
|
||
emitter.on('error', err => { | ||
console.error('Heartbeat failed: ', err) | ||
}); | ||
|
||
emitter.on('config', newConfig => { | ||
console.log('Received updated config:', JSON.stringify(newConfig)) | ||
queryParams = newConfig.labResultsParams | ||
}); | ||
|
||
function getQueryParameters() { return queryParams } | ||
module.exports = { getQueryParameters, queryParams }; |