private static IsoUnit DetermineIsoUnit(UnitOfMeasure rateUnit) { if (rateUnit == null) return null; return UnitFactory.Instance.GetUnitByDimension(rateUnit.Dimension); }
private static ISOUnit DetermineIsoUnit(UnitOfMeasure rateUnit) { if (rateUnit == null) { return(null); } return(UnitFactory.Instance.GetUnitByDimension(rateUnit.Dimension)); }
private ISOProcessDataVariable ExportProcessDataVariable(NumericRepresentationValue value, string isoProductIdRef, ISOUnit unit) { if (value != null && value.Value != null) { UnitOfMeasure adaptUnit = unit.ToAdaptUnit(); var dataVariable = new ISOProcessDataVariable { ProductIdRef = isoProductIdRef, ProcessDataValue = value.AsIntViaMappedDDI(RepresentationMapper), ProcessDataDDI = DetermineVariableDDI(value.Representation, adaptUnit).AsHexDDI() }; return(dataVariable); } return(null); }
private List <RxRates> LoadRatesFromProducts(GridDescriptor gridDescriptor, List <int> productIds, RasterGridPrescription prescription) { var rates = new List <RxRates>(); foreach (var productRates in gridDescriptor.ProductRates) { var rate = new RxRates { RxRate = new List <RxRate>() }; for (int productIndex = 0; productIndex < productRates.Count; productIndex++) { var adaptProductId = productIds[productIndex]; UnitOfMeasure uom = null; AddRate(adaptProductId, productRates[productIndex], rate, prescription, uom); } rates.Add(rate); } return(rates); }
private static void AddRate(int productId, double productRate, RxRates rates, RasterGridPrescription prescription, UnitOfMeasure uom) { RxProductLookup rxProductLookup; if (prescription.RxProductLookups.Any(x => x.ProductId == productId)) rxProductLookup = prescription.RxProductLookups.Single(x => x.ProductId == productId); else { rxProductLookup = new RxProductLookup { ProductId = productId, UnitOfMeasure = uom }; prescription.RxProductLookups.Add(rxProductLookup); } var rxRate = new RxRate { Rate = productRate, RxProductLookupId = rxProductLookup.Id.ReferenceId, }; rates.RxRate.Add(rxRate); }
/// <summary> /// If an implementer wants to export to a custom DDI or otherwise one that doesn't map, /// the appropriate DDI may be set in the Prescription prior to exporting. /// A ISO11783_DDI representation is as such the first mapping attempted. /// </summary> /// <param name="representation"></param> /// <param name="adaptUnit"></param> /// <returns></returns> private int DetermineVariableDDI(NumericRepresentation representation, UnitOfMeasure adaptUnit) { if (representation != null) { if (representation.CodeSource == RepresentationCodeSourceEnum.ISO11783_DDI) { return(Int32.Parse(representation.Code)); } int?mappedDDI = RepresentationMapper.Map(representation); if (mappedDDI.HasValue) { return(mappedDDI.Value); } } if (adaptUnit != null && UnitFactory.DimensionToDdi.ContainsKey(adaptUnit.Dimension)) { return(UnitFactory.DimensionToDdi[adaptUnit.Dimension]); } TaskDataMapper.AddError($"Unable to determine DDI for Prescription export {representation.Code}.", $"Representation ID : {representation.Id.ReferenceId}", "PrescriptionMapper.DetermineVariableDDI()"); return(0); //Return an invalid DDI }
public NumericValue(UnitOfMeasure uom, double value) { UnitOfMeasure = uom; Value = value; }
public NumericRepresentationValue(NumericRepresentation representation, UnitOfMeasure userProvidedUnitOfMeasure, NumericValue value) { Representation = representation; UserProvidedUnitOfMeasure = userProvidedUnitOfMeasure; Value = value; }
private static void AddRate(int productId, double productRate, RxRates rates, RasterGridPrescription prescription, UnitOfMeasure uom) { RxProductLookup rxProductLookup; if (prescription.RxProductLookups.Any(x => x.ProductId == productId)) { rxProductLookup = prescription.RxProductLookups.Single(x => x.ProductId == productId); } else { rxProductLookup = new RxProductLookup { ProductId = productId, UnitOfMeasure = uom }; prescription.RxProductLookups.Add(rxProductLookup); } var rxRate = new RxRate { Rate = productRate, RxProductLookupId = rxProductLookup.Id.ReferenceId, }; rates.RxRate.Add(rxRate); }