Nelly-Barret / BETTER-fairificator

The fairification tools for BETTER project.
https://www.better-health-project.eu/
0 stars 0 forks source link

Broken Examination category? #71

Closed Nelly-Barret closed 1 week ago

Nelly-Barret commented 1 week ago
  {
    _id: ObjectId('6672f20396d8fcc09725de4f'),
    code: {
      text: '3oh ga',
      coding: [
        {
          system: 'https://clir.mayo.edu/',
          code: 'M-000797',
          display: '3oh ga (3-OH glutaric acid)'
        }
      ]
    },
    category: {
      text: '',
      coding: [
        {
          system: 'http://loinc.org',
          code: '81259-4',
          display: 'Associated phenotype'
        }
      ]
    },
    createdAt: ISODate('2024-06-19T16:58:10.000Z'),
    identifier: { value: 'Examination/4' },
    permittedDatatype: [],
    resourceType: 'Examination'
  }
Nelly-Barret commented 1 week ago

For sure it is broken, we only have phenotypic examinations:

better_multip> db["Examination"].distinct("category.coding.display")
[ 'Associated phenotype' ]
Nelly-Barret commented 1 week ago

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 }
]
Nelly-Barret commented 1 week ago

Done since https://github.com/Nelly-Barret/BETTER-fairificator/commit/0a0148cb26994855beea9115c2d3a873cfd16c53