Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Officially support ODK Central for offline stock movements #6235

Closed
jniles opened this issue Jan 3, 2022 · 3 comments · Fixed by #6337
Closed

Officially support ODK Central for offline stock movements #6235

jniles opened this issue Jan 3, 2022 · 3 comments · Fixed by #6337

Comments

@jniles
Copy link
Collaborator

jniles commented Jan 3, 2022

We released a tag v1.21.3-pcima with support for ODK Central. This was to handle the PCIMA project's need to track stock offline with ODK forms. I propose we formalize this support in BHIMA and merge the functionality into master. It will make support easier going forwards.

We've released a module @ima-worldhealth/odk-central-api that should offload the ODK Central API functionality into its own tested module. This means we can focus on rewriting the import.js functionality to bring stock movements into BHIMA from data collected in the ODK Central Server.


One thing to think about - we could migrate the pepkits project to using this version of BHIMA/Central and have another project using this functionality in addition to the PCIMA project.

@jniles
Copy link
Collaborator Author

jniles commented Jan 4, 2022

Similarly, we might be able to improve our aggregate stock consumption by providing telephones for users in the health centers to use to record their stock consumption information. This would ensure that we have more accurate data from the FOSAs in our Health Zone stock tracking project.

Basically, the following projects would greatly benefit from this:

  • OFDA Pepkits III
  • ASSR Stock Movement Tracking in Tshikaji Health Zone
  • UNICEF PCIMA

@jniles
Copy link
Collaborator Author

jniles commented Jan 17, 2022

Design

This describes the rough design of the BHIMA ODK link. It is useful to look over the ODK Central API documentation.

A BHIMA enterprise is an ODK Central project

When you install BHIMA, you'll be allowed to optionally add the configuration for an ODK Central Server. This would be the username, password, and server URL. This user must be an administrative user to create new projects. A project on ODK Central would be created for the enterprise, and the odk_project_id would be stored in some table, probably its own table aside. Currently, we don't model multiple enterprises in BHIMA.

Information we need to store in BHIMA so far:

  • odk_central_url
  • odk_admin_user
  • odk_admin_password
  • odk_project_id

A BHIMA user (with access to a depot) is an ODK Central user

When someone creates a user in BHIMA, we should create a user in ODK Central with their email address. It's a 1-1 mapping. But @jniles, you cry, email addresses have to be unique in ODK Central! What happens if I want to have a user account on two BHIMA instances?!

Well... this works:

image

So, we just append +${enterprise_name} to the email address and you can make one million accounts of the single email address. We save the odk_user_id for each user in BHIMA. Simple.

This user will have access to the forms specified by their user_depot permission mapping in BHIMA. Each time a user's depot permissions are updated, we'll need to update their ODK Central permissions. This might be tricky, but the API makes it seem doable.

For each user, we'll need to store:

  • odk_user_id
  • odk_user_password ?

A BHIMA depot creates three ODK Central forms - entry, exit, and routine inventory

We need to implement three forms for each depot - entry, exit, and routine inventory. I propose that these be called ${depot.label} - Stock Entry, ${depot.label} - Stock Exit, ${depot.label} - Routine Inventory.

The first page of each form should provide the BHIMA installation name, the depot name, the timestamp the information in the form was updated.

For both entry and exit, we'll want to specify the origin depot or the destination depot. In both cases, the user should have permission to see that depot. Question: For stock entries, should we require that users select from a list of transfer documents destined to the destination depot?

When a BHIMA user is given permission to access a depot in BHIMA, they are also given permission to that depot's forms in ODK Central.

Each of these depot forms will have a list of all BHIMA products in them, that can be looked up via a barcode scan. These will be in an external select for convenience.

When the stock in a depot changes (either via an entry or an exit), this form should be updated with a new version.

For each depot, we'll need to store:

  • odk_entry_form_id
  • odk_exit_form_id
  • odk_inventory_form_id

@mbayopanda
Copy link
Collaborator

The design is great, it presents how things have to be done for a real benefit of both BHIMA and ODK.

The doability is a real challenge because we have to go deep inside the ODK API and find all answers that we need.

Here my point of view according points :

A BHIMA enterprise is an ODK Central project

I had a concern with existing project in ODK Central, but if we have to consider the new created one related to a BHIMA instance its okay to me.

A BHIMA user (with access to a depot) is an ODK Central user

It is okay to me.

A BHIMA depot creates three ODK Central forms - entry, exit, and routine inventory

So we have to add 3 forms for each bhima depot,

  • 30.000 forms to add in the case of PCIMA
  • 30.000 forms to add in the case of PEPKITS
  • etc.

Our ODK Central will had to deal with a huge number of forms.

Question: For stock entries, should we require that users select from a list of transfer documents destined to the destination depot?

In the case the exit was made with ODK Collect, I don't know if the user will have the document ID (in case of zone where there is not BHIMA: FOSA). So It can be difficulet to
select from a list of transfer documents since the user don't know the concerned transfer document.

@jniles this is a great feature to add in BHIMA.

The next release with that can be BHIMA 3.X :-)

jniles added a commit to jniles/bhima that referenced this issue Jan 17, 2022
Adds odk central integration tables for the eventual link to ODK
Central.  Currently adds them under Stock Settings, but we can move them
easily enough later.

Related to Third-Culture-Software#6235.
jniles added a commit to jniles/bhima that referenced this issue Jan 17, 2022
Adds odk central integration tables for the eventual link to ODK
Central.  Currently adds them under Stock Settings, but we can move them
easily enough later.

Related to Third-Culture-Software#6235.
jniles added a commit to jniles/bhima that referenced this issue Jan 17, 2022
Adds odk central integration tables for the eventual link to ODK
Central.  Currently adds them under Stock Settings, but we can move them
easily enough later.

Related to Third-Culture-Software#6235.
@jniles jniles self-assigned this Jan 18, 2022
mbayopanda pushed a commit to mbayopanda/bhima that referenced this issue Jan 24, 2022
Adds odk central integration tables for the eventual link to ODK
Central.  Currently adds them under Stock Settings, but we can move them
easily enough later.

Related to Third-Culture-Software#6235.
jniles added a commit to jniles/bhima that referenced this issue Jan 25, 2022
This commit implements the ODK Central link with BHIMA, developped
during the `prosani-sprint`.  The goal is to have a functional, optional
link to ODK Central that can be merged into the BHIMA repository.

Closes Third-Culture-Software#6235.
jniles added a commit to jniles/bhima that referenced this issue Jan 25, 2022
This commit implements the ODK Central link with BHIMA, developped
during the `prosani-sprint`.  The goal is to have a functional, optional
link to ODK Central that can be merged into the BHIMA repository.

Closes Third-Culture-Software#6235.
jniles added a commit to jniles/bhima that referenced this issue Jan 25, 2022
This commit implements the ODK Central link with BHIMA, developped
during the `prosani-sprint`.  The goal is to have a functional, optional
link to ODK Central that can be merged into the BHIMA repository.

Closes Third-Culture-Software#6235.
jniles added a commit to jniles/bhima that referenced this issue Jan 26, 2022
This commit implements the ODK Central link with BHIMA, developped
during the `prosani-sprint`.  The goal is to have a functional, optional
link to ODK Central that can be merged into the BHIMA repository.

Closes Third-Culture-Software#6235.
jniles added a commit to jniles/bhima that referenced this issue Jan 28, 2022
This commit implements the ODK Central link with BHIMA, developped
during the `prosani-sprint`.  The goal is to have a functional, optional
link to ODK Central that can be merged into the BHIMA repository.

Closes Third-Culture-Software#6235.
bors bot added a commit that referenced this issue Jan 28, 2022
6337: Feat: merge ODK central work r=jmcameron a=jniles

This PR adds in [ODK Central](https://docs.getodk.org/central-install/) functionality to the BHIMA server.  Here is what the ODK administration interface looks like:

![image](https://user-images.githubusercontent.com/896472/150951277-34cf068b-9eca-4363-a485-ad135ad18df1.png)

You'll need to set your own username/password and ODK Central URL to test it out.

This installation is very bare-bones.  The way this works is somewhat documented in #6235 (comment).

This PR is plucked from work done by `@jniles` and `@mbayopanda` in `sprint-prosani`.

Closes #6235.
Closes #6302.
Closes #6322.

---

**TESTING**  (based on session with `@jniles` )
- Use bhima test (rebuild db, etc)
- Go to Administration > ODK Settings
  - Enter the ODK Central login credentials in the left-most panel (ODK Integration Settings)
  - In the middle panel, click on
    - Synchronize enterprise settings
    - Synchronize users
    - Synchronize forms
- Go to Adminstration > User Management
   - In the action menu for Superuser, click on the [ODK QR Code] link to display the QR code (leave it up on your screen)
- On your mobile phone
  - If you have not installed ODK Collect, do that
  - In ODK Collect, click on the [Configure with QR code] button on the entry screen. This should bring up the "Test Enterprise" page
  - Click on [Get Blank Form].  It should show that it has downloaded a form
  - On the bottom right of the page, click on the [Get Selected] button.  This downloads the form and sends you back to the "Test Enterprise" page.
  - Click on [Fill Blank Form] and select the form.  This should start filling out the form.
  - Fill out the form
     - For Nombre des articles, enter 1
     - For the barcode, first go to Bhima (Stock Lots) and display the barcode for lot VITAMIN-A.  Then scan that barcode with your phone.  When you click next, it should show the lot you selected.
     - Finish the form ([X] Mark form as finalize, press [Save Form and Exit])
  - Back on the "Test Enterprise" page, click [Send Finalized Form].  Select the form you just completed and press [Send Selected] on the bottom right of the page.
  - Back on Bhima go to Administration > ODK Settings
  - Click on:  Synchronize Submissions [Sync]
  - Go to Stock > Stock Movements and verify that you have a new stock entry in Depot Tertiaire







Co-authored-by: Jonathan Niles <jonathanwniles@gmail.com>
@bors bors bot closed this as completed in 774b12a Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants