function findOptionInChoice(choice, optionId, dataElementSpecs) {
  // First look for a direct match
  for (const option of choice.aggregateOptions) {
    if (optionId.equals(option.identifier)) {
      return option;
    }
  }
  // Then look for a match on one of the selected options's base types
  // E.g., if choice has Quantity but selected option is IntegerQuantity
  for (const option of choice.aggregateOptions) {
    if (checkHasBaseType(optionId, option.identifier, dataElementSpecs)) {
      return option;
    }
  }
  return null;
}
function findOptionInChoice(choice, optionId, dataElementSpecs) {
  // First look for a direct match
  for (const option of choice.aggregateOptions) {
    if (optionId.equals(option.identifier)) {
      return option;
    }
  }
  // Then look for a match on one of the selected options's base types
  // E.g., if choice has Quantity but selected option is IntegerQuantity
  for (const option of choice.aggregateOptions) {
    if (checkHasBaseType(optionId, option.identifier, dataElementSpecs)) {
      return option;
    }
  }
  return null;
}
function findOptionInChoice ( choice , optionId , dataElementSpecs ) { // First look for a direct match for ( const option of choice . aggregateOptions ) { if ( optionId . equals ( option . identifier ) ) { return option ; } } // Then look for a match on one of the selected options's base types // E.g., if choice has Quantity but selected option is IntegerQuantity for ( const option of choice . aggregateOptions ) { if ( checkHasBaseType ( optionId , option . identifier , dataElementSpecs ) ) { return option ; } } return null ; }
Searches the aggregate options of a choice for the specified option.

@param {ChoiceValue} choice - the choice to evaluate.
@param {Identifier} optionId - the identifier to find in the choice.
@param {DataElementSpecifications} dataElementSpecs - The available DataElement specs.
@returns {Value?} The first option in the choice that matches the specified optionId.
Searches the aggregate options of a choice for the specified option .