Receive device data through Azure IoT Hub

Important

As of September 2022, the IoT Connector feature within Azure API for FHIR will be retired and replaced with the MedTech service for enhanced service quality and functionality.

All new users are directed to deploy and use the MedTech service feature within the Azure Health Data Services. For more information about the MedTech service, see What is the MedTech service?.

Azure IoT Connector for Fast Healthcare Interoperability Resources (FHIR®)* provides you the capability to ingest data from Internet of Medical Things (IoMT) devices into Azure API for FHIR. The Deploy Azure IoT Connector for FHIR (preview) using Azure portal quickstart showed an example of device managed by Azure IoT Central sending telemetry to Azure IoT Connector for FHIR. Azure IoT Connector for FHIR can also work with devices provisioned and managed through Azure IoT Hub. This tutorial provides the procedure to connect and route device data from Azure IoT Hub to Azure IoT Connector for FHIR.

Prerequisites

Tip

If you are using an Azure IoT Hub simulated device application, feel free to pick the application of your choice amongst different supported languages and systems.

Get connection string for Azure IoT Connector for FHIR (preview)

Azure IoT Hub requires a connection string to securely connect with your Azure IoT Connector for FHIR. Create a new connection string for your Azure IoT Connector for FHIR as described in Generate a connection string. Preserve this connection string to be used in the next step.

Azure IoT Connector for FHIR uses an Azure Event Hub instance under the hood to receive device messages. The connection string created above is basically the connection string to this underlying Event Hub.

Connect Azure IoT Hub with the Azure IoT Connector for FHIR (preview)

Azure IoT Hub supports a feature called message routing that provides capability to send device data to various Azure services like Event Hub, Storage Account, and Service Bus. Azure IoT Connector for FHIR uses this feature to connect and send device data from Azure IoT Hub to its Event Hub endpoint.

Note

At this time you can only use PowerShell or CLI command to create message routing because Azure IoT Connector for FHIR's Event Hub is not hosted on the customer subscription, hence it won't be visible to you through the Azure portal. Though, once the message route objects are added using PowerShell or CLI, they are visible on the Azure portal and can be managed from there.

Setting up a message routing consists of two steps.

Add an endpoint

This step defines an endpoint to which the IoT Hub would route the data. Create this endpoint using either Add-AzIotHubRoutingEndpoint PowerShell command or az iot hub routing-endpoint create CLI command, based on your preference.

Here's the list of parameters to use with the command to create an endpoint:

PowerShell Parameter CLI Parameter Description
ResourceGroupName resource-group Resource group name of your IoT Hub resource.
Name hub-name Name of your IoT Hub resource.
EndpointName endpoint-name Use a name that you would like to assign to the endpoint being created.
EndpointType endpoint-type Type of endpoint that IoT Hub needs to connect with. Use literal value of "EventHub" for PowerShell and "eventhub" for CLI.
EndpointResourceGroup endpoint-resource-group Resource group name for your Azure IoT Connector for the FHIR Azure API for FHIR resource. You can get this value from the Overview page of Azure API for FHIR.
EndpointSubscriptionId endpoint-subscription-id Subscription ID for your Azure IoT Connector for the FHIR Azure API for FHIR resource. You can get this value from the Overview page of Azure API for FHIR.
ConnectionString connection-string Connection string to your Azure IoT Connector for FHIR. Use the value you obtained in the previous step.

Add a message route

This step defines a message route using the endpoint created above. Create a route using either Add-AzIotHubRoute PowerShell command or az iot hub route create CLI command, based on your preference.

Here's the list of parameters to use with the command to add a message route:

PowerShell Parameter CLI Parameter Description
ResourceGroupName g Resource group name of your IoT Hub resource.
Name hub-name Name of your IoT Hub resource.
EndpointName endpoint-name Name of the endpoint you've created above.
RouteName route-name A name you want to assign to message route being created.
Source source-type Type of data to send to the endpoint. Use literal value of "DeviceMessages" for PowerShell and "devicemessages" for CLI.

Send device message to IoT Hub

Use your device (real or simulated) to send the sample heart rate message shown below to Azure IoT Hub. This message will get routed to Azure IoT Connector for FHIR, where the message will be transformed into a FHIR Observation resource and stored into the Azure API for FHIR.

{
  "HeartRate": 80,
  "RespiratoryRate": 12,
  "HeartRateVariability": 64,
  "BodyTemperature": 99.08839032397609,
  "BloodPressure": {
    "Systolic": 23,
    "Diastolic": 34
  },
  "Activity": "walking"
}

Important

Make sure to send the device message that conforms to the mapping templates configured with your Azure IoT Connector for FHIR.

View device data in Azure API for FHIR

You can view the FHIR Observation resource(s) created by Azure IoT Connector for FHIR using Postman. For more information, see Access the FHIR service using Postman, and make a GET request to https://your-fhir-server-url/Observation?code=http://loinc.org|8867-4 to view Observation FHIR resources with the heart rate value submitted in the above sample message.

Tip

Ensure that your user has appropriate access to Azure API for FHIR data plane. Use Azure role-based access control (Azure RBAC) to assign required data plane roles.

Next steps

In this quickstart guide, you set up Azure IoT Hub to route device data to Azure IoT Connector for FHIR. Select from below next steps to learn more about Azure IoT Connector for FHIR:

Understand different stages of data flow within Azure IoT Connector for FHIR.

Learn how to configure IoT Connector using device and FHIR mapping templates.

*In the Azure portal, Azure IoT Connector for FHIR is referred to as IoT Connector (preview). FHIR® is a registered trademark of HL7 and is used with the permission of HL7.