Protocol Deviation Digital Healthcare Product
  • INTRODUCTION
    • Purpose
    • Scope
    • Deployment
  • USER GUIDE
    • User Login
    • User Roles and Permissions
      • Administration
        • User Management
        • Team Management
        • Study Management
        • Audit Trail
    • Data Files
      • Data File Requirements
      • Spreadsheets
        • Using the Spreadsheet for AI Categorisation
        • Using the Spreadsheet for Manual Categorisation
    • Data Upload
      • Audit Trail
      • Data Trail
      • Data Categorisation
    • Data Visualisation
      • Team Visualisations
      • Study Visualisations
    • Maintenance and Support
      • Troubleshooting for users
      • Support contact information
  • TECHNICAL DOCUMENTATION
    • Web App
      • Design
        • Database
        • Backend
        • Frontend
      • Installation
    • AI Classifier
      • User documentation
      • Administrator documentation
      • Code documentation
    • Developer Guide
      • Requirements
      • Installation
      • Builds
      • Database
Powered by GitBook
On this page
  • Web API application
  • Scenario i
  • Scenario ii
  • Scenario iii
  • Common errors
  1. TECHNICAL DOCUMENTATION
  2. AI Classifier

User documentation

PreviousAI ClassifierNextAdministrator documentation

Last updated 2 months ago

The Protocol Deviation (PD) Classifier is a system designed to handle requests over a specified server and port. By default, the service starts on the local server's IP address and runs on port 8088. Please contact your local IT support for details about the service.

Web API application


The API supports only the following message

POST request. This request returns a predicted classification for the given text query. The request should be formatted as follows:

  1. For a single query string:

 {"query":"text_to_be_queried"
  "num_predictions":desired_prediction_number}
  1. For multiple query strings:

{"query":["text_to_be_queried_1", "text_to_be_queried_2"], 
  "num_predictions":desired_prediction_number}

Replace "text_to_be_queried" with the desired input text, and "num_predictions" with the desired number of predictions for each query string. The "num_predictions" parameter is optional and defaults to 1, with a maximum limit of 64.

%curl -d '{"query":"something went wrong", 
"num_predictions":desired_prediction_number}' -H "Content-Type: 
application/json" -X POST http://localhost:8088/prediction

Note

Queries should be made to the path /prediction. Requests to a different path or incomplete requests will generate an error response. In this example, localhost and 8088 correspond to the server's IP address and service port, respectively. Please consult your local IT support for more details regarding this information.[!NOTE] Queries should be made to the path /prediction. Requests to a different path or incomplete requests will generate an error response. In this example, localhost and 8088 correspond to the server's IP address and service port, respectively. Please consult your local IT support for more details regarding this information.

The response consists of the following elements:

  1. "dvspondes": Contains the queried text.

  2. "categories": An array that includes the predicted values of "dvcat", along with the corresponding "dvdecod" and the probability or likelihood associated with the provided text.

  3. "dvcat": The predicted category based on the input text.

  4. "dvdecod": The predicted code corresponding to the input text and the "dvcat".

  5. "probability": The assigned probability associated with the combination of dvcat and dvdecod.

  6. "timestamp": The timestamp of the query request.

This response confirms the successful execution of the query. In any other case, an error message will be returned.

Based on the number of parameters, we have four possible scenarios:

i) Multiple query strings with one prediction.

ii) A single query string with multiple predictions.

iii) Multiple query strings with multiple predictions.

All of these responses share a similar structure to that described in the previous section.

Scenario i


Multiple query strings and number of predictions set to one. This scenario considers query of the form:

"query":["text_to_be_queried_1", "text_to_be_queried_2"], and 
"num_prediction" : 1

We should expect the following output:

The response includes the two query strings along with their respective predictions. Number 1 corresponds to the first query string and its predictions, while number 2 follows the same structure.

Scenario ii


A string query with a number of predictions greater than 1. This scenario involves queries of the following form:

"query":"text_to_be_queried_1", and
"num_prediction" : 3

We should expect the following output:

The response includes the one query strings along with three predictions. Number 1 corresponds to the first query string and its predictions, while number 2 and 3 follow the same structure.

Scenario iii


Multiple query strings with a number of predictions greater than 1. This scenario involves queries of the following form:

"query":["text_to_be_queried_1", "text_to_be_queried_2"], and
"num_prediction" : 3

You should expect the following output. Note: only a partial output is displayed:

The response includes two query strings, each accompanied by two predictions. Numbers 1 and 2 correspond to the first and second predictions for the first query string, while numbers 3 and 4 correspond to the first and second predictions for the second query string.

Common errors


  1. JSON query format.

This issue might occur if the query isn’t formatted correctly, such as when a comma or quotation mark is missing. In such cases, the application will return the following response:

mark is missing. In such cases, the application will return the following response:

Number 1 identifies the type of error we’re dealing with, while Number 2 offers more detail about

the error. In this case, the message indicates that a delimiter, specifically a comma, was expected.

  1. Invalid parameter.

This error occurs when you provide a parameter that is outside the range defined by the system.

The message might look like this:

The error message (number 1) indicates that one of the arguments is out of range. Additionally, the

system states that it could not process the request.

  1. Server Unavailable. If the server is down, you may encounter the following error:

This indicates that the connection to the server on the specified port did not respond. In this case,

it’s recommended to check if the system is running.

  1. Incorrect URL Path

If the URL path is incorrect, you will receive the following message because the system could not

locate the requested service.

  1. Incorrect Event

If the request is not properly selected, you may have chosen an event other than "POST":

You will receive the following message:

This message means that the selected event is not supported.

The previous text should be incorporated into an API client, such as a custom application or an operating system command like . The following example demonstrates usage with curl:

In this example, "text_to_be_queried" is replaced with "something went wrong", and "num_predictions" is omitted, so the number of predictions defaults to 1. This query returns a response in the following format:

curl
JSON
microservice