fhir-fuel / fhir-fuel.github.io

Place to prepare proposal to FHIR about JSON, JSON-Schema, Swagger/OpenAPI, JSON native databases and other JSON-frendly formats (yaml, edn, avro, protobuf etc) and technologies
Other
21 stars 0 forks source link

Simple, but useful PATCH operation #9

Open niquola opened 7 years ago

niquola commented 7 years ago

Problem

Sometimes you need update only part of resource, but FHIR operations granularity requires to update resource as a whole. There is json/xml-diff proposal, but it's not so easy to construct diff, you need some library. Server could diff and do it for you

Solution 1

Patch operation with the logic of object/hash-map merging:


PUT /Patient/1
{ 
  birthDate: '1970-01-01',
  name: [{given: ['nicola'], family: 'Ryzhikov', use: 'official'}],
  active: false
}

PATCH /Patient/1
{
  active: null, // delete active element
  birthDate: '1970-02-01' // updaet birthDate element
}

Open questions

grahamegrieve commented 7 years ago

why not just use what the spec says about patch?

On Wed, Jun 21, 2017 at 4:06 AM, niquola notifications@github.com wrote:

Problem

Sometimes you need update only part of resource, but FHIR operations granularity requires to update resource as a whole. There is json/xml-diff proposal, but it's not so easy to construct diff, you need some library. Server could diff and do it for you Solution 1

Patch operation with the logic of object/hash-map merging:

PUT /Patient/1 { birthDate: '1970-01-01', name: [{given: ['nicola'], family: 'Ryzhikov', use: 'official'}], active: false } PATCH /Patient/1 { active: null, // delete active element birthDate: '1970-02-01' // updaet birthDate element }

Open questions

  • more cases
  • how work with collections?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fhir-fuel/fhir-fuel.github.io/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/AFllFcYyO1unUFKTg4nqt2EpfQXO_QC8ks5sGAokgaJpZM4N_87o .

--

http://www.healthintersections.com.au / grahame@healthintersections.com.au / +61 411 867 065

niquola commented 7 years ago

This is just a sugar to PATCH API - 80% simplicity for 80% simple cases

grahamegrieve commented 7 years ago

well, ok. maybe. I think it will turn out that the syntax is simpler, but using it is full of pitfalls, and the simplicity will be marginal. There's a reason why the existing xml and json patch don't do things that way?

Grahame

On Thu, Jun 22, 2017 at 7:52 AM, niquola notifications@github.com wrote:

This is just a sugar to PATCH API - 80% simplicity for 80% cases

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fhir-fuel/fhir-fuel.github.io/issues/9#issuecomment-310215898, or mute the thread https://github.com/notifications/unsubscribe-auth/AFllFYNkEjDg54YX2Q8MEEMlhSE5q3rXks5sGZCzgaJpZM4N_87o .

--

http://www.healthintersections.com.au / grahame@healthintersections.com.au / +61 411 867 065

niquola commented 6 years ago

https://datatracker.ietf.org/doc/rfc7396/?include_text=1 could be used for this

igorsirkovich commented 6 years ago

I agree that this would be a simpler solution than regular PATCH in many scenarios.