-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2439 Misleading info in global POP PK Analysis if no parameter… #2459
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using PKSim.Assets; | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Domain.UnitSystem; | ||
using OSPSuite.Core.Services; | ||
using OSPSuite.Presentation.Core; | ||
using OSPSuite.Presentation.Presenters; | ||
using OSPSuite.Presentation.Services; | ||
using OSPSuite.Utility.Extensions; | ||
using PKSim.Assets; | ||
using PKSim.Core; | ||
using PKSim.Core.Mappers; | ||
using PKSim.Core.Model; | ||
using PKSim.Core.Repositories; | ||
using PKSim.Core.Services; | ||
using PKSim.Presentation.DTO.Mappers; | ||
using PKSim.Presentation.DTO.Simulations; | ||
using PKSim.Presentation.Views.Simulations; | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Domain.UnitSystem; | ||
using OSPSuite.Core.Services; | ||
using OSPSuite.Presentation.Core; | ||
using OSPSuite.Presentation.Presenters; | ||
using OSPSuite.Presentation.Services; | ||
|
||
namespace PKSim.Presentation.Presenters.Simulations | ||
{ | ||
|
@@ -29,6 +30,7 @@ public interface IGlobalPKAnalysisPresenter : IPresenter<IGlobalPKAnalysisView>, | |
void CalculateDDIRatioFor(string compoundName); | ||
string DisplayNameFor(string parameterName); | ||
bool HasParameters(); | ||
bool CanCalculateGlobalPK(); | ||
} | ||
|
||
public class GlobalPKAnalysisPresenter : AbstractSubPresenter<IGlobalPKAnalysisView, IGlobalPKAnalysisPresenter>, IGlobalPKAnalysisPresenter | ||
|
@@ -43,15 +45,17 @@ public class GlobalPKAnalysisPresenter : AbstractSubPresenter<IGlobalPKAnalysisV | |
private GlobalPKAnalysisDTO _globalPKAnalysisDTO; | ||
private DefaultPresentationSettings _settings; | ||
private readonly IPresentationSettingsTask _presentationSettingsTask; | ||
private readonly IProtocolToSchemaItemsMapper _protocolToSchemaItemsMapper; | ||
|
||
public GlobalPKAnalysisPresenter(IGlobalPKAnalysisView view, IPKAnalysesTask pkAnalysesTask, | ||
IGlobalPKAnalysisToGlobalPKAnalysisDTOMapper globalPKAnalysisDTOMapper, IHeavyWorkManager heavyWorkManager, IRepresentationInfoRepository representationInfoRepository, IPresentationSettingsTask presentationSettingsTask) : base(view) | ||
IGlobalPKAnalysisToGlobalPKAnalysisDTOMapper globalPKAnalysisDTOMapper, IHeavyWorkManager heavyWorkManager, IRepresentationInfoRepository representationInfoRepository, IPresentationSettingsTask presentationSettingsTask, IProtocolToSchemaItemsMapper protocolToSchemaItemsMapper) : base(view) | ||
{ | ||
_pkAnalysesTask = pkAnalysesTask; | ||
_globalPKAnalysisDTOMapper = globalPKAnalysisDTOMapper; | ||
_heavyWorkManager = heavyWorkManager; | ||
_representationInfoRepository = representationInfoRepository; | ||
_presentationSettingsTask = presentationSettingsTask; | ||
_protocolToSchemaItemsMapper = protocolToSchemaItemsMapper; | ||
_settings = new DefaultPresentationSettings(); | ||
} | ||
|
||
|
@@ -78,7 +82,7 @@ public bool ShouldCalculateDDIRatio(string compoundName, string parameterName) | |
shouldCalculateGlobalPKParameter(compoundName, parameterName, CoreConstants.PKAnalysis.C_maxRatio); | ||
} | ||
|
||
private bool shouldCalculateGlobalPKParameter(string compoundName, string parameterName,string globalPKParameterName) | ||
private bool shouldCalculateGlobalPKParameter(string compoundName, string parameterName, string globalPKParameterName) | ||
{ | ||
if (!string.Equals(parameterName, globalPKParameterName)) | ||
return false; | ||
|
@@ -119,10 +123,7 @@ private void loadPreferredUnitsForPKAnalysis() | |
|
||
private void updateParameterDisplayUnits(string parameterName) | ||
{ | ||
GlobalPKAnalysis.PKParameters(parameterName).Each(parameter => | ||
{ | ||
parameter.DisplayUnit = parameter.Dimension.Unit(_settings.GetSetting(parameterName, DisplayUnitFor(parameterName).Name)); | ||
}); | ||
GlobalPKAnalysis.PKParameters(parameterName).Each(parameter => { parameter.DisplayUnit = parameter.Dimension.Unit(_settings.GetSetting(parameterName, DisplayUnitFor(parameterName).Name)); }); | ||
} | ||
|
||
private Simulation firstSimulation => _simulations.FirstOrDefault(); | ||
|
@@ -164,6 +165,18 @@ public bool HasParameters() | |
return false; | ||
} | ||
|
||
public bool CanCalculateGlobalPK() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran resharper to auto-format so there's some noise in this PR. The gist is we need to calculate when a simulation contains only multiple IV applications of all compounds. If there's only single IV, oral, or a mix we want to show the global panel. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it this how it was doen for individual simulation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for individual, the global is calculated on demand, so if it can calculate a global, the presenter just indicates that the datatable has rows and the view should show the panel. For populations, you might have to re-run if the results are from an older version because the global would not have been calculated, and will not be calculated just because you show it. |
||
{ | ||
return firstSimulation.Compounds.Any(compound => | ||
{ | ||
var schemaItems = _protocolToSchemaItemsMapper.MapFrom(firstSimulation.CompoundPropertiesFor(compound).ProtocolProperties.Protocol); | ||
return !isMultipleIV(schemaItems); | ||
}); | ||
} | ||
|
||
private bool isMultipleIV(IReadOnlyList<SchemaItem> schemaItems) => schemaItems.Count(schemaItem => schemaItem.IsIV) > 1; | ||
|
||
|
||
public void LoadSettingsForSubject(IWithId subject) | ||
{ | ||
_settings = _presentationSettingsTask.PresentationSettingsFor<DefaultPresentationSettings>(this, subject); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this chnage from Interface to not interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented a bool property on SchemaItem that matches 'IsOral' and 'IsUserDefined' (IsIV) and like those ones, I did not pull them up to interface. I'm pretty sure all those conversions are local in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we need the ISchemaItem at all. Another day