-
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.
Updates to current blood draw queries and adding visual plot (#703)
* Add blood graph along with queries to support it, as well as new column for blood avail including thirty days in the future * exclude today for next 30 days calculation of blood, fix blood summary calc, adjust labels * use next 30 days since it does not include today * use ehr version * remove wnprc blood graph to use ehr instead * Consolidate blood draw reports into currentBloodDraws.sql, adjust references * ignore project type * group up the blood draws if they are done at the same time * Revert back to original AvailBlood calculation, add new calc for future draws in the new current blood report, fix ehr blood store so all records in transaction are used * update notification to revert to old blood avail name, use species as lookups for blood queries * restore demographicsBloodSummary query file * update test comments * restore old blood draw query --------- Co-authored-by: Marty Pradere <martyp@labkey.com>
- Loading branch information
1 parent
c5729d5
commit 8f9759d
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.