Skip to content

Commit

Permalink
Fix - add removeDuplicateCodings implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
fongsean committed Aug 27, 2024
1 parent 9215d0c commit 0905378
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/smart-forms-renderer/src/utils/choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ export function findInAnswerOptions(
return;
}

/**
* Remove duplicate codings based on coding.code
*/
export function removeDuplicateCodings(codings: Coding[]): Coding[] {
const seenCodes = new Set();
return codings.filter((coding) => {
if (seenCodes.has(coding.code)) {
return false;
} else {
seenCodes.add(coding.code);
return true;
}
});
}

/**
* Compare answer option value with selected value via valueString, valueInteger, or valueCoding.code
*
Expand Down

0 comments on commit 0905378

Please sign in to comment.