Exemplo n.º 1
0
        public static void CreateAllocation(Participant participant, ITrialDataContext context)
        {
            //try
            //{
            if (participant.TrialArm != RandomisationArm.NotSet)
            {
                throw new InvalidOperationException("participant.TrialArm must have a value of NotSet - use forceallocation if the allocation is pre-set");
            }
            var            currentBlock = Get1stUnfilledBlock(participant, out RandomisationStrata strata, context);
            BlockComponent component    = currentBlock?.GetComponents();

            if (currentBlock == null || context.Participants.Count(p => p.AllocationBlockId == currentBlock.Id) == component.TotalBlockSize())
            {
                currentBlock = CreateNewAllocationBlock(participant, strata, out component, context);
            }
            participant.AllocationBlockId = currentBlock.Id;
            participant.Block             = currentBlock;
            participant.TrialArm          = BlockRandomisation.NextAllocation(from p in context.Participants
                                                                              where p.AllocationBlockId == currentBlock.Id
                                                                              select p.TrialArm, component);
        }