Closed Nelly-Barret closed 1 week ago
For sure it is broken, we only have phenotypic examinations:
better_multip> db["Examination"].distinct("category.coding.display")
[ 'Associated phenotype' ]
The for
loop determining whether an Examination instance is phenotypic or not was missing a .values()
and thus was comparing phenotypic variables URIs to column names. Also the clinical and phenotypic variables were inverted: the clinical one was refering to the phenotype and vice-versa.
Now that I have added the missing .values()
(to iterate over phenotypic variables names) and re-inverted the constants for phenotypic and clinical variables, I have the expected result:
better_multip> db["Examination"].aggregate({"$group": { "_id": "$category.coding.display", count: {"$sum": 1}}})
[
{ _id: [ 'Clinical finding' ], count: 89 },
{ _id: [ 'Associated phenotype' ], count: 8 }
]