# Merge Patient data from Multiple Installations Project

**URL:** <https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024>\
**Category:** GSoC\
**Tags:** gsoc2018\
**Created:** [May 13, 2018, 2:31pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024 "2018-05-13T14:31:17Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [May 17, 2018, 1:13pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/21 "2018-05-17T13:13:14Z")

</div>

@samuel34 What stops you from dumping the sync data into a file and uploading it into another server?

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 17, 2018, 1:25pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/22 "2018-05-17T13:25:16Z")

</div>

Obviously nothing stops me 😄 but I was confused on why we should depend on sync ☹

---

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [May 17, 2018, 1:26pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/23 "2018-05-17T13:26:19Z")

</div>

@samuel34 What options did you envisage other than sync?

---

<div class="post-metadata">

**Author:** ![tmueller](https://talk.openmrs.org/user_avatar/talk.openmrs.org/tmueller/32/827_2.png) [@tmueller](https://talk.openmrs.org/u/tmueller)\
**Post date:** [May 17, 2018, 1:29pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/24 "2018-05-17T13:29:20Z")

</div>

Hi, @samuel34

I can see nothing wrong in your config, but I suspect that your local instance may not be accessible from outside and that’s why sync4 can’t access it as well.

Regards, Tomasz

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 17, 2018, 1:32pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/25 "2018-05-17T13:32:28Z")

</div>

I think I was getting it wrongly.   
Since its in the same circles, I think its sync.

---

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [May 17, 2018, 1:37pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/26 "2018-05-17T13:37:20Z")

</div>

@dkayiwa @samuel34 Just to confirm that we are on the same page… Below is my understanding.

1. The purpose of this project is to be able to merge patient data from multiple installations

2. The default way is to extract the patient information from each of the different tables and package it in a way that can be imported into another instance

3. However with sync2 in progress, there is a possibility to leverage this. How:

- Sync currently exposes patients, observations etc into a FHIR/REST interface, but underneath all that the data is stored in tables (in case of no connection)
- The idea in this case is to export the data from the sync tables and import it into another instance…
- That way the project is dependent on the sync structure, but extends it in a way that was not planned earlier

@tmueller Please do add your thoughts too - I may be totally off track here

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 17, 2018, 1:49pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/27 "2018-05-17T13:49:28Z")

</div>

> [@ssmusoke](#):
>
> The idea in this case is to export the data from the sync tables and import it into another instance…

I think I now understand and agree with that design.

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [May 17, 2018, 2:07pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/28 "2018-05-17T14:07:45Z")

</div>

Sorry, just jumped in here with very little context, but it does sound like if this project could leverage sync like @ssmusoke suggests, that would be great… I would definitely get the thoughts of the team working on Sync about this use case.

Take care, Mark

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [May 17, 2018, 2:40pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/29 "2018-05-17T14:40:00Z")

</div>

@samuel34 @ssmusoke is your primary mentor and hence has the final say in regards to the direction of this project. 😄

---

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [May 17, 2018, 2:54pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/30 "2018-05-17T14:54:59Z")

</div>

@dkayiwa I am happy to be swayed … in a direction that is best for OpenMRS and the overall implementation community a sanity check for my tunnel vision…

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 18, 2018, 11:47am UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/31 "2018-05-18T11:47:09Z")

</div>

Hi all!   
I’m still getting myself familiar of how sync2 works by looking directly at the code base.  
 I’m atleast aware that sync uses the atomfeed module for getting aware of events in the entire platform ie. New Patient update. But I was curious of how it happens(is it through some AOP logic!). Looking at the codebase, I hit upon this [AtomFeedClient#process()](https://github.com/openmrs/openmrs-module-atomfeed/blob/master/api/src/main/java/org/openmrs/module/atomfeed/client/AtomFeedClient.java#L7) method delegated [here](https://github.com/openmrs/openmrs-module-sync2/blob/master/api/src/main/java/org/openmrs/module/sync2/client/reader/impl/LocalFeedReaderImpl.java#L51). Is that the method that checks the entire OpenMRS context for new events(Atom feeds) ? If not, could you try explain this for me or point me to related resources!  
cc: @tmueller , @ssmusoke , @mogoodrich and Others.

---

<div class="post-metadata">

**Author:** ![tmueller](https://talk.openmrs.org/user_avatar/talk.openmrs.org/tmueller/32/827_2.png) [@tmueller](https://talk.openmrs.org/u/tmueller)\
**Post date:** [May 18, 2018, 9:16pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/32 "2018-05-18T21:16:09Z")

</div>

Yes,

but the methods that trigger the whole synchronization process are:

[LocalFeedWorker#process](https://github.com/openmrs/openmrs-module-sync2/blob/master/api/src/main/java/org/openmrs/module/sync2/client/reader/LocalFeedWorker.java#process()) and [ParentFeedWorker#process](https://github.com/openmrs/openmrs-module-sync2/blob/master/api/src/main/java/org/openmrs/module/sync2/client/reader/ParentFeedWorker.java#process())

Regards, Tomasz

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 22, 2018, 12:26pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/33 "2018-05-22T12:26:17Z")

</div>

Hi @ssmusoke!  
 I think I should get started with “real” work on this today.

#### How to get started
I thought of starting with implementing service layers that retrieve the sync-able data from the entire OpenMRS context first. Could you come in here now, help me get moving by giving me directives in form of TODOs? I feel its the best way we can get moving 🙂

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 25, 2018, 12:24pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/34 "2018-05-25T12:24:22Z")

</div>

Hi !  
 As a starting point, I have so far focused on a Patient as a Resource. I made a [PatientResourceService](https://github.com/samuelmale/openmrs-module-mergepatientdata/blob/master/api/src/main/java/org/openmrs/module/mergepatientdata/api/PatientResourceService.java), however, this doesn’t have a DAO. I’m thinking of just it just delegating the core PatientService [here](https://github.com/samuelmale/openmrs-module-mergepatientdata/blob/master/api/src/main/java/org/openmrs/module/mergepatientdata/api/impl/PatientResourceServiceImpl.java#L16). However, running this [test case](https://github.com/samuelmale/openmrs-module-mergepatientdata/blob/master/api/src/test/java/org/openmrs/module/mergepatientdata/api/PatientResourceServiceTest.java#L21) fails with the error below.

> ERROR - Context.getServiceContext(258) |2018-05-25 04:07:20,859| serviceContext is null. Creating new ServiceContext()

Could I be missing something?  
cc: @ssmusoke , @dkayiwa

---

<div class="post-metadata">

**Author:** ![ssmusoke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ssmusoke/32/8020_2.png) [@ssmusoke](https://talk.openmrs.org/u/ssmusoke)\
**Post date:** [May 25, 2018, 12:26pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/35 "2018-05-25T12:26:16Z")

</div>

@samuel34 What task are you working on? What are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 25, 2018, 12:28pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/36 "2018-05-25T12:28:51Z")

</div>

Looking at a Patient as a Resource, I’m trying to implement some service that will have to persist the ‘merged/uploaded’ Patient into the DB.

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 25, 2018, 12:29pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/37 "2018-05-25T12:29:54Z")

</div>

At the same time retrieve a batch of data from the DM for exportation

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 25, 2018, 12:46pm UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/38 "2018-05-25T12:46:48Z")

</div>

> [@samuel34](#):
>
> Looking at a Patient as a Resource, I’m trying to implement some service that will have to persist the ‘merged/uploaded’ Patient into the DB.

BTW @ssmusoke , does this use case make any sense? If so, could the problem be with my [moduleApplicationContext.xml](https://github.com/samuelmale/openmrs-module-mergepatientdata/blob/master/api/src/main/resources/moduleApplicationContext.xml)?

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 28, 2018, 8:25am UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/39 "2018-05-28T08:25:52Z")

</div>

The problem was solved 😉

But just to ask a little about openmrs-platform .  
Should snapshot 1.0.0 depend on platform [1.11.6](https://github.com/samuelmale/openmrs-module-mergepatientdata/blob/master/pom.xml#L70) as it is by default? Or!   
How do we basically handle platform compatibility?  
cc: @ssmusoke, @dkayiwa

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [May 28, 2018, 8:50am UTC](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024/40 "2018-05-28T08:50:48Z")

</div>

I’m gonna depend on platform 2.0.5

[Previous page](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024.md?page=1)

[Next page](https://talk.openmrs.org/t/merge-patient-data-from-multiple-installations-project/18024.md?page=3)
