Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clinical data value casing #11281

Open
wants to merge 1 commit into
base: demo-rfc80-poc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Comment on lines 28 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably avoid modifying this method by reusing normalizeDataCounts. So, something like this after this line might be better.

var result = studyViewRepository.getClinicalDataCounts(context, filteredAttributes);

result.forEach(item -> item.setCounts(StudyViewColumnarServiceUtil.normalizeDataCounts(item.getCounts())));

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
Loading