microsoft / fhir-server

A service that implements the FHIR standard
MIT License
1.17k stars 497 forks source link

OR conditions not supported with comparator #815

Open hansenms opened 4 years ago

hansenms commented 4 years ago

Describe the bug

It is not possible to search for dates with comparators, e.g. to exclude a date range.

To Reproduce Steps to reproduce the behavior:

  1. Spin up FHIR server, load synthea data
  2. Search /Patient?birthdate=ge1980-01-01,lt1970-01-01, i.e. not the 70s.
  3. Returns:
    {
    "resourceType": "OperationOutcome",
    "id": "88972a44-e8f0-4773-97b4-b6780c2f5bff",
    "issue": [
        {
            "severity": "error",
            "code": "forbidden",
            "diagnostics": "Comparator is not supported when multiple values are specified using OR search parameter."
        }
    ]
    }

    Expected behavior

Should return all patients not born in the 70s.

Actual behavior

Rejects search.

Additional information

HAPI does not support this:

GET http://hapi.fhir.org/baseR4/Patient?birthdate=ge1980-01-01,lt1970-01-01

returns:

{
  "resourceType": "OperationOutcome",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>DateRange parameter does not suppport OR queries</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
  },
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "DateRange parameter does not suppport OR queries"
    }
  ]
}

Vonk supports this search:

GET https://vonk.fire.ly/Patient?birthdate=ge1980-01-01,lt1970-01-01
jackliums commented 4 years ago

The spec didn't specifically mention this so I think the original assumption was that only equal should be supported but I don't see why we shouldn't support prefix on individual values. Should be simple change by moving the parsing of the prefix down to individual values.