Stream: devices
Topic: Multiple Devices for One Observation
Cado (Feb 12 2021 at 10:22):
Hi there,
apologies if this is not the correct thread to post this in.
My question: Is there a way to somehow reference multiple device sources for one observation?
Use Case: Our system is receiving a daily step count from the Apple Health Kit. The step count from the health kit can potentially originate from multiple sources (e.g Apple Watch + iPhone itself). One measurement (daily step count) is sent to us via a FHIR conform POST Request.
Since the data is supposed to be used for a study, we need this request to include information about all devices that are involved (including product type, manufacturer and OS version).
If I understood correctly, the documentation states that there can only be one referenced measurement device for an observation (https://www.hl7.org/fhir/observation.html).
As a first idea, I thought it would maybe work if I only have one Object of resourceType "Device" but add multiple "deviceName" as well as "version" and "identifier" objects. But I am very unsure if this is a good/valid approach in any way.
Something like this:
{ "resourceType": "Bundle",
"type": "transaction",
"entry": [{ "resource": {
"contained": [{ "resourceType": "Device", "id": "1", "manufacturer": "Apple Inc",
"deviceName" : [
{ "name" : "Apple Watch Series X", "type" : "model-name" },
{ "name" : "iPhone XYZ", "type" : "model-name" }],
"version" : [
{ "value" : "7.0"},
{ "value" : "8.0"}],
"identifier": [
{ "value": "device_id_1" },
{ "value": "device_id_2" }] },
"resourceType": "Observation", "device": { "reference": "#1" }, } }]}
Thank you very much in advance for any help or advice on this matter :)
Cheers!
René Spronk (Feb 12 2021 at 11:03):
Using device.reference one can construct a hierarchy of devices, one device being part of another one (e.g. an App, on a cell phone, OR a watch, and a cell phone app).
Jacob Andersen (Feb 12 2021 at 15:31):
If you are looking for a way to represent a second device which assumes the role of a gateway (connecting the sensor - in your case the Apple Watch) to the Internet, you should take a look at the gatewayDevice extension http://hl7.org/fhir/extension-observation-gatewaydevice.html
Also, take a look at the PHD implementation guide at http://hl7.org/fhir/uv/phd/2019May/
Todd Cooper (Feb 12 2021 at 17:09):
@Stefan Karl @Kathrin Riech @John Rhoads ... DoF reponse?
Stefan Karl (Feb 15 2021 at 08:48):
I agree with Jacobs proposal - the gatewayDevice extension has been introduced to link a gateway device to an observation in addition to the measurement device.
Cado (Feb 15 2021 at 10:47):
Thanks a bunch for the quick replies and suggestions! I will try my luck with the gateway device extension :)
Cado (Feb 24 2021 at 12:32):
Hi again,
one follow-up question for when I have a collection of devices (more than 2) that I want to link to the observation in addition to the main measurement device. Could I still use the gatewayDevice extension? It seems a bit odd to add more than one gatewayDevice extension to a single observation but I need a way to basically link an arbitrary amount of devices to one observation ...
Thanks again if anybody can help me with this!
Todd Cooper (Feb 24 2021 at 19:03):
@Cado Could you give an example? That would really help: What observation and which kinds of devices (and why you need multiple devices for a single Observation instance)
Cado (Feb 25 2021 at 08:52):
Yeah, of course. The use case is for a medical study monitoring patients and tracking specific activities, for example their daily step count. To be as accurate as possible about how a measurement was generated, they need to know exactly which devices were involved.
As far as I know, you can use your phone to trace your steps as well as an Apple Watch or any other private device. Say, your watch tracks 200 steps, you take it off and your phone has tracked about 400 steps while an independent tracking app has counted 450 steps. This data will be run through an algorithm, duplicates will be deleted and you'll end up with one single end result for the accumulated steps of that day. I want to send this one value via a FHIR observation somewhere else and I need to include all devices that were involved in calculating this one value. Does that make more sense?
I have actually thought of trying the first suggestion in this thread and appoint one parent device with an arbitrary amount of child devices. That would probably make more sense than trying to add multiple gatewayDevice extensions.
Todd Cooper (Feb 25 2021 at 15:12):
Yes, this hits VERY close to home: I have the same issue between my iPhone tracking and my Oura ring. Of course, both report to my Apple Health and then it shows up automagically in my Withing's HealthMate app. Ditto for sleep info that is sent to Apple Health both from my bed and my ring - good news is that they are relatively consistent with each other BUT obviously one is better at some info (e.g., bed exits) and the other at different info (e.g., sleep stage tracking).
And I agree that the gatewayDevice extension path is pretty ... ugly.
And there are analogous scenarios in the device informatics world where multiple data sources (including both sensors such as EEG and independent devices) are combined to drive a therapeutic algorithm that derives a more stable indicator. For example, you might want to know an individual's temperature, but there could be 2 or 3 different sensors that report that temperature. At one level, the clinician (or other applications) just want a temperature, but knowing the sources could become crucial in certain scenarios.
All to say: I'd recommend using Observation.method to indicate that this is an algorithmically derived value (sorry, but I can't give you a specific recommendation as to a code) + Observation.derivedFrom (0...*) where you could identify a set of observation instances (each with a Device reference and if you want a sample array of readings).
Cado (Mar 02 2021 at 07:37):
@Todd Cooper Thanks a lot for your detailed response :)
I really like the idea of adding Observation.method to make it clear that the measurement is an algorithmically derived value.
The other thing you suggested, adding Observation.derivedFrom and referencing a set of additional observation instances, might not work for me however. Problem is, I don't have access to the individual measurements that make up the accumulated result. I only get one number from the Health Kit and the additional info that a specific Apple Watch, a specific phone and maybe a specific third device were involved in calculating the end result. So I think it wouldn't make sense to separate those into individual observation instances.
I tried to simply add all involved devices to the Observation.contained array and add a parent property to all but one. @René Spronk Is this what you meant by using device.reference?
.....
"resource": { "contained": [
{
"resourceType": "Device",
"id": "1",
"manufacturer": "Apple Inc",
"deviceName" : [ { "name" : "Watch6,2", "type" : "model-name" } ],
"identifier": [ { "value": "id_1" } ] },
{
"resourceType": "Device",
"id": "2",
"manufacturer": "Apple Inc",
"deviceName" : [{ "name" : "iPhone 11 Pro", "type" : "model-name" }],
"identifier": [ { "value": "id_2" } ],
"parent": { "reference": "#1" } },
{
"resourceType": "Device",
"id": "3",
"manufacturer": "Apple Inc",
"deviceName" : [{ "name" : "random private device", "type" : "model-name" }]
"identifier": [{ "value": "id_3" }],
"parent": { "reference": "#1" }
}],
"resourceType": "Observation",
"device": {
"reference": "#1"
},
........... }
But it seems that when I try to parse this using our FHIR framework (FhirContextForR4().newJsonParser().encodeResourceToString(observation)), the only thing that remains in the Observation.contained array is the first entry that I specifically referenced within the device property. All other data is simply lost. Like I said, kinda new to FHIR tbh ^^" so I might be misunderstanding how this works.
But is there an option where I can add info about additional devices that do not stand on their own (they don't need to). I simply need this information stored somewhere inside one observation instance so it can be forwarded in a FHIR-conforming way.
Todd Cooper (Mar 02 2021 at 15:45):
w.r.t. my proposal to use .derivedFrom, the focus was on a simple way to put a list of Device instance references and not on including all the related sample data. A single value is fine IMHO, and in fact, you probably DON'T want to pass on all that info on at the same time.
Jose Costa Teixeira (Mar 02 2021 at 19:14):
IIRC there was a change request to add Device to observation .performer
Jose Costa Teixeira (Mar 02 2021 at 19:15):
I believe the use case was the same as is hinted above- it's not really a person using a device that takes a measurement, but rather a device that does some determination (e.g. a clever algorithm in a system)
Jacob Andersen (Mar 04 2021 at 13:56):
Hi @Cado
I would probably model this along the lines also suggested by Todd: In the real world, you have a number of devices. Each device collected some data. You do not have access to the original data but only the aggregated / total sum or whatever. So one suggestion that maps this into a FHIR model could be the following pseudo code with aggregated data from 3 sources:
{
resourceType: Observation,
derivedFrom: [ obs-1, obs-2, obs-3 ],
valueQuantity: { THE_AGGREGATED_VALUE },
contained: [
{
id: obs-1
resourceType: Observation,
dataAbsentReason: { not-asked }
device: { DEVICE_1 }
},
{
id: obs-2
resourceType: Observation,
dataAbsentReason: { not-asked }
device: { DEVICE_2 }
},
{
id: obs-3
resourceType: Observation,
dataAbsentReason: { not-asked }
device: { DEVICE_3 }
}
]
}
Lloyd McKenzie (Mar 04 2021 at 14:18):
You can only have contained resources if they reference the parent or are referenced by the parent. What's the relationship between parent and contained resources here?
Jacob Andersen (Mar 04 2021 at 14:27):
@Lloyd McKenzie I assume you are answering Cado's question from March 2nd about why content is disappearing, right? If the comment was instead addressed to me, please elaborate.
Lloyd McKenzie (Mar 04 2021 at 15:04):
It was addressed to you @Jacob Andersen. Your example showed multiple contained Observations, but no reference from the containing Observation to the contained Observations - which isn't conformant. It wasn't clear to me what the relationship should be either.
Jacob Andersen (Mar 04 2021 at 15:23):
But there are references from the parent to the contained resources, @Lloyd McKenzie The derivedFrom property of the parent points to all three contained observations
Lloyd McKenzie (Mar 04 2021 at 15:26):
That wasn't shown in the instance you posted. If you've got derived from, that would work. So you're essentially saying "this result was derived from 3 other observations about which no details are known other than what devices were used"? Would you not want to reflect the chain of derivation? I.e. would obs-3 not have a derivation relationship to obs-2 and obs-2 having a derived relationship to obs-1?
Jacob Andersen (Mar 04 2021 at 15:30):
Yes, that is in line 3 of the code block - and has been there all along.
As I understand Cado's original question [elaborated in the posting on Feb 25 at 9:52 am], there is no logical derivation chain. I understand the use case such that there is a number of devices that all provide data. These original data are unknown because some piece of software aggregates/summarises them. This is what I am attempting to reflect here.
Jacob Andersen (Mar 04 2021 at 15:43):
In other words: I am modelling an (unordered) set of devices contributing to the observation in contrast to an ordered list of devices.
Lloyd McKenzie (Mar 04 2021 at 16:07):
ok
Last updated: Apr 12 2022 at 19:14 UTC