Skip to content

Instantly share code, notes, and snippets.

@MatthewVita
Last active July 11, 2019 19:28
Show Gist options
  • Save MatthewVita/ea277dd2969f6cf291b481a1fd5eb818 to your computer and use it in GitHub Desktop.
Save MatthewVita/ea277dd2969f6cf291b481a1fd5eb818 to your computer and use it in GitHub Desktop.
OpenEMR Rest API Dev Setup

Hi Sherwin and Daniel,

Sorry for my delayed response on this - I have been very ill. Follow these steps to get the REST API up and running so we can continue with some of the TODO items.

  1. Install Ubuntu on your computer or in a VirtualBox via https://itsfoss.com/install-linux-in-virtualbox/
  2. Install Docker:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"
sudo apt update -y
sudo apt install -y docker-ce
sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo groupadd docker
sudo usermod -aG docker $USER
  1. Setup your SSH key by following https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
  2. run git clone git@github.com:{your up to date fork}/openemr.git # must be your updated openemr fork
  3. run cd openemr
  4. run docker-compose up
  5. Open up Chrome and visit http://localhost:8300/interface/login/login.php?site=default
  6. Login with admin/pass
  7. Go to Administration > Globals > Connectors
  8. Check Enable OpenEMR REST API and click Save
  9. Open up a terminal and execute the following:
curl -X POST -H 'Content-Type: application/json' 'http://localhost:8300/apis/api/auth' \
-d '{
    "grant_type":"password",
    "username": "admin",
    "password": "pass",
    "scope":"default"
}'
  1. Copy the access_token part of the response to your clipboard (for example):
0087041b68035831e2d062d3f65081e76f656d7264656661756c74
  1. Execute the following command (with the correct token, e.x.: 0087041b6803...):
curl -X POST 'http://localhost:8300/apis/api/patient' -d \
'{
    "title": "Mr",
    "fname": "Foo",
    "mname": "",
    "lname": "Bar",
    "street": "456 Tree Lane",
    "postal_code": "08642",
    "city": "FooTown",
    "state": "FL",
    "country_code": "US",
    "phone_contact": "123-456-7890",
    "dob": "1992-02-02",
    "sex": "Male",
    "race": "",
    "ethnicity": ""
}' \
 -H 'Authorization: Bearer 0087041b68035831e2d062d3f65081e76f656d7264656661756c74'
  1. Assuming success, list all patients with the following command:
curl -X GET 'http://localhost:8300/apis/api/patient' -H 'Authorization: Bearer 0087041b68035831e2d062d3f65081e76f656d7264656661756c74'
  1. If correct, "Mr. Foo Bar" patient will be shown.

  2. Reply-all to this email thread once you have reached this point and then we'll talk about how to change the code as well as open tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment