From 90bf392223b2b2962865a2345dcf47b2b028d693 Mon Sep 17 00:00:00 2001 From: claudia1296 Date: Mon, 2 Aug 2021 15:37:29 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20clin-148=20fix=20age=20apparition=20non?= =?UTF-8?q?=20observ=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ClinicalInformation/index.jsx | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/client/src/components/screens/PatientSubmission/components/ClinicalInformation/index.jsx b/client/src/components/screens/PatientSubmission/components/ClinicalInformation/index.jsx index 4090d118..255c4b18 100644 --- a/client/src/components/screens/PatientSubmission/components/ClinicalInformation/index.jsx +++ b/client/src/components/screens/PatientSubmission/components/ClinicalInformation/index.jsx @@ -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, @@ -92,6 +93,7 @@ class ClinicalInformation extends React.Component { this.state = { hpoOptions: [], treeData: INITIAL_TREE_ROOTS, + hpoInterpretation: [], }; const { treeData } = this.state; @@ -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 (
@@ -185,7 +211,7 @@ class ClinicalInformation extends React.Component { size="small" dropdownClassName="selectDropdown" defaultValue={getHPOInterpretationCode(hpoResource)} - onChange={onChange} + onChange={onChangeInterpretation} > { hpoInterpretationValues().map((interpretation, index) => ( { hpoOnsetValues.map((group, gIndex) => (