Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 1x 1x 17x 2x 15x 9x 6x 1x 5x 5x 1x 4x 1x 3x 18x 1x 1x 20x 19x 5x 1x 1x 1x 1x | /**
* @prettier
*/
/*
* Part of Pleiar.no - a collection of tools for nurses
*
* Copyright (C) Eskild Hustvedt 2017-2018
* Copyright (C) Fagforbundet 2019
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { Row, Col, Form, Input, Label } from "reactstrap";
import {
CalcExplanation,
CalcExplanationLine,
CalcExplanationDescription,
CalcExplanationCalculation,
CalcExplanationFormula,
Fraction,
FractionResult,
} from "./calculators-shared.js";
import { setWeight } from "../actions/nutricalc-shared";
import { setHeight } from "../actions/nutricalc-bmi";
import { numbers } from "../helper.numbers";
import { PageTitle } from "./layout";
import { ExternalLink } from "./shared/links";
import type { CalcResultWithExplanation } from "../types/calculator-types";
type NutriCalcBMIPropsFromRedux = {|
weight: number,
height: number,
round: boolean,
|};
type NutriCalcBMIReduxDispatchProps = {|
onWeightUpdate: (SyntheticEvent<HTMLInputElement>) => void,
onHeightUpdate: (SyntheticEvent<HTMLInputElement>) => void,
|};
/**
* Props for {@link NutriCalcBMI}
*/
type NutriCalcBMIProps = {|
...NutriCalcBMIReduxDispatchProps,
...NutriCalcBMIPropsFromRedux,
|};
/**
* Calculates the required calories per day for a patient
*/
class NutriCalcBMI extends React.PureComponent<NutriCalcBMIProps> {
/**
* Perform the calculation
*/
getResult(): CalcResultWithExplanation {
const descr = [];
let bmi: number = 0;
const heightM = numbers.conditionalRound(
this.props.height / 100,
this.props.round,
);
descr.push(
<CalcExplanationLine key="heightCM">
<CalcExplanationDescription>
Konverter CM til M
</CalcExplanationDescription>
<CalcExplanationCalculation>
<Fraction top={this.props.height} bottom="100" />
<FractionResult>= {heightM}</FractionResult>
</CalcExplanationCalculation>
<CalcExplanationFormula>
<Fraction top="CM" bottom="100" />
</CalcExplanationFormula>
</CalcExplanationLine>,
);
bmi = numbers.conditionalRound(
this.props.weight / (heightM * heightM),
this.props.round,
1,
);
descr.push(
<CalcExplanationLine key="bmi">
<CalcExplanationDescription>
Uterkning av BMI (kg/m²)
</CalcExplanationDescription>
<CalcExplanationCalculation>
<Fraction top={this.props.weight} bottom={heightM + "²"} />
<FractionResult>= {bmi}</FractionResult>
</CalcExplanationCalculation>
<CalcExplanationFormula>
<Fraction top="Vekt" bottom="Høyde × Høyde" />
</CalcExplanationFormula>
</CalcExplanationLine>,
);
return {
result: bmi,
description: <CalcExplanation>{descr}</CalcExplanation>,
};
}
/**
* Main rendering
*/
// eslint-disable-next-line require-jsdoc
render(): React.Node {
const result = this.getResult();
let interpretation: string;
let interpPrefix: string = "at pasienten er";
if (
Number.isNaN(result.result) ||
result.result === 0 ||
result.result === Infinity
) {
result.result = 0;
result.description = null;
} else if (result.result < 18.5) {
interpretation = "undervektig (18,4 og lågare)";
} else if (result.result < 25) {
interpretation = "normalvektig (18,5-24,9)";
} else if (result.result < 30) {
interpretation = "overvektig (25-29,9)";
} else {
interpPrefix = "at pasienten har";
if (result.result < 35) {
interpretation = "fedme, grad 1 (30-34,9)";
} else if (result.result < 40) {
interpretation = "fedme, grad 2 (35-39,9)";
} else {
interpretation = "fedme, grad 3 (40+)";
}
}
return (
<div>
<PageTitle title="Ernæringskalkulator - BMI" />
<Row>
<Col>
<h3>BMI</h3>
</Col>
</Row>
<Row>
<Col>
<h4>Pasientdata</h4>
</Col>
</Row>
<Form className="smallInputElements boldColLabels">
<Row>
<Label for="weight" xs="3" md="2">
Vekt
</Label>
<Col className="form-inline">
<Input
type="number"
min="1"
max="300"
className="mr-2"
value={this.props.weight}
onChange={(e) => {
this.props.onWeightUpdate(e);
}}
id="weight"
/>{" "}
kg
</Col>
</Row>
<Row>
<Label for="weight" xs="3" md="2">
Høyde
</Label>
<Col className="form-inline">
<Input
type="number"
min="1"
max="300"
className="mr-2"
value={this.props.height}
onChange={(e) => {
this.props.onHeightUpdate(e);
}}
id="height"
/>{" "}
cm
</Col>
</Row>
</Form>
<Row className="mt-4">
<Col>
<h4>Resultat</h4>
BMI er <b id="nutriCalcBMIResult">
{result.result}
</b>{" "}
kg/m².
<span
className={
result.result === 0 || result.result < 8
? "invisible"
: ""
}
>
{" "}
Det kan tolkast som {interpPrefix}{" "}
<span id="nutriCalcBMInterp">{interpretation}</span>
.
</span>
</Col>
</Row>
{result.description}
<Row className="text-secondary mt-4">
<Col>
<h5>Kjelde</h5>
<small>
Formelen og tolkinga er henta frå
Folkehelseinstituttet (2015).{" "}
<i>
<ExternalLink
className="text-secondary"
href="https://www.fhi.no/fp/overvekt/kroppsmasseindeks-kmi-og-helse/"
>
Kroppsmasseindeks (KMI) og helse.
</ExternalLink>
</i>{" "}
Oslo: Folkehelseinstituttet.
</small>
</Col>
</Row>
</div>
);
}
}
const NutriCalcBMIContainer: React.AbstractComponent<{||}> = connect<
NutriCalcBMIProps,
{||},
NutriCalcBMIPropsFromRedux,
NutriCalcBMIReduxDispatchProps,
_,
_,
>(
(state): NutriCalcBMIPropsFromRedux => {
return {
weight: state.nutriCalc.shared.weight,
height: state.nutriCalc.bmi.height,
round: state.global.round,
};
},
(dispatch): NutriCalcBMIReduxDispatchProps => {
return {
onWeightUpdate(ev: SyntheticEvent<HTMLInputElement>) {
const value = numbers.floatishInRangeFromThing(ev, 0, 400);
dispatch(setWeight(value));
},
onHeightUpdate(ev: SyntheticEvent<HTMLInputElement>) {
const value = numbers.floatishInRangeFromThing(ev, 0, 250);
dispatch(setHeight(value));
},
};
},
)(NutriCalcBMI);
export default NutriCalcBMIContainer;
|