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

Performing an Observation search with value-quantity that has zero's after decimal gives no results #22

Closed
brianpos opened this issue Dec 9, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@brianpos
Copy link
Contributor

brianpos commented Dec 9, 2014

If you have an Observation in your database with a quantity value of "140.0" a search with that value will not return any results (with no error)
http://zzzz z.com.au/fhir/Observation?value-quantity=140.0||mm[Hg]

however if you search for 140 (no decimal places) then it works
http://zzzz z.com.au/fhir/Observation?value-quantity=140||mm[Hg]

@mharthoorn mharthoorn added the bug label Jul 21, 2015
@mharthoorn mharthoorn added this to the Spark 3.1 milestone Jul 21, 2015
@mbaltus mbaltus modified the milestones: Spark 3.3 - DevDays2015, Spark 3.1 Oct 19, 2015
@CorinaCiocanea CorinaCiocanea self-assigned this Nov 2, 2015
CorinaCiocanea added a commit that referenced this issue Nov 2, 2015
@mharthoorn
Copy link
Member

As far as I can see, the behaviour that Brian mention is not a bug, but by design. 140.0 IS more precise than 140 so. A search for 140.0 should exclude a value of 140.5. While a search for 140 should include a value of 140.5. This behaviour is documented and conforms to our unit tests. See https://github.com/furore-fhir/Fhir.Metrics/blob/master/Fhir.Metrics.Tests/TestSearchableQuantity.cs.

The measurement 140 means that the value lies between 139.5 and 140.5. So it is very well possible that the value lies outside of the range of 140.0.

Another way of explaining it: with 140 you will find 140.0. Where as with 140.0 you will not find 140.

Or am I missing your point here Brian?

@mharthoorn mharthoorn reopened this Nov 13, 2015
@brianpos
Copy link
Contributor Author

I searched for exactly what was in the value and it didn't get returned. 140.0 was in the db.

@CorinaCiocanea
Copy link
Contributor

So, appereantly this could be a bug, but is a bug in the Hl7.FhirLibrary that Spark uses:
The behaviour is like that: Spark uses Hl7.Fhir.Serialization.FhirSerializer that in turn uses Newtonsoft.Json serialization. By default Newtonsoft.Json serializes both decimal value 6 and 6.0 as 6.0.
That means that we lose a part of the precision specified above from Martijn.
The search functionality does not use the value serialized in the above form. This is why the search still behaves correctly :) (although that is not obvious). If you insert a resource with a value of 140, and afterwards you read it back it will have the value 140.0. But the search will still know that the actual value was 140, so it won't be returned if you search for 140.0.
So, this is not a search issue, but a "create"/"storage" issue and is not really a Spark issue, but a Hl7.Fhir issue. I will close this issue and add one in Hl7.Fhir.

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

No branches or pull requests

4 participants