public JsonResult LookupMedicalSpecialties(string term, int pageSize, int pageIndex)
        {
            using (var db = this.CreateNewCerebelloEntities())
            {
                var baseQuery = db.SYS_MedicalSpecialty.AsQueryable();
                if (!string.IsNullOrEmpty(term))
                    baseQuery = baseQuery.Where(mp => mp.Name.Contains(term) || mp.Code.Contains(term));

                baseQuery = baseQuery.Where(ms => ms.Code != null && ms.Code != "");
                baseQuery = baseQuery.Where(ms => ms.Name != null && ms.Name != "");

                var query = from mp in baseQuery
                            orderby mp.Name
                            select new MedicalSpecialtiesLookupGridModel
                            {
                                Id = mp.Id,
                                Code = mp.Code,
                                Name = mp.Name,
                            };

                var result = new AutocompleteJsonResult()
                {
                    Rows = new System.Collections.ArrayList(query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()),
                    Count = query.Count()
                };

                return this.Json(result, JsonRequestBehavior.AllowGet);
            }
        }
Ejemplo n.º 2
0
        public JsonResult AutocompleteDiagnoses(string term, int pageSize, int pageIndex)
        {
            IQueryable<SYS_Cid10> baseQuery = this.db.SYS_Cid10;
            if (!string.IsNullOrEmpty(term))
                baseQuery = baseQuery.Where(c => c.Name.Contains(term));

            var queryResult = (from c in baseQuery.OrderBy(c => c.Name).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()
                               select new CidAutocompleteGridModel
                                   {
                                       Cid10Code = c.Cat ?? c.SubCat,
                                       Cid10Name = c.Name
                                   }).ToList();

            var result = new AutocompleteJsonResult()
            {
                Rows = new ArrayList(queryResult),
                Count = baseQuery.Count()
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AutocompleteModelMedicalCertificates(string term, int pageSize, int pageIndex)
        {
            IQueryable<ModelMedicalCertificate> baseQuery = this.db.ModelMedicalCertificates;
            baseQuery = baseQuery.Where(c => c.DoctorId == this.Doctor.Id);
            if (!string.IsNullOrEmpty(term))
                baseQuery = baseQuery.Where(c => c.Name.Contains(term));

            var queryResult = (from c in baseQuery.OrderBy(c => c.Name).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()
                               select new AutocompleteRow
                               {
                                   Id = c.Id.ToString("0"),
                                   Value = c.Name
                               }).ToList();

            var result = new AutocompleteJsonResult
            {
                Rows = new ArrayList(queryResult),
                Count = baseQuery.Count()
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
        public JsonResult LookupMedicalProcedures(string term, int pageSize, int pageIndex)
        {
            var baseQuery = this.db.SYS_MedicalProcedure.AsQueryable();
            if (!string.IsNullOrEmpty(term))
                baseQuery = baseQuery.Where(mp => mp.Name.Contains(term) || mp.Code.Contains(term));

            var query = from mp in baseQuery
                        orderby mp.Name
                        select new MedicalProceduresLookupGridModel
                        {
                            Id = mp.Id,
                            Name = mp.Name,
                            Code = mp.Code,
                        };

            var result = new AutocompleteJsonResult()
            {
                Rows = new System.Collections.ArrayList(query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()),
                Count = query.Count()
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 5
0
        public JsonResult AutocompleteLaboratories(string term, int pageSize, int pageIndex)
        {
            var baseQuery = this.db.Laboratories.Where(l => l.DoctorId == this.Doctor.Id);

            if (!string.IsNullOrEmpty(term))
                baseQuery = baseQuery.Where(l => l.Name.Contains(term));

            var query = from l in baseQuery.OrderBy(l => l.Name).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()
                        orderby l.Name
                        select new AutocompleteRow
                        {
                            Id = l.Id,
                            Value = l.Name
                        };

            var result = new AutocompleteJsonResult()
            {
                Rows = new System.Collections.ArrayList(query.ToList()),
                Count = baseQuery.Count()
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 6
0
        public JsonResult LookupSysMedicine(string term, int pageSize, int pageIndex)
        {
            var baseQuery = this.db.SYS_Medicine.Include("Laboratory").AsQueryable();
            if (!string.IsNullOrEmpty(term))
                baseQuery = baseQuery.Where(m => m.Name.Contains(term) || m.ActiveIngredients.Any(ai => ai.Name.Contains(term)));

            var rows = (from p in baseQuery.OrderBy(p => p.Name).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()
                        select new SysMedicineLookupGridModel
                        {
                            Id = p.Id,
                            Name = p.Name,
                            LaboratoryName = p.Laboratory.Name
                        }).ToList();

            var result = new AutocompleteJsonResult()
            {
                Rows = new System.Collections.ArrayList(rows),
                Count = baseQuery.Count()
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 7
0
        public JsonResult LookupMedication(string term, int pageSize, int pageIndex)
        {
            var baseQuery = this.db.Medicines.Where(m => m.DoctorId == this.Doctor.Id);
            if (!string.IsNullOrEmpty(term))
                baseQuery = baseQuery.Where(m => m.Name.Contains(term) || m.ActiveIngredients.Any(ai => ai.Name.Contains(term)));

            var query = from m in baseQuery
                        orderby m.Name
                        select new MedicineLookupGridModel
                        {
                            Id = m.Id,
                            Name = m.Name,
                            LaboratoryName = m.Laboratory.Name
                        };

            var result = new AutocompleteJsonResult()
            {
                Rows = new System.Collections.ArrayList(query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()),
                Count = query.Count()
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
        public JsonResult LookupHealthInsurances(string term, int pageSize, int? pageIndex)
        {
            var listInsurances = this.Doctor.HealthInsurances
                .Where(hi => hi.IsActive)
                .OrderByDescending(h => h.IsParticular)
                .ThenBy(h => h.Name)
                .ToList();

            IEnumerable<HealthInsurance> baseQuery = listInsurances;

            if (!string.IsNullOrEmpty(term))
            {
                if (pageIndex == null)
                {
                    // if pageIndex is null, locate the first page where the terms can be found
                    var val = listInsurances.Select((hi, idx) => new { hi, idx }).FirstOrDefault(d => d.hi.Name.Contains(term));
                    pageIndex = val != null ? val.idx / pageSize + 1 : 1;
                }
                else
                {
                    baseQuery = baseQuery.Where(l => l.Name.IndexOf(term, StringComparison.InvariantCultureIgnoreCase) >= 0);
                }
            }
            else if (pageIndex == null)
            {
                // if pageIndex is null and there is no term to look for, just go to the first page
                pageIndex = 1;
            }

            var rows = (from p in baseQuery.OrderBy(p => p.Name).Skip((pageIndex.Value - 1) * pageSize).Take(pageSize).ToList()
                        select new
                        {
                            Id = p.Id,
                            Value = p.Name,
                        }).ToList();

            var result = new AutocompleteJsonResult()
            {
                Rows = new System.Collections.ArrayList(rows),
                Page = pageIndex.Value,
                Count = baseQuery.Count(),
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 9
0
        public JsonResult LookupPatients(string term, int pageSize, int? pageIndex)
        {
            if (pageIndex == null)
                throw new ArgumentNullException("pageIndex");

            var baseQuery = this.db.Patients.Include("Person").Where(l => l.DoctorId == this.Doctor.Id);
            if (!string.IsNullOrEmpty(term))
                baseQuery = baseQuery.Where(l => l.Person.FullName.Contains(term));

            var rows = (from p in baseQuery.OrderBy(p => p.Person.FullName).Skip((pageIndex.Value - 1) * pageSize).Take(pageSize).ToList()
                        select new
                        {
                            Id = p.Id,
                            Value = p.Person.FullName,
                            InsuranceId = p.LastUsedHealthInsuranceId,
                            InsuranceName = this.db.HealthInsurances.Where(hi => hi.Id == p.LastUsedHealthInsuranceId).Select(hi => hi.Name),
                        }).ToList();

            var result = new AutocompleteJsonResult()
            {
                Rows = new System.Collections.ArrayList(rows),
                Count = baseQuery.Count()
            };

            return this.Json(result, JsonRequestBehavior.AllowGet);
        }