Skip to content

Instantly share code, notes, and snippets.

@johngrimes
Created August 2, 2022 06:54
Show Gist options
  • Save johngrimes/31b3565279b46e061b3aa6fc48184502 to your computer and use it in GitHub Desktop.
Save johngrimes/31b3565279b46e061b3aa6fc48184502 to your computer and use it in GitHub Desktop.
Convert between FHIR search and update Bundles
import json
import sys
input_bundle = json.load(sys.stdin)
output_bundle = {
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": e["resource"],
"request": {
"method": "PUT",
"url": f'{e["resource"]["resourceType"]}/{e["resource"]["id"]}',
},
}
for e in input_bundle["entry"]
],
}
print(json.dumps(output_bundle, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment