Skip to content

Commit

Permalink
Set up points to be saved for applications started and grafana gui
Browse files Browse the repository at this point in the history
  • Loading branch information
euanmillar committed Apr 2, 2020
1 parent fa2b406 commit e84e506
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 48 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Expand Up @@ -5,3 +5,4 @@
**/*.log
.secrets/*
data
grafana
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,6 +19,7 @@ build
!.secrets/.gitignore
.idea
data
grafana

.vscode/launch.json
.history
Expand Down
65 changes: 37 additions & 28 deletions docker-compose.dev-deps.yml
Expand Up @@ -7,28 +7,28 @@
#
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
# graphic logo are (registered/a) trademark(s) of Plan International.
version: '3.3'
version: "3.3"

services:
# For dependencies, expose ports locally for dev
mongo1:
ports:
- '27017:27017'
- "27017:27017"
volumes:
- './data/mongo:/data/db'
- "./data/mongo:/data/db"

redis:
ports:
- '6379:6379'
- "6379:6379"

elasticsearch:
ports:
- '9200:9200'
- '9300:9300'
- "9200:9200"
- "9300:9300"
volumes:
- './data/elasticsearch:/usr/share/elasticsearch/data'
- "./data/elasticsearch:/usr/share/elasticsearch/data"
environment:
- 'cluster.routing.allocation.disk.threshold_enabled=false'
- "cluster.routing.allocation.disk.threshold_enabled=false"
#- discovery.type=single-node
#- http.port=9200
#- http.cors.enabled=true
Expand All @@ -47,40 +47,49 @@ services:
#links:
# - elasticsearch

# grafana browser. Uncomment during development, to browse Influxdb via a GUI at http://localhost:4000/
# influx will be running on http://influxdb:8086
#grafana:
#image: grafana/grafana:5.1.0
#ports:
# - "4000:3000"
#volumes:
# - ./grafana:/var/lib/grafana

influxdb:
ports:
- '8086:8086'
- "8086:8086"
volumes:
- './data/influxdb:/var/lib/influxdb'
- "./data/influxdb:/var/lib/influxdb"

# Expose dev secrets as a plain volume - these will use docker secrets in staging and prod
hearth:
volumes:
- '.secrets/public-key.pem:/secrets/public-key.pem'
- './infrastructure/hearth-plugins/checkDuplicateTask.js:/src/hearth/lib/plugins/checkDuplicateTask.js'
- './infrastructure/hearth-queryparam-extensions.json:/src/hearth/config/queryparam-extensions.json'
- ".secrets/public-key.pem:/secrets/public-key.pem"
- "./infrastructure/hearth-plugins/checkDuplicateTask.js:/src/hearth/lib/plugins/checkDuplicateTask.js"
- "./infrastructure/hearth-queryparam-extensions.json:/src/hearth/config/queryparam-extensions.json"
ports:
- '3447:3447'
- "3447:3447"

# Expose config as a plain volume - these will use docker config in staging and prod
openhim-console:
volumes:
- './infrastructure/openhim-console-config.json:/usr/share/nginx/html/config/default.json'
- "./infrastructure/openhim-console-config.json:/usr/share/nginx/html/config/default.json"
ports:
- '8888:80'
- "8888:80"

openhim-core:
ports:
- '8080:8080'
- '5000:5000'
- '5001:5001'
- "8080:8080"
- "5000:5000"
- "5001:5001"
extra_hosts:
- 'gateway:${LOCAL_IP-172.17.0.1}'
- 'workflow:${LOCAL_IP-172.17.0.1}'
- 'search:${LOCAL_IP-172.17.0.1}'
- 'auth:${LOCAL_IP-172.17.0.1}'
- 'user-mgnt:${LOCAL_IP-172.17.0.1}'
- 'notification:${LOCAL_IP-172.17.0.1}'
- 'metrics:${LOCAL_IP-172.17.0.1}'
- 'bgd-dhis2-mediator:${LOCAL_IP-172.17.0.1}'
- 'ocrvs-chatbot-mediator:${LOCAL_IP-172.17.0.1}'
- "gateway:${LOCAL_IP-172.17.0.1}"
- "workflow:${LOCAL_IP-172.17.0.1}"
- "search:${LOCAL_IP-172.17.0.1}"
- "auth:${LOCAL_IP-172.17.0.1}"
- "user-mgnt:${LOCAL_IP-172.17.0.1}"
- "notification:${LOCAL_IP-172.17.0.1}"
- "metrics:${LOCAL_IP-172.17.0.1}"
- "bgd-dhis2-mediator:${LOCAL_IP-172.17.0.1}"
- "ocrvs-chatbot-mediator:${LOCAL_IP-172.17.0.1}"
3 changes: 2 additions & 1 deletion infrastructure/license-config.json
Expand Up @@ -19,7 +19,8 @@
"**/packages/components/lib",
"**/packages/*/build",
"packages/gateway/src/graphql/schema.d.ts",
"infrastructure/configure-file-monitoring.sh"
"infrastructure/configure-file-monitoring.sh",
"grafana"
],
"license": "infrastructure/license-header.txt",
"licenseFormats": {
Expand Down
28 changes: 28 additions & 0 deletions infrastructure/openhim-base-config.json
Expand Up @@ -240,6 +240,20 @@
"primary": true,
"username": "",
"password": ""
},
{
"type": "http",
"status": "enabled",
"forwardAuthHeader": true,
"name": "Metrics -> New Birth Validation",
"secured": false,
"host": "metrics",
"port": 1050,
"path": "",
"pathTransform": "",
"primary": false,
"username": "",
"password": ""
}
],
"priority": 1
Expand Down Expand Up @@ -1038,6 +1052,20 @@
"primary": true,
"username": "",
"password": ""
},
{
"type": "http",
"status": "enabled",
"forwardAuthHeader": true,
"name": "Metrics -> New Death Validation",
"secured": false,
"host": "metrics",
"port": 1050,
"path": "",
"pathTransform": "",
"primary": false,
"username": "",
"password": ""
}
],
"requestBody": true,
Expand Down
37 changes: 29 additions & 8 deletions packages/metrics/src/config/routes.ts
Expand Up @@ -16,9 +16,12 @@ import {
newBirthRegistrationHandler,
markCertifiedHandler,
markValidatedHandler,
baseHandler,
waitingValidationHandler,
markDeathRegisteredHandler,
newDeathRegistrationHandler
newDeathRegistrationHandler,
newDeclarationHandler,
newWaitingValidationHandler,
newValidationHandler
} from '@metrics/features/registration/handler'
import { metricsHandler } from '@metrics/features/metrics/handler'
import { getTimeLoggedHandler } from '@metrics/features/getTimeLogged/handler'
Expand Down Expand Up @@ -48,15 +51,33 @@ export const getRoutes = () => {
{
method: 'POST',
path: '/events/birth/new-declaration',
handler: baseHandler,
handler: newDeclarationHandler,
config: {
tags: ['api']
}
},
{
method: 'POST',
path: '/events/death/new-declaration',
handler: baseHandler,
handler: newDeclarationHandler,
config: {
tags: ['api']
}
},

// New validation
{
method: 'POST',
path: '/events/birth/new-validation',
handler: newValidationHandler,
config: {
tags: ['api']
}
},
{
method: 'POST',
path: '/events/death/new-validation',
handler: newValidationHandler,
config: {
tags: ['api']
}
Expand All @@ -66,31 +87,31 @@ export const getRoutes = () => {
{
method: 'POST',
path: '/events/birth/waiting-validation',
handler: baseHandler,
handler: waitingValidationHandler,
config: {
tags: ['api']
}
},
{
method: 'POST',
path: '/events/death/waiting-validation',
handler: baseHandler,
handler: waitingValidationHandler,
config: {
tags: ['api']
}
},
{
method: 'POST',
path: '/events/birth/new-waiting-validation',
handler: baseHandler,
handler: newWaitingValidationHandler,
config: {
tags: ['api']
}
},
{
method: 'POST',
path: '/events/death/new-waiting-validation',
handler: baseHandler,
handler: newWaitingValidationHandler,
config: {
tags: ['api']
}
Expand Down
7 changes: 7 additions & 0 deletions packages/metrics/src/features/metrics/constants.ts
Expand Up @@ -23,3 +23,10 @@ export const WITHIN_45_DAYS = 'DAYS_0_TO_45'
export const WITHIN_45_DAYS_TO_1_YEAR = 'DAYS_46_TO_365'
export const WITHIN_1_YEAR = 'DAYS_0_TO_365'
export const EVENT = 'event'
export const NOTIFICATION_TYPES = ['birth-notification', 'death-notification']
export enum Events {
IN_PROGRESS_DEC = 'in-progress-declaration', // Field agent or DHIS2 in progress
NEW_DEC = 'new-declaration', // Field agent complete
NEW_WAITING_VALIDATION = 'new-waiting-validation', // Registrar
NEW_VALIDATE = 'new-validation' // Registration agent new event
}
18 changes: 18 additions & 0 deletions packages/metrics/src/features/registration/fhirUtils.ts
Expand Up @@ -14,6 +14,7 @@ import { fetchTaskHistory } from '@metrics/api'

export const CAUSE_OF_DEATH_CODE = 'ICD10'
export const MANNER_OF_DEATH_CODE = 'uncertified-manner-of-death'
import { NOTIFICATION_TYPES } from '@metrics/features/metrics/constants'

export function getSectionBySectionCode(
bundle: fhir.Bundle,
Expand Down Expand Up @@ -206,6 +207,23 @@ export function getTimeLoggedFromTask(task: fhir.Task) {
return timeLoggedExt.valueInteger
}

export function isNotification(composition: fhir.Composition): boolean {
const compositionTypeCode =
composition.type.coding &&
composition.type.coding.find(
code => code.system === 'http://opencrvs.org/doc-types'
)
if (!compositionTypeCode) {
throw new Error('Composition has no type codings defined')
}

return (
(compositionTypeCode.code &&
NOTIFICATION_TYPES.includes(compositionTypeCode.code)) ||
false
)
}

export function getObservationValueByCode(
bundle: fhir.Bundle,
observationCode: string
Expand Down

0 comments on commit e84e506

Please sign in to comment.