Skip to content

This is a service accessed through APIs. Data got from APIs is stored in mysql ass well as couch db. Couch Db for transportation. Mysql for querying. This Service requires aunthentiation inorder to access the service resources

License

Notifications You must be signed in to change notification settings

BaobabHealthTrust/nlims_controller

Repository files navigation

GitHub issues GitHub forks GitHub stars GitHub license

Brief description

NLims Controller is a Laboratory Information Management Systems' (LIMS) service which communicates with Eletronic Medical Record System (EMRS). It is used to exhange lab orders between these two systems. This README documents steps that are necessary to get the service up and running.

Requirements

  • ruby ~> 2.5.3
  • bundler ~> 2.1.4
  • rails ~> 5.1.7
  • Mysql ~> 5.7
  • Couchdb ~> 3.1.0

Configuration

  1. Rename .example files in config.

    From the commandline, moved into config directory then rename all files with .example by removing the .example extension from then.

    Here is the command:

    cd config
    cp database.yml.example database.yml
    cp application.yml.example application.yml
    cp couchdb.yml.example couchdb.yml
    cp secrets.yml.example secrets.yml
  2. Configure your facility.

    Using your text editor open application.yml in config and provide district, facility_name and facility_code. Thus, your application.yml should look like this

    district: "Lilongwe"
    facility_name: "Kamuzu Central Hospital"
    facility_code: 'KCH'
    
  3. Configure your database.

    While still in config folder, provide details of your mysql database in database.yml and couchdb in couchdb.yml respectively.

    For database.yml, replace username with the username of your mysql and password with the password of your mysql.

    Here is the example:

    default: &default
          adapter: mysql2
          encoding: utf8
          pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
          username: your_username
          password: your_password
          socket: /var/run/mysqld/mysqld.sock
    .
    .
    .
    development:
          <<: *default
          database: lims_db
    test:
          <<: *default
          database: lims_test
    .
    .
    .
    production:
          <<: *default
          database: nlims_production
          username: your_username
          password: <%= ENV['NLIMS_DATABASE_PASSWORD'] %>

    In couchdb, provide details of your couchdb including protocol (whether http or https), port (normally runs on 5984, but can be replaced with your couchdb port), host, database name in form of prefix and suffix (for example, if your database name is "lims_database" then your prefix will be "lims" and "database" will be your suffix, but if your database is just "lims" then "lims" will be your prefix and no suffix), username and password.

    Here is an example of how your couchdb.yml will be:

    development: &development
          protocol: 'http'
          host: your_host
          port: 5984
          prefix: nlims
          suffix: repo
          username: your_username
          password: your_password
     
    test:
          <<: *development
          suffix: test
           production:
          <<: *development
          protocol: 'http'

Installation

Install ruby gems by running the following command:

bundle install

Initiate database by running this command;

rails db:create
rails db:migrate
rails db:seed

NB: Database initialization is completed by a service called nlims_data_syncroniser. This service is used to sync data between two sites using couchdb.

Development

To run the application in development server, type the following in commandline:

rails s -p 3010

Or using a passenger

passenger start -p 3010

Test

Production

To deploy the application in production you can either use nginx or apache2 servers. Nginx is recommended since it has been tested and approved by our deployment team.

  1. Initialize database

    To initialize database for development, in the database.yml folder in production block, provide the name of the database and the username. In your commandline type the following (replacing your_password with your actual password of mysql database):

    export NLIMS_DATABASE_PASSWORD='your_password'
    

    Then run the following commands to create, migrate and seed data into your database:

    rails db:create RAILS_ENV=production
    rails db:migrate RAILS_ENV=production
    rails db:seed RAILS_ENV=production
  2. Deploy

How to use

  1. Retrieve target labs.

    The following endpont is used to get a list of target labs from LIMS:

    Method: GET
    URL: http://your_host:3010/api/v1/retrieve_target_labs
    
  2. Order tests

    The following endpoint is used to order tests in LIMS:

    Method: POST
    URL: http://your_host:3010/api/v1/create_order
    Payload: {
          "district"=>"Lilongwe",
          "health_facility_name"=>"Ntchisi District Hospital",
          "first_name"=>"Ted",
          "last_name"=>"Talk",
          "middle_name"=>"",
          "date_of_birth"=>"1994-05-15",
          "gender"=>"M",
          "national_patient_id"=>"P158602329249",
          "phone_number"=>"", 
          "who_order_test_last_name"=>"User", 
          "who_order_test_first_name"=>"Super", 
          "who_order_test_id"=>"1", 
          "order_location"=>"TB", 
          "date_sample_drawn"=>"2020-05-15T14:55:33.000+02:00", 
          "tests"=>["TB"], 
          "sample_priority"=>"Diagnosis", 
          "art_start_date"=>"not_applicable", 
          "sample_type"=>"Sputum", 
          "sample_status"=>"specimen_not_collected", 
          "target_lab"=>"Kamuzu Central Hospital", 
          "recommended_examination"=>nil, 
          "treatment_history"=>nil, 
          "sample_date"=>"2020-05-15", 
          "sending_facility"=>"Ntchisi District Hospital", 
          "time_line"=>"NA", 
          "requesting_clinician"=>"admin"
      }
    

Contribution

We are very much willing to have your contributions. Contact BHT software development team @ [email protected] for such arrangements.

Issues

Issues with the system can be logged on directy here on git. You can also contact BHT software support team @ [email protected].

License

MPL-2.0

About

This is a service accessed through APIs. Data got from APIs is stored in mysql ass well as couch db. Couch Db for transportation. Mysql for querying. This Service requires aunthentiation inorder to access the service resources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published