How to get date added of a DICOM study in orthanc?
Assistant
In the context of using Orthanc, which is an open-source DICOM server, you would retrieve the date a DICOM study was added to the Orthanc database through its REST API. This date is not the same as the study date (the date the study was conducted), but rather the date the study was ingested or stored in Orthanc.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To fetch the date a study was added to Orthanc, you can use the REST API to get the metadata associated with the study. The specific metadata tag that holds the date and time when a resource was stored in Orthanc is called LastUpdate. Note that while LastUpdate reflects the last time the metadata about the DICOM study was changed, it can also serve as the study's addition date if the study hasn't been updated since it was added.
Here's a step-by-step process to get the date a study was added to Orthanc using its REST API:
Ensure that Orthanc is running and that you have the StudyInstanceUID of the study of interest.
Use an HTTP client (such as curl, Postman, or any programming language with HTTP request capabilities) to make a GET request to the /studies/{StudyInstanceUID}/metadata endpoint of the Orthanc API.
Extract the LastUpdate metadata field from the JSON response.
Here's an example of how to do this using curl from a command line:
curl -X GET http://localhost:8042/studies/{StudyInstanceUID}/metadata
Replace {StudyInstanceUID} with the actual UID of the study you're interested in. This will return a JSON response containing the metadata about the study, including the LastUpdate timestamp.
Here is how you can parse the JSON response in command-line using jq:
curl -s -X GET http://localhost:8042/studies/{StudyInstanceUID}/metadata | jq '.LastUpdate'
Remember to install jq if you haven't already, as it's a tool for processing JSON inputs via command line.
If you are using a programming language such as Python, you might write a simple script as follows:
import requests
import json
orthanc_url = 'http://localhost:8042'
study_instance_uid = 'your_study_instance_uid'
response = requests.get(f'{orthanc_url}/studies/{study_instance_uid}/metadata')
metadata = json.loads(response.text)
last_update = metadata.get('LastUpdate', None)
print(f'Study was last updated (added or modified) on: {last_update}')
Make sure to replace your_study_instance_uid with the actual UID of the DICOM study.
Note: You need appropriate permissions to access the Orthanc server, and the orthanc_url might be different if Orthanc is not running locally or configured with a different port.