Using the cityEHR API

Enabling API Access

cityEHR has an Application Programming Interface (API) exposed as a RESTful web service. API For any installation API access can be enabled in the Administration page System | Manage System Parameters by clicking the Edit check box, then checking API Access and pressing Save.

Enabling API access
Enabling API access

With cityEHR accessible on http://localhost:8080/cityehr, the API can be invoked using the URL

http://localhost:8080/cityehr//ehr/api

When the API is disabled, the response (as shown in the Firefox web browser) is a simple statement with guidance on how to enable it.

Disabled API message
Disabled API message

When the API is enabled the response (as shown in the Firefox web browser) provides a summary of the API specification.

Enabled API message
Enabled API message

Each command is shown with an example call, response and a list of its parameters.

API command parameters
API command parameters

There are two styles of API call – either style invokes the same command:

/ehr/api/authenticate/?userId=user&password=secret

or

/ehr/api/?command=authenticate&userId=user&password=secret

Using the cityEHR API

Authenticate and Start a Session

http://localhost:8080/cityehr/ehr/api/authenticate/?userId=admin&password=password

http://localhost:8080/cityehr/ehr/api/authenticate/?userId=admin&password=wrong

  1. Get List of Applications

http://localhost:8080/cityehr/ehr/api/getApplicationList/?userId=admin&sessionId=863fa22fd0253e00333d96bb4417973a

Get Patient Demographics

http://localhost:8080/cityehr/ehr/api/getDemographics/?userId=admin&sessionId=863fa22fd0253e00333d96bb4417973a&applicationId=TSO-13606-EHR_Extract-cityEHR&patientId=K123456789

Get List of Patient Compositions

http://localhost:8080/cityehr/ehr/api/getCompositionList/?userId=admin&sessionId=863fa22fd0253e00333d96bb4417973a&applicationId=TSO-13606-EHR_Extract-cityEHR&patientId=K123456789

Get Patient Composition

/ehr/api/getComposition/?userId=admin&sessionId=863fa22fd0253e00333d96bb4417973a&applicationId=TSO-13606-EHR_Extract-cityEHR&patientId=K123456789&compositionId=2023-10-26T20-52-40.71*01-00-CityEHR-Form-BaseRegistration-admin&mime=application/pdf