示例#1
0
        private FormulationSelection formulationSelectionFrom(FormulationMapping formulationMapping, PKSimProject project)
        {
            var formulation = project.BuildingBlockById(formulationMapping.TemplateFormulationId) ?? formulationMapping.Formulation;

            return(new FormulationSelection {
                Name = formulation.Name, Key = formulationMapping.FormulationKey
            });
        }
示例#2
0
        protected override void Context()
        {
            _simulation = new IndividualSimulation
            {
                Properties         = new SimulationProperties(),
                SimulationSettings = new SimulationSettings(),
                ModelConfiguration = new ModelConfiguration()
            };
            _individual        = new Individual().WithName("MyIndividual");
            _speciesPopulation = new SpeciesPopulation();

            _individual.OriginData = new OriginData {
                SpeciesPopulation = _speciesPopulation
            };
            _compound    = A.Fake <Compound>().WithName("MyCompound");
            _protocol    = A.Fake <SimpleProtocol>().WithName("MyProtocol");
            _formulation = A.Fake <Formulation>().WithName("Formulation");

            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Individual", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual
            });
            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Compound", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _compound
            });
            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Protocol", PKSimBuildingBlockType.Protocol)
            {
                BuildingBlock = _protocol
            });
            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Formulation", PKSimBuildingBlockType.Formulation)
            {
                BuildingBlock = _formulation
            });

            _protocolToProtocolSchemaItemMapper = A.Fake <IProtocolToSchemaItemsMapper>();
            sut = new SimulationConfigurationValidator(_protocolToProtocolSchemaItemMapper);

            _speciesPopulation.IsHeightDependent = false;
            _schemaItem = A.Fake <SchemaItem>();
            _doseUnit   = A.Fake <Unit>();
            _schemaItem.Dose.DisplayUnit = _doseUnit;

            _protocolProperties = new ProtocolProperties();
            _formulationMapping = new FormulationMapping {
                FormulationKey = "F1", Formulation = _formulation
            };
            _simulation.Properties.AddCompoundProperties(new CompoundProperties
            {
                Compound           = _compound,
                ProtocolProperties = _protocolProperties
            });
            A.CallTo(() => _protocolToProtocolSchemaItemMapper.MapFrom(_protocol)).Returns(new [] { _schemaItem });
        }
示例#3
0
 private void updateFormulationMapping(ProtocolProperties protocolProperties, FormulationSelection[] snapshotProtocolFormulations, PKSimProject project)
 {
     snapshotProtocolFormulations?.Each(x =>
     {
         var formulation        = project.BuildingBlockByName <Model.Formulation>(x.Name);
         var formulationMapping = new FormulationMapping
         {
             Formulation           = formulation,
             FormulationKey        = x.Key,
             TemplateFormulationId = formulation.Id
         };
         protocolProperties.AddFormulationMapping(formulationMapping);
     });
 }
示例#4
0
        private Formulation retrieveFormulation(Simulation simulation, FormulationMapping formulationMapping, Func <UsedBuildingBlock, Formulation> formulationRetriever)
        {
            if (!isValid(formulationMapping))
            {
                return(null);
            }

            var templateFormulation = _buildingBlockRepository.ById <Formulation>(formulationMapping.TemplateFormulationId);
            var usedBuildingBlock   = simulation.UsedBuildingBlockByTemplateId(formulationMapping.TemplateFormulationId);

            //this forumation was not used in the simulation yet, return the template
            if (usedBuildingBlock == null)
            {
                return(templateFormulation);
            }

            //formulation was used in the simulation.
            var formulation = formulationRetriever(usedBuildingBlock);

            return(formulation ?? templateFormulation);
        }
        protected override void Context()
        {
            base.Context();
            _formulation = new Formulation();
            _simulation  = new IndividualSimulation {
                Properties = new SimulationProperties()
            };
            _formulationUsedInSimulation  = new Formulation();
            _usedBuildingBlockFormulation = new UsedBuildingBlock("template", PKSimBuildingBlockType.Formulation)
            {
                BuildingBlock = _formulationUsedInSimulation
            };
            var compoundProperties = new CompoundProperties();
            var formulationMapping = new FormulationMapping {
                Formulation = _formulation
            };

            compoundProperties.ProtocolProperties.AddFormulationMapping(formulationMapping);
            _simulation.Properties.AddCompoundProperties(compoundProperties);
            A.CallTo(() => _buildingBlockMapper.MapFrom(_formulation, null)).Returns(_usedBuildingBlockFormulation);
        }
        protected override void Context()
        {
            base.Context();
            _emptyFormulation = string.Empty;
            _formulationKey1  = "Tralal";
            _formulationKey2  = "toto";
            _formulation1.AddRoute(ApplicationTypes.Intravenous.Route);
            _formulation2.AddRoute(ApplicationTypes.Oral.Route);
            var formulationMapping1 = new FormulationMapping();
            var formulationMapping2 = new FormulationMapping();

            A.CallTo(() => _protocol.UsedFormulationKeys).Returns(new[] { _emptyFormulation, _formulationKey1, _formulationKey2 });
            A.CallTo(() => _protocolProperties.MappingWith(_formulationKey1)).Returns(formulationMapping1);
            A.CallTo(() => _protocolProperties.MappingWith(_formulationKey2)).Returns(formulationMapping2);
            A.CallTo(() => _protocol.ApplicationTypeUsing(_formulationKey1)).Returns(ApplicationTypes.Intravenous);
            A.CallTo(() => _protocol.ApplicationTypeUsing(_formulationKey2)).Returns(ApplicationTypes.Oral);
            A.CallTo(() => _formulationFromMappingRetriever.TemplateFormulationUsedBy(_simulation, formulationMapping1)).Returns(_formulation1);
            A.CallTo(() => _formulationFromMappingRetriever.TemplateFormulationUsedBy(_simulation, formulationMapping2)).Returns(null);
            _formulation2.AddRoute(ApplicationTypes.Oral.Route);
            A.CallTo(() => _view.BindTo(A <IEnumerable <FormulationMappingDTO> > ._))
            .Invokes(x => _formMappingDtoList = x.GetArgument <IEnumerable <FormulationMappingDTO> >(0).ToList());
        }
示例#7
0
 private bool isValid(FormulationMapping formulationMapping)
 {
     return(formulationMapping != null && !formulationMapping.TemplateFormulationId.IsNullOrEmpty());
 }
示例#8
0
 public Formulation TemplateFormulationUsedBy(Simulation simulation, FormulationMapping formulationMapping)
 {
     return(retrieveFormulation(simulation, formulationMapping, _buildingBlockInSimulationManager.TemplateBuildingBlockUsedBy <Formulation>));
 }
示例#9
0
 public Formulation FormulationUsedBy(Simulation simulation, FormulationMapping formulationMapping)
 {
     return(retrieveFormulation(simulation, formulationMapping, b => b.BuildingBlock as Formulation));
 }
示例#10
0
 protected override void Because()
 {
     _result = sut.MapFrom(_formulationMappingDTO, _simulation);
 }