Пример #1
0
        public BMICalculatorViewModel calculateBMI(long patientID, long orgCode, decimal weight)
        {
            string  message = "";
            var     patient = patientDemographicRepository.GetPatient(patientID, orgCode).First();
            decimal?bmi1    = weight / (patient.Height * patient.Height);

            double?bmi = (double?)Convert.ChangeType(bmi1, typeof(double));

            bmi = Math.Round((double)bmi, 1);

            if (bmi < 18.5)
            {
                message = "Underweight";
            }
            else if (bmi >= 18.5 && bmi < 25)
            {
                message = "Healthy";
            }
            else if (bmi >= 25 && bmi < 30)
            {
                message = "Overweight";
            }
            else
            {
                message = "Obese";
            }
            BMICalculatorViewModel bmiModel = new BMICalculatorViewModel();

            bmiModel.BMI     = bmi;
            bmiModel.message = message;
            return(bmiModel);
        }
Пример #2
0
        public void InsertWeight(Weight weight)
        {
            BMICalculatorViewModel bmVM = new BMICalculatorViewModel();

            bmVM       = bmirepository.calculateBMI(weight.PatientID, weight.OrganizationCode, (decimal)weight.WeightValue);
            weight.BMI = (decimal?)bmVM.BMI;
            Lb.Weights.Add(weight);
            Save();
        }
Пример #3
0
        public IHttpActionResult CalculateBMI(long PatientID, long OrganizationCode, decimal weight)
        {
            BMICalculatorViewModel bmiVM = bmirepository.calculateBMI(PatientID, OrganizationCode, weight);

            return(Ok(bmiVM));
        }