IMA-WorldHealth / bhima

A hospital information management application for rural Congolese hospitals
GNU General Public License v2.0
215 stars 103 forks source link

Rewrite cash missing debtor error text #3100

Closed jniles closed 6 years ago

jniles commented 6 years ago

If a user tries to register invoices to the cash window without first selecting a debtor, the system will display a small error message with almost incomprehensible text. It is shown below.

missingdebtorerrortext

It would be helpful if this text would direct the user that they should first choose a patient, then attempt to pay their bills.

AdamWatts commented 6 years ago

Hi, I would like to take on this issue. Setup might take bit but should be pretty quick.

jniles commented 6 years ago

Hey @AdamWatts, great to have you on board!

If you have any questions, please to feel free to ask!

AdamWatts commented 6 years ago

Thanks @jniles. I'm running into issues getting the DB running, I've done some research and I believe its because I'm on WSL for windows https://github.com/Microsoft/WSL/issues/2941. There might be a work around, not sure yet. I'm not certain I need to get the DB working just to fix this error message, but I was assuming you would like it thorough; have all test run and pass before merge.

sfount commented 6 years ago

Hi @AdamWatts, I've had some experience with WSL and would love to help you get up and running!

A workflow that I like using on Windows is to take advantage of Windows editors and ecosystem (I personally use VSCode) but use WSL for the services running in the background, in the case of this project these are MySQL and Redis.

You mentioned that there was an issue with the database, hopefully I can give some pointers with how I got MySQL up and running.

I've had a lot of issues with the latest version of Ubuntu (18.04) with WSL, in fact I think the MySQL installation process fails with this. Because of this I'm still using Ubuntu (16.04) which you can find as a separate application in the Windows store Link to store.

You can double check that it's running 16.04 with the command

lsb_release -a

From here we can set up MySQL:

sudo apt update 
sudo apt upgrade 

# This will have you set the mysql root password in an interactive session
sudo apt install mysql-server 

# Because of a quirk on WSL (this is a common theme!) the mysql service 
# doesn't correctly start, we can start this manually though 
sudo service mysql start 

# We can now login to MySQL - the instance should be running correctly 
msyql -u root -p 

# The redis installation is much simpler 
sudo apt install redis-server
sudo service redis-server start 

# Double check redis server is up and running - this should return PONG
redis-cli ping 

These two services can now be accessed from Windows simply as if it is running locally (on 127.0.0.1).

It should be possible to follow the install instructions for building the database etc. Install.md

From my experience there has been a lot of fighting with making different services run on WSL, but I can assure you it works! Running Linux in a Virtual Machine is also a great way to get up and running with Linux on Windows.

Please let me know if this helps get the database up and running, if there's anything keeping you from getting the full system connected you can let me know!

AdamWatts commented 6 years ago

@sfount Hey thanks for the help. I use VS Code as well with Oh My Zsh but I'm using Debian 9, trying to get a feel for Linux. Thinking of getting one for my next machine. DLing 16.04 right now, going to give that a try. I'll let you know how it goes.

AdamWatts commented 6 years ago

@sfount Okay so with 16.04 everything seemed to be going smoothly, I was able to Configure the bhima user in MySQL and build the app or I thought. Once I ran build:db script I got the same error as before

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

I was able to get something of the app on localhost but unable to login. with errors code: 'ECONNREFUSED'

So my guess was the configuration of the bhima user in MySQL didn't work, but when I re-attempt I get the original error.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Its late now, I'll give it another shot in the morning. Thanks for the help and patience, sorry I'm really just getting started in opensrc.

sfount commented 6 years ago

@AdamWatts I can definitely encourage getting a feel for Linux when it comes to web development; many resources online assume a 'nix based system and being comfortable with the basics can really help out.

Re: the setup, it sounds like you're most of the way there! Our MySQL error here is a cryptic one, 9 times out of 10 a MySQL socket error is just a complicated way of telling you that the MySQL server isn't running at all so it can't connect.

Services on WSL have a bug that prevents the startup 'daemon' from correctly starting the service when Linux starts. What this means is you had probably restarted your computer or Ubuntu application between configuring the bhima user and running the build:db script.

Unfortunately after a long time trying to get these services to start correctly I gave in and created a small script that I run myself when I start Ubuntu.

start_services.sh

#!/bin/bash
# WSL service start patch
sudo service mysql start 
sudo service redis-server start 

With this script we can manually start the services, note that this is not how these services work in general on Linux, on any other system you should expect these services to always be running in the background.

# Tell Linux that this file can be executed - this only needs to be run once 
chmod +x start_services.sh

# Finally running the script will ask for your sudo password to start the services 
./start_services.sh

Any time that restart your computer, this script will need to be run again until WSL figure out the services related bug.

(Note if you have any other MySQL servers running, on Windows for example, it is possible that they are both trying to bind the default port of 3306 and colliding - I think this is very unlikely though, as I said the var/run/mysqld/mysqld.sock error is almost always complaining that MySQL hasn't started.)

Hopefully knowing this and getting the services started will let you continue with building the database! If it keeps giving us a problem, we could investigate other ways of running Linux or setting up on Windows itself.

Please let me know how you get on with this, I'm happy to help and really appreciate the interest in both open source and this project!

AdamWatts commented 6 years ago

@sfount Alright awesome this solution worked perfectly, everything seems to be running well. I now am prompt with the login form on localhost. Quick question though, what should the login credentials be? I thought it would be the user configuration -u -p from the DB but I'm mistaken.

sfount commented 6 years ago

@AdamWatts Glad to hear it!

The build:db command that you've run for set up builds an SQL file that inserts data for testing the system, this is what creates the system users. You can find it in test/data.sql (line 312).

A good account to use for getting familiar with the application would be username: superuser password: superuser. This user has been created to have permission to all modules. We can certainly update the getting started documentation to make this clearer.

AdamWatts commented 6 years ago

@sfount Thank you for the clarification. Yes I think updating the documentation would be helpful for newcomers. I'm feeling a little groggy today, so I might just try and get familiar with the app today. Then work on the issue tomorrow.

sfount commented 6 years ago

@AdamWatts it looks like there is a great entry on getting into the application on the Getting Up and Running under 'Resources for Contributors' on the wiki. I just didn't know to point you in that direction!

If you have any suggested changes to the wiki or install guide based on your new perspective we could use the help! Pull requests can be made for this documentation in the same way as code changes. Good luck and thanks!

AdamWatts commented 6 years ago

So I'm new to angular but I have some react experience. I was able to find the controller who's state params are being called for this particular error message in https://github.com/IMA-WorldHealth/bhima-2.X/blob/7c3822f7f6749d2992e6c0d0285ddb3ed9ec04ca/client/src/modules/cash/modals/invoice-modal.ctrl.js#L25 and the controller is receiving a list of debtor invoices from the server, and if I'm not mistaken the server is being populated with info from the DB. Still trying to understand the system, get familiar, and hunt this down. Any direction would be appreciated :)

Need to get to these params and change msg? https://github.com/IMA-WorldHealth/bhima-2.X/blob/7c3822f7f6749d2992e6c0d0285ddb3ed9ec04ca/client/src/modules/cash/modals/invoice-modal.html#L17

Never mind found it :) all that is required I think is to edit this error https://github.com/IMA-WorldHealth/bhima-2.X/blob/7c3822f7f6749d2992e6c0d0285ddb3ed9ec04ca/client/src/i18n/en/form.json#L117

Re-build the app, then re-run it.

Suggestions on a more clear error message? Should we also edit the French message to be more clear?

jniles commented 6 years ago

Hey @AdamWatts, great work!

In my view, a short message that tells the user how to fix the problem is preferable. I imagine "Please select a patient before the invoices" would do just fine.

The French translations will be in an identical location fr/form.json. If you feel confident in French, go ahead an take a wack at it! Otherwise, either myself or one of our native speakers (@lomamech @mbayopanda) will add in the French translations separately.

Awesome that you've gotten this far on WSL!

AdamWatts commented 6 years ago

@jniles Thanks.

Cool I'll just use that, unless I come up with something genius lol.

I was just going to use google translate so it might be better if someone fluent did ¯_(ツ)_/¯

AdamWatts commented 6 years ago

@jniles

So I ran the client-unit tests and got

clientunitpass

Then again with

clientunitfail

I'm pretty new to running tests on projects such as this so I'm not to sure what to make of the results...

Also for the branch name I was going to go with

refactor-cash-missing-debtor-error-text

For the commit message

chore(i18n): refactor en.json key

jniles commented 6 years ago

@AdamWatts, the unit tests spin up a chrome browser with Karma and it looks like that may not be working correctly on your machine. Since we run our tests online before merging (as you've seen), it's not that big a deal.

I am curious, do your integration tests pass? You can run them with yarn test:integration or npm run test:integration.

AdamWatts commented 6 years ago

@jniles I'm not really sure what happened, but I cant run/build anything right now. Can't seem to find gulp-rev-rewrite module....I'll let you know once I solve this.

Error: Cannot find module 'gulp-rev-rewrite'

sfount commented 6 years ago

@AdamWatts occasionally the libraries the project depends on will change, usually this is accompanied by a pull request with the label 'Breaking Changes' and it means new libraries will need to be downloaded.

The good news is that updating your dependencies is as simple as

yarn

Yarn is the package manager so if there is ever an issue with a module, that is the place to look! Running yarn will check the package.json for changes and make sure you are all up to date.

EDIT for you information the pull request that updated dependencies landed 2 days ago and was a small update to the way the Javascript build tools work. You can find it here https://github.com/IMA-WorldHealth/bhima-2.X/pull/3123

AdamWatts commented 6 years ago

@sfount Awesome, thank you. I was using npm because I already had it installed, but just downloaded yarn and updated the dependencies, everything seems to be in order. Other than running the tests.

AdamWatts commented 6 years ago

@jniles I was getting an error about chrome binary with CHROME_BIN so I went to the Karma Docs and ran

//Changing the path to the Chrome binary $ export CHROME_BIN=/usr/local/bin/my-chrome-build

fixed that error

but the tests are still not running properly, I got a massive output of errors. Unsure if I should post it or not.