# Support ADX disaggregations with DHIS2 Reporting Module

**URL:** <https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154>\
**Category:** DHIS2 Integration\
**Tags:** module, dhis2, gsoc2020\
**Created:** [June 24, 2020, 4:16pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154 "2020-06-24T16:16:55Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [June 24, 2020, 4:16pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/1 "2020-06-24T16:16:56Z")

</div>

Hi all,

The current module doesn’t support ADX disaggregations. In order to do that we need to map DHIS2’s Categories and CategoryOptions within the module. The next thing is the current import format is not compatible with the exported metadata information of DHIS2. We have to fix it at all.

This is the current DB:

 ![image](https://talk.openmrs.org/uploads/default/original/2X/7/786d112a277781be9e002eb12b594c066485096a.jpeg)

There’s an existing ticket that suggested a structure. [https://issues.openmrs.org/projects/DRM/issues/DRM-43](https://issues.openmrs.org/projects/DRM/issues/DRM-43)

But according to the [DHIS2 ADX documentation](https://docs.dhis2.org/master/en/developer/html/webapi_adx_data_format.html) we don’t need to store the `CategoryOptionCombos`. I raised a discussion on DHIS2 Community as well.

> **[Is it possible to generate a Data Value Set Template for ADX?](https://community.dhis2.org/t/is-it-possible-to-generate-a-data-value-set-template-for-adx/39632/2)**
>
> Hi @jayasanka, I’m sure @morten, our integration team lead, can help you. You can also reach the integration team at integration@dhis2.org.

This is the EER I came up by considering the above.

 ![image](https://talk.openmrs.org/uploads/default/original/2X/4/4c78b97134b49478758eaf857737e8061daca198.jpeg)

One more thing to clarify; The Reporting module supports custom queries right? If it is we no longer need to add another field to store custom queries.

cc: @akshika47 @heliostrike

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [June 25, 2020, 2:22pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/2 "2020-06-25T14:22:23Z")

</div>

@mseaton @judeniroshan @darius @ssmusoke @dkayiwa @arbaughj @maurya

Could you please help to review this EER diagram?

Also, may I know whether the reporting module supports custom queries?

---

<div class="post-metadata">

**Author:** ![akshika47](https://talk.openmrs.org/user_avatar/talk.openmrs.org/akshika47/32/11494_2.png) [@akshika47](https://talk.openmrs.org/u/akshika47)\
**Post date:** [June 25, 2020, 11:28pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/3 "2020-06-25T23:28:41Z")

</div>

This is good progress @jayasanka.

@judeniroshan could you answer the question on the reports module? I have not worked with that module before.

---

<div class="post-metadata">

**Author:** ![judeniroshan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/judeniroshan/32/4503_2.png) [@judeniroshan](https://talk.openmrs.org/u/judeniroshan)\
**Post date:** [June 26, 2020, 5:11pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/4 "2020-06-26T17:11:46Z")

</div>

I have shared the knowledge with @jayasanka on this topic 🙂

---

<div class="post-metadata">

**Author:** ![akshika47](https://talk.openmrs.org/user_avatar/talk.openmrs.org/akshika47/32/11494_2.png) [@akshika47](https://talk.openmrs.org/u/akshika47)\
**Post date:** [June 26, 2020, 7:15pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/5 "2020-06-26T19:15:37Z")

</div>

Thank you @judeniroshan 🙂

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 9, 2020, 7:21am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/6 "2020-07-09T07:21:35Z")

</div>

Hello there,

We have to remove existing implementations that aren’t compatible with the new ADX disaggregations. The current implementation is designed according to the DFX structure but later on, it has changed to ADX while keeping the same. It supports only non disaggregated data. Unfortunately, the current implementation isn’t expandable because it is incompatible with the latest DHIS2’s data structure. In order to implement it, we have to remove some previous implementations.

Also, there are some unused classes as which used on DFX and haven’t removed when upgrading. Need to remove them as well.

Issue:

> <https://issues.openmrs.org/browse/DRM-53>

@akshika47 could you please review and merge this PR?

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/72>

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 9, 2020, 8:09am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/7 "2020-07-09T08:09:47Z")

</div>

@akshika47 Please review and merge this PR as well, (after merging DRM-53)

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/73?a=b>
>
> \## The issue I worked on
> See https://issues.openmrs.org/browse/DRM-54
> 
> \## Des…cription of what I changed:
> 
> \- Implement new model classes
> \- Add SQL queries to create the DB
> \- Implement Hibernate mappings

This is the updated EER:

 ![NeededModel](https://talk.openmrs.org/uploads/default/original/2X/c/c7632ece6ae64c7949b196d11bc16776fe7545a3.jpeg)

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 13, 2020, 9:31am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/8 "2020-07-13T09:31:01Z")

</div>

@akshika47 could you please review and merge this PR?

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/74>

Ticket:

[https://issues.openmrs.org/browse/DRM-56](https://issues.openmrs.org/browse/DRM-56)

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 14, 2020, 1:14pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/9 "2020-07-14T13:14:27Z")

</div>

I’ve generated JAXB classes to fully unmarshal the import file using [XJC](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/xjc.html). XJC compiles an XML schema file into fully annotated Java classes.

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/75>

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 15, 2020, 5:41pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/10 "2020-07-15T17:41:33Z")

</div>

Hi all,

I implemented the following:

- Create methods to extract and save,
  1. Data Elements
  2. Data Set
  3. Categories
  4. Category Options
  5. Disaggregations

- Create a new DAO method to save Disaggregations
- Create a new DAO method to find a Dissagregation using a Category and a Category Option

Please Review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/76>

Ticket:

> <https://issues.openmrs.org/browse/DRM-58>

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 17, 2020, 2:19pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/11 "2020-07-17T14:19:28Z")

</div>

Hi all, I implemented the following,

- Implement a method to generate Data Value Template
- Implement a recursive method to generate Disaggregation combinations for a given Data Element
- Remove irrelevant field “name” from Data Value Template
- Fix wrong field “dataelement\_id” in Data Value Template’s mapping file
- Implement DAO methods to
  1. save a Data Value Template
  2. remove Data Value Templates of a given Dataset
  3. get Disaggregations of a given Category

With this PR the import function is being fully completed.

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/77>

Ticket:

> <https://issues.openmrs.org/browse/DRM-59>

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 21, 2020, 10:20am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/12 "2020-07-21T10:20:50Z")

</div>

Hi all,

I’ve implemented the following,

- Create a new view list imported Data Sets
- Create a new controller to handle reports
- Create a new DAO method to get all Data Sets
- Modify the local header with new links and fix broken HTML tags
- Remove irrelevant JSP pages

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/78>

Ticket: [https://issues.openmrs.org/browse/DRM-60](https://issues.openmrs.org/browse/DRM-60)

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 25, 2020, 11:11am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/13 "2020-07-25T11:11:17Z")

</div>

Hello there,

I’ve implemented the following,

- Create DAO methods
  - Find Data Value Templates by a Data Set
  - Find a dataset by UUID

- Create a new service to update the report of a Data Set
- Create a new view to map Report with a DataSet

![Kapture 2020-07-25 at 16 37 38](https://user-images.githubusercontent.com/33048395/88455712-4ae21180-ce95-11ea-9fb7-08b6ac127402.gif)

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/79>

Ticket: [https://issues.openmrs.org/browse/DRM-61](https://issues.openmrs.org/browse/DRM-61)

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [July 29, 2020, 7:26am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/14 "2020-07-29T07:26:52Z")

</div>

Hi, I’ve implemented the following,

- Create a DAO method to find a DataValueTemplate by id
- Create a service to update the Report Indicator of a DataValue Template
- Create a view to mapping DataValueTemplates with Report Indicators

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/80>

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [August 6, 2020, 1:20pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/15 "2020-08-06T13:20:41Z")

</div>

Hi all, I’ve implemented the following,

- Exclude dependencies which included `javax.xml.namespace.QName`
- Create new Controller and Service methods to
  - Execute the mapped Report Definition
  - Map Report result with Data Value Templates
  - Generate ADX output
  - Post data to connected DHIS2 instance

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/81>

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [August 7, 2020, 8:07am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/16 "2020-08-07T08:07:22Z")

</div>

Hi all, I’ve replaced Category and Category Options with Category Options Combos. With that, it will be easy to store metadata and it will reduces the complexity of the module.

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/82>

Ticket: [https://issues.openmrs.org/browse/DRM-64](https://issues.openmrs.org/browse/DRM-64)

---

<div class="post-metadata">

**Author:** ![jayasanka](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jayasanka/32/22204_2.png) [@jayasanka](https://talk.openmrs.org/u/jayasanka)\
**Post date:** [August 14, 2020, 5:12am UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/17 "2020-08-14T05:12:37Z")

</div>

Hi all, I’ve added the support for the following period Types:

- Daily
- Weekly
- WeeklyWednesday
- WeeklyThursday
- WeeklySaturday
- WeeklySunday
- Monthly
- BiMonthly
- Quarterly
- Yearly

Please review and merge:

> <https://github.com/openmrs/openmrs-module-dhisreport/pull/84>

Ticket: [https://issues.openmrs.org/browse/DRM-66](https://issues.openmrs.org/browse/DRM-66)

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [August 14, 2020, 12:36pm UTC](https://talk.openmrs.org/t/support-adx-disaggregations-with-dhis2-reporting-module/29154/18 "2020-08-14T12:36:40Z")

</div>

@jayasanka After our conversation with @jamesm , do you think there’s a way we could extend or modify the `Period` type to support the full range of ADX periods rather than just creating fixed classes for supported period lengths? E.g., as I understand things “01-02-2020/P2D” is a valid ADX period descriptor, but with the current setup, it looks like to support that we’d need to add a new “EveryOtherDay” class and supporting code. It would be nicer if the `Period` class defined something like a static function `of`:

```java
public static Period of(String periodDescriptor) {
    Period newPeriod = new Period();
    String[] parts = periodDescriptor.split("/");
    ...
}

```
