Code Monkey home page Code Monkey logo

avni-webapp's Introduction

Readme

You will need yarn package mananger to be installed globally to run this project. Follow the instructions on https://yarnpkg.com/en/docs/install to install yarn if it is not already installed on your machine. Once installed you can verify it by running yarn -v on terminal. It should return whatever is the latest version mentioned on https://yarnpkg.com/en/docs/install.

Install dependencies

Once yarn is installed run the following:

make deps

Setup

There are two possible ways to setup Avni Webapp for developement:

  1. You can setup the webapp in a way that it directly connects to the hosted API server so you don't have to setup local postgres database and Java API server. This is an easy way to get started as you don't have to worry about having to install Java and API Server. Also this will consume less resources on your system as you are not running API server.
  2. You can setup local postgres database and API server also locally and connect the webapp to that server. This is more difficult as it involves having to install Postgres, Java and running Java API Server.

1. Setup to connect to hosted API Server (Samanvay hosted staging server)

make start-with-staging

2. Setup to connect to your local API Server

  1. Start your Java Server. For this refer to product developement setup document.
  2. Run make start in avni-webapp directory.
  3. It will assume whatever user you started the Java Server with since we don't do authentication when running the server locally. If you want to change the user then restart the webapp after setting environment variable REACT_APP_DEV_ENV_USER to user you want. E.g. start the server like REACT_APP_DEV_ENV_USER=ihmp-admin make start.

Contributing

Pull requests

File/folder structure

  • There are multiple apps inside this repository
    • Admin (Allow admins to do admin work like creating organisations, users, locations)
    • App Designer (Allow admins to design the app)
    • Reports (Allow admins to download longitudnal reports)
    • Translations (Allow admins to upload translations)
    • Data Entry App (Allow users to do data entry using web based app)
  • Folders per route/feature (See https://marmelab.com/blog/2015/12/17/react-directory-structure.html)
  • Reducers and actions in 'ducks' structure (See https://github.com/erikras/ducks-modular-redux). This is not applicable for App Designer as it does not use Redux.

Code Style

  • We use Prettier for javascript/jsx formatting. You can use your IDE/Editor specific Plugin to format code using Prettier. Alternatively there is also a command make prettier-all that will format all files in src folder using Prettier. And there also is a git precommit hook that formats staged files using prettier before commiting.

Continuous Integration

All commits are built and tested and deployed to staging if tests succeed. Build status can be seen at https://circleci.com/gh/OpenCHS/openchs-webapp. Please run tests using make test before you push your code so you don't end up breaking things unnecessarily.

avni-webapp's People

Contributors

1t5j0y avatar amarkamthe avatar amolnirmalpsl avatar arjunk avatar balamuruganjeevi avatar charl3sj avatar darshanatakpsl avatar dependabot[bot] avatar eshjoshi avatar eshwarjoshipsl avatar garimadosar5 avatar himeshr avatar hithacker avatar mahalakshme avatar narendranath-pasupuleti-psl avatar nupoorkhandelwal avatar ombhardwajj avatar petmongrels avatar ramyaedapalapati avatar ramyaedapalapatipsl avatar rudresh avatar sachsk avatar shivamragnar avatar sidsamanvay avatar sidtharthanan avatar swapnil106111 avatar vedfordev avatar vinayvenu avatar vindeolal avatar yenugukeerthana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

avni-webapp's Issues

CRUD for encounter type

UI:
Using react admin. Fields - Name.

API:
New api needs to be created which will create encounter type and operational encounter type.

Ability to create concept inline when creating a form element

As an org admin, I want to be able to create a concept inline when creating a form element.

Mockups:

The flow when you are adding a new element and want to choose an existing concept for it:
image.png

The flow when you are adding a new element and want to create a new concept for it:
image.png

The key idea behind these mockups is that we are telling the user explicitly that you have to choose or create a concept when you create a new element. Another main idea is to have a separate box for the concept in the element so it's obvious as to what the concept fields are and what the element fields are once the concept is created or chosen.

Test Scenarios -

  • Create a new question with the new concept.
  • Create a new question with an existing concept.
  • Create a new coded type question with the existing concept for question and new coded answer.
  • Create a new question with the new concept but that concept already exist in the system (it should give an error).
  • Create a new concept and use this with existing coded answers.

[WebApp] Delete Location Bug

Location -> select a location with children -> Click on Edit -> Click on delete -> It gives message "Element Deleted"
After few seconds it gives the message "Cannot delete this location until all the sub-locations are deleted".

"Element Deleted" message should not come.

Ability to change display order

Acceptance Criteria:

  • User should be able to change the display order of form element and form element groups using drag and drop.
  • When a question is dragged to another place in the same group then we should change the display order of that element and all other elements after it.
  • When a group is dragged to another place then we should change the display order of that group and all other groups after it.
  • When a question is dragged from one group to another then we should void the question from the source group and create a same question with another uuid into destination group.

Ability to stitch forms

In scope

  • Registration and enrolment through the search screen
  • Automatic addition of scheduled visits
  • Implementations specific changes to worklists.

Behaviour of web app after session expiration

  1. Login.
  2. From any listing open an item. Go back to listing.
  3. Leave the tab open till your session expires (depends on the token expiration policy we have in Cognito). This basically simulates use case when people stay logged in, use tabs and work regularly using web app.
  4. After the session expiration, try to open an item in the listing.

Expected - The user would be logged out and brought to the login screen.
Actual - It tries to open the item, fails and goes back to listing. No feedback to the user that they need to log in.

Subject Search page improvements

Functionalities:

The Search API provides pagination and sorting. However, the UI does not allow pagination or sorting in the results. This story is to provide these capabilities within the app.

The UI needs to be similar to how sort is implemented in the admin UI for consistency between admin and data entry apps.

Show subject dashboard

The subject dashboard is a place that provides a snapshot view of a subject, and the different actions that can be taken for that subject. Capabilities include

  • View subject registration details
  • View subject enrolment details
  • View enrolment summary rules
  • View checklists for a program
  • Create new visit
  • Edit visit
  • Cancel visit
  • Add checklist
  • Exit from program
  • Add or remove relationships

[Webapp] Add parent field to AddressLevelType UI

We have parentId in AddressLevelType but we don’t have it on Webapp UI so add it on UI.

In Create/Edit forms, add Parent field

 

QA Comment – 

• A location type is tagged as a parent for another location type. Now if you delete the parent location
type, It will be still tagged with the child location type. for eg: Check location type- Block. 

!Screen_Shot_2019-06-19_at_3.17.02_PM.png!

• Not able to create a location type “District” Level – 4. Error msg – Server communication error.
• In edit option, it gives the option of editing Parent also. But parent cannot be changed.

Migrate existing implementation rules to UI based rules

Scope

We will migrate implementations that we want to demo to UI based rules.

Tasks

  • calls to classes like RuleHelper etc will either have to be provided as library functions or have to be inlined as nested functions.
  • libraries like moment and lodash to be injected as function parameters.

Don't allow to void location type before voiding it's children

Don't allow to void location type before voiding it's children.

https://docs.google.com/spreadsheets/d/1cVy2Lz1_A9f8RP3HhNUfvbCkrgMjA4k4nUy6Figx5NI/edit#gid=2134823698&range=D13

QA Comment -

• It does not allow to delete the location but at first it gives the message that element deleted and after some seconds it gives the error message that "location cannot be deleted......".
It should give the error message as user click on the delete button.

Create search screen

QA Comment -
  • Refresh is not working on the search page. [fixed]
  • In which order list is sorted. [separate card exists for sorting]
  • Can we have some filter also and on top of that we perform the search? [create a separate card if this suggestion converts to a requirement]
  • Also, mention somewhere what is the list about. [Not clear what needs to be fixed]
  • For waterbody, subject type list is not appearing. Username - dhakaneka@ddm. [fixed]
  • Does not tokenify names (search for "sushma thakur" and "thakur sushma" must give Sushma Thakur) [create a separate card for search imporvement]
  • Enter key does not work to search [it works]

On login, if a user is not an org admin, (s)he will be taken to the search screen. Search screen should have the following.

  1. Logout button
  2. One search field (text input) and a search button
  3. Search results with the following parameters.
    a. Name
    b. gender (if individual)
    c. Date of birth (if individual)
    d. Location (full location in the form of A->B->C)
    e. Programs enrolled
  4. Search results will always be shown by default without starting search.
  5. Search results will be limited to the catchment of the user.

Out of scope:

  1. Pagination. Separate card exists for search page improvements.
  2. Granular filters. ex: Gender, Active Programs.

Concept Create/Edit page

image.png

Tasks:

  • On choice of datatype, show different ui for each type.
    • Common fields are name(string(255)) and dataType.
    • Numeric - Show form fields for Low Absolute(number), High Absolute(number), Low Normal(number), High Normal(number), Unit(string)
    • Text
    • Notes
    • Coded - Show an autocomplete field for Answers. It should call API on typing to get matching concepts. Also functionality to quickly add new concept to be used as an answer.
    • NA
    • Date
    • DateTime
    • Time
    • Duration
    • Image
    • Id
    • Video
  • Finally when all the details are filled user will click on Save button which will call POST /concepts API.

API will expect below format:

  • For Coded concept
  {
    "name": "Block",
    "uuid": "87e1989a-c690-4385-b3da-e6e1bacc8f85",
    "dataType": "Coded",
    "answers": [
      {
        "name": "Sagbara",
        "uuid": "833d9b73-1743-424e-8b0e-0de05b69ca4a"
      },
      {
        "name": "Nandod",
        "uuid": "8f7befa1-2cc5-4189-9f67-1fd1953ab720"
      },
      {
        "name": "Tilakwada",
        "uuid": "236c7984-4176-45e3-819b-992a39e2a3a4"
      }
    ]
  }

Ability to clone a form and map it to different program and encounter types

UI:
In the form listing page - In action column there will be a button called copy for each records.
Once user click on the copy button of the appropriate row a pop-up will show-up. This pop-up will ask for name, an encounter type and a program. On confirmation it will create a new form with different name and form mapping but same groups, questions, and rules.

API:
New API need to be created which will clone the form server side.

Form Details Page - Ability to add and remove questions/groups

image.png

Tasks:

  • Add Create New Group button - 1
    • Will be located outside group section
    • Should add a new group section below an existing group
  • Add Create New Question button - 1
    • Will be inside group
    • Should add new question below last question
  • Expand/Collapse for groups and questions - 0.5

Checklists

In scope

  • Show checklists
  • Fill in form for checklists

[DataEntryApp] Subject Registration without System Recommendations

As a field service user, when I am on the search subject list page, I need to be able to register a new subject.

In scope

  • Basic Registration wizard with all form element types for any subject type
  • Mandatory validation
  • Regex validation
  • Form element filters
  • New Registration
  • Edit Registration

Out of scope

  • System recommendations
  • Scheduling visits

Notes

  1. Fetch all reference data - concepts, locations, genders, operational subject types, operational programs etc during initial load
  2. Ensure these are not fetched every time using http cache
  3. Extract openchs-models into its own npm repository. Use this as a dependency

Register a subject

In scope

From the search screen, the add button must take you to a listing of different subject types. Clicking on appropriate subject type takes you to the registration screen.
Registration screen must contain the following types of form elements.

  • Numeric [done]
  • Text [done]
  • Notes [done]
  • Date [done]
  • DateTime [done]
  • Time [done]
  • Duration [done]
  • SingleSelect [done]
  • MultiSelect [done]

Out of scope

  • Form elements Image, Id and Video
  • Storing of location
  • Validation (mandatory, range, regex)
  • Implementation hooks (visibility filter, calculated fields, decisions)
  • Ability to choose address of the Subject ( a separate card is there)

Notes

  • Use openchs-models for data
  • Keep reference data in memory

Workdone

date of registration should be current date by default - [done]
date of birth should have age - [done]
test with multiple subject types - [done (almost)]
multiple form element groups - [done]
add previous button on first page of form - [done]
other field types - [done]
handle non Duration FormElements [done]
fix underline in previous and next [done]
tests for new adapters for operational modules [done]
remove Linebreaks in SubjecrRegister

CRUD for subject type

UI:
using react admin. Field - Name

API:
Needs to be created which creates subject type and operational subject type.

Validation of fields in a form

Motivation:

As an data entry operator, the system should validate the data being entered in the forms before Save

Acceptance criteria

  • When a validation fails, field is highlighted in red
  • When a validation fails, user is not allowed to go to the next page and apt message is shown to the user
  • For default fields in forms in application, validations given on technical details below link1 should work. eg: default fields: basic registration details: First name, last name, age, gender, date of registration, date of birth.
  • For custom fields configured on forms:
    • All types of fields in the form such as (Numeric, Text, Notes, Coded, Date, DateTime, Time, Duration) should be validated based on the form configurations.
    • Configuration can be done on forms through admin app (regex and description key ) for any custom validations
      Example: Form, text element will have regex configured for validation for allowed characters and validation description key for error to be shown. If regex is not matched then we highlight the field in red and show an error given in the validation description key.
      Another example: Numeric concept will have low absolute and high absolute specified. If the value entered by the user is below low absolute then an error message with key numberBelowLowAbsolute should be shown. If the value entered by the user is above high absolute then an error message with key numberAboveHiAbsolute should be shown.
  • Below Validations are in scope for different field types:
    • Mandatory validation for all types of fields (Numeric, Text, Notes, Coded, Date, DateTime, Time, Duration)
    • Numeric validation
    • Coded unique validation
    • Range validation for absolute min and max
    • Highlighting of values that are beyond the acceptable range
    • Regex validation
      ( Please see link2 in technical details for form elements validations that should work )

Technical Details:

All of this validations code is already there in particular avni model and you are supposed to just reuse it instead of writing all these validations from scratch. Use the validate() method of Individual model and FormElement model to validate the user data and get back the validation results. You only have to implement rendering the validation errors returned by the model and stopping the user from going to next page.

( as discussed and given by Hiren )
For default fields - like on registration basic details , Validations in code exist here:
https://github.com/avniproject/avni-models/blob/ac5e4209b70777f5f1682bb8cd308f7dc37d22ad/src/Individual.ts#L326

For other validations from form element:
https://github.com/avniproject/avni-models/blob/ca82d057567d1f49f709144f8000693a8063ea28/src/application/FormElement.js#L88

Create a new empty form

Acceptance Criteria

  • Allows user to enter form type, form name, and other details.
  • For the form types: ProgramEncounter, ProgramExit, ProgramEnrolment, ProgramEncounterCancellation it should ask the user to select the program name.
  • For the form types: Encounter, ProgramEncounter, ProgramEncounterCancellation it should ask the user to select Encounter Type.
  • Form name and Subject type are mandatory for all types of form.
  • Redirects to form edit page after creating the form.

Mockup

image.png

Implementation details:

Move Form Type to be the first field of the form.

Add a new field for Subject type.
Subject Type, Encounter Type, and Program dropdowns should get populated from /web/operationalModules API.

Call the POST /forms on click of Create Form with all the details. Generate and send form uuid along with other parameters like form name, subject type, encounter type etc to the API. Once the form is created then navigate the user to form details page. API needs to be modified to take subject type, encounter type, and program name.

Listing of forms

form-list.jpeg

Tasks:

  • Listing forms
  • API also needs to be changed because current /forms api returns only program related forms and not forms like registration or individual encounters.

CRUD for program

UI:
Using react admin. Fields are Name, color(color picker) and subject label(hint same as name).
Way to define rules at program level : Program summary rule type.
Note : Current we use color name and not hex code so this need to verified.

API:
New combined api needs to be created which acts as a single resource for both operational program and program. API Url can be /web/program.

Resource structure is as follows:

{
  "name": string,
  "colour": string,
  "programSubjectLabel"
}

Form settings and form level rules

image.png

Tasks:

  • Add fields form type, form name, subject type, program name, encounter type. For this use the same component as Create New Form. If necessary refactor code to extract out the common component.
  • For rules
    • Give a UI to add new rules with rule type(Decision, VisitSchedule, Validation) and rule function(string). We can give add button to add new rule.
  • Call the PUT /forms API on form save.

New landing page and menubar for form designer

image.png
Two cards to navigate to react admin and the form designer.
Left menu component :

  1. Add left menu to the form designer where we will be listing concepts and forms.
  2. Refresh to take to same menu.

[WebApp] User Profile section

For every web user, there will be a profile section where all the information about User will be mentioned that we can see in admin login (but in this case user will be able to see only his/her info).

Location creation fails when there is only one location type

Steps to reproduce:

  1. Make sure there is only one non-voided location_type exist.
  2. Go to locations -> create.
  3. There won't be any input for parent location. [as expected]
  4. When you save, it fails.

Rough idea on why it fails:

  • even though there is no parent location. the payload to the location api has a parent object.
  • It is {uuid,title,level,type, parents=[{}] }. But it has to be {uuid,title,level,type,} or {uuid,title,level,type, parents=[]}

App Designer

Problem

Today doing an Avni implementation is not very intuitive to anyone outside of the product team. The metadata creation is tech heavy. It requires quite a bit of training on how an implementation is to be done and knowledge of json, sql and unix.

Solution

To fix the metadata problem, we have already started building the admin UI. Most of the metadata creation (users, locations, catchments) is available there, the only last thing being the ability to design programs, forms and the custom logic required for skip logic, calculated fields, visit scheduling and configuration other extension points available through code.

In scope

  • A UI from which following can be designed
    • Programs
    • Forms with rules
    • Checklists

Out of scope

  • Self service UI for tech organisations to host on existing hosted solutions
    This will require features like Database and reports access for partners, Log access for implementers, Server status available publicly, Ability to export and import data from an organisation, Migration of all existing rules to the new format

  • Self service UI for end users
    Self service UI. The current purpose is not to have any organisation coming in and designing things for themselves. This is a good to have, but means that we need to integrate invoicing, emails, build a different kind of authentication, a lot more automation etc. The current objective is to be able to open up implementations to partners only. Opening it up to the general public will depend on how this goes. Partners will be empowered to handle data for their own organisations.

  • Translations from UI [Being done part of a separate epic]

Challenges

  • We might need to move away from hierarchical organisations to single organisations, and encapsulate data within each.

User flow

The deployment workflow will be managed through organisations. The implementers would be able to create organisations for QA, UAT and production. Metadata from one organisation to another will be promoted through an export-import mechanism.

Tech choices

  • We will replace the uniqueness constraint on uuids on every table, and replace it with a combined constraint on uuid and organisation.
  • We will move javascript logic from the file system, break it down and attach it to where they belong (form elements, program etc). This can be either done in the same table, or in a common different table where all rules are stored. This also means zero imports/dependencies like what
  • We will move away from hierarchical organisations to single organisations.
  • We have not solidified any restrictions we need to provide from test to production.
  • Import/export will reuse existing endpoints, and will be idempotent.

Export implementation

Acceptance Criteria

  • It should export all the entities that can be created from UI designer and admin app as a single zip file.
  • Directory structure: Flat files for all entities inside bundle zip. Forms will have it's own directory named forms. Inside forms directory store each form by it's name.
  • All exported entities should have all attributes specified via UI Designer
    e.g. If an entity is voided it must have voided attribute set to true. Deleting existing form element, form element group, program, encounter type, subject, concept, concept answer results in it being voided.
    e.g. The numeric concept must have lowAbsolute, highAbsolute etc if they are set.
    e.g. Coded concept must have answers if they are set. Answers must have unique, abnromal if set.
  • Parent addressLevelType should come before children addressLevelTypes in addressLevelTypes.json.
  • Parent location should come before location in locations.json.
  • In concepts.json: concepts that are used as answers in other coded concepts should come first. Concept answers in coded concepts should be ordered by order property of answer.
  • form element groups and form elements inside each group should be ordered by display order.
  • All exported files should be importable on both fresh database as well as an existing database.

Tech tasks:

  • Entities to be exported
    • Form
    • FormMapping
    • Catchments
    • Concept
    • Location Types
    • Locations
    • Programs
    • Encounter Type
    • Operational Encounter Type
    • Operational Programs
    • Operational Subject Types
      • Translations
      • Organisation Config
  • Create an API that will return zipped bundle file.

Checklist Schedule Builder

Mockup

Checklist Builder

  • Checklist Form <dropdown that allows to choose form of type ChecklistItem>

Items (Option to add items)
Item (Option to remove item)

  • Concept <autocomplete with NA concepts>

  • After how many days of birth should it be scheduled? <number>

  • Can this item expire? <yes|no>

  • Expires after how many days from birth date? <number>

  • Do this item depend on any other item? <yes|no>

  • Dependent On <autocomplete or dropdown with items defined previously>

  • Minimum Gap From Dependent (days) <number> //show only when this item depends on other item

IMG_20200110_124312.jpg

Implementation Details

You need to call POST /checklistDetail api to save the checklist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.