...
Notice that for the data obtained from the IncomingObservation ie the measured height, weight, waist circumference, systolic blood pressure and diastolic blood pressure; we don't need to say 'vmr.observations', but when we are looking outside the context of the incoming observation, we do- e.g. for recent pathology. This code keeps the convention of searching for Observations, then ordering them by dateTime, then getting the last Observation. This is probably unnecessary for the archetyped clinical data, but it is possible to repeat a blood pressure reading if high ; so it is retained.
Do a BMI calculation: ( we know the units will be cm for height and kg for weight.
-- do BMI calculation
Let currentHeightInMeters: PQ = currentHeight/100
Let bmi: Real = currentWeight.value/currentHeightInMeters.value.power(2)
Let bmi_Rounded: Real = bmi.round()
Let bmi_AsString: String = If bmi_Rounded.oclIsDefined() then bmi_Rounded.toChar() else '' endif
Do a triglyceride / HDL ratio:
--TG HDL ratio
Let trig_HDL_Ratio : Real = If last_trigObservation.oclIsDefined() and last_hdlObservation.oclIsDefined() then
last_trigObservation.value.oclAsType(PQ).value / last_hdlObservation.value.oclAsType(PQ).value
else null endif
Let trig_HDL_Ratio_raised: Boolean = If last_trigObservation.oclIsDefined() and last_hdlObservation.oclIsDefined() then
If last_trigObservation.value.oclAsType(PQ).value / last_hdlObservation.value.oclAsType(PQ).value > 2
then True
else False endif
else False endif
Let trig_HDL_ratio_asChar: String = If trig_HDL_Ratio.oclIsDefined() then trig_HDL_Ratio.toChar() else '' endif
Prepare comments:
-- prepare comments
Let commentCode:CD =CD{code = '8251-1', codeSystem = '2.16.840.1.113883.6.1', codeSystemName ='LN', displayName = ST{value='Comment'}}
Let bmiString: String = 'BMI is '
Let additionalBMIComment: String = If bmi.oclIsDefined() then
If bmi <18.6 then '. Patient is considered to be Underweight.' else
If bmi >25 and bmi < 30 then '. Patient is considered to be Overweight.' else
If bmi >29.9 then '. Patient is considered to be Obese.' else
''
endif endif endif else '' endif
Let trig_HDL_ratio_asChar: String = If trig_HDL_Ratio.oclIsDefined() then trig_HDL_Ratio.toChar() else '' endif
Let trig_HDL_ratio_comment1: String = If trig_HDL_Ratio_raised then
\nTriglyceride-HDL ratio is ' else '' endif
Let trig_HDL_ratio_comment2: String = If trig_HDL_Ratio_raised then trig_HDL_ratio_asChar.concat('. Levels above 2 are significant.')
else '' endif
Let trig_HDL_ratio_comment: String = trig_HDL_ratio_comment1.concat(trig_HDL_ratio_comment2)
Let comment: String = bmiString.concat(bmi_AsString).concat(additionalBMIComment).concat(trig_HDL_ratio_comment)
uwf