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

Decimal for lowBoundary and highBoundary #238

Open
Diferti opened this issue May 3, 2024 · 4 comments
Open

Decimal for lowBoundary and highBoundary #238

Diferti opened this issue May 3, 2024 · 4 comments

Comments

@Diferti
Copy link

Diferti commented May 3, 2024

In #229 I implemented lowBoundary and highBoundary for dateTime, date, and time.

How should I interpret lowBoundary and highBodunary for Decimal? The expectation here says lowBoundary for 1.0 should be 0.95 but why is it not 1.000000000000000000e+000000000?

JavaScript can't have numbers as big as the FHIR spec? What should we do? One option is just to make them as big as JavaScript can be.

@awalley-ncqa
Copy link
Contributor

I am still confused, myself, on how to implement the low/high boundary functions in FHIRPath (and subsequently sof).
Based on this definition, I am not sure how we get 0.95 as an expectation. I think that would mean we only have precision on a step of 0.05, right?

Also in the fhirpath spec that I shared it says that decimal should have a minimum of 8 digits of precision. I believe a double fits within this requirement, so we could (potentially) use a minimum requirement based on the 8 digits (?)

@Diferti
Copy link
Author

Diferti commented May 10, 2024

Thank you. I will review it.

However, even 8 digits of precision JS can not hold in some cases, for example:

1.123456789123456 is 16 digits in total, precision is 15, it works fine
1.1234567891234567 is 17 digits in total, precision is 16, overflow happens
12345.123456789123456 is 20 digits in total, precision is 15, overflow happens, because floating point numbers in JS can hold only 16 digits in total. One digit represents 4-bits, hence 64-bit has 16 digits.

So, case when input value like 123456789123.1234, precision 4 is maximum if more then overflow will happen.

if consider FHIR datatypes maximum input value can be this:
999999999999999999.999999999999999999e999999999

As for step of 0.05, in my opinion this is an error in the tests, because it does not make sense and the expected number does not really change in length, that is it does not fulfill what the boundary function intended.

@johngrimes
Copy link
Collaborator

Here is a link to where I am trying to get a resolution on the intended behaviour for these functions: https://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/Boundary.20functions

I think the SQL on FHIR spec is fine as is, as our link goes to the CI build of the FHIRPath spec.

The reference implementation may need to change to reflect any updates to the semantics.

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

No branches or pull requests

3 participants