From 9c2e3cf226f28ac908099504aefad1d13d73b434 Mon Sep 17 00:00:00 2001 From: "Kipchumba C. Bett" Date: Wed, 13 Jul 2022 09:53:16 +0300 Subject: [PATCH 1/4] docker support for development environment --- .dockerignore | 5 +++ .gitignore | 7 ++++ docker-compose.yml | 50 ++++++++++++++++++++++++++ install-maven.sh | 32 +++++++++++++++++ module.properties | 4 +++ prepare.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 187 insertions(+) create mode 100644 .dockerignore create mode 100644 docker-compose.yml create mode 100644 install-maven.sh create mode 100644 module.properties create mode 100644 prepare.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..ab5c2e35 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +############################## +## Docker ignore java outputs,git +############################## +.git/ +target/ diff --git a/.gitignore b/.gitignore index d9c3792c..825a9990 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,10 @@ nb-configuration.xml ## OS X ############################## .DS_Store + +############################## +## ENV Variables and .omod +############################## +.env +required_modules +.omod diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..69b8894a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,50 @@ +version: "3.8" + +# This Source Code Form is subject to the terms of the Mozilla Public License, +# v. 2.0. If a copy of the MPL was not distributed with this file, You can +# obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under +# the terms of the Healthcare Disclaimer located at http://openmrs.org/license. +# +# Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS +# graphic logo is a trademark of OpenMRS Inc. + +services: + db: + image: mariadb:10.3 + command: "mysqld --character-set-server=utf8 --collation-server=utf8_general_ci" + environment: + MYSQL_DATABASE: ${OPENMRS_DB_NAME:-openmrs} + MYSQL_USER: ${OPENMRS_DB_USER:-openmrs} + MYSQL_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} + MYSQL_ROOT_PASSWORD: ${OPENMRS_DB_ROOT_PASSWORD:-openmrs} + deploy: + #replicas: ${OPENMRS_DB_REPLICAS} + replicas: 0 + restart_policy: + max_attempts: 3 + volumes: + - db-data:/var/lib/mysql + + openmrs-core: + image: openmrs/openmrs-core:${OPENMRS_CORE_VERSION:-dev} + ports: + - "8080:8080" + - "8000:8000" + restart: "no" + environment: + OMRS_CONFIG_MODULE_WEB_ADMIN: "true" + OMRS_CONFIG_AUTO_UPDATE_DATABASE: "true" + OMRS_CONFIG_CREATE_TABLES: "true" + OMRS_CONFIG_CONNECTION_SERVER: ${OPENMRS_DB:-openmrs} + OMRS_CONFIG_CONNECTION_DATABASE: ${OPENMRS_DB_NAME:-openmrs} + OMRS_CONFIG_CONNECTION_USERNAME: ${OPENMRS_DB_USER:-openmrs} + OMRS_CONFIG_CONNECTION_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:8080/openmrs" ] + timeout: 5s + volumes: + - ${PWD}/omod/target/${OMOD_TARGET}:/root/.OpenMRS/modules/${OMOD_TARGET} + - ${PWD}/required_modules:/root/.OpenMRS/modules + +volumes: + db-data: diff --git a/install-maven.sh b/install-maven.sh new file mode 100644 index 00000000..ac75832f --- /dev/null +++ b/install-maven.sh @@ -0,0 +1,32 @@ +#!/bin/sh +set -e + +# script to install maven + +# TODO: Automatically grab the latest version +mvn_version=${mvn_version:-3.8.6} +url="http://www.mirrorservice.org/sites/ftp.apache.org/maven/maven-3/${mvn_version}/binaries/apache-maven-${mvn_version}-bin.tar.gz" +install_dir="/opt/maven" + +if [ -d ${install_dir} ]; then + mv ${install_dir} ${install_dir}."$(date +"%Y%m%d")" +fi + +mkdir ${install_dir} +curl -fsSL "${url}" | tar zx --strip-components=1 -C ${install_dir} + +cat << EOF > /etc/profile.d/maven.sh +#!/bin/sh +export MAVEN_HOME=${install_dir} +export M2_HOME=${install_dir} +export M2=${install_dir}/bin +export PATH=${install_dir}/bin:$PATH +EOF + +# shellcheck disable=SC2039 +source /etc/profile.d/maven.sh + +echo maven installed to ${install_dir} +mvn --version + +printf "\n\nTo get mvn in your path, open a new shell or execute: source /etc/profile.d/maven.sh\n" diff --git a/module.properties b/module.properties new file mode 100644 index 00000000..d259c705 --- /dev/null +++ b/module.properties @@ -0,0 +1,4 @@ +version=0.0.1-DEV +war.openmrs=2.6.0-SNAPSHOT +name=Queue module +omod.webservices.rest=2.36.0 diff --git a/prepare.sh b/prepare.sh new file mode 100644 index 00000000..c4aa242f --- /dev/null +++ b/prepare.sh @@ -0,0 +1,89 @@ +#!/bin/sh +set -e + +# This Source Code Form is subject to the terms of the Mozilla Public License, +# v. 2.0. If a copy of the MPL was not distributed with this file, You can +# obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under +# the terms of the Healthcare Disclaimer located at http://openmrs.org/license. +# +# Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS +# graphic logo is a trademark of OpenMRS Inc. + +# This script is used to setup the development environment for the module. +# It is run once when the project is first clone/created. +# Downloads the required openmrs modules and installs them. + +OPENMRS_SDK_PLUGIN="org.openmrs.maven.plugins:openmrs-sdk-maven-plugin" +MODULES_DIR="required_modules" + +#Extract project artifactId & version +OMOD_NAME=$(mvn help:evaluate -Dexpression=project.artifactId | grep -e '^[^\[]') +OMOD_VERSION=$(mvn help:evaluate -Dexpression=project.version | grep -e '^[^\[]') +echo "Current version: $OMOD_NAME-$OMOD_VERSION" + +installMaven() { + # Linux/unix + # TODO: Find a better way to do this + sh install-maven.sh +} + +createEnvironmentVariablesFile() { + cat <.env +OPENMRS_CORE_VERSION=dev + +OPENMRS_DB=localhost +OPENMRS_DB_NAME=openmrs +OPENMRS_DB_USER=openmrs +OPENMRS_DB_PASSWORD=openmrs +OPENMRS_DB_REPLICAS=0 + +#Omod file name +OMOD_TARGET="$OMOD_NAME-$OMOD_VERSION.omod" +EOF +} + +setupOpenmrsSDK() { + # Setup SDK + mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B + #docker run -it -v maven-repo:/root/.m2 maven mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B +} + +downloadArtifacts() { + #prepare the dir + if [ -d "${MODULES_DIR}" ]; then + echo "${MODULES_DIR} dir is already exists." + #Remove contents + rm -rf "${MODULES_DIR:?}/"* + else + echo "Creating ${MODULES_DIR} directory..." + mkdir -p "${MODULES_DIR}" + fi + + mkdir -p artifacts + # Download modules + #docker run -it openmrs/openmrs-core:dev-m1 mvn "$OPENMRS_SDK_PLUGIN":build-distro -Ddistro=module.properties -Ddir=artifacts -B + mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B + cp -r artifacts/web/modules/* "${MODULES_DIR}" + # Clean up artifacts + rm -rf artifacts +} + +if [ -x "$(command -v docker)" ]; then + installed_docker_version=$(docker --version) + echo "Installed ${installed_docker_version}" + echo "configuring openmrs sdk..." + + #docker run openmrs/openmrs-core:dev + #docker run openmrs/openmrs-core:dev mvn + + if ! command -v mvn -v &>/dev/null; then + echo "Installing maven..." + installMaven + fi + + setupOpenmrsSDK + downloadArtifacts + createEnvironmentVariablesFile +else + printf "Please install Docker and re-run setup script.\n" +fi From 92321dd740fdff76554304ebaad01abc55ad8ff7 Mon Sep 17 00:00:00 2001 From: "Kipchumba C. Bett" Date: Wed, 13 Jul 2022 11:04:00 +0300 Subject: [PATCH 2/4] some refactoring --- README.md | 49 +++++++++++++++++++++++++++++ docker-compose.yml | 4 +-- prepare.sh => prepare-docker-env.sh | 21 ++++++++----- 3 files changed, 64 insertions(+), 10 deletions(-) rename prepare.sh => prepare-docker-env.sh (83%) diff --git a/README.md b/README.md index 2bbf021b..f90f65dc 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,55 @@ Openmrs-module-queue - Java 8 or higher - Webservices rest module -(Always bundled with the platform) +## Docker development environment +To prepare environment for development of the module, execute the following command; + +```bash +sh prepare-docker-env.sh +``` +The above command will create a directory named `required_modules` in the current directory and install all required modules. +Also, it will create an environment file named `.env` in the current directory and populate it with the following variables: + +``` +# OpenMRS core platform version. +OPENMRS_CORE_VERSION=dev + +# To use an existing database, set the following variables. +OPENMRS_DB=localhost +OPENMRS_DB_NAME=openmrs +OPENMRS_DB_USER=openmrs +OPENMRS_DB_PASSWORD=openmrs + +# To use an existing database, set this variable to 0 +# To create a new database, set this variable to 1 +OPENMRS_DB_REPLICAS=1 + +# OMOD file name +OMOD_TARGET="queue-1.0.0-SNAPSHOT.omod" + +``` +Now, you can spin up an OpenMRS instance with the `required_modules` by executing the following command; + +```bash +docker-compose up -d +``` + +To deploy module changes, run the following command; + +```bash + docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev-m1 mvn clean install +``` +Or if you already have maven installed on your system, you can use the following command; + +```bash +mvn clean install +``` +Then, you can restart the container(OpenMRS instance) by executing the following command; + +```bash +docker-compose restart +``` + ## Configurations After installing the queue module, configure the following GPs according to your implementation needs. Note that this is a diff --git a/docker-compose.yml b/docker-compose.yml index 69b8894a..87c9c528 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,8 +18,8 @@ services: MYSQL_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} MYSQL_ROOT_PASSWORD: ${OPENMRS_DB_ROOT_PASSWORD:-openmrs} deploy: - #replicas: ${OPENMRS_DB_REPLICAS} - replicas: 0 + replicas: '${OPENMRS_DB_REPLICAS}' + #replicas: 0 restart_policy: max_attempts: 3 volumes: diff --git a/prepare.sh b/prepare-docker-env.sh similarity index 83% rename from prepare.sh rename to prepare-docker-env.sh index c4aa242f..a03e4404 100644 --- a/prepare.sh +++ b/prepare-docker-env.sh @@ -23,21 +23,26 @@ echo "Current version: $OMOD_NAME-$OMOD_VERSION" installMaven() { # Linux/unix - # TODO: Find a better way to do this + # TODO: Find a better way to do this (No mvn install needed) sh install-maven.sh } createEnvironmentVariablesFile() { cat <.env +# OpenMRS core platform version. OPENMRS_CORE_VERSION=dev +# To use an existing database, set the following variables. OPENMRS_DB=localhost OPENMRS_DB_NAME=openmrs OPENMRS_DB_USER=openmrs OPENMRS_DB_PASSWORD=openmrs -OPENMRS_DB_REPLICAS=0 -#Omod file name +# To use an existing database, set this variable to 0 +# To create a new database, set this variable to 1 +OPENMRS_DB_REPLICAS=1 + +# OMOD file name OMOD_TARGET="$OMOD_NAME-$OMOD_VERSION.omod" EOF } @@ -49,10 +54,10 @@ setupOpenmrsSDK() { } downloadArtifacts() { - #prepare the dir + # Prepare the modules dir if [ -d "${MODULES_DIR}" ]; then echo "${MODULES_DIR} dir is already exists." - #Remove contents + # Remove contents rm -rf "${MODULES_DIR:?}/"* else echo "Creating ${MODULES_DIR} directory..." @@ -73,8 +78,8 @@ if [ -x "$(command -v docker)" ]; then echo "Installed ${installed_docker_version}" echo "configuring openmrs sdk..." - #docker run openmrs/openmrs-core:dev - #docker run openmrs/openmrs-core:dev mvn + # docker run openmrs/openmrs-core:dev + # docker run openmrs/openmrs-core:dev mvn if ! command -v mvn -v &>/dev/null; then echo "Installing maven..." @@ -85,5 +90,5 @@ if [ -x "$(command -v docker)" ]; then downloadArtifacts createEnvironmentVariablesFile else - printf "Please install Docker and re-run setup script.\n" + printf "Please install Docker and re-run prepare script.\n" fi From f6f42b23758d47e9be4590cff94bbd3393a866d7 Mon Sep 17 00:00:00 2001 From: "Kipchumba C. Bett" Date: Wed, 13 Jul 2022 15:09:35 +0300 Subject: [PATCH 3/4] Zero installation/configuration but docker --- README.md | 8 +++--- install-maven.sh | 32 ---------------------- prepare-docker-env.sh | 63 +++++++++++++++---------------------------- 3 files changed, 26 insertions(+), 77 deletions(-) delete mode 100644 install-maven.sh diff --git a/README.md b/README.md index f90f65dc..594bdc14 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Openmrs-module-queue - Webservices rest module -(Always bundled with the platform) ## Docker development environment -To prepare environment for development of the module, execute the following command; +Prepare the docker development environment by executing the following command; ```bash sh prepare-docker-env.sh @@ -40,7 +40,7 @@ OPENMRS_DB_REPLICAS=1 OMOD_TARGET="queue-1.0.0-SNAPSHOT.omod" ``` -Now, you can spin up an OpenMRS instance with the `required_modules` by executing the following command; +Now, spin up an OpenMRS instance with`required_modules` by executing the following command; ```bash docker-compose up -d @@ -51,12 +51,12 @@ To deploy module changes, run the following command; ```bash docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev-m1 mvn clean install ``` -Or if you already have maven installed on your system, you can use the following command; +Or if you already have maven installed on your system, use the following command; ```bash mvn clean install ``` -Then, you can restart the container(OpenMRS instance) by executing the following command; +Then, restart the container(OpenMRS instance) by executing the following command; ```bash docker-compose restart diff --git a/install-maven.sh b/install-maven.sh deleted file mode 100644 index ac75832f..00000000 --- a/install-maven.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -set -e - -# script to install maven - -# TODO: Automatically grab the latest version -mvn_version=${mvn_version:-3.8.6} -url="http://www.mirrorservice.org/sites/ftp.apache.org/maven/maven-3/${mvn_version}/binaries/apache-maven-${mvn_version}-bin.tar.gz" -install_dir="/opt/maven" - -if [ -d ${install_dir} ]; then - mv ${install_dir} ${install_dir}."$(date +"%Y%m%d")" -fi - -mkdir ${install_dir} -curl -fsSL "${url}" | tar zx --strip-components=1 -C ${install_dir} - -cat << EOF > /etc/profile.d/maven.sh -#!/bin/sh -export MAVEN_HOME=${install_dir} -export M2_HOME=${install_dir} -export M2=${install_dir}/bin -export PATH=${install_dir}/bin:$PATH -EOF - -# shellcheck disable=SC2039 -source /etc/profile.d/maven.sh - -echo maven installed to ${install_dir} -mvn --version - -printf "\n\nTo get mvn in your path, open a new shell or execute: source /etc/profile.d/maven.sh\n" diff --git a/prepare-docker-env.sh b/prepare-docker-env.sh index a03e4404..3533044c 100644 --- a/prepare-docker-env.sh +++ b/prepare-docker-env.sh @@ -9,25 +9,19 @@ set -e # Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS # graphic logo is a trademark of OpenMRS Inc. -# This script is used to setup the development environment for the module. -# It is run once when the project is first clone/created. +# This script is used to setup the development environment for this module. +# It should be run once when the project is first clone/created. # Downloads the required openmrs modules and installs them. OPENMRS_SDK_PLUGIN="org.openmrs.maven.plugins:openmrs-sdk-maven-plugin" MODULES_DIR="required_modules" -#Extract project artifactId & version +# Extract project artifactId & version OMOD_NAME=$(mvn help:evaluate -Dexpression=project.artifactId | grep -e '^[^\[]') OMOD_VERSION=$(mvn help:evaluate -Dexpression=project.version | grep -e '^[^\[]') echo "Current version: $OMOD_NAME-$OMOD_VERSION" -installMaven() { - # Linux/unix - # TODO: Find a better way to do this (No mvn install needed) - sh install-maven.sh -} - -createEnvironmentVariablesFile() { +create_environment_variables_file() { cat <.env # OpenMRS core platform version. OPENMRS_CORE_VERSION=dev @@ -47,48 +41,35 @@ OMOD_TARGET="$OMOD_NAME-$OMOD_VERSION.omod" EOF } -setupOpenmrsSDK() { - # Setup SDK - mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B - #docker run -it -v maven-repo:/root/.m2 maven mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B +prepare_modules_directory() { + # prepare modules directory + if [ -d "${MODULES_DIR}" ]; then + echo "${MODULES_DIR} dir is already exists." + # remove contents + rm -rf "${MODULES_DIR:?}/"* + else + echo "Creating ${MODULES_DIR} directory..." + mkdir -p "${MODULES_DIR}" + fi } -downloadArtifacts() { - # Prepare the modules dir - if [ -d "${MODULES_DIR}" ]; then - echo "${MODULES_DIR} dir is already exists." - # Remove contents - rm -rf "${MODULES_DIR:?}/"* - else - echo "Creating ${MODULES_DIR} directory..." - mkdir -p "${MODULES_DIR}" - fi - +download_artifacts() { mkdir -p artifacts - # Download modules - #docker run -it openmrs/openmrs-core:dev-m1 mvn "$OPENMRS_SDK_PLUGIN":build-distro -Ddistro=module.properties -Ddir=artifacts -B - mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B + # download modules + docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B + # copy downloaded modules to ${MODULES_DIR} directory cp -r artifacts/web/modules/* "${MODULES_DIR}" - # Clean up artifacts + # clean up artifacts rm -rf artifacts } if [ -x "$(command -v docker)" ]; then installed_docker_version=$(docker --version) echo "Installed ${installed_docker_version}" - echo "configuring openmrs sdk..." - - # docker run openmrs/openmrs-core:dev - # docker run openmrs/openmrs-core:dev mvn - - if ! command -v mvn -v &>/dev/null; then - echo "Installing maven..." - installMaven - fi - setupOpenmrsSDK - downloadArtifacts - createEnvironmentVariablesFile + prepare_modules_directory + download_artifacts + create_environment_variables_file else printf "Please install Docker and re-run prepare script.\n" fi From 99f16039fd3206fcd78a102f579576c7634ba820 Mon Sep 17 00:00:00 2001 From: "Kipchumba C. Bett" Date: Wed, 12 Oct 2022 11:21:26 +0300 Subject: [PATCH 4/4] Fine tuning --- README.md | 130 +++++++++++++++++------------------------- docker-compose.yml | 13 ++--- prepare-docker-env.sh | 75 ------------------------ 3 files changed, 59 insertions(+), 159 deletions(-) delete mode 100644 prepare-docker-env.sh diff --git a/README.md b/README.md index 594bdc14..aa1de846 100644 --- a/README.md +++ b/README.md @@ -13,65 +13,33 @@ Openmrs-module-queue - Java 8 or higher - Webservices rest module -(Always bundled with the platform) -## Docker development environment -Prepare the docker development environment by executing the following command; +## Development -```bash -sh prepare-docker-env.sh -``` -The above command will create a directory named `required_modules` in the current directory and install all required modules. -Also, it will create an environment file named `.env` in the current directory and populate it with the following variables: - -``` -# OpenMRS core platform version. -OPENMRS_CORE_VERSION=dev +### Using docker -# To use an existing database, set the following variables. -OPENMRS_DB=localhost -OPENMRS_DB_NAME=openmrs -OPENMRS_DB_USER=openmrs -OPENMRS_DB_PASSWORD=openmrs +The `docker-compose.yml` at the root of this repository defines local development environment, including environment +variables, +ports you need accessible, and volumes to mount. -# To use an existing database, set this variable to 0 -# To create a new database, set this variable to 1 -OPENMRS_DB_REPLICAS=1 - -# OMOD file name -OMOD_TARGET="queue-1.0.0-SNAPSHOT.omod" - -``` -Now, spin up an OpenMRS instance with`required_modules` by executing the following command; - -```bash -docker-compose up -d -``` - -To deploy module changes, run the following command; - -```bash - docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev-m1 mvn clean install -``` -Or if you already have maven installed on your system, use the following command; +Now that the local development environment is defined in `docker-compose.yml`, you can spin up an instance of OpenMRS service +with the specified modules with one command: -```bash -mvn clean install +```shell + docker-compose up -d ``` -Then, restart the container(OpenMRS instance) by executing the following command; -```bash -docker-compose restart -``` +TODO ## Configurations After installing the queue module, configure the following GPs according to your implementation needs. Note that this is a necessary step, no defaults provided. -|Property | Default value | Description -|:---|---|---| -|queue.statusConceptSetName | Queue Status | A set of concepts for queue status, i.e Waiting for Service, With Service, and Finished With Service | -|queue.priorityConceptSetName | Queue Priority | A set of queue priority concepts e.g Urgent, Emergency, Not Urgent | -|queue.serviceConceptSetName | Queue Service | A set of queue service concepts. Services offered in a clinic e.g Triage, Consultation, ... | +| Property | Default value | Description | +|:-----------------------------|----------------|------------------------------------------------------------------------------------------------------| +| queue.statusConceptSetName | Queue Status | A set of concepts for queue status, i.e Waiting for Service, With Service, and Finished With Service | +| queue.priorityConceptSetName | Queue Priority | A set of queue priority concepts e.g Urgent, Emergency, Not Urgent | +| queue.serviceConceptSetName | Queue Service | A set of queue service concepts. Services offered in a clinic e.g Triage, Consultation, ... | ## Rest docs @@ -88,9 +56,9 @@ Retrieve a queue by UUID. Returns a `404 Not found` status if the queue(to be re GET /ws/rest/v1/queue/ ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | -| `UUID` | `string` | UUID of queue to be retrieved | +| Parameter | Type | Description | +|:----------|:---------|:------------------------------| +| `UUID` | `string` | UUID of queue to be retrieved | #### Create queue @@ -128,9 +96,9 @@ queue(to be updated) doesn't exist. If not authenticated, 401 Unauthorized statu POST /ws/rest/v1/queue/ ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | -| `UUID` | `string` | UUID of queue to be updated | +| Parameter | Type | Description | +|:----------|:---------|:----------------------------| +| `UUID` | `string` | UUID of queue to be updated | Body @@ -150,10 +118,10 @@ authenticated, 401 Unauthorized status is returned. DELETE /ws/rest/v1/queue/?purge=false ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | -| `UUID` | `string` | UUID of queue to be voided | -| `purge` | `boolean` | The queue record will be voided unless `purge=true` | +| Parameter | Type | Description | +|:----------|:----------|:----------------------------------------------------| +| `UUID` | `string` | UUID of queue to be voided | +| `purge` | `boolean` | The queue record will be voided unless `purge=true` | ### Queue Entry Resource @@ -166,9 +134,9 @@ not authenticated, 401 Unauthorized status is returned. GET /ws/rest/v1/queue//entry/ ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | -| `QueueUUID` | `string` | UUID of the associated queue | +| Parameter | Type | Description | +|:-----------------|:---------|:------------------------------------| +| `QueueUUID` | `string` | UUID of the associated queue | | `QueueEntryUUID` | `string` | UUID of queue entry to be retrieved | #### Find queue entries by status @@ -178,10 +146,12 @@ Finds queue entries by status. Return empty results if no queue entry with the s ```http request GET /ws/rest/v1/queue//entry?status=Waiting For Service ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | + +| Parameter | Type | Description | +|:------------|:---------|:-----------------------------| | `QueueUUID` | `string` | UUID of the associated queue | -| `status` | `string` | queue entry status | +| `status` | `string` | queue entry status | + #### Create queue entry Creates queue entry record. If not authenticated, 401 Unauthorized status is returned. @@ -218,9 +188,9 @@ to be updated) doesn't exist. If not authenticated, 401 Unauthorized status is r POST /ws/rest/v1/queue//entry/ ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | -| `QueueUUID` | `string` | UUID of the associated queue | +| Parameter | Type | Description | +|:-----------------|:---------|:----------------------------------| +| `QueueUUID` | `string` | UUID of the associated queue | | `QueueEntryUUID` | `string` | UUID of queue entry to be updated | Body @@ -241,29 +211,35 @@ not authenticated, 401 Unauthorized status is returned. DELETE /ws/rest/v1/queue//entry/?purge=false ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | -| `QueueUUID` | `string` | UUID of queue associated | -| `QueueEntryUUID` | `string` | UUID of queue entry record to be voided | -| `purge` | `boolean` | The queue entry record will be voided unless `purge=true` then deleted | +| Parameter | Type | Description | +|:-----------------|:----------|:-----------------------------------------------------------------------| +| `QueueUUID` | `string` | UUID of queue associated | +| `QueueEntryUUID` | `string` | UUID of queue entry record to be voided | +| `purge` | `boolean` | The queue entry record will be voided unless `purge=true` then deleted | ### Queue Entry Count -#### Get queue entries count + +#### Get queue entries count + Gets the count of all active queue entries in a given queue. ```http request GET /ws/rest/v1/queue//count ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | + +| Parameter | Type | Description | +|:------------|:---------|:-----------------------------| | `QueueUUID` | `string` | UUID of the associated queue | #### Get queue entries count by status + Gets the count of queue entries record by status + ```http request GET /ws/rest/v1/queue//count?status=Waiting for Service ``` -| Parameter | Type | Description | -| :--- | :--- | :--- | + +| Parameter | Type | Description | +|:------------|:---------|:-----------------------------| | `QueueUUID` | `string` | UUID of the associated queue | -| `status` | `string` | the status of queue entry | +| `status` | `string` | the status of queue entry | diff --git a/docker-compose.yml b/docker-compose.yml index 87c9c528..776904fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,15 +18,14 @@ services: MYSQL_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} MYSQL_ROOT_PASSWORD: ${OPENMRS_DB_ROOT_PASSWORD:-openmrs} deploy: - replicas: '${OPENMRS_DB_REPLICAS}' - #replicas: 0 + replicas: '${OPENMRS_DB_REPLICAS:-1}' restart_policy: max_attempts: 3 volumes: - db-data:/var/lib/mysql openmrs-core: - image: openmrs/openmrs-core:${OPENMRS_CORE_VERSION:-dev} + image: openmrs-core:dev ports: - "8080:8080" - "8000:8000" @@ -35,16 +34,16 @@ services: OMRS_CONFIG_MODULE_WEB_ADMIN: "true" OMRS_CONFIG_AUTO_UPDATE_DATABASE: "true" OMRS_CONFIG_CREATE_TABLES: "true" - OMRS_CONFIG_CONNECTION_SERVER: ${OPENMRS_DB:-openmrs} + OMRS_CONFIG_CONNECTION_SERVER: ${OPENMRS_DB_SERVER:-db} OMRS_CONFIG_CONNECTION_DATABASE: ${OPENMRS_DB_NAME:-openmrs} OMRS_CONFIG_CONNECTION_USERNAME: ${OPENMRS_DB_USER:-openmrs} OMRS_CONFIG_CONNECTION_PASSWORD: ${OPENMRS_DB_PASSWORD:-openmrs} + OMRS_REFRESH_MODULES: ${OMRS_REFRESH_MODULES:-false} healthcheck: test: [ "CMD", "curl", "-f", "http://localhost:8080/openmrs" ] timeout: 5s volumes: - - ${PWD}/omod/target/${OMOD_TARGET}:/root/.OpenMRS/modules/${OMOD_TARGET} - - ${PWD}/required_modules:/root/.OpenMRS/modules - + - ${PWD}:/openmrs/module/source + # - ~/.m2:/root/.m2 volumes: db-data: diff --git a/prepare-docker-env.sh b/prepare-docker-env.sh deleted file mode 100644 index 3533044c..00000000 --- a/prepare-docker-env.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -set -e - -# This Source Code Form is subject to the terms of the Mozilla Public License, -# v. 2.0. If a copy of the MPL was not distributed with this file, You can -# obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under -# the terms of the Healthcare Disclaimer located at http://openmrs.org/license. -# -# Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS -# graphic logo is a trademark of OpenMRS Inc. - -# This script is used to setup the development environment for this module. -# It should be run once when the project is first clone/created. -# Downloads the required openmrs modules and installs them. - -OPENMRS_SDK_PLUGIN="org.openmrs.maven.plugins:openmrs-sdk-maven-plugin" -MODULES_DIR="required_modules" - -# Extract project artifactId & version -OMOD_NAME=$(mvn help:evaluate -Dexpression=project.artifactId | grep -e '^[^\[]') -OMOD_VERSION=$(mvn help:evaluate -Dexpression=project.version | grep -e '^[^\[]') -echo "Current version: $OMOD_NAME-$OMOD_VERSION" - -create_environment_variables_file() { - cat <.env -# OpenMRS core platform version. -OPENMRS_CORE_VERSION=dev - -# To use an existing database, set the following variables. -OPENMRS_DB=localhost -OPENMRS_DB_NAME=openmrs -OPENMRS_DB_USER=openmrs -OPENMRS_DB_PASSWORD=openmrs - -# To use an existing database, set this variable to 0 -# To create a new database, set this variable to 1 -OPENMRS_DB_REPLICAS=1 - -# OMOD file name -OMOD_TARGET="$OMOD_NAME-$OMOD_VERSION.omod" -EOF -} - -prepare_modules_directory() { - # prepare modules directory - if [ -d "${MODULES_DIR}" ]; then - echo "${MODULES_DIR} dir is already exists." - # remove contents - rm -rf "${MODULES_DIR:?}/"* - else - echo "Creating ${MODULES_DIR} directory..." - mkdir -p "${MODULES_DIR}" - fi -} - -download_artifacts() { - mkdir -p artifacts - # download modules - docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B - # copy downloaded modules to ${MODULES_DIR} directory - cp -r artifacts/web/modules/* "${MODULES_DIR}" - # clean up artifacts - rm -rf artifacts -} - -if [ -x "$(command -v docker)" ]; then - installed_docker_version=$(docker --version) - echo "Installed ${installed_docker_version}" - - prepare_modules_directory - download_artifacts - create_environment_variables_file -else - printf "Please install Docker and re-run prepare script.\n" -fi