[GSoC-2017] : Built-In Reports for Reference Application

gsoc2017
Tags: #<Tag:0x00007f88ce1230f0>

(Jude Niroshan) #21

I tried but I couldn’t make any reports with cohort definitions. I was not able to complete the Patient Visit Report. Rafal told that it was okay, and let’s keep it to the end. Today we had the weekly meeting for GSoC project.

This week task is to implement those reports through java code. inside the referenceApplication module.


(Jude Niroshan) #22

Hi @raff & @ssmusoke,

Here is my current status in brief.:slight_smile:

Things completed:

  1. I have created the reports through the reporting module user interfaces using the SQL data definitions.
  2. I have implemented those reports inside referenceApplication module still using the SQL data definitions. (github fork repo: modifications)

Things not completed:

  1. Implement reports using cohort definitions.
  2. Implement the Patient Visit Report (last report in the planned report-list)
  3. Couldn’t resolve the test failure.

Best Regards, Jude Niroshan


(Jude Niroshan) #23

Hi @raff, @ssmusoke,

Thanks for coming for the weekly meeting yesterday.:grinning: I was able to solve the above mentioned test failure. Now the module builds without no exceptions. Here is the Pull Request I made for my last week work:

This week task: Implement the selected reports using cohorts. Try to write test overages for already implemented reports

Best Regards, Jude Niroshan


(Jude Niroshan) #24

Hi @raff, @ssmusoke,

This is my current state of almost the end of 2nd week. :neutral_face:

We were discussed in our last meeting to create the New Patient Registrations reports using cohorts. I spent many days trying to create this report through the reporting module UI. It seems that date_created of a patient is not possible to retrieve through the existing data definitions.

When I look at the rest of the reports, they are moreover to metadata than patient specific data. For all those reports, the default cohort which is All Patients is good enough.

Last week objective:

For the moment, I have these reports which were implemented through SQL definitions inside the referenceApplication module. Here is the Pull Request I made with the suggested modifications.

I will be so happy to see, if there is another possible way to get date_created attribute in the patient table as a data definition.

Regards, Jude Niroshan


(Jude Niroshan) #25

Hi @raff, @ssmusoke,

Last Tuesday (13th-June-2017) we had the weekly meeting. We were discussed on the the work which I was doing in the 2nd week. Rafal had a look on the half-baked report which I created. He tried to help me to setup the demoreporting module in my local machine, but we couldn’t set it up as the provided metadata SQL file wasn’t compatible with the code.

Week 3 tasks:

  • Finish the New Patient Registrations report.
  • Write Unit Test coverage for that report. (I have already created that report through reporting module, currently I’m implementing it in java code)

Regards, Jude Niroshan


(Jude Niroshan) #26

Hi @raff, @ssmusoke,

I have implemented the New Patient Registrations report using cohorts inside the referenceApplication module. I have also written the test coverage for that report. I made slight changes for package structure (may be new way would bring more clarity) . Appreciate your feedback. :grinning:

Here is the Pull Request -> https://github.com/openmrs/openmrs-module-referenceapplication/pull/43

Now I’m working on 'Number of visits’ report to implement it through cohorts (encounter) and write unit test coverage.

Regards, Jude Niroshan


(Jude Niroshan) #27

Hi Everyone!

It’s almost end of 3rd week of GSoC 2017 coding phase timeline (9 weeks left :grimacing: ). I have been working on this project since the day it was announced. @raff and @ssmusoke gave me immense support in many ways. Up to now, I have implemented the following reports (or rather components as @mseaton called it :wink:)

  • Number or Visits
  • Number of Patient Registrations
  • Number of Admissions/Transfers/Discharges per service area
  • Number of Visit Notes
  • List of Diagnosis’s made and quantity
  • List of Providers (grouped by active/retired)
  • List of Users (grouped by active/retired)
  • List of new Patient Registrations
  • Patient Visit Report (This has not done)

All these reports have implemented inside the referenceApplication module. All cohorts definitions, libraries and everything resides inside this module at the moment. We had a discussion over this few weeks back whether we need to move some potion of this to referencemetadata module or not. If we are going to move to referencemetadata module what sort of things needs to be take in there?

@mseaton @darius Appreciate any of your valuable inputs. :slight_smile:

Kind Regards, Jude Niroshan


(Rafal Korytkowski) #28

@judeniroshan, moving all your changes so far to referencemetadata will be all what is needed. It should be quick.

I’m sorry for misguiding you about putting the code in the referenceapplication module, whereas it should go to the referencemetadata module as it was discussed in this thread above.


(Jude Niroshan) #29

Hi @raff,

I made the PR to openmrs-module-referencemetadata. I have a minor change to be done for 3 or 4 test cases. Apart from that the reports which we were discussed have completed. I think it’s now time start working on exposing these reports to outside. Can you please point me where to start off with that? :slight_smile:

Kind Regards, Jude Niroshan


(Rafal Korytkowski) #30

@judeniroshan, as discussed let’s try to expose a simple metric with one number e.g. NumberOfAdmissions by writing a react component communicating with reporting REST. Since there’s no OWA generator for React yet, please create a regular React project by following https://facebook.github.io/react/docs/installation.html Next add manifest.webapp e.g. https://github.com/openmrs/openmrs-module-metadatamapping/blob/master/owa/app/manifest.webapp to make it an OWA, which you can upload as a zip to be served by OpenMRS via the advanced administration page as explained here https://wiki.openmrs.org/display/docs/Open+Web+Apps+Module.

Do not worry about styling yet. The goal is to run the report and fetch the result via REST.


(Jude Niroshan) #31

Thank you @raff for your support.:blush: I have made another PR for reference metadata module. That includes the remained test coverage.

I have created a new OWA in my github account. I am currently working on fetching a report through Reporting REST.

Regards, Jude Niroshan


(Jude Niroshan) #32

Hi @raff, @ssmusoke,

It’s been a while since I could update this thread, as I was bit busy with my college work. However it’s all done now and I’m much more focused over here. I have created a simple react component for List of Users report. I have not much concerned about the styling yet.

Here is what I have done so far.

I appreciate your feedback, specially on the component structure. Now I’m working on rest of the reports. :slight_smile:

Regards, Jude Niroshan


(Jude Niroshan) #33

Hi @raff, @ssmusoke,

I have created the components for rest of the reports as well. Here is the commit I have made for it.

I’m still a newbie to ReactJS. I couldn’t find the way to display the report components when an item has been clicked from the navigation bar. I think, it shouldn’t redirect to a new page, instead it should it done as in a SAP (Single Page Application). Any advice on it? :grimacing:


I have written the component in more generic way. That’s why the date is being showing as an integer.

Thanks & Regards, Jude Niroshan


(Jude Niroshan) #34

Hi @raff, @ssmusoke,

Here is my current status after end of 7th week:

Things completed so far:

  • Implemented the basic reports inside ReferenceMetaData module (Already merged to master branch)
  • Created a new OWA in ReactJS and fetch report data through Reporting REST API
  • Created basic React components for each of those reports

Things not done:

  • Refine the ReactJS components
  • Implement a proper navigation structure within the OWA
  • Embed Charts into ReactJS components (Charts in OpenMRS)
  • Extract out the common UI styling and make a separate npm module (for others to use in future)

Is there anything that is missing in this targeted task list?


@raff, I was trying to implement a simple navigation using react-router-dom v4.0.0. I have noticed that in the OWA which I generated through OpenMRS OWA generator has included react-router v.3 by default. It is said that react-router is deprecated and to use react-router-dom. So, I added that dependency to my module and tried to implement the navigation functionality. But I’m stuck on it.

If anyone knows a way to get around with this, please feel free to answer to my question in StackOverflow.

Thanks & Regards, Jude Niroshan


(Jude Niroshan) #35

Hi @raff, @ssmusoke,

Last Tuesday I had the weekly meeting with my mentor Rafal. There we planned the following work for this week:

  1. Generalized table component for all the reports (Done)
  2. Complete the navigation panel (Done)
  3. Adjust the styling (Done)
  4. Integrate Chart.js

I have created a component for reports to show in tabular format. There is a problem which I’m currently trying to solve that I couldn’t run a report through reporting REST. Reports which accepts a location as a parameter, I couldn’t run them through API.

I have also reported a issue as the API does not return a properly formatted datetime object to http response.

Until I get sorted out these, I thought to move with Chart.js implementations and try to add a very simple graph.

Thanks & Regards, Jude Niroshan


(Rafal Korytkowski) #36

@judeniroshan, please work on REPORT-817 first since it is essential for displaying valid report results.


(Jude Niroshan) #37

@raff sure, I’ll work on it :slight_smile:


(Jude Niroshan) #38

Hi @raff, @ssmusoke,

I have integrated the Jest and SinonJS (mock HTTP calls) for the new OWA UI testing. I have committed what I have done so far.

I have an issue to mock the HTTP call which I make inside the component. This call is actually generated inside the componentDidMount() life cycle method. When I compare it with the cohort builder OWA, they have made this API endpoint as a prop. In this case, they were able to inject a mock at runtime of testing.

Should I follow the same approach of taking out the API endpoint? Then again the users of this component has to provide the API endpoint everytime they are using this react component.

Any advice is appreciated :thumbsup:

Regards, Jude Niroshan


(Jude Niroshan) #39

Hi @raff,

I have implemented the Date picker and used it to take the user inputs. But this particular report is keep redirecting and doesn’t render anything. I couldn’t find out why it is happening like that. Could you please point out what I’m doing wrong here?

@dkayiwa

Regards, Jude Niroshan


(Jude Niroshan) #40

Hi @raff,

I was able to fix that issue. It was because when I simply set the state, I only set the updated the element. Because of that the rest of the elements are getting cleared off from the state. I used the previous state values and set it.

In fact the redirect is happening because the parameters for the reporting rest API call doesn’t made properly.

Here is the fix:

Regards, Jude Niroshan