-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
567 additions
and
492 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
WNPRC_EHR/resources/queries/study/Current Blood/.qview.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2016 LabKey Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
--this query is designed to return any dates when allowable blood draw volume changes | ||
--this includes dates of blood draws, plus the date those draws drop off | ||
PARAMETERS(DATE_INTERVAL INTEGER DEFAULT 30) | ||
|
||
SELECT | ||
b2.id, | ||
b2.status, | ||
b2.dateOnly, | ||
b2.quantity, | ||
DATE_INTERVAL as blood_draw_interval, | ||
TIMESTAMPADD('SQL_TSI_DAY', (-1 * DATE_INTERVAL), b2.dateOnly) as minDate, | ||
TIMESTAMPADD('SQL_TSI_DAY', DATE_INTERVAL, b2.dateOnly) as maxDate, | ||
|
||
FROM ( | ||
SELECT | ||
b.id, | ||
b.dateOnly, | ||
b.status, | ||
sum(b.quantity) as quantity | ||
|
||
FROM ( | ||
--find all blood draws within the interval, looking backwards | ||
SELECT | ||
b.id, | ||
b.qcstate as status, | ||
b.dateOnly, | ||
b.quantity, | ||
FROM study.blood b | ||
WHERE b.dateOnly > timestampadd('SQL_TSI_DAY', -1 * DATE_INTERVAL, curdate()) | ||
|
||
UNION ALL | ||
|
||
--join 1 row for the current date | ||
SELECT | ||
d1.id, | ||
null as status, | ||
curdate() as dateOnly, | ||
0 as quantity, | ||
FROM study.demographics d1 | ||
WHERE d1.calculated_status = 'Alive' | ||
|
||
UNION ALL | ||
|
||
--add one row for each date when the draw drops off the record | ||
SELECT | ||
b.id, | ||
null as status, | ||
timestampadd('SQL_TSI_DAY', DATE_INTERVAL, b.dateOnly), | ||
0 as quantity, | ||
FROM study.blood b | ||
WHERE timestampadd('SQL_TSI_DAY', DATE_INTERVAL, b.dateOnly) >= timestampadd('SQL_TSI_DAY', -1 * DATE_INTERVAL, curdate()) | ||
|
||
) b | ||
|
||
GROUP BY b.id, b.dateOnly, b.status | ||
) b2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
<query xmlns="http://labkey.org/data/xml/query"> | ||
<metadata> | ||
<tables xmlns="http://labkey.org/data/xml"> | ||
<table tableName="bloodSummary" tableDbType="NOT_IN_DB"> | ||
<columns> | ||
<column columnName="Lsid"> | ||
<isKeyField>true</isKeyField> | ||
<!--<isHidden>true</isHidden>--> | ||
</column> | ||
<column columnName="BloodLast30"> | ||
<columnTitle>Drawn in Previous 30 Days (inclusive)</columnTitle> | ||
<url>/query/executeQuery.view?schemaName=study& | ||
query.queryName=Blood Draws& | ||
query.viewName=Blood Summary& | ||
query.Id~eq=${Id}& | ||
query.Date~lte=${Date}& | ||
query.Date~gte=${minDate}& | ||
query.sort=-Date& | ||
</url> | ||
</column> | ||
<column columnName="BloodNext30"> | ||
<columnTitle>Scheduled in Next 30 Days (inclusive)</columnTitle> | ||
<url>/query/executeQuery.view?schemaName=study& | ||
query.queryName=Blood Draws& | ||
query.viewName=Blood Summary& | ||
query.Id~eq=${Id}& | ||
query.Date~gt=${Date}& | ||
query.sort=-Date& | ||
</url> | ||
</column> | ||
</columns> | ||
<titleColumn>BloodLast30</titleColumn> | ||
</table> | ||
</tables> | ||
</metadata> | ||
</query> | ||
<query xmlns="http://labkey.org/data/xml/query"> | ||
<metadata> | ||
<tables xmlns="http://labkey.org/data/xml"> | ||
<table tableName="bloodSummary" tableDbType="NOT_IN_DB"> | ||
<columns> | ||
<column columnName="Lsid"> | ||
<isKeyField>true</isKeyField> | ||
<!--<isHidden>true</isHidden>--> | ||
</column> | ||
<column columnName="BloodLast30"> | ||
<columnTitle>Drawn in Previous 30 Days (including today)</columnTitle> | ||
<url>/query/executeQuery.view?schemaName=study& | ||
query.queryName=Blood Draws& | ||
query.viewName=Blood Summary& | ||
query.Id~eq=${Id}& | ||
query.Date~lte=${Date}& | ||
query.Date~gte=${minDate}& | ||
query.sort=-Date& | ||
</url> | ||
</column> | ||
<column columnName="BloodNext30"> | ||
<columnTitle>Scheduled in Next 30 Days (excluding today)</columnTitle> | ||
<url>/query/executeQuery.view?schemaName=study& | ||
query.queryName=Blood Draws& | ||
query.viewName=Blood Summary& | ||
query.Id~eq=${Id}& | ||
query.Date~gt=${Date}& | ||
query.sort=-Date& | ||
</url> | ||
</column> | ||
</columns> | ||
<titleColumn>BloodLast30</titleColumn> | ||
</table> | ||
</tables> | ||
</metadata> | ||
</query> |
Oops, something went wrong.