Stream: implementers
Topic: QuestionnaireResponse.questionnaire element
Mohsen Jafari (Feb 18 2022 at 15:37):
I'm going to associate a QuestionnaireResponse to a Questionnaire in Java. I'm importing the QuestionnaireResponse model from org.hl7.fhir.r4.model.QuestionnaireResponse
. The QuestionnaireResponse model has a function called setQuestionnaire(String value)
which takes a string value. I have the related questionnaire's identifier but not its logical id (the id created by the FHIR server). is that possible/valid to associate the QuestionnaireResponse to the Questionnaire like the following?
QuestionnaireResponse qr = new QuestionnaireResponse();
String some_identifier = "1234";
qr.setQuestionnaire("http://localhost:some_port/Questionnaire?identifier=" + some_identifier));
Lloyd McKenzie (Feb 18 2022 at 15:43):
No. The QuestionnaireResponse.questionnaire element is a canonical. It MUST be a canonical reference to the Questionnaire - i.e. the Questionnaire.url or the Questionnaire.url + version (separated by '|').
Lloyd McKenzie (Feb 18 2022 at 15:43):
You can't point to a Questionnaire by .identifier.
Mohsen Jafari (Feb 18 2022 at 15:59):
Lloyd McKenzie said:
No. The QuestionnaireResponse.questionnaire element is a canonical. It MUST be a canonical reference to the Questionnaire - i.e. the Questionnaire.url or the Questionnaire.url + version (separated by '|').
As far as I understood, the Questionnaire.url is a URI, and a URI's structure should follow the format scheme:[//authority]path[?query][#fragment]
. In this case, if I have already set the Questionnaire.url to, for example, http://localhost:some_port/Questionnaire?identifier=1234"
then can't I set the same string for the QuestionnaireResponse.questionnaire using the above-mentioned code? If not, so how can I associate my QuestionnaireResponse to its Questionnaire? And could you clarify/explain the canonical stuff? I have read a lot but still don't understand and confused completely.
Lloyd McKenzie (Feb 18 2022 at 16:41):
The objective of the Questionnaire.url is to ensure that it can't ever collide with any other Questionnaire defined on any other system anywhere. While "http://localhost" is certainly a legal URL, it'd be a very bad idea to use as the root of the url of a CanonicalResource because there's no control over that namespace and the chances of ending up with a collision are high. Simply assign the Questionnaire a url in a space that you control. It's nice if the URL resolves, but it isn't critical.
Elliot Silver (Feb 18 2022 at 17:27):
Lloyd McKenzie said:
The objective of the Questionnaire.url is to ensure that it can't ever collide with any other Questionnaire defined on any other system anywhere.
Hi @Lloyd McKenzie , while I understand what you're trying to say, I think the way you've said it actually conveys the opposite meaning. Questionnaire.url is essentially a special-case business identifier for the resource. Questionnaires and several other "knowledge" or "definitional" resources will typically be copied to multiple servers (e.g., you and I both copy a questionnaire from the questionnaire publishing organization), but this "canonical" identifier will stay constant in all locations. Think of canonical as an identifier that just happens to be expressed in the format of a URL. There is no particular meaning in the URL, it's just a name. This is in contrast to the Questionnaire.id which may vary from server to server (and when combined with the server's base service url, must vary from server to server). Identifying a Questionnaire by canonical lets my app, for example, perform the same search on multiple servers for QuestionnaireResponses to a given Questionnaire, and I don't need to be concerned with what the local id for that Questionnaire is (or even if it is present on every server).
Mohsen Jafari (Feb 19 2022 at 09:25):
Dear @Elliot Silver, therefore, am I allowed to set, for example, http//localhost:some_port/Questionnaire?identifier=1234
to my Questionnaire.url
and set the same http//localhost:some_port/Questionnaire?identifier=1234
to my QuestionnaireResponse.questionnaire
to associate the QuesionnaireResponse to the Questionnaire ?
Lloyd McKenzie (Feb 19 2022 at 19:40):
The purpose of Questionnaire.url is to uniquely identify the questionnaire across all systems throughout the world. A localhost-based URL won't do that. While it's not non-compliant to use it, it's not a good idea. It's better to have a url that doesn't resolve than one that might end up not being truly unique.
To find a referenced Questionnaire you do a search on the server based on url (and possibly version). If you don't find the Questionnaire on your local server, you search on whatever your 'preferred' registries are to see if you can find it there. Only in the event that you can't find the Questionnaire locally or on any registry would you try to resolve the canonical URL - and there's no guarantee it'll resolve or that you'll have access.
Last updated: Apr 12 2022 at 19:14 UTC