Skip to content

Nested Criteria 'index message' is not updating #2850

Description

@chrisknoll

Expected behavior

When you set the concept set on the 'root' criteria object, the nested criteria should say 'index is based on {concept set name}'

Actual behavior

It defaults to 'any condition' (for example), and never changes.

Steps to reproduce behavior

  1. Create Cohort Definition
  2. Add Condition Occurrence criteria
  3. Add Nested Criteria
  4. Change Root Condition Occurrence criteria to a new concept set.
  5. Observe: nested criteria says 'index based on 'any condition'.

Solution

This is due to the lack of an observable being used in the view model. This is correctly implemented in ConditionEra, but not ConditionOccurrence.

Bad Code:

    self.indexMessage = ko.i18nformat(
      'components.conditionOccurrence.indexDataText',
      'The index date refers to the condition occurrence of <%= conceptSetName %>.',
      {
        conceptSetName: utils.getConceptSetName(
          self.Criteria.CodesetId,
          self.expression.ConceptSets,
          ko.i18n('components.conditionOccurrence.anyCondition', 'Any Condition')
        ),
      }
    );

Working Code:

    self.indexMessage = ko.pureComputed(() => {
      var anyCondition = ko.i18n('components.conditionEra.anyConditionButton', 'Any Condition');
      var message = ko.i18n('components.conditionEra.returnText_1', 'The index date refers to the condition era of');
      var conceptSetName = utils.getConceptSetName(
        self.Criteria.CodesetId,
        self.expression.ConceptSets,
        anyCondition()
      );
      return `${message()} ${conceptSetName}.`;
    });

The difference is the indexMessage is a computed observable that pulls in the value from the i18n and the concept set name. The bad code is returning the result of an ko.i18n result, which may be observable, but only changes when the localization changes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions