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 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | 20x 20x 36x 36x 2x 34x 10x 10x 10x 3x 1x 2x 3x 2x 1x 3x 10x 4x 6x 10x 10x 9x 1x 10x 10x 10x 10x 10x 1x 10x 3x 3x 3x 6x 6x 6x 6x 2x 6x 3x 6x 6x 1x 6x 6x 1x 5x 1x 6x 1x 1x 1x 1x 1x 1x | /*
* Part of Pleiar.no - a collection of tools for nurses
*
* Copyright (C) Eskild Hustvedt 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 type { LabValueEntry as LabValueEntryType, LabValueDataStructure } from '../types/data';
import { Row, Col, Table } from 'reactstrap';
import slug from '../helper.slugs.js';
import { MobileAbbreviation, MobileAbbrWordDefinition } from './shared/abbrev';
/**
* The type for the LabValueGenericNotices object
*/
type LabValueNoticeType = {
[string]: string,
"refStringSpecial": {
[string]: string
}
};
/**
* A constant list of generic notices that apply to specific groups of
* lab values. This is used both when rendering a single cleartext element
* and when rendering tables.
*/
const LabValueGenericNotices: LabValueNoticeType = {
UrineHormone: "Vær oppmerksom på at konsentrasjonen av mange hormoner kan variere betydelig gjennom døgnet, gjennom menstruasjonssyklus og gjennom livet.",
UrineElectrolyte: "I urinen er utskillelsen av elektrolytter, urinstoff og urinsyre avhengig av kostholdet, og kan derfor variere sterkt.",
UrineGeneral: "Referanseverdiene per døgn er de som vanligvis finnes, og beregningene forutsetter at urinvolum og samletid er oppgitt.",
refStringGeneral: "Referanseområde",
refStringSpecial: {
"Klinisk farmakologi":"Terapeutisk område"
},
};
/**
* A constant list of "material shorthand" to "material full name" values.
* This is used both when rendering a single cleartext element and when
* rendering tables.
*/
const LabValueMaterialMap = {
'B':{
name: 'Fullblod',
description: 'Fullblod er for analyser som må utføres uten at blodet har blitt filtrert. Disse prøvene tas ofte på glass uten tilsetning.'
},
'E':{
name: 'Erytrocytter',
description: 'Erytrocytter er de røde blodcellene.',
},
'SP':{
name: 'Spinalvæske',
description: 'Spinalvæske er væsken som finnes innen for hjernehinnene. Kalles også for cerbrospinalvæske, forkortet CSF.',
},
'P':{
name: 'Plasma',
description: 'Plasma er den delen av blodet som er igjen når man har sentrifugert bort alle blodceller.',
},
'U':{
name: 'Urin',
description: 'En urinprøve kan f.eks. avdekke problemer med nyrene eller annen sykdom i urinveiene.',
},
'S':{
name: 'Serum',
description: 'Serum er blodet når alle blodceller (erytrocytter, leukocytter, blodplater) og koagulasjonsfaktorer er fjernet.',
},
'PT':{
name: 'Pasient',
description: 'Prøver hvor man må ha pasienten fysisk til stede for å ta. Dette kan f.eks. være hvis man skal måle hvor lang tid det tar før en person slutter å blø.',
},
};
/**
* A single element (field) for a cleartext rendering of a lab value
*/
class LabValueEntryCleartextElement extends React.PureComponent<{| title: string, value: string |}>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const {title,value} = this.props;
if (/\n/.test(value))
{
return <div><div className="labValueField">{title}:</div><div className="labValueLiteral">{value}</div></div>;
}
else
{
return <div><span className="labValueField">{title}:</span> {value}</div>;
}
}
}
/**
* A component that renders a single lab value to a text box
*/
class LabValueEntryCleartext extends React.PureComponent<{|entry: LabValueEntryType |}>
{
/**
* Method that adds notices from LabValueGenericNotices to the "merknad" field
* for a lab value, if needed.
*/
getMerknad (): React.Node | null
{
const { entry } = this.props;
let merknad: ?string = entry.merknad;
if(entry.materiale == "U")
{
if (merknad)
{
merknad += "\n";
}
else
{
merknad = "";
}
if (/Hormon/.test(entry.category))
{
merknad += LabValueGenericNotices.UrineHormone;
}
else
{
merknad += LabValueGenericNotices.UrineElectrolyte;
}
merknad += " "+LabValueGenericNotices.UrineGeneral;
}
if(merknad)
{
return <LabValueEntryCleartextElement title="Merknad" value={merknad} />;
}
return null;
}
/**
* Method that expands the material from the shorthand value to the full value
* using the LabValueMaterialMap.
*/
expandMaterial (): string
{
const { entry } = this.props;
if ( LabValueMaterialMap[ entry.materiale ] )
{
return LabValueMaterialMap[ entry.materiale ].name;
}
return entry.materiale;
}
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { entry } = this.props;
const merknad = this.getMerknad();
const material = this.expandMaterial();
let refString: string = "Referanseområde";
if(entry.category == "Klinisk farmakologi")
{
refString = "Terapeutisk område";
}
return <Row key={entry.navn} className="labValueEntry">
<Col>
<div className="labValueTitle" target="_blank">Laboratorieprøve: {entry.materiale}-{entry.navn}</div>
<LabValueEntryCleartextElement title="Materiale" value={material} />
<LabValueEntryCleartextElement title={refString} value={entry.ref} />
<span className="labValueSecondary">
<LabValueEntryCleartextElement title="Kategori" value={entry.category} />
{merknad}
</span>
</Col>
</Row>;
}
}
/**
* The props for LabValueTableRow
*/
type LabValueTableRowProps = {| entry: LabValueEntryType |};
/**
* Renders a single lab value as a table row
*/
class LabValueTableRow extends React.PureComponent<LabValueTableRowProps, {| tooltipVisible: boolean |}>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { entry } = this.props;
const expandedMaterial = LabValueMaterialMap[ entry.materiale ];
return <tr>
<td>{ entry.navn }</td>
<td>
<MobileAbbrWordDefinition mobileText={entry.materiale} fullText={expandedMaterial.name} definition={expandedMaterial.description} id={entry.navn+entry.materiale} />
</td>
<td>{ entry.ref }</td>
<td>{ entry.merknad }</td>
</tr>;
}
}
/**
* Renders a single category of lab values as a table, with messages from
* LabValueGenericNotices displayed above it, if needed.
*/
class LabValueCategoryTable extends React.PureComponent<{| values: LabValueDataStructure, category: string, inhibitTitle?: boolean |}>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { values, category } = this.props;
const entries = [];
let title: React.Node | null = <h3 id={slug.get(category)}>{category}</h3>;
if(this.props.inhibitTitle)
{
title = null;
}
for(const entryNo of values.index[category])
{
entries.push(<LabValueTableRow key={entryNo} entry={ values.values[entryNo] } />);
}
let refHeader: string = LabValueGenericNotices.refStringGeneral;
if ( LabValueGenericNotices.refStringSpecial[ category ] !== undefined )
{
refHeader = LabValueGenericNotices.refStringSpecial[ category ];
}
let notices: React.Node = null;
if(category == "Hormonanalyser i urin")
{
notices = <div>{LabValueGenericNotices.UrineHormone} {LabValueGenericNotices.UrineGeneral}</div>;
}
else if(category === "Klinisk kjemi i urin og spinalvæske")
{
notices = <div>{LabValueGenericNotices.UrineElectrolyte} {LabValueGenericNotices.UrineGeneral}</div>;
}
return <div className="LabValueTable">
{title}
{notices}
<Table hover responsive>
<thead>
<tr>
<th>Navn</th>
<th>
<span className="d-none d-md-block">Materiale</span>
<span className="d-md-none">
<MobileAbbreviation abbrev="Mat." full="Materiale" />
</span>
</th>
<th>{refHeader}</th>
<th>Merknad</th>
</tr>
</thead>
<tbody>
{entries}
</tbody>
</Table>
</div>;
}
}
/**
* Renders tables for each of the categories of lab values we have
*/
class LabValueTable extends React.PureComponent<{| values: LabValueDataStructure |}>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const renderTo = [];
const LabValues = this.props.values;
slug.reset();
for(const category in LabValues.index)
{
renderTo.push(<LabValueCategoryTable key={category} values={this.props.values} category={category} />);
}
return <div className="LabValueTables">
{renderTo}
</div>;
}
}
// Public exports
export { LabValueEntryCleartext, LabValueTable, LabValueCategoryTable };
// Testing exports
export { LabValueEntryCleartextElement, LabValueTableRow, LabValueMaterialMap };
|