예제 #1
0
        public CheckListFormEditModel GetCustomerCheckListEdtiModel(Customer customer, CorporateAccount account, EventCustomer eventCustomer)
        {
            var preApporvedTestNames = _eventCustomerPreApprovedTestRepository.GetPreApprovedTestNameByEventCustomerId(eventCustomer.Id);
            var result = _eventCustomerResultRepository.GetById(eventCustomer.Id);

            var template = _checkListTemplateRepository.GetTemplateByEventId(eventCustomer.EventId);

            if (template == null && account.CheckListTemplateId.HasValue)
            {
                template = _checkListTemplateRepository.GetById(account.CheckListTemplateId.Value);
            }
            else if (template == null)
            {
                template = _checkListTemplateRepository.GetDefaultTemplate();
            }

            var templateGroup           = _checkListGroupRepository.GetAllGroups();
            var checkListQuestion       = _checkListQuestionRepository.GetAllQuestionsForTemplateId(template.Id);
            var checklistGroupQuestions = _checkListTemplateRepository.GetAllGroupQuestionsForTemplateId(template.Id);

            var version    = _checkListAnswerRepository.GetLatestVersion(eventCustomer.Id);
            var answerList = new List <CheckListAnswer>();

            if (version > 0)
            {
                answerList = _checkListAnswerRepository.GetAllAnswerByEventCustomerId(eventCustomer.Id, version).ToList();
            }

            return(new CheckListFormEditModel
            {
                CustomerId = customer.CustomerId,
                PreApporvedTestNames = preApporvedTestNames,
                EventId = eventCustomer.EventId,
                Name = customer.Name,
                DoB = customer.DateOfBirth,
                //HealthPlanName = (template.HealthPlanId.HasValue && account != null) ? account.Name : string.Empty,
                EventCustomerId = eventCustomer.Id,
                CheckListQuestion = _checkListQuestionAnswerEditModelFactory.CheckListQuestionAnswerEditModel(checkListQuestion, answerList, templateGroup, checklistGroupQuestions),
                IsEditable = result == null || result.ResultState < (long)TestResultStateNumber.PreAudit,
                Gender = customer.Gender
            });
        }
예제 #2
0
        public PatientWorksheet GetPatientWorksheetModel(Customer customer, Event theEvent, EventCustomer eventCustomer)
        {
            var customerId = customer.Id;
            var eventId    = theEvent.Id;

            var order                = _orderRepository.GetOrderByEventCustomerId(eventCustomer.Id);
            var eventPackage         = _eventPackageRepository.GetPackageForOrder(order.Id);
            var eventTest            = _eventTestRepository.GetTestsForOrder(order.Id);
            var products             = _electronicProductRepository.GetAllProductsForEvent(eventId);
            var purchasedProduct     = _electronicProductRepository.GetElectronicProductByOrderId(order.Id);
            var customerIcdCodes     = _customerIcdCodesRepository.GetIcdByCustomerId(customerId);
            var customerTags         = _corporateCustomerCustomTagRepository.GetByCustomerId(customerId);
            var preApporvedTestNames = _preApprovedTestRepository.GetPreApprovedTestNameByEventCustomerId(eventCustomer.Id);
            var testForTechnician    = _eventTestRepository.GetTestsForEventByRole(eventId, (long)Roles.Technician);

            string[] customerRecentTags = null;

            var isCorporateEvent = theEvent.EventType == EventType.Corporate;

            if (customerTags != null && customerTags.Any() && isCorporateEvent)
            {
                customerTags       = customerTags.OrderByDescending(x => x.DataRecorderMetaData.DateCreated).Take(4);
                customerRecentTags = customerTags.Select(x => x.Tag).ToArray();
            }

            var icdCodes = new List <string>();

            if (!customerIcdCodes.IsNullOrEmpty())
            {
                icdCodes = _icdCodesRepository.GetIcdByIds(customerIcdCodes.Select(x => x.IcdCodeId)).Select(x => x.CodeName.ToUpper()).ToList();
            }

            var labName = string.Empty;

            if (customer.LabId.HasValue)
            {
                var lab = _labRepository.GetById(customer.LabId.Value);
                labName = lab.Name;
            }

            return(new PatientWorksheet
            {
                Name = customer.Name,
                CustomerId = customer.CustomerId,
                Dob = customer.DateOfBirth,
                Height = customer.Height,
                Weight = customer.Weight,
                Gender = customer.Gender,
                Package = eventPackage,
                Tests = eventTest,
                Lab = labName,
                AlaCarteTest = testForTechnician,
                AllProducts = products,
                ProductId = purchasedProduct != null ? purchasedProduct.Id : 0,
                IcdCodes = icdCodes,
                PreApporvedTestNames = preApporvedTestNames,
                EventDate = theEvent.EventDate,
                CustomTags = customerRecentTags,
                IsCorporateEvent = theEvent.EventType == EventType.Corporate
            });
        }