erikking
(Erikking)
August 20, 2023, 12:55am
1
Is it possible to use sample/patient related attributes in Calculations formula?
i.e.
if [SampleType] = ‘Serum’: return [Ca]*10 elif [SampleType] = ‘Plasma’: return [Ca]*3
or
if [Sex] = ‘Female’: return [Ca]*10 elif [Sex] = ‘Male’: return [Ca]*3
Thanks in advance.
ramonski
(Ramon Bartl)
August 21, 2023, 7:49pm
2
Hi @erikking ,
you can do so with an external calculation:
TLDR; You get the parent from the analysis (which is the sample) and find out the patient sex from there.
If you would like to have specifications based on a patient sex/age/ethnicity etc., you would probably want to have a dynamic analysis specification adapter implemented:
Hope this helps,
best regards
Ramon
erikking
(Erikking)
August 22, 2023, 12:51pm
3
Thanks a lot for helping. I think I got your point. Since the calculation is called from there
# Update ResultCapture date if necessary
if not val:
self.setResultCaptureDate(None)
elif prev_result != val:
self.setResultCaptureDate(DateTime())
# Set the result field
self.getField("Result").set(self, val)
@security.public
def calculateResult(self, override=False, cascade=False):
"""Calculates the result for the current analysis if it depends of
other analysis/interim fields. Otherwise, do nothing
"""
if self.getResult() and override is False:
return False
calc = self.getCalculation()
if not calc:
return False
should get parent (analysis) information easily.
I will do a try for that. Thanks again, it helps.