EGA-archive / beacon2-ri-api

Beacon v2 Reference Implementation (API)
Apache License 2.0
16 stars 38 forks source link

payload to query age #257

Closed mustafahsyed closed 7 months ago

mustafahsyed commented 9 months ago

Hi,

I have "individual" json as

Screenshot 2023-12-12 at 4 18 47 pm

How can I query by ageRange, please provide me with payload I need to pass to "individual" endpoint.

Cheers Mustafa

costero-e commented 9 months ago

Hi @mustafahsyed,

thank you for the feedback. First of all, just let me tell you that you have a couple of specification breaks in your schema. The first bug would be the naming of the ageAtOnset, that should be ageOfOnset. The second one is that age values in ISO8601, as you are showing, need to have the field 'iso8601duration'. An example would be:

{
    "diseases": [
        {
            "ageOfOnset": 
                {
                    "end": {
                        "iso8601duration": ""
                    },
                    "start": {
                        "iso8601duration": ""
                    }
                }
            }
      ]
}

A Beacon will be able to query anything as long as you provide a filtering term for the "parameter" you want to query. In this case, you have to provide an alphanumeric term that points to this iso8601duration field inside start or end, like this:

{
"type": "alphanumeric",
"id": "diseases.ageOfOnset.end.iso8601duration",
"scope": "individuals"
}

This filtering term is not going to be populated using the extract_filtering_terms.py script, as we are not taking it into account and specifications let the beacon choose what filtering_terms to have, so if you want to use this filtering term you should create a script to insert it. After doing that, then you could make a query like an alphanumeric filter type, for example, this way:

    "query": {
        "filters": [    {
        "id": "diseases.ageOfOnset.end.iso8601duration",   
        "operator": "=",
        "value": "P12Y"     
    }],

I hope this helps.

mustafahsyed commented 7 months ago

thanks @costero-e costero-e