You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm very new to FHIR and I'm learning. Any help is much appreciated. I'm trying to attach a PDF file to a document reference for a patient. I'm using the following code:
fromfhirclient.models.patientimportPatientfromfhirclient.models.documentreferenceimportDocumentReferencefromfhirclient.models.attachmentimportAttachmentfromfhirclient.models.binaryimportBinaryfromfhirclientimportclient# client to local HAPI FHIR serversmart=client.FHIRClient({'api_base':'http://localhost:8080/baseDtsu3', 'app_id':''})
smart.prepare()
# get a patientpatient=Patient.read('1', smart.server)
# make a document referencedr=DocumentReference()
dr.subject=patient# make attachmenta=Attachment()
a.contentType='application/pdf'# read in pdf filepdf_file= ....
pdf_data=Nonewithopen(pdf_file, 'rb') asf:
pdf_data=f.read()
a.data=pdf_datadr.attachment=a# now try to postdr.create(smart.server)
When I try running this code, I get an error stating that Expecting property "data" on <class 'fhirclient.models.attachment.Attachment'> to be <class 'str'>, but is <class 'bytes'>. How should the binary data be stored?
Where now pdf_b64_m is a UTF-8 encoded string. Is this the correct way to store the data? I would then be able to re-encode it back to binary, but I want to make sure that this is correct so other programs that download the data from the server can interpret the PDF correctly.
The text was updated successfully, but these errors were encountered:
Hi all,
I'm very new to FHIR and I'm learning. Any help is much appreciated. I'm trying to attach a PDF file to a document reference for a patient. I'm using the following code:
When I try running this code, I get an error stating that
Expecting property "data" on <class 'fhirclient.models.attachment.Attachment'> to be <class 'str'>, but is <class 'bytes'>
. How should the binary data be stored?I could do something like:
Where now
pdf_b64_m
is a UTF-8 encoded string. Is this the correct way to store the data? I would then be able to re-encode it back to binary, but I want to make sure that this is correct so other programs that download the data from the server can interpret the PDF correctly.The text was updated successfully, but these errors were encountered: