Creating a new patient and study from attachments

Hello all,

I need to be able to use the REST API to create a new patient and study. I don’t have any DICOM files to be associated with the study but I have attachments.

I have the user defined data for the patient and study tags but don’t know how to create a new study and patient instance with the data. Without the study instance I am unable to add the attachments.

Thanks,
Callie

Hi Callie,

Indeed, you need at least one DICOM file in Orthanc in order to create the Study and Patient and be able to attach attachments to it.

Maybe you can create a DICOM with some of your PDF attachments or create a study with a fake image or an empty PDF file.

You can get inspiration from this python code that is used to attach a pdf as a DICOM instance to an existing study. In your case, since the study does not exist, you may not use the ‘Parent’ argument but you have to provide at least the PatientID tag. That would end up sending this kind of request:

r = requests.post(
url=f"{orthanc_url}/tools/create-dicom",
json={
“Tags” : {

“PatientName”: “…”,
“PatientID”: “…”,
“StudyDescription”: “…”,
“Modality” : “OT”,
“SeriesDescription” : “Sample protocol”
},
“Content”: “data:application/pdf;base64,” + base64.b64encode(pdf_content).decode(‘utf-8’)
}
)

HTH,

Alain.

This is really good to know! Thank you Alain! :blush: I appreciate your time.