diff --git a/.env b/.env index 72e4992..4427969 100644 --- a/.env +++ b/.env @@ -14,6 +14,93 @@ HOST_URL=${SERVER_SCHEME}://${HOST_NAME} TIMEZONE=UTC GITPOD_ENV=false ENABLE_SSO=false + +# Bahmni EMR + +RUN_WITH_BAHMNI_EMR=false + +# Mail Config Properties Environment Variables +MAIL_TRANSPORT_PROTOCOL=smtps +MAIL_SMTP_AUTH=true +MAIL_SMTP_STARTTLS_ENABLE=true +MAIL_SMTP_SSL_ENABLE=true +MAIL_DEBUG=false +SEND_MAIL=false +MAIL_FROM= +MAIL_SMTP_HOST= +MAIL_SMTP_PORT= +MAIL_USER= +MAIL_PASSWORD= + +# Bahmni Config Environment Variables +BAHMNI_CONFIG_IMAGE_TAG=1.0.0 +BAHMNI_CONFIG_VOLUME=bahmni-config +BAHMNI_CONFIG_OVERRIDE_PATH= + +# OpenMRS Environment Variables +OPENMRS_HOST=openmrs +OPENMRS_PORT=8080 +OPENMRS_IMAGE_TAG=1.1.1 +OPENMRS_DB_IMAGE_NAME=bahmni/openmrs-db:1.0.0-standard +OPENMRS_DB_NAME=openmrs +OPENMRS_DB_HOST=openmrsdb +OPENMRS_DB_USERNAME=openmrs-user +OPENMRS_DB_PASSWORD=password +OPENMRS_DB_SQL_MODES='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' +OPENMRS_DB_CREATE_TABLES='true' +OPENMRS_DB_AUTO_UPDATE='true' +OPENMRS_MODULE_WEB_ADMIN='false' +# OMRS_DEV_DEBUG_PORT= +OMRS_JAVA_SERVER_OPTS='' +OMRS_JAVA_MEMORY_OPTS='' +OPENMRS_UPLOAD_FILES_PATH=./openmrs-uploads +BAHMNI_OPENMRS_MODULES_PATH= +OPENMRS_DB_TYPE=mysql +OMRS_C3P0_MAX_SIZE=50 +WEIGHT_CONCEPT_UUID=5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +HEIGHT_CONCEPT_UUID=5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +OPENMRS_DOCKER_ENV='true' +OMRS_DB_EXTRA_ARGS="&zeroDateTimeBehavior=convertToNull" +LUCENE_MATCH_TYPE="START" +DOCUMENT_MAX_SIZE_MB= + +# Bahmni Web Environment Variables +BAHMNI_WEB_IMAGE_TAG=1.1.0 +BAHMNI_APPS_PATH= + +# Implementer Interface Environment Variables +IMPLEMENTER_INTERFACE_IMAGE_TAG=1.1.1 +IMPLEMENTER_INTERFACE_CODE_PATH= + +# Bahmni Reports Environment Variables +REPORTS_DB_IMAGE_NAME=mysql:8.0 +REPORTS_DB_NAME=bahmni_reports +REPORTS_DB_USERNAME=reports-user +REPORTS_DB_PASSWORD=password +REPORTS_IMAGE_TAG=1.1.0 + +#Patient Documents environmental variables +PATIENT_DOCUMENTS_TAG=1.1.1 + +#Appointments environmental variables +APPOINTMENTS_IMAGE_TAG=1.1.1 +APPOINTMENTS_PATH= + +#SMS-service Environment Variables +SMS_SERVICE_IMAGE_TAG=1.1.0 +SMS_TOKEN= +SMS_ORIGINATOR= +SMS_PROVIDER_API="https://api.d7networks.com/messages/v1/send" +SMS_COUNTRY_CODE= + +IPD_TAG=1.0.0 +IPD_PATH= + +# SNOMED-ICD10 Reporting +ICD10_LITE_INDICATOR=true + +# O3 EMR + # # OpenMRS # diff --git a/docker-compose-bahmniemr.yml b/docker-compose-bahmniemr.yml new file mode 100644 index 0000000..a6b66a9 --- /dev/null +++ b/docker-compose-bahmniemr.yml @@ -0,0 +1,222 @@ +x-default-logging: &default + {} + +x-log-config: &log-config + <<: *default + +services: + + bahmni-config: + image: 'bahmni/standard-config:${BAHMNI_CONFIG_IMAGE_TAG:?}' + volumes: + - '${BAHMNI_CONFIG_VOLUME:?}:/usr/local/bahmni_config' + - '${BAHMNI_CONFIG_OVERRIDE_PATH:-bahmni-config-override}:/usr/local/bahmni_config_override' + logging: *log-config + restart: unless-stopped + networks: + - ozone + command: ["sh", "-c", "rm -rf /etc/bahmni_config/masterdata/configuration && cp -r /usr/local/bahmni_config_override/bahmniemr_config/* /etc/bahmni_config/openmrs && ./start.sh"] + + openmrs: + image: bahmni/openmrs:${OPENMRS_IMAGE_TAG:?} + environment: + TZ: ${TIMEZONE} + OMRS_DB_NAME: ${OPENMRS_DB_NAME:?} + OMRS_DB_HOSTNAME: ${OPENMRS_DB_HOST:?} + OMRS_DB_USERNAME: ${OPENMRS_DB_USER:?} + OMRS_DB_PASSWORD: ${OPENMRS_DB_PASSWORD:?} + OMRS_CREATE_TABLES: ${OPENMRS_DB_CREATE_TABLES} + OMRS_AUTO_UPDATE_DATABASE: ${OPENMRS_DB_AUTO_UPDATE} + OMRS_MODULE_WEB_ADMIN: ${OPENMRS_MODULE_WEB_ADMIN} + # OMRS_DEV_DEBUG_PORT: ${OMRS_DEV_DEBUG_PORT} + OMRS_JAVA_SERVER_OPTS: ${OMRS_JAVA_SERVER_OPTS} + OMRS_JAVA_MEMORY_OPTS: ${OMRS_JAVA_MEMORY_OPTS} + SEND_MAIL: ${SEND_MAIL} + MAIL_TRANSPORT_PROTOCOL: ${MAIL_TRANSPORT_PROTOCOL} + MAIL_SMTP_HOST: ${MAIL_SMTP_HOST} + MAIL_SMTP_PORT: ${MAIL_SMTP_PORT} + MAIL_SMTP_AUTH: ${MAIL_SMTP_AUTH} + MAIL_SMTP_STARTTLS_ENABLE: ${MAIL_SMTP_STARTTLS_ENABLE} + MAIL_SMTP_SSL_ENABLE: ${MAIL_SMTP_SSL_ENABLE} + MAIL_DEBUG: ${MAIL_DEBUG} + MAIL_FROM: ${MAIL_FROM} + MAIL_USER: ${MAIL_USER} + MAIL_PASSWORD: ${MAIL_PASSWORD} + OMRS_DOCKER_ENV: ${OPENMRS_DOCKER_ENV} + OMRS_C3P0_MAX_SIZE: ${OMRS_C3P0_MAX_SIZE} + WEIGHT_CONCEPT_UUID: ${WEIGHT_CONCEPT_UUID} + HEIGHT_CONCEPT_UUID: ${HEIGHT_CONCEPT_UUID} + OMRS_DB_EXTRA_ARGS: ${OMRS_DB_EXTRA_ARGS} + LUCENE_MATCH_TYPE: ${LUCENE_MATCH_TYPE} + DOCUMENT_MAX_SIZE_MB: ${DOCUMENT_MAX_SIZE_MB} + #ports: + # - ${OMRS_DEV_DEBUG_PORT}:${OMRS_DEV_DEBUG_PORT} + volumes: + - "${BAHMNI_CONFIG_VOLUME:?}:/etc/bahmni_config/:ro" + - "bahmni-lab-results:/home/bahmni/uploaded_results" + - "bahmni-uploaded-files:/home/bahmni/uploaded-files" + - "${BAHMNI_OPENMRS_MODULES_PATH:?}/:/openmrs/distribution/openmrs_modules/" + - 'bahmni-patient-images:/home/bahmni/patient_images' + - 'bahmni-document-images:/home/bahmni/document_images' + - 'bahmni-clinical-forms:/home/bahmni/clinical_forms' + - "${BAHMNI_CONFIG_OVERRIDE_PATH:-openmrs-config}/initializer_config:/openmrs/distribution/openmrs_config/" + - 'configuration_checksums:/openmrs/data/configuration_checksums' + - 'sms-token:/openmrs/data/sms-token' + depends_on: + - mysql + logging: *log-config + restart: unless-stopped + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:8080/openmrs/index.htm" ] + interval: 10s + timeout: 5s + retries: 360 + start_period: 180s + networks: + - ozone + + mysql: + environment: + OPENMRS_DB_NAME: ${OPENMRS_DB_NAME} + OPENMRS_DB_USER: ${OPENMRS_DB_USER} + OPENMRS_DB_PASSWORD: ${OPENMRS_DB_PASSWORD} + volumes: + - "${SQL_SCRIPTS_PATH}/mysql/openmrs:/docker-entrypoint-initdb.d/db/openmrs" + # command: + # - "--sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" + logging: *log-config + + bahmni-web: + image: bahmni/bahmni-web:${BAHMNI_WEB_IMAGE_TAG:?} + volumes: + - "${BAHMNI_CONFIG_VOLUME:?}:/usr/local/apache2/htdocs/bahmni_config/:ro" + # - "${BAHMNI_APPS_PATH:?}/ui/app/:/usr/local/apache2/htdocs/bahmni" + # - "${BAHMNI_APPS_PATH:?}/ui/node_modules/@bower_components/:/usr/local/apache2/htdocs/bahmni/components" + logging: *log-config + restart: unless-stopped + networks: + - ozone + + implementer-interface: + image: bahmni/implementer-interface:${IMPLEMENTER_INTERFACE_IMAGE_TAG:?} + #volumes: + # - "${IMPLEMENTER_INTERFACE_CODE_PATH:?}/dist:/usr/local/apache2/htdocs/implementer_interface" + depends_on: + - openmrs + logging: *log-config + restart: unless-stopped + networks: + - ozone + + reports: + image: bahmni/reports:${REPORTS_IMAGE_TAG:?} + environment: + TZ: ${TIMEZONE} + OPENMRS_DB_HOST: ${OPENMRS_DB_HOST:?} + OPENMRS_DB_NAME: ${OPENMRS_DB_NAME:?} + OPENMRS_DB_USERNAME: root + OPENMRS_DB_PASSWORD: ${MYSQL_ROOT_PASSWORD:?} + OPENMRS_HOST: ${OPENMRS_HOST:?} + OPENMRS_PORT: ${OPENMRS_PORT:?} + REPORTS_DB_SERVER: reportsdb + REPORTS_DB_NAME: ${REPORTS_DB_NAME:?} + REPORTS_DB_USERNAME: ${REPORTS_DB_USERNAME:?} + REPORTS_DB_PASSWORD: ${REPORTS_DB_PASSWORD:?} + ODOO_DB_SERVER: ${POSTGRES_DB_HOST:?} + ODOO_DB_NAME: ${ODOO_DATABASE:?} + ODOO_DB_USERNAME: ${ODOO_DB_USER:?} + ODOO_DB_PASSWORD: ${ODOO_DB_PASSWORD:?} + ICD10_LITE_INDICATOR: ${ICD10_LITE_INDICATOR} + volumes: + - "${BAHMNI_CONFIG_VOLUME:?}:/etc/bahmni_config/:ro" + - "bahmni-queued-reports:/home/bahmni/reports" + # - "../snomed-resources/icd10-extensions-1.0.0-SNAPSHOT.jar:/var/run/bahmni-reports/bahmni-reports/WEB-INF/lib/icd10-extensions-1.0.0-SNAPSHOT.jar:ro" + depends_on: + - reportsdb + - mysql + - bahmni-web + logging: *log-config + restart: unless-stopped + networks: + - ozone + + reportsdb: + platform: linux/amd64 + image: ${REPORTS_DB_IMAGE_NAME:?} + environment: + TZ: ${TIMEZONE} + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?} + MYSQL_DATABASE: ${REPORTS_DB_NAME:?} + MYSQL_USER: ${REPORTS_DB_USERNAME:?} + MYSQL_PASSWORD: ${REPORTS_DB_PASSWORD:?} + volumes: + - 'reportsdbdata:/var/lib/mysql' + logging: *log-config + restart: unless-stopped + networks: + - ozone + + patient-documents: + image: 'bahmni/patient-documents:${PATIENT_DOCUMENTS_TAG:?}' + volumes: + - 'bahmni-document-images:/usr/share/nginx/html/document_images' + - 'bahmni-lab-results:/usr/share/nginx/html/uploaded_results' + - "bahmni-uploaded-files:/usr/share/nginx/html/uploaded-files" + environment: + TZ: ${TIMEZONE} + OPENMRS_HOST: ${OPENMRS_HOST:?} + depends_on: + - openmrs + logging: *log-config + restart: unless-stopped + networks: + - ozone + + appointments: + image: bahmni/appointments:${APPOINTMENTS_IMAGE_TAG:?} + restart: unless-stopped + # volumes: + # - "${APPOINTMENTS_PATH:?}/dist/:/usr/local/apache2/htdocs/appointments" + networks: + - ozone + + sms-service: + image: bahmni/sms-service:${SMS_SERVICE_IMAGE_TAG:?} + restart: unless-stopped + environment: + TZ: ${TIMEZONE} + SMS_TOKEN: ${SMS_TOKEN} + SMS_ORIGINATOR: ${SMS_ORIGINATOR} + SMS_PROVIDER_API: ${SMS_PROVIDER_API} + SMS_OPENMRS_HOST: ${OPENMRS_HOST:?} + SMS_OPENMRS_PORT: ${OPENMRS_PORT:?} + SMS_COUNTRY_CODE: ${SMS_COUNTRY_CODE} + volumes: + - 'sms-token:/opt/tokens' + networks: + - ozone + + ipd: + image: bahmni/microfrontend-ipd:${IPD_TAG:?} + container_name: ipd + restart: unless-stopped + # volumes: + # - "${IPD_PATH:?}/dist/federation/:/usr/local/apache2/htdocs/ipd" + logging: *log-config + networks: + - ozone + +volumes: + openmrs-data: + openmrsdbdata: + bahmni-config-override: ~ + bahmni-patient-images: + bahmni-document-images: + bahmni-clinical-forms: + bahmni-config: + bahmni-lab-results: + bahmni-uploaded-files: + configuration_checksums: + sms-token: + bahmni-queued-reports: + reportsdbdata: diff --git a/proxy/Dockerfile b/proxy/Dockerfile index e34fa0d..5f9c592 100644 --- a/proxy/Dockerfile +++ b/proxy/Dockerfile @@ -3,4 +3,5 @@ FROM nginx:1.25-alpine ENV FRAME_ANCESTORS "" COPY nginx.conf /etc/nginx/nginx.conf -COPY default.conf.template /etc/nginx/templates/ \ No newline at end of file +COPY default.conf.template /etc/nginx/templates/ +COPY bahmni/systemdate.sh /usr/local/bahmni/cgi-bin/systemdate \ No newline at end of file diff --git a/proxy/bahmni/systemdate.sh b/proxy/bahmni/systemdate.sh new file mode 100644 index 0000000..4f74d94 --- /dev/null +++ b/proxy/bahmni/systemdate.sh @@ -0,0 +1,8 @@ +# Note: This script has been copied from bahmni-playbboks/roles/bahmni-emr/files/systemdate.sh +#!/usr/bin/env bash +OUTPUT=$(date +"%D %r %Z") +OFFSET=$(date +"%z") + + echo "Content-type: application/json" + echo "" + echo "{\"date\": \"$OUTPUT\" , \"offset\" : \"$OFFSET\"}" \ No newline at end of file diff --git a/proxy/default.conf.template b/proxy/default.conf.template index 8a1306b..cbcc424 100644 --- a/proxy/default.conf.template +++ b/proxy/default.conf.template @@ -24,15 +24,6 @@ map $GITPOD_ENV $senaite_rewrite { default /VirtualHostBase/http/$host/senaite/VirtualHostRoot/; } -upstream frontend { - # always assume the frontend will be available - server frontend max_fails=0; -} - -upstream backend { - server openmrs:8080 max_fails=0; -} - server { listen 80; @@ -85,17 +76,157 @@ server { } location /openmrs/spa/ { - proxy_pass http://frontend/; + set $frontend frontend; + proxy_pass http://$frontend/; proxy_redirect http://$host/ /openmrs/spa/; } location /openmrs { - proxy_pass http://backend; + set $openmrs openmrs:8080; + proxy_pass http://$openmrs; } location = / { return 301 /openmrs/spa/; } + + # Uploaded Files + location = /uploaded-files { + return 301 /uploaded-files/; + } + + location /uploaded-files/ { + set $patient_documents patient-documents:80; + proxy_pass http://$patient_documents; + proxy_redirect http://$host/ /; + } + + # Patient Documents + location = /document_images { + return 301 /document_images/; + } + + location /document_images/ { + set $patient_documents patient-documents:80; + proxy_pass http://$patient_documents; + proxy_redirect http://$host/ /; + } + + # Lab Results + location = /uploaded_results { + return 301 /uploaded_results/; + } + + location /uploaded_results/ { + set $patient_documents patient-documents:80; + proxy_pass http://$patient_documents; + proxy_redirect http://$host/ /; + } + + # OpenMRS Authentication + location = /openmrs/auth { + return 301 /openmrs/auth/; + } + + location /openmrs/auth/ { + set $patient_documents patient-documents:80; + proxy_pass http://$patient_documents; + proxy_redirect http://$host/ /; + } + + # appointments + location = /appointments { + return 301 /appointments/; + } + + location /appointments/ { + set $appointments appointments:80; + proxy_pass http://$appointments; + proxy_redirect http://$host/ /; + } + + # ipd + location = /ipd { + return 301 /ipd/; + } + + location /ipd/ { + set $ipd ipd:80; + proxy_pass http://$ipd; + proxy_redirect http://$host/ /; + } + + # bahmnireports + location = /bahmnireports { + return 301 /bahmnireports/; + } + + location /bahmnireports/ { + set $bahmnireports reports:8051; + proxy_pass http://$bahmnireports; + proxy_redirect http://$host/ /; + } + + # Bahmni Web + location = /bahmni { + return 301 /bahmni/; + } + + location /bahmni/ { + set $bahmni_web bahmni-web:8091; + add_header X-Robots-Tag "noindex, nofollow"; + proxy_pass http://$bahmni_web; + proxy_redirect http://$host/ /; + } + + # Bahmni Person Management + location = /person-management { + return 301 /person-management/; + } + + location /person-management/ { + set $bahmni_web bahmni-web:8091; + proxy_pass http://$bahmni_web; + proxy_redirect http://$host/ /; + } + + # Bahmni Config OpenMRS Apps + location = /bahmni_config/openmrs/apps { + return 301 /bahmni_config/openmrs/apps/; + } + + location /bahmni_config/openmrs/apps/ { + set $bahmni_web bahmni-web:8091; + proxy_pass http://$bahmni_web; + proxy_redirect http://$host/ /; + } + + # Bahmni Config OpenMRS I18n + location = /bahmni_config/openmrs/i18n { + return 301 /bahmni_config/openmrs/i18n/; + } + + location /bahmni_config/openmrs/i18n/ { + set $bahmni_web bahmni-web:8091; + proxy_pass http://$bahmni_web; + proxy_redirect http://$host/ /; + } + + # Implementer Interface + location = /implementer-interface { + return 301 /implementer-interface/; + } + + location /implementer-interface/ { + set $implementer_interface implementer-interface:80; + proxy_pass http://$implementer_interface; + proxy_redirect http://$host/ /; + } + + # Bahmni's CGI script location + location /cgi-bin/ { + root /usr/local/bahmni; + } } server { @@ -105,7 +236,7 @@ server { # Increase proxy buffer size proxy_buffers 16 64k; proxy_buffer_size 128k; - # Force timeouts if the backend dies + # Force timeouts if the openmrs:8080 dies proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; # Enable data compression gzip on; diff --git a/scripts/docker-compose-files.txt b/scripts/docker-compose-files.txt index 723d993..49a0cd3 100755 --- a/scripts/docker-compose-files.txt +++ b/scripts/docker-compose-files.txt @@ -4,6 +4,7 @@ docker-compose-odoo.yml docker-compose-odoo-sso.yml docker-compose-openmrs.yml docker-compose-openmrs-sso.yml +docker-compose-bahmniemr.yml docker-compose-senaite.yml docker-compose-senaite-sso.yml docker-compose-backup.yml diff --git a/scripts/start-with-bahmniemr.sh b/scripts/start-with-bahmniemr.sh new file mode 100755 index 0000000..30d5149 --- /dev/null +++ b/scripts/start-with-bahmniemr.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e + +# Run with Bahmni EMR +export RUN_WITH_BAHMNI_EMR=true +echo "$INFO Setting RUN_WITH_BAHMNI_EMR=true..." +echo "→ RUN_WITH_BAHMNI_EMR=$RUN_WITH_BAHMNI_EMR" + +source start.sh diff --git a/scripts/utils.sh b/scripts/utils.sh index 529f368..8aab8e8 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -42,6 +42,8 @@ function exportPaths () { export ERPNEXT_SCRIPTS_PATH=$DISTRO_PATH/binaries/erpnext/scripts/ export KEYCLOAK_CONFIG_PATH=$DISTRO_PATH/configs/keycloak export KEYCLOAK_BINARIES_PATH=$DISTRO_PATH/binaries/keycloak + export BAHMNI_OPENMRS_MODULES_PATH=$DISTRO_PATH/binaries/bahmniemr/modules + export BAHMNI_CONFIG_OVERRIDE_PATH=$DISTRO_PATH/configs/bahmni echo "→ OPENMRS_CONFIG_PATH=$OPENMRS_CONFIG_PATH" echo "→ OPENMRS_PROPERTIES_PATH=$OPENMRS_PROPERTIES_PATH" @@ -62,12 +64,18 @@ function exportPaths () { echo "→ ERPNEXT_SCRIPTS_PATH=$ERPNEXT_SCRIPTS_PATH" echo "→ KEYCLOAK_CONFIG_PATH=$KEYCLOAK_CONFIG_PATH" echo "→ KEYCLOAK_BINARIES_PATH=$KEYCLOAK_BINARIES_PATH" - + echo "→ BAHMNI_OPENMRS_MODULES_PATH=$BAHMNI_OPENMRS_MODULES_PATH" + echo "→ BAHMNI_CONFIG_OVERRIDE_PATH=$BAHMNI_CONFIG_OVERRIDE_PATH" } function setDockerComposeCLIOptions () { # Parse 'docker-compose-files.txt' to get the list of Docker Compose files to run dockerComposeFiles=$(cat docker-compose-files.txt) + + if [ "$RUN_WITH_BAHMNI_EMR" == "true" ]; then + export ENABLE_SSO=false + fi + for file in ${dockerComposeFiles} do if [ "$ENABLE_SSO" != "true" ]; then @@ -75,6 +83,15 @@ function setDockerComposeCLIOptions () { continue fi fi + + if [[ "$file" == *"-bahmniemr.yml" && "$RUN_WITH_BAHMNI_EMR" == "false" ]]; then + continue + fi + + if [[ "$file" == *"-openmrs.yml" && "$RUN_WITH_BAHMNI_EMR" == "true" ]]; then + continue + fi + export dockerComposeFilesCLIOptions="$dockerComposeFilesCLIOptions -f ../$file" done