How to get dicom tags on OnDeletedInstance?

62 views
Skip to first unread message

Marius S

unread,
Nov 19, 2021, 2:26:57 AM11/19/21
to Orthanc Users
Hello,

When instance is deleted we would like to get it's dicom tags (studyuid, sopinstanceuid, etc.) and save to json file.

We use OnDeletedInstance lua callback however it does not have dicom tags.
We have tried to use this: 
function OnDeletedInstance(instanceId)
   local instance = ParseJson(RestApiGet('/instances/' .. instanceId .. '/simplified-tags'))
   local info = {}
   info['study_iuid'] = instance['StudyInstanceUID']
   info['series_iuid'] = instance['SeriesInstanceUID']
   info['modality'] = instance['Modality']
   info['sop_iuid'] = instance['SOPInstanceUID']
   info['sop_class_uid'] = instance['SOPClassUID']

      -- Write to the file
  
      local target = assert(io.open(TARGET .. os.time(os.date("!*t")) .. '_' .. instanceId .. '.json', 'wb'))
      target:write(JSON:encode(info))
      target:close()
   
end

But it seems that instance is already deleted, because we get error: attempt to index a nil value (local 'instance')

Any suggestions how to get these dicom tags then instance is deleted?

Thanks,
M.

Alain Mazy

unread,
Nov 19, 2021, 3:53:59 AM11/19/21
to Marius S, Orthanc Users
Hi Marius,

Sorry, not much we can do against that.  We could maybe implement a PreDelete callback but that's quite a bit of development.

Your only chance is probably to have an extra DB in which you store the meaningful tags associated with each orthanc instance id.

Best regards,

Alain.



--
You received this message because you are subscribed to the Google Groups "Orthanc Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orthanc-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orthanc-users/5e19a411-3f2e-400a-b9c7-87918611473cn%40googlegroups.com.

Marius S

unread,
Nov 19, 2021, 4:27:39 AM11/19/21
to Orthanc Users
Maybe it would be easier to include tags variable on OnDeletedInstance?

Alain Mazy

unread,
Nov 19, 2021, 8:34:22 AM11/19/21
to Marius S, Orthanc Users
Unfortunately not, since we need to keep backward compatibility, we can not change the signature of the callback so we need to define a new callback anyway

Sébastien Jodogne

unread,
Nov 24, 2021, 6:57:15 AM11/24/21
to Orthanc Users
Hello,

You could implement such a feature using a Python plugin:

You'll find attached to this message a sample Python script that overrides the "DELETE" method on the "/instances/{id}" URI.

You could extend this script to deal with the deletion of patients/studies/series.

HTH,
Sébastien-
test.py
Reply all
Reply to author
Forward
0 new messages