Hi,
I am new to FHIR and trying to implement the FHIR Resource type Patient using demographic data. I have created the Practitioner resource but not sure how to add it to the Patient Resource.
Hl7.Fhir.Model.Practitioner MyGP = new Practitioner();
MyGP.Name.Add(new HumanName().WithGiven(pat.GP_Given_name).AndFamily(pat.GP_Family_name));
Hl7.Fhir.Model.Address MyGPAddress = new Address();
MyGPAddress.Line = new string[] { pat.GP_Practice_Name_St_Suburb };
MyGPAddress.Type = Address.AddressType.Physical;
MyGPAddress.City = pat.GP_Practice_City;
MyGPAddress.State = pat.GP_State;
MyGPAddress.Country = pat.GP_Country;
MyGPAddress.PostalCode = pat.GP_postcode;
MyGP.Address.Add(MyGPAddress);
MyGP.Telecom.Add(new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Work, pat.GP_phone_work));
ResourceReference p = new ResourceReference();
p.Type = ResourceType.Practitioner.ToString();
MyPatient.GeneralPractitioner = ??
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[0]â while parsing).
Please help!
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?