Home Applications QueryResponse Interface Design and Development Guide Based on REST API in HealthConnect

QueryResponse Interface Design and Development Guide Based on REST API in HealthConnect Awaiting Review

InterSystems does not provide technical support for this project. Please contact its developer for the technical assistance.
0
0 reviews
0
Awards
4
Views
0
IPM installs
0
0
Details
Releases (1)
Reviews
Issues
Articles (1)
QueryResponse Interface Design and Development

What's new in this version

Initial Release

QueryResponse Interface Design and Development Guide Based on REST API in HealthConnect

Background:

This guideline provides an overview of how to design and implement a REST API interface for querying patient demographic data from an Electronic Patient Record (EPR) system using HealthConnect. The process involves sending a query request with the patient’s identification number, retrieving the response from the EPR system, extracting the required patient demographic data from the HL7 message, and sending it as a JSON response to the supplier. The high-level process diagram is shown below (Screenshot 1).

🚨 Note: You can modify or add code and other features according to your requirements. This is just a basic guideline I’ve created for quick solutions.

Screenshot 1: A High-Level Message Process Diagram.

High LevelDiagram

πŸ› οΈ Usage Instructions

The step-by-step guideline is provided below:

  1. Setup HealthConnect Management Portal (MP) – Production Configuration (PC).
  2. Custom Code
  3. Using Postman

πŸš€ Step 1: Set Up Web Application

πŸ₯ Step 2: Set Up the REST Service in HealthConnect Management Portal

  1. πŸ”‘ Navigate to Web Application Setup
    Go to: System Administration β†’ Security β†’ Application β†’ Web Application.

  2. βž• Create a New Web Application

    • Click β€œCreate New Web Application”
    • Enter the Name of the application
    • Optionally, provide a Description
    • For Namespace, select the appropriate namespace
  3. ⚑ Enable REST

    • Click on REST to enable the service
    • Enter the Dispatch Class
    • Select β€œUnauthenticated” (password setup will be explained later)
  4. πŸ’Ύ Save Your Configuration

    • Click β€œSave”
    • Refer to Screenshot 2 for an example

πŸ“Έ Screenshot 2: Web Application and Setting Up REST
Web Application

πŸ› οΈ Step 2: Create Required Classes

A. Create Class – GetRequestDatasets

  1. πŸ“‚ Open Cache Studio

    • Select the appropriate namespace (the one you set up previously).
  2. βž• Create a New Class

    • Go to File β†’ New β†’ General β†’ Class Definition β†’ OK.
  3. πŸ“ Enter Class Details

    • Package Name: (your chosen package)
    • Class Name: GetRequestDatasets

πŸ“Έ Screenshot 3: Code for GetRequestDatasets
Web Application

B. Create Response Datasets Class – SetResponseDatasets

⚠️ Note: You can add or remove properties according to your requirements.

  1. βž• Create a New Class

    • Class Name: SetResponseDatasets
  2. πŸ“ Add the Code

    • Write the required code for the class
    • Compile the class

πŸ“Έ Screenshot 4: Code for SetResponseDatasets
Web Application

C. Create Business Process – QueryRequestResponse

  1. βž• Create a New Business Process

    • Name: QueryRequestResponse
  2. πŸ“ Add the Code

    • Write the required code for the business process
    • Compile it

πŸ“Έ Screenshot 5: Code for Business Process – QueryRequestResponse
Web Application

⚠️ Note: "404 Not Found" is just a display message; you can configure this differently if needed.

D. Create Business Service – GetRequest

  1. βž• Create a New Business Service

    • Name: GetRequest
  2. πŸ“ Add the Code

    • Write the required code for the business service
    • Compile it

πŸ“Έ Screenshot 6: Code for Business Service – GetRequest
Web Application

E. Create REST Handler – RestHandler

  1. βž• Create a New REST Handler

    • Name: RestHandler
  2. πŸ“ Add the Code

    • Write the required code for the REST handler
    • Compile it

πŸ“Έ Screenshot 7: Code for RestHandler
Web Application

βœ… Final Layout in Studio

Once all classes, business processes, services, and REST handlers are created and compiled, your Studio should display the following layout:

πŸ“Έ Screenshot 8: Studio Layout of RESTful API

REST API

βš™οΈ Step 3: Set Up Management Portal – Production Configuration

Give the names (services, processes, operations) according to your requirements.

  1. πŸ› οΈ Configure Services

    • Select the appropriate class: ...RESTfulAPI.SERVICES.GetRequest
  2. πŸ”„ Configure Processes

    • Select the appropriate class: ...RESTfulAPI.PROCESS.QueryRequestResponse
  3. ⚑ Configure Operations

    • Select: EnsLib.HL7.Operation.TCPOperation (for EPR System)

⚠️ Note:

  • Go to the service’s settings and select the process name from the dropdown list you defined.

πŸ“Έ Screenshot 9: Management Portal – Production Configuration view

REST API

Finally, we have set up everything. Now, let’s test or evaluate the interface.

πŸ§ͺ Step 4: Testing and Evaluation

If you don’t already have it, download and install Postman to test the REST interface.

πŸ”Ή Test Case 1: Request with a Valid Patient MRN

  1. 🌐 Send a GET Request

    • URL: https://......restapi/Patient?MRN=510800
    • Method: GET
  2. βœ… Verify the Response

    • Check that the returned data matches the patient record for MRN 510800.

πŸ“Έ Screenshot 10: Output of Test Case 1

REST API

πŸ”Ή Test Case 2: Request with a Valid Patient MRN (Alternative URL)

  1. 🌐 Send a GET Request

    • URL: https://......restapi/510800
    • Method: GET
  2. βœ… Verify the Response

    • Ensure the returned data matches the patient record for MRN 510800.

πŸ“Έ Screenshot 11: Output of Test Case 2

REST API

πŸ”Ή Test Case 3: Request with an Invalid Patient MRN

  1. 🌐 Send a GET Request

    • URL: https://......restapi/Patient?MRN=INVALID_MRN
    • Method: GET
  2. ⚠️ Verify the Response

    • The system should return an error message or indicate that no record was found.

πŸ“Έ Screenshot 12: Output of Test Case 3

REST API

πŸ”Ή Test Case 4: Management Portal Services Disabled

  1. ⚠️ Scenario

    • If the services in the Management Portal are disabled, requests to the REST API will not succeed.
  2. 🌐 Send a Request

    • Try sending a GET request to your REST endpoint.
  3. ❌ Expected Output

    • The system will display a message indicating that the services are disabled.

πŸ“Έ Screenshot 13(a): Disabled Services – Output of Test Case 4

REST API

πŸ“Έ Screenshot 13(b): Disabled Services – Additional Output of Test Case 4

REST API

πŸ”Ή Visual Trace of Messages

To better understand the flow of requests and responses, you can view the message visual trace in the Studio.

πŸ“Έ Screenshot 14: Visual Trace

REST API

πŸ“Έ Screenshot 15: Source Message

REST API

πŸ“Έ Screenshot 16: Process Message – Generate Message

REST API

πŸ“Έ Screenshot 17: Response from the EPR System – ADR^A19

REST API

πŸ”’ Password Setup for REST API

This section provides a basic method to set up a username and password for accessing the REST API configured in HealthConnect.

For testing and demonstration purposes, Postman is used.

1. Initial Unauthorized Access

  1. 🌐 Send a Request Without Credentials

    • Attempt to access the REST endpoint using Postman without a username or password.
  2. ❌ Expected Result

    • The system will return an unauthorized error indicating that authentication is required.

πŸ“Έ Screenshot 1: Unauthorized Access

REST API

πŸ‘€ Step 1: Create a Limited-Access User Account

  1. πŸ”‘ Navigate to User Management

    • Go to: System Administrator β†’ Security β†’ Users.
  2. βž• Create a New User

    • Click β€œCreate New User”
    • Enter a Username (e.g., Test)
    • Fill in other details: Name, Comment, etc.
    • Set a Password (e.g., restTest764)
    • Click Save

πŸ“Έ Screenshot 2: Creating a New User

  1. πŸ›‘οΈ Assign Roles
    • Navigate to the Roles section
    • Select the appropriate %DB_… role
    • Click Assign

πŸ“Έ Screenshot 3: Assigning Roles to the User

REST API

πŸ“Έ Screenshot 3: Assigning Roles to the User

REST API

πŸ” Step 2: Verify the User Account

  1. πŸ”’ Log Out from the Management Portal

    • End your current session as the admin user.
  2. πŸ‘€ Log In with the New User

    • Use the username and password you created (e.g., Test / restTest764).
  3. βœ… Verify Access

    • Ensure the user has limited access as per the assigned roles.
    • Confirm the user can only access the intended REST services and no other administrative functions.

REST API

πŸ“Έ Screenshot 4: Limited-Access View for the User

REST API

πŸ” Step 3: Convert Username and Password to BASE64

⚠️ Note:

  • The username and password must match the credentials created in the Management Portal.
  1. 🌐 Go to a Base64 Encoder

  2. πŸ“ Enter the Credentials

    • Format: Username:Password
    • Example: Test:Test123
  3. πŸ“„ Copy the Encoded Value

    • This BASE64 value will be used for authorization in Postman or other REST clients.

πŸ“Έ Screenshot 5: BASE64 Encoding of Username and Password

REST API

πŸ”‘ Step 4: Set Up the Password in Postman

  1. πŸ’» Open Postman

    • Launch Postman on your system.
  2. βš™οΈ Go to the β€œHeaders” Tab

  3. πŸ“ Enter Authorization Header

    • Key: Authorization
    • Value: Basic <your_base64_encoded_value>
  4. πŸ“Έ Reference Screenshot

    • See Screenshot 6 below for guidance.

πŸ“Έ Screenshot 6: Setting Authorization Header in Postman

REST API

πŸ§ͺ Step 5: Test the REST API with Authenticated User

  1. 🌐 Send the Request in Postman

    • Ensure the Authorization header is set with your BASE64 credentials.
    • Use the same endpoint you configured in the Management Portal.
  2. βœ… Verify the Response

    • If everything is set up correctly, the REST API will return a valid response.
  3. πŸ“„ Example Response

    • (This is an example response from a successful request using my setup.)

REST API

🏁 Conclusion: Providing Access to End Users

  1. πŸ”‘ Share the BASE64 Credentials

    • Provide the Base64-encoded username and password to your end users so they can access the REST API.
  2. ⚠️ Security Note

    • This is a basic authentication approach and is not the most secure method.
    • For a more secure authentication approach using JWT / OAuth2.0, refer to this InterSystems Community article: Generate JWT / OAuth2.0 Signature
    • You can read more about JWT in my other article.
  3. πŸ‘ Final Tip

    • Ensure users are aware of their credentials and the limited-access permissions you have set in HealthConnect.

I hope this guide helps you set up and test your REST API successfully!

Version
1.0.022 Feb, 2026
Ideas portal
Category
Solutions
Works with
InterSystems IRIS for HealthHealthShareEnsemble
First published
22 Feb, 2026
Last edited
22 Feb, 2026