Some changes to scheduledpatients

also thread safe dictionary