Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical filtering on the individuals endpoint #200

Open
DavidCroftDKFZ opened this issue Sep 7, 2023 · 6 comments
Open

Numerical filtering on the individuals endpoint #200

DavidCroftDKFZ opened this issue Sep 7, 2023 · 6 comments

Comments

@DavidCroftDKFZ
Copy link

Hi,

I would like to apply a filter to find all individuals with a BMI greater than 25. However, my attempts so far always give me zero results, even though I know that there is at least one individual with a BMI greater than 25. Could you help?

Here is the endpoint I was using: POST http://localhost:5050/api/individuals

Here is what I sent in the body of my request:

{
"query": {
"filters": [
{
"id": "LOINC:35925-4",
"operator": ">",
"value": "25.0"
}
],
"includeResultsetResponses": "HIT",
"testMode": false,
"requestedGranularity": "count"
}
}

(I also tried id=NCIT:C49671, with the same results)

I looked at the RI BFF for individuals that was uploaded to Beacon, and found this:

  "measures" : [
     {
        "assayCode" : {
           "id" : "LOINC:35925-4",
           "label" : "BMI"
        },
        "date" : "2021-09-24",
        "measurementValue" : {
           "quantity" : {
              "unit" : {
                 "id" : "NCIT:C49671",
                 "label" : "Kilogram per Square Meter"
              },
              "value" : 26.63838307
           }
        }
     },

Regards,

David Croft.

@costero-e
Copy link
Collaborator

Hi David,

here is the POST I am using and it's getting me results:

curl \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "LOINC:35925-4",
        "operator": ">",
        "value": "25.0"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "record"
    }
}' \
  http://localhost:5050/api/individuals

Maybe you can try this and tell me if you get some results.
Checking your POST everything seems right but the difference between yours and mine is requestedGranularity: record instead of count maybe is what makes the difference.

Best,

Oriol

@DavidCroftDKFZ
Copy link
Author

DavidCroftDKFZ commented Sep 29, 2023 via email

@costero-e
Copy link
Collaborator

Hi David,

at first sight, I don't see any differences between your BFF and mine.

Did you use RI to do the queries?

If so, please checkout to "develop" branch and try the query I sent you, it should work as expected.

Other possible solution is to see the logs of your beacon to see what it's throwing to the database but I can't help you more without this information.

Best,

Oriol

@albodrug
Copy link

albodrug commented Jun 4, 2024

Hello,

I cannot make use of the BMI filter either. I updated yesterday and used the cineca data. The filter on sex seems to work though...

bodrug-a ▶ pp-irs1-4071ylt ▶~/bin/beacon2-ri-api/deploy 
(itx)> curl   -H 'Content-Type: application/json'   -X POST   -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "LOINC:35925-4",
        "operator": ">",
        "value": "25.0"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "count"
    }
}'   http://localhost:5050/api/individuals
{"meta":{"beaconId":"itx.french.beacon","apiVersion":"v2.0.1","returnedGranularity":"count","receivedRequestSummary":{"apiVersion":"2.0","requestedSchemas":[],"filters":["LOINC:35925-4",">","25.0"],"requestParameters":{},"includeResultsetResponses":"HIT","pagination":{"skip":0,"limit":10},"requestedGranularity":"count","testMode":false},"returnedSchemas":[{"entityType":"individual","schema":"beacon-individual-v2.0.0"}]},"responseSummary":{"exists":true,"numTotalResults":2504},"beaconHandovers":[{"handoverType":{"id":"CUSTOM:000001","label":"Project description"},"note":"Project description","url":"https://www.nist.gov/programs-projects/genome-bottle"}]}
bodrug-a ▶ pp-irs1-4071ylt ▶~/bin/beacon2-ri-api/deploy 
(itx)> curl   -H 'Content-Type: application/json'   -X POST   -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "LOINC:35925-4",
        "operator": ">",
        "value": "45.0"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "count"
    }
}'   http://localhost:5050/api/individuals
{"meta":{"beaconId":"itx.french.beacon","apiVersion":"v2.0.1","returnedGranularity":"count","receivedRequestSummary":{"apiVersion":"2.0","requestedSchemas":[],"filters":["LOINC:35925-4",">","45.0"],"requestParameters":{},"includeResultsetResponses":"HIT","pagination":{"skip":0,"limit":10},"requestedGranularity":"count","testMode":false},"returnedSchemas":[{"entityType":"individual","schema":"beacon-individual-v2.0.0"}]},"responseSummary":{"exists":true,"numTotalResults":2504},"beaconHandovers":[{"handoverType":{"id":"CUSTOM:000001","label":"Project description"},"note":"Project description","url":"https://www.nist.gov/programs-projects/genome-bottle"}]}
bodrug-a ▶ pp-irs1-4071ylt ▶~/bin/beacon2-ri-api/deploy 
(itx)> curl   -H 'Content-Type: application/json'   -X POST   -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "NCIT:C16576"
    }],                 
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },             
        "testMode": false,
        "requestedGranularity": "count"
    }                                  
}'   http://localhost:5050/api/individuals
{"meta":{"beaconId":"itx.french.beacon","apiVersion":"v2.0.1","returnedGranularity":"count","receivedRequestSummary":{"apiVersion":"2.0","requestedSchemas":[],"filters":["NCIT:C16576"],"requestParameters":{},"includeResultsetResponses":"HIT","pagination":{"skip":0,"limit":10},"requestedGranularity":"count","testMode":false},"returnedSchemas":[{"entityType":"individual","schema":"beacon-individual-v2.0.0"}]},"responseSummary":{"exists":true,"numTotalResults":1271},"beaconHandovers":[{"handoverType":{"id":"CUSTOM:000001","label":"Project description"},"note":"Project description","url":"https://www.nist.gov/programs-projects/genome-bottle"}]}

Kind regards,
Alex

@costero-e
Copy link
Collaborator

Hi @albodrug,

thanks for the comment. Recently, we changed the query by the ontology in the alphanumeric filters queries and we only allow to query for the specific label. We are doing it like this to not mix concepts of ontologies and alphanumeric terms. So, if you want to query for a measurement and its value, use the label for the assayCode, please. For example:

curl \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "meta": {
        "apiVersion": "2.0"
    },
    "query": {
        "filters": [{
        "id": "BMI",
        "operator": ">",
        "value": "25"
    }],
        "includeResultsetResponses": "HIT",
        "pagination": {
            "skip": 0,
            "limit": 10
        },
        "testMode": false,
        "requestedGranularity": "record"
    }
}' \
  http://localhost:5050/api/individuals

Let me know if this solved your issue.

Thanks,

Oriol

@albodrug
Copy link

albodrug commented Jun 5, 2024

Thanks Oriol, query is working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants