...
Here is some GELLO code to calculate BMI:
imports HL7_v2_VMR_V1
...
Context SinglePatient
...
Let allWeights:Sequence(Observation) = vitals.weight
...
Let allHeights:Sequence(Observation) = vitals.height
...
Let mostRecentWeight:Observation = allWeights->sortedBy(dateTime)->last()
...
Let mostRecentHeight:Observation = allHeights->sortedBy(dateTime)->last()
...
Let wt:Real = mostRecentWeight.value.oclAsType(PQ).value
...
Let ht:Real = mostRecentHeight.value.oclAsType(PQ).convert('m').value
...
Let BMI: Real = wt/ht.power(2)
...
If BMI < 18.5 then 'Underweight'
...
else If BMI >= 18.5 and BMI < 25 then 'Normal'
else If BMI >= 25 and BMI < 30 then 'Overweight'
else 'Obese'
endif
endif
...
else If BMI >= 25 and BMI < 30 then 'Overweight'
else 'Obese'
endif
endif
endif
Using test fifthTest.xml, here is the result:
The url for the POST in the REST client is http://mowgli.medical-objects.com.au/rest/gellov2/generic
...
If we don’t need to return all the variables, delete ‘V,1’ from line 2, to make it:
"Debug": "",
You can also return the result as a tuple instead of a single typed value (which in this case is simply a string).