Stream: implementers
Topic: Calculation
Pranitha Sruthi (Sep 12 2017 at 11:24):
Hi all, which resource shall I use to calculate a particular quantity? For instance, calculating the corrected QT interval in an ECG profile. Thank you
Lloyd McKenzie (Sep 12 2017 at 14:29):
Observation
Pranitha Sruthi (Sep 13 2017 at 12:50):
@Lloyd McKenzie Bazett's formula to calculate corrected QT interval is QTC = QT / √ RR. There are two variables QT and RR. Also, QT and RR have units (msec or sec). Which resource does this calculation? qtc.PNG
Christiaan Knaap (Sep 13 2017 at 14:38):
A Resource is a datastructure, it does no calculations whatsoever. In the Observation resource you can add multiple components, so you can choose to include either QT and RR or the derived QTC, or all three. But the actual calculation has to be done in the software that processes the Observation. You can check the bloodpressure example resource to see one with multiple components (systolic and diastolic blood pressure in this case).
Lloyd McKenzie (Sep 13 2017 at 14:49):
Are you wanting a resource to store the definition of the calculation?
Pranitha Sruthi (Sep 19 2017 at 07:01):
@Christiaan Knaap Thank you
@Lloyd McKenzie Yes. Which resource shall I pick?
Lloyd McKenzie (Sep 19 2017 at 19:46):
Library would be the option if you're wanting to store it in a computable way.
Lloyd McKenzie (Sep 19 2017 at 19:48):
That said, storing a single calculation in a Library would be "unusual". What is your objective?
Pranitha Sruthi (Sep 21 2017 at 13:35):
@Lloyd McKenzie My intention is to store some calculations (similar to corrected QT interval) in a resource. How can I do that using the resource 'Library'? Can I use the resource 'Measure' to calculate certain quantity and store the result in MeasureReport? Thank you
Lloyd McKenzie (Sep 21 2017 at 15:25):
You want to store the calculated values or you want to store the formula? MeasureReport is for quality measures not for arbitrary calculations
Pranitha Sruthi (Sep 22 2017 at 12:50):
I want to store formulae and the interpretation as well. calci.PNG The QTc interval is calculated in the screenshot and the interpretation is displayed. Therefore I need a resource which can store formulae and interpretation for the respective formulae.
Lloyd McKenzie (Sep 22 2017 at 14:36):
Ok. From the screen-shot, it looks like the storage of the formula is as a display string for consumption by a human reader, not as a computable artifact for machine execution. Is that accurate? Your screen looks like it's representing something we've been calling an ObservationDefinition - also known as an "observation master file entry". It describes a test or observation that can be performed and relevant information about when/how/why the observation is done, how much it costs, etc. Would that align with your use-case?
Pranitha Sruthi (Sep 25 2017 at 12:59):
@Lloyd McKenzie I need a resource which can store both the formula for the consumption of a human reader and also computable artifact for machine execution. May I know what is ObservationDefinition?
Lloyd McKenzie (Sep 25 2017 at 14:36):
ObservationDefinition is a proposed new resource that would support defining types of observations that can exist. It does not exist yet (and it's not clear whether it'll get done prior to R4 or not). It's possible you might also be able to use ActivityDefinition, though I'm not sure if this use-case is in scope. @Bryn Rhodes ?
Pranitha Sruthi (Sep 27 2017 at 05:48):
@Lloyd McKenzie Please suggest a resource which can store both the formula for the consumption of a human reader and also computable artifact for machine execution.
John Moehrke (Sep 27 2017 at 14:25):
Observation.text is for human consumption; all the rest of the resource is for machine execution...
Lloyd McKenzie (Sep 27 2017 at 14:58):
The only resource we have right now that might be a candidate is ActivityDefinition, but it's best to wait for guidance from @Bryn Rhodes . The alternative would be to define something in Basic.
Bryn Rhodes (Sep 27 2017 at 15:06):
@Pranitha Sruthi , as Lloyd suggested, you could use a Library to store the logic as a CQL expression. It does sound like an ActivityDefinition would work though, you are defining a possible observation with instructions for how to calculate it (if I understand the use case correctly). So, in that usage, you'd specify the calculation as a dynamicValue element. See the Using Expressions topic for more.
Pranitha Sruthi (Sep 28 2017 at 12:03):
@Lloyd McKenzie Thank you
@John Moehrke Ok thank you
@Bryn Rhodes Thanks for your response. I have gone through the content. How can I use the extension in my DiagnosticReport (ECG) profile? I need to store the formula for the QTc interval and the computable artifact. Thank you
Lloyd McKenzie (Sep 28 2017 at 14:37):
So you'd capture the QTc as an Observation. You'll need put a http://hl7.org/fhir/extension-event-definition.html extension on the Observation that points to the ActivityDefinition. And then you put the formula in the ActivityDefinition.
Bryn Rhodes (Sep 29 2017 at 02:02):
Right, and in the ActivityDefinition, you would put the formula for the value as a dynamicValue element.
Jose Costa Teixeira (Oct 02 2017 at 20:26):
so ActivityDefinition would also support operations on data, not only operations on activities?
Brian Postlethwaite (Oct 03 2017 at 01:42):
@Bryn Rhodes can the CQL expression handle the square root calculation?
Pranitha Sruthi (Oct 03 2017 at 09:00):
@Bryn Rhodes Is it not necessary to add the CQL extension?
Bryn Rhodes (Oct 03 2017 at 14:11):
@Jose Costa Teixeira, yes, the intent is to support dynamic calculation of values, including access to data in context.
Bryn Rhodes (Oct 03 2017 at 14:13):
@Brian Postlethwaite, yes, just use the power, X ^ 0.5
Bryn Rhodes (Oct 03 2017 at 14:17):
@Pranitha Sruthi, you only need to use the CQL extension for cases where the resources don't already have facilities to support expressions. The ActivityDefinition already has the dynamicValue attribute to support the extension. You could use the extension to describe the formula on the appropriate attributes in DiagnosticReport, but since it's instance-level, the only value in doing so would be descriptive. By using it on ActivityDefinition to describe how to build a DiagnosticReport, you provide a way to share the calculation.
Pranitha Sruthi (Oct 04 2017 at 04:52):
expression.PNG @Bryn Rhodes I have mentioned the formula in the expression element as in the screenshot. Is that correct?
Bryn Rhodes (Oct 06 2017 at 21:30):
@Pranitha Sruthi yes, that's correct, but you need to express QT and RR in terms of the attributes of the Observation, right?
Pranitha Sruthi (Oct 07 2017 at 11:38):
@Bryn Rhodes Yes. How can I do that?
Pranitha Sruthi (Oct 07 2017 at 11:39):
Do I need to install the cql software?
Bryn Rhodes (Oct 07 2017 at 22:40):
Where are QT and RR represented in the Observation?
Lloyd McKenzie (Oct 08 2017 at 14:24):
Can they be interpreted independently? If so, they'd be separate observations. Otherwise they'd be components
Pranitha Sruthi (Oct 09 2017 at 06:01):
How can I represent QT interval and RR rate in the QTc profile (Observation)?
Lloyd McKenzie (Oct 09 2017 at 13:46):
I think I answered that in the prvious post in this thread?
Pranitha Sruthi (Oct 09 2017 at 13:47):
Yes but which method shall I use? Are they 'components' or independant profiles?
Lloyd McKenzie (Oct 09 2017 at 13:54):
Do you understand what a QT interval and RR rate are? Do you know if they can be interpretted independently?
John Moehrke (Oct 10 2017 at 15:05):
They are measurements made from the recorded ECG. I.e., The "QT" is the interval measured between the "Q" and the "T" part of the waveform (The waveform has specifically labeled parts). It is a measure of how well the heart is recovering from the work it just did. It is a measurement, but each heart-beat has a QT. And there is some interpretation of where exactly the Q and T are. Which is why the waveform needs to be scalable so that the human cardiologist can use their own diagnostic viewer calipers.
Lloyd McKenzie (Oct 10 2017 at 18:42):
Ok - and are the QT and RR typically examined and useful on their own?
Pranitha Sruthi (Nov 15 2017 at 09:27):
Hi, @Bryn Rhodes I have created a profile for the QTc calculation (formula) using the ActivityDefinition resource (as per your instructions). I have modified only the 'dynamicValue' element. Kindly check the screenshots for any mistakes. language.PNG expression.PNG path.PNG
Bryn Rhodes (Nov 15 2017 at 13:03):
Hi @Pranitha Sruthi , I think this is mixing the type/instance distinction. ActivityDefinition is already at the type level, so what's needed here isn't a profile on ActivityDefinition, but an instance of an ActivityDefinition that specifies how to construct an Observation. Does that make sense?
Pranitha Sruthi (Nov 15 2017 at 13:06):
@Bryn Rhodes Sorry I don't know. Which one of them do you recommend?
Bryn Rhodes (Nov 15 2017 at 13:12):
Well, what I'm saying is that you don't need to define a profile, you need to define an ActivityDefinition.
Pranitha Sruthi (Nov 15 2017 at 13:14):
Ok. How can I do that?
Lloyd McKenzie (Nov 15 2017 at 13:16):
You'll need to manually create an XML or JSON instance. There's no authoring tool for ActivityDefinitions that I'm aware of yet. (Though you can and should use a tool that at least supports schema validation of your XML or JSON instance.)
Pranitha Sruthi (Nov 15 2017 at 13:17):
Can I use clinFHIR?
Lloyd McKenzie (Nov 15 2017 at 13:19):
I don't know if it supports ActivityDefinition yet - @David Hay ?
David Hay (Nov 15 2017 at 14:38):
Well, you should be able to build an instance of the ActivityType in the Scenario Builder (though I've not tries specifically). Was there something more that you wanted to do with it?
Pranitha Sruthi (Nov 16 2017 at 06:36):
@David Hay I have used Scenario Builder to create an instance for the ActivityDefinition. I need to add the formula for corrected QT interval of an ECG waveform.
{
"path": "QTc Interval",
"language": "text/cql",
"expression": "QT / RR^0.5"
}
I have edited the dynamicValue element of the resource. Is the above mentioned format correct?
Bryn Rhodes (Nov 16 2017 at 08:35):
Path needs to resolve to an element of the target resource. So if the ActivityDefinition is a template for an Observation, then the path would need to resolve to an element of an Observation, most likely "value", right? You're defining the expression for calculating the value of the Observation?
Pranitha Sruthi (Nov 16 2017 at 08:38):
Ok. Should I mention the URL of the target Observation in the 'path'?
Bryn Rhodes (Nov 16 2017 at 09:17):
No, it's a relative path expressed from the root of the target resource.
Pranitha Sruthi (Nov 16 2017 at 09:18):
Do you mean the location of the target resource?
Bryn Rhodes (Nov 16 2017 at 09:20):
No, just the target resource. Think of an ActivityDefinition is a set of instructions for constructing a resource. When you follow those instructions, you get an instance of a resource. That instance is what I'm calling the target here.
Pranitha Sruthi (Nov 16 2017 at 09:32):
Can you give an example for the path?
Bryn Rhodes (Nov 16 2017 at 10:06):
Sure, path in this case should be value
. You could say valueQuantity
if you wanted to delineate the target type, but value
is the target element.
Bryn Rhodes (Nov 16 2017 at 10:07):
Because what you're building is an Observation, and you're calculating the value of the Observation, right?
Pranitha Sruthi (Nov 16 2017 at 10:12):
Yes. As the result of the calculation would be a numerical quantity (number), the path has to be mentioned as 'value'.
Pranitha Sruthi (Jan 30 2018 at 13:52):
Hi all, which one of the following is a better approach for calculating a particular quantity using a specific formula
1. with the help of a mobile client or
2. with the help of a cql executor?
Thank you
Last updated: Apr 12 2022 at 19:14 UTC