...
and screenshot after running is :
Now we need to see if mostRecentHb is too low ( ie if the patient is anemic). Make a threshold for anaemia, say 115 g/l.
Let anaemiaThreshold: PQ = factory.PQ(115,'g/L')
Yup - there is a factory to which we send a method PQ (to make a Physical quantity - which has attributes of value: Real and units: String)
Need to make 'mostRecentHb' a PQ as well (currently an Observation); so
Let mostRecentHBAsPQ: PQ = mostRecentHb.value.oclAsType(PQ)
We are getting the value of the Observation ( which here is a PQ type) but we need to make it explicitly a PQ using the oclAsType(PQ) method. Its a GELLO 2 thing...
[As an aside when you have just put a dot after some code, there is code autocomplete available which can help guide you ]
Now we compare the two to get a boolean intermediate answer:
Let hemoglobinIsLow:Boolean = mostRecentHBAsPQ < anaemiaThreshold
and running this returns true for the 'hemoglobinIsLow' variable.
But we need a final declarative statement, and this should be a type of GLIFDecisionResult as we are in a GLIF decision arrow for "yes" , so the final GELLO to be added is:
--need to return a GLIFDecisionResult as we are doing a GLIF Decision
let q: String = "Is hemoglobin below 115 g/l?"
let aWeight: Integer = 50
Let result:GLIFDecisionResult =
if not mostRecentHb.oclIsDefined() then
GLIFDecisionResult{Question = q,Answer = unknown, Reason = "No hemoglobin observations",Weight = aWeight}
else
if hemoglobinIsLow
then
GLIFDecisionResult{Question = q,Answer = true, Reason = "Sodium is above threshold",Weight = aWeight}
else
GLIFDecisionResult{Question = q,Answer = false, Reason = "Sodium in not above threshold",Weight = aWeight}
endif
endif
result
Ok here we have two new variables for the result object ( as required for a GLIFDEcisionResult - see the model in model explorer), a test for no data, and if-then statements for the final result.
Here is screen shot of this working in the GLIFeditor's gello editor we are using: