Exemplo n.º 1
0
 public Formulation AddFormulationForDefinition(int definitionId, Formulation formulation)
 {
     formulation.DefinitionId = definitionId;
     Formulation fm = entities.Formulations.Add(formulation);
     SaveChanges();
     return fm;
 }
Exemplo n.º 2
0
        public void Visit(Formulation formulation)
        {
            if (!formulation.FormulationType.IsOneOf(CoreConstants.Formulation.Weibull, CoreConstants.Formulation.Lint80, CoreConstants.Formulation.Table))
            {
                return;
            }

            var templateFormulation = _formulationRepository.FormulationBy(formulation.FormulationType);
            var useAsSuspension     = _cloner.Clone(templateFormulation.Parameter(CoreConstants.Parameters.USE_AS_SUSPENSION));

            useAsSuspension.Value = 0;
            formulation.Add(useAsSuspension);
            _converted = true;
        }
 protected override void Context()
 {
     base.Context();
     _tableParameter = new PKSimParameter();
     _formulation    = new Formulation {
         FormulationType = CoreConstants.Formulation.Table
     };
     _formulation.Add(_tableParameter);
     _formulationDTO            = A.Fake <FormulationDTO>();
     _formulationDTO.Parameters = new[] { _tableParameter };
     _formulationDTO.Type       = new FormulationTypeDTO {
         Id = "oral"
     };
     A.CallTo(() => _formulationDTOMapper.MapFrom(_formulation)).Returns(_formulationDTO);
     A.CallTo(() => _tableFormulationPresenter.EditedFormula).Returns(new TableFormula());
 }
Exemplo n.º 4
0
        protected override async Task Context()
        {
            await base.Context();

            _snapshotType = typeof(Snapshots.Formulation);
            _snapshot1    = new Snapshots.Formulation();
            _snapshot2    = new Snapshots.Formulation();
            _formulation1 = new Formulation();
            _formulation2 = new Formulation();

            A.CallTo(() => _snapshotMapper.SnapshotTypeFor <Formulation>()).Returns(_snapshotType);
            A.CallTo(_dialogCreator).WithReturnType <string>().Returns(_fileName);
            A.CallTo(() => _jsonSerializer.DeserializeAsArray(_fileName, _snapshotType)).Returns(new[] { _snapshot1, _snapshot2 });
            A.CallTo(() => _snapshotMapper.MapToModel(_snapshot1)).Returns(_formulation1);
            A.CallTo(() => _snapshotMapper.MapToModel(_snapshot2)).Returns(_formulation2);
        }
Exemplo n.º 5
0
        protected override void Context()
        {
            base.Context();
            _formulation    = A.Fake <Formulation>();
            _formulation.Id = "simFormulation";
            _simulation     = new IndividualSimulation();
            var usedBuildingBlock = new UsedBuildingBlock("templateId", PKSimBuildingBlockType.Formulation);

            _simulation.AddUsedBuildingBlock(usedBuildingBlock);
            usedBuildingBlock.BuildingBlock = _formulation;
            _formulationMappingDTO          = new FormulationMappingDTO {
                ApplicationType = ApplicationTypes.Oral, Selection = new FormulationSelectionDTO {
                    BuildingBlock = _formulation
                }, FormulationKey = "tata"
            };
        }
Exemplo n.º 6
0
    public override void OnInspectorGUI()
    {
        var other = Array.Find(formulations, x => x != formulation && Formulation.CheckMaterialsDuplicate(formulation, x));

        if (other)
        {
            EditorGUILayout.HelpBox($"配方材料重复!配置路径:\n{AssetDatabase.GetAssetPath(other)}", MessageType.Error);
        }
        for (int i = 0; i < formulation.Materials.Count; i++)
        {
            bool bre  = false;
            var  left = formulation.Materials[i];
            if (!left.IsValid)
            {
                EditorGUILayout.HelpBox("该配方未补充完整", MessageType.Warning);
                break;
            }
            for (int j = 0; j < formulation.Materials.Count; j++)
            {
                var right = formulation.Materials[j];
                if (i != j && left.MakingType == right.MakingType)
                {
                    if (left.MakingType == MakingType.SingleItem && left.Item == right.Item || left.MakingType == MakingType.SameType && left.MaterialType == right.MaterialType)
                    {
                        EditorGUILayout.HelpBox($"第[{i + 1}]和第[{j + 1}]个材料重复!", MessageType.Error);
                        bre = true;
                    }
                }
                if (bre)
                {
                    break;
                }
            }
            if (bre)
            {
                break;
            }
        }
        serializedObject.UpdateIfRequiredOrScript();
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(remark, new GUIContent("备注"));
        listDrawer.DoLayoutDraw();
        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
    }
Exemplo n.º 7
0
        protected float[][][] _binParticlesFractionPerSegment; //no of particles fraction[particles bin][lumen segment][time]

        public override void GlobalContext()
        {
            base.GlobalContext();
            _compound.Name = "C1";

            _protocol    = DomainFactoryForSpecs.CreateStandardOralProtocol();
            _formulation = DomainFactoryForSpecs.CreateParticlesFormulation(NumberOfBins);

            //user defined actions in the building blocks
            SetupBuildingBlocks();

            _simulation = DomainFactoryForSpecs.CreateModelLessSimulationWith(
                _individual, _compound, _protocol, allowAging: false, formulation: _formulation) as IndividualSimulation;

            //setup compound processes
            SetupProcesses();

            DomainFactoryForSpecs.AddModelToSimulation(_simulation);

            //user defined actions in simulations, different for every test scenario
            SetupSimulation();

            if (DisableIntestinalAbsorptionAndLuminalFlow)
            {
                //disable intestinal absorption and luminal flow to feces for easier mass balance checks
                MoleculeProperties(CoreConstants.Parameters.INTESTINAL_PERMEABILITY).Value = 0;
                IntestinalTransitRateFor(CoreConstants.Compartment.Rectum).Value           = 0;
            }

            //store initial drug mass
            _appliedDrugMass = Application.Container(CoreConstants.ContainerName.ProtocolSchemaItem)
                               .Parameter(CoreConstantsForSpecs.Parameter.DRUG_MASS).Value.ToFloat();

            //Get paths for output quantities of interest
            (var lumenPaths, var binSolidDrugPaths, var binInsolubleDrugPaths,
             var binSolidDrugPerSegmentPaths, var binParticlesFractionPerSegmentPaths) = outputPaths(NumberOfBins);

            //add quantities of interest to the simulation outputs
            addOutputs(lumenPaths, binSolidDrugPaths, binInsolubleDrugPaths, binSolidDrugPerSegmentPaths, binParticlesFractionPerSegmentPaths);

            RunSimulation(_simulation).Wait();

            //fill simulation output times and values required for all further tests
            fillSimulationOutputs(lumenPaths, binSolidDrugPaths, binInsolubleDrugPaths, binSolidDrugPerSegmentPaths, binParticlesFractionPerSegmentPaths);
        }
 public void EditFormulation(Formulation formulation)
 {
     Formulation     = formulation;
     _formulationDTO = _formulationDTOMapper.MapFrom(formulation);
     adjustParameterVisibility();
     if (Formulation.IsTable)
     {
         _view.AddParameterView(_tableFormulationPresenter.BaseView);
         _tableFormulationPresenter.Edit(formulation);
     }
     else
     {
         _formulationParametersPresenter.Edit(_formulationDTO.Parameters);
         _view.AddParameterView(_formulationParametersPresenter.View);
     }
     updatePlot();
     _view.BindTo(_formulationDTO);
 }
        protected override void Context()
        {
            base.Context();
            var formulation = new Formulation().WithName("F");

            _simulation = new IndividualSimulation {
                Properties = new SimulationProperties()
            };
            var formulationUsedInSimulation = new Formulation().WithName("F");
            var compoundProperties          = new CompoundProperties();

            compoundProperties.ProtocolProperties.AddFormulationMapping(new FormulationMapping {
                Formulation = formulation
            });
            compoundProperties.ProtocolProperties.AddFormulationMapping(new FormulationMapping {
                Formulation = formulationUsedInSimulation
            });
            _simulation.Properties.AddCompoundProperties(compoundProperties);
        }
Exemplo n.º 10
0
        protected override double ValueFor(Formulation formulation, double time)
        {
            if (time <= _lagTime)
            {
                return(0);
            }

            if (time - _lagTime <= _dissTime80)
            {
                return(0.8 * (time - _lagTime) / _dissTime80);
            }

            if (time - _lagTime < 3.0 / 2 * _dissTime80)
            {
                return(1 - 0.8 * Math.Pow((time - _lagTime - 3.0 / 2 * _dissTime80) / _dissTime80, 2));
            }

            return(1);
        }
 protected override void Context()
 {
     base.Context();
     _templateFormulation = A.Fake <Formulation>();
     _formulation1        = A.Fake <Formulation>().WithName("f1");
     _formulation1.Id     = "1";
     _formulation2        = A.Fake <Formulation>().WithName("f2");
     _formulation2.Id     = "2";
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock(_formulation1.Id, PKSimBuildingBlockType.Formulation)
     {
         BuildingBlock = _formulation1
     });
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock(_formulation2.Id, PKSimBuildingBlockType.Formulation)
     {
         BuildingBlock = _formulation2
     });
     A.CallTo(() => _buildingBlockRepository.ById <Formulation>("template")).Returns(_templateFormulation);
     A.CallTo(() => _buildingBlockRepository.ById <Formulation>("does not exist")).Returns(null);
 }
        protected override void Context()
        {
            _individual  = new Individual().WithName("Individual");
            _compound    = new Compound().WithName("Compound");
            _formulation = new Formulation().WithName("Formulation");
            _protocol    = new Protocol().WithName("Protocol");
            _population  = new Population().WithName("Population");
            _event       = new Event().WithName("Event");

            sut = new SnapshotProject
            {
                Compounds    = new[] { _compound },
                Formulations = new[] { _formulation },
                Protocols    = new[] { _protocol },
                Individuals  = new[] { _individual },
                Populations  = new[] { _population },
                Events       = new[] { _event }
            };
        }
Exemplo n.º 13
0
        public Formulation Get(string formulationType)
        {
            string sql = "SELECT * FROM Formulations WHERE FormulationType=@formulationType";

            this.command = new SqlCommand(sql, this.db.Conn);
            this.command.Parameters.AddWithValue("@formulationType", formulationType);
            this.db.Conn.Open();
            SqlDataReader reader = this.command.ExecuteReader();

            Formulation f = new Formulation();

            if (reader.Read())
            {
                f.Id = Convert.ToInt32(reader["Id"]);
                f.FormulationType = reader["FormulationType"].ToString();
            }

            this.db.Conn.Close();
            return(f);
        }
Exemplo n.º 14
0
        /// <summary>Creates the formulation.</summary>
        /// <param name="formulation">The formulation.</param>
        /// <returns>A JSON encoded success indicator</returns>
        public JsonResult Create(Formulation formulation)
        {
            try
            {
                var farmContext = new PicolEntities();
                farmContext.Formulations.Add(formulation);
                farmContext.SaveChanges();

                return(new JsonNetResult {
                    Data = new { Error = false, Formulation = formulation }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            catch (Exception e)
            {
                // Signal the error to be logged by elmah
                ErrorSignal.FromCurrentContext().Raise(e);
                return(new JsonNetResult {
                    Data = new { Error = true, ErrorMessage = "Failed save formulation." }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
        protected override void Context()
        {
            _view                            = A.Fake <ISimulationCompoundProtocolFormulationView>();
            _formulationTask                 = A.Fake <IFormulationTask>();
            _formulationMappingMapper        = A.Fake <IFormulationMappingDTOToFormulationMappingMapper>();
            _formulationFromMappingRetriever = A.Fake <IFormulationFromMappingRetriever>();
            _formulation1                    = new Formulation();
            _formulation2                    = new Formulation();
            _protocol                        = A.Fake <Protocol>();
            _compound                        = A.Fake <Compound>();
            _simulation                      = A.Fake <Simulation>();
            _protocolProperties              = A.Fake <ProtocolProperties>();
            var compoundProperties = new CompoundProperties();

            A.CallTo(() => _simulation.CompoundPropertiesFor(_compound)).Returns(compoundProperties);
            compoundProperties.ProtocolProperties = _protocolProperties;
            _protocolProperties.Protocol          = _protocol;
            A.CallTo(() => _formulationTask.All()).Returns(new[] { _formulation1, _formulation2 });
            _buildingBlockSelectionDisplayer = A.Fake <IBuildingBlockSelectionDisplayer>();
            sut = new SimulationCompoundProtocolFormulationPresenter(_view, _formulationTask, _formulationMappingMapper, _formulationFromMappingRetriever, _buildingBlockSelectionDisplayer);
        }
        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);
        }
Exemplo n.º 17
0
        /// <summary>Updates the formulation.</summary>
        /// <param name="formulation">The formulation.</param>
        /// <returns>A JSON encoded success indicator</returns>
        public JsonResult Update(Formulation formulation)
        {
            try
            {
                var farmContext = new PicolEntities();
                farmContext.Formulations.Attach(formulation);
                farmContext.Entry(formulation).State = System.Data.Entity.EntityState.Modified;
                farmContext.SaveChanges();

                return(new JsonNetResult {
                    Data = new { Error = false }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            catch (Exception e)
            {
                // Signal the error to be logged by elmah
                ErrorSignal.FromCurrentContext().Raise(e);
                return(new JsonNetResult {
                    Data = new { Error = true, ErrorMessage = "Failed to update formulation." }, MaxJsonLength = int.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
        }
Exemplo n.º 18
0
        public List <Formulation> GetAll()
        {
            string sql = "SELECT * FROM Formulations";

            this.command = new SqlCommand(sql, this.db.Conn);
            this.db.Conn.Open();
            SqlDataReader reader = this.command.ExecuteReader();

            List <Formulation> flist = new List <Formulation>();

            while (reader.Read())
            {
                Formulation f = new Formulation();
                f.Id = Convert.ToInt32(reader["Id"]);
                f.FormulationType = reader["FormulationType"].ToString();

                flist.Add(f);
            }

            this.db.Close();
            return(flist);
        }
Exemplo n.º 19
0
        public ProcessResult AddFormulation(int definitionId,
                                            int studentId,
                                            string specificdifference)
        {
            var definition = GetDefinition(definitionId);

            if (definition == null)
            {
                return(ProcessResults.DefinitionNotExisting);
            }

            var formulation = new Formulation
            {
                AddedDate          = DateTime.Now,
                DefinitionId       = definitionId,
                StudentId          = studentId,
                SpecificDifference = specificdifference,
            };

            entities.Formulations.Add(formulation);
            SaveChanges();
            return(ProcessResults.FormulationSuccessfullyAdded);
        }
        protected override void Context()
        {
            base.Context();
            _formulationTypeDTO = new FormulationTypeDTO {
                Id = "trala"
            };
            _formulation    = A.Fake <Formulation>();
            _formulationDTO = new FormulationDTO {
                Type = _formulationTypeDTO
            };

            A.CallTo(() => _formulationDTOMapper.MapFrom(_formulation)).Returns(_formulationDTO);
            sut.EditFormulation(_formulation);
            sut.FormulationTypeChanged += e =>
            {
                _eventRaised = true;
                _valueRaised = e;
            };
            var templateFormulation = A.Fake <Formulation>();

            A.CallTo(() => _cloner.Clone(templateFormulation)).Returns(_formulation);
            A.CallTo(() => _formulationRepository.FormulationBy(_formulationTypeDTO.Id)).Returns(templateFormulation);
        }
Exemplo n.º 21
0
        private IEventGroupBuilder createFormulationAsEventGroupBuilderFrom(Formulation formulation)
        {
            var formulationBuilder = _objectBaseFactory.Create <IEventGroupBuilder>();

            formulationBuilder.UpdatePropertiesFrom(formulation, _cloneManagerForBuildingBlock);
            foreach (var parameter in formulation.AllParameters())
            {
                var builderParameter = _cloneManagerForBuildingBlock.Clone(parameter);
                //reset the origin in any case since it might have been set by clone
                builderParameter.Origin.ParameterId = string.Empty;
                formulationBuilder.Add(builderParameter);
            }

            _parameterIdUpdater.UpdateBuildingBlockId(formulationBuilder, formulation);
            _parameterIdUpdater.UpdateParameterIds(formulation, formulationBuilder);

            if (formulation.FormulationType.Equals(CoreConstants.Formulation.Particles))
            {
                setParticleRadiusDistributionParametersToLockedAndInvisible(formulationBuilder);
            }

            return(formulationBuilder);
        }
Exemplo n.º 22
0
 public override bool IsSatisfiedBy(Formulation formulation)
 {
     return(formulation.FormulationType == CoreConstants.Formulation.Dissolved);
 }
Exemplo n.º 23
0
 protected override void CacheParameterValueFor(Formulation formulation)
 {
     /*nothng to do */
 }
Exemplo n.º 24
0
 protected override void CacheParameterValueFor(Formulation formulation)
 {
     _lagTime    = formulation.Parameter(CoreConstants.Parameters.LAG_TIME).Value;
     _dissTime80 = formulation.Parameter(CoreConstants.Parameters.DISS_TIME80).Value;
 }
Exemplo n.º 25
0
 protected override void CacheParameterValueFor(Formulation formulation)
 {
     _tHalf = formulation.Parameter(CoreConstants.Parameters.HALF_LIFE).Value;
 }
Exemplo n.º 26
0
 public override bool IsSatisfiedBy(Formulation formulation)
 {
     return(formulation.FormulationType == CoreConstants.Formulation.FirstOrder);
 }
Exemplo n.º 27
0
 protected override double ValueFor(Formulation formulation, double time)
 {
     return(1);
 }
Exemplo n.º 28
0
 public override bool IsSatisfiedBy(Formulation formulation)
 {
     return(formulation.FormulationType == CoreConstants.Formulation.FIRST_ORDER);
 }
 public void Visit(Formulation objToVisit)
 {
     openPresenter(objToVisit);
 }
Exemplo n.º 30
0
 protected override double ValueFor(Formulation formulation, double time)
 {
     return(1 - Math.Exp(-Math.Log(2) * time / _tHalf));
 }
Exemplo n.º 31
0
 public void Visit(Formulation formulation)
 {
     performCommonConversion(formulation);
 }