GSoC Week 7: Flags

Rishav Rakshit
3 min readJul 18, 2019

--

In this week of GSoC we take a look at building the Flags component and what it took to get there (Hint: it’s Redux)

We need Redux — But why?

Unlike other components like Tags or Priorities, Flag is a bit of tricky one. Flag loads both Tag and Priority data and asks the user which Tags or Priority he or she wants to be associated with a particular Flag.

Legacy UI for Patient Flags

This reuse of data poses some design & optimization challenges —

  • I want to reduce the number of API Calls as far as possible.
  • Every time I reload a tab, I don’t want there to be an API per reload.
  • If I’ve already opened the Tag or Priority tabs once, it has already made API calls to fetch the Tag or Priority data. I don’t want to make another 2 API calls to display available Tags or Priorities when adding a new Flag.
  • I want to create a common store so that I can reuse Tag and Priority data effectively in Flags component, which is far apart from Tag and Priority nodes in the app tree.

All these requires necessitated the use of Redux in our application.

Let’s have a look at our project structure after introducing actions, reducers, and putting it altogether via combineReducers in our main reducers.js file, created automatically when using the Yeoman generator to create our OpenMRS React OWA project.

Current Project Structure

We use a dataLoaded flag in our ‘Actions’ to check whether a ‘GET’ API call to fetch list of Tags or Priorities has previous occurred or not.

Flags Component

Once we have redux implemented successfully and this structure in place, we could go ahead and code the Flags Component.

Legacy UI for Patient Flags
Legacy UI for Edit Flags
React OWA for Patient Flags
React OWA for Edit Flags — Editing existing Flag
React OWA for Edit Flags — Creating a new Flag

SPRINT #4 Action Plan

Sprint 4 begins today!

Sprint Duration: 1 Week

TODOs:

  1. Refactoring for code optimizations
  2. UI Enchancements — Integrating openmrs-react-components, openmrs Styleguide and Bootstrap

LINKS

[Latest Pull Request]

--

--

Rishav Rakshit

GSoC 2019 @ OpenMRS | I’m a software developer with ❤ for NLP and UIs. You can see my ML & NLP blog here — https://rishavr.github.io/