It is not possible in FHIR to embed the Practitioner data inline in the generalPractitioner field. You will have to link the Practitioner to the Patient using a resource reference. This is done using the technical ID of the linked resource.
At this point in your code, your Practitioner has not been created on a server yet, so it does not have one. I think you have two options:
Create the Practitioner first, using the FhirClient.Create method to send it to your server. The server response will fill the technical id. Then that can be used in the reference of your Patient.
Use a UUID as temporary ID for the Practitioner, put that in the reference, and send both Patient and Practitioner with a transaction Bundle to the server. The server will update the temporary ID with its own, and will also update the reference.
In case 1, you would be able to add the reference like this - where createdPrac is the response from the server after sending the Practitioner: MyPatient.GeneralPractitioner.Add(new ResourceReference("Practitioner/" + createdPrac.Id));
For case 2, filling your reference will look like this - not including the code to generate the transaction Bundle: MyGP.Id = System.Guid.NewGuid().ToString(); MyPatient.GeneralPractitioner.Add(new ResourceReference("urn:uuid:" + MyGP.Id);
Thank you… However when I try either of these options, I am getting below error:
[ERROR] (no details)(further diagnostics: Body parsing failed: Type checking the data: Encountered unknown element ‘generalPractitioner’ at location ‘Resource.generalPractitioner’ while parsing).
I assumed MyPatient was a Patient resource, although that part was not shown in your code. That error message indicates that a resource of type Resource is parsed and found to be invalid, since Resource does not define a ‘generalPractitioner’ field.
Can you check your surrounding code to see if you’ve created a Patient? And if so, what is the code you used to send it to a server ending in the error?
No, for batch it is not possible. The interactions in a batch do not depend on each other - if one fails, the rest can still be carried out. Therefore, resources in batch Bundles are not supposed to be interrelated. See http://hl7.org/fhir/http.html#brules.
@1111: Why do you not use a transaction Bundle in your case?