Skip to content

The main Repository for both the API and Client source of the Malawi Master Health Facility Register

Notifications You must be signed in to change notification settings

BaobabHealthTrust/master-facility-list

Repository files navigation

Master Health Facility Register

At its very core, the MFL is a comprehensive database of all the Health Facilities in the country (Malawi). From Private Hospitals to Village Clinics, the system keeps track of resources, utilities and services available in each one of these facilities just to mention a few.

This project is the first deliverable under the Kuunika Data For Action Initiative and aims at serving the general users, District Health Officers and any other stakeholders in the Malawi Healthcare Sector. Additionally, the facilities and their information will be available via a REST API for other services and systems to consume, such as Baoabab Health Trust Electronic Management Record Systems (EMRs) or the District Health Information System (DHIS).

Dependancies

Setup

The project is generated by LoopBack, a rapid API development framework. For more information, see the Loopback documentation. There is a client directory that has a create-react-app setup from which the User Interface will be built. The idea is to build static files from create-react-app into the client folder so that the API and front-end can run on the same node server.

Installation

Step 1 clone

Clone this repository into your local directory, Use the command below:

# Clone project to a computer
git clone https://github.com/BaobabHealthTrust/master-facility-list

# Navigate to the project root directory
cd master-facility-list

Step 2 dependancies

Install all the dependancies for the main (backend project).

# install backend dependancies
npm install

setup front-end dependancies

set up the frontend dependancies by following the commands bellow:

# navigate to the frontend directory
cd client

# install frontend dependancies
npm install

NOTE: use sudo npm install if you have permission issues. This applies to both the backend and the frontend.

Step 3 tests

Run the tests and make sure they are all passing:

# Run tests
npm test

If they are not passing, please check whether your environment has all the dependancies installed correctly.

Step 4 database

Create a schema in mysql database called mflApi:

# connect to mysql database
# replace 'user' with your mysql user name in the command bellow
mysql -u user -p

# enter the specified user password in the prompt

# create the database
mysql> CREATE DATABASE mflApi;


# exist from mysql
mysql> \q

Create a .env file with the contents of your .env.example file.

# copy the .env.example to .env file
cp .env.example .env

Modify the .env file and make sure it reflects your MySQL Database Settings. Furthermore, set the port and the host of the server in the same file .env

Change NODE environment in the .env. Set the environment to staging, testing or production. This notifies loopback the environment you are running. In the .env file, set NODE_ENV=staging

Run the database migration by install a loopback-migration-tool, i.e npm i -g loopback-migration-tool followed by running the migration., i.e lb-migration migrate.

# set node environment to staging
export NODE_ENV=staging

# install the migration tool
sudo npm i -g loopback-migration-tool

# run the migration
lb-migration migrate

Step 5 User

Run node seed.js to generate an admin user.

# create admin user.
node seed.js

Step 6 run backend server

Once the admin user has been generated, you are now ready to start the backend server by running node .

# run the master facility server
node .

Step 7 frontend server settings

# navigate to frontend directory.
cd client

# copy the .env.example to .env file
cp .env.example .env

# Modify .env file in the terminal or text editor
# Set the REACT_APP_API_URL in .env file to the url of the backend server `192.168.12.252:3000/api`.

Step 8 run frontend server

You are now ready to start the front end application as follows, npm start (while in client directory)

# start frontend server
npm start

Contribution

Once you have followed the installation step, you are ready to contribute to the source code. When working on the API, you will mostly use the Loopback Model Generator, as well as make changes to files in common/models.  When working on the Front-end, you will be modifying files in client. Make sure to add tests for every generated model, covering the major enpoints and relationships that will be hit via the API. From the root, running npm start will start the API on port 3000. Tests are not mandatory for the React Project, but highly encouraged.

Reporting Issues

If you have noticed a bug, you can open an issue in github web and attempt to fix (see below), otherwise we will do our best to look at it.

Fixing Issues

From the issue list, you can select an issue, and create a branch in your local directory describing the issue you are fixing. Once the issue is fixed and all the tests are running, you can publish your local branch to the repository. From there, you may open a pull request describing how you have solved the issue. Remember to explicity say which issue number it solves, i.e. "solves issue #41" so that the issue is automatically closed upon merge

Adding Features

If you have any features to add, please follow the instructions in the previous step to create a new feature branch and publish it to the remote repository upon completion of the feature. Every additional feature on the backend must have tests to go along with it.

Enjoy, and feel free to contact jeremiahchienda@baobabhealth.org

About

The main Repository for both the API and Client source of the Malawi Master Health Facility Register

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published