if (existingObs != null) {
commentFieldWidget.setInitialValue(existingObs.getComment());
}
}
ObsField field = new ObsField();
field.setName(valueLabel);
if (concept != null) {
field.setQuestion(concept);
} else if (concepts != null && concepts.size() > 0) { //for concept selects
for (int i = 0; i < concepts.size(); i++) {
ObsFieldAnswer ans = new ObsFieldAnswer();
ans.setConcept(concepts.get(i));
if (i < conceptLabels.size()) {
ans.setDisplayName(conceptLabels.get(i));
}
field.getQuestions().add(ans);
}
}
if (answerConcept != null) {
ObsFieldAnswer ans = new ObsFieldAnswer();
ans.setDisplayName(getAnswerLabel());
ans.setConcept(answerConcept);
field.setAnswers(Arrays.asList(ans));
} else if (conceptAnswers != null) {
for (int i = 0; i < conceptAnswers.size(); i++) {
ObsFieldAnswer ans = new ObsFieldAnswer();
ans.setConcept(conceptAnswers.get(i));
if (i < answerLabels.size()) {
ans.setDisplayName(answerLabels.get(i));
}
field.getAnswers().add(ans);
}
}
//conceptSelects should be excluded from obsGroup matching, because there's nothing to match on.
if (concept != null && context.getActiveObsGroup() != null) {
context.getActiveObsGroup().getChildren().add(field);