Nelly-Barret / BETTER-fairificator

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

NaN values still exist #60

Closed Nelly-Barret closed 1 week ago

Nelly-Barret commented 1 week ago

Taking advantage of the MongoDB flexible architecture, when there is no value for a specific column (typically a NaN / empty cell), we should not record NaN or "" or null for that column.

However, I could see some columns with NaN value in the Sample instances:

{
    _id: ObjectId('6670422296d8fcc097251fd1'),
    identifier: { value: 'Sample/20LD811194' },
    BIS: 0,
    insertedAt: '06/24/2024, 16:03:14',
    quality: NaN,
    resourceType: 'Sample',
    sampling: 'Iniziale',
    timeCollected: '2021-12-16',
    timeReceived: '2021-12-16',
    tooYoung: 0
  }
Nelly-Barret commented 1 week ago

This is fixed now:

[
  {
    _id: ObjectId('6672954796d8fcc09725ac8d'),
    identifier: { value: 'Sample/20LD811194' },
    BIS: 0,
    createdAt: ISODate('2024-06-19T10:22:31.000Z'),
    resourceType: 'Sample',
    sampling: 'Iniziale',
    timeCollected: ISODate('2021-12-16T00:00:00.000Z'),
    timeReceived: ISODate('2021-12-16T00:00:00.000Z'),
    tooYoung: 0
  }
]

does not show the NaN quality field anymore.

Nelly-Barret commented 1 week ago

A good test is to look for any field having a NaN value

Nelly-Barret commented 1 week ago

We can show instances with at least one NaN value with this query:

db["Sample"].aggregate([{$addFields: { doc: { $objectToArray: "$$ROOT" }}}, { $match: { "doc.k": /.*/i, "doc.v": NaN}}])

"doc.k": /.*/i matches any field in the instance

The above query returns nothing if no instance has a NaN value (in any field). This is now the case for the Sample table.

Merged with https://github.com/Nelly-Barret/BETTER-fairificator/pull/64