function legacyKeyRespectingDecodeStatementForAttribute()

in src/plugins/coding.ts [116:147]


function legacyKeyRespectingDecodeStatementForAttribute(
  attribute: CodeableAttribute,
  secureCoding: boolean,
): string[] {
  const defaultDecodeStatement: string = decodeStatementForAttribute(
    attribute,
    secureCoding,
  );
  const decodeStatements: string[] = [defaultDecodeStatement];

  if (attribute.legacyKeyNames.length > 0) {
    const nilValueForAttribute: string = nilValueForType(attribute.type);
    if (nilValueForAttribute.length > 0) {
      const legacyDecodeStatements: string[] = FunctionUtils.flatMap(
        attribute.legacyKeyNames,
        (legacyKeyName) => {
          return decodeStatementForAttributeAndLegacyKey(
            attribute,
            nilValueForAttribute,
            legacyKeyName,
            secureCoding,
          );
        },
      );
      if (legacyDecodeStatements.length > 0) {
        return decodeStatements.concat(legacyDecodeStatements);
      }
    }
  }

  return decodeStatements;
}