Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #739 from Ferlab-Ste-Justine/fix/AgeApparition
Browse files Browse the repository at this point in the history
fix: clin-148 fix age apparition non observé
  • Loading branch information
claudia1296 authored Aug 3, 2021
2 parents c0e5742 + 90bf392 commit 9a94e5d
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import isEmpty from 'lodash/isEmpty';
import get from 'lodash/get';
import map from 'lodash/map';
import toArray from 'lodash/values';
import findIndex from 'lodash/findIndex';

import {
hpoOnsetValues,
Expand Down Expand Up @@ -92,6 +93,7 @@ class ClinicalInformation extends React.Component {
this.state = {
hpoOptions: [],
treeData: INITIAL_TREE_ROOTS,
hpoInterpretation: [],
};

const { treeData } = this.state;
Expand Down Expand Up @@ -158,6 +160,30 @@ class ClinicalInformation extends React.Component {
return '';
};
const { onChange } = this.props;
const { hpoInterpretation } = this.state;

const onChangeInterpretation = (e) => {
const hpoDisplay = getHPODisplay(hpoResource);
if (e === 'POS') {
this.setState({
hpoInterpretation: [...hpoInterpretation, hpoDisplay],
});
} if (hpoInterpretation.includes(hpoDisplay)) {
const indexObservedDisplay = hpoInterpretation.indexOf(hpoDisplay);
hpoInterpretation.splice(indexObservedDisplay, 1);
const hposForm = form.getFieldValue('hpos');
const indexHpos = findIndex(hposForm, { display: hpoDisplay });
const hpoElement = hposForm[indexHpos];
delete hpoElement.onset;
hposForm.splice(indexHpos, 1, hpoElement);
form.setFieldsValue({ hpos: hposForm });
this.setState({
hpoInterpretation,
});
}
onChange();
};

return (
<div key={hpoResource.valueCodeableConcept.coding[0].code} className="phenotypeBlock">
<div className="phenotypeFirstLine">
Expand Down Expand Up @@ -185,7 +211,7 @@ class ClinicalInformation extends React.Component {
size="small"
dropdownClassName="selectDropdown"
defaultValue={getHPOInterpretationCode(hpoResource)}
onChange={onChange}
onChange={onChangeInterpretation}
>
{ hpoInterpretationValues().map((interpretation, index) => (
<Select.Option
Expand All @@ -209,6 +235,7 @@ class ClinicalInformation extends React.Component {
dropdownClassName="selectDropdown"
defaultValue={getHPOOnsetCode(hpoResource)}
onChange={onChange}
disabled={!hpoInterpretation.includes(getHPODisplay(hpoResource))}
>
{
hpoOnsetValues.map((group, gIndex) => (
Expand Down

0 comments on commit 9a94e5d

Please sign in to comment.