MediaWiki:Gadget-calculator-cardiovascular.js
From WikiAnesthesia
Revision as of 15:55, 5 April 2022 by Chris Rishel (talk | contribs) (Created page with "( function() { mw.calculators.addUnitsBases( { bpm: { toString: function( units ) { units = units.replace( 'bpm', 'beats/min' ); return units; } }, hgb: { toString: function( units ) { units = units.replace( 'hgbperdL', '/dL' ); units = units.replace( /\s?pcthct/, '%' ); return units; } }, o2: {...")
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
( function() { mw.calculators.addUnitsBases( { bpm: { toString: function( units ) { units = units.replace( 'bpm', 'beats/min' ); return units; } }, hgb: { toString: function( units ) { units = units.replace( 'hgbperdL', '/dL' ); units = units.replace( /\s?pcthct/, '%' ); return units; } }, o2: { toString: function( units ) { units = units.replace( /\s?pcto2/, '%' ); return units; } } } ); mw.calculators.addUnits( { bpm: { baseName: 'bpm' }, pcthct: { baseName: 'hgb' }, pcto2: { baseName: 'o2' }, ghgbperdL: { baseName: 'hgb', prefixes: 'short', definition: '3 pcthct' } } ); mw.calculators.addVariables( { heartRate: { name: 'Heart rate', type: 'number', abbreviation: 'HR', defaultValue: '60 bpm', maxLength: 4, units: [ 'bpm' ] }, hgb: { name: 'Hemoglobin/hematocrit', type: 'number', abbreviation: 'HgB', minValue: '3 ghgbperdL', maxValue: '25 ghgbperdL', defaultValue: '13 ghgbperdL', maxLength: 4, units: [ 'pcthct', 'ghgbperdL' ] }, saO2: { name: 'SaO<sub>2</sub>', type: 'number', abbreviation: 'SaO<sub>2</sub>', minValue: '25 pcto2', maxValue: '100 pcto2', defaultValue: '100 pcto2', maxLength: 3, units: [ 'pcto2' ] }, smvO2: { name: 'SmvO<sub>2</sub>', type: 'number', abbreviation: 'SmvO<sub>2</sub>', minValue: '25 pcto2', maxValue: '100 pcto2', defaultValue: '75 pcto2', maxLength: 3, units: [ 'pcto2' ] } } ); // Force re-render of ibw and lbw. This is necessary to remove the additional inputs for patient variables from the // calculation which are now provided by the patient input toolbar. mw.calculators.calculations.bsa.render(); mw.calculators.addCalculations( { systolicBloodPressure: { name: 'Systolic blood pressure', abbreviation: 'SBP', data: { variables: { required: [ 'age' ] } }, type: 'string', references: [ 'Baby Miller 6e, ch. 16, pg. 550' ], calculate: function( data ) { var age = data.age.toNumber( 'yo' ); var systolicMin, systolicMax, diastolicMin, diastolicMax, meanMin, meanMax; if( age >= 16 ) { systolicMin = 100; systolicMax = 125; } else if( age >= 13 ) { systolicMin = 95; systolicMax = 120; } else if( age >= 9 ) { systolicMin = 90; systolicMax = 115; } else if( age >= 6 ) { systolicMin = 85; systolicMax = 105; } else if( age >= 3 ) { systolicMin = 80; systolicMax = 100; } else if( age >= 1 ) { systolicMin = 75; systolicMax = 95; } else if( age >= 6 / 12 ) { systolicMin = 70; systolicMax = 90; } else if( age >= 1 / 12 ) { systolicMin = 65; systolicMax = 85; } else { systolicMin = 60; systolicMax = 75; } } } } ); // Cardiovascular mw.calculators.addCalculations( { vO2: { name: 'Rate of oxygen consumption (VO<sub>2</sub>)', abbreviation: 'VO<sub>2</sub>', data: { calculations: { required: [ 'bsa' ] }, variables: { optional: [ 'age' ] } }, units: 'mL/min', formula: '<math>\\mathrm{VO_2} = \\begin{cases} 125 * \\mathrm{BSA} & \\text{if age} < 70 \\\\ 110 * \\mathrm{BSA} & \\text{if age} \\geq 70 \\end{cases}</math>', references: [], calculate: function( data ) { var bsa = data.bsa.toNumber(); var age = data.age ? data.age.toNumber( 'yr' ) : null; if( age < 70 ) { return 125 * bsa; } else { return 110 * bsa; } } }, cardiacOutputFick: { name: 'Cardiac output (Fick)', abbreviation: 'CO (Fick)', data: { variables: { required: [ 'saO2', 'smvO2', 'hgb' ] }, calculations: { required: [ 'vO2' ] } }, units: 'L/min', formula: '<math>\\mathrm{CO_{Fick}}=\\frac{\\mathrm{VO_2}}{(\\mathrm{S_aO_2} - \\mathrm{S_{mv}O_2}) * H_b * 13.4}</math>', link: false, references: [], calculate: function( data ) { var vO2 = data.vO2.toNumber( 'mL/min' ); var saO2 = data.saO2.toNumber() / 100; var smvO2 = data.smvO2.toNumber() / 100; var hgb = data.hgb.toNumber( 'ghgbperdL' ); return vO2 / ( ( saO2 - smvO2 ) * hgb * 13.4 ); } }, cardiacIndex: { name: 'Cardiac index', abbreviation: 'CI', data: { calculations: { required: [ 'bsa', 'cardiacOutputFick' ] } }, units: 'L/min/m^2', formula: '<math>\\mathrm{CI}=\\frac{\\mathrm{CO}}{\\mathrm{BSA}}</math>', link: false, references: [], calculate: function( data ) { var cardiacOutput = data.cardiacOutputFick.toNumber( 'L/min' ); var bsa = data.bsa.toNumber( 'm^2' ); return cardiacOutput / bsa; } }, strokeVolume: { name: 'Stroke volume', abbreviation: 'SV', data: { variables: { required: [ 'heartRate' ] }, calculations: { required: [ 'cardiacOutputFick' ] } }, units: 'mL', formula: '<math>\\mathrm{SV}=\\frac{\\mathrm{CO}}{\\mathrm{HR}}</math>', link: false, references: [], calculate: function( data ) { var cardiacOutput = data.cardiacOutputFick.toNumber( 'mL/min' ); var heartRate = data.heartRate.toNumber(); return cardiacOutput / heartRate; } } } ); }() );