Difference between revisions of "MediaWiki:Gadget-calculator-anatomyPhysiology.js"
From WikiAnesthesia
Chris Rishel (talk | contribs) |
Chris Rishel (talk | contribs) |
||
| Line 3: | Line 3: | ||
bmi: { | bmi: { | ||
abbreviation: 'BMI', | abbreviation: 'BMI', | ||
formula: '\\mathrm{BMI} = \\frac{\\text{mass}_\\text{kg}}{{\\text{height}_\\text{m}}^2}', | formula: '<math>\\mathrm{BMI} = \\frac{\\text{mass}_\\text{kg}}{{\\text{height}_\\text{m}}^2}</math>', | ||
link: false, | link: false, | ||
name: 'Body mass index', | name: 'Body mass index', | ||
| Line 17: | Line 17: | ||
bsa: { | bsa: { | ||
abbreviation: 'BSA', | abbreviation: 'BSA', | ||
formula: '\\mathrm{BSA} = 0.007184 \\times W^{0.425} \\times H^{0.725} ', | formula: '<math>\\mathrm{BSA} = 0.007184 \\times W^{0.425} \\times H^{0.725}</math>', | ||
link: false, | link: false, | ||
name: 'Body surface area', | name: 'Body surface area', | ||
| Line 28: | Line 28: | ||
calculate: function( data ) { | calculate: function( data ) { | ||
return Math.pow( data.weight.toNumber( 'kgwt' ), 0.425 ) * Math.pow( data.height.toNumber( 'cm' ), 0.725 ); | return Math.pow( data.weight.toNumber( 'kgwt' ), 0.425 ) * Math.pow( data.height.toNumber( 'cm' ), 0.725 ); | ||
} | |||
}, | |||
ebv: { | |||
abbreviation: 'EBV', | |||
formula: '', | |||
link: false, | |||
name: 'Estimated blood volume', | |||
references: [ | |||
'Morgan & Mikhail\'s Clinical Anesthesiology. 5e. p1168' | |||
], | |||
units: 'L', | |||
variables: { | |||
required: [ 'weight', 'age' ] | |||
}, | |||
calculate: function( data ) { | |||
var weight = data.weight.toNumber( 'kgwt' ); | |||
var age = data.age.toNumber( 'yo' ); | |||
var ebvPerKg; | |||
if( age >= 1 ) { | |||
if( data.gender === 'F' ) { | |||
ebvPerKg = 65; | |||
} else { | |||
ebvPerKg = 75; | |||
} | |||
} else if( age >= 1/12 ) { | |||
ebvPerKg = 80; | |||
} else if( age >= 0 ) { | |||
ebvPerKg = 85; | |||
} else { | |||
ebvPerKg = 95; | |||
} | |||
return weight * ebvPerKg; | |||
} | } | ||
}, | }, | ||
| Line 64: | Line 99: | ||
}, | }, | ||
calculate: function( data ) { | calculate: function( data ) { | ||
var age = data.age.toNumber( 'yo' ); | |||
if( age >= 12 ) { | if( age >= 12 ) { | ||
| Line 93: | Line 128: | ||
'bmi', | 'bmi', | ||
'bsa', | 'bsa', | ||
'ebv', | |||
'ibw', | 'ibw', | ||
'ettSize' | 'ettSize' | ||
Revision as of 23:58, 22 July 2021
( function() {
mw.calculators.addCalculations( {
bmi: {
abbreviation: 'BMI',
formula: '<math>\\mathrm{BMI} = \\frac{\\text{mass}_\\text{kg}}{{\\text{height}_\\text{m}}^2}</math>',
link: false,
name: 'Body mass index',
references: [],
units: 'kg/m^2',
variables: {
required: [ 'weight', 'height' ]
},
calculate: function( data ) {
return data.weight.toNumber( 'kgwt' ) / Math.pow( data.height.toNumber( 'm' ), 2 );
}
},
bsa: {
abbreviation: 'BSA',
formula: '<math>\\mathrm{BSA} = 0.007184 \\times W^{0.425} \\times H^{0.725}</math>',
link: false,
name: 'Body surface area',
references: [
'Verbraecken, J; Van de Heyning P; De Backer W; Van Gaal L (Apr 2006). "Body surface area in normal-weight, overweight, and obese adults. A comparison study". Metabolism: Clinical and Experimental. 55 (4): 515–24. doi:10.1016/j.metabol.2005.11.004. PMID 16546483'
],
variables: {
required: [ 'weight', 'height' ]
},
calculate: function( data ) {
return Math.pow( data.weight.toNumber( 'kgwt' ), 0.425 ) * Math.pow( data.height.toNumber( 'cm' ), 0.725 );
}
},
ebv: {
abbreviation: 'EBV',
formula: '',
link: false,
name: 'Estimated blood volume',
references: [
'Morgan & Mikhail\'s Clinical Anesthesiology. 5e. p1168'
],
units: 'L',
variables: {
required: [ 'weight', 'age' ]
},
calculate: function( data ) {
var weight = data.weight.toNumber( 'kgwt' );
var age = data.age.toNumber( 'yo' );
var ebvPerKg;
if( age >= 1 ) {
if( data.gender === 'F' ) {
ebvPerKg = 65;
} else {
ebvPerKg = 75;
}
} else if( age >= 1/12 ) {
ebvPerKg = 80;
} else if( age >= 0 ) {
ebvPerKg = 85;
} else {
ebvPerKg = 95;
}
return weight * ebvPerKg;
}
},
ibw: {
abbreviation: 'IBW',
link: 'https://en.wikipedia.org/wiki/Human_body_weight#Ideal_body_weight',
name: 'Ideal body weight',
references: [
'Devine BJ. Gentamicin therapy. Drug Intell Clin Pharm. 1974;8:650–655.'
],
units: 'kg',
variables: {
required: [ 'height', 'gender' ]
},
calculate: function( data ) {
if( data.height.toNumber( 'cm' ) < 152 ) {
throw new Error( 'Ideal body weight may only be applied to persons 152 cm (60 inches) or taller' );
}
var baseWeight = data.gender === 'F' ? 45.5 : 50;
// baseWeight + 2.3 kg for every inch over 5 feet
return baseWeight + 2.3 * ( data.height.toNumber( 'in' ) - 60 );
}
},
ettSize: {
abbreviation: 'ETT size',
name: 'Endotracheal tube size',
references: [
'Smith\'s Anesthesia for Infants and Children. 8e. p356'
],
type: 'string',
variables: {
required: [ 'age' ],
optional: [ 'height' ]
},
calculate: function( data ) {
var age = data.age.toNumber( 'yo' );
if( age >= 12 ) {
return '7?';
} else if( age >= 1 ) {
// ( age + 16 ) / 4
// To nicely display in increments of 0.5, double the calculation, round (floor), then divide by 2
return String( Math.floor( 2 * ( ( age + 16 ) / 4 ) ) / 2 );
} else if (age >= 0.5 ) {
return '3.5-4';
} else if( age >= 0 ) {
return '3-3.5';
} else {
return '2.5-3';
}
},
renderLabel: function( renderOptions ) {
// Link only ETT/Endotracheal tube
return 'woo';
}
}
} );
mw.calculators.addCalculators( {
patientStats: {
name: 'Patient statistics',
calculations: [
'bmi',
'bsa',
'ebv',
'ibw',
'ettSize'
]
}
} );
mw.calculators.getCalculator( 'patientStats' ).render();
}() );