-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OZ-741: Bahmni lab orders re-written as OpenMRS test orders.
- Loading branch information
Showing
3 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
189 changes: 189 additions & 0 deletions
189
distro/configs/bahmni/bahmni_eip/config/application.properties
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,189 @@ | ||
camel.springboot.xml-routes=classpath*:camel/*.xml,file:routes/*.xml,file:routes/*/*.xml,file:routes/*/*/*.xml | ||
|
||
openmrs.db.host=${OPENMRS_DB_HOST} | ||
|
||
# The OpenMRS MySQL database port | ||
openmrs.db.port=${OPENMRS_DB_PORT} | ||
|
||
# The OpenMRS MySQL database name | ||
openmrs.db.name=${OPENMRS_DB_NAME} | ||
# *********************** General EIP sender properties **************************************************************** | ||
# | ||
|
||
# Maximum size of each batch of source records to be read by debezium from the binlog files, maps to the | ||
## debezium MySQL connector property named max.batch.size | ||
#https://debezium.io/documentation/reference/1.6/connectors/mysql.html#mysql-property-max-batch-size | ||
debezium.reader.maxBatchSize=2048 | ||
|
||
# The client Id of the account. Defaults to empty. | ||
oauth.access.token.uri=${OAUTH_ACCESS_TOKEN_URL:} | ||
|
||
# The client Id of the account to use to authenticate. Defaults to empty. | ||
oauth.client.id=${OAUTH_CLIENT_ID:} | ||
|
||
# The client secret of the account to use to authenticate. Defaults to empty. | ||
oauth.client.secret=${OAUTH_CLIENT_SECRET:} | ||
|
||
# Authentication scope, can be multiple values separated by commas. Defaults to empty. | ||
oauth.client.scope=${OAUTH_CLIENT_SCOPE:} | ||
|
||
#Authentication scope, can be multiple values separated by commas | ||
oauth.client.scope=email | ||
|
||
eip.home=/eip-home | ||
|
||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
# *********************** Logging Configuration ************************************************************************ | ||
# | ||
# Uncomment this to use console logging otherwise defaults to the logback.xml file located on the classpath which is | ||
# configured to log to ${eip.home}/logs/openmrs-eip.log | ||
logging.config=classpath:logback-console.xml | ||
|
||
# Logging level for the application loggers (all built-in routes and classes) | ||
openmrs.eip.log.level=INFO | ||
|
||
# Logging level for ONLY application class loggers | ||
logging.level.org.openmrs.eip=${openmrs.eip.log.level} | ||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
# *********************** Tomcat Configuration ************************************************************************* | ||
# | ||
# Server HTTP port. | ||
server.port=8083 | ||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
# *********************** H2 configuration ***************************************************************************** | ||
# | ||
# Whether to enable the console | ||
#spring.h2.console.enabled=false | ||
|
||
# Path at which the console is available, defaults to /h2-console | ||
# spring.h2.console.path= | ||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
# *********************** Configuration of the OpenMRS Web App ********************************************************* | ||
# | ||
# OpenMRS user credentials | ||
openmrs.username=${OPENMRS_USER} | ||
openmrs.password=${OPENMRS_PASSWORD} | ||
|
||
# OpenMRS base url | ||
openmrs.baseUrl=${OPENMRS_URL}/openmrs | ||
|
||
# The results encounter type for all patient result observations | ||
results.encounterType.uuid=${RESULTS_ENCOUNTER_TYPE_UUID} | ||
|
||
|
||
concept.complex.uuid=${CONCEPT_COMPLEX_UUID} | ||
# ---------------------------------------------------------------------------------------------------------------------- | ||
openmrs.identifier.type.uuid=${OPENMRS_IDENTIFIER_TYPE_UUID} | ||
|
||
|
||
# *********************** OpenMRS Datasource config ******************************************************************** | ||
# | ||
# Driver class of the openMRS datasource (should not be changed in a usual use) | ||
spring.openmrs-datasource.driverClassName=com.mysql.jdbc.Driver | ||
# | ||
# Dialect of the openMRS datasource (should not be changed in a usual use) | ||
spring.openmrs-datasource.dialect=org.hibernate.dialect.MySQLDialect | ||
|
||
# Url of the openMRS datasource, you don't have to change this value as long you've set the placeholder property values | ||
spring.openmrs-datasource.jdbcUrl=jdbc:mysql://${openmrs.db.host}:${openmrs.db.port}/${openmrs.db.name} | ||
|
||
# User name of the openMRS datasource | ||
spring.openmrs-datasource.username=${OPENMRS_DB_USER} | ||
|
||
# Password of the openMRS datasource | ||
spring.openmrs-datasource.password=${OPENMRS_DB_PASSWORD} | ||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
# *********************** Debezium Config ****************************************************************************** | ||
|
||
# Unique logical name of the MySQL database server, maps to the debezium MySQL connector property named | ||
# database.server.name, DO NOT change after setting it | ||
debezium.db.serverName=${openmrs.db.name} | ||
|
||
# Database username for debezium user account you created to access the MySQL binlog, maps to the debezium MySQL | ||
# connector property named database.user, it's highly recommended to create separate user account as described at | ||
# https://debezium.io/documentation/reference/connectors/mysql.html#setting-up-mysql | ||
debezium.db.user=${MYSQL_ADMIN_USER} | ||
|
||
# Database password for debezium user account you created to access the MySQL binlog, maps to the debezium MySQL | ||
# connector property named database.password | ||
debezium.db.password=${MYSQL_ADMIN_USER_PASSWORD} | ||
|
||
# Specifies the criteria for running a snapshot when the connector starts, DO NOT change after setting it, maps to the | ||
# debezium MySQL connector property named snapshot.mode | ||
debezium.snapshotMode=schema_only | ||
|
||
# The 2 properties below are debezium engine specific and are documented at | ||
# https://debezium.io/documentation/reference/development/engine.html#engine-properties | ||
# | ||
# Path to file where offsets are to be stored, maps to property named offset.storage.file.filename, DO NOT change after | ||
# setting it | ||
debezium.offsetFilename=offsets.txt | ||
|
||
# Path to file where offsets are to be stored, maps to property named database.history.file.filename, DO NOT change | ||
# after setting it | ||
debezium.historyFilename=dbhistory.txt | ||
# ---------------------------------------------------------------------------------------------------------------------- | ||
debezium.snapshotLockingMode=extended | ||
|
||
# *********************** Configuration of the Senaite Web App ******************************************************* | ||
# | ||
# URL to connect to the SENAITE REST API | ||
senaite.baseUrl=${SENAITE_URL}/senaite | ||
|
||
# SENAITE username | ||
senaite.username=${SENAITE_USERNAME} | ||
|
||
# SENAITE password | ||
senaite.password=${SENAITE_PASSWORD} | ||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
fhirR4.baseUrl=${openmrs.baseUrl}/ws/fhir2/R4 | ||
|
||
# Camel endpoints that need to be notified of DB events | ||
db-event.destinations=direct:write-bahmniOrder-as-testOrder | ||
|
||
# Lab Order Type (Bahmni specific) | ||
bahmni.test.orderType.uuid=${BAHMNI_TEST_ORDER_TYPE_UUID} | ||
|
||
# *********************** Debezium Config ****************************************************************************** | ||
# | ||
# For details explanations of this properties, please refer to | ||
# https://debezium.io/documentation/reference/connectors/mysql.html#mysql-connector-properties | ||
# Maps to the connect property named database.server.id, MUST match the server-id value in your my.cnf file when you | ||
# enabled mysql binlog, DO NOT change after setting it | ||
debezium.db.serverId=27555 | ||
|
||
# A comma separated list of database tables names to watch for changes | ||
eip.watchedTables=orders | ||
|
||
# *********************** Configuration of the Management database ***************************************************** | ||
# | ||
# Driver class of the management datasource (should not be changed in a usual use) | ||
spring.mngt-datasource.driverClassName=com.mysql.jdbc.Driver | ||
|
||
# Dialect of the management datasource (should not be changed in a usual use) | ||
spring.mngt-datasource.dialect=org.hibernate.dialect.MySQLDialect | ||
|
||
# Url of the management datasource | ||
# spring.mngt-datasource.jdbcUrl=jdbc:h2:mem:test;DB_CLOSE_DELAY=30;LOCK_TIMEOUT=10000 | ||
spring.mngt-datasource.jdbcUrl=jdbc:mysql://${openmrs.db.host}:${openmrs.db.port}/${EIP_DB_NAME_SENAITE} | ||
|
||
# User name of the management datasource | ||
spring.mngt-datasource.username=${EIP_DB_USER_SENAITE} | ||
|
||
# Password of the management datasource | ||
spring.mngt-datasource.password=${EIP_DB_PASSWORD_SENAITE} | ||
|
||
debezium.extraParameters=&databaseHistorySkipUnparseableDdl=true |
35 changes: 35 additions & 0 deletions
35
distro/configs/bahmni/bahmni_eip/routes/write-bahmniOrder-as-testOrder.xml
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,35 @@ | ||
<routes xmlns="http://camel.apache.org/schema/spring"> | ||
<route id="write-bahmniOrder-as-testOrder" errorHandlerRef="watcherErrorHandler"> | ||
<from uri="direct:write-bahmniOrder-as-testOrder"/> | ||
<setProperty name="bahmniTestOrderTypeUuid"> | ||
<simple>${properties:bahmni.test.orderType.uuid:'xxxxx'}</simple> | ||
</setProperty> | ||
<log message="Processing Test Order from Order"/> | ||
<choice> | ||
<when> | ||
<simple>${exchangeProperty.event.tableName} == 'orders' && ${exchangeProperty.event.operation} == 'c'</simple> | ||
<!-- Query database to check if the order already exists in test_order table --> | ||
<toD uri="sql:SELECT COUNT(*) total FROM test_order WHERE order_id=${exchangeProperty.event.primaryKeyId}?dataSource=openmrsDataSource"/> | ||
<choice> | ||
<when> | ||
<!-- Proceed only if no associated test_order --> | ||
<jsonpath>$.[?(@.total == 0)]</jsonpath> | ||
<toD uri="sql:SELECT ot.uuid as order_type_uuid from order_type ot join orders o on o.order_type_id = ot.order_type_id where o.uuid ='${exchangeProperty.event.identifier}'?dataSource=#openmrsDataSource"/> | ||
<choice> | ||
<when> | ||
<!-- Check if it's the correct order type --> | ||
<jsonpath>$.[?(@.order_type_uuid == '${exchangeProperty.bahmniTestOrderTypeUuid}')] </jsonpath> | ||
<!-- Insert a new record into test_order if it's the correct order type --> | ||
<toD uri="sql:INSERT INTO test_order(order_id) VALUES (${exchangeProperty.event.primaryKeyId})?dataSource=openmrsDataSource"/> | ||
</when> | ||
</choice> | ||
</when> | ||
<otherwise> | ||
<!-- Do nothing if the related test order exists --> | ||
<log message="Related test order exists, no action needed."/> | ||
</otherwise> | ||
</choice> | ||
</when> | ||
</choice> | ||
</route> | ||
</routes> |
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,26 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
function create_user_and_database() { | ||
mysql --password=$MYSQL_ROOT_PASSWORD --user=root <<MYSQL_SCRIPT | ||
CREATE DATABASE $1; | ||
CREATE USER '$2'@'localhost' IDENTIFIED BY '$3'; | ||
CREATE USER '$2'@'%' IDENTIFIED BY '$3'; | ||
GRANT ALL PRIVILEGES ON $1.* TO '$2'@'localhost'; | ||
GRANT ALL PRIVILEGES ON $1.* TO '$2'@'%'; | ||
FLUSH PRIVILEGES; | ||
MYSQL_SCRIPT | ||
} | ||
|
||
create_eip_client_user_and_database() { | ||
local dbName="${1:-}" | ||
local dbUser="${2:-}" | ||
local dbUserPassword="${3:-}" | ||
if [ "${dbName:-}" ] && [ "${dbUser:-}" ] && [ "${dbUserPassword:-}" ]; then | ||
create_user_and_database "$dbName" "$dbUser" "$dbUserPassword"; | ||
fi | ||
} | ||
|
||
echo "Creating '${EIP_DB_USER_BAHMNI}' user and '${EIP_DB_NAME_BAHMNI}' database..." | ||
create_eip_client_user_and_database ${EIP_DB_NAME_BAHMNI:-} ${EIP_DB_USER_BAHMNI:-} ${EIP_DB_PASSWORD_BAHMNI:-}; |