firely-net-sdk icon indicating copy to clipboard operation
firely-net-sdk copied to clipboard

Add support for sending the JSON PATCH interaction to FhirClient

Open ewoutkramer opened this issue 1 year ago • 0 comments

Discussed in https://github.com/FirelyTeam/firely-net-sdk/discussions/2217

Originally posted by timammons August 30, 2022 I am trying to patch a patient in the following way, but getting an error body: must be a list of patch operation requests. Any idea why?

Code: `static void UpdatePatientName(FhirClient fireClient, string patientID) { var pat = fireClient.Read<Patient>($"/Patient/{patientID}"); var eTag = fireClient.LastResult.Etag;

Parameters patParams = new Parameters();
patParams.AddReplacePatchParameter("name/0/given", new HumanName().WithGiven("Beulah").WithGiven("Z"));

fireClient.RequestHeaders.IfMatch.Add(new EntityTagHeaderValue($"\"{eTag}\"", true)); 
var updatedPat = fireClient.Patch<Patient>($"{patientID}", patParams);

}`

This is the body it created, which appears to be a list of patch operation requests: {"resourceType":"Parameters","parameter":[{"name":"operation","part":[{"name":"type","valueCode":"replace"},{"name":"path","valueString":"name/0/given"},{"name":"value","valueHumanName":{"given":["Beulah","Z"]}}]}]}

Thanks, Tim

ewoutkramer avatar Jan 11 '24 15:01 ewoutkramer