Ember frontend for HospitalRun: free software for developing world hospitals
To run the development environment for this frontend you will need to have Git, Node.js, Ember CLI, Bower, and CouchDB installed.
- Contributing
- Installation
- Running the application
- Running with Docker
- Accessing HospitalRun with Docker Toolbox
- Accessing HospitalRun with Docker or Docker-compose
- Troubleshooting your local environment
- Loading sample data
- Testing
- Contributing
- Start coding
- Further Reading / Useful Links
- Experimental
- Frequently Asked Questions
Contributions are welcome via pull requests and issues. Please see our contributing guide for more details, including a link to join our project Slack.
To install the frontend please do the following:
- Make sure you have installed Git.
- Make sure you have installed Node.js. Versions 6.0.0 and higher should work. We recommend that you use the most-recent "Active LTS" version of Node.js.
- Install ember-cli latest:
npm install -g ember-cli@latest
. Depending on your npm permissions you might need root access to install ember-cli. - Install bower:
npm install -g bower
. - Clone this repo with
git clone https://github.com/HospitalRun/hospitalrun-frontend
, go to the cloned folder and runscript/bootstrap
.
- Note: If installing packages globally via
npm
requires root access on your machine (seeember-cli
installation), runningscript/bootstrap
will also require root access. The containedbower install
step will fail when running as root. A fix for this is to editscript/bootstrap
and add the--allow-root
option to the command:bower install --allow-root
. - Note: If you are using Windows with
cygwin
please run the script in the following way to remove trailing\r
characters:
bash -o igncr script/bootstrap
- Note: Depending on your npm permissions you might need root access to install PhantomJS2; also, Windows users must run with Cygwin).
- Note: If you just want to use the project, cloning is the best option. However, if you wish to contribute to the project, you will need to fork the project first, and then clone your
hospitalrun-frontend
fork and make your contributions via a branch on your fork.
- Install and configure CouchDB:
- Download and install CouchDB from http://couchdb.apache.org/#download.
- Start CouchDB:
- If you downloaded the installed app, navigate to CouchDB and double-click on the application.
- If you installed CouchDB via Homebrew or some other command line tool, launch the tool from the command line.
- If you're stuck with the installation, check out the instructions published here: http://docs.couchdb.org/en/1.6.1/install/index.html
- Verify that CouchDB is running by successfully navigating to 127.0.0.1:5984/_utils. If that fails, check the installation guide for CouchDB: http://docs.couchdb.org/en/1.6.1/install/index.html.
- Create admin user:
- If you are running CouchDB 1.x:
- If you have just installed CouchDB and have no admin user, please run
./script/initcouch.sh
in the folder you cloned the HospitalRun repo. A userhradmin
will be created with passwordtest
. - If you already have a CouchDB admin user, please run
./script/initcouch.sh USER PASS
in the folder you cloned the HospitalRun repo.USER
andPASS
are the CouchDB admin user credentials.
- If you have just installed CouchDB and have no admin user, please run
- If you are running CouchDB 2.x (experimental):
- HospitalRun currently does not fully support CouchDB 2.x, but you are welcome to try using it. Most functionality should work but currently creating and/or editing users does not work in CouchDB 2.x. See HospitalRun#953 for more details.
- If you have just installed CouchDB and have no admin user, please run
./script/initcouch2.sh
in the folder you cloned the HospitalRun repo. A userhradmin
will be created with passwordtest
. - If you already have a CouchDB admin user, please run
./script/initcouch2.sh USER PASS
in the folder you cloned the HospitalRun repo.USER
andPASS
are the CouchDB admin user credentials.
- If you are running CouchDB 1.x:
- Copy the
server/config-example.js
toserver/config.js
in the folder you cloned the HospitalRun repo. If you already had a CouchDB admin user that you passed into the couch script (./script/initcouch.sh USER PASS
), then you will need to modify thecouchAdminUser
andcouchAdminPassword
values inserver/config.js
to reflect those credentials. (Note: If on Mac, you need to make sure CouchDB can be run. See How to open an app from a unidentified developer and exempt it from Gatekeeper.) - Verify that CouchDB is running by visiting: http://127.0.0.1:5984/_utils/#login
and logging in with the with the credentials you just created from steps 6 and 7.
- If the page returns an error or 404:
- Run
make serve
, it will start couchdb, install npm dependencies and start the server. - Or start the application from your applications folder.
- Run
- If the page returns an error or 404:
To start the frontend please do the following:
- Start the server by running
npm start
in the repo folder. Ifnpm start
doesn't work for you, tryember serve
as an alternative. - Go to http://localhost:4200/ in a browser and login with username
hradmin
and passwordtest
.
To run HospitalRun with Docker please do the following:
- Go to https://docs.docker.com/engine/installation to download and install Docker.
- Clone the repository with the command
git clone https://github.com/HospitalRun/hospitalrun-frontend.git
. - Change to the hospitalrun-frontend directory
cd hospitalrun-frontend
. - Build the HospitalRun image with
docker build -t hospitalrun-frontend .
. - Execute
docker run -it --name couchdb -d couchdb
to create the couchdb container. - Execute
docker run -it --name hospitalrun-frontend -p 4200:4200 --link couchdb:couchdb -d hospitalrun-frontend
to create the HospitalRun container.
To run HospitalRun with Docker-compose please do the following:
- Go to https://docs.docker.com/compose/install to install Docker-compose.
- Execute 'docker-compose up' to reduce the steps to build and run the application.
If you are running with Docker Toolbox you will have to run the following commands to get the IP of the docker machine where hospitalrun-frontend is running with the following:
- Run the following command to get the ip of the docker machine that the image was created on
docker-machine ip default
. - Go to
http://<docker-machine ip>:4200
in a browser and login with usernamehradmin
and passwordtest
.
If you are not running with Docker toolbox, please do the following:
- Go to
http://localhost:4200
in a browser and login with usernamehradmin
and passwordtest
.
Always make sure to git pull
and get the latest from master.
The app will usually tell you when something needs to happen (i.e. if you try to npm start
and npm is out of date, it will tell you to run npm update
. But If you run into problems you can't resolve, feel free to open an issue, or ask for help in the HospitalRun Slack channel (you can request an invite here).
Otherwise, here are some tips for common issues:
The browser shows only a loading dialog
Is your server (still) running? Is CouchDB running? If not, that's probably the issue.
My changes aren't showing up in the browser
Try a browser refresh cmd + r
.
If you would like to load sample data, you can do so by navigating to Load DB under the Administration menu. You should see the following screen:
Click on Choose File and select the file sample-data.txt which is included in root directory of the repo at sample-data.txt. Next, click on Load File. When the database load is complete a message will appear indicating if the load was successful.
Fixtures are PouchDB dumps that are generated with pouchdb-dump-cli.
To create a fixture, run pouchdb-dump http://localhost:5984/main -u hradmin -p test | cat > tests/fixtures/${name_of_fixture}.txt
.
To use a fixture, use runWithPouchDump(${name_of_fixture}, function(){..});
in your acceptance test. For example:
test('visiting /patients', function(assert) {
runWithPouchDump('default', function() {
//Actual test code here
authenticateUser();
visit('/patients');
andThen(function() {
assert.equal(currentURL(), '/patients');
});
});
});
To run the test suite locally while developing, just run ember test
from the project root.
Tests will also run automatically via Travis CI when you push a branch to the repository or a pull request. You can view output by going to the Travis test status from the Pull Request merge box.
Again, contributions are welcome via pull requests and issues. Please see our contributing guide for more details.
Seriously, please read the Contribution Guide.
To start coding and understand the frameworks, concepts and structure of the project, please read: Contribution Guide: Start Coding.
If you are willing to try using make
, ensure you have installed Git, Node.js and CouchDB (steps 1, 2 and 7 above), you may skip the rest. This requires CouchDB in the path to work correctly.
- Run
make serve
, it will start CouchDB, install npm dependencies and start the server. - Run
make all
to run all tests and build the app. - Look into
Makefile
to figure other targets available.
Documented in the project wiki
Q: What is the difference between hospitalrun-frontend and hospitalrun-server?
Frontend is the primary repository and is used for development purposes. Server is the node backend, if you are looking to run HospitalRun in a clinical setting, you should use server.