Skip to content

Commit

Permalink
#736 | Support Subject form elements in repeatable question group
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed Feb 3, 2023
1 parent faeac2f commit aead314
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import DurationDateFormElement from "./DurationDateFormElement";
import DurationFormElement from "./DurationFormElement";
import MultiSelectMediaFormElement from "./MultiSelectMediaFormElement";
import PhoneNumberFormElement from "./PhoneNumberFormElement";
import SingleSelectSubjectLandingFormElement from './SingleSelectSubjectLandingFormElement';
import MultiSelectSubjectLandingFormElement from './MultiSelectSubjectLandingFormElement';

class QuestionGroup extends AbstractFormElement {
static propTypes = {
Expand Down Expand Up @@ -95,6 +97,11 @@ class QuestionGroup extends AbstractFormElement {
return _.isNil(observation) ? nullReplacement : observation.getValueWrapper();
}

getSelectedAnswerFromObservationHolder(concept, element, questionGroupIndex, nullReplacement) {
const observation = this.props.observationHolder.findQuestionGroupObservation(concept, element, questionGroupIndex);
return _.isNil(observation) ? nullReplacement : observation.getValueWrapper();
}

renderTextFormElement(formElement) {
return <TextFormElement
key={formElement.concept.uuid}
Expand Down Expand Up @@ -140,6 +147,7 @@ class QuestionGroup extends AbstractFormElement {
actionName: this.props.actionName,
validationResult: validationResult,
parentElement: this.props.element,
parentFormElement: this.props.element,
questionGroupIndex: this.props.questionGroupIndex
};
const dataType = concept.datatype;
Expand Down Expand Up @@ -214,6 +222,20 @@ class QuestionGroup extends AbstractFormElement {
observation={this.props.observationHolder.findQuestionGroupObservation(fe.concept, this.props.element, this.props.questionGroupIndex)}
{...commonProps}/>
}
if (dataType === dataTypes.Subject && fe.isSingleSelect()) {
return <SingleSelectSubjectLandingFormElement
element={fe}
value={this.getSelectedAnswerFromObservationHolder(fe.concept, this.props.element, this.props.questionGroupIndex, new SingleCodedValue())}
{...commonProps}
/>
}
if (dataType === dataTypes.Subject && fe.isMultiSelect()) {
return <MultiSelectSubjectLandingFormElement
element={fe}
value={this.getSelectedAnswerFromObservationHolder(fe.concept, this.props.element, this.props.questionGroupIndex, new MultipleCodedValues())}
{...commonProps}
/>
}
})}
</Fragment>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class SubjectFormElement extends AbstractFormElement {
this.dispatchAction(this.props.actionName, {
formElement: this.props.element,
answerUUID: subjectUUID,
parentFormElement: this.props.parentElement,
questionGroupIndex: this.props.questionGroupIndex,
});
}

Expand All @@ -80,6 +82,8 @@ class SubjectFormElement extends AbstractFormElement {
this.dispatchAction(this.props.actionName, {
formElement: this.props.element,
answerUUID: individual.uuid,
parentFormElement: this.props.parentElement,
questionGroupIndex: this.props.questionGroupIndex,
});
}
}).to(IndividualSearchView, true);
Expand Down

0 comments on commit aead314

Please sign in to comment.