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

Difference between revisions of "FHIR Patch Examples"

From HL7Wiki
Jump to navigation Jump to search
(formatting)
 
Line 1: Line 1:
put examples of patch here
+
===Adding an attribute to a non-list object===
 +
  <diff>&lt;add sel="Patient/gender" type="@id">patient-1-gender-1&lt;/add></diff>
 +
 
 +
  [{"op":"add", "path":"/_gender/id", "value":"patient-1-gender-1"}]
  
 +
=== Adding an attribute to a list object identified by index===
 +
  <diff>&lt;add sel="Patient/identifier[1]" type="@id">identifier-1&lt;/add>/diff>
 +
 
 +
  [{"op":"add", "path":"/identifier/0/id", "value":"identifier-1"}]</code
  
1: Adding an attribute to a non-list object
+
===Adding an attribute to a list object identified by predicate===
<diff><add sel="Patient/gender" type="@id">patient-1-gender-1</add></diff>
+
  <diff>&lt;add sel="Patient/identifier[use/@value='usual']" type="@id">identifier-1&lt;/add></diff>
[{"op":"add", "path":"/_gender/id", "value":"patient-1-gender-1"}]
+
n/a for json
  
2: Adding an attribute to a list object identified by index
+
===Adding a simple non-list object===
<diff><add sel="Patient/identifier[1]" type="@id">identifier-1</add></diff>
+
  <diff>&lt;add sel="Patient/managingOrganization">&lt;display value="Massachusetts General Hospital"/>&lt;/add>/diff>
[{"op":"add", "path":"/identifier/0/id", "value":"identifier-1"}]
+
 
 +
  [{"op":"add", "path":"/managingOrganization/display", "value":"Massachusetts General Hospital"}]
  
3: Adding an attribute to a list object identified by predicate
+
===Adding a complex non-list object===
<diff><add sel="Patient/identifier[use/@value='usual']" type="@id">identifier-1</add></diff>
+
  <diff>&lt;add sel="Patient">&lt;animal>&lt;species>&lt;text value="human"/>&lt;coding>&lt;system value="http://hl7.org/fhir/animal-species"/>&lt;code value="1234-5"/>&lt;display value="human"/>&lt;/coding>&lt;/species>&lt;/animal>&lt;/add>/diff>
n/a
+
 
 +
  [{"op":"add", "path":"/animal", "value":{"species":{"text":"human", "coding":[{"system":"http://hl7.org/fhir/animal-species", "code":"1234-5", "display":"human"}]}}}]
  
4: Adding a simple non-list object
+
===Appending a simple object to a list===
<diff><add sel="Patient/managingOrganization"><display value="Massachusetts General Hospital"/></add></diff>
+
  <diff>&lt;add sel="Patient/name[1]">&lt;given value="Matt"/>&lt;/add>/diff>
[{"op":"add", "path":"/managingOrganization/display", "value":"Massachusetts General Hospital"}]
+
 
 +
  [{"op":"add", "path":"/name/0/given/-", "value":"Matt"}]
  
5: Adding a complex non-list object
+
===Appending a complex object to a list===
<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>
+
  <diff>&lt;add sel="Patient">&lt;name>&lt;use value="old"/>&lt;family value="Hutz"/>&lt;given value="Lionel"/>&lt;given value="J"/>&lt;suffix value="JD"/>&lt;suffix value="Esq."/>&lt;period>&lt;end value="1997-08-02"/>&lt;/period>&lt;/name>&lt;/add>/diff>
[{"op":"add", "path":"/animal", "value":{"species":{"text":"human", "coding":[{"system":"http://hl7.org/fhir/animal-species", "code":"1234-5", "display":"human"}]}} }]
+
 
 +
  [{ "op":"add", "path":"/name/-", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]
  
6: Appending a simple object to a list
+
===Prepending a simple object to a list===
<diff><add sel="Patient/name[1]"><given value="Matt"/></add></diff>
+
  <diff>&lt;add sel="Patient/name[1]" pos="prepend">&lt;given value="John"/>&lt;/add>/diff>
[{"op":"add", "path":"/name/0/given/-", "value":"Matt"}]
+
 
 +
  [{"op":"add", "path":"/name/0/given/0", "value":"John" }]
  
7: Appending a complex object to a list
+
===Prepending 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>
+
  <diff>&lt;add sel="Patient" pos="prepend">&lt;name>&lt;use value="nickname"/>&lt;given value="Pedro"/>&lt;/name>&lt;/add>/diff>
[{ "op":"add", "path":"/name/-", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]
+
 
 +
  [{"op":"add", "path":"/name/0", "value":{"use":"nickname", "given":["Pedro"]} }]
  
8: Prepending a simple object to a list
+
===Inserting a simple object into a list by index (xml pos="before")===
<diff><add sel="Patient/name[1]" pos="prepend"><given value="John"/></add></diff>
+
  <diff>&lt;add sel="Patient/name[1]/given[1]" pos="before">&lt;given value="Matthew"/>&lt;/add>/diff>
[{"op":"add", "path":"/name/0/given/0", "value":"John" }]
+
 
 +
  [{"op":"add", "path":"/name/0/given/0", "value":"Matthew"}]
  
9: Prepending a complex object to a list
+
===Inserting a simple object into a list by index (xml pos="after")===
<diff><add sel="Patient" pos="prepend"><name><use value="nickname"/><given value="Pedro"/></name></add></diff>
+
  <diff>&lt;add sel="Patient/name[1]/given[1]" pos="after">&lt;given value="Matthew"/>&lt;/add>/diff>
[{"op":"add", "path":"/name/0", "value":{"use":"nickname", "given":["Pedro"]} }]
+
 
 +
  [{"op":"add", "path":"/name/0/given/1", "value":"Matthew"}]
  
10: Inserting a simple object into a list by index (xml pos="before")
+
===Inserting an simple object into a list by predicate (xml pos="before")===
<diff><add sel="Patient/name[1]/given[1]" pos="before"><given value="Matthew"/></add></diff>
+
  <diff>&lt;add sel="Patient/name[1]/given[@value='James']" pos="before">&lt;given value="Michael"/>&lt;/add></diff>
[{"op":"add", "path":"/name/0/given/0", "value":"Matthew"}]
+
n/a for json
  
11: Inserting a simple object into a list by index (xml pos="after")
+
===Inserting an simple object into a list by predicate (xml pos="after")===
<diff><add sel="Patient/name[1]/given[1]" pos="after"><given value="Matthew"/></add></diff>
+
  <diff>&lt;add sel="Patient/name[1]/given[@value='James']" pos="after">&lt;given value="Michael"/>&lt;/add></diff>
[{"op":"add", "path":"/name/0/given/1", "value":"Matthew"}]
+
n/a for json
  
12: Inserting an simple object into a list by predicate (xml pos="before")
+
===Inserting a complex object into a list by index (xml pos="before")===
<diff><add sel="Patient/name[1]/given[@value='James']" pos="before"><given value="Michael"/></add></diff>
+
  <diff>&lt;add sel="Patient/name[2]" pos="before">&lt;name>&lt;use value="old"/>&lt;family value="Hutz"/>&lt;given value="Lionel"/>&lt;given value="J"/>&lt;suffix value="JD"/>&lt;suffix value="Esq."/>&lt;period>&lt;end value="1997-08-02"/>&lt;/period>&lt;/name>&lt;/add>/diff>
n/a
+
 
 +
  [{ "op":"add", "path":"/name/1", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]
  
13: Inserting an simple object into a list by predicate (xml pos="after")
+
===Inserting a complex object into a list by index (xml pos="after")===
<diff><add sel="Patient/name[1]/given[@value='James']" pos="after"><given value="Michael"/></add></diff>
+
  <diff>&lt;add sel="Patient/name[1]" pos="after">&lt;name>&lt;use value="old"/>&lt;family value="Hutz"/>&lt;given value="Lionel"/>&lt;given value="J"/>&lt;suffix value="JD"/>&lt;suffix value="Esq."/>&lt;period>&lt;end value="1997-08-02"/>&lt;/period>&lt;/name>&lt;/add>/diff>
n/a
+
 
 +
  [{ "op":"add", "path":"/name/1", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]
  
14: Inserting a complex object into a list by index (xml pos="before")
+
===Replacing an attribute on a non-list object===
<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>
+
  <diff>&lt;replace sel="Patient/birthDate/@value">1984-10-11&lt;/replace>/diff>
[{ "op":"add", "path":"/name/1", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]
+
 
 +
  [{ "op":"replace", "path":"/birthDate", "value":"1984-10-11" }]
  
15: Inserting a complex object into a list by index (xml pos="after")
+
===Replacing an attribute on a list object selected by index===
<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>
+
  <diff>&lt;replace sel="Patient/name[1]/given[1]/@value">Petey&lt;/replace>/diff>
[{ "op":"add", "path":"/name/1", "value":{"use":"old", "family":["Hutz"], "given":["Lionel","J"], "suffix":["JD","Esq."], "period":{"end":"1997-08-02"}} }]
+
 
 +
  [{ "op":"replace", "path":"name/0/given/0", "value":"Petey" }]
  
16: Replacing an attribute on a non-list object
+
===Replacing an attribute on a list object selected by predicate===
<diff><replace sel="Patient/birthDate/@value">1984-10-11</replace></diff>
+
  <diff>&lt;replace sel="Patient/name[1]/given[@value='Peter']/@value">Pedro&lt;/replace></diff>
[{ "op":"replace", "path":"/birthDate", "value":"1984-10-11" }]
+
n/a for json
  
17: Replacing an attribute on a list object selected by index
+
===Replacing a non-list object===
<diff><replace sel="Patient/name[1]/given[1]/@value">Petey</replace></diff>
+
  <diff>&lt;replace sel="Patient/managingOrganization">&lt;managingOrganization>&lt;reference value="Organization/536"/>&lt;display value="MGH"/>&lt;/managingOrganization>&lt;/replace>/diff>
[{ "op":"replace", "path":"name/0/given/0", "value":"Petey" }]
+
 
 +
  [{ "op":"replace", "path":"/managingOrganization", "value":{"reference":"Organization/536", "display":"MGH"} }]
  
18: Replacing an attribute on a list object selected by predicate
+
===Replacing an object in a list selected by index===
<diff><replace sel="Patient/name[1]/given[@value='Peter']/@value">Pedro</replace></diff>
+
  <diff>&lt;replace sel="Patient/name[2]">&lt;name>&lt;use value="usual"/>&lt;given value="Jimmy"/>&lt;/name>&lt;/replace>/diff>
n/a
+
 
 +
  [{ "op":"replace", "path":"/name/1", "value":{"use":"usual", "given":["Jimmy"]} }]
  
19: Replacing a non-list object
+
===Replacing an object in a list selected by predicate===
<diff><replace sel="Patient/managingOrganization"><managingOrganization><reference value="Organization/536"/><display value="MGH"/></managingOrganization></replace></diff>
+
  <diff>&lt;replace sel="Patient/name[use/@value='official']/given[@value='Peter']">&lt;given value="Pierre"/>&lt;/replace></diff>
[{ "op":"replace", "path":"/managingOrganization", "value":{"reference":"Organization/536", "display":"MGH"} }]
+
n/a for json
  
20: Replacing an object in a list selected by index
+
===Replacing all entries in a list with a single object===
<diff><replace sel="Patient/name[2]"><name><use value="usual"/><given value="Jimmy"/></name></replace></diff>
+
  <diff>&lt;replace sel="Patient/name">&lt;name>&lt;use value="official"/>&lt;family value="Johnson"/>&lt;given value="Eric"/>&lt;given value="Middle"/>&lt;/name>&lt;/replace>/diff>
[{ "op":"replace", "path":"/name/1", "value":{"use":"usual", "given":["Jimmy"]} }]
+
 
 +
  [{ "op":"replace", "path":"/name", "value":[{"use":"official", "family":["Johnson"], "given":["Eric", "Middle"]}] }]
  
21: Replacing an object in a list selected by predicate
+
===Removing an attribute on a non-list object===
<diff><replace sel="Patient/name[use/@value='official']/given[@value='Peter']"><given value="Pierre"/></replace></diff>
+
  <diff>&lt;remove sel="Patient/name[1]/use/@value"/>/diff>
n/a
+
 
 +
  [{ "op":"remove", "path":"/name/0/use" }]
  
22: Replacing all entries in a list with a single object
+
===Removing an attribute on a list object selected by index===
<diff><replace sel="Patient/name"><name><use value="official"/><family value="Johnson"/><given value="Eric"/><given value="Middle"/></name></replace></diff>
+
  <diff>&lt;remove sel="Patient/birthDate/extension[1]/@url"/>/diff>
[{ "op":"replace", "path":"/name", "value":[{"use":"official", "family":["Johnson"], "given":["Eric", "Middle"]}] }]
+
 
 +
  [{ "op":"remove", "path":"/birthDate/extension/0/url" }]
  
23: Removing an attribute on a non-list object
+
===Removing an attribute on a list object selected by predicate===
<diff><remove sel="Patient/name[1]/use/@value"/></diff>
+
  <diff>&lt;remove sel="Patient/name[use/@value='official']/given[@value='James']/@value"/></diff>
[{ "op":"remove", "path":"/name/0/use" }]
+
n/a for json
  
24: Removing an attribute on a list object selected by index
+
===Removing a non-list object===
<diff><remove sel="Patient/birthDate/extension[1]/@url"/></diff>
+
  <diff>&lt;remove sel="Patient/managingOrganization"/>/diff>
[{ "op":"remove", "path":"/birthDate/extension/0/url" }]
+
 
 +
  [{ "op":"remove", "path":"/managingOrganization" }]
  
25: Removing an attribute on a list object selected by predicate
+
===Removing a list object selected by index===
<diff><remove sel="Patient/name[use/@value='official']/given[@value='James']/@value"/></diff>
+
  <diff>&lt;remove sel="Patient/name[1]"/>/diff>
n/a
+
 
 +
  [{ "op":"remove", "path":"/name/0" }]
  
26: Removing a non-list object
+
===Removing a list object selected by predicate===
<diff><remove sel="Patient/managingOrganization"/></diff>
+
  <diff>&lt;remove sel="Patient/name[use/@value='usual']"/></diff>
[{ "op":"remove", "path":"/managingOrganization" }]
+
n/a for json
  
27: Removing a list object selected by index
+
===Removing an entire list===
<diff><remove sel="Patient/name[1]"/></diff>
+
  <diff>&lt;remove sel="Patient/name"/>/diff>
[{ "op":"remove", "path":"/name/0" }]
+
 
 
+
  [{ "op":"remove", "path":"/name" }]
28: Removing a list object selected by predicate
 
<diff><remove sel="Patient/name[use/@value='usual']"/></diff>
 
n/a
 
 
 
29: Removing an entire list
 
<diff><remove sel="Patient/name"/></diff>
 
[{ "op":"remove", "path":"/name" }]
 

Latest revision as of 15:18, 18 September 2016

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" }]