Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion IDR/resources/queries/bimber_data/idrAnchorDateSource.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PID0 as date,

FROM bimber_data.subjects
WHERE PID0 IS NOT NULL
AND Cohort NOT IN ('PC549', 'PC585', 'PC529') AND Cohort NOT LIKE 'W%'

UNION ALL

Expand All @@ -18,4 +19,5 @@ D0 as date,
'Hansen/IDR' as dataSource

FROM bimber_data.subjects
WHERE D0 IS NOT NULL
WHERE D0 IS NOT NULL
AND Cohort NOT IN ('PC549', 'PC585', 'PC529') AND Cohort NOT LIKE 'W%'
3 changes: 2 additions & 1 deletion IDR/resources/queries/bimber_data/idrOutcomeSource.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ END as outcome,
'Hansen/IDR' as dataSource

FROM bimber_data.subjects
WHERE contprog IS NOT NULL AND contprog != ''
WHERE contprog IS NOT NULL AND contprog != ''
AND Cohort NOT IN ('PC549', 'PC585', 'PC529') AND Cohort NOT LIKE 'W%'
2 changes: 1 addition & 1 deletion SivStudies/resources/etls/idr-data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<setting name="dataSourceColumns" value="Rh,PID0"/>
<setting name="dataSourceColumnMapping" value="Rh=Id,PID0=date"/>
<setting name="dataSourceColumnDefaults" value="dataSource=Hansen/IDR;category=SIV Infection;treatment=SIV - Unknown"/>
<setting name="dataSourceAdditionalFilters" value="PID0~isnonblank="/>
<setting name="dataSourceAdditionalFilters" value="PID0~isnonblank=;Cohort~neqornull=PC549;Cohort~neqornull=PC585;Cohort~neqornull=W1170;Cohort~neqornull=W1173;Cohort~neqornull=PC529"/>

<setting name="targetSchema" value="study"/>
<setting name="targetQuery" value="treatments"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<customView xmlns="http://labkey.org/data/xml/queryCustomView" hidden="false" canOverride="false">
<columns>
<column name="Id"/>
<column name="sex"/>
<column name="projects/allStudies"/>
<column name="projects/studyDescription"/>
<column name="projects/subgroups"/>
<column name="projects/analysisGroups"/>
<column name="immunizations/immunizations"/>
<column name="sivART/allInfections"/>
<column name="sivART/ageAtInfection"/>
<column name="sivART/allART"/>
<column name="sivART/artInitiationDPI"/>
<column name="sivART/artReleaseWPI"/>
<column name="interventions/allInterventions"/>
<column name="interventions/firstInterventionDPI"/>
<column name="interventions/firstInterventionPostArtReleaseWeeks"/>
<column name="pvlInfo/numPVL"/>
<column name="pvlInfo/numPVLPostArtRelease"/>
<column name="pvlInfo/lastPvlPostArtReleaseWeeks"/>
</columns>
<sorts>
<sort column="Id" descending="false"/>
</sorts>
</customView>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<customView xmlns="http://labkey.org/data/xml/queryCustomView" hidden="false" canOverride="false">
<columns>
<column name="Id"/>
<column name="sex"/>
<column name="projects/allStudies"/>
<column name="projects/studyDescription"/>
<column name="projects/subgroups"/>
<column name="projects/analysisGroups"/>
<column name="immunizations/immunizations"/>
<column name="sivART/allInfections"/>
<column name="sivART/infectionDate"/>
<column name="sivART/ageAtInfection"/>
<column name="sivART/allART"/>
<column name="interventions/allInterventions"/>
<column name="interventions/firstInterventionDPI"/>
<column name="pvlInfo/numPVL"/>
</columns>
<sorts>
<sort column="Id" descending="false"/>
</sorts>
</customView>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<column name="sex"/>
<column name="species"/>
<column name="calculated_status"/>
<column name="birth"/>
<column name="death"/>
<column name="sivART/ageAtInfection"/>
<column name="projects/allStudies"/>
<column name="projects/studyDescription"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<column name="sex"/>
<column name="species"/>
<column name="calculated_status"/>
<column name="projects/categories"/>
<column name="projects/studyDescription"/>
<column name="projects/allStudies"/>
<column name="projects/subgroups"/>
<column name="sivART/allInfections"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
<columnTitle>SIV Infection</columnTitle>
<url>/query/executeQuery.view?schemaName=study&amp;query.queryName=treatments&amp;query.Id~eq=${Id}&amp;query.category~eq=SIV Infection</url>
<urlTarget>_blank</urlTarget>
<displayWidth>150</displayWidth>
</column>
<column columnName="allART">
<columnTitle>ART</columnTitle>
<columnTitle>ART Regimen</columnTitle>
<url>/query/executeQuery.view?schemaName=study&amp;query.queryName=treatments&amp;query.Id~eq=${Id}&amp;query.category~eq=ART</url>
<urlTarget>_blank</urlTarget>
<displayWidth>175</displayWidth>
</column>
<column columnName="infectionDate">
<columnTitle>Infection Date</columnTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ FROM (
SELECT
t.Id,
group_concat(DISTINCT CASE
WHEN t.category = 'SIV Infection' THEN (cast(month(t.date) as varchar) || '/' || cast(dayofmonth(t.date) as varchar) || '/' || cast(year(t.date) as varchar) || ' (' || t.treatment || ')')
WHEN t.category = 'SIV Infection' THEN (t.treatment || (CASE WHEN t.route IS NULL then '' ELSE (', ' || t.route) END) || (CASE WHEN t.amount IS NULL then '' ELSE (', ' || CAST(t.amount as VARCHAR) || ' ' || t.amount_units) END))
ELSE NULL
END, char(10)) as allInfections,
min(floor(age(t.DataSets.Demographics.birth, CASE WHEN t.category = 'SIV Infection' THEN t.date ELSE NULL END))) AS ageAtInfection,

group_concat(DISTINCT CASE
WHEN t.category = 'ART' THEN (cast(month(t.date) as varchar) || '/' || cast(dayofmonth(t.date) as varchar) || '/' || cast(year(t.date) as varchar) || ' (' || t.treatment || ')')
WHEN t.category = 'ART' THEN (t.treatment || ' (' || COALESCE(t.timePostSivChallenge.timePostInfection, 'Unk DPI') || ')')
ELSE NULL
END, char(10)) as allART,
min(CASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<column columnName="firstInterventionWPI">
<columnTitle>First Intervention (WPI)</columnTitle>
</column>
<column columnName="firstInterventionPostArtReleaseWeeks">
<columnTitle>First Intervention Relative to ART Release (Weeks)</columnTitle>
</column>
</columns>
<titleColumn>allInterventions</titleColumn>
</table>
Expand Down
22 changes: 6 additions & 16 deletions SivStudies/resources/queries/study/demographicsInterventions.sql
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
SELECT
t.Id,
group_concat(DISTINCT CASE
WHEN t.category = 'Intervention' THEN (t.treatment || ' (' || t.timePostSivChallenge.timePostInfection || ')')
ELSE NULL
END, char(10)) as allInterventions,
min(CASE
WHEN t.category = 'Intervention' THEN t.date
ELSE NULL
END) as firstInterventionDate,
min(CASE
WHEN t.category = 'Intervention' THEN t.timePostSivChallenge.daysPostInfection
ELSE NULL
END) as firstInterventionDPI,
min(CASE
WHEN t.category = 'Intervention' THEN t.timePostSivChallenge.weeksPostInfection
ELSE NULL
END) as firstInterventionWPI
group_concat(DISTINCT (t.treatment || ' (' || COALESCE(t.timePostSivChallenge.timePostInfection, 'Unk DPI') || ')'), char(10)) as allInterventions,
min(t.date) as firstInterventionDate,
min(t.timePostSivChallenge.daysPostInfection) as firstInterventionDPI,
min(t.timePostSivChallenge.weeksPostInfection) as firstInterventionWPI,
min(t.timePostSivChallenge.weeksPostInfection) - min(t.sivART.artReleaseWPI) as firstInterventionPostArtReleaseWeeks
FROM study.treatments t
WHERE t.category = 'Intervention'
GROUP BY t.Id
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@
<columnTitle>Study Categories</columnTitle>
</column>
<column columnName="allStudies">
<columnTitle>All Studies</columnTitle>
<columnTitle>Studies</columnTitle>
<url>/query/executeQuery.view?schemaName=study&amp;query.queryName=assignment&amp;query.Id~eq=${Id}</url>
<urlTarget>_blank</urlTarget>
</column>
<column columnName="allStudiesAndAnalyses">
<columnTitle>Studies and Analyses</columnTitle>
</column>
<column columnName="analysisGroups">
<columnTitle>Analysis Groups</columnTitle>
<displayWidth>150</displayWidth>
</column>
<column columnName="subgroups">
<columnTitle>Subgroups/Treatments</columnTitle>
Expand Down
4 changes: 3 additions & 1 deletion SivStudies/resources/queries/study/demographicsProjects.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
SELECT
s.Id,
count(s.Id) as totalProjects,
group_concat(DISTINCT s.study, char(10)) as allStudies,
group_concat(DISTINCT s.study, char(10)) as allStudiesAndAnalyses,
group_concat(DISTINCT CASE WHEN s.category = 'Analysis Cohorts' THEN NULL ELSE s.study END, char(10)) as allStudies,
group_concat(DISTINCT CASE WHEN s.category = 'Analysis Cohorts' THEN s.study ELSE NULL END, char(10)) as analysisGroups,
group_concat(DISTINCT s.cohortId.studyId.description, char(10)) as studyDescription,
group_concat(DISTINCT s.category, char(10)) as categories,
group_concat(DISTINCT s.subgroup, char(10)) as subgroups
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
SELECT
t.Id,
coalesce(t.Id, t2.subjectId) as Id,
'SIV Infection' as category,
t.date as treatmentTableDate,
t2.date as subjectAnchorDatesTableDate

FROM study.treatments t
FULL JOIN studies.subjectAnchorDates t2 ON (
t.category = 'SIV Infection' AND
t2.subjectId = t.Id AND
t2.eventLabel = 'SIV Infection'
t.category = t2.eventLabel AND
t2.subjectId = t.Id
)

WHERE t2.date != t.date OR
WHERE (t2.date != t.date OR
t2.date IS NULL OR
t.date IS NULL
t.date IS NULL) AND COALESCE(t.category, t2.eventLabel) = 'SIV Infection'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="missingAnchorDates" tableDbType="TABLE" useColumnOrder="true">
<tableTitle>Missing Anchor Dates</tableTitle>
</table>
</tables>
</metadata>
</query>
30 changes: 30 additions & 0 deletions SivStudies/resources/queries/study/missingAnchorDates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
SELECT
dc.Id as SubjectId,
dc.infectionDate as date,
'SIV Infection' as eventLabel

FROM study.demographicsChallengeAndArt dc
LEFT JOIN studies.subjectAnchorDates ad ON (dc.Id = ad.SubjectId AND dc.infectionDate = ad.date AND ad.eventLabel = 'SIV Infection')
WHERE ad.rowid IS NULL AND dc.infectionDate IS NOT NULL

UNION ALL

SELECT
dc.Id as SubjectId,
dc.artInitiationDate as date,
'ART Initiation' as eventLabel

FROM study.demographicsChallengeAndArt dc
LEFT JOIN studies.subjectAnchorDates ad ON (dc.Id = ad.SubjectId AND dc.artInitiationDate = ad.date AND ad.eventLabel = 'ART Initiation')
WHERE ad.rowid IS NULL AND dc.artInitiationDate IS NOT NULL

UNION ALL

SELECT
dc.Id as SubjectId,
dc.artReleaseDate as date,
'ART Release' as eventLabel

FROM study.demographicsChallengeAndArt dc
LEFT JOIN studies.subjectAnchorDates ad ON (dc.Id = ad.SubjectId AND dc.artReleaseDate = ad.date AND ad.eventLabel = 'ART Release')
WHERE ad.rowid IS NULL AND dc.artReleaseDate IS NOT NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<customView xmlns="http://labkey.org/data/xml/queryCustomView" hidden="false" canOverride="false">
<columns>
<column name="Id"/>
<column name="date"/>
<column name="enddate"/>
<column name="category"/>
<column name="treatment"/>
<column name="route"/>
<column name="amount"/>
<column name="amount_units"/>
<column name="comments"/>
<column name="dataSource"/>
<column name="viralLoad"/>
<column name="timePostSivChallenge/weeksPostInfection"/>
<column name="artInformation/daysPostArtInitiation"/>
<column name="artInformation/daysPostArtRelease"/>

</columns>
<sorts>
<sort column="Id" descending="false"/>
<sort column="date" descending="true"/>
</sorts>
</customView>
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public TableInfo getLookupTableInfo()
"JOIN studies.subjectAnchorDates ad ON (ad.subjectId = c." + idCol.getFieldKey().toSQLString() + ")\n" +
"WHERE ad.eventLabel = 'SIV Infection'\n" +
"GROUP BY c.date, c." + pkCol.getFieldKey().toString() + "\n" +
"HAVING count(*) = 1) t"
"HAVING count(DISTINCT c.date) = 1) t"
);
qd.setIsTemporary(true);

Expand Down Expand Up @@ -472,9 +472,10 @@ public TableInfo getLookupTableInfo()
"GROUP_CONCAT(DISTINCT tr.treatment) AS artTreatment,\n" +
"c." + pkCol.getFieldKey().toString() + "\n" +
"FROM \"" + schemaName + "\".\"" + queryName + "\" c " +
// TODO: consider whether this should include all dates
"JOIN study.treatments tr ON (tr.category = 'ART' AND CAST(tr.date AS DATE) <= CAST(c." + dateCol.getFieldKey().toString() + " AS DATE) AND tr.Id = c." + idCol.getFieldKey().toSQLString() + ")\n" +
"GROUP BY c." + dateCol.getFieldKey().toString() + ", c." + pkCol.getFieldKey().toString() + "\n" +
"HAVING COUNT(*) = 1"
"HAVING COUNT(DISTINCT tr.date) = 1"
);
qd.setIsTemporary(true);

Expand Down
6 changes: 3 additions & 3 deletions mcc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.