couchbaselabs / couchbaselabs/Linq2Couchbase

Incorrect N1QL generated when doing string comparisons using Fhir API

Open
#213 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
98
Forks
50
PR merge metrics
No merged PRs in 30d

Description

_**Note: [Fhir](https://github.com/ewoutkramer/fhir-net-api) is a specification for sharing health care records electronically**._

_A Linq2Couchbase user observes:_

"FHIR has a special way it serializes objects into JSON. This works fine for reading and writing, but is complicated when searching. For example, when an extension with a FhirString value is serialized, it becomes a “valueString” property name:

new Models.Extension("https://fhir.app.localhost.net/Extension/ProjectName",
new Models.FhirString("EBCD"));

When serialized it looks like this:

{
"url": "https://fhir.app.localhost.net/Extension/ProjectName",
"valueString": "EBCD"
}

The problem is when trying to search for that, here’s what the LINQ expression becomes:

device => device.Extension.Any(x => x.Url == "https://fhir.app.localhost.net/Extension/ProjectName" && x.Value == new Models.FhirString("EBCD

The N1QL generated looks like this:

SELECT `Extent1`.* FROM `FhirBucket` as `Extent1` WHERE (`Extent1`.`resourceType` = 'Device') AND ANY `Extent2` IN `Extent1`.`extension` SATISFIES ((`Extent2`.`url` = 'https://fhir.app.localhost.net/Extension/ProjectName') AND (`Extent2`.`value` = EBCD)) END LIMIT 100

Notice how it’s searching on the property `Extent2`.`value` because it doesn’t know how to change that to `Extent2`.`valueString` which is how the JSON is actually stored. I suspect this is because the object FhirString is on the right hand side of the equal sign whereas the change from `value` to `valueString` needs to happen on the left hand side of the equal sign."

_I am not sure if this can be resolved at the Linq layer, since its really an effect of how Fhir wraps .NET strings with FhirString objects without actually changing the Fhir API._

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.