-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AMPATH:master' into POC-341
- Loading branch information
Showing
99 changed files
with
107,759 additions
and
507 deletions.
There are no files selected for viewing
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,6 @@ | ||
{ | ||
"trailingComma": "none", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
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,54 @@ | ||
var db = require('../../etl-db'); | ||
|
||
export class CohortModuleService { | ||
getCohortSummary = (cohortUuids) => { | ||
const uuids = cohortUuids | ||
.split(',') | ||
.map((s) => { | ||
return `"${s}"`; | ||
}) | ||
.join(','); | ||
return new Promise((resolve, reject) => { | ||
let queryParts = {}; | ||
const sql = `SELECT | ||
c.uuid, | ||
COUNT(DISTINCT cm.patient_id) AS total_patients, | ||
IFNULL(SUM(CASE | ||
WHEN fl.hiv_viral_load < 200 THEN 1 | ||
ELSE 0 | ||
END) / NULLIF(COUNT(DISTINCT cm.patient_id), 0) * 100, | ||
0) AS suppression_rate_percentage | ||
FROM | ||
amrs.cohort c | ||
LEFT JOIN | ||
amrs.location l ON l.location_id = c.location_id | ||
INNER JOIN | ||
amrs.cohort_member cm ON c.cohort_id = cm.cohort_id | ||
LEFT JOIN | ||
(SELECT | ||
person_id, MAX(test_datetime) AS latest_test_datetime | ||
FROM | ||
etl.flat_labs_and_imaging | ||
WHERE | ||
hiv_viral_load IS NOT NULL | ||
GROUP BY person_id) AS latest_tests ON cm.patient_id = latest_tests.person_id | ||
LEFT JOIN | ||
etl.flat_labs_and_imaging fl ON latest_tests.person_id = fl.person_id | ||
AND latest_tests.latest_test_datetime = fl.test_datetime | ||
WHERE | ||
l.uuid = '${cohortUuids}' | ||
GROUP BY c.cohort_id; | ||
`; | ||
|
||
queryParts = { | ||
sql: sql | ||
}; | ||
|
||
return db.queryServer(queryParts, function (result) { | ||
result.sql = sql; | ||
resolve(result); | ||
}); | ||
}); | ||
}; | ||
} |
Large diffs are not rendered by default.
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
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
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
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
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
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
Oops, something went wrong.