Created
August 2, 2022 06:54
-
-
Save johngrimes/31b3565279b46e061b3aa6fc48184502 to your computer and use it in GitHub Desktop.
Convert between FHIR search and update Bundles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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