Skip to content

Search by quantity with units #308

@andy-a-o

Description

@andy-a-o

Describe the bug
Search by quantity with units is not working.

To Reproduce

> db.resources.find({resourceType: "Observation", "id":"80"}, {"valueQuantity":1});
{ "_id" : "Observation/80/_history/1", "valueQuantity" : { "value" : 2, "unit" : "mmol", "system" : "http://unitsofmeasure.org" } }
> db.searchindex.find({"internal_id" : "Observation/80"}, {"value-quantity":1, "internal_justid":1})
{ "_id" : ObjectId("5f9d5bde896f3f0b43f23d8b"), "internal_justid" : "80", "value-quantity" : { "system" : "http://unitsofmeasure.org", "value" : 2, "decimals" : "E00x2.0", "unit" : "" } }

GET /fhir/Observation?value-quantity=2.0||mmol

prouces this search:

{
  "find" : "searchindex",
  "filter" : {
    "internal_level" : 0,
    "internal_resource" : "Observation",
    "$or" : [
      {
        "value-quantity" : {
          "$elemMatch" : {
            "decimals" : /^E21x1.2/,
            "unit" : ""
          }
        }
      },
      {
        "value-quantity" : {
          "$not" : {
            "$type" : 4
          }
        },
        "value-quantity.decimals" : /^E21x1.2/,
        "value-quantity.unit" : ""
      }
    ]
  },
  "projection" : {
    "internal_selflink" : 1
  },
  "$db" : "spark",
  "lsid" : {
    "id" : UUID("3bcf5075-2e89-4ccd-80ea-37667866dcd3")
  }
}

and gives no results.

Expected behavior
Search with quantity and units returning the valid results.

Failed tests
SprinklerSearchTest (SE21P, SE21G, SE22P, SE22G).

Additional context
http://hl7.org/fhir/DSTU2/search.html#quantity

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions