Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export DICOM images via FTPS #190

Closed
7 tasks done
stefpiatek opened this issue Dec 18, 2023 · 1 comment · Fixed by #226
Closed
7 tasks done

Export DICOM images via FTPS #190

stefpiatek opened this issue Dec 18, 2023 · 1 comment · Fixed by #226
Assignees
Milestone

Comments

@stefpiatek
Copy link
Contributor

stefpiatek commented Dec 18, 2023

Definition of Done / Acceptance Criteria

De-identified DICOM images will be downloaded from orthanc-anon and sent via FTPS to the DSH under the project slug directory using the pseudonymised id as the filename (e.g. {project-slug}/{study-pseduonymised-id}.zip)

Breakdown of steps for progress:

  • get pseudonymised identifier for image from DICOM data (currently in patient ID tag you can do this in a REST request: {dicom-server}/instances/{resource-id}/content/0010-0020 gets us just the patient idenfier, see below for details)
  • get project name slug from PIXL db using the pseudonymised identifier (in pixl db: Image.hashed_identifier)
  • download zip of DICOM data (see details below)
  • upload zip of DICOM data to {project-slug}/{study-pseduonymised-id}.zip on the DSH (see details and prototype repo below)
  • Update the existing image row in the database with the current time added to exported_at

Testing

In an ideal world we'd have a mock DSH in docker compose which we can ftp into. If we can set this up in a day then probably worth it. Have a prototype repo for setting this up so I think this should be quick,

Current State

At the moment DICOM images are pushed via the DICOMweb protocol to an azure DICOM server. Sadly the DSH doesn't have a DICOM server that we can use, so we'll have to use FTPS for 100 days.

Documentation

No response

Dependencies

Details and Comments

Getting hashed identifier

Downloading dicom data

It looks like its possible to do this using the resourceId that we currently use in the dicomweb request in SendViaStow in orthanc-anon.

All instances of a study can be retrieved as a zip file as follows:

$ curl http://localhost:8042/studies/6b9e19d9-62094390-5f9ddb01-4a191ae7-9766b715/archive > Study.zip

So in python we could do something like this?

# Query orthanc-anon for the study
query = f "{orthanc_url}/studies/{resource_id}/archive"
response_study = requests.get(query, verify=False,   
							  auth=(orthanc_user, orthanc_password))  
if response_study.status_code != 200:  
	raise SpecificException(f"Could not download archive of resource '{resource_id}'")
# get the zip content
zip_content = response_study.content  

Copying file

@tcouch uses this curl command to send data to the DSH

curl --netrc --tlsv1.2 --ftp-ssl-reqd --ftp-create-dirs -T $ZIPFILE.zip "ftps://filetransfer.idhs.ucl.ac.uk/"

We can convert this to python that creates a directory in the FTP server if it doesn't exist. 🎉 Prototype repo that can be used as a basis for automated testing 🎉

@docsteveharris
Copy link

request from Tim to bear in mind that we'd need to the same for non-imaging tasks

@stefpiatek stefpiatek assigned ruaridhg and unassigned jeremyestein Jan 15, 2024
@milanmlft milanmlft changed the title Export DICOM images via SFTP Export DICOM images via FTPS Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants