Stream: questionnaire
Topic: Search for QuestionnaireResponse from Questionnaire
Grey Faulkenberry (Nov 22 2021 at 04:14):
I'm trying to search for any QuestionnaireResponses to a certain Questionnaire. This search works:
QuestionnaireResponse?_lastUpdated=gt$2020-01-01&subject=Patient/1234567890
But none of these do.
QuestionnaireResponse?questionnaire=d79017af-3a87-4ca1-aa6d-400f66d037b9&_lastUpdated=gt$2020-01-01&subject=Patient/1234567890
QuestionnaireResponse?questionnaire=d79017af-3a87-4ca1-aa6d-400f66d037b9
QuestionnaireResponse?questionnaire=Questionnaire/d79017af-3a87-4ca1-aa6d-400f66d037b9
I've tried this on both HAPI and GCP. I assume I'm just formatting it incorrectly, but I've tried the permutations above plus a number of others, and I can't seem to figure it out. What would be the correct format for this?
Lloyd McKenzie (Nov 22 2021 at 14:18):
QuestionnaireResponse.questionnaire has a type of 'canonical'. That means it must refer to Questionnaire.url, which in turn must be a full URL. (Relative URLs aren't allowed.)
Lloyd McKenzie (Nov 22 2021 at 14:20):
So try questionnaire=http://somewhere.org/fhir/Questionnaire/d79017af-...
assuming that's the 'url' of your Questionnaire. There are variants where you can also specify the Questionnaire.version. Don't forget to escape the URL when it appears as a parameter in your search.
Grey Faulkenberry (Nov 22 2021 at 15:36):
Aha, that's my problem. Thanks Lloyd!
Grey Faulkenberry (Nov 22 2021 at 18:07):
Or not. I'm apparently still missing something. On Hapi, there's this questionnaire:
http://hapi.fhir.org/baseR4/Questionnaire/1634062
Along with this QuestionnaireResponse:
http://hapi.fhir.org/baseR4/QuestionnaireResponse/1672619
But then when I try this:
http://hapi.fhir.org/baseR4/QuestionnaireResponse?questionnaire=http%3A%2F%2Fhapi.fhir.org%2FbaseR4%2FQuestionnaire%2F1634062&_pretty=true
I get an error. Any thoughts on what I'm doing wrong?
Lloyd McKenzie (Nov 22 2021 at 18:09):
I don't see a 'url' element declared in that Questionnaire.
Lloyd McKenzie (Nov 22 2021 at 18:09):
If it doesn't have a 'url' defined, you can't reference it.
Grey Faulkenberry (Nov 22 2021 at 18:12):
Alright, how about now?
Lloyd McKenzie (Nov 22 2021 at 19:17):
That should work I believe. If it's not, best to raise on #hapi
Grey Faulkenberry (Nov 22 2021 at 20:55):
Will do, just wanted to make sure it was formatted properly, thanks!
Lloyd McKenzie (Nov 22 2021 at 21:18):
As far as I could tell :)
Paul Lynch (Nov 30 2021 at 15:16):
Lloyd McKenzie said:
QuestionnaireResponse.questionnaire has a type of 'canonical'. That means it must refer to Questionnaire.url, which in turn must be a full URL. (Relative URLs aren't allowed.)
@Lloyd McKenzie Is a canonical like "#q" (as used in https://build.fhir.org/ig/HL7/sdc/adaptive.html) considered to be a "full" URL?
Lloyd McKenzie (Nov 30 2021 at 15:57):
Yes. If you're pointing to a contained Questionnaire, then you can get away with just the #[id]. (And no need for the contained Questionnaire to have a url.)
Grey Faulkenberry (Dec 10 2021 at 00:12):
OK, so I apparently still need some help, because I can't get this to work on HAPI or GCP. Here is my HAPI setup:
http://hapi.fhir.org/baseR4/Questionnaire/1634062
And then there's this response to it:
http://hapi.fhir.org/baseR4/QuestionnaireResponse/1672619
Note that the QuestionnaireResponse has
http://hapi.fhir.org/baseR4/Questionnaire/1634062
as the URL, and I can even search like this:
http://hapi.fhir.org/baseR4/Questionnaire?url=http%3A%2F%2Fhapi.fhir.org%2FbaseR4%2FQuestionnaire%2F1634062&_pretty=true
And it will find the Questionnaire I'm looking for. However, when I perform this search:
But then when I try to search for the second using the first as a parameter:
http://hapi.fhir.org/baseR4/QuestionnaireResponse?questionnaire=http%3A%2F%2Fhapi.fhir.org%2FbaseR4%2FQuestionnaire%2F1634062&_pretty=true
I get an error.
Another example on GCP (this request requires authentication, but I get the same result):
https://healthcare.googleapis.com/v1/projects/zanenet-njinck/locations/us-central1/datasets/dev-zanenet-njinck/fhirStores/stage-zanenet-njinck-datastore/fhir/Questionnaire/5b267df7-b195-4a75-8848-50c8a01dc85b
Or I can search for the questionnaire:
https://healthcare.googleapis.com/v1/projects/zanenet-njinck/locations/us-central1/datasets/dev-zanenet-njinck/fhirStores/stage-zanenet-njinck-datastore/fhir/Questionnaire?url=https%3A%2F%2Fhealthcare.googleapis.com%2Fv1%2Fprojects%2Fzanenet-njinck%2Flocations%2Fus-central1%2Fdatasets%2Fdev-zanenet-njinck%2FfhirStores%2Fstage-zanenet-njinck-datastore%2Ffhir%2FQuestionnaire%2F5b267df7-b195-4a75-8848-50c8a01dc85b
So it recognizes the url properly. Then this is an example for a QuestionnaireResponse to the Questionnaire:
https://healthcare.googleapis.com/v1/projects/zanenet-njinck/locations/us-central1/datasets/dev-zanenet-njinck/fhirStores/stage-zanenet-njinck-datastore/fhir/Questionnaire/a210d717-8c68-449d-8668-41fcb9391f7e
And I note that the questionnaire field for this QuestionniareResponse is:
https://healthcare.googleapis.com/v1/projects/zanenet-njinck/locations/us-central1/datasets/dev-zanenet-njinck/fhirStores/stage-zanenet-njinck-datastore/fhir/Questionnaire/5b267df7-b195-4a75-8848-50c8a01dc85b
And yet, when I try this:
https://healthcare.googleapis.com/v1/projects/zanenet-njinck/locations/us-central1/datasets/dev-zanenet-njinck/fhirStores/stage-zanenet-njinck-datastore/fhir/QuestionnaireResponse?questionnaire=https://healthcare.googleapis.com/v1/projects/zanenet-njinck/locations/us-central1/datasets/dev-zanenet-njinck/fhirStores/stage-zanenet-njinck-datastore/fhir/Questionnaire/5b267df7-b195-4a75-8848-50c8a01dc85b
Or this:
https://healthcare.googleapis.com/v1/projects/zanenet-njinck/locations/us-central1/datasets/dev-zanenet-njinck/fhirStores/stage-zanenet-njinck-datastore/fhir/QuestionnaireResponse?questionnaire=https%3A%2F%2Fhealthcare.googleapis.com%2Fv1%2Fprojects%2Fzanenet-njinck%2Flocations%2Fus-central1%2Fdatasets%2Fdev-zanenet-njinck%2FfhirStores%2Fstage-zanenet-njinck-datastore%2Ffhir%2FQuestionnaire%2F5b267df7-b195-4a75-8848-50c8a01dc85b
It returns an empty bundle.
Could anyone help point out what I'm doing wrong?
Brian Postlethwaite (Dec 10 2021 at 04:34):
That indeed looks like a HAPI bug to me.
Lloyd McKenzie (Dec 10 2021 at 05:55):
Suggest asking on #hapi
Grey Faulkenberry (Dec 10 2021 at 15:19):
The thing that bothered me was that I got an error on the GCP platform as well (and they use their own implementation). So I was trying to make sure I wasn't missing something. I had asked this on the HAPI channel but hadn't gotten a response yet.
Paul Lynch (Dec 10 2021 at 15:50):
The questionnaire parameter works in HAPI 5.3: https://lforms-fhir.nlm.nih.gov/baseR4/QuestionnaireResponse?questionnaire=https://lforms-fhir.nlm.nih.gov/baseR4/Questionnaire/74728-7-modified-x
Last updated: Apr 12 2022 at 19:14 UTC