Patch without needing to specify index?
# support
v
Is there a way to patch a resource with an identifier other than the index?
Copy code
const result = await medplum.patchResource('Patient', '123', [
  {op: 'replace', path: '/name/0/family', value: 'Smith'},
]);
console.log(result.meta.versionId);
Or... Is there a way to know the index if I'm using list args?
r
Hi @vinny1575 , the patch resource follows the JSON patch specification, which requires an index, unfortunately. The only exception is that you can use the
-
character to refer to the end of a list https://jsonpatch.com/
We've discussed internally implementing the FHIRPatch spec, which might solve your problem. But this is an untested part of the spec so we just want to be cautious. Let us know if this would help http://hl7.org/fhir/R4/fhirpatch.html
157 Views