Multi-tenancy for Bahmni Lite (and OpenMRS)

Back references about multitenancy - Bahmni as Multi-Tenant SAAS solution,
Multi-practice support in OpenMRS etc.

Multitenancy Goal - Database per tenant - Tenant identification at the application level identifies the tenant-specific database connection with minimal changes to BahmniCore + OpenMRS.

Has OpenMRS team explored Hibernate 5 interfaces - MultiTenantConnectionProvider and CurrentTenantIdentifierResolver?

Is there any other way to achieve multitenancy with minimal changes to BahmniCore and OpenMRS?

@raff @ibacher @dkayiwa @angshuonline @binduak

I’m not aware of any real efforts to implement multitenancy in OpenMRS. However, you can always define arbitrary Hibernate properties via the runtime properties using the same syntax, so if you had, e.g.,

hibernate.multi_tenant_connection_provider=# your provider class

And you caused your class to be available on the classpath (e.g., by packaging it in a JAR in the /WEB-INF/lib directory of the OpenMRS WAR), you could leverage the setup. However, you’d have to add some code that would correctly apply the Liquibase changes to each tenant connection. There are potentially some other places where we assume that there’s at least one main connection, but Liquibase is generally the big one since that can run before we’ve configured Hibernate.

1 Like

This is the closest attempt, that i have seen, in that direction:

2 Likes

Few thoughts

  1. Would a single app-server (Tomcat running OMRS) be good enough? maybe - however OMRS server does take fair amount of resources. So can’t imagine on say 2 GB memory pod!
  2. Creating the database (through liquibase) is possible - just spin up another instance that will create a database and subsequently die.
  3. The single app server will need some dynamic lookup of different data sources/connections. This may require some code changes?
  4. Lucene indexes - prefer different indexes for different instances (different volumes mounted). Otherwise every patient must be associated with a clinic/hospital in the index and search modified to include that filter - should be easy. But not really absolute segregation of data.
  5. Documents that are uploaded, also need to be segregated - but that should be easy enough. e.g. different S3 bucket
1 Like