Skip to content

Commit

Permalink
normalize clinical data
Browse files Browse the repository at this point in the history
  • Loading branch information
onursumer committed Aug 15, 2024
1 parent d62c6e5 commit 383de6f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,20 @@
</if>
</trim>
</foreach>

</sql>

<sql id="categoricalClinicalDataCountFilter">
SELECT ${unique_id}
FROM ${table_name}
WHERE attribute_name = '${clinicalDataFilter.attributeId}' AND
type='${type}'
<foreach item="dataFilterValue" collection="clinicalDataFilter.values" open=" AND ((" separator=") OR (" close="))">
<trim prefix="" prefixOverrides="AND">
AND attribute_value = '${dataFilterValue.value}'
AND (
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="attribute_value"/>
</include>
) = '${dataFilterValue.value}'
</trim>
</foreach>
</sql>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,9 @@
<sql id="getClinicalDataCountsQuerySample">
SELECT
attribute_name as attributeId,
<include refid="normalizeAttributeValueNA">
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="attribute_value"/>
<property name="as_value" value="value"/>
</include>,
</include> as value,
count(value) as count
FROM clinical_data_derived
<where>
Expand All @@ -197,10 +196,9 @@
<sql id="getClinicalDataCountsQueryPatient">
SELECT
attribute_name as attributeId,
<include refid="normalizeAttributeValueNA">
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="attribute_value"/>
<property name="as_value" value="value"/>
</include>,
</include> as value,
count(value) as count
FROM clinical_data_derived
<where>
Expand Down Expand Up @@ -524,15 +522,30 @@
OR upperUTF8(${attribute_value})='NAN'
OR upperUTF8(${attribute_value})='N/A'
</sql>

<!-- This is to match boolean values ignoring the case -->
<sql id="isAttributeValueTrue">
upperUTF8(${attribute_value})='TRUE'
</sql>
<sql id="isAttributeValueFalse">
upperUTF8(${attribute_value})='FALSE'
</sql>

<sql id="normalizeAttributeValueNA">
if(
<include refid="isAttributeValueNA">
<sql id="normalizeAttributeValue">
multiIf(
<include refid="isAttributeValueNA">
<property name="attribute_value" value="${attribute_value}"/>
</include>,
'NA',
${attribute_value}
</include>,
'NA',
<include refid="isAttributeValueTrue">
<property name="attribute_value" value="${attribute_value}"/>
</include>,
'True',
<include refid="isAttributeValueFalse">
<property name="attribute_value" value="${attribute_value}"/>
</include>,
'False',
${attribute_value}
)
AS ${as_value}
</sql>
</mapper>

0 comments on commit 383de6f

Please sign in to comment.