Giter VIP home page Giter VIP logo

marlonecunha / medic-webapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from medic/cht-core

1.0 1.0 0.0 61.19 MB

Medic Mobile combines SMS messaging, data collection, and analytics for health workers and health systems in hard-to-reach areas with or without internet connectivity.

Home Page: http://medicmobile.org/tools

License: GNU Affero General Public License v3.0

JavaScript 92.80% CSS 2.01% HTML 4.60% Shell 0.60%

medic-webapp's Introduction

Medic Mobile

These instructions should help you get setup to run or develop on Medic Mobile. For latest changes and release announcements see our change log.

Overview

Medic Mobile combines messaging, data collection, and analytics for health workers and health systems in hard-to-reach areas with or without internet connectivity.

The medic-webapp repository is the core tool of the Medic Mobile stack. When health workers submit data โ€” using text messages (SMS), our mobile applications, or our SIM applications โ€” the web app confirms data submission, generates unique IDs, and schedules automated reminder messages based on user-defined configurations. All information submitted by mobile users can be viewed, filtered, verified, and exported using the reports tab in the web application.

The web app is fully responsive with a mobile-first design, and supports localization using any written language. It can be installed locally, as part of a virtual machine (see medic-os), or in the cloud.

Currently, we functionally support the latest versions of Chrome, Chrome for Android and Firefox. We do not support Safari (unreliable implementations of web APIs we need) and the generic android browser (unreliable implementations in general). Our webapp code, which includes any code written as configuration, is still ES5. Our exact support matrix (including older app versions) can be found in our docs.

For more information about Medic Mobile's tools, visit http://medicmobile.org/tools. For more information about Medic Mobile's architecture and how the pieces fit together, see Architecture Overview. For more information about the format of docs in the database, see Database Schema. For more information about the SMS exchange protocol between webapp and gateway, see Message States.

Easy local deployment

If you want to get up and running with no fuss, you can use Horticulturalist.

If you want to use our standard configuration, you can use the Medic Project Configurer in the ./config/standard directory once Horticuluralist has successfully started.

If you want to develop against Medic, follow the Development Setup below.

Development Setup

Before getting started, read about our development workflow and the architecture overview.

The setup described below doesn't use Medic OS, the tools will be run directly on your machine.

Dependencies

You will need to install the following:

Node.js 8.11.x and above

npm 6.x.x and above (to support npm ci)

CouchDB v2.x

Setup CouchDB on a single node

NB: multiple CouchDB nodes will be more complicated, but the general pattern outlined below will be the same.

Enabling a secure CouchDB

By default CouchDB runs in "admin party" mode, which means you do not need users to read or edit any data. This is great for some, but to use Medic safely we're going to disable this feature.

First, add an admin user. When prompted to create an admin during installation, use a strong username and password. Passwords can be changed via Fauxton. For more information see the CouchDB install doc.

Now that's done, we must configure some security settings on CouchDB:

COUCH_URL=http://myAdminUser:myAdminPass@localhost:5984/medic
[email protected]
grunt secure-couchdb

After following these steps CouchDB should no longer allow unauthorised access:

curl http://myAdminUser:myAdminPass@localhost:5984 # should work
{"couchdb":"Welcome","version":"2.0.0","vendor":{"name":"The Apache Software Foundation"}}
curl http://localhost:5984 # should fail
{"error":"unauthorized","reason":"Authentication required."}

To be able to use Fauxton with authenticated users:

curl -X PUT http://myAdminUser:myAdminPass@localhost:5986/_config/httpd/WWW-Authenticate \
  -d '"Basic realm=\"administrator\""' -H "Content-Type: application/json"

Build and run

Build the webapp

git clone https://github.com/medic/medic-webapp
cd medic-webapp
npm ci

Deploy all the apps

Create a .env file in the app directory with the following contents

COUCH_URL=http://myAdminUser:myAdminPass@localhost:5984/medic
COUCH_NODE_NAME=couchdb@localhost

Then do an initial deploy of the webapp:

grunt dev-webapp
# or just
grunt

Once this is complete you can close it, and from now on you can just run:

npm start

which will start the webapp, api, and sentinel, and watch for changes in each app.

Deploy apps individually

If npm start is not to your taste for whatever reason, the apps can be deployed individually.

Deploy the webapp

grunt dev-webapp will build and deploy the webapp, then watch for changes and redeploy when necessary.

Start medic-sentinel

cd sentinel
npm ci
export COUCH_NODE_NAME=couchdb@localhost
export COUCH_URL=http://myAdminUser:myAdminPass@localhost:5984/medic

Then run either node ./server.js from the sentinel directory or grunt dev-sentinel from the repository directory (which will watch for changes).

Start medic-api

cd api
npm ci
export COUCH_NODE_NAME=couchdb@localhost
export COUCH_URL=http://myAdminUser:myAdminPass@localhost:5984/medic

Then run either node ./server.js from the api directory or grunt dev-api from the repository directory (which will watch for changes).

Try it out

Navigate your browser to http://localhost:5988/medic/login.

Data

To fill your app with generated data, you can batch-load messages from a CSV file, with the load_messages.js script.

Use curl to submit a single message:

curl -i -u gateway:123qwe \
    --data-urlencode 'message=Test One two' \
    --data-urlencode 'from=+13125551212' \
    --data-urlencode 'sent_timestamp=1403965605868' \
    -X POST \
    http://localhost:5988/api/v1/records

Localization

All text labels in the app are localized. See the translation documentation for more details on how to add new labels or modify existing ones.

Tests

Check out the Gruntfile for all the tests you can run.

Unit tests

They live in the tests directories of each app. Run them with grunt: grunt unit-continuous.

End to End tests

They live in tests. To run them:

  1. Update and start Webdriver: npm run webdriver
  2. Run tests: grunt e2e

API integration tests

grunt api-e2e

Integration tests

Travis runs grunt ci every time some new code is pushed to github.

Other deployment steps

Deploy locally using Horticulturalist (beta)

Horticulturalist is an easy way to deploy Medic locally if you're not going to be developing against it.

Horti is currently in beta, and will eventually replace the Market, Gardener and Dashboard as our standard way to deploy and manage our software.

To use it locally:

  • Install, configure and secure CouchDB
  • Install npm
  • Install Horticulturalist with npm install -g horticulturalist

Now use the horti tool to bootstrap Medic and launch it:

COUCH_NODE_NAME=couchdb@localhost COUCH_URL=http://myAdminUser:myAdminPass@localhost:5984/medic horti --local --bootstrap

This will download, configure and install the latest Master build of medic. If you're looking to deploy a specific version, provide it to the bootstrap command:

COUCH_NODE_NAME=couchdb@localhost COUCH_URL=http://myAdminUser:myAdminPass@localhost:5984/medic horti --local --bootstrap=3.0.0-beta.1

To kill Horti hit CTRL+C. To start Horti (and Medic) again, run the same command as above, but this time don't bootstrap:

COUCH_NODE_NAME=couchdb@localhost COUCH_URL=http://myAdminUser:myAdminPass@localhost:5984/medic horti --local

If you wish to change the version of Medic installed, you can either bootstrap again, or use the Instance Upgrade configuration screen.'

NB: Horticulturalist doesn't wipe your database when it bootstraps, it just installs the provided version (or master) over whatever you already have. To completely start again, stop Horti and delete the medic database, either using Futon / Fauxton, or from the command line:

curl -X DELETE $COUCH_URL

Configuring Medic

We ship with one "standard" configuration, which can be a useful basis to start with. It is located at ./config/standard.

Configuration is performed using Medic Configurer. medic-conf expects a particular structure (seen in the standard config above). It compiles forms and configuration into the required formats, as well as uploading that configuration and performing other tasks.

To import the standard configuration:

  1. Install medic-conf: npm install -g medic-conf
  2. Navigate to the configuration you want to import: cd config/standard
  3. Import the config: medic-conf --url http://username:password@localhost:5984

Automated Deployment on Travis

Code is automatically published via Travis CI to the staging server.

Help

Join our Google Group or file an issue on Github. You can also post questions, and look for answers, on our AnswerHub site.

Contributing

At Medic Mobile we welcome and appreciate community contributions. If you have an idea or a question we'd love to hear from you! The easiest ways to get in touch are by raising issues in the medic-webapp Github repo or by messaging our Google Group. For more info check out our contributor guidelines.

Build Status

Builds brought to you courtesy of Travis CI.

Build Status

Copyright

Copyright 2013-2018 Medic Mobile, Inc. [email protected]

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

medic-webapp's People

Contributors

abbyad avatar alxndrsn avatar bedengaruko avatar browndav avatar catherinewong avatar dianabarsan avatar eljhkrr avatar endor avatar estellecomment avatar garethbowen avatar henokgetachew avatar igorprotsenko avatar igorprotsenkood avatar jodge avatar kennsippell avatar mandric avatar medic-translators avatar michaelkohn avatar mkwiatkowski avatar newtewt avatar ngaruko avatar ochiengpeter avatar puertea avatar rmhowe avatar ryanramage avatar scdf avatar tookam avatar vimago avatar vimemo avatar wombleton avatar

Stargazers

 avatar

Watchers

 avatar

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.