Created
May 1, 2023 21:20
-
-
Save tashrifbillah/eeb9ab01d4d0fb04ca285857e1e07654 to your computer and use it in GitHub Desktop.
Count MongoDB subjects
This file contains hidden or 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
// count good | |
let demographs; | |
let count=0; | |
let incl; | |
let csv; | |
let coll; | |
demographs=db.toc.find({"assessment":"form_sociodemographics"}) | |
// print(demographs.length()) | |
for (let i=0; i<demographs.length(); i++) { | |
d=demographs[i]; | |
s=d['subject']; | |
// print(s); | |
coll=db[d['collection']].findOne(); | |
if ( ! coll ){ continue; } | |
if (! 'chdemo_sexassigned' in coll) { | |
continue; | |
} | |
incl=db.toc.findOne({"assessment":"form_inclusionexclusion_criteria_review","subject":s}); | |
if (! incl) { continue; } | |
csv=db[incl['collection']].findOne(); | |
if (csv) { | |
if ( ('chrcrit_part' in csv) && ('included_excluded' in csv) ) { | |
count++; | |
} | |
} | |
} | |
print(count) | |
// count missing | |
let demographs; | |
let count=0; | |
let incl; | |
let csv; | |
let coll; | |
demographs=db.toc.find({"assessment":"form_sociodemographics"}) | |
// print(demographs.length()) | |
for (let i=0; i<demographs.length(); i++) { | |
d=demographs[i]; | |
s=d['subject']; | |
// print(s); | |
coll=db[d['collection']].findOne(); | |
if (! coll){ continue; } | |
if (! 'chdemo_sexassigned' in coll) { | |
continue; | |
} | |
incl=db.toc.findOne({"assessment":"form_inclusionexclusion_criteria_review","subject":s}); | |
if (! incl) { continue; } | |
csv=db[incl['collection']].findOne(); | |
if (csv) { | |
// if ( ('chrcrit_part' in csv) && ('included_excluded' in csv) ) { | |
if ('chrcrit_part' in csv && 'included_excluded' in csv && csv['included_excluded']==='') { | |
count++; | |
} | |
} | |
} | |
print(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment