public double GetNioshIndex(NioshCalculateDto dto) { if (String.IsNullOrEmpty(dto.LiftFrequencyType)) { dto.LiftFrequencyType = this.GetLiftFrequencyTypes().First().Type; } if (String.IsNullOrEmpty(dto.LiftDurationType)) { dto.LiftDurationType = this.GetLiftDurationTypes().First().Type; } if (!dto.EffortType.Contains("Lift") || dto.WeightLb <= 0) { return(-1); } int lc = 51; //var hm = 1; double vm = 1 - 0.0075 * Math.Abs(dto.FromHeight - 30); double dist = Math.Abs(dto.ToHeight - dto.FromHeight); if (dist == 0) { return(-1); } double dm = 0.82 + 1.8 / dist; //var am = 1; //assymetry double fm = 1.0; //frequency //var cm = 1; // coupling // //frequency multiplier is defined by // a. lifts per minute F // b. vertical location of hands at origin V // c. durtion of continuous lifting // string liftOriginType = "Low"; if (dto.FromHeight > 30) { liftOriginType = "High"; } // //TBD: Cache Frequency Multipliers // fm = this.FrequencyMultipliers() .Where(f => f.LiftDurationType == dto.LiftDurationType && f.LiftFrequencyType == dto.LiftFrequencyType && f.LiftOriginType == liftOriginType) .Select(f => f.Multiplier) .DefaultIfEmpty(0) .FirstOrDefault(); var rwl = lc * vm * dm * fm; var liftingIndex = dto.WeightLb / rwl; return(liftingIndex); }
public async Task <double> GetNioshIndex(NioshCalculateDto dto) { var response = await _httpClient.PostAsJsonAsync <NioshCalculateDto>(BaseUrl + "/helpers/nioshIndex", dto); var nioshIndex = response.Content.ReadFromJsonAsync <double>().Result; return(nioshIndex); }
public bool Update(UpdateJobTaskDto dto) { var dbJobTask = _context.JobTasks.Find(dto.Id); // //make sure this task name is unique for this //jobTask // bool exists = (from item in _context.JobTasks where item.Id != dbJobTask.Id && item.Name == dto.Name && item.JobId == dbJobTask.JobId select item).Any(); if (exists) { throw new OccumetricException("This task name is already taken in this job description."); } // //calculate niosh and snooks // var snooksDto = new SnooksCalculateDto { EffortType = dto.EffortType, WeightLb = (int)dto.WeightLb, FromHeight = Utility.SanitizeStringToInteger(dto.FromHeight), ToHeight = Utility.SanitizeStringToInteger(dto.ToHeight), }; var snooksVm = _helperService.CalculateSnooks(snooksDto); dbJobTask.SnooksMale = snooksVm.StrMalePercentage; dbJobTask.SnooksFemale = snooksVm.StrFemalePercentage; var nioshDto = new NioshCalculateDto { WeightLb = (int)dto.WeightLb, EffortType = dto.EffortType, FromHeight = Utility.SanitizeStringToInteger(dto.FromHeight), ToHeight = Utility.SanitizeStringToInteger(dto.ToHeight), LiftDurationType = dto.LiftDurationType, LiftFrequencyType = dto.LiftFrequencyType }; dbJobTask.LiftingIndex = _helperService.GetNioshIndex(nioshDto); _mapper.Map <UpdateJobTaskDto, JobTask>(dto, dbJobTask); _context.SaveChanges(); return(true); }
public IActionResult CalculateNioshIndex(NioshCalculateDto dto) { return(Ok(_helperService.GetNioshIndex(dto))); }