The Société Française d’Anesthésie et de Réanimation provides Google's top-ranked result for a Thoracoscore calculator. Their Thorascore calculator has a systematic error that introduces an addition of 0.05% to all scores that it calculates. We provide a patched version of their calculator's Javascript that corrects this error. We presented our findings at the Society for Cardiothoracic Surgery for Great Britain & Ireland's 2012 Annual Meeting.
SFAR's Thoracoscore calculator uses the following function to attempt to round the calculated score (x
) to 2 decimal places:
function Fmt(x) {
var v
if (x >= 0) {
v = '' + (x + 0.05)
} else {
v = '' + (x - 0.05)
}
return v.substring(0,v.indexOf('.')+3)
}
As x
is always ≥0, this adds 0.05 to x
before the substring
method truncates the string to 2 decimal places. This does not round to 2 decimal places. What was perhaps meant was to add 0.005 before truncating to 2 decimal places; this would be a valid rounding function.
We suggest the alternative:
function Fmt(x) {
return Math.round(x * 100) / 100;
}
We provide 3 files:
- thoracoscore2.php - The original source from SFAR's website: http://www.sfar.org/scores2/thoracoscore2.php. Accessed 2012-04-15 19:00.
- calculator.html - Tidied version of the original calculator.
- fixed.html - Patched version of calculator.html
We presented our findings at the Society for Cardiothoracic Surgery for Great Britain & Ireland's 2012 Annual Meeting. Our slides are on SpeakerDeck:
- Kenrick Turner (@kenners), Norfolk & Norwich University Hospital
- Andrew Ho (@andrewlkho), St. George's Hospital, London
- Gunnar Rø (@gulfa), University of Durham
- Martin Turner
- Filip Van Tornout, Norfolk & Norwich University Hospital
Correspondance should be addressed to Kenrick: kenrickturner[at]nhs.net