Difference between revisions of "MediaWiki:Gadget-calculator-anatomyPhysiology.js"
From WikiAnesthesia
Chris Rishel (talk | contribs) m (Chris.Rishel moved page MediaWiki:Gadget-calculator-patientstats.js to MediaWiki:Gadget-calculator-patientStats.js without leaving a redirect) |
Chris Rishel (talk | contribs) |
||
Line 67: | Line 67: | ||
} | } | ||
}, | }, | ||
renderLabel: function( | renderLabel: function( renderOptions ) { | ||
// Link only ETT/Endotracheal tube | // Link only ETT/Endotracheal tube | ||
return 'woo'; | return 'woo'; | ||
Line 73: | Line 73: | ||
} | } | ||
} ); | } ); | ||
mw.calculators.addCalculators( { | |||
patientStats: { | |||
name: 'Patient statistics', | |||
calculations: [ | |||
'bmi', | |||
'ibw' | |||
] | |||
} | |||
} ); | |||
mw.calculators.getCalculator( 'patientStats' ).render(); | |||
}() ); | }() ); |
Revision as of 19:22, 22 July 2021
( function() { mw.calculators.addCalculations( { bmi: { abbreviation: 'BMI', digits: 1, formula: '\\mathrm{BMI} = \\frac{\\text{mass}_\\text{kg}}{{\\text{height}_\\text{m}}^2}', 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 ); } }, ibw: { abbreviation: 'IBW', digits: 1, 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', digits: 1, name: 'Endotracheal tube size', references: [ 'Smith\'s Anesthesia for Infants and Children. 8e. p356' ], variables: { required: [ 'age' ], optional: [ 'height' ] }, calculate: function( data ) { const 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', 'ibw' ] } } ); mw.calculators.getCalculator( 'patientStats' ).render(); }() );