-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
32 changed files
with
1,201 additions
and
409 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
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,31 @@ | ||
version: '3.9' | ||
|
||
services: | ||
couchdb: | ||
image: public.ecr.aws/medic/cht-couchdb:4.1.0-alpha | ||
volumes: | ||
- couchdb-data:/opt/couchdb/data | ||
- cht-credentials:/opt/couchdb/etc/local.d/ | ||
environment: | ||
- "COUCHDB_USER=${COUCHDB_USER:-admin}" | ||
- "COUCHDB_PASSWORD=${COUCHDB_PASSWORD:-password}" | ||
- "COUCHDB_SECRET=${COUCHDB_SECRET:-secret}" | ||
- "COUCHDB_UUID=${COUCHDB_UUID:-CC0C3BA1-88EE-4AE3-BFD3-6E0EE56ED534}" | ||
- "SVC_NAME=${SVC_NAME:-couchdb}" | ||
- "COUCHDB_LOG_LEVEL=${COUCHDB_LOG_LEVEL:-error}" | ||
restart: always | ||
logging: | ||
driver: "local" | ||
options: | ||
max-size: "${LOG_MAX_SIZE:-50m}" | ||
max-file: "${LOG_MAX_FILES:-20}" | ||
networks: | ||
cht-net: | ||
|
||
volumes: | ||
cht-credentials: | ||
couchdb-data: | ||
|
||
networks: | ||
cht-net: | ||
name: ${CHT_NETWORK:-cht-net} |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ import * as dotenv from 'dotenv'; | |
dotenv.config(); | ||
|
||
export const PORT = process.env.PORT || 6000; | ||
const REQUEST_TIMEOUT = Number(getEnvironmentVariable('REQUEST_TIMEOUT', '5000')); | ||
|
||
export const OPENHIM = { | ||
username: getEnvironmentVariable('OPENHIM_USERNAME', '[email protected]'), | ||
|
@@ -11,27 +12,30 @@ export const OPENHIM = { | |
}; | ||
|
||
export const FHIR = { | ||
url: getEnvironmentVariable('FHIR_URL', 'http://openhim-core:5001/fhir'), | ||
url: getEnvironmentVariable('FHIR_URL', 'https://openhim-core:5001/fhir'), | ||
username: getEnvironmentVariable('FHIR_USERNAME', 'interop-client'), | ||
password: getEnvironmentVariable('FHIR_PASSWORD', 'interop-password'), | ||
timeout: Number(getEnvironmentVariable('REQUEST_TIMEOUT', '5000')) | ||
timeout: REQUEST_TIMEOUT | ||
}; | ||
|
||
export const CHT = { | ||
url: getEnvironmentVariable('CHT_URL', 'https://nginx'), | ||
username: getEnvironmentVariable('CHT_USERNAME', 'admin'), | ||
password: getEnvironmentVariable('CHT_PASSWORD', 'password'), | ||
timeout: Number(getEnvironmentVariable('REQUEST_TIMEOUT', '5000')) | ||
timeout: REQUEST_TIMEOUT | ||
}; | ||
|
||
export const OPENMRS = { | ||
url: getEnvironmentVariable('OPENMRS_CHANNEL_URL', 'http://openhim-core:5001/openmrs'), | ||
url: getEnvironmentVariable('OPENMRS_CHANNEL_URL', 'https://openhim-core:5001/openmrs'), | ||
username: getEnvironmentVariable('OPENMRS_CHANNEL_USERNAME', 'interop-client'), | ||
password: getEnvironmentVariable('OPENMRS_CHANNEL_PASSWORD', 'interop-password'), | ||
timeout: Number(getEnvironmentVariable('REQUEST_TIMEOUT', '5000')) | ||
timeout: REQUEST_TIMEOUT | ||
}; | ||
|
||
export const SYNC_INTERVAL = getEnvironmentVariable('SYNC_INTERVAL', '60000'); | ||
// how often in seconds the sync should run. hardcoded to 1 minute | ||
export const SYNC_INTERVAL = '60'; | ||
// how far back should the sync look for new resources. Defaults to one hour | ||
export const SYNC_PERIOD = getEnvironmentVariable('SYNC_PERIOD', '3600'); | ||
|
||
function getEnvironmentVariable(env: string, def: string) { | ||
if (process.env.NODE_ENV === 'test') { | ||
|
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
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,18 @@ | ||
import { logger } from '../../logger'; | ||
import { syncPatients, syncEncounters } from '../utils/openmrs_sync' | ||
import { SYNC_PERIOD } from '../../config' | ||
|
||
export async function sync() { | ||
try { | ||
let now = Date.now(); | ||
let syncPeriod = parseInt(SYNC_PERIOD, 10); | ||
let startTime = new Date(now - syncPeriod); | ||
|
||
await syncPatients(startTime); | ||
await syncEncounters(startTime); | ||
return { status: 200, data: { message: `OpenMRS sync completed successfully`} }; | ||
} catch(error: any) { | ||
logger.error(error); | ||
return { status: 500, data: { message: `Error during OpenMRS Sync`} }; | ||
} | ||
} |
Oops, something went wrong.