Difference between revisions of "MediaWiki:Gadget-calculator-patients-patientInput.js"

From WikiAnesthesia
m (Chris.Rishel moved page MediaWiki:Gadget-calculator-patientinput.js to MediaWiki:Gadget-calculator-patientInput.js without leaving a redirect)
 
(15 intermediate revisions by the same user not shown)
Line 3: Line 3:
  */
  */
( function() {
( function() {
     mw.calculators.addVariables( {
     mw.calculators.renderPatientInput = function() {
         age: {
         if( mw.calculators.getOptionValue( 'patientinputinline' ) ) {
            name: 'Age',
             return;
            type: 'number',
            defaultValue: '40 yr',
            maxLength: 3,
            units: [
                'yr',
                'mo',
                'wk'
            ]
        },
        gender: {
            name: 'Gender',
            type: 'string',
            defaultValue: 'F',
            options: [
                'F',
                'M'
            ]
        },
        height: {
            name: 'Height',
            type: 'number',
            abbreviation: 'Ht',
            defaultValue: '175 cm',
            maxLength: 3,
            units: [
                'cm',
                'm',
                'in',
                'ft'
            ]
        },
        weight: {
            name: 'Weight',
            type: 'number',
            abbreviation: 'Wt',
            defaultValue: '75 kgwt',
            maxLength: 3,
            renderUnits: function( units ) {
                return units.replace( 'wt', '' );
             },
            units: [
                'kgwt',
                'lbwt',
                'gwt'
            ]
         }
         }
    } );


    var containerId = 'calculator-patientinput';
        var containerId = 'calculator-patients-patientInput';


    if( !$( '#' + containerId ).length ) {
        if( !$( '#' + containerId ).length ) {
        var $container = $( '<div>', {
            var inputs = [
             id: containerId
                'weight',
        } );
                'height',
                'age',
                'gender'
             ];


        $container.addClass( 'container border-bottom px-0 py-1' );
            var $container = $( '<div>', {
                id: containerId
            } );


        var $containerRow = $( '<div>', {
            $container.addClass( 'container border-bottom px-0 py-1' );
            class: 'form-row align-items-center'
        } );


        var inputOptions = {
             $container.append( mw.calculators.createInputGroup( inputs, true, inputs.length ) );
             size: 'compact'
        };


        $containerRow.append( mw.calculators.getVariable( 'weight' ).createInput( inputOptions ) );
            $container.appendTo( $( '#contentHeader' ) );
        $containerRow.append( mw.calculators.getVariable( 'height' ).createInput( inputOptions ) );
         }
        $containerRow.append( mw.calculators.getVariable( 'age' ).createInput( inputOptions ) );
    };
         $containerRow.append( mw.calculators.getVariable( 'gender' ).createInput( inputOptions ) );
 
        $container.appendTo( $( '#contentHeader' ) );


        $container.append( $containerRow );
    mw.hook( 'calculators.initialized' ).add( mw.calculators.renderPatientInput );
    }
}() );
}() );

Latest revision as of 21:59, 29 March 2022

/**
 * @author Chris Rishel
 */
( function() {
    mw.calculators.renderPatientInput = function() {
        if( mw.calculators.getOptionValue( 'patientinputinline' ) ) {
            return;
        }

        var containerId = 'calculator-patients-patientInput';

        if( !$( '#' + containerId ).length ) {
            var inputs = [
                'weight',
                'height',
                'age',
                'gender'
            ];

            var $container = $( '<div>', {
                id: containerId
            } );

            $container.addClass( 'container border-bottom px-0 py-1' );

            $container.append( mw.calculators.createInputGroup( inputs, true, inputs.length ) );

            $container.appendTo( $( '#contentHeader' ) );
        }
    };

    mw.hook( 'calculators.initialized' ).add( mw.calculators.renderPatientInput );
}() );