Skip to content

Commit

Permalink
Merge 24.12 to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-teamcity committed Dec 11, 2024
2 parents 1fafd91 + 95ee850 commit 41f7769
Show file tree
Hide file tree
Showing 13 changed files with 567 additions and 492 deletions.
113 changes: 0 additions & 113 deletions WNPRC_EHR/resources/queries/study/Current Blood.sql

This file was deleted.

42 changes: 0 additions & 42 deletions WNPRC_EHR/resources/queries/study/Current Blood/.qview.xml

This file was deleted.

71 changes: 71 additions & 0 deletions WNPRC_EHR/resources/queries/study/bloodDrawChanges.sql
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
72 changes: 36 additions & 36 deletions WNPRC_EHR/resources/queries/study/bloodSummary.query.xml
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&amp;
query.queryName=Blood Draws&amp;
query.viewName=Blood Summary&amp;
query.Id~eq=${Id}&amp;
query.Date~lte=${Date}&amp;
query.Date~gte=${minDate}&amp;
query.sort=-Date&amp;
</url>
</column>
<column columnName="BloodNext30">
<columnTitle>Scheduled in Next 30 Days (inclusive)</columnTitle>
<url>/query/executeQuery.view?schemaName=study&amp;
query.queryName=Blood Draws&amp;
query.viewName=Blood Summary&amp;
query.Id~eq=${Id}&amp;
query.Date~gt=${Date}&amp;
query.sort=-Date&amp;
</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&amp;
query.queryName=Blood Draws&amp;
query.viewName=Blood Summary&amp;
query.Id~eq=${Id}&amp;
query.Date~lte=${Date}&amp;
query.Date~gte=${minDate}&amp;
query.sort=-Date&amp;
</url>
</column>
<column columnName="BloodNext30">
<columnTitle>Scheduled in Next 30 Days (excluding today)</columnTitle>
<url>/query/executeQuery.view?schemaName=study&amp;
query.queryName=Blood Draws&amp;
query.viewName=Blood Summary&amp;
query.Id~eq=${Id}&amp;
query.Date~gt=${Date}&amp;
query.sort=-Date&amp;
</url>
</column>
</columns>
<titleColumn>BloodLast30</titleColumn>
</table>
</tables>
</metadata>
</query>
Loading

0 comments on commit 41f7769

Please sign in to comment.