Skip to content

Commit 6e2accc

Browse files
authored
Merge pull request #240390 from msjasteppe/iotjsonpathcontent-updates
Major updates to IotJsonPathContent article
2 parents bc22188 + 2a7eac7 commit 6e2accc

File tree

3 files changed

+158
-255
lines changed

3 files changed

+158
-255
lines changed

articles/healthcare-apis/iot/device-messages-through-iot-hub.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ When deployment is completed, the following resources and access roles are creat
124124

125125
* **Azure Event Hubs Data Sender** role. In this deployment, the sender role is named *devicedatasender* and can be used to provide access to the event hub using a shared access signature (SAS). To learn more about authorizing access using a SAS, see [Authorizing access to Event Hubs resources using Shared Access Signatures](../../event-hubs/authorize-access-shared-access-signature.md). The **Azure Event Hubs Data Sender** role isn't used in this tutorial.
126126

127-
* IoT hub with [message routing](../../iot-hub/iot-hub-devguide-messages-d2c.md) configured to send device messages to the event hub.
127+
* IoT hub with [message routing](../../iot-hub/iot-hub-devguide-messages-d2c.md) configured to route device messages to the event hub.
128128

129129
* [User-assigned managed identity](../../active-directory/managed-identities-azure-resources/overview.md), which provides send access from the IoT hub to the event hub. The managed identity has the **Azure Event Hubs Data Sender** role in the [Access control section (IAM)](../../role-based-access-control/overview.md) of the event hub.
130130

@@ -211,7 +211,7 @@ You complete the steps by using Visual Studio Code with the Azure IoT Hub extens
211211
After you select **Send**, it might take up to five minutes for the FHIR resources to be available in the FHIR service.
212212

213213
> [!IMPORTANT]
214-
> To avoid device spoofing in device-to-cloud (D2C) messages, Azure IoT Hub enriches all device messages with additional properties before sending it to the MedTech service device event hub. For example: **Properties**: `iothub-creation-time-utc` and **SystemProperties**: `iothub-connection-device-id`. For more information, see [Anti-spoofing properties](../../iot-hub/iot-hub-devguide-messages-construct.md#anti-spoofing-properties) and [How to use IotJsonPathContent mappings](how-to-use-iot-jsonpath-content-mappings.md).
214+
> To avoid device spoofing in device-to-cloud (D2C) messages, Azure IoT Hub enriches all device messages with additional properties before routing them to the event hub. For example: **Properties**: `iothub-creation-time-utc` and **SystemProperties**: `iothub-connection-device-id`. For more information, see [Anti-spoofing properties](../../iot-hub/iot-hub-devguide-messages-construct.md#anti-spoofing-properties) and [How to use IotJsonPathContent templates with the MedTech service device mapping](how-to-use-iotjsonpathcontent-templates.md).
215215
>
216216
> You do not want to send this example device message to your IoT hub as the enrichments will be duplicated by the IoT hub and cause an error with your MedTech service. This is only an example of how your device messages are enriched by the IoT hub.
217217
>

articles/healthcare-apis/iot/how-to-use-calculatedcontent-templates.md

Lines changed: 62 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: msjasteppe
55
ms.service: healthcare-apis
66
ms.subservice: fhir
77
ms.topic: how-to
8-
ms.date: 06/07/2023
8+
ms.date: 07/20/2023
99
ms.author: jasteppe
1010
---
1111

@@ -48,8 +48,8 @@ In the following example, `typeMatchExpression` is defined as:
4848

4949
The CalculatedContent templates allow matching on and extracting values from a device message read from an Azure Event Hubs event hub through the following expressions:
5050

51-
|Element|Description|JSONPath expression|JMESPath expression|
52-
|:------|:----------|:------------------|:------------------|
51+
|Element|Description|JSONPath expression example|JMESPath expression example|
52+
|:------|:----------|:--------------------------|:--------------------------|
5353
|typeMatchExpression|The expression that the MedTech service evaluates against the device message payload. If the service finds a matching token value, it considers the template a match. The service evaluates all later expressions against the extracted token value matched here.|`$..[?(@heartRate)]`|``[Body][?contains(keys(@), `heartRate`)] \| @[0]``|
5454
|deviceIdExpression|The expression to extract the device identifier.|`$.matchedToken.deviceId`|`@.matchedToken.deviceId`|
5555
|timestampExpression|The expression to extract the timestamp value for the measurement's `OccurrenceTimeUtc` value.|`$.matchedToken.endDate`|`@.matchedToken.endDate`|
@@ -58,6 +58,9 @@ The CalculatedContent templates allow matching on and extracting values from a d
5858
|correlationIdExpression|*Optional*: The expression to extract the correlation identifier. You can use this output to group values into a single observation in the FHIR destination mapping.|`$.matchedToken.correlationId`|`@.matchedToken.correlationId`|
5959
|values[].valueExpression|The expression to extract the wanted value.|`$.matchedToken.heartRate`|`@.matchedToken.heartRate`|
6060

61+
> [!NOTE]
62+
> The **Resolution type** specifies how the MedTech service associates device data with Device resources and Patient resources. The MedTech service reads Device and Patient resources from the FHIR service using [device identifiers](https://www.hl7.org/fhir/r4/device-definitions.html#Device.identifier) and [patient identifiers](https://www.hl7.org/fhir/r4/patient-definitions.html#Patient.identifier). If an [encounter identifier](https://hl7.org/fhir/r4/encounter-definitions.html#Encounter.identifier) is specified and extracted from the device data payload, it's linked to the observation if an encounter exists on the FHIR service with that identifier. If the [encounter identifier](../../healthcare-apis/release-notes.md#medtech-service) is successfully normalized, but no FHIR Encounter exists with that encounter identifier, a **FhirResourceNotFound** exception is thrown. For more information on configuring the MedTech service **Resolution type**, see [Configure the Destination tab](deploy-manual-portal.md#configure-the-destination-tab).
63+
6164
## Expression languages
6265

6366
When you're specifying the language to use for the expression, the following values are valid:
@@ -67,7 +70,7 @@ When you're specifying the language to use for the expression, the following val
6770
| JSONPath | `JsonPath` |
6871
| JMESPath | `JmesPath` |
6972

70-
Because JSONPath is the default expression language, it's not required to include the expression language within a CalculatedContent template:
73+
Because JSONPath is the default expression language, it's not required to include the expression language within a CalculatedContent template.
7174

7275
```json
7376
"templateType": "CalculatedContent",
@@ -110,49 +113,50 @@ In this example, we're using a device message that is capturing `heartRate` data
110113

111114
```json
112115
{
113-
"heartRate": "78",
114-
"endDate": "2023-03-13T22:46:01.8750000",
115-
"deviceId": "device01"
116+
"heartRate": "78",
117+
"endDate": "2023-03-13T22:46:01.8750000",
118+
"deviceId": "device01"
116119
}
117120
```
118121

119122
The event hub enriches the device message before the MedTech service reads the device message from the event hub:
120123

121124
```json
122125
{
123-
"Body": {
124-
"heartRate": "78",
125-
"endDate": "2023-03-13T22:46:01.8750000",
126-
"deviceId": "device01"
127-
}
126+
"Body": {
127+
"heartRate": "78",
128+
"endDate": "2023-03-13T22:46:01.8750000",
129+
"deviceId": "device01"
130+
}
128131
}
129132
```
130133

131134
We're using this device mapping for the normalization stage:
132135

133136
```json
134137
{
135-
"templateType": "CollectionContent",
136-
"template": [
137-
{
138-
"templateType": "CalculatedContent",
139-
"template": {
140-
"typeName": "heartrate",
141-
"typeMatchExpression": "$..[?(@heartRate)]",
142-
"deviceIdExpression": "$.matchedToken.deviceId",
143-
"timestampExpression": "$.matchedToken.endDate",
144-
"values": [
145-
{
146-
"required": true,
147-
"valueExpression": "$.matchedToken.heartRate",
148-
"valueName": "hr"
149-
}
150-
]
151-
}
152-
}
153-
]
138+
"templateType": "CollectionContent",
139+
"template": [
140+
{
141+
"templateType": "CalculatedContent",
142+
"template": {
143+
"typeName": "heartrate",
144+
"typeMatchExpression": "$..[?(@heartRate)]",
145+
"deviceIdExpression": "$.matchedToken.deviceId",
146+
"timestampExpression": "$.matchedToken.endDate",
147+
"values": [
148+
{
149+
"required": true,
150+
"valueExpression": "$.matchedToken.heartRate",
151+
"valueName": "hr"
152+
}
153+
]
154+
}
155+
}
156+
]
154157
}
155158
```
159+
156160
> [!IMPORTANT]
157161
> The MedTech service evaluates `typeMatchExpression` against the incoming device data payload. If the service finds a matching token value, it considers the template a match.
158162
>
@@ -162,34 +166,34 @@ We're using this device mapping for the normalization stage:
162166
163167
```json
164168
{
165-
"Body": {
166-
"heartRate": "78",
167-
"endDate": "2023-03-13T22:46:01.8750000",
168-
"deviceId": "device01"
169-
},
170-
"matchedToken": {
171-
"heartRate": "78",
172-
"endDate": "2023-03-13T22:46:01.8750000",
173-
"deviceId": "device01"
174-
}
169+
"Body": {
170+
"heartRate": "78",
171+
"endDate": "2023-03-13T22:46:01.8750000",
172+
"deviceId": "device01"
173+
},
174+
"matchedToken": {
175+
"heartRate": "78",
176+
"endDate": "2023-03-13T22:46:01.8750000",
177+
"deviceId": "device01"
178+
}
175179
}
176180
```
177181

178182
The resulting normalized message will look like this after the normalization stage:
179183

180184
```json
181185
[
182-
{
183-
"type": "heartrate",
184-
"occurrenceTimeUtc": "2023-03-13T22:46:01.875Z",
185-
"deviceId": "device01",
186-
"properties": [
187-
{
188-
"name": "hr",
189-
"value": "78"
190-
}
191-
]
192-
}
186+
{
187+
"type": "heartrate",
188+
"occurrenceTimeUtc": "2023-03-13T22:46:01.875Z",
189+
"deviceId": "device01",
190+
"properties": [
191+
{
192+
"name": "hr",
193+
"value": "78"
194+
}
195+
]
196+
}
193197
]
194198
```
195199

@@ -202,9 +206,14 @@ The resulting normalized message will look like this after the normalization sta
202206

203207
In this article, you learned how to use CalculatedContent templates with the MedTech service device mapping.
204208

205-
To learn how to use the MedTech service custom functions, see:
209+
To learn how to use the MedTech service custom functions, see
206210

207211
> [!div class="nextstepaction"]
208212
> [How to use custom functions with the MedTech service device mapping](how-to-use-custom-functions.md)
209213
214+
For an overview of the MedTech service FHIR destination mapping, see
215+
216+
> [!div class="nextstepaction"]
217+
> [Overview of the FHIR destination mapping](overview-of-fhir-destination-mapping.md)
218+
210219
FHIR® is a registered trademark of Health Level Seven International, registered in the U.S. Trademark Office, and is used with permission.

0 commit comments

Comments
 (0)