Skip to content

Commit

Permalink
Allow original casing of clinical data values (but group them case in…
Browse files Browse the repository at this point in the history
…sensitive)
  • Loading branch information
alisman committed Dec 13, 2024
1 parent 540b57d commit 37a8acf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ public static List<ClinicalDataCountItem> mergeClinicalDataCounts(
) {
items.forEach(attr -> {
Map<String, List<ClinicalDataCount>> countsPerType = attr.getCounts().stream()
.collect(Collectors.groupingBy(ClinicalDataCount::getValue));
.collect(Collectors.groupingBy(a -> a.getValue().toLowerCase()));
List<ClinicalDataCount> res = countsPerType.entrySet().stream().map(entry -> {
ClinicalDataCount mergedCount = new ClinicalDataCount();
mergedCount.setAttributeId(attr.getAttributeId());
mergedCount.setValue(entry.getKey());
// we are just going to choose the value of the first item
// due to failure in data normalization in source files, we may find values
// have inconsistent casing. we choose to merge and choose an arbitrary casing
mergedCount.setValue(entry.getValue().stream().findFirst().get().getValue());
mergedCount.setCount(entry.getValue().stream().mapToInt(ClinicalDataCount::getCount).sum());
return mergedCount;
}).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
WITH clinical_data_query AS (
SELECT
attribute_name AS attributeId,
upper(attribute_value) AS value,
attribute_value AS value,
cast(count(*) AS INTEGER) as count
FROM clinical_data_derived
<where>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public void testMergeClinicalDataCounts() {
count1.setValue("value1");
count1.setCount(1);

// not that the caseing of the value is different
// our merge code should ignore that and choose the first item
ClinicalDataCount count2 = new ClinicalDataCount();
count2.setAttributeId("attr1");
count2.setValue("value1");
count2.setValue("VALUE1");
count2.setCount(2);

ClinicalDataCount count3 = new ClinicalDataCount();
Expand Down

0 comments on commit 37a8acf

Please sign in to comment.