Skip to content

WengLab-InformaticsResearch/cohd_api

Repository files navigation

Columbia Open Health Data API (COHD)

A database of frequencies of clinical concepts observed at Columbia University Medical Center. Over 17,000 clinical concepts and 8.7M pairs of clinical concepts, including conditions, drugs, and procedures are included. The COHD RESTful API allows users to query the database.

Deploy COHD with Docker

Note: For NCATS ITRB, please also see the Translator Application Intake Form

  1. Clone the COHD_API github repository
    git clone https://github.com/WengLab-InformaticsResearch/cohd_api.git/
    cd cohd_api
  2. Edit the MySQL database configuration file with MySQL credentials cohd_api/database.cnf
    Note: Please request MySQL database dump file from @CaseyTa
  3. Change DEV_KEY in cohd_api/cohd/cohd_flask.conf. This key allows certain privileged developer API calls.
  4. [Optional] If necessary, edit the nginx configuration file cohd_api/nginx.conf
  5. Build the COHD docker image
    docker build -t cohd_image .
  6. Run the COHD docker container (the second port mapping to 443 is only necessary if enabling HTTPS)
    docker run -d -p <HOST:PORT>:80 -p <HOST:PORT>:443 --name=cohd cohd_image
  7. [Optional] If necessary, use tools like certbot to enable HTTPS. In the COHD container:
    1. Start a shell to the COHD container
      docker container exec -it cohd bash
    2. Use certbot to generate trusted SSL certificates
      certbot certonly --webroot -w /root/certbot -d <url>
    3. Update the nginx configuration file:
      1. vi /etc/nginx/nginx.conf
      2. Uncomment the ssl server block to listen on port 443
      3. Update the ssl_certificate lines with the correct location of the pubic and private keys
      4. Save and exit
    4. Test and reload the nginx configuration:
      nginx -t
      service nginx reload
  8. [Recommended] Trigger COHD to build the OMOP-Biolink mappings
    curl --request GET 'https://<LOCATION>/api/dev/build_mappings?q=<DEV_KEY_FROM_STEP_3>'

[DEPRECATED] Instructions for manually deploying COHD

The instructions below provide guidance for deploying COHD manually to a linux server.

Requirements

Python 3

Python packages

pip install flask flask_cors flask-caching pymysql requests reasoner_validator numpy scipy semantic_version apscheduler

Running the Application

The COHD API is served using FLASK:

FLASK_APP=cohd.py flask run

Deploying and running COHD on AWS

COHD is served on an AWS EC2 instance using Nginx and uWSGI. For consistency, use the approach in the following blog post: http://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/

Caveats:

  • If using virtualenv, you either have to have the virtualenv directory in the same location as the cohd.py application, or specify the location of the virtualenv using the uWSGI -H parameter.