Example #1
0
        public async Task <List <NutritionInformation> > GetDietByEpiRowIdAsync(long epiRowId)
        {
            var nutriInfos = await _questionnaireRepository.GetNutriInfoBehavioralAsync(epiRowId);

            var result = new List <NutritionInformation>();

            foreach (var item in nutriInfos)
            {
                var dietPatterns = await _questionnaireRepository.GetNutriInfoDietaryPatternAsync(item.ID);

                var dietaryPatterns = await dietPatterns.GetDietaryPatterns();

                var behavioral = new Behavioral()
                {
                    QAlcoholConsumption   = item.QAlcoholConsumption,
                    QAlcoholFrequency     = item.QAlcoholFrequency,
                    QAlcoholNote          = item.QAlcoholNote,
                    QAlcoholType          = item.QAlcoholType,
                    QAlcoholTypeOther     = item.QAlcoholTypeOther,
                    QBehavioralNA         = item.QBehavioralNA,
                    QCoffeeConsumption    = item.QCoffeeConsumption,
                    QCoffeeFrequency      = item.QCoffeeFrequency,
                    QCoffeeNote           = item.QCoffeeNote,
                    QCoffeeTpyeOther      = item.QCoffeeTpyeOther,
                    QCoffeeType           = item.QCoffeeType,
                    QFruitConsumption     = item.QFruitConsumption,
                    QFruitFrequency       = item.QFruitFrequency,
                    QFruitNote            = item.QFruitNote,
                    QTeaConsumption       = item.QTeaConsumption,
                    QTeaFrequency         = item.QTeaFrequency,
                    QTeaNote              = item.QTeaNote,
                    QTeaType              = item.QTeaType,
                    QTeaTypeOther         = item.QTeaTypeOther,
                    QVegetableConsumption = item.QVegetableConsumption,
                    QVegetableFrequency   = item.QVegetableFrequency,
                    QVegetableNote        = item.QVegetableNote
                };

                var nutrition = new NutritionInformation()
                {
                    ID              = item.ID,
                    QUESDate        = item.QUESDate,
                    QUESTime        = item.QUESTime,
                    Behavioral      = behavioral,
                    DietaryPatterns = dietaryPatterns,
                    QDietHistory    = item.QDietHistory,
                    QDietOrder      = item.QDietOrder,
                    QUESUserDR      = item.QUESUserDR,
                    SSUSR_Initials  = item.SSUSR_Initials,
                    SSUSR_Name      = item.SSUSR_Name
                };

                result.Add(nutrition);
            }

            return(result);
        }
        private NutritionList BuildNutrition(Values <NutritionInformation>?nutrition)
        {
            if (!nutrition.HasValue || !nutrition.Value.HasValue)
            {
                return(null);
            }
            NutritionList        nList = new NutritionList();
            NutritionInformation nInfo = (NutritionInformation)nutrition.Value.Value;

            nList.Calories      = ExtractCalories(nInfo.Calories);
            nList.Carbohydrates = ExtractCarbs(nInfo.CarbohydrateContent);
            nList.Fat           = ExtractFat(nInfo.FatContent);
            nList.Fiber         = ExtractFiber(nInfo.FiberContent);
            nList.Protien       = ExtractProtien(nInfo.ProteinContent);

            return(nList);
        }
Example #3
0
        public NutritionInformation FindBySaucer(int saucerId)
        {
            var nutritionInformation = new NutritionInformation();
            var saucerConfigurations = _saucerConfigurationRepository.FindBy(saucerConfiguration => saucerConfiguration.SaucerId == saucerId && saucerConfiguration.Status);

            saucerConfigurations.ForEach(saucerConfiguration =>
            {
                var ingredient = _ingredientRepository.FindBy(saucerConfiguration.IngredientId);
                var portion    = saucerConfiguration.Portion;

                nutritionInformation.Energy       += (ingredient.Energy * portion);
                nutritionInformation.Protein      += (ingredient.Protein * portion);
                nutritionInformation.Carbohydrate += (ingredient.Carbohydrate * portion);
                nutritionInformation.Sugar        += (ingredient.Sugar * portion);
                nutritionInformation.Lipid        += (ingredient.Lipid * portion);
                nutritionInformation.Sodium       += (ingredient.Sodium * portion);
            });
            return(nutritionInformation);
        }
Example #4
0
        public async Task <DietViewModel> GetDietViewModelByEpiRowIdAsync(long epiRowId)
        {
            var nutriInfos = await _questionnaireRepository.GetNutriInfoBehavioralAsync(epiRowId);

            var nutritions = new List <NutritionInformation>();
            var result     = new DietViewModel();
            var hn         = "";
            var epiNo      = "";

            foreach (var item in nutriInfos)
            {
                hn    = string.IsNullOrEmpty(hn) ? item.PAPMI_No : hn;
                epiNo = string.IsNullOrEmpty(epiNo) ? item.PAADM_ADMNo : epiNo;

                var dietPatterns = await _questionnaireRepository.GetNutriInfoDietaryPatternAsync(item.ID);

                var dietaryPatterns = await dietPatterns.GetDietaryPatterns();

                var behavioral = new Behavioral()
                {
                    QAlcoholConsumption   = item.QAlcoholConsumption,
                    QAlcoholFrequency     = item.QAlcoholFrequency,
                    QAlcoholNote          = item.QAlcoholNote,
                    QAlcoholType          = item.QAlcoholType,
                    QAlcoholTypeOther     = item.QAlcoholTypeOther,
                    QBehavioralNA         = item.QBehavioralNA,
                    QCoffeeConsumption    = item.QCoffeeConsumption,
                    QCoffeeFrequency      = item.QCoffeeFrequency,
                    QCoffeeNote           = item.QCoffeeNote,
                    QCoffeeTpyeOther      = item.QCoffeeTpyeOther,
                    QCoffeeType           = item.QCoffeeType,
                    QFruitConsumption     = item.QFruitConsumption,
                    QFruitFrequency       = item.QFruitFrequency,
                    QFruitNote            = item.QFruitNote,
                    QTeaConsumption       = item.QTeaConsumption,
                    QTeaFrequency         = item.QTeaFrequency,
                    QTeaNote              = item.QTeaNote,
                    QTeaType              = item.QTeaType,
                    QTeaTypeOther         = item.QTeaTypeOther,
                    QVegetableConsumption = item.QVegetableConsumption,
                    QVegetableFrequency   = item.QVegetableFrequency,
                    QVegetableNote        = item.QVegetableNote
                };

                var nutrition = new NutritionInformation()
                {
                    ID              = item.ID,
                    QUESDate        = item.QUESDate,
                    QUESTime        = item.QUESTime,
                    Behavioral      = behavioral,
                    DietaryPatterns = dietaryPatterns,
                    QDietHistory    = item.QDietHistory,
                    QDietOrder      = item.QDietOrder,
                    QUESUserDR      = item.QUESUserDR,
                    SSUSR_Initials  = item.SSUSR_Initials,
                    SSUSR_Name      = item.SSUSR_Name
                };

                nutritions.Add(nutrition);
            }

            result = new DietViewModel()
            {
                PAPMI_No              = hn,
                PAADM_ADMNo           = epiNo,
                NutritionInformations = nutritions
            };

            return(result);
        }