Using the m.Care REST API

Endpoints

APIDescription
POST api/v{version}/laboratory/{laboratoryId}/adt

No documentation available.

In order to use the API, you must have previously been assigned an account credentials to LSTMonitor and those credentials must have been given access to a laboratory/department.

The first step is to visit the API Access section on the My Profile page in LSTMonitor to obtain a Client ID, Client Secret and the Authorization Code. You'll use those credentials to request an API access token which must be passed with every request you make to the API server in the authorization header that accompanies the request.

Every request must have the authorization header filled in. If the header is not filled in with an appropriate authorization key, the API will reject the request with an appropriate 401 type server response.

The API key provides you with access to 1 or more department’s worth of data. You may access each department by specifying which department you are interested in on the requests that you make the to endpoint.

The token endpoint accepts two grant types, Code and Refresh. The Code grant type accepts the Authorization Code which is good for one use. Below is a sample request.

              GET /api/v1/token/code/{authorization_code} HTTP/1.1
              Host: clientrest.lstmonitor.com
              Authorization: Bearer {client_id:client_secret (base64 encoded)}
The Authorization Code can only be used once so you need to save the refreshToken from the response each time a token is requested in order to obtain subsequent tokens via the refresh grantType. The refreshToken request is similiar to the authorization code request.
              GET /api/v1/token/refresh/{refreshToken} HTTP/1.1
              Host: clientrest.lstmonitor.com
              Authorization: Bearer {client_id:client_secret (base64 encoded)}
Once you have an accessToken you can pass it in the Authorization header of all other requests. A request to list your laboratories for example would look like:
              GET /api/v1/laboratory HTTP/1.1
              Host: clientrest.lstmonitor.com
              Authorization: Bearer {accessToken}

APIDescription
POST api/v{version}/authorize/{username}/{password}

Request the authorization code needed to obtain an access token through the token/code endpoint.

GET api/v{version}/token/{grantType}/{code}

Obtain an access token using your initial API code (grantType=code) or refresh token (grantType=refresh).

APIDescription
GET api/v{version}/laboratory/{laboratoryId}/dashboard

No documentation available.

Endpoints for managing epidemics

APIDescription
GET api/v{version}/epidemic/CareCenters

Given a person's registration info, sees if they match up with a care center

POST api/v{version}/epidemic/Register

Registers everyone in a registration package and returns results of the registration

APIDescription
GET api/v{version}/laboratory/{laboratoryId}/menu

No documentation available.

APIDescription
GET api/v{version}/laboratory/{laboratoryID}/roles

No documentation available.

APIDescription
GET api/v{version}/nationalLanguages

No documentation available.

APIDescription
GET api/v{version}/roles

No documentation available.

Endpoints for managing Subjects

APIDescription
GET api/v{version}/laboratory/{laboratoryId}/subject?SubjectID={SubjectID}&Mrn={Mrn}&Name={Name}

Gets a list of Subjects belonging to the specified Laboratory.

GET api/v{version}/laboratory/{laboratoryId}/subject/{subjectId}

Gets the specified subject.

POST api/v{version}/laboratory/{laboratoryId}/subject

Insert or Update a subject record

POST api/v{version}/laboratory/{laboratoryId}/subject/enroll-with-template-and-plan

No documentation available.

POST api/Subject?msg={msg}

No documentation available.

Endpoints for managing surveys

APIDescription
GET api/v{version}/laboratory/{laboratoryId}/survey/{surveyId}

Gets a list of Surveys belonging to the specified Laboratory.

GET api/v{version}/laboratory/{laboratoryId}/survey/{surveyId}/question/{surveyQuestionId}

List the available questions for the specified survey

GET api/v{version}/laboratory/{laboratoryId}/survey/{surveyId}/answer?surveyQuestionId={surveyQuestionId}

List the available answers for the specified survey/question.

GET api/v{version}/laboratory/{laboratoryId}/survey/{surveyId}/question/{surveyQuestionId}/answer

List the available answers for the specified survey/question.

GET api/v{version}/laboratory/{laboratoryId}/survey/subdist/{surveyDistributionId}?StartDate={StartDate}&Declined={Declined}&IsNew={IsNew}&InvitationDate={InvitationDate}&Complete={Complete}&CompletionDate={CompletionDate}&ExpectedCompletionDate={ExpectedCompletionDate}&UserProfileID={UserProfileID}&Title={Title}&CompletionDateOption={CompletionDateOption}&DemoSubjectOption={DemoSubjectOption}&SurveyID={SurveyID}&subjectId={subjectId}

Gets a list of SurveyDistributionSubject belonging to the specified Laboratory/Subject.

GET api/v{version}/laboratory/{laboratoryId}/subject/{subjectId}/survey/subdist/{surveyDistributionId}?StartDate={StartDate}&Declined={Declined}&IsNew={IsNew}&InvitationDate={InvitationDate}&Complete={Complete}&CompletionDate={CompletionDate}&ExpectedCompletionDate={ExpectedCompletionDate}&UserProfileID={UserProfileID}&Title={Title}&CompletionDateOption={CompletionDateOption}&DemoSubjectOption={DemoSubjectOption}&SurveyID={SurveyID}

Gets a list of SurveyDistributionSubject belonging to the specified Laboratory/Subject.

GET api/v{version}/laboratory/{laboratoryId}/survey/subdist/{surveyDistributionId}/answer/{subjectSurveyAnswerId}?SurveyID={SurveyID}&SurveyQuestionID={SurveyQuestionID}&SelectedAnswerID={SelectedAnswerID}&AnswerText={AnswerText}&SubjectID={SubjectID}&CreationStartDate={CreationStartDate}&CreationEndDate={CreationEndDate}&DemoSubjectOption={DemoSubjectOption}

List the subject answers for the specified survey distribution.

GET api/v{version}/laboratory/{laboratoryId}/subject/{SubjectID}/survey/subdist/{surveyDistributionId}/answer/{subjectSurveyAnswerId}?SurveyID={SurveyID}&SurveyQuestionID={SurveyQuestionID}&SelectedAnswerID={SelectedAnswerID}&AnswerText={AnswerText}&CreationStartDate={CreationStartDate}&CreationEndDate={CreationEndDate}&DemoSubjectOption={DemoSubjectOption}

List the subject answers for the specified survey distribution.

APIDescription
GET api/v{version}/laboratory/{laboratoryId}/task-type

No documentation available.

Test endpoint

APIDescription
GET api/v{version}/test/authorization

Simple authentication test.

GET api/v{version}/test/anonymous

Simple anonymous access test.

Endpoints for managing Users

APIDescription
GET api/v{version}/laboratory/{laboratoryId}/subject/{subjectId}/timeline

Gets a timeline for the specified subject.

APIDescription
GET api/v{version}/timeZones

No documentation available.

APIDescription
GET api/v{version}/laboratory/{laboratoryId}/userClass

No documentation available.

.NET Example

Imports System.Net
Imports System.IO
Imports System.Runtime.Serialization.Json
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Text

Public Class TestWebAPI
    Private m_WebStream As Stream
    Private m_WebResponse As String = ""
    Private m_Request As HttpWebRequest
    Private m_Response As WebResponse

    Public Function Execute(url As String, httpMethod As String, body As String, ByRef response As String) As Boolean
        Dim res As Boolean = False
        Try
            Dim authHeader As String = "Bearer " + YOUR_API_KEY

            m_Request = WebRequest.Create(url)
            m_Request.Method = httpMethod
            m_Request.Headers.Add("Authorization", authHeader)
            m_Request.Accept = "application/xml"
            m_Response = m_Request.GetResponse()

            Try
                m_WebStream = m_Response.GetResponseStream()
                Try
                    Dim webStreamReader As StreamReader = New StreamReader(m_WebStream)
                    Try
                        ' Pull in any data from the web stream reader
                        While webStreamReader.Peek >= 0
                            m_WebResponse = webStreamReader.ReadToEnd()
                        End While
 
                        ' If any data was received, all is good
                        If m_WebResponse.Trim.Length > 0 Then
                            res = True
                            response = m_WebResponse
                        End If
                    Catch ex As Exception
                        Console.WriteLine(ex.Message)
                    Finally
                        If webStreamReader IsNot Nothing Then
                            webStreamReader.Dispose()
                        End If
                    End Try
                Catch ex As Exception
                    Console.WriteLine(ex.Message)
                Finally
                    If m_WebStream IsNot Nothing Then
                        m_WebStream.Dispose()
                    End If
                End Try
            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try

        Return res
    End Function

    Public Sub TryGettingStream()
        m_WebStream = m_Response.GetResponseStream()
        Try
            Dim webStreamReader As StreamReader = New StreamReader(m_WebStream)
            Try
                ' Pull in any data from the web stream reader
                While webStreamReader.Peek >= 0
                    m_WebResponse = webStreamReader.ReadToEnd()
                End While

                Dim s As String = m_WebResponse
            Finally
                If webStreamReader IsNot Nothing Then
                    webStreamReader.Dispose()
                End If
            End Try
        Finally
            If m_WebStream IsNot Nothing Then
                m_WebStream.Dispose()
            End If
        End Try
    End Sub
End Class