This wiki has undergone a migration to Confluence found Here
<meta name="googlebot" content="noindex">

FHIR Patch Examples

From HL7Wiki
Revision as of 15:18, 18 September 2016 by Jenni syed (talk | contribs) (formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Contents

Adding an attribute to a non-list object

 <diff><add sel="Patient/gender" type="@id">patient-1-gender-1</add></diff>
 
 [{"op":"add", "path":"/_gender/id", "value":"patient-1-gender-1"}]

Adding an attribute to a list object identified by index

 <diff><add sel="Patient/identifier[1]" type="@id">identifier-1</add>/diff>
 
 [{"op":"add", "path":"/identifier/0/id", "value":"identifier-1"}]</code

Adding an attribute to a list object identified by predicate

 <diff><add sel="Patient/identifier[use/@value='usual']" type="@id">identifier-1</add></diff>

n/a for json

Adding a simple non-list object

 <diff><add sel="Patient/managingOrganization"><display value="Massachusetts General Hospital"/></add>/diff>
 
 [{"op":"add", "path":"/managingOrganization/display", "value":"Massachusetts General Hospital"}]

Adding a complex non-list object

 <diff><add sel="Patient"><animal><species><text value="human"/><coding><system value="http://hl7.org/fhir/animal-species"/><code value="1234-5"/><display value="human"/></coding></species></animal></add>/diff>
 
 [{"op":"add", "path":"/animal", "value":{"species":{"text":"human", "coding":[{"system":"http://hl7.org/fhir/animal-species", "code":"1234-5", "display":"human"}]}}}]

Appending a simple object to a list

 <diff><add sel="Patient/name[1]"><given value="Matt"/></add>/diff>
 
 [{"op":"add", "path":"/name/0/given/-", "value":"Matt"}]

Appending a complex object to a list

 <diff><add sel="Patient"><name><use value="old"/><family value="Hutz"/><given value="Lionel"/><given value="J"/><suffix value="JD"/><suffix value="Esq."/><period><end value="1997-08-02"/></period></name></add>/diff>
 
 [{ "op":"add", "path":"/name/-", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]

Prepending a simple object to a list

 <diff><add sel="Patient/name[1]" pos="prepend"><given value="John"/></add>/diff>
 
 [{"op":"add", "path":"/name/0/given/0", "value":"John" }]

Prepending a complex object to a list

 <diff><add sel="Patient" pos="prepend"><name><use value="nickname"/><given value="Pedro"/></name></add>/diff>
 
 [{"op":"add", "path":"/name/0", "value":{"use":"nickname", "given":["Pedro"]} }]

Inserting a simple object into a list by index (xml pos="before")

 <diff><add sel="Patient/name[1]/given[1]" pos="before"><given value="Matthew"/></add>/diff>
 
 [{"op":"add", "path":"/name/0/given/0", "value":"Matthew"}]

Inserting a simple object into a list by index (xml pos="after")

 <diff><add sel="Patient/name[1]/given[1]" pos="after"><given value="Matthew"/></add>/diff>
 
 [{"op":"add", "path":"/name/0/given/1", "value":"Matthew"}]

Inserting an simple object into a list by predicate (xml pos="before")

 <diff><add sel="Patient/name[1]/given[@value='James']" pos="before"><given value="Michael"/></add></diff>

n/a for json

Inserting an simple object into a list by predicate (xml pos="after")

 <diff><add sel="Patient/name[1]/given[@value='James']" pos="after"><given value="Michael"/></add></diff>

n/a for json

Inserting a complex object into a list by index (xml pos="before")

 <diff><add sel="Patient/name[2]" pos="before"><name><use value="old"/><family value="Hutz"/><given value="Lionel"/><given value="J"/><suffix value="JD"/><suffix value="Esq."/><period><end value="1997-08-02"/></period></name></add>/diff>
 
 [{ "op":"add", "path":"/name/1", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]

Inserting a complex object into a list by index (xml pos="after")

 <diff><add sel="Patient/name[1]" pos="after"><name><use value="old"/><family value="Hutz"/><given value="Lionel"/><given value="J"/><suffix value="JD"/><suffix value="Esq."/><period><end value="1997-08-02"/></period></name></add>/diff>
 
 [{ "op":"add", "path":"/name/1", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]

Replacing an attribute on a non-list object

 <diff><replace sel="Patient/birthDate/@value">1984-10-11</replace>/diff>
 
 [{ "op":"replace", "path":"/birthDate", "value":"1984-10-11" }]

Replacing an attribute on a list object selected by index

 <diff><replace sel="Patient/name[1]/given[1]/@value">Petey</replace>/diff>
 
 [{ "op":"replace", "path":"name/0/given/0", "value":"Petey" }]

Replacing an attribute on a list object selected by predicate

 <diff><replace sel="Patient/name[1]/given[@value='Peter']/@value">Pedro</replace></diff>

n/a for json

Replacing a non-list object

 <diff><replace sel="Patient/managingOrganization"><managingOrganization><reference value="Organization/536"/><display value="MGH"/></managingOrganization></replace>/diff>
 
 [{ "op":"replace", "path":"/managingOrganization", "value":{"reference":"Organization/536", "display":"MGH"} }]

Replacing an object in a list selected by index

 <diff><replace sel="Patient/name[2]"><name><use value="usual"/><given value="Jimmy"/></name></replace>/diff>
 
 [{ "op":"replace", "path":"/name/1", "value":{"use":"usual", "given":["Jimmy"]} }]

Replacing an object in a list selected by predicate

 <diff><replace sel="Patient/name[use/@value='official']/given[@value='Peter']"><given value="Pierre"/></replace></diff>

n/a for json

Replacing all entries in a list with a single object

 <diff><replace sel="Patient/name"><name><use value="official"/><family value="Johnson"/><given value="Eric"/><given value="Middle"/></name></replace>/diff>
 
 [{ "op":"replace", "path":"/name", "value":[{"use":"official", "family":["Johnson"], "given":["Eric", "Middle"]}] }]

Removing an attribute on a non-list object

 <diff><remove sel="Patient/name[1]/use/@value"/>/diff>
 
 [{ "op":"remove", "path":"/name/0/use" }]

Removing an attribute on a list object selected by index

 <diff><remove sel="Patient/birthDate/extension[1]/@url"/>/diff>
 
 [{ "op":"remove", "path":"/birthDate/extension/0/url" }]

Removing an attribute on a list object selected by predicate

 <diff><remove sel="Patient/name[use/@value='official']/given[@value='James']/@value"/></diff>

n/a for json

Removing a non-list object

 <diff><remove sel="Patient/managingOrganization"/>/diff>
 
 [{ "op":"remove", "path":"/managingOrganization" }]

Removing a list object selected by index

 <diff><remove sel="Patient/name[1]"/>/diff>
 
 [{ "op":"remove", "path":"/name/0" }]

Removing a list object selected by predicate

 <diff><remove sel="Patient/name[use/@value='usual']"/></diff>

n/a for json

Removing an entire list

 <diff><remove sel="Patient/name"/>/diff>
 
 [{ "op":"remove", "path":"/name" }]