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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | 28x 28x 3x 25x 25x 25x 2x 25x 19x 25x 24x 1x 14x 14x 14x 14x 7x 7x 9x 7x 5x 7x 1x 7x 10x 10x 10x 1x 9x 1x 8x 8x 1x 7x 9x 4x 4x 4x 4x 2x 2x 2x 2x 7x 1x 7x 4x 7x 7x 7x 7x 1x 6x 2x 4x 6x 6x 2x 6x 6x 7x 9x 9x 5x 5x 4x 19x 8x 5x 12x 19x 7x 5x 1x 2x | /*
* Part of Pleiar.no - a collection of tools for nurses
*
* Copyright (C) Fagforbundet 2020
*
* 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 { PageTitle } from './layout';
import { ToolContainer } from './tools';
import { Row, Col, Input } from 'reactstrap';
import { connect } from 'react-redux';
import { setMedSynonymsSearchString } from '../actions/med-synonyms';
import { getValueFromLiteralOrEvent } from '../helper.general';
import { ConditionalRender } from './shared';
import MedSearcher from '../med-synonym-searcher';
import { ExternalLink } from './shared/links';
import type { medSynonymResult } from '../med-synonym-searcher';
type ATCCodeDispatchProps = {|
onSearchUpdate: (string) => void,
|};
type ATCCodeOwnProps = {|
atc?: string
|};
type ATCCodeProps = {|
...ATCCodeDispatchProps,
...ATCCodeOwnProps
|};
/**
* Renders a single ATC code
*/
class ATCCodeUnconnected extends React.PureComponent<ATCCodeProps>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { atc, onSearchUpdate } = this.props;
if(atc === undefined || atc === null || atc === "")
{
return [];
}
const pre = atc.substr(0,3);
const post = atc.substr(3);
const searchForATC = () =>
{
onSearchUpdate('ATC '+pre+' '+post);
};
return <span className="atc-code" onClick={ searchForATC }>
ATC {pre} {post}
</span>;
}
}
const ATCCode: React.AbstractComponent<ATCCodeOwnProps> = connect<ATCCodeProps,*,*,ATCCodeDispatchProps,*,*>(
() => { return {}; },
(dispatch): MedicationSynonymsSearchBarDispatchProps =>
{
return {
onSearchUpdate(ev: string)
{
dispatch(setMedSynonymsSearchString(getValueFromLiteralOrEvent(ev)));
}
};
}
)(ATCCodeUnconnected);
/**
* Renders a single result entry
*/
class MedicationSynonymsRenderSingleResult extends React.PureComponent<{|result: medSynonymResult|}>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { result } = this.props;
const synList: Array<React.Node> = [];
let merknad: ?React.Node;
let synStr: string = "Synonymer";
if(!result.synonyms || result.synonyms.length === 0)
{
return <Row><Col><b>{result.name}</b> (<ATCCode atc={result.atc} />) har ingen kjente synonympreparat</Col></Row>;
}
for(const synonym of result.synonyms)
{
synList.push(
<li key={synonym}>{synonym}</li>
);
}
if(result.synonyms.length == 1)
{
synStr = "Synonym";
}
if(result.notice)
{
merknad = <div className="merknad"><b className="text-danger">MERK:</b> {result.notice}</div>;
}
return <Row className="med-syn-result">
<Col>
<b className="med-syn-header">{result.name} (<ATCCode atc={result.atc} />)</b>
{merknad}
<Row>
<Col sm="3" lg="2">{synStr}:</Col>
<Col>
<ul>
{synList}
</ul>
</Col>
</Row>
</Col>
</Row>;
}
}
type MedicationSynonymsResultProps = {|
search: string
|};
/**
* The result renderer for medication synonyms
*/
class MedicationSynonymsResultUnconnected extends React.PureComponent<MedicationSynonymsResultProps>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { search } = this.props;
const renderedResults: Array<React.Node> = [];
if(search === undefined || search === null || search === "")
{
return <div />;
}
if(typeof(search) === "string" && search.length <= 2)
{
renderedResults.push(<div key="requires-result">Skriv minst to tegn for å få et resultat</div>);
}
else Eif(typeof(search) === "string")
{
if (MedSearcher.looksLikeATC( search ))
{
renderedResults.push(<MedicationSynonymsResultATC key="atcResult" search={search} />);
}
else
{
renderedResults.push(<MedicationSynonymsResultText key="textResult" search={search} />);
}
}
return <Row className="med-syn-result-list">
<Col>
{renderedResults}
</Col>
</Row>;
}
}
/**
* Result renderer for ATC searches
*/
class MedicationSynonymsResultATC extends React.PureComponent<MedicationSynonymsResultProps>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { search } = this.props;
const results = MedSearcher.atcSearch(search);
const renderedResults: Array<React.Node> = [];
if(results.list.length === 0)
{
const outputSearch = search.replace(/^ATC\s*:?\s*/,'');
renderedResults.push(<div key="no-hits">Ingen treff på ATC koden «{outputSearch}». Sjekk stavemåten, eventuelt prøv å søke på legemiddelnavn i stedenfor. Du kan bare søke etter fulle ATC koder (f.eks. N02AA01), du vil ikke få treff på deler av en ATC kode (f.eks. N02AA).</div>);
}
else
{
renderedResults.push(<Row key="warning">
<Col className="med-syn-atc-warning">
<b>Merk:</b> ATC kode ikke nødvendigvis er det samme som byttbarhet, da legemidler med samme ATC kode kan ha forskjellig styrke og legemiddelform (depot/vanlig tablett, mikstur/tablett). Sjekk med ordinerende lege før du bytter.
</Col>
</Row>);
for(const result of results.list)
{
let merknad: ?React.Node;
if(result.notice)
{
merknad = <div className="merknad"><b className="text-danger">MERK:</b> {result.notice}</div>;
}
renderedResults.push(<Row key={result.name}>
<Col>
{result.name} (<ATCCode atc={result.atc} />)
{merknad}
</Col>
</Row>);
}
}
return renderedResults;
}
}
/**
* Result renderer for cleartext searches
*/
class MedicationSynonymsResultText extends React.PureComponent<MedicationSynonymsResultProps>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const { search } = this.props;
const results = MedSearcher.search(search);
const renderedResults: Array<React.Node> = [];
if(results.length === 0)
{
renderedResults.push(<div key="no-hits">Ingen treff på «{search}». Sjekk at legemiddelet er stavet rett. Alternativt kan det være et legemiddel på godkjenningsfritak (disse er ikke i synonymlisten).</div>);
}
else
{
if(results.with.length > 0)
{
for(const result of results.with)
{
renderedResults.push( <MedicationSynonymsRenderSingleResult key={result.name} result={result} /> );
}
}
Eif(results.without.length > 0)
{
if(results.with.length > 0)
{
renderedResults.push(<h5 key="without">Legemiddel uten synonymer</h5>);
}
for(const result of results.without)
{
renderedResults.push( <MedicationSynonymsRenderSingleResult key={result.name} result={result} /> );
}
}
}
return renderedResults;
}
}
/**
* Wrapper around {@link MedicationSynonymsResultUnconnected} that loads the data if it's
* missing
*/
class MedicationSynonymsResultLoader extends React.PureComponent<MedicationSynonymsResultProps>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
const {search} = this.props;
if(search === undefined || search === null || search === "")
{
MedSearcher.initialize();
return <div />;
}
return <ConditionalRender component={MedicationSynonymsResultUnconnected} test={() => MedSearcher.hasInitialized()} resolve={() => MedSearcher.initialize()} {...this.props} />;
}
}
const MedicationSynonymsResult: React.AbstractComponent<{| |}> = connect<MedicationSynonymsResultProps,*,MedicationSynonymsResultProps,*,*,*>(
(state): MedicationSynonymsResultProps =>
{
return {
search: state.medSynonyms.search,
};
},
() => {return {};}
)(MedicationSynonymsResultLoader);
type MedicationSynonymsSearchBarStateProps = {|
search: string,
|};
type MedicationSynonymsSearchBarDispatchProps = {|
onSearchUpdate: (string) => void,
|};
type MedicationSynonymsSearchBarProps = {|
...MedicationSynonymsSearchBarDispatchProps,
...MedicationSynonymsSearchBarStateProps,
|};
/**
* The search bar for the medication synonyms page
*/
class MedicationSynonymsSearchBarUnconnected extends React.PureComponent<MedicationSynonymsSearchBarProps>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
return <Row>
<Col>
<Input placeholder="Søk" type="search" value={this.props.search} onChange={this.props.onSearchUpdate} name="search" id="medicationSynonymsSearch" />
</Col>
</Row>;
}
}
const MedicationSynonymsSearchBar: React.AbstractComponent<{| |}> = connect<MedicationSynonymsSearchBarProps,*,MedicationSynonymsSearchBarStateProps,MedicationSynonymsSearchBarDispatchProps,*,*>(
(state): MedicationSynonymsSearchBarStateProps =>
{
return {
search: state.medSynonyms.search,
};
},
(dispatch): MedicationSynonymsSearchBarDispatchProps =>
{
return {
onSearchUpdate(ev: string)
{
dispatch(setMedSynonymsSearchString(getValueFromLiteralOrEvent(ev)));
}
};
}
)(MedicationSynonymsSearchBarUnconnected);
/**
* The UI for querying the generic medication database
*/
class MedicationSynonyms extends React.PureComponent<{||}>
{
// eslint-disable-next-line require-jsdoc
render(): React.Node
{
return <ToolContainer tool="med-synonyms" requiresAuth={false}>
<PageTitle title="Synonymliste for medikament" />
<Row>
<Col lg={10}>
<Row>
<Col>
<h3>Synonymliste for medikament</h3>
</Col>
</Row>
<MedicationSynonymsSearchBar />
<Row>
<Col>
<small>Dette er et hjelpeverktøy. Du er selv ansvarlig for å sikre at bytter er forsvarlige og, hvis din organisasjon krever det, å få byttene godkjent av ordinerende lege.
Data hentet fra <ExternalLink href="https://legemiddelverket.no/andre-temaer/fest">forskrivnings- og ekspedisjonsstøtte (FEST)</ExternalLink> levert av <ExternalLink href="https://legemiddelverket.no/">Statens Legemiddelverk</ExternalLink></small>.
</Col>
</Row>
<MedicationSynonymsResult />
</Col>
</Row>
</ToolContainer>;
}
}
export default MedicationSynonyms;
// Test-only exports
export { MedicationSynonyms, MedicationSynonymsResult, MedicationSynonymsSearchBar, MedicationSynonymsSearchBarUnconnected, MedicationSynonymsResultLoader, MedicationSynonymsResultUnconnected, MedicationSynonymsRenderSingleResult, ATCCode, ATCCodeUnconnected, MedicationSynonymsResultATC, MedicationSynonymsResultText };
|