public WeightService(WeightRepository repository, PatientRepository patientRepository, IUnitWork unitWork, IOptions <MyOptions> optionsAccessor)
 {
     _repository        = repository;
     _patientRepository = patientRepository;
     _unitWork          = unitWork;
     _optionsAccessor   = optionsAccessor.Value;
 }
Esempio n. 2
0
 public PatientService(PatientRepository repository, WeightRepository weightRepository, BloodPressureRepository bloodPressureRepository, BloodSugarRepository bloodSugarRepository, PatientContactRepository patientContactRepository, IUnitWork unitWork, OssRepository ossRepository)
 {
     _repository               = repository;
     _weightRepository         = weightRepository;
     _bloodPressureRepository  = bloodPressureRepository;
     _bloodSugarRepository     = bloodSugarRepository;
     _patientContactRepository = patientContactRepository;
     _unitWork      = unitWork;
     _ossRepository = ossRepository;
 }
        public void TestAdd()
        {
            try
            {
                var entity = new WeightEntity()
                {
                    UserId = "568227be27041f34b038bb6c",
                    Points = new List<TimeValue>()
                };

                var value = 56.7;
                var seed = DateTime.UtcNow.Second;
                var random = new Random(seed);
                var date = new DateTime(2014, 8, 1, 14, 23, 6, DateTimeKind.Utc);
                while (date < new DateTime(2016, 1, 1, 0, 0, 0, DateTimeKind.Utc))
                {
                    entity.Points.Add(new TimeValue()
                    {
                        TimeStamp = date,
                        Value = value
                    });

                    var delta = random.NextDouble()*(DateTime.UtcNow.Millisecond%2 == 0 ? 1 : -1);
                    if (value + delta < 55.0)
                        value = 55.0 + Math.Abs(delta);
                    else if (value + delta > 70.0)
                        value = 70.0 + -1 * Math.Abs(delta);
                    else
                        value = value + delta;
                    date = date.Add(new TimeSpan(0, 3, 53, 37)); //step
                }

                var weightRepo = new WeightRepository();
                var task = weightRepo.Add(entity);
                task.Wait();

                Assert.IsTrue(true);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
        public static async Task<WeightChartModel> GetModel(UserEntity user)
        {
            if (user == null)
                return null;

            var weightRepo = new WeightRepository();
            var points = await weightRepo.GetByLatest(user.Id, new DateTime(DateTime.UtcNow.Year - 1, 1, 1, 0, 0, 0, DateTimeKind.Utc));
            if (points == null || points.Count <= 0)
                return null;

            points.Sort(new WeightEntity());

            var result = new WeightChartModel()
                {
                    MinValue = points[0].Value,
                    MaxValue = points[0].Value,
                    From = points[0].TimeStamp,
                    End = points[points.Count - 1].TimeStamp,
                    Points = new List<dynamic>()
                };

            foreach (var timeValue in points)
            {
                result.Points.Add(new List<dynamic>()
                    {
                        DateTimeHelper.ToLocalJavaTime(timeValue.TimeStamp, user.TimezoneOffset),
                        Math.Round(timeValue.Value, 1)
                    });

                if (timeValue.Value < result.MinValue)
                    result.MinValue = timeValue.Value;

                if (timeValue.Value > result.MaxValue)
                    result.MaxValue = timeValue.Value;
            }

            return result;
        }
Esempio n. 5
0
 public WeightBL(IMapper mapper, WeightRepository weightRepository, UsuarioRepository userRepository)
 {
     _mapper           = mapper;
     _weightRepository = weightRepository;
     _userRepository   = userRepository;
 }
Esempio n. 6
0
 public PatientService(PatientRepository repository, WeightRepository weightRepository, IUnitWork unitWork)
 {
     _repository       = repository;
     _weightRepository = weightRepository;
     _unitWork         = unitWork;
 }