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

Implement FhirPath subtraction operations for dateTime and date in the default symbol table #2599

Closed
almostchristian opened this issue Sep 28, 2023 · 0 comments · Fixed by #2600

Comments

@almostchristian
Copy link
Contributor

FhirPath subtraction for dateTime and date are currently not included in the standard functions, but can be simulated by changing the expression to use binary.+ and unary.- which is cumbersome.

Fails:
Patient.birthDate - 100 years
Exception:
Invocation of operator '-' failed: Unable to cast object of type 'Hl7.Fhir.ElementModel.Types.Date' to type 'Hl7.Fhir.ElementModel.Types.Quantity'.

Works:
Patient.birthDate + (-100 years)

We are able to use the desired expression by adding the operations to the symbol table which I think should be included by default.

FHIRPath date/time subtraction

FhirPathCompiler.DefaultSymbolTable.Add("binary.-", (object f, P.DateTime a, P.Quantity b) => a + new P.Quantity(-b.Value, b.Unit), doNullProp: true);
FhirPathCompiler.DefaultSymbolTable.Add("binary.-", (object f, P.Date a, P.Quantity b) => a + new P.Quantity(-b.Value, b.Unit), doNullProp: true);
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

Successfully merging a pull request may close this issue.

1 participant