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);
        }
Exemplo n.º 2
0
        static AllocationBlock CreateNewAllocationBlock(Participant participant, RandomisationStrata strata, out BlockComponent component, ITrialDataContext context)
        {
            var block = GetNextAllocationGroup(participant, strata, context);

            component = ArmData.GetRatio(block);
            if (participant.Centre == null)
            {
                participant.Centre = context.StudyCentres.Find(participant.CentreId);
            }
            var returnVar = new AllocationBlock
            {
                Id = context.AllocationBlocks.GetNextId(participant.CentreId, participant.Centre.MaxIdForSite),
                AllocationGroup       = block,
                GroupRepeats          = component.Repeats,
                RandomisationCategory = strata
            };

            context.AllocationBlocks.Add(returnVar);

            return(returnVar);
        }
Exemplo n.º 3
0
 public static RandomisationArm NextAllocation(IEnumerable <RandomisationArm> currentBlock, BlockComponent block, IRandom randomGenerator)
 {
     return(NextAllocation(currentBlock, block.GetAllocations(), randomGenerator));
 }
Exemplo n.º 4
0
 public static RandomisationArm NextAllocation(IEnumerable <RandomisationArm> currentBlock, BlockComponent block)
 {
     return(NextAllocation(currentBlock, block, new RandomAdaptor()));
 }