Difference between revisions of "FHIR Patch Examples"
(Created page with "put examples of patch here") |
|||
Line 1: | Line 1: | ||
put examples of patch here | put examples of patch here | ||
+ | |||
+ | |||
+ | 1: 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"}] | ||
+ | |||
+ | 2: 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"}] | ||
+ | |||
+ | 3: 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 | ||
+ | |||
+ | 4: 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"}] | ||
+ | |||
+ | 5: 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"}]}} }] | ||
+ | |||
+ | 6: 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"}] | ||
+ | |||
+ | 7: 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"}} }] | ||
+ | |||
+ | 8: 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" }] | ||
+ | |||
+ | 9: 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"]} }] | ||
+ | |||
+ | 10: 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"}] | ||
+ | |||
+ | 11: 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"}] | ||
+ | |||
+ | 12: 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 | ||
+ | |||
+ | 13: 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 | ||
+ | |||
+ | 14: 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"}} }] | ||
+ | |||
+ | 15: 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"}} }] | ||
+ | |||
+ | 16: 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" }] | ||
+ | |||
+ | 17: 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" }] | ||
+ | |||
+ | 18: 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 | ||
+ | |||
+ | 19: 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"} }] | ||
+ | |||
+ | 20: 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"]} }] | ||
+ | |||
+ | 21: 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 | ||
+ | |||
+ | 22: 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"]}] }] | ||
+ | |||
+ | 23: Removing an attribute on a non-list object | ||
+ | <diff><remove sel="Patient/name[1]/use/@value"/></diff> | ||
+ | [{ "op":"remove", "path":"/name/0/use" }] | ||
+ | |||
+ | 24: 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" }] | ||
+ | |||
+ | 25: 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 | ||
+ | |||
+ | 26: Removing a non-list object | ||
+ | <diff><remove sel="Patient/managingOrganization"/></diff> | ||
+ | [{ "op":"remove", "path":"/managingOrganization" }] | ||
+ | |||
+ | 27: Removing a list object selected by index | ||
+ | <diff><remove sel="Patient/name[1]"/></diff> | ||
+ | [{ "op":"remove", "path":"/name/0" }] | ||
+ | |||
+ | 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" }] |
Revision as of 17:29, 17 September 2016
put examples of patch here
1: 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"}]
2: 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"}]
3: 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
4: 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"}]
5: Adding a complex non-list object
<diff><add sel="Patient"><animal><species><text value="human"/><coding><system value="http://hl7.org/fhir/animal-species"/><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"}]}} }]
6: 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"}]
7: 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"}} }]
8: 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" }]
9: 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"]} }]
10: 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"}]
11: 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"}]
12: 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
13: 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
14: 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"}} }]
15: 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"}} }]
16: 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" }]
17: 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" }]
18: 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
19: 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"} }]
20: 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"]} }]
21: 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
22: 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"]}] }]
23: Removing an attribute on a non-list object <diff><remove sel="Patient/name[1]/use/@value"/></diff> [{ "op":"remove", "path":"/name/0/use" }]
24: 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" }]
25: 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
26: Removing a non-list object <diff><remove sel="Patient/managingOrganization"/></diff> [{ "op":"remove", "path":"/managingOrganization" }]
27: Removing a list object selected by index <diff><remove sel="Patient/name[1]"/></diff> [{ "op":"remove", "path":"/name/0" }]
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" }]