Esempio n. 1
0
        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()));
        }
Esempio n. 2
0
        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);
        }