Пример #1
0
 public async Task <List <MarkDto> > GetByMethod(Guid MethodId)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.Marks.Include(m => m.User).Include(m => m.MethodOfTreatment).Where(m => m.MethodOfTreatmentId == MethodId).Select(m => new MarkDto
             {
                 Id = m.Id,
                 Comment = m.Comment,
                 CreateDate = m.CreateDate,
                 Login = m.User.Login,
                 MethodName = m.MethodOfTreatment.Title,
                 MethodOfTreatmentId = m.MethodOfTreatmentId,
                 UserId = m.UserId,
                 Value = m.Value
             })
                    .ToListAsync());
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed Get List Marks By Method {MethodId} : {exc}");
         throw;
     }
 }
Пример #2
0
        public async Task Update(DiseaseUpdateDto dto)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var entity = await db.Diseases.Include(d => d.Symptoms).SingleOrDefaultAsync(Disease => Disease.Id == dto.Id);

                    entity.Description = dto.Description;
                    entity.Name        = dto.Name;
                    entity.ICDID       = dto.ICDID;
                    entity.Symptoms.Clear();
                    if (dto.SymptomIds != null)
                    {
                        foreach (var item in dto.SymptomIds)
                        {
                            var symptomdb = await db.Symptoms.FirstOrDefaultAsync(s => s.Id == item);

                            entity.Symptoms.Add(symptomdb);
                        }
                    }
                    // TODO UPDATE SYMPTOMS
                    db.Entry(entity).State = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed update Disease {dto.Id} : {exc}");
            }
        }
Пример #3
0
 public async Task Create(DiseaseCreateDto dto)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             Disease entity = new Disease
             {
                 Id          = Guid.NewGuid(),
                 Description = dto.Description,
                 Name        = dto.Name,
                 ICDID       = dto.ICDID
             };
             if (dto.SymptomIds != null)
             {
                 foreach (var item in dto.SymptomIds)
                 {
                     entity.Symptoms.Add(await db.Symptoms.FirstOrDefaultAsync(s => s.Id == item));
                 }
             }
             db.Diseases.Add(entity);
             await db.SaveChangesAsync();
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed create disease : {exc}");
     }
 }
Пример #4
0
        public async Task <List <DiseaseDto> > GetAll()
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var dbItems = await db.Diseases.Include(d => d.ICD).Include(d => d.Symptoms).ToListAsync();

                    return(dbItems.Select(disease => new DiseaseDto
                    {
                        Id = disease.Id,
                        Description = disease.Description,
                        ICDID = disease.ICDID,
                        ICDName = disease.ICDID != null ? disease.ICD.Code : string.Empty,
                        Name = disease.Name,
                        SymptomIds = disease.Symptoms != null
                            ? disease.Symptoms.Select(s => s.Id).ToList()
                            : new List <Guid>(),
                        SymptomNames = disease.Symptoms != null
                            ? disease.Symptoms.Select(s => s.Name).ToList()
                            : new List <string>()
                    }).ToList());
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get all diseases : {exc}");
                throw;
            }
        }
Пример #5
0
        public ActionResult SignIn(Account account)
        {
            var db = new DHContext();

            string isCorrect = String.Empty;

            switch (account.Role)
            {
            case "Больница":
                isCorrect = db.Hospitals
                            .Where(u => u.Name == account.UserName)
                            .Select(u => u.Name)
                            .SingleOrDefault();
                break;

            case "Доктор":
                isCorrect = db.Doctors
                            .Where(u => u.Username == account.UserName)
                            .Where(u => u.Password == account.Password)
                            .Select(u => u.Name)
                            .SingleOrDefault();
                break;
            }

            if (String.IsNullOrEmpty(isCorrect))
            {
                Session["isAuth"] = true;
                return(Redirect("~/Home/Cabinet"));
            }

            return(Redirect("~/Error/LogInError"));
        }
Пример #6
0
        public async Task <List <DiagnosticResultDto> > GetResult(List <Guid> SymptomIds)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var AllDisease = await db.Diseases.Include(d => d.ICD).Include(d => d.Symptoms).ToListAsync();

                    List <DiagnosticResultDto> result = new List <DiagnosticResultDto>();
                    foreach (var disease in AllDisease)
                    {
                        DiagnosticResultDto currnetresult = null;
                        foreach (var diseaseSymptom in disease.Symptoms)
                        {
                            if (SymptomIds.Contains(diseaseSymptom.Id))
                            {
                                if (currnetresult == null)
                                {
                                    currnetresult = new DiagnosticResultDto();
                                    currnetresult.NumberOfCoincidences = 1;
                                    var diseaseresult = new DiseaseDto
                                    {
                                        Id           = disease.Id,
                                        Description  = disease.Description,
                                        ICDID        = disease.ICDID,
                                        ICDName      = disease.ICD.Name,
                                        Name         = disease.Name,
                                        SymptomIds   = disease.Symptoms.Select(s => s.Id).ToList(),
                                        SymptomNames = disease.Symptoms.Select(s => s.Name).ToList()
                                    };
                                    currnetresult.Disease = diseaseresult;
                                }
                                else
                                {
                                    currnetresult.NumberOfCoincidences++;
                                }
                            }
                        }

                        if (currnetresult != null)
                        {
                            result.Add(currnetresult);
                        }
                    }
                    return(result.OrderByDescending(r => r.NumberOfCoincidences).ToList());
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get result for diagnostic : {exc}");
                throw;
            }
        }
Пример #7
0
 public async Task <int> GetTotalCount()
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.ICDs.CountAsync());
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed GetTotalCount ICD : {exc}");
         throw;
     }
 }
Пример #8
0
 private async Task <ICD> GetEntity(Guid Id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.ICDs.SingleOrDefaultAsync(icd => icd.Id == Id));
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed GetEntity ICD {Id} : {exc}");
         throw;
     }
 }
Пример #9
0
 private async Task <Mark> GetEntity(Guid Id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.Marks.Where(m => m.Id == Id).FirstOrDefaultAsync());
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed GetEntity Mark {Id} : {exc}");
         throw;
     }
 }
Пример #10
0
 private async Task <MethodOfTreatment> GetEntity(Guid Id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.MethodOfTreatments.SingleOrDefaultAsync(method => method.Id == Id));
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed GetEntity MethodOfTreatment {Id}: {exc}");
         throw;
     }
 }
Пример #11
0
 private async Task <Disease> GetEntity(Guid Id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.Diseases.SingleOrDefaultAsync(Disease => Disease.Id == Id));
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed GetEntity Disease {Id} : {exc}");
         throw;
     }
 }
 private async Task <User> GetEntity(Guid id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.Users.Where(u => u.Id == id).Include(u => u.Profile).Include(u => u.Role)
                    .SingleOrDefaultAsync());
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed GetEntity user {id} : {exc}");
         throw;
     }
 }
Пример #13
0
        public async Task Delete(Guid Id)
        {
            try
            {
                var entity = await GetEntity(Id);

                using (DHContext db = new DHContext())
                {
                    db.Entry(entity).State = EntityState.Deleted;
                    db.ICDs.Remove(entity);
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed delete ICD {Id} : {exc}");
            }
        }
Пример #14
0
        public async Task <MarkListDto> List(int page = 0, int size = 5, string search = null)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var marks = db.Marks.Include(m => m.MethodOfTreatment).Include(m => m.User).AsNoTracking().AsQueryable();
                    if (!string.IsNullOrEmpty(search))
                    {
                        marks = marks.Where(mark => (mark.Comment.ToLower() == search.ToLower()));
                    }
                    var TotalCount = await marks.CountAsync();

                    marks = marks.OrderByDescending(mark => mark.CreateDate).Skip(page * size).Take(size);
                    var EntityItems = await marks.ToListAsync();

                    var items = EntityItems.Select(mark => new MarkDto
                    {
                        Id                  = mark.Id,
                        Comment             = mark.Comment,
                        CreateDate          = mark.CreateDate,
                        Login               = mark.User.Login,
                        MethodName          = mark.MethodOfTreatment.Title,
                        MethodOfTreatmentId = mark.MethodOfTreatmentId,
                        UserId              = mark.UserId,
                        Value               = mark.Value
                    }).ToList();
                    var obj = new MarkListDto
                    {
                        MarkDtos   = items,
                        TotalCount = TotalCount,
                        Page       = page + 1,
                        PageSize   = size,
                        PageCount  = (TotalCount % size) > 0 ? TotalCount / size + 1 : TotalCount / size
                    };
                    return(obj);
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get list mark : {exc}");
                throw;
            }
        }
Пример #15
0
        public async Task <DiseaseListDto> List(int page = 0, int size = 5, string search = null)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var diseases = db.Diseases.AsNoTracking().AsQueryable();
                    if (!string.IsNullOrEmpty(search))
                    {
                        diseases = diseases.Where(disease => (disease.Name.ToLower() == search.ToLower()) ||
                                                  (disease.Description.ToLower() == search.ToLower()));
                    }
                    var TotalCount = await diseases.CountAsync();

                    diseases = diseases.OrderBy(disease => disease.Name).Skip(page * size).Take(size);
                    var EntityItems = await diseases.Include(d => d.ICD).Include(d => d.Symptoms).ToListAsync();

                    var items = EntityItems.Select(disease => new DiseaseDto
                    {
                        Id           = disease.Id,
                        Description  = disease.Description,
                        ICDID        = disease.ICDID,
                        ICDName      = disease.ICDID != null ? disease.ICD.Code : string.Empty,
                        Name         = disease.Name,
                        SymptomIds   = disease.Symptoms != null ? disease.Symptoms.Select(s => s.Id).ToList() : new List <Guid>(),
                        SymptomNames = disease.Symptoms != null ? disease.Symptoms.Select(s => s.Name).ToList() : new List <string>()
                    }).ToList();
                    var obj = new DiseaseListDto
                    {
                        DiseaseDtos = items,
                        TotalCount  = TotalCount,
                        Page        = page + 1,
                        PageSize    = size,
                        PageCount   = (TotalCount % size) > 0 ? TotalCount / size + 1 : TotalCount / size
                    };
                    return(obj);
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get List Disease : {exc}");
                throw;
            }
        }
        public async Task SetUserRole(UserDto dto, Guid RoleId)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var entity = await db.Users.Where(u => u.Id == dto.UserId).FirstOrDefaultAsync();

                    entity.RoleId          = RoleId;
                    db.Entry(entity).State = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed set user ({dto.UserId}) role ({RoleId}) : {exc}");
                throw;
            }
        }
        public async Task <UserListDto> List(int page = 0, int size = 5, string search = null)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var users = db.Users.AsNoTracking().AsQueryable();
                    if (!string.IsNullOrEmpty(search))
                    {
                        users = users.Where(user => (user.Login.ToLower() == search.ToLower()));
                    }
                    var TotalCount = await users.CountAsync();

                    users = users.OrderBy(user => user.Login).Skip(page * size).Take(size);
                    var EntityItems = await users.Include(d => d.Role).Include(d => d.Profile).ToListAsync();

                    var items = EntityItems.Select(user => new UserDto
                    {
                        UserId    = user.Id,
                        FullName  = user.Profile != null ? user.Profile.LastName + ' ' + user.Profile.FirstName + ' ' + user.Profile.MiddleName : string.Empty,
                        Gender    = user.Profile != null? user.Profile.Gender : string.Empty,
                        Login     = user.Login,
                        ProfileId = user.ProfileId != null ? user.ProfileId.Value : Guid.Empty,
                        RoleId    = user.RoleId,
                        RoleName  = user.Role.Name
                    }).ToList();
                    var obj = new UserListDto
                    {
                        UserDtos   = items,
                        TotalCount = TotalCount,
                        Page       = page + 1,
                        PageSize   = size,
                        PageCount  = (TotalCount % size) > 0 ? TotalCount / size + 1 : TotalCount / size
                    };
                    return(obj);
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get list users : {exc}");
                throw;
            }
        }
Пример #18
0
        public async Task <MethodOfTreatmentListDto> List(int page = 0, int size = 5, string search = null)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var methods = db.MethodOfTreatments.AsNoTracking().AsQueryable();
                    if (!string.IsNullOrEmpty(search))
                    {
                        methods = methods.Where(method => (method.Title.ToLower() == search.ToLower()) ||
                                                (method.Description.ToLower() == search.ToLower()));
                    }
                    var TotalCount = await methods.CountAsync();

                    methods = methods.OrderBy(method => method.Title).Skip(page * size).Take(size);
                    var items = await methods.Include(m => m.Disease).Select(method => new MethodOfTreatmentDto
                    {
                        Id          = method.Id,
                        Description = method.Description,
                        DiseaseId   = method.DiseaseId,
                        DiseaseName = method.Disease.Name,
                        Source      = method.Source,
                        Title       = method.Title
                    }).ToListAsync();

                    var obj = new MethodOfTreatmentListDto
                    {
                        MethodOfTreatmentDtos = items,
                        TotalCount            = TotalCount,
                        Page      = page + 1,
                        PageSize  = size,
                        PageCount = (TotalCount % size) > 0 ? TotalCount / size + 1 : TotalCount / size
                    };
                    return(obj);
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get list MethodOfTreatments : {exc}");
                throw;
            }
        }
 public async Task <SymptomUpdateDto> Get(Guid Id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.Symptoms.Select(Symptom => new SymptomUpdateDto
             {
                 Id = Symptom.Id,
                 Description = Symptom.Description,
                 Name = Symptom.Name
             }).SingleOrDefaultAsync(Symptom => Symptom.Id == Id));
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed Get SymptomDto {Id} : {exc}");
         throw;
     }
 }
Пример #20
0
        public async Task Update(ICDDto dto)
        {
            try
            {
                var entity = await GetEntity(dto.Id);

                using (DHContext db = new DHContext())
                {
                    entity.Code            = dto.Code;
                    entity.Description     = dto.Description;
                    entity.Name            = dto.Name;
                    db.Entry(entity).State = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed update ICD {dto.Id} : {exc}");
            }
        }
 public async Task <List <RoleDto> > GetAll()
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.Roles.Select(r => new RoleDto
             {
                 Id = r.Id,
                 Description = r.Description,
                 Name = r.Name
             }).ToListAsync());
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed GetAll Roles : {exc}");
         throw;
     }
 }
 public async Task <SymptomDetailsDto> GetWithDiseases(Guid Id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.Symptoms.Include(s => s.Diseases).Select(Symptom => new SymptomDetailsDto
             {
                 Id = Symptom.Id,
                 Description = Symptom.Description,
                 Name = Symptom.Name,
                 Diseases = Symptom.Diseases.Select(d => d.Name).ToList(),
             }).SingleOrDefaultAsync(Symptom => Symptom.Id == Id));
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed Get details Symptom {Id} : {exc}");
         throw;
     }
 }
 public async Task <List <SymptomUpdateDto> > GetAll()
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             var symptoms = db.Symptoms.AsNoTracking().AsQueryable();
             return(await symptoms.Select(symptom => new SymptomUpdateDto()
             {
                 Id = symptom.Id,
                 Name = symptom.Name,
                 Description = symptom.Description,
             }).ToListAsync());
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed get all symptoms : {exc}");
         throw;
     }
 }
Пример #24
0
 public async Task <ICDDto> Get(Guid Id)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.ICDs.Select(icd => new ICDDto
             {
                 Id = icd.Id,
                 Code = icd.Code,
                 Description = icd.Description,
                 Name = icd.Name
             }).SingleOrDefaultAsync(icd => icd.Id == Id));
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed get ICDDto {Id} : {exc}");
         throw;
     }
 }
Пример #25
0
 public async Task <List <ICDDto> > GetAll()
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             return(await db.ICDs.Select(icd => new ICDDto
             {
                 Id = icd.Id,
                 Name = icd.Name,
                 Description = icd.Description,
                 Code = icd.Code
             }).ToListAsync());
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed get all ICD : {exc}");
         throw;
     }
 }
Пример #26
0
        public async Task <ICDListDto> List(int page = 0, int size = 5, string search = null)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var icds = db.ICDs.AsNoTracking().AsQueryable();
                    if (!string.IsNullOrEmpty(search))
                    {
                        icds = icds.Where(icd => (icd.Code.ToLower() == search.ToLower()) ||
                                          (icd.Name.ToLower() == search.ToLower()));
                    }
                    var TotalCount = await icds.CountAsync();

                    icds = icds.OrderBy(icd => icd.Name).Skip(page * size).Take(size);
                    var items = await icds.Select(icd => new ICDDto
                    {
                        Id          = icd.Id,
                        Name        = icd.Name,
                        Description = icd.Description,
                        Code        = icd.Code
                    }).ToListAsync();

                    var obj = new ICDListDto {
                        IcdDtos    = items,
                        TotalCount = TotalCount,
                        Page       = page + 1,
                        PageSize   = size,
                        PageCount  = (TotalCount % size) > 0? TotalCount / size + 1 : TotalCount / size
                    };
                    return(obj);
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get List ICD : {exc}");
                throw;
            }
        }
Пример #27
0
        public async Task Update(MethodOfTreatmentUpdateDto dto)
        {
            try
            {
                var entity = await GetEntity(dto.Id);

                using (DHContext db = new DHContext())
                {
                    entity.Title           = dto.Title;
                    entity.Description     = dto.Description;
                    entity.DiseaseId       = dto.DiseaseId;
                    entity.Source          = dto.Source;
                    db.Entry(entity).State = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed Update MethodOfTreatment {dto.Id} : {exc}");
                throw;
            }
        }
        public async Task <SymptomListDto> List(int page = 0, int size = 5, string search = null)
        {
            try
            {
                using (DHContext db = new DHContext())
                {
                    var symptoms = db.Symptoms.AsNoTracking().AsQueryable();
                    if (!string.IsNullOrEmpty(search))
                    {
                        symptoms = symptoms.Where(symptom => (symptom.Name.ToLower() == search.ToLower()) ||
                                                  (symptom.Description.ToLower() == search.ToLower()));
                    }
                    var TotalCount = await symptoms.CountAsync();

                    symptoms = symptoms.OrderBy(symptom => symptom.Name).Skip(page * size).Take(size);
                    var items = await symptoms.Select(symptom => new SymptomUpdateDto()
                    {
                        Id          = symptom.Id,
                        Name        = symptom.Name,
                        Description = symptom.Description,
                    }).ToListAsync();

                    var obj = new SymptomListDto
                    {
                        SymptomDtos = items,
                        TotalCount  = TotalCount,
                        Page        = page + 1,
                        PageSize    = size,
                        PageCount   = (TotalCount % size) > 0 ? TotalCount / size + 1 : TotalCount / size
                    };
                    return(obj);
                }
            }
            catch (Exception exc)
            {
                _logger.Error($"Failed get list symptom : {exc}");
                throw;
            }
        }
Пример #29
0
 public async Task Create(ICDDto dto)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             ICD entity = new ICD
             {
                 Id          = Guid.NewGuid(),
                 Code        = dto.Code,
                 Description = dto.Description,
                 Name        = dto.Name
             };
             db.ICDs.Add(entity);
             await db.SaveChangesAsync();
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed create ICD : {exc}");
     }
 }
 public async Task Create(SymptomCreateDto dto)
 {
     try
     {
         using (DHContext db = new DHContext())
         {
             Symptom entity = new Symptom
             {
                 Id          = Guid.NewGuid(),
                 Description = dto.Description,
                 Name        = dto.Name
             };
             db.Symptoms.Add(entity);
             await db.SaveChangesAsync();
         }
     }
     catch (Exception exc)
     {
         _logger.Error($"Failed create symptom : {exc}");
         throw;
     }
 }