Skip to content

Commit 5fac207

Browse files
committed
Add arrival record on MCC transfers
1 parent 5dc8748 commit 5fac207

4 files changed

Lines changed: 87 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="demographicsArrival" tableDbType="NOT_IN_DB">
5+
<columns>
6+
<column columnName="Id">
7+
<isKeyField>true</isKeyField>
8+
<isHidden>true</isHidden>
9+
</column>
10+
<column columnName="MostRecentArrival">
11+
<url>/query/executeQuery.view?schemaName=study&amp;
12+
query.queryName=arrival&amp;
13+
query.Id~eq=${Id}&amp;
14+
query.sort=-Date&amp;
15+
</url>
16+
</column>
17+
<column columnName="EarliestArrival">
18+
<url>/query/executeQuery.view?schemaName=study&amp;
19+
query.queryName=arrival&amp;
20+
query.Id~eq=${Id}&amp;
21+
query.sort=-Date&amp;
22+
</url>
23+
</column>
24+
<column columnName="Center_Arrival">
25+
<url>/query/executeQuery.view?schemaName=study&amp;
26+
query.queryName=arrival&amp;
27+
query.Id~eq=${Id}&amp;
28+
query.sort=-Date&amp;
29+
</url>
30+
<columnTitle>Arrival At Center</columnTitle>
31+
</column>
32+
</columns>
33+
<titleColumn>MostRecentArrival</titleColumn>
34+
</table>
35+
</tables>
36+
</metadata>
37+
</query>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2010-2019 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
SELECT
7+
d.Id AS Id,
8+
9+
T1.MostRecentArrival,
10+
11+
T2.EarliestArrival,
12+
13+
coalesce(T2.EarliestArrival, d.birth) as Center_Arrival
14+
15+
FROM study.demographics d
16+
17+
18+
--date of most recent arrival
19+
LEFT JOIN
20+
(select T1.Id, max(T1.date) as MostRecentArrival FROM study.arrival T1 WHERE T1.qcstate.publicdata = true GROUP BY T1.Id) T1
21+
ON (T1.Id = d.Id)
22+
23+
--date of first arrival
24+
LEFT JOIN
25+
(select T1.Id, min(T1.date) as EarliestArrival FROM study.arrival T1 WHERE T1.qcstate.publicdata = true GROUP BY T1.Id) T2
26+
ON (T2.Id = d.Id)

mcc/resources/referenceStudy/study/datasets/datasets_metadata.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@
558558
<column columnName="estimated">
559559
<datatype>boolean</datatype>
560560
</column>
561+
<column columnName="mccRequestId">
562+
<datatype>integer</datatype>
563+
</column>
561564
</columns>
562565
<tableTitle>Arrival</tableTitle>
563566
</table>

mcc/resources/web/mcc/window/MarkShippedWindow.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ Ext4.define('MCC.window.MarkShippedWindow', {
205205
schemaName: 'study',
206206
queryName: 'Demographics',
207207
filterArray: [LABKEY.Filter.create('lsid', lsids.join(';'), LABKEY.Filter.Types.IN)],
208-
columns: 'Id,gender,colony,species,birth,death,center,Id/MostRecentDeparture/MostRecentDeparture,Id/mccAlias/externalAlias,calculated_status,dam,sire,damMccAlias/externalAlias,sireMccAlias/externalAlias',
208+
columns: 'Id,gender,colony,species,birth,death,center,Id/MostRecentDeparture/MostRecentDeparture,Id/MostRecentArrival/MostRecentArrival,Id/mccAlias/externalAlias,calculated_status,dam,sire,damMccAlias/externalAlias,sireMccAlias/externalAlias',
209209
scope: this,
210210
failure: LDK.Utils.getErrorCallback(),
211211
success: function(results) {
@@ -245,6 +245,26 @@ Ext4.define('MCC.window.MarkShippedWindow', {
245245
});
246246
}
247247

248+
var shouldAddArrival = !row['Id/MostRecentArrival/MostRecentArrival'] ||
249+
row['Id/MostRecentArrival/MostRecentArrival'] !== Ext4.Date.format(row.effectiveDate, 'Y-m-d') ||
250+
row['Id/MostRecentArrival/mccRequestId'] !== requestId ||
251+
row.Id !== effectiveId;
252+
commands.push({
253+
command: 'insert',
254+
schemaName: 'study',
255+
containerPath: targetFolder,
256+
queryName: 'Arrival',
257+
rows: [{
258+
Id: row.Id,
259+
date: effectiveDate,
260+
source: row.colony,
261+
mccRequestId: requestId,
262+
qcstate: null,
263+
objectId: null,
264+
QCStateLabel: 'Completed'
265+
}]
266+
});
267+
248268
// If going to a new LK folder, we're creating a whole new record:
249269
if (targetFolderId.toUpperCase() !== LABKEY.Security.currentContainer.id.toUpperCase() || effectiveId !== row.Id) {
250270
commands.push({

0 commit comments

Comments
 (0)