Bug 58

Summary: Patient recycling order should be defined by the reception of its last instance, not by the patient creation
Product: Orthanc Reporter: Sébastien Jodogne <s.jodogne>
Component: Orthanc CoreAssignee: Sébastien Jodogne <s.jodogne>
Status: RESOLVED FIXED    
Severity: minor    
Priority: ---    
Version: unspecified   
Hardware: All   
OS: All   

Description Sébastien Jodogne 2020-06-29 15:12:49 CEST
[BitBucket user: Alain Mazy]
[BitBucket date: 2017-07-19.13:17:16]

There's a workaround however by implementing a lua script (http://book.orthanc-server.com/users/lua.html) which will protect and unprotect a patient each time a new study is received for this patient.  This way, everytime a new study is received, the patient will be moved to the last position in the recycling order.

```
function OnStablePatient(patientId)
	local protectedStatus = RestApiGet('patients/' .. patientId .. '/protected')
	
	if protectedStatus == '1' then
	  RestApiPut('/patients/' .. patientId .. '/protected', '0')
	  RestApiPut('/patients/' .. patientId .. '/protected', '1')
	else
	  RestApiPut('/patients/' .. patientId .. '/protected', '1')
	  RestApiPut('/patients/' .. patientId .. '/protected', '0')
	end
end
```
Comment 1 Sébastien Jodogne 2020-06-29 15:23:52 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-01-15.19:59:59]

The decision was taken to modify the patient recycling order as follows: Whenever a new **instance** is received, its parent patient is moved to the end of the recycling order.
Comment 2 Sébastien Jodogne 2020-06-29 15:23:54 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-01-15.20:09:39]

Fix issue #58 (Patient recycling order should be defined by their received last instance)

→ https://hg.orthanc-server.com/orthanc/changeset/c0d7aee8c3f8