public IEnumerable <Call> GetCallDetails(IEnumerable <long> customerIds)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                IEnumerable <CallsEntity> entities;

                var query = from cl in linqMetaData.Calls
                            where customerIds.Contains(cl.CalledCustomerId.Value) && cl.IsUploaded == false
                            select cl;

                entities = query.ToArray();

                return(Mapper.Map <IEnumerable <CallsEntity>, IEnumerable <Call> >(entities));
            }
        }
        public void Save(IEnumerable <WellMedAttestation> attestations)
        {
            var wellMedAttestations = attestations as WellMedAttestation[] ?? attestations.ToArray();

            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var entities = new EntityCollection <WellMedAttestationEntity>();
                foreach (var criteria in wellMedAttestations)
                {
                    entities.Add(Mapper.Map <WellMedAttestation, WellMedAttestationEntity>(criteria));
                }
                if (adapter.SaveEntityCollection(entities) == 0)
                {
                    throw new PersistenceFailureException();
                }
            }
        }
        public CustomerBillingAccount GetByCustomerIdBillingAccountId(long customerId, long billingAccountId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var entity = (from cba in linqMetaData.CustomerBillingAccount
                              where cba.CustomerId == customerId && cba.BillingAccountId == billingAccountId
                              select cba).SingleOrDefault();

                if (entity == null)
                {
                    return(null);
                }
                return(Mapper.Map <CustomerBillingAccountEntity, CustomerBillingAccount>(entity));
            }
        }
Example #4
0
        public IEnumerable <OrderedPair <long, long> > GetOrderEventCustomerIdPairforEventCustomerIds(IEnumerable <long> eventCustomerIds)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                return((from pair in
                        (from od in linqMetaData.OrderDetail
                         join ecod in linqMetaData.EventCustomerOrderDetail on od.OrderDetailId equals
                         ecod.OrderDetailId
                         where eventCustomerIds.Contains(ecod.EventCustomerId)
                         select new { od.OrderId, ecod.EventCustomerId })
                        group pair by pair.OrderId
                        into grp
                        select new OrderedPair <long, long>(grp.Key, grp.Max(p => p.EventCustomerId))).ToArray());
            }
        }
Example #5
0
        public PhysicianCustomerAssignment GetAssignedPhysicians(long eventCustomerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var assignedPhysicianEntity = (from pc in linqMetaData.PhysicianCustomerAssignment
                                               where pc.EventCustomerId == eventCustomerId && pc.IsActive
                                               select pc).FirstOrDefault();
                if (assignedPhysicianEntity != null)
                {
                    return(_mapper.Map(assignedPhysicianEntity));
                }

                return(null);
            }
        }
        public ActivityType GetById(long id)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);
                var entity       = (from q in linqMetaData.ActivityType
                                    where q.Id == id
                                    select q).FirstOrDefault();

                if (entity == null)
                {
                    return(null);
                }

                return(Mapper.Map <ActivityTypeEntity, ActivityType>(entity));
            }
        }
Example #7
0
        public List <OrderedPair <long, List <Core.Finance.Domain.Order> > > GetCallCenterRepActiveOrderPairs(DateTime startDate, DateTime endDate)
        {
            var callCenterRepOrderPairs = new List <OrderedPair <long, List <Core.Finance.Domain.Order> > >();

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(myAdapter);

                var eventCustomers = linqMetaData.EventCustomers.Join(linqMetaData.OrganizationRoleUser.Where(o => GetParentRoleIdByRoleId(o.RoleId) == (long)Roles.CallCenterRep),
                                                                      ec => ec.CreatedByOrgRoleUserId, oru => oru.OrganizationRoleUserId, (ec, oru) => ec).Where(ec => ec.DateCreated >= startDate &&
                                                                                                                                                                 ec.DateCreated <= endDate && !ec.NoShow && ec.AppointmentId.HasValue).ToList();


                var filteredOrderIds = eventCustomers.Join(linqMetaData.EventCustomerOrderDetail,
                                                           ec => ec.EventCustomerId,
                                                           ecod => ecod.EventCustomerId,
                                                           (ec, ecod) =>
                                                           new { ecod.OrderDetailId, ecod.IsActive }).Join(
                    linqMetaData.OrderDetail, @t => @t.OrderDetailId, od => od.OrderDetailId,
                    (@t, od) => new { @t.IsActive, od.OrderId }).Where(@t => @t.IsActive).Select(@t => new { @t.OrderId });

                var callCenterRepOrderGroups =
                    filteredOrderIds.Join(linqMetaData.Order, @t => @t.OrderId, o => o.OrderId, (@t, o) => o).Where(
                        o => o.DateCreated >= startDate && o.DateCreated <= endDate).GroupBy(
                        o => o.OrganizationRoleUserCreatorId);


                foreach (var callCenterRepOrderGroup in callCenterRepOrderGroups)
                {
                    if (callCenterRepOrderGroup != null && !callCenterRepOrderGroup.IsEmpty())
                    {
                        var groupOrderIds = callCenterRepOrderGroup.Select(group => group.OrderId).Distinct();
                        var orders        = new List <Core.Finance.Domain.Order>();
                        foreach (var orderId in groupOrderIds)
                        {
                            orders.Add(GetOrder(orderId));
                        }
                        callCenterRepOrderPairs.Add(
                            new OrderedPair <long, List <Core.Finance.Domain.Order> >(
                                callCenterRepOrderGroup.Key, orders));
                    }
                }

                return(callCenterRepOrderPairs);
            }
        }
        public bool IsSourceCodeAppliedforGivenEventCustomer(long sourceCodeId, long eventId, long customerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData    = new LinqMetaData(adapter);
                var eventCustomerId = (from ec in linqMetaData.EventCustomers
                                       join ecod in linqMetaData.EventCustomerOrderDetail on ec.EventCustomerId equals
                                       ecod.EventCustomerId
                                       join od in linqMetaData.SourceCodeOrderDetail on ecod.OrderDetailId equals od.OrderDetailId
                                       where
                                       ec.EventId == eventId && ec.CustomerId == customerId && ecod.IsActive &&
                                       od.IsActive && od.SourceCodeId == sourceCodeId
                                       select ec.EventCustomerId).SingleOrDefault();

                return(eventCustomerId > 0);
            }
        }
Example #9
0
        public Encounter GetByEventCustomerId(long eventCustomerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var entity = (from e in linqMetaData.Encounter
                              join ee in linqMetaData.EventCustomerEncounter on e.EncounterId equals ee.EncounterId
                              where ee.EventCustomerId == eventCustomerId
                              select e).SingleOrDefault();
                if (entity == null)
                {
                    return(null);
                }
                return(Mapper.Map <EncounterEntity, Encounter>(entity));
            }
        }
Example #10
0
        private void Save(AccountCallQueueSetting accountCallQueueSetting)
        {
            if (accountCallQueueSetting == null)
            {
                return;
            }

            var entity = Mapper.Map <AccountCallQueueSetting, AccountCallQueueSettingEntity>(accountCallQueueSetting);

            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                if (!adapter.SaveEntity(entity, true))
                {
                    throw new PersistenceFailureException();
                }
            }
        }
        public bool UpdateAmount(long sourceCodeId, long orderDetailId, decimal amount, long organizationRoleUserCreatorId)
        {
            var sourceCodeOrderDetailEntity = new SourceCodeOrderDetailEntity
            {
                Amount = amount,
                OrganizationRoleUserCreatorId = organizationRoleUserCreatorId
            };

            IRelationPredicateBucket bucket =
                new RelationPredicateBucket(SourceCodeOrderDetailFields.OrderDetailId == orderDetailId);

            bucket.PredicateExpression.AddWithAnd(SourceCodeOrderDetailFields.SourceCodeId == sourceCodeId);
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                return(adapter.UpdateEntitiesDirectly(sourceCodeOrderDetailEntity, bucket) > 0);
            }
        }
        public bool UpdateCalledCustomerId(long customerId, long callId, long?healthPlanId, long?ProductTypeId = null)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var callEntity = new CallsEntity()
                {
                    CalledCustomerId = customerId, HealthPlanId = healthPlanId, ProductTypeId = ProductTypeId
                };
                var bucket = new RelationPredicateBucket(CallsFields.CallId == callId);

                if (adapter.UpdateEntitiesDirectly(callEntity, bucket) == 0)
                {
                    throw new PersistenceFailureException("CallId doesn't exist");
                }
            }
            return(true);
        }
        public bool UpdateCallCenterCallEvent(long eventId, long callId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var callEntity = new CallsEntity()
                {
                    EventId = eventId
                };
                var bucket = new RelationPredicateBucket(CallsFields.CallId == callId);

                if (adapter.UpdateEntitiesDirectly(callEntity, bucket) == 0)
                {
                    throw new PersistenceFailureException("CallId doesn't exist");
                }
            }
            return(true);
        }
        public bool UpdateCallersPhoneNumber(long callId, string patientPhoneNumber)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var callEntity = new CallsEntity()
                {
                    CallersPhoneNumber = patientPhoneNumber, CallBackNumber = patientPhoneNumber
                };
                var bucket = new RelationPredicateBucket(CallsFields.CallId == callId);

                if (adapter.UpdateEntitiesDirectly(callEntity, bucket) == 0)
                {
                    throw new PersistenceFailureException("CallId doesn't exist");
                }
            }
            return(true);
        }
Example #15
0
        public IEnumerable <OrderedPair <long, string> > GetIdNamePairofAllUsersByRole(Roles role)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var roleIds = (from r in linqMetaData.Role
                               where ((r.ParentId.HasValue && r.ParentId.Value == (long)role) || r.RoleId == (long)role)
                               select r.RoleId);

                return((from u in linqMetaData.User
                        join oru in linqMetaData.OrganizationRoleUser on u.UserId equals oru.UserId
                        where roleIds.Contains(oru.RoleId)
                        select new OrderedPair <long, string>(oru.OrganizationRoleUserId, u.FirstName + " " + u.LastName)).OrderBy(op => op.SecondValue)
                       .ToList());
            }
        }
Example #16
0
        public IEnumerable <EventCustomerEncounter> GetEventCustomerEncounterByEventCustomerIds(IEnumerable <long> eventCustomerIds)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var entities = (from ece in linqMetaData.EventCustomerEncounter
                                where eventCustomerIds.Contains(ece.EventCustomerId)
                                select ece).ToArray();

                if (entities != null && entities.Any())
                {
                    return(Mapper.Map <IEnumerable <EventCustomerEncounterEntity>, IEnumerable <EventCustomerEncounter> >(entities));
                }
                return(null);
            }
        }
        public ActivityType GetByAlias(string alias)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);
                var entity       = (from q in linqMetaData.ActivityType
                                    where q.Alias.ToLower() == alias.ToLower() && q.IsActive
                                    select q).FirstOrDefault();

                if (entity == null)
                {
                    return(null);
                }

                return(Mapper.Map <ActivityTypeEntity, ActivityType>(entity));
            }
        }
Example #18
0
        public IEnumerable <HospitalPartnerCustomer> GetHospitalPartnerCustomersByHospitalPartnerId(long hospitalPartnerId, ResultInterpretation resultInterpretation, int validityPeriod = 0)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var entities = (from hpc in linqMetaData.VwHospitalPartnerCustomers
                                join ehp in linqMetaData.EventHospitalPartner on hpc.EventId equals ehp.EventId
                                join ecr in linqMetaData.EventCustomerResult on new { hpc.EventId, hpc.CustomerId } equals new { ecr.EventId, ecr.CustomerId }
                                join e in linqMetaData.Events on ecr.EventId equals e.EventId
                                where ehp.HospitalPartnerId == hospitalPartnerId &&
                                ecr.ResultSummary == (long)resultInterpretation &&
                                (validityPeriod < 1 || e.EventDate >= DateTime.Now.Date.AddDays(-1 * validityPeriod))
                                select hpc).ToArray();
                return(Mapper.Map <IEnumerable <VwHospitalPartnerCustomersEntity>, IEnumerable <HospitalPartnerCustomer> >(entities));
            }
        }
        public EventCustomerNotification GetByEventCustomerId(long eventCustomerId, string notificationType)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var entity = (from ecn in linqMetaData.EventCustomerNotification
                              join nt in linqMetaData.NotificationType on ecn.NotificationTypeId equals nt.NotificationTypeId
                              where nt.NotificationTypeNameAlias == notificationType && ecn.EventCustomerId == eventCustomerId
                              select ecn).FirstOrDefault();
                if (entity == null)
                {
                    return(null);
                }
                return(Mapper.Map <EventCustomerNotificationEntity, EventCustomerNotification>(entity));
            }
        }
Example #20
0
        public IEnumerable <ShippingDetail> GetEventCustomerShippingDetailForFilter(int pageNumber, int pageSize, PcpSummaryLogReportModelFilter filter, IEnumerable <long> shippingOptions, out int totalRecords)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);


                var query = (from ec in linqMetaData.EventCustomers
                             join ecod in linqMetaData.EventCustomerOrderDetail on ec.EventCustomerId equals ecod.EventCustomerId
                             join sdod in linqMetaData.ShippingDetailOrderDetail on ecod.OrderDetailId equals sdod.OrderDetailId
                             join sd in linqMetaData.ShippingDetail on sdod.ShippingDetailId equals sd.ShippingDetailId
                             join ea in linqMetaData.EventAccount on ec.EventId equals ea.EventId
                             where ec.AppointmentId.HasValue && !ec.NoShow && ec.LeftWithoutScreeningReasonId == null &&
                             ea.AccountId == filter.HealthPlanId &&
                             ecod.IsActive && sdod.IsActive &&
                             sd.ShipmentDate.HasValue &&
                             (sd.Status == (long)ShipmentStatus.Delivered || sd.Status == (long)ShipmentStatus.Shipped) &&
                             (shippingOptions.Contains(sd.ShippingOptionId))

                             select new { ec, sd });

                if (filter.DateFrom.HasValue || filter.DateTo.HasValue)
                {
                    var fromDate = filter.DateFrom.HasValue ? filter.DateFrom.Value : DateTime.Now;
                    var toDate   = filter.DateTo.HasValue ? filter.DateTo.Value : DateTime.Now;

                    query = from q in query
                            where q.sd.ShipmentDate >= fromDate && q.sd.ShipmentDate <= toDate
                            select q;
                }

                if (!string.IsNullOrWhiteSpace(filter.Tag))
                {
                    var customerIds = (from cp in linqMetaData.CustomerProfile where cp.Tag == filter.Tag select cp.CustomerId);

                    query = (from q in query where customerIds.Contains(q.ec.CustomerId) select q);
                }


                var queryForShipping = from q in query orderby q.sd.ShipmentDate ascending, q.ec.EventId ascending, q.ec.CustomerId ascending select q.sd;
                totalRecords = queryForShipping.Count();

                var entities = queryForShipping.TakePage(pageNumber, pageSize).ToArray();
                return(Mapper.MapMultiple(entities));
            }
        }
Example #21
0
        public IEnumerable <Core.Finance.Domain.Order> GetAllOrders(int pageNumber, int pageSize)
        {
            IEnumerable <OrderEntity> orderEntities;
            var orders = new List <Core.Finance.Domain.Order>();

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(myAdapter);
                orderEntities = linqMetaData.Order.Skip((pageNumber - 1) * pageSize).
                                Take(pageSize).ToList();
            }
            foreach (var orderEntity in orderEntities)
            {
                orders.Add(GetOrder(orderEntity.OrderId));
            }
            return(orders);
        }
Example #22
0
        public bool UpdateMemberUploadLog(long oldCustomerId, long newCustomerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var memberUploadLogBucket = new RelationPredicateBucket(MemberUploadLogFields.CustomerId == oldCustomerId);
                var entities = new EntityCollection <MemberUploadLogEntity>();

                adapter.FetchEntityCollection(entities, memberUploadLogBucket);

                foreach (var cba in entities)
                {
                    cba.CustomerId = newCustomerId;
                    adapter.SaveEntity(cba);
                }
            }
            return(true);
        }
Example #23
0
        public int GetPinExpireInDays(long technicianId, int pinExpirationDays)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);
                var technician   = linqMetaData.TechnicianProfile.SingleOrDefault(x => x.OrganizationRoleUserId == technicianId);

                if (technician == null || !technician.PinChangeDate.HasValue)
                {
                    return(0);
                }

                var totalDaysLastPinChage = (technician.PinChangeDate.Value.AddDays(pinExpirationDays).Date - DateTime.Today.Date).TotalDays + 1;

                return(Convert.ToInt32(totalDaysLastPinChage));
            }
        }
Example #24
0
        public bool UpdateEventCustomerQuestionAnswer(long oldCustomerId, long newCustomerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var eventCustomerQuestionAnswerBucket = new RelationPredicateBucket(EventCustomerQuestionAnswerFields.CustomerId == oldCustomerId);
                var entities = new EntityCollection <EventCustomerQuestionAnswerEntity>();

                adapter.FetchEntityCollection(entities, eventCustomerQuestionAnswerBucket);

                foreach (var cba in entities)
                {
                    cba.CustomerId = newCustomerId;
                    adapter.SaveEntity(cba);
                }
            }
            return(true);
        }
Example #25
0
        public void Save(HealthPlanEventZip healthPlanEventZip)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                if (healthPlanEventZip != null && healthPlanEventZip.AccountID > 0)
                {
                    Delete(healthPlanEventZip.AccountID);

                    var entity = Mapper.Map <HealthPlanEventZip, HealthPlanEventZipEntity>(healthPlanEventZip);

                    if (!adapter.SaveEntity(entity, true))
                    {
                        throw new PersistenceFailureException();
                    }
                }
            }
        }
Example #26
0
        public bool UpdateCareCodingOutbound(long oldCustomerId, long newCustomerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var careCodingOutboundBucket = new RelationPredicateBucket(CareCodingOutboundFields.CustomerId == oldCustomerId);
                var entities = new EntityCollection <CareCodingOutboundEntity>();

                adapter.FetchEntityCollection(entities, careCodingOutboundBucket);

                foreach (var cba in entities)
                {
                    cba.CustomerId = newCustomerId;
                    adapter.SaveEntity(cba);
                }
            }
            return(true);
        }
        public IEnumerable <EventCustomerQuestionAnswer> GetEventCustomerQuestionAnswer(long customerId, long templateId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var questionIds = linqMetaData.PreQualificationTemplateQuestion.Where(x => x.TemplateId == templateId).Select(x => x.QuestionId).ToArray();

                var maxVersion = linqMetaData.EventCustomerQuestionAnswer.Where(x => x.CustomerId == customerId && questionIds.Contains(x.QuestionId) && x.IsActive == true).Max(x => x.Version);

                var entities = (from q in linqMetaData.EventCustomerQuestionAnswer
                                where q.CustomerId == customerId && q.Version == maxVersion &&
                                q.IsActive
                                select q).ToArray();
                return(Mapper.Map <IEnumerable <EventCustomerQuestionAnswerEntity>, IEnumerable <EventCustomerQuestionAnswer> >(entities));
            }
        }
Example #28
0
        public IEnumerable <OrderedPair <long, string> > GetIdNamePairofUsersByRoles(long[] roles)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var roleIds = (from role in linqMetaData.Role
                               where (role.ParentId.HasValue && roles.Contains(role.ParentId.Value) || roles.Contains(role.RoleId))
                               select role.RoleId);

                return((from u in linqMetaData.User
                        join oru in linqMetaData.OrganizationRoleUser on u.UserId equals oru.UserId
                        where roleIds.Contains(oru.RoleId) && oru.IsActive && u.IsActive
                        select new OrderedPair <long, string>(oru.OrganizationRoleUserId, u.FirstName + " " + u.LastName + " (" + oru.Role.Name + ")")).OrderBy(op => op.SecondValue)
                       .ToList());
            }
        }
Example #29
0
        public CheckListTemplate GetById(long id)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);
                try
                {
                    var query = (from clt in linqMetaData.CheckListTemplate where clt.Id == id select clt).First();

                    return(Mapper.Map <CheckListTemplateEntity, CheckListTemplate>(query));
                }
                catch (InvalidOperationException)
                {
                    throw new ObjectNotFoundInPersistenceException <CheckListTemplate>(id);
                }
            }
        }
Example #30
0
        public List <ZipCode> GetAllZipCodesByCounteryId(long counterId)
        {
            List <ZipEntity> zipEntities;

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(myAdapter);
                zipEntities = (from zip in linqMetaData.Zip
                               join c in linqMetaData.City on zip.CityId equals c.CityId
                               join s in linqMetaData.State on c.StateId equals s.StateId
                               where s.CountryId == counterId
                               select zip).ToList();
                //zipEntities = linqMetaData.Zip.Where(z => z.IsActive).ToList();
            }

            return(_mapper.MapMultiple(zipEntities).ToList());
        }