Exemplo n.º 1
0
        public static void SetBaseValue(Expression<Func<UnitValue>> prop, decimal value, Prescription prescription)
        {
            if (PropertyExpressionsEquals(prop, () => prescription.Frequency))
                GetUnitValue(prop).BaseValue = value * UnitConverter.GetBaseValue(prescription.Frequency.Time, 1); ;

            if (PropertyExpressionsEquals(prop, () => prescription.Doses[0].Quantity))
                GetUnitValue(prop).BaseValue = value;

            if (PropertyExpressionsEquals(prop, () => prescription.Doses[0].Total))
                GetUnitValue(prop).BaseValue = value * UnitConverter.GetBaseValue(prescription.Frequency.Time, 1);

            if (PropertyExpressionsEquals(prop, () => prescription.Total))
                GetUnitValue(prop).BaseValue = value * UnitConverter.GetBaseValue(prescription.Frequency.Time, 1);

            if (PropertyExpressionsEquals(prop, () => prescription.Quantity))
                GetUnitValue(prop).BaseValue = value;

            if (PropertyExpressionsEquals(prop, () => prescription.Drug.Quantity))
                GetUnitValue(prop).BaseValue = value;

            if (PropertyExpressionsEquals(prop, () => prescription.FirstSubstance.DrugConcentration))
                GetUnitValue(prop).BaseValue = value;

            if (PropertyExpressionsEquals(prop, () => prescription.FirstSubstance.Quantity))
                GetUnitValue(prop).BaseValue = value;

            if (PropertyExpressionsEquals(prop, () => prescription.FirstDose.Rate))
                GetUnitValue(prop).BaseValue = value * UnitConverter.GetBaseValue("uur", 1); ;

            if (PropertyExpressionsEquals(prop, () => prescription.Rate))
                GetUnitValue(prop).BaseValue = value * UnitConverter.GetBaseValue("uur", 1); ;

            if (PropertyExpressionsEquals(prop, () => prescription.Duration))
                GetUnitValue(prop).BaseValue = value * UnitConverter.GetBaseValue("uur", 1);
        }
Exemplo n.º 2
0
 private bool _scenarioIsTrue(Prescription prescription)
 {
     return (
         !prescription.DoseVolume &&
         prescription.AdminVolume
     );
 }
Exemplo n.º 3
0
        public static void Execute(Prescription prescription, PrescriptionDto pDto)
        {
            if (prescription.Drug.Generic == "" || prescription.Drug.Route == "" || prescription.Drug.Shape == "")
                return;

            _setScenariosVisibility(prescription, pDto);
        }
Exemplo n.º 4
0
 private bool _scenarioIsTrue(Prescription prescription)
 {
     return (
         prescription.OnRequest &&
         !prescription.Infusion &&
         !prescription.Continuous
     );
 }
Exemplo n.º 5
0
 private static void _setScenariosVisibility(Prescription prescription, PrescriptionDto pDto)
 {
     for (int i = 0; i < _scenarios.Length; i++)
     {
         _scenarios[i].SetVisibilities(prescription, pDto);
     }
     _setSubstanceQuantityVisibility(pDto);
 }
Exemplo n.º 6
0
 public static decimal[] ConvertUnitValuesToDecimalArray(Expression<Func<UnitValue>>[] properties, Prescription prescription)
 {
     decimal[] values = new decimal[properties.Length];
     for (int i = 0; i < properties.Length; i++)
     {
         //_unitValues[i] = GetUnitValue(properties[i]);
         values[i] = Math.Round(GetConvertedValue(properties[i], prescription), 8, MidpointRounding.AwayFromZero);
     }
     return values;
 }
Exemplo n.º 7
0
        public static PrescriptionDto AssemblePrescriptionDto(Prescription prescription)
        {
            var prescriptionDto = new PrescriptionDto();
            prescriptionDto.startDate = prescription.StartDate.ToString();
            prescriptionDto.Id = prescription.Id.ToString();

            prescriptionDto.drugGeneric = prescription.Drug.Generic;
            prescriptionDto.drugRoute = prescription.Drug.Route;
            prescriptionDto.drugShape = prescription.Drug.Shape;

            prescriptionDto.prescriptionFrequency = UnitValueDto.AssembleUnitValueDto(prescription.Frequency);
            prescriptionDto.prescriptionDuration = UnitValueDto.AssembleUnitValueDto(prescription.Duration);

            prescriptionDto.substanceQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Drug.Components[0].Substances[0].Quantity);
            prescriptionDto.substanceDrugConcentration = UnitValueDto.AssembleUnitValueDto(prescription.Drug.Components[0].Substances[0].DrugConcentration);

            prescriptionDto.adminQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Quantity);
            prescriptionDto.adminTotal = UnitValueDto.AssembleUnitValueDto(prescription.Total);
            prescriptionDto.adminRate = UnitValueDto.AssembleUnitValueDto(prescription.Rate);

            prescriptionDto.drugQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Drug.Quantity);

            prescriptionDto.doseQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Doses[0].Quantity);
            prescriptionDto.doseTotal = UnitValueDto.AssembleUnitValueDto(prescription.Doses[0].Total);
            prescriptionDto.doseRate = UnitValueDto.AssembleUnitValueDto(prescription.Doses[0].Rate);

            var weightUnitValue = UnitValue.NewUnitValue();
            weightUnitValue.Unit = prescription.PatientWeightUnit;
            weightUnitValue.BaseValue = prescription.PatientWeight;
            prescriptionDto.patientWeight = UnitValueDto.AssembleUnitValueDto(weightUnitValue);

            var lengthUnitValue = UnitValue.NewUnitValue();
            lengthUnitValue.Unit = prescription.PatientLengthUnit;
            lengthUnitValue.BaseValue = prescription.PatientLength;
            prescriptionDto.patientLength = UnitValueDto.AssembleUnitValueDto(lengthUnitValue);

            prescriptionDto.PID = prescription.PID;

            prescriptionDto.verbalization = "";// PrescriptionVerbalization.Verbalize(prescription);

            prescriptionDto.AdminVolume = prescription.AdminVolume;
            prescriptionDto.DoseVolume = prescription.DoseVolume;

            var bsa = prescription.PatientBsa;
            prescriptionDto.patientBSA = new UnitValueDto()
            {
                unit = "m2",
                value = bsa,
                state = "calculated"
            };

            PrescriptionVisibility.Execute(prescription, prescriptionDto);

            return prescriptionDto;
        }
        public static OldPrescriptionCalculator SetCombinations(Prescription prescription)
        {
            var pc = new OldPrescriptionCalculator(prescription);
            var combi = new MultiplierCombination(
                prescription,
                () => prescription.Total, () => prescription.Frequency, () => prescription.Quantity
            );

            pc.AddCalculation(combi);
            return pc;
        }
Exemplo n.º 9
0
 public void SetVisibilities(Prescription prescription, PrescriptionDto _prescriptionDto)
 {
     if (_scenarioIsTrue(prescription))
     {
         _prescriptionDto.drugQuantity.visible = true;
         _prescriptionDto.substanceDrugConcentration.visible = true;
         _prescriptionDto.prescriptionSolution.visible = true;
         _prescriptionDto.prescriptionOnrequest.visible = true;
         _prescriptionDto.prescriptionContinuous.visible = true;
         _prescriptionDto.prescriptionInfusion.visible = true;
     }
 }
Exemplo n.º 10
0
 public void SetVisibilities(Prescription prescription, PrescriptionDto _prescriptionDto)
 {
     if (_scenarioIsTrue(prescription))
     {
         _prescriptionDto.prescriptionFrequency.visible = true;
         _prescriptionDto.prescriptionDuration.visible = false;
         _prescriptionDto.doseQuantity.visible = true;
         _prescriptionDto.adminQuantity.visible = true;
         _prescriptionDto.adminTotal.visible = false;
         _prescriptionDto.doseTotal.visible = false;
         _prescriptionDto.adminRate.visible = false;
         _prescriptionDto.doseRate.visible = false;
     }
 }
Exemplo n.º 11
0
 public PrescriptionCalculator(Prescription prescription)
 {
     _prescription = prescription;
     setCombinations();
 }
Exemplo n.º 12
0
 public MultiplierCombination(Prescription prescription, params Expression<Func<UnitValue>>[] properties)
 {
     _prescription = prescription;
     _properties = properties;
     ConvertCombinationsValuesToArray();
 }
Exemplo n.º 13
0
 public OldPrescriptionCalculator(Prescription prescription)
 {
     _prescription = prescription;
     SetIncrements(_prescription);
 }
Exemplo n.º 14
0
 public CalculationCombination(Prescription prescription, params Expression<Func<UnitValue>>[] properties)
 {
     _prescription = prescription;
     _properties = properties;
     _values = PropertyHelper.ConvertUnitValuesToDecimalArray(_properties, _prescription);
 }
Exemplo n.º 15
0
 private static void SetIncrementValues(Prescription p, Expression<Func<UnitValue>> property, decimal[] values, bool incrementStepping)
 {
     UnitValue unitValue = PropertyHelper.GetUnitValue(property);
     unitValue.Factor.IncrementSizes = values;
     unitValue.Factor.IncrementStepping = incrementStepping;
 }
Exemplo n.º 16
0
 private PrescriptionVerbalization(Prescription prescription)
 {
     _prescription = prescription;
     var substance = _prescription.Drug.Components[0].Substances[0];
 }
Exemplo n.º 17
0
 public static void Calculate(Prescription prescription)
 {
     var pc = new OldPrescriptionCalculator(prescription);
     pc.Start();
 }
Exemplo n.º 18
0
        private static decimal GetConvertedValue(Expression<Func<UnitValue>> prop, Prescription prescription)
        {
            if (PropertyExpressionsEquals(prop, () => prescription.Frequency))
                return GetUnitValue(prop).BaseValue / UnitConverter.GetBaseValue(prescription.Frequency.Time, 1);

            if (PropertyExpressionsEquals(prop, () => prescription.Doses[0].Quantity))
                return GetUnitValue(prop).BaseValue;

            if (PropertyExpressionsEquals(prop, () => prescription.Doses[0].Total))
                return GetUnitValue(prop).BaseValue / UnitConverter.GetBaseValue(prescription.Frequency.Time, 1);

            if (PropertyExpressionsEquals(prop, () => prescription.Quantity))
                return GetUnitValue(prop).BaseValue;

            if (PropertyExpressionsEquals(prop, () => prescription.Total))
                return GetUnitValue(prop).BaseValue / UnitConverter.GetBaseValue(prescription.Frequency.Time, 1);

            if (PropertyExpressionsEquals(prop, () => prescription.FirstSubstance.Quantity))
                return GetUnitValue(prop).BaseValue;

            if (PropertyExpressionsEquals(prop, () => prescription.FirstSubstance.DrugConcentration))
                return GetUnitValue(prop).BaseValue;

            if (PropertyExpressionsEquals(prop, () => prescription.Drug.Quantity))
                return GetUnitValue(prop).BaseValue;

            if (PropertyExpressionsEquals(prop, () => prescription.Rate))
                return GetUnitValue(prop).BaseValue / UnitConverter.GetBaseValue("uur", 1);

            if (PropertyExpressionsEquals(prop, () => prescription.FirstDose.Rate))
                return GetUnitValue(prop).BaseValue / UnitConverter.GetBaseValue("uur", 1);

            if (PropertyExpressionsEquals(prop, () => prescription.Duration))
                return prescription.Duration.BaseValue / UnitConverter.GetBaseValue("uur", 1);

            throw new Exception("property has no convert configuration " + ((MemberExpression)prop.Body).Member.DeclaringType.FullName + "." + ((MemberExpression)prop.Body).Member.Name);
        }
Exemplo n.º 19
0
 public PropertyStates(Prescription prescription)
 {
     _prescription = prescription;
 }
        public void CreatePrescription()
        {
            _prescription = Prescription.NewPrescription();
            _prescription.Drug.Generic = "paracetamol";
            _prescription.Drug.Shape = "zetp";
            _prescription.Drug.Route = "rect";

            _prescriptionDto = new PrescriptionDto();
        }
Exemplo n.º 21
0
 public static string Verbalize(Prescription prescription)
 {
     var prescriptionVerbalization = new PrescriptionVerbalization(prescription);
     return prescriptionVerbalization._verbalize();
 }
Exemplo n.º 22
0
 public void AddCombiToCalculator(Prescription p, OldPrescriptionCalculator pc, params Expression<Func<UnitValue>>[] properties)
 {
     var combi = new MultiplierCombination(p,properties);
     pc.AddCalculation(combi);
 }
Exemplo n.º 23
0
        public static Prescription NewPrescription()
        {
            var prescription = new Prescription
            {
                Doses = new List<Dose> {Dose.NewDose()},
                Quantity = UnitValue.NewUnitValue(),
                Frequency = UnitValue.NewUnitValue(),
                Total = UnitValue.NewUnitValue(),
                Rate = UnitValue.NewUnitValue(),
                Duration = UnitValue.NewUnitValue(),
            };
            prescription.Frequency.Time = "dag";
            prescription.Total.Time = "dag";
            prescription.Rate.Time = "uur";
            prescription.Duration.Time = "uur";

            prescription.Drug = Drug.NewDrug(prescription);

            return prescription;
        }
Exemplo n.º 24
0
        private static void SetIncrements(Prescription prescription)
        {
            var componentInc = new decimal[] { 1 };
            var substanceInc = new decimal[] { 0.24m };
            var freqInc = new decimal[] { 1 };

            SetIncrementValues(prescription, () => prescription.Frequency, freqInc, true);
            SetIncrementValues(prescription, () => prescription.Quantity, componentInc, true);
            SetIncrementValues(prescription, () => prescription.Total, componentInc, true);

            SetIncrementValues(prescription, () => prescription.Doses[0].Quantity, substanceInc, true);
            SetIncrementValues(prescription, () => prescription.Doses[0].Total, substanceInc, true);
        }