/changes api empty when all dicom removed ?

Hi There,

I think I picked up something strage in Orthanc.
I’m using the /changes API to monitor orthanc. And basically I use orthanc to make some export, so when I see new studies I make export and remove the study from Orthanc. So my Orthanc is usually containing one or non study.

When I have a study in Orthanc I have a proper /change API such

{
“Changes” : [
{
“ChangeType” : “NewInstance”,
“Date” : “20181121T105443”,
“ID” : “3b61ac90-199d7ca5-144e2cfb-d17a5617-cb765816”,
“Path” : “/instances/3b61ac90-199d7ca5-144e2cfb-d17a5617-cb765816”,
“ResourceType” : “Instance”,
“Seq” : 549392
},
{
“ChangeType” : “NewSeries”,
“Date” : “20181121T105443”,
“ID” : “f089088c-ae251419-f9a7091b-627186d0-578cb11c”,
“Path” : “/series/f089088c-ae251419-f9a7091b-627186d0-578cb11c”,
“ResourceType” : “Series”,
“Seq” : 549393
},
{
“ChangeType” : “NewStudy”,
“Date” : “20181121T105443”,
“ID” : “938c18da-d642cf57-fdef6e40-af0085d2-01193bce”,
“Path” : “/studies/938c18da-d642cf57-fdef6e40-af0085d2-01193bce”,
“ResourceType” : “Study”,
“Seq” : 549394
},
{
“ChangeType” : “NewPatient”,
“Date” : “20181121T105443”,
“ID” : “e20610bc-23cb5152-19c2460e-4a6c1d68-c774c924”,
“Path” : “/patients/e20610bc-23cb5152-19c2460e-4a6c1d68-c774c924”,
“ResourceType” : “Patient”,
“Seq” : 549395
}
],
“Done” : true,
“Last” : 549395
}

but then when I remove the only study in Orthanc and Orthanc do not contain any DICOM anymore I have an empty /change API

{
“Changes” : [],
“Done” : true,
“Last” : 0
}

It is kind strage to suddently move from 549395 sequences, to 0.
I guess the change API act as a log that shouldn’t be cleared when the dicom is removed, isn’t it ?

Best regards,

Salim

Just additional information, when I add a new dicom the counter sequence go back to 549395+ but the previous changes seems to be lost as the ?limit=1000 only show the few message that came after the drop of /changes.
I’m using the last version of orthanc

Hello,

Indeed, the “/changes” route is not meant to provide a full history log. It only reflects the changes about the current content of the server. This is to prevent the database from growing to infinity in routing scenarios.

If you want to preserve the full history, a dedicated plugin could register against “OrthancPluginRegisterOnChangeCallback()” and store such information in e.g. a NoSQL database.

HTH,
Sébastien-

Dear sebastien,

Ok now I understand.

But the counter isn’t a problem ?
When studies are removed the counter isn’t changed but there are no dicom it comes back to 0.

In fact each time my app scann the /changes api it store the last counter position.
so it fall back to zero and the next round the call will be changes?since=0 while the next message will be 549394+
if all positions between zero and 549394 are empty and orthanc directly jump to 549394 without memory issue it’s OK.

For my app it’s OK, it just kind of disturbing to come back to zero.
Anyway just to point this, you will decide if is safe this way or not, for me since the intermediate message are removed my app will be OK to go back to zero.

Thanks for you help,

Salim

Dear Salim,

I understand your concern, unfortunately implementing this (admittedly more consistent) behavior requires a refactoring of the database SDK.

I will give a try improving the situation, but I fear this is quite low-priority in my roadmap.

Regards,
Sébastien-

Hello Salim,

FYI, this more consistent behavior has been implemented in the “db-changes” branch of Orthanc, that will soon become Orthanc 1.5.2:
https://bitbucket.org/sjodogne/orthanc/commits/2e1711f80f74753723691db2efb395b7afaa3bdd

Regards,
Sébastien-

Thanks a lot !

Best regards,

Salim