hapifhir / hapi-fhir

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

$populate on Questionnaire with a subject=Patient/A1 results in a reference of Patient/Patient/A1 #6201

Open jwhiteside27 opened 3 months ago

jwhiteside27 commented 3 months ago

When using the populate operation against a questionnaire and supplying a Patient reference e.g.

https://FHIRSERVER.COM/fhir/Questionnaire/OSA/$populate?subject=Patient/A1

the QuestionnaireResponse returned provides a reference of "reference": "Patient/Patient/A1"

If I omit the Patient/ element from the $populate operation I get the correct reference of "reference": "Patient/A1"

However, the FHRI documentation - http://hl7.org/fhir/R4/questionnaireresponse.html states that the subject is of type Reference(any) so I should be able to assign a questionnaire to other individuals such as a Practitioner or RelatedPerson.

If I try and $populate a Questionnaire to a RelatedPerson e.g.

https://FHIRSERVER.COM/fhir/Questionnaire/OSA/$populate?subject=RelatedPerson/A1

I receive a QuestionnaireResponse reference of "reference": "Patient/RelatedPerson/A1"

Can you please clarify if this is a bug or the Clinical Reasoning module is only intended to assign questionnaires to Patients - which is not documented, and in the FHIR documentation appears to be restrictive against the specification.

This testing was performed using POSTman with the JPA Server 7.0.2 using FHIR R4.

jwhiteside27 commented 3 months ago

Additional to the reference issue above, The Questionnaire resource contained within the QuestionnaireResponse Resource is generated with an ID equal to that of the subject in the $populate call, e.g. server/Questionnaire/OSA/$populate?subject=Patient/ID1

results in... { "resourceType": "QuestionnaireResponse", "id": "ID1-response", "contained": [ { "resourceType": "Questionnaire", "id": "ID1", "meta": { "source": "#w1Plno23WNoP4RT6" },

Surely the ID of the contained resource should be that of the Questionnaire itself (in this case OSA) rather than the id of the patient (ID1)?