# Project: Implement Spring Data to LibreHealth Toolkit

**URL:** <https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341>\
**Category:** Toolkit\
**Tags:** gsoc2018, toolkit, gsoc2018-project\
**Created:** [April 24, 2018, 2:33pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341 "2018-04-24T14:33:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [April 24, 2018, 2:33pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/1 "2018-04-24T14:33:33Z")

</div>

This thread is for discussions regarding GSoC project: [Project: Implement spring data to the LibreHealth toolkit](https://forums.librehealth.io/t/project-implement-spring-data-to-the-librehealth-toolkit/583) For the proposal see: [https://goo.gl/96nfEu](https://goo.gl/96nfEu)

This project’s purpose is to replace or rather migrate the existing persistence schema of LibreHealth toolkit which uses hibernate mappings to a more modular spring data persistence mechanism.

---

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [April 24, 2018, 5:37pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/2 "2018-04-24T17:37:12Z")

</div>

@sunbiz @namratanehete@prashadi I’m creating a spring boot app with [spring starter](https://start.spring.io/), I’ve added  
`devtools, reactive web and lombok`.  
For reactive NoSQL databases, spring starter offers Redis, MongoDB, Cassandra and Couchbase. Which one should I go with?

---

<div class="post-metadata">

**Author:** ![namratanehete](https://forums.librehealth.io/user_avatar/forums.librehealth.io/namratanehete/32/708_2.png) [@namratanehete](https://forums.librehealth.io/u/namratanehete)\
**Post date:** [April 25, 2018, 2:34pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/3 "2018-04-25T14:34:35Z")

</div>

I think Cassandra and Couchbase is good option. But I would like you to do comparison of both databases and how does they work with Spark?

@sunbiz do you have any suggestions?

---

<div class="post-metadata">

**Author:** ![prashadi](https://forums.librehealth.io/user_avatar/forums.librehealth.io/prashadi/32/460_2.png) [@prashadi](https://forums.librehealth.io/u/prashadi)\
**Post date:** [April 25, 2018, 6:25pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/4 "2018-04-25T18:25:21Z")

</div>

I’ll too check on the behavior of spark with these databases.

---

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [April 26, 2018, 3:38am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/5 "2018-04-26T03:38:48Z")

</div>

From reading up on both the dbs I’ve gathered this,

1. Both Cassandra and Couchbase are schema free,
2. Cassandra uses a **Wide column store** where data is stored in rows in sort of a key-value format with columns grouped into a column family, whereas Couchbase uses a **Document store** where JSON objects are stored and views are defined over those objects.
3. Cassandra is entirely free whereas Couchbase has an Enterprise edition which is paid.
4. Cassandra is highly scalable but Coucbase makes up for it in better read/write latencies.

However, I would like to build a sample app using each of them with spark to come to a conclusion.

---

<div class="post-metadata">

**Author:** ![sunbiz](https://forums.librehealth.io/user_avatar/forums.librehealth.io/sunbiz/32/395_2.png) [@sunbiz](https://forums.librehealth.io/u/sunbiz)\
**Post date:** [April 26, 2018, 3:59am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/6 "2018-04-26T03:59:14Z")

</div>

I recommend Cassandra. Implementing the app on Cassandra or CouchDB might be worth a try, but there are enough benchmarks out there that show Cassandra’s improved scalability for concurrent transactions, scalability across multiple nodes etc. And not to mention Spark deployments over Cassandra are very popular.

Though what really convinces me: Cassandra is on Java. If we are a Java platform, I don’t think we should add an Erlang dependency (Couchbase) unless it’s critically important. That’s my two cents!

---

<div class="post-metadata">

**Author:** ![prashadi](https://forums.librehealth.io/user_avatar/forums.librehealth.io/prashadi/32/460_2.png) [@prashadi](https://forums.librehealth.io/u/prashadi)\
**Post date:** [April 26, 2018, 3:22pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/7 "2018-04-26T15:22:24Z")

</div>

Cassandra would be a good solution. Cassandra scalability is very high. There are several connectors which we can use to plug cassandara and spark. Datastax cassandra connector seems very popular [https://github.com/datastax/spark-cassandra-connector](https://github.com/datastax/spark-cassandra-connector)

---

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [April 27, 2018, 2:58pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/8 "2018-04-27T14:58:06Z")

</div>

I guess we have enough reasons to use Cassandra over Couchbase. I’ll setup a spring reactive project using Cassandra in a gitlab repository.

**Update:** I’d also like to point out that Spring Data Rest does _not_ work with Spring Reactive Web (webflux). [https://jira.spring.io/browse/DATAREST-933](https://jira.spring.io/browse/DATAREST-933)  
This is not a big issue since the [new functional framework](https://spring.io/blog/2016/09/22/new-in-spring-5-functional-web-framework) kind of reduces the load of rewriting similar controller functions.

---

<div class="post-metadata">

**Author:** ![sunbiz](https://forums.librehealth.io/user_avatar/forums.librehealth.io/sunbiz/32/395_2.png) [@sunbiz](https://forums.librehealth.io/u/sunbiz)\
**Post date:** [April 27, 2018, 8:33pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/9 "2018-04-27T20:33:33Z")

</div>

Yes, we will have very little to do with requiring Spring data REST, mainly because at the moment the Jackson bindings are synchronous or blocking IO.

Getting a quick-win with the [HAPI-JPA style app](https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jpaserver-example), that uses their existing libraries, with Spring data JPA should be our first pass with Cassandra as the database. This could possibly be done even before we begin the coding phase. Then we can try to make it reactive. @yashdsaraf , does that sound like a good plan to you for your GSoC project?

---

<div class="post-metadata">

**Author:** ![prashadi](https://forums.librehealth.io/user_avatar/forums.librehealth.io/prashadi/32/460_2.png) [@prashadi](https://forums.librehealth.io/u/prashadi)\
**Post date:** [April 28, 2018, 4:13am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/10 "2018-04-28T04:13:41Z")

</div>

@sunbiz @namratanehete

For my project, I will follow the below steps.

- After the @yashdsaraf created the project, I will work on a separate branch

- I’ll use Bunsen library from cerner to integrate with Spark ([http://engineering.cerner.com/blog/announcing-bunsen-fhir-data-with-apache-spark/](http://engineering.cerner.com/blog/announcing-bunsen-fhir-data-with-apache-spark/))

- Writing the backend service layer

- Then I’ll write query builder UI to get data from service layer

Hope my approach is correct.

---

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [April 29, 2018, 8:31pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/11 "2018-04-29T20:31:13Z")

</div>

@sunbiz From what I understand, I should clone [HAPI JPA example](https://github.com/yashdsaraf/hapi-fhir/tree/master/hapi-fhir-jpaserver-example) and migrate it to Spring Data JPA with Cassandra, is this right?

---

<div class="post-metadata">

**Author:** ![sunbiz](https://forums.librehealth.io/user_avatar/forums.librehealth.io/sunbiz/32/395_2.png) [@sunbiz](https://forums.librehealth.io/u/sunbiz)\
**Post date:** [April 29, 2018, 10:38pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/12 "2018-04-29T22:38:03Z")

</div>

Yes, only as an sample app. So that we can do the same thing in our spring boot app.

---

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [April 29, 2018, 10:49pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/13 "2018-04-29T22:49:40Z")

</div>

Okay, I’m on it. 🙂

---

<div class="post-metadata">

**Author:** ![prashadi](https://forums.librehealth.io/user_avatar/forums.librehealth.io/prashadi/32/460_2.png) [@prashadi](https://forums.librehealth.io/u/prashadi)\
**Post date:** [April 30, 2018, 7:58am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/14 "2018-04-30T07:58:19Z")

</div>

@yashdsaraf please share the link of the gitlab project that you work on. So I can clone and start work. 🙂

---

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [April 30, 2018, 11:57am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/15 "2018-04-30T11:57:41Z")

</div>

@prashadi Here’s the repo url [https://gitlab.com/yashdsaraf/hapi-spring-jpa-fhir.git](https://gitlab.com/yashdsaraf/hapi-spring-jpa-fhir.git) It’s just the [https://github.com/yashdsaraf/hapi-fhir/tree/master/hapi-fhir-jpaserver-example](https://github.com/yashdsaraf/hapi-fhir/tree/master/hapi-fhir-jpaserver-example) as is right now, I’ll push the changes for Spring jpa later today. Also what’s your gitlab username? I’ll add you as a developer to the repo.

---

<div class="post-metadata">

**Author:** ![prashadi](https://forums.librehealth.io/user_avatar/forums.librehealth.io/prashadi/32/460_2.png) [@prashadi](https://forums.librehealth.io/u/prashadi)\
**Post date:** [April 30, 2018, 12:26pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/16 "2018-04-30T12:26:52Z")

</div>

Great @yashdsaraf. My github username is kavindya89.

---

<div class="post-metadata">

**Author:** ![yashdsaraf](https://forums.librehealth.io/user_avatar/forums.librehealth.io/yashdsaraf/32/683_2.png) [@yashdsaraf](https://forums.librehealth.io/u/yashdsaraf)\
**Post date:** [May 1, 2018, 12:05am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/17 "2018-05-01T00:05:39Z")

</div>

@sunbiz The [example app](https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jpaserver-example) uses DAOs from [HAPI JPA server](https://github.com/yashdsaraf/hapi-fhir/tree/master/hapi-fhir-jpaserver-base). Instead of using these I have to create Repository interfaces for all structures using spring data’s CRUDRepository right? Also am I supposed to migrate only the DSTU3 structures or older ones as well? Sorry for the nitty-gritty questions, I’d really like to be sure I’m headed in the right direction 😅

---

<div class="post-metadata">

**Author:** ![sunbiz](https://forums.librehealth.io/user_avatar/forums.librehealth.io/sunbiz/32/395_2.png) [@sunbiz](https://forums.librehealth.io/u/sunbiz)\
**Post date:** [May 1, 2018, 12:39am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/18 "2018-05-01T00:39:14Z")

</div>

No problem with the nitty-gritty questions. But I’d like you to express your opinion and ask us for feedback.

> [@yashdsaraf](#):
>
> am I supposed to migrate only the DSTU3 structures or older ones as well

I think only the DSTU3 structures are fine.

> [@yashdsaraf](#):
>
> I have to create Repository interfaces for all structures using spring data’s CRUDRepository right?

Yes, you create your own instead of using the dependencies that they use in the example jpa pom

---

<div class="post-metadata">

**Author:** ![prashadi](https://forums.librehealth.io/user_avatar/forums.librehealth.io/prashadi/32/460_2.png) [@prashadi](https://forums.librehealth.io/u/prashadi)\
**Post date:** [May 1, 2018, 4:13am UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/19 "2018-05-01T04:13:13Z")

</div>

According to my search, STU3 are the current mature structures and we should go with that. FHIR specification working on new R4 standard which is targeting to release fully on October.

---

<div class="post-metadata">

**Author:** ![lehone](https://forums.librehealth.io/user_avatar/forums.librehealth.io/lehone/32/352_2.png) [@lehone](https://forums.librehealth.io/u/lehone)\
**Post date:** [May 4, 2018, 1:26pm UTC](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341/20 "2018-05-04T13:26:39Z")

</div>

@yashdsaraf, @prashadi please I have some doubt which needs clarifications. Firstly, since we are migrating from openmrs.librehealth to FHIR, will the implementation of the Spring Data for Toolkit be in the current [toolkit repo](https://gitlab.com/librehealth/toolkit/lh-toolkit) or will you guys be creating a completely new app? Secondly, will your project include REST endpoints for Radiology Study, Procedure Request, Radiology Report and Report Template?

[Next page](https://forums.librehealth.io/t/project-implement-spring-data-to-librehealth-toolkit/2341.md?page=2)
