Beispiel #1
0
        private List <RxCellLookup> ImportRatesFromTreatmentZones(GridDescriptor gridDescriptor, IEnumerable <ISOTreatmentZone> treatmentZones, List <int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List <RxCellLookup>();

            foreach (var treatmentZoneCode in gridDescriptor.TreatmentZoneCodes)
            {
                ISOTreatmentZone treatmentZone = treatmentZones.FirstOrDefault(t => t.TreatmentZoneCode == treatmentZoneCode);
                if (treatmentZone == null)
                {
                    return(null);
                }

                var lookup = new RxCellLookup {
                    RxRates = new List <RxRate>()
                };
                foreach (ISOProcessDataVariable pdv in treatmentZone.ProcessDataVariables)
                {
                    if (!string.IsNullOrEmpty(pdv.ProductIdRef))
                    {
                        int?productID = TaskDataMapper.InstanceIDMap.GetADAPTID(pdv.ProductIdRef);
                        if (productID.HasValue)
                        {
                            lookup.RxRates.Add(PrescriptionMapper.ImportAndConvertRate(productID.Value, pdv, prescription));
                        }
                    }
                }

                rates.Add(lookup);
            }

            return(rates);
        }
Beispiel #2
0
        private List <RxCellLookup> ImportRatesFromProducts(GridDescriptor gridDescriptor, List <int> productIds, RasterGridPrescription prescription)
        {
            var  rates = new List <RxCellLookup>();
            bool binaryDataMatchesDefinition = true;

            foreach (var productRates in gridDescriptor.ProductRates)
            {
                var lookup = new RxCellLookup {
                    RxRates = new List <RxRate>()
                };
                for (int productIndex = 0; productIndex < productRates.Count; productIndex++)
                {
                    int adaptProductId = 0;
                    if (productIds.Count > productIndex)
                    {
                        adaptProductId = productIds[productIndex];
                    }
                    else if (productIds.Count > 0)
                    {
                        binaryDataMatchesDefinition = false;
                    }
                    lookup.RxRates.Add(PrescriptionMapper.ImportRate(adaptProductId, productRates[productIndex], prescription));
                }
                rates.Add(lookup);
            }
            if (!binaryDataMatchesDefinition)
            {
                TaskDataMapper.AddError($"Binary Grid Data for Type-2 Grid {TaskDataMapper.InstanceIDMap.GetISOID(prescription.Id.ReferenceId)} does not match its definition.  Product data will be omitted.");
            }
            return(rates);
        }
        //Determines a unique key that describes the products and rates assigned to each cell.
        private string GetRxRatesKey(RxCellLookup cellLookup)
        {
            string key = string.Empty;

            cellLookup.RxRates.ForEach(r => key += $"{r.RxProductLookupId}:{r.Rate}|");
            return(key);
        }
        //Adds a treatment zone for a new rate combination
        private ISOTreatmentZone GetNewType1TreatmentZone(RxCellLookup cellLookup, byte counter, Prescription rx)
        {
            ISOTreatmentZone treatmentZone = new ISOTreatmentZone()
            {
                TreatmentZoneCode = counter, TreatmentZoneDesignator = $"TreatmentZone {counter.ToString()}"
            };

            foreach (RxRate rate in cellLookup.RxRates)
            {
                treatmentZone.ProcessDataVariables.Add(ExportProcessDataVariable(rate, rx));
            }
            return(treatmentZone);
        }
Beispiel #5
0
        private List <RxCellLookup> ImportRatesFromProducts(GridDescriptor gridDescriptor, List <int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List <RxCellLookup>();

            foreach (var productRates in gridDescriptor.ProductRates)
            {
                var lookup = new RxCellLookup {
                    RxRates = new List <RxRate>()
                };
                for (int productIndex = 0; productIndex < productRates.Count; productIndex++)
                {
                    int adaptProductId = productIds[productIndex];
                    lookup.RxRates.Add(PrescriptionMapper.ImportRate(adaptProductId, productRates[productIndex], prescription));
                }
                rates.Add(lookup);
            }

            return(rates);
        }