ejp-rd-vp / vp-portal-issues

0 stars 0 forks source link

Choosing multiple genders is not working properly for beacon queries #21

Closed ammarbarakat closed 1 year ago

ammarbarakat commented 1 year ago

Describe your problem.

Currently, the feature allowing users to choose multiple genders when performing beacon queries is experiencing functionality problems. This issue hinders the proper selection of multiple genders, resulting in inaccurate query results.

If it is a bug name steps to reproduce

Steps to reproduce the behavior:

  1. Go to vp-portal
  2. Search for an orphaCode (e.g. 778)
  3. Select multiple genders and send the query
  4. See error

Describe the solution you'd like

Searching for multiple genders should work properly.

Additional context

Thank you for bringing the issue to our attention, @rini21

ammarbarakat commented 1 year ago

Related issues: #18

rini21 commented 1 year ago

The issue persists, and does not show accurate results for L2 resources. Tested with multiple resources.

Example: In GPAP, querying via Postman for 778 AND (Male or Female) results in 93 (as below): image

However, this is not the case when tested in the VP-Portal as GPAP itself is not shown in the results: image

ammarbarakat commented 1 year ago

The resource does not appear in the results because the response time exceeds the time limit allowed by vp-portal. In order to conduct tests, we have increased the timeout duration. Kindly perform another test and verify if everything is functioning correctly. Thank you. @rini21

rini21 commented 1 year ago

Reopening this issue, as it might not be related to the time limit, but because there is a potential logic flaw originating from the request - if multiple filters are selected, say, genders male, female, the VP-Portal is sending the request as male AND female instead of the intended male OR female.

Logging the incoming request from VP-Portal: [Thu Jul 06 11:46:33.433595 2023] [php:notice] [pid 64104] [client 192.168.17.244:45010] array(2) { ["meta"]=> array(1) { ["apiVersion"]=> string(4) "v2.0" } ["query"]=> array(1) { ["filters"]=> array(9) { [0]=> array(3) { ["id"]=> string(11) "NCIT_C28421" ["operator"]=> string(1) "=" ["value"]=> string(11) "NCIT_C16576" } [1]=> array(3) { ["id"]=> string(11) "NCIT_C28421" ["operator"]=> string(1) "=" ["value"]=> string(11) "NCIT_C20197" } [2]=> array(1) { ["id"]=> string(12) "Orphanet_730" } [3]=> array(3) { ["id"]=> string(11) "NCIT_C83164" ["operator"]=> string(2) ">=" ["value"]=> string(1) "0" } [4]=> array(3) { ["id"]=> string(11) "NCIT_C83164" ["operator"]=> string(2) "<=" ["value"]=> string(3) "100" } [5]=> array(3) { ["id"]=> string(12) "NCIT_C124353" ["operator"]=> string(2) ">=" ["value"]=> string(1) "0" } [6]=> array(3) { ["id"]=> string(12) "NCIT_C124353" ["operator"]=> string(2) "<=" ["value"]=> string(3) "100" } [7]=> array(3) { ["id"]=> string(12) "NCIT_C156420" ["operator"]=> string(2) ">=" ["value"]=> string(1) "0" } [8]=> array(3) { ["id"]=> string(12) "NCIT_C156420" ["operator"]=> string(2) "<=" ["value"]=> string(3) "100" } } }}

Decoding the above and ignoring ages for readability, the incoming request from VP-Portal currently is:

{
    "meta": {
        "apiVersion": "v2.0"
    },
    "query": {
        "filters": [
            {
                "id": "Orphanet_730"
            },
            {
                "id": "NCIT_C28421",
                "operator": "=",
                "value": "NCIT_C20197"
            },
            {
                "id": "NCIT_C28421",
                "operator": "=",
                "value": "NCIT_C16576"
            }
        ]
    }
}

The expected filter request for gender if multiple genders are selected on the VP-Portal is:

{
    "meta": {
        "apiVersion": "v2.0"
    },
    "query": {
        "filters": [
            {
                "id": "Orphanet_730"
            },
            {
                "id": "NCIT_C28421",
                "operator": "=",
                "value": ["NCIT_C20197", "NCIT_C16576"]
            }
        ]
    }
}

Multiple genders are sent as male AND female and will result 0 as an individual cannot both be male AND female (not accounting for hermaphroditic characteristics). Instead, the request needs to be sent and properly formatted as male OR female OR ... using an array. It then has to be logical AND with other types of filters like ages, genes etc.,

@Ammarbr kindly check the logic.

rini21 commented 1 year ago

Working as expected after the fix. Thanks @Ammarbr!