Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit

Permalink
NMA-618(Changed mediator port number, Added openhim response)
Browse files Browse the repository at this point in the history
  • Loading branch information
Collin-jehonia committed Oct 7, 2022
1 parent 82caa24 commit 3c5e6ed
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ CMD npm start

RUN npm install -g sequelize-cli

EXPOSE 4000
EXPOSE 4400

VOLUME [ "/app/node_modules" ]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ services:
build:
./
ports:
- "127.0.0.1:4000:4000"
- "127.0.0.1:2000:2000"
restart: unless-stopped

volumes:
Expand Down
6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/config/mediator-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"name": "DHIS2 Mediator Route",
"host": "dhis2-mediator",
"path": "/",
"port": "4000",
"port": "4400",
"primary": true,
"type": "http"
}
Expand Down
Empty file.
Empty file.
Empty file.
8 changes: 7 additions & 1 deletion src/dhis2/pushData.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ async function postDataToDhis2() {
}
}

async function getDataAndPostToDhis2(){
await this.postDataToDhis2().then(async(res)=>{
return res;
})
};

//save csv data before sending to DHIS2
function saveCsvFile(csvPath, csvData) {
Expand Down Expand Up @@ -63,5 +68,6 @@ module.exports = {
postPtrackerData,
getCsv,
saveCsvFile,
postDataToDhis2
postDataToDhis2,
getDataAndPostToDhis2
}
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ app.get('/openhim', async (req, res) => {
`\n${ new Date().toUTCString('en-GB', { timeZone: 'UTC' }) } - `,
`DHIS 2 <=> Database File Mediator has received a new request. \n`
);
pushData.postDataToDhis2()
//get data from CSV and send data to DHIS2
await pushData.getDataAndPostToDhis2()
.then((results) => {
res.json('PTracker data succesfully sent to DHIS2');
}).catch(error => { res.json(`Error retrieving PTracker Data: ${error}`) })
});
//middlleware
app.use(express.json())
Expand All @@ -26,7 +30,6 @@ app.use('/api/csv', router)
//openhim
getQueryParameters();


//Server PORT
app.listen(privateConfig.appConfig.PORT, (err) => {
if (err) console.log(`Error: ${err}`)
Expand Down

0 comments on commit 3c5e6ed

Please sign in to comment.