hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2k stars 1.31k forks source link

Custom SearchParameter #797

Open ghost opened 6 years ago

ghost commented 6 years ago

So the custom search in HAPI 3.3.0 works great, we are using it for Strings and References. However either I, or HAPI can't seem to process nested Search Parameters. Meaning when you want to search for example in a section of a composition.

So this works: Composition.extension("http://example.com/xxx")

but this creates a really long error message in HAPI: Composition.section.section.extension("http://example.com/yyy")

It actually breaks the DB so much that any subsequent action (PUT, POST, GET, DELETE) results in another error message. Similar to how HAPI 2.4 reacted to searches with References

jamesagnew commented 6 years ago

Interesting.. Would you be able to provide a example SearchParameter resource demonstrating this, as well as a resource that should be matched by it?

ghost commented 6 years ago

Sorry for the late reply...

I did look into it more, and turn's out that I accessed the wrong endpoint, the server was a 2.4 instance.

However when having the following search parameter (another mistake of mine was not adding the .text at the end of the expression): { "resourceType": "SearchParameter", "id": "34", "meta": { "versionId": "1", "lastUpdated": "2017-12-13T10:06:18.947+01:00" }, "title": "note as Annotation", "status": "active", "code": "note", "base": [ "Composition" ], "type": "string", "expression": "Composition.section.section.extension('http://example.com/fhir/AnnotationExample').text", "xpathUsage": "normal" }

And having the following resource: { "fullUrl": "http://localhost:12344/baseDstu3/Composition/32", "resource": { "resourceType": "Composition", "id": "32", "meta": { "versionId": "1", "lastUpdated": "2017-12-13T10:05:51.785+01:00", }, "status": "final", "type": { "coding": [ { "system": "some sytsem", "code": "some code", "display": "some display" } ] }, "date": "2017-05-23T09:15:00+02:00", "title": "Example Composition", "section": [ { "title": "Layer 1", "section": [ { "title": "Layer 2" "extension": [ { "url": "http://example.com/fhir/AnnotationExample", "valueAnnotation": { "text": "note1" } }, { "url": "http://example.com/fhir/AnnotationExample", "valueAnnotation": { "text": "note2" } } ] } ] } ] }

This search returns the resource: http://localhost:12344/baseDstu3/Composition?note

But this search returns nothing: http://localhost:12344/baseDstu3/Composition?note=note1