I am new to FHIR, and I am building a Winforms application in C# that can search Patient resources on a server, modify them, and upload the modifications. The search part works fine and displays entries in the returned bundle as xml in a multiline TextBox called resultTextBox. The idea is that the user can adjust the values here and click an Upload button to store the adjusted resource. The HL7.Fhir.STU3 NuGet package is installed in my project.
Uploading an adjusted resource does not work. This is the code:
returnedSearchBundle contains the bundle that, well, yes indeed, is returned by the search operation.
I found that updatedBundle did not automatically get an Id assigned, so I thought to fix that like so:
Guid newGuid = Guid.NewGuid();
string id = newGuid.ToString().Replace('-'.ToString(), String.Empty);
updateBundle.Id = id;
The Replace() is because maybe the - were not allowed - all other Ids don't have them - but that does not make a difference.
If I run the code with the dashes removed so that the Id resembles other Ids, I get the same error.
Another suggestion I found was to update the resource only and not the bundle, so there wouldn't be an Id issue. This should be established by commenting out the lines between UPDATE BUNDLE and END UPDATE BUNDLE, and uncommenting the line between UPDATE RESOURCE and END UPDATE RESOURCE. I don't get any errors that way, but the resource isn't updated either.
How can I accomplish a resource update?
PS I am very sorry to have my code as images, but stackoverflow appears to be very picky regarding formatting. I've spent over an hour trying to post my question. Google "how to fix stackoverflow "Your post appears to contain code that is not properly formatted as code."" and be amazed at the number of results.