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
(Created page with "put examples of patch here")
 
(formatting)
 
(One intermediate revision by one other user not shown)
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
 +
 
 +
===Adding an attribute to a list object identified by predicate===
 +
  <diff>&lt;add sel="Patient/identifier[use/@value='usual']" type="@id">identifier-1&lt;/add></diff>
 +
n/a for json
 +
 
 +
===Adding a simple non-list object===
 +
  <diff>&lt;add sel="Patient/managingOrganization">&lt;display value="Massachusetts General Hospital"/>&lt;/add>/diff>
 +
 
 +
  [{"op":"add", "path":"/managingOrganization/display", "value":"Massachusetts General Hospital"}]
 +
 
 +
===Adding a complex non-list object===
 +
  <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>
 +
 
 +
  [{"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>&lt;add sel="Patient/name[1]">&lt;given value="Matt"/>&lt;/add>/diff>
 +
 
 +
  [{"op":"add", "path":"/name/0/given/-", "value":"Matt"}]
 +
 
 +
===Appending a complex object to a list===
 +
  <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":"/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>&lt;add sel="Patient/name[1]" pos="prepend">&lt;given value="John"/>&lt;/add>/diff>
 +
 
 +
  [{"op":"add", "path":"/name/0/given/0", "value":"John" }]
 +
 
 +
===Prepending a complex object to a list===
 +
  <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/0", "value":{"use":"nickname", "given":["Pedro"]} }]
 +
 
 +
===Inserting a simple object into a list by index (xml pos="before")===
 +
  <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":"Matthew"}]
 +
 
 +
===Inserting a simple object into a list by index (xml pos="after")===
 +
  <diff>&lt;add sel="Patient/name[1]/given[1]" pos="after">&lt;given value="Matthew"/>&lt;/add>/diff>
 +
 
 +
  [{"op":"add", "path":"/name/0/given/1", "value":"Matthew"}]
 +
 
 +
===Inserting an simple object into a list by predicate (xml pos="before")===
 +
  <diff>&lt;add sel="Patient/name[1]/given[@value='James']" pos="before">&lt;given value="Michael"/>&lt;/add></diff>
 +
n/a for json
 +
 
 +
===Inserting an simple object into a list by predicate (xml pos="after")===
 +
  <diff>&lt;add sel="Patient/name[1]/given[@value='James']" pos="after">&lt;given value="Michael"/>&lt;/add></diff>
 +
n/a for json
 +
 
 +
===Inserting a complex object into a list by index (xml pos="before")===
 +
  <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>
 +
 
 +
  [{ "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>&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>
 +
 
 +
  [{ "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>&lt;replace sel="Patient/birthDate/@value">1984-10-11&lt;/replace>/diff>
 +
 
 +
  [{ "op":"replace", "path":"/birthDate", "value":"1984-10-11" }]
 +
 
 +
===Replacing an attribute on a list object selected by index===
 +
  <diff>&lt;replace sel="Patient/name[1]/given[1]/@value">Petey&lt;/replace>/diff>
 +
 
 +
  [{ "op":"replace", "path":"name/0/given/0", "value":"Petey" }]
 +
 
 +
===Replacing an attribute on a list object selected by predicate===
 +
  <diff>&lt;replace sel="Patient/name[1]/given[@value='Peter']/@value">Pedro&lt;/replace></diff>
 +
n/a for json
 +
 
 +
===Replacing a non-list object===
 +
  <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":"/managingOrganization", "value":{"reference":"Organization/536", "display":"MGH"} }]
 +
 
 +
===Replacing an object in a list selected by index===
 +
  <diff>&lt;replace sel="Patient/name[2]">&lt;name>&lt;use value="usual"/>&lt;given value="Jimmy"/>&lt;/name>&lt;/replace>/diff>
 +
 
 +
  [{ "op":"replace", "path":"/name/1", "value":{"use":"usual", "given":["Jimmy"]} }]
 +
 
 +
===Replacing an object in a list selected by predicate===
 +
  <diff>&lt;replace sel="Patient/name[use/@value='official']/given[@value='Peter']">&lt;given value="Pierre"/>&lt;/replace></diff>
 +
n/a for json
 +
 
 +
===Replacing all entries in a list with a single object===
 +
  <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", "value":[{"use":"official", "family":["Johnson"], "given":["Eric", "Middle"]}] }]
 +
 
 +
===Removing an attribute on a non-list object===
 +
  <diff>&lt;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>&lt;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>&lt;remove sel="Patient/name[use/@value='official']/given[@value='James']/@value"/></diff>
 +
n/a for json
 +
 
 +
===Removing a non-list object===
 +
  <diff>&lt;remove sel="Patient/managingOrganization"/>/diff>
 +
 
 +
  [{ "op":"remove", "path":"/managingOrganization" }]
 +
 
 +
===Removing a list object selected by index===
 +
  <diff>&lt;remove sel="Patient/name[1]"/>/diff>
 +
 
 +
  [{ "op":"remove", "path":"/name/0" }]
 +
 
 +
===Removing a list object selected by predicate===
 +
  <diff>&lt;remove sel="Patient/name[use/@value='usual']"/></diff>
 +
n/a for json
 +
 
 +
===Removing an entire list===
 +
  <diff>&lt;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" }]