public float?EstimateStartTimeFrom(PKCalculationOptions pkCalculationOptions) { double?estimatedStartTime() { if (StartTime != null) { return(StartTime + StartTimeOffset.GetValueOrDefault(0)); } var applicationIndex = StartApplicationIndex.GetValueOrDefault(-1); if (applicationIndex < 0) { return(null); } var dosingInterval = pkCalculationOptions.DosingIntervalAt(applicationIndex); if (dosingInterval?.StartValue == null) { return(null); } return(dosingInterval.StartValue + StartTimeOffset.GetValueOrDefault(0)); } return(toNullableFloat(estimatedStartTime())); }
public float?EstimateEndTimeFrom(PKCalculationOptions pkCalculationOptions) { double?estimatedEndTime() { if (EndTime != null) { return(EndTime + EndTimeOffset.GetValueOrDefault(0)); } var applicationIndex = EndApplicationIndex.GetValueOrDefault(-1); if (applicationIndex < 0) { return(null); } var dosingInterval = pkCalculationOptions.DosingIntervalAt(applicationIndex); if (dosingInterval?.StartValue == null) { return(null); } //We use the start value here as we are not interested in the time after the application return(dosingInterval.StartValue + EndTimeOffset.GetValueOrDefault(0)); } return(toNullableFloat(estimatedEndTime())); }
public double?EstimateDrugMassPerBodyWeight(PKCalculationOptions pkCalculationOptions) { // It can be quite complicated to estimate the total drug mass between two intervals // If a start time and end time is provided or any time offset, we cannot calculate for sure and we'll return NULL // if a start application and an end infusion index is provided, we'll sum up the interval between those two application // if a start application is provided, we'll sum up the drug mass starting at this application until the end // if an end application is provided, we'll sum up the drug mass from the start until the application if (StartTime.HasValue || EndTime.HasValue || EndTimeOffset.HasValue || StartTimeOffset.HasValue) { return(null); } //no intervals defined if (!StartApplicationIndex.HasValue && !EndApplicationIndex.HasValue) { return(pkCalculationOptions.TotalDrugMassPerBodyWeight); } var startApplicationIndex = StartApplicationIndex.GetValueOrDefault(0); var endApplicationIndex = EndApplicationIndex.GetValueOrDefault(pkCalculationOptions.DosingIntervals.Count); // invalid intervals if (startApplicationIndex >= endApplicationIndex) { return(null); } double drugMassPerBodyWeight = 0; for (int applicationIndex = startApplicationIndex; applicationIndex < endApplicationIndex; applicationIndex++) { //wrong indexes var interval = pkCalculationOptions.DosingIntervalAt(applicationIndex); if (interval == null) { return(null); } drugMassPerBodyWeight += interval.DrugMassPerBodyWeight.GetValueOrDefault(0); } return(drugMassPerBodyWeight); }