Skip to content

OHSU-OCTRI/omop-annotator

Repository files navigation

OMOP Annotator

Development Info

This is a Spring Boot project. It uses a MySQL database for storage, managed using Flyway.

Development Setup

We provide Docker Compose configuration to facilitate running the application locally. For a detailed description of how to configure the application and an alternative method of running it from the command line, see RUNNING.md.

Recommended VS Code Extensions

When you open the project for the first time with Visual Studio Code, it should offer to install recommended extensions for Java and JavaScript development. To install the extensions manually, open the command palette (CMD-Shift-P), type "recommended", and select the option for "Extensions: Show Recommended Extensions".

Configuration

Copy env.sample to .env and update as needed. At a minimum, you should update .env to set the OMOP data source connection parameters.

  • OMOP_DATASOURCE_URL
  • OMOP_DATASOURCE_USERNAME
  • OMOP_DATASOURCE_PASSWORD

You should also configure the authentication system properties as needed. See the "LDAP authentication" and "table-based authentication" sections of env.sample.

Application Startup

Running with Docker

Build the project.

mvn clean package -DskipTests

Start the containers, getting MySQL up first.

docker compose up -d mysql
docker compose up -d app

You should find the app at http://localhost:8080/omop_annotator unless you updated SERVER_SERVLET_CONTEXTPATH.

Templates

Mustache templates are stored in src/main/resources/mustache-templates which was overridden in src/main/resources/application.properties by the property spring.mustache.prefix.

By default there is a home.mustache template that uses a header layout (layout/header.mustache) and a footer layout (layout/footer.mustache).

Bootstrap 5 and jQuery 3 are both included in the templates. Additional CSS styles may be added to static/css/main.css.

Integration tests requiring a database

To bring up a testing database you may use the Docker Compose file docker-compose.test.yml:

docker-compose -f docker-compose.test.yml up -d

This brings up a second MySQL database container on port 3307. test-application.properties overrides the datasource URL.

Add the following annotations to your test class which will bring up a full application context that uses this test datasource.

@RunWith(SpringRunner.class)
@TestPropertySource(locations = { "classpath:application.properties", "classpath:test-application.properties" })
@SpringBootTest

Flyway Migrations

To create a Flyway migration, create a version directory in src/main/resources/db/migration. For example:

mkdir src/main/resources/db/migration/0.0.1

Now add your migrations in this directory. For example, V19700101000042__my_first_migration.sql which follows the format: V, followed by the year, month, day, hours, minutes, seconds (YYYYMMDDhhmmss), two underscores, a short description, and finally .sql.

Search Indexing

The Judging interface for OMOP Annotator provides judges with the ability to perform full text searches on VisitOccurrences as well as all related visit data. To do this efficiently, the application uses the Hibernate Search library, which provides a consistent API over full text search engines such as Apache Lucene and Elasticsearch. See the application.properties file to view the configuration options.

The default search engine is Lucene, which stores index data to disk. An index schema is created on application startup, but the index is not populated until the Indexer has been run. The easiest way to do this is to login as an admin and navigate to the url: /admin/search/init_index. Note that this operation will index all visit occurrences associated with a Patient record that has been assigned to a Pool. This operation can take a long time so it should be performed when the application is not in use.