Created
June 14, 2024 19:00
-
-
Save dkapitan/67ba9a473231ef0d86e99c70066de4ac to your computer and use it in GitHub Desktop.
Simple redacting of FHIR patient resource in ndjson
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 ndjson | |
def redact(patient: dict) -> dict: | |
for key in ["name", "telecom"]: | |
patient.pop(key, None) | |
return patient | |
with open("patient.ndjson") as f: | |
patients = ndjson.load(f) | |
redacted_patient = [redact(patient) for patient in patients] | |
with open("patient_redacted.ndjon", "w") as f: | |
writer = ndjson.writer(f, ensure_ascii=False) | |
for patient in redacted_patient: | |
writer.writerow(patient) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment