Skip to content

Commit b0eaca5

Browse files
committed
Expand MCC weight precision
1 parent a7f0747 commit b0eaca5

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

mcc/resources/queries/study/demographicsMostRecentWeight.query.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
query.queryName=Weight&
1414
query.id~eq=${id}
1515
</url>
16-
<formatString>0.##</formatString>
16+
<formatString>0.####</formatString>
1717
</column>
1818
<column columnName="MostRecentWeightGrams">
1919
<columnTitle>Current Weight (g)</columnTitle>

mcc/resources/queries/study/demographicsMostRecentWeight.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ timestampdiff('SQL_TSI_DAY', w.MostRecentWeightDate, now()) AS DaysSinceWeight,
1212
null as weightField,
1313
--NOTE: we need to be careful in case duplicate weights are entered on the same time
1414
cast((
15-
SELECT round(cast(AVG(w2.weight) as double), 2) AS _expr
15+
SELECT round(cast(AVG(w2.weight) as double), 4) AS _expr
1616
FROM study.weight w2
1717
WHERE w.id=w2.id AND w.MostRecentWeightDate=w2.date
1818
) as double) AS MostRecentWeight,

mcc/resources/queries/study/weight.query.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
</fk>
3939
</column>
4040
<column columnName="weight">
41-
<columnTitle>Weight (kg)</columnTitle>
42-
<formatString>0.###</formatString>
41+
<columnTitle>Weight (kg)</columnTitle>
42+
<formatString>0.####</formatString>
4343
</column>
4444
</columns>
4545
</table>

mcc/src/org/labkey/mcc/notification/MCCDataNotification.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import org.labkey.mcc.MccManager;
1515

1616
import java.util.Date;
17-
import java.util.HashMap;
18-
import java.util.Map;
1917

2018
/**
2119
* User: bimber
@@ -81,6 +79,7 @@ public String getMessageBodyHTML(Container c, User u)
8179
doU24AssignedCheck(mccData, u , msg);
8280
doMissingIdCheck(mccData, u, msg);
8381
doZeroWeightCheck(mccData, u, msg);
82+
doDuplicationCheck(mccData, u, msg);
8483

8584
//since we dont want to trigger an email if there's no alerts, conditionally append the title
8685
if (msg.length() > 0)
@@ -174,4 +173,37 @@ protected void doParentSexCheck(final Container c, User u, final StringBuilder m
174173
msg.append("<hr>\n\n");
175174
}
176175
}
176+
177+
protected void doDuplicationCheck(final Container c, User u, final StringBuilder msg)
178+
{
179+
TableInfo ti = getUserSchemaByName(c, u, "mcc").getTable("duplicateDemographics");
180+
TableSelector ts = new TableSelector(ti);
181+
long count = ts.getRowCount();
182+
if (count > 0)
183+
{
184+
msg.append("<b>WARNING: There are ").append(count).append(" demographics records with duplicated MCC IDs\n");
185+
msg.append("<p><a href='").append(getExecuteQueryUrl(c, "mcc", "duplicateDemographics", null)).append("'>Click here to view them</a><br>\n\n");
186+
msg.append("<hr>\n\n");
187+
}
188+
189+
ti = getUserSchemaByName(c, u, "mcc").getTable("duplicatedAggregatedDemographics");
190+
ts = new TableSelector(ti);
191+
count = ts.getRowCount();
192+
if (count > 0)
193+
{
194+
msg.append("<b>WARNING: There are ").append(count).append(" aggregated demographics records with duplicated MCC IDs\n");
195+
msg.append("<p><a href='").append(getExecuteQueryUrl(c, "mcc", "duplicatedAggregatedDemographics", null)).append("'>Click here to view them</a><br>\n\n");
196+
msg.append("<hr>\n\n");
197+
}
198+
199+
ti = getUserSchemaByName(c, u, "mcc").getTable("duplicatedAggregatedDemographicsParents");
200+
ts = new TableSelector(ti);
201+
count = ts.getRowCount();
202+
if (count > 0)
203+
{
204+
msg.append("<b>WARNING: There are ").append(count).append(" aggregated demographics parent records with duplicated MCC IDs\n");
205+
msg.append("<p><a href='").append(getExecuteQueryUrl(c, "mcc", "duplicatedAggregatedDemographicsParents", null)).append("'>Click here to view them</a><br>\n\n");
206+
msg.append("<hr>\n\n");
207+
}
208+
}
177209
}

0 commit comments

Comments
 (0)