예제 #1
0
        public JsonResult UpdateQuestionnaireType(QuestionnaireType questionnaireType)
        {
            JsonResult result = new JsonResult();
            string     msg    = "";

            try
            {
                questionnaireType.ModifiedTime = DateTime.Now;
                questionnaireType.Modifier     = (Session["user"] as SYS_User)?.UserName;
                bool isSuccess = questionnaireTypeService.UpdateQuestionnaireType(questionnaireType);
                if (isSuccess)
                {
                    msg = "修改成功";
                }
                else
                {
                    msg = "修改失败";
                }
                log.Info(msg);
            }
            catch (DbEntityValidationException e)
            {
                log.Error(e.Message);
            }
            catch (Exception e)
            {
                log.Error(e.Message);
            }
            finally
            {
                result = Json(new { msg = msg }, JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
        private void SetHraInfo(long eventId, long customerId, DateTime eventDate, CorporateAccount account)
        {
            var settings = IoC.Resolve <ISettings>();

            QuestionnaireType questionnaireType = QuestionnaireType.None;

            if (account != null && account.IsHealthPlan)
            {
                var accountHraChatQuestionnaireHistoryServices = IoC.Resolve <IAccountHraChatQuestionnaireHistoryServices>();
                questionnaireType = accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(account.Id, eventDate);
            }

            if (account != null && account.IsHealthPlan && (questionnaireType == QuestionnaireType.HraQuestionnaire))
            {
                var testResultService = new TestResultService();
                IsEawvPurchased = testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.eAWV);

                CorporateAccountTag = account.Tag;
                var sessionContext = IoC.Resolve <ISessionContext>();

                HraQuestionerAppUrl = settings.HraQuestionerAppUrl;
                OrganizationNameForHraQuestioner = settings.OrganizationNameForHraQuestioner;
                HraToken = (Session.SessionID + "_" + sessionContext.UserSession.UserId + "_" +
                            sessionContext.UserSession.CurrentOrganizationRole.RoleId + "_" +
                            sessionContext.UserSession.CurrentOrganizationRole.OrganizationId).Encrypt();

                ChatQuestionerAppUrl = string.Empty;
            }
            else if (account != null && (questionnaireType == QuestionnaireType.ChatQuestionnaire))
            {
                ChatQuestionerAppUrl = settings.ChatQuestionerAppUrl;
                HraQuestionerAppUrl  = string.Empty;
            }
        }
 /// <summary>
 /// 添加问卷类型
 /// </summary>
 /// <param name="questionnaire">问卷类型对象</param>
 /// <returns></returns>
 public bool InsertQuestionnaireType(QuestionnaireType questionnaireType)
 {
     using (var db = base.GDDSVSPDb)
     {
         db.QuestionnaireType.Add(questionnaireType);
         return(db.SaveChanges() > 0);
     }
 }
 /// <summary>
 /// 通过ID获取问卷类型名字
 /// </summary>
 /// <param name="id">问卷类型Id</param>
 /// <returns></returns>
 public string GetQuestionnaireTypeNameById(Guid?id)
 {
     using (var db = base.GDDSVSPDb)
     {
         QuestionnaireType questionnaireType = db.QuestionnaireType.SingleOrDefault(p => p.QuestionnaireTypeID == id);
         return(questionnaireType?.QuestionnaireTypeName);
     }
 }
 /// <summary>
 /// 删除问卷类型
 /// </summary>
 /// <param name="id">问卷类型ID</param>
 /// <returns></returns>
 public bool DeleteQuestionnaireType(Guid id)
 {
     using (var db = base.GDDSVSPDb)
     {
         QuestionnaireType questionnaireType = db.QuestionnaireType.SingleOrDefault(p => p.QuestionnaireTypeID == id);
         db.QuestionnaireType.Remove(questionnaireType);
         return(db.SaveChanges() > 0);
     }
 }
예제 #6
0
 public Questionnaire(string code, QuestionnaireType type, string instruction, IEnumerable<Item> questions)
 {
     Code = code;
     Type = type;
     Instruction = instruction;
     Items = new List<Item>();
     _items = new Dictionary<string, Item>();
     foreach (var question in questions)
         AddQuestion(question);
 }
예제 #7
0
 public Questionnaire(string code, QuestionnaireType type, string instruction, IEnumerable <Item> questions)
 {
     Code        = code;
     Type        = type;
     Instruction = instruction;
     Items       = new List <Item>();
     _items      = new Dictionary <string, Item>();
     foreach (var question in questions)
     {
         AddQuestion(question);
     }
 }
예제 #8
0
        public QuestionnaireDto Get(int questionnaireId, QuestionnaireType? type, ViewType view)
        {            
            QuestionnaireDto retval = null;
            DbCommand sp = null;
            DbConnection connection = null;
            IDataReader reader = null;
            try
            {
                connection = _dbLayer.GetConnection();
                sp = connection.CreateCommand();

                sp.CommandText = "select_questionnaire_general";
                sp.CommandType = CommandType.StoredProcedure;
                _dbLayer.AddParameter(sp, "@questionnaire_id", ParameterDirection.Input, DbType.Int32, questionnaireId);
                if (type.HasValue)
                {
                    _dbLayer.AddParameter(sp, "@questionnaire_type", ParameterDirection.Input, DbType.String, ((char)type).ToString());
                }                
                _dbLayer.AddReturnParameter(sp);
                reader = sp.ExecuteReader();
                bool alreadyRead = false;
                if (reader.Read())
                {                    
                    retval = Read(reader, ref alreadyRead, view);
                }
                else
                {
                    int err = _dbLayer.GetReturnValue(sp);
                    Trace.WriteLine("QuestionnaireDao.Get(" + questionnaireId + ", " + type + ", " + view +") returned " + err);
                }
            }
            catch (DbException e)
            {
                Trace.WriteLine("QuestionnaireDao.Get(" + questionnaireId + ", " + type + ", "+view+"): " + e.Message);
                retval = null;
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
                if (sp != null)
                    sp.Dispose();
                if (connection != null)
                {
                    _dbLayer.ReturnConnection(connection);
                }
                else
                {
                    _dbLayer.ReturnConnection(connection, true);
                }
            }
            return retval;
        }
        public QuestionnaireType QuestionnaireTypeByAccountIdandEventDate(long accountId, DateTime eventDate)
        {
            var questionnaireTypeByAccountId = _accountHraChatQuestionnaireHistoryRepository.GetByAccountId(accountId);
            var result = questionnaireTypeByAccountId.Where(q => q.StartDate <= eventDate && (q.EndDate == null || q.EndDate >= eventDate)).FirstOrDefault();

            QuestionnaireType questionnaireType = QuestionnaireType.None;

            if (result == null)
            {
                return(questionnaireType);
            }

            return((QuestionnaireType)result.QuestionnaireType);
        }
예제 #10
0
        public ActionResult QuestionnaireTypeDetail(string obj)
        {
            QuestionnaireType vo = new QuestionnaireType();

            if (!string.IsNullOrEmpty(obj))
            {
                vo = JsonConvert.DeserializeObject <QuestionnaireType>(obj);
                ViewData["QuestionnaireTypeData"] = vo;
            }
            else
            {
                vo.QuestionnaireTypeID            = Guid.Empty;
                ViewData["QuestionnaireTypeData"] = vo;
            }
            return(View());
        }
예제 #11
0
 /// <summary>
 /// 修改问卷类型
 /// </summary>
 /// <param name="questionnaire">问卷类型对象</param>
 /// <returns></returns>
 public bool UpdateQuestionnaireType(QuestionnaireType obj)
 {
     try
     {
         using (var db = base.GDDSVSPDb)
         {
             QuestionnaireType questionnaireType = db.QuestionnaireType.SingleOrDefault(p => p.QuestionnaireTypeID == obj.QuestionnaireTypeID);
             questionnaireType.QuestionnaireTypeName = obj.QuestionnaireTypeName;
             questionnaireType.ModifiedTime          = obj.ModifiedTime;
             questionnaireType.Modifier = obj.Modifier;
             return(db.SaveChanges() > 0);
         }
     }
     catch (DbEntityValidationException ex)
     {
         throw ex;
     }
 }
예제 #12
0
        public JsonResult InsertQuestionnaireType(QuestionnaireType questionnaireType)
        {
            JsonResult result = new JsonResult();

            try
            {
                questionnaireType.QuestionnaireTypeID = Guid.NewGuid();
                questionnaireType.CreateTime          = DateTime.Now;
                questionnaireType.Creator             = (Session["user"] as SYS_User)?.UserName;
                bool isSuccess = questionnaireTypeService.InsertQuestionnaireType(questionnaireType);
                log.Info("添加成功");
            }
            catch (Exception e)
            {
                log.Error(e.Message);
            }
            finally
            {
                result = Json(new { msg = "添加成功" }, JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
예제 #13
0
    public static void SaveCollecter(QuestionnaireType type)
    {
        int index = 1;

        switch (type)
        {
        case QuestionnaireType.Pre:
            index = 1;
            break;

        case QuestionnaireType.Post:
            index = 4;
            break;
        }
        int[] values = new int[Variables.AnswerDict.Values.Count];
        Variables.AnswerDict.Values.CopyTo(values, 0);
        for (int i = 0; i < Variables.AnswerDict.Count; i++)
        {
            Save(index, values[i]);
            index++;
        }
        Variables.AnswerDict.Clear();
    }
예제 #14
0
        private void NextButtonClick()
        {
            if (!EventValidation())
            {
                return;
            }

            SetPackageData();
            if (!string.IsNullOrEmpty(txtCouponCode.Text))
            {
                SetSourceCodeData();
            }
            else
            {
                SourceCodeId     = 0;
                SourceCode       = string.Empty;
                SourceCodeAmount = decimal.Zero;
            }

            TotalAmount = PackageCost - SourceCodeAmount;

            if (!string.IsNullOrWhiteSpace(hfQuestionAnsTestId.Value))
            {
                QuestionIdAnswerTestId = hfQuestionAnsTestId.Value;
            }
            else
            {
                QuestionIdAnswerTestId = string.Empty;
            }

            if (!string.IsNullOrWhiteSpace(hfDisqualifedTest.Value))
            {
                DisqualifiedTest = hfDisqualifedTest.Value;
            }
            else
            {
                DisqualifiedTest = string.Empty;
            }

            var isEawvPurchased = (TestIds.Any(x => x == (long)TestType.eAWV) || AddOnTestIds.Any(x => x == (long)TestType.eAWV));

            if (CustomerId > 0 && !RegistrationFlow.AwvVisitId.HasValue)
            {   // this was added so that Even if the user forgets to open the HRA Questionnaire Button - We push the User to Medicare.
                var account = AccountByEventId;

                QuestionnaireType questionnaireType = QuestionnaireType.None;
                if (account != null && EventData != null)
                {
                    var accountHraChatQuestionnaireHistoryServices = IoC.Resolve <IAccountHraChatQuestionnaireHistoryServices>();
                    questionnaireType = accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(account.Id, EventData.EventDate);
                }


                if (account != null && account.IsHealthPlan && (questionnaireType == QuestionnaireType.HraQuestionnaire) && isEawvPurchased)
                {
                    try
                    {
                        var setting = IoC.Resolve <ISettings>();

                        if (setting.SyncWithHra)
                        {
                            var medicareService = IoC.Resolve <IMedicareService>();
                            var model           = medicareService.GetCustomerDetails(CustomerId);
                            model.Tag = account.Tag;
                            var medicareApiService = IoC.Resolve <IMedicareApiService>();


                            model.EventDetails = new MedicareEventEditModel {
                                EventId = EventId, VisitDate = EventData.EventDate
                            };
                            var result = medicareApiService.PostAnonymous <MedicareCustomerSetupViewModel>(setting.MedicareApiUrl + MedicareApiUrl.CreateUpdateCustomer, model);
                            if (result != null)
                            {
                                RegistrationFlow.AwvVisitId = result.PatientVisitId;
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        var logger = IoC.Resolve <ILogManager>().GetLogger <Global>();
                        logger.Error("Error occured in Medicare Customer Sync (In Existing Customer : Select appointment) for Customer : " + CustomerId +
                                     " Message: " + exception.Message + "\n stack Trace: " + exception.StackTrace);
                    }
                }
            }

            if (Request.QueryString["Eventid"] != null)
            {
                EventId = long.Parse(Request.QueryString["Eventid"]);
                Response.RedirectUser("/App/Common/RegisterCustomer/SelectAppointment.aspx?EventID=" + EventId + "&guid=" + GuId);
            }
            else if (CustomerType == CustomerType.Existing)
            {
                Response.RedirectUser("SelectAppointment.aspx?Customer=Existing" + "&guid=" + GuId);
            }
            else
            {
                Response.RedirectUser("SelectAppointment.aspx?guid=" + GuId);
            }
        }
예제 #15
0
        public QuestionnaireDto(
            QuestionnaireType type,
            string creatorEmailAddress,
            string campaignCode,
            string countryCode,
            string languageCode,
            string qidTitle,
            bool isActive,
            DateTime expireDate,
            string expireRedirect,
            bool sendToCrm,
            string crmMrmCode,
            bool personalized,
            bool registeredPersonalized,
            bool hasClosurePage,
            string externalClosurePage,
            bool hasThankYouEmail,
            bool hasNotificationEmail,
            string themeColor,
            string mainImage,
            string leftNavHtml,
            string comments,
            int metaPageContent,
            int metaSegment,
            DateTime creationDate,
            string businessOwner,
            string urlLayoutForm,
            bool hasNotificationEmailAstro2,
            DateTime? offlineStart,
            DateTime? offlineEnd,
            int? offlineMode,
            DateTime? offlineRecurEnd,
            string offlineRedirect,
            string region,
            DateTime? datePublished,
            DateTime? dateModified,
            string metaPageContentValue,
            string metaSegmentValue,
            string htmlLang,
            DateTime? publishDate,
            string crmWaveCode,
            bool hppEnabled,
            bool anyAsset,
            string treatmentCode,
            int userProfile, 
            string userProfileValue,
            bool isGofaForm,
            int questionnaireType_GOFA,
            int questionnaireCategory,
            bool isCCDBUpdate, //Balakumar Sprint 2
            int max_number_responses,//Balakumar
            int number_of_responses,//Balakumar
            string banner,
            int banner_height,
            int banner_width,
            int banner_template,
            int company_code
            )
        {
            _questionnaireId = TransientId;
            _businessOwner = businessOwner;
            _campaignCode = campaignCode;
            _comments = comments;
            _countryCode = countryCode;
            _creationDate = creationDate;
            _creatorEmailAddress = creatorEmailAddress;
            _crmMrmCode = crmMrmCode;
            _expireDate = expireDate;
            _expireRedirect = expireRedirect;
            _externalClosurePage = externalClosurePage;
            _hasClosurePage = hasClosurePage;
            _hasNotificationEmail = hasNotificationEmail;
            _hasNotificationEmailAstro2 = hasNotificationEmailAstro2;
            _hasThankYouEmail = hasThankYouEmail;
            _isActive = isActive;
            _languageCode = languageCode;
            _leftNavHtml = leftNavHtml;
            _mainImage = mainImage;
            _metaPageContent = metaPageContent;
            _metaSegment = metaSegment;
            _offlineEnd = offlineEnd;
            _offlineMode = offlineMode;
            _offlineRecurEnd = offlineRecurEnd;
            _offlineRedirect = offlineRedirect;
            _offlineStart = offlineStart;
            _personalized = personalized;
            _qidTitle = qidTitle;
            _registeredPersonalized = registeredPersonalized;
            _sendToCrm = sendToCrm;
            _themeColor = themeColor;
            _type = type;
            _urlLayoutForm = urlLayoutForm;
            _region = region;
            _datePublished = datePublished;
            _dateModified = dateModified;
            _metaPageContentValue = metaPageContentValue;
            _metaSegmentValue = metaSegmentValue;
            _htmlLang = htmlLang;
            _publishDate = publishDate;
            _crmWaveCode = crmWaveCode;
            _hppEnabled = hppEnabled;
            _anyAsset = anyAsset;
            _treatmentCode = treatmentCode;
            _userProfile = userProfile;
            _userProfileValue = userProfileValue;

            _useClassicDesign = false; // TODO: check if this needs to be in ctor Parameters as well...
            _isGofaForm = IsGofaForm;
            _questionnaireType_GOFA = questionnaireType_GOFA;
            _questionnaireCategory = questionnaireCategory;
            _isCCDBUpdate = isCCDBUpdate; //Balakumar
            _max_number_responses = max_number_responses;//Balakumar
            _number_of_responses = number_of_responses;
            _banner = banner;
            _banner_height = banner_height;
            _banner_width = banner_width;
            _banner_template = banner_template;
            _Company_Code = company_code;
        }
        public EventCustomerResultStatusListModel Create(Event theEvent, Host eventHost, IEnumerable <EventTest> eventTests, IEnumerable <EventCustomer> eventCustomers,
                                                         IEnumerable <Customer> customers, IEnumerable <EventPackage> packages, IEnumerable <OrderedPair <long, long> > ecIdPackageIdpairs, IEnumerable <OrderedPair <long, long> > ecIdTestIdPairs,
                                                         IEnumerable <ResultArchive> fileUploads, IEnumerable <ResultArchiveLog> parsingResults, List <CustomerResultStatusViewModel> customerResults,
                                                         IEnumerable <EventCustomerResult> eventCustomerResults, IEnumerable <OrderedPair <long, string> > physcianComments, Notes emrNotes,
                                                         IEnumerable <AssignedPhysicianViewModel> assignedPhysicians, IEnumerable <Order> orders, CorporateAccount account, IEnumerable <PrimaryCarePhysician> primaryCarePhysicians,
                                                         IEnumerable <PriorityInQueue> priorityInQueues, bool printcheck, bool isNewResultFlow, IEnumerable <OrderedPair <long, long> > eventCustomerResultIdTestIdNotPerformedPairs, QuestionnaireType questionnaireType)
        {
            var model = new EventCustomerResultStatusListModel
            {
                EventId                = theEvent.Id,
                EventDate              = theEvent.EventDate,
                Address                = Mapper.Map <Address, AddressViewModel>(eventHost.Address),
                Host                   = eventHost.OrganizationName,
                EmrNotes               = emrNotes != null ? emrNotes.Text : "",
                EventTests             = eventTests.Where(et => et.Test.IsRecordable).Select(et => et.Test).OrderBy(et => et.Id).ToArray(),
                CaptureAbnStatus       = account != null && account.CaptureAbnStatus,
                CaptureHaf             = (account == null || account.CaptureHaf),
                BloodPackageTracking   = theEvent.BloodPackageTracking,
                RecordsPackageTracking = theEvent.RecordsPackageTracking,
                PrintCheckList         = printcheck,
            };

            if (eventCustomers == null || eventCustomers.Count() < 1)
            {
                return(model);
            }
            var newCustomerResults = new List <CustomerResultStatusViewModel>();

            if (customerResults == null)
            {
                customerResults = new List <CustomerResultStatusViewModel>();
            }

            foreach (EventCustomer eventCustomer in eventCustomers)
            {
                var orderPurchased = "";

                var packageIdPurchased =
                    ecIdPackageIdpairs.Where(p => p.FirstValue == eventCustomer.Id).Select(p => p.SecondValue).SingleOrDefault();

                var customerTests = new List <Test>();
                if (packageIdPurchased > 0)
                {
                    var package = packages.SingleOrDefault(p => p.Id == packageIdPurchased);
                    orderPurchased = package.Package.Name;
                    customerTests.AddRange(package.Package.Tests);
                }

                var testIdsPurchased = ecIdTestIdPairs.Where(p => p.FirstValue == eventCustomer.Id).Select(p => p.SecondValue).ToArray();
                if (testIdsPurchased.Count() > 0)
                {
                    if (!string.IsNullOrEmpty(orderPurchased))
                    {
                        orderPurchased += " + ";
                    }
                    var addOnTests = eventTests.Where(et => testIdsPurchased.Contains(et.Id)).Select(et => et.Test).ToArray();
                    orderPurchased += string.Join(" + ", addOnTests.Select(t => t.Name));
                    customerTests.AddRange(addOnTests);
                }

                var customer = customerResults.SingleOrDefault(c => c.CustomerId == eventCustomer.CustomerId) ??
                               new CustomerResultStatusViewModel {
                    CustomerId = eventCustomer.CustomerId
                };


                newCustomerResults.Add(customer);

                var theCustomerDo = customers.SingleOrDefault(c => c.CustomerId == eventCustomer.CustomerId);

                customer.CustomerName      = theCustomerDo.NameAsString;
                customer.CustomerFirstName = theCustomerDo.Name.FirstName;
                customer.CustomerLastName  = theCustomerDo.Name.LastName;
                customer.Address           = Mapper.Map <Address, AddressViewModel>(theCustomerDo.Address);
                customer.Email             = theCustomerDo.Email != null?theCustomerDo.Email.ToString() : "";

                var phone = ((theCustomerDo.HomePhoneNumber ?? theCustomerDo.OfficePhoneNumber) ?? theCustomerDo.OfficePhoneNumber);
                if (phone != null)
                {
                    customer.Phone = phone.ToString();
                }
                customer.OrderPurchased = orderPurchased;

                var eventCustomerResult = eventCustomerResults != null?eventCustomerResults.SingleOrDefault(ec => ec.Id == eventCustomer.Id) : null;

                var isHraQuestionnaire  = questionnaireType == QuestionnaireType.HraQuestionnaire;
                var isChatQuestionnaire = questionnaireType == QuestionnaireType.ChatQuestionnaire;

                bool ischartSignoff = false;
                if (isChatQuestionnaire)
                {
                    var hasPurchasedQVTest = customerTests.Any(x => x.Id == (long)TestType.Qv);
                    ischartSignoff = hasPurchasedQVTest || (eventCustomerResult != null && eventCustomerResult.SignedOffBy.HasValue);
                }
                else
                {
                    var hasPurchasedEawvTest   = isHraQuestionnaire && customerTests.Any(x => x.Id == (long)TestType.eAWV);
                    var isEawvTestNotPerformed = eventCustomerResultIdTestIdNotPerformedPairs.Any(x => x.FirstValue == eventCustomer.Id && x.SecondValue == (int)TestType.eAWV);

                    ischartSignoff = (eventCustomerResult != null && eventCustomerResult.SignedOffBy.HasValue) || !hasPurchasedEawvTest || isEawvTestNotPerformed;
                }

                var eventTestResults = customerTests.Select(ct => new TestResultStatusViewModel
                {
                    TestId      = ct.Id,
                    Label       = ct.Name,
                    Alias       = ct.Alias,
                    ResultState = (isNewResultFlow ? (int)NewTestResultStateNumber.NoResults : (int)TestResultStateNumber.NoResults),
                    State       = isNewResultFlow && ischartSignoff ? TestResultStateLabel.NoResultsChartSigned : TestResultStateLabel.NoResults
                }).ToArray();


                var capturePcpConsent = false;
                if (account != null && account.CapturePcpConsent && primaryCarePhysicians != null && primaryCarePhysicians.Any())
                {
                    capturePcpConsent = primaryCarePhysicians.Any(x => x.CustomerId == customer.CustomerId);
                }

                bool isClinicalFormGenerated = false;
                bool isResultPdfGenerarted   = false;
                bool isIpResultGenerated     = false;

                if (eventCustomerResult != null)
                {
                    isClinicalFormGenerated = eventCustomerResult.IsClinicalFormGenerated;
                    isResultPdfGenerarted   = eventCustomerResult.IsResultPdfGenerated;
                    isIpResultGenerated     = eventCustomerResult.IsIpResultGenerated;
                }

                var order = orders.Where(o => o.EventId == eventCustomer.EventId && o.CustomerId == eventCustomer.CustomerId).Select(o => o).SingleOrDefault();
                if (order != null)
                {
                    customer.IsPaid = order.DiscountedTotal > order.TotalAmountPaid ? false : true;
                }

                var priorityInqueue = priorityInQueues != null?priorityInQueues.FirstOrDefault(piq => piq.EventCustomerResultId == eventCustomer.Id) : null;

                customer.InQueuePriority = priorityInqueue != null ? priorityInqueue.InQueuePriority : (long?)null;
                customer.HipaaStatus     = eventCustomer.HIPAAStatus;
                customer.PartnerRelease  = eventCustomer.PartnerRelease;
                customer.AbnStatus       = eventCustomer.AbnStatus;

                customer.IsPremiumVersionPdfGenerated = isResultPdfGenerarted;
                customer.IsClinicalFormGenerated      = isClinicalFormGenerated;
                customer.IsIpResultGenerated          = isIpResultGenerated;

                customer.HospitalFacilityId = eventCustomer.HospitalFacilityId;

                customer.CapturePcpConsent      = capturePcpConsent;
                customer.PcpConsentStatus       = eventCustomer.PcpConsentStatus;
                customer.InsuranceReleaseStatus = eventCustomer.InsuranceReleaseStatus;

                customer.IsChartSigned     = ischartSignoff;
                customer.IsCodingCompleted = eventCustomerResult != null && eventCustomerResult.CodedBy.HasValue;
                customer.InvoicingDate     = eventCustomerResult != null ? eventCustomerResult.AcesApprovedOn : null;

                if (customer.EventCustomerId <= 0)
                {
                    customer.EventCustomerId = eventCustomer.Id;
                }

                customer.PhysicianComments = physcianComments != null?physcianComments.Where(pc => pc.FirstValue == eventCustomer.Id).Select(pc => pc.SecondValue).FirstOrDefault() : string.Empty;

                customer.AcesId = theCustomerDo.AcesId;

                var allTestIds = customerTests.Select(x => x.Id).ToArray();

                customer.IsAnyTestinHip = eventTests.Any(t => allTestIds.Contains(t.TestId) && t.Test.ShowinCustomerPdf && (t.ResultEntryTypeId.HasValue == false || t.ResultEntryTypeId.Value == (long)ResultEntryType.Hip));

                if (assignedPhysicians != null)
                {
                    var assignedPhysician =
                        assignedPhysicians.SingleOrDefault(ap => ap.CustomerId == customer.CustomerId);

                    customer.AssignedPhysicians = assignedPhysician;
                }

                try
                {
                    customer.TestResults = CompareEventTestResults(customer.TestResults, eventTestResults, parsingResults != null ? parsingResults.Where(pr => pr.CustomerId == eventCustomer.CustomerId).ToArray() : null, isNewResultFlow, customer.IsChartSigned);
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("Loading Test Results! Customer[{0}] & Event[{1}]. Message: {2}. \nStack Trace: {3}", customer.CustomerId, eventCustomer.EventId, ex.Message, ex.StackTrace));
                    customer.TestResults = null;
                }
            }
            model.AccountId    = account != null ? account.Id : 0;
            model.IsHealthPlan = account != null && account.IsHealthPlan;

            model.Customers = newCustomerResults;
            return(model);
        }
예제 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ISystemInformationRepository systemInformationRepository = new SystemInformationRepository();

            VersionNumber = systemInformationRepository.GetBuildNumber();

            var master = ((Franchisor_FranchisorMaster)Master);

            if (master != null)
            {
                master.HideLeftContainer = true;
                master.hideucsearch();
                master.settitle("Post Audit");
                master.SetBreadCrumbRoot = "<a href=\"#\">DashBoard</a>";
            }

            long s = 0;

            if (Request.QueryString["EventId"] != null && long.TryParse(Request.QueryString["EventId"], out s))
            {
                EventId = s;
            }

            s = 0;
            if (Request.QueryString["CustomerId"] != null && long.TryParse(Request.QueryString["CustomerId"], out s))
            {
                CustomerId = s;
            }

            if (EventId > 0 && CustomerId > 0)
            {
                var corporateAccountRepository = IoC.Resolve <ICorporateAccountRepository>();
                var account = corporateAccountRepository.GetbyEventId(EventId);

                IsHealthPlan = account != null && account.IsHealthPlan;

                var eventRepository = IoC.Resolve <IEventRepository>();
                var theEvent        = eventRepository.GetById(EventId);
                QuestionnaireType = QuestionnaireType.None;
                if (account != null && theEvent != null)
                {
                    var accountHraChatQuestionnaireHistoryServices = IoC.Resolve <IAccountHraChatQuestionnaireHistoryServices>();
                    QuestionnaireType = accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(account.Id, theEvent.EventDate);
                }

                ShowHraQuestions = (QuestionnaireType == QuestionnaireType.HraQuestionnaire);

                var eventCustomerResultRepository = IoC.Resolve <IEventCustomerResultRepository>();
                var testResultService             = IoC.Resolve <ITestResultService>();
                var eventCustomerResult           = eventCustomerResultRepository.GetByCustomerIdAndEventId(CustomerId, EventId);

                IsEawvTestPurchased = testResultService.IsTestPurchasedByCustomer(eventCustomerResult.Id, (long)TestType.eAWV);
                if (IsEawvTestPurchased)
                {
                    IsEawvTestNotPerformed = IoC.Resolve <ITestNotPerformedRepository>().IsTestNotPerformed(eventCustomerResult.Id, (long)TestType.eAWV);
                }

                if (account != null)
                {
                    if (account.MarkPennedBack && eventCustomerResult.IsRevertedToEvaluation)
                    {
                        MarkAsPennedBackDiv.Visible = true;
                        if (eventCustomerResult.IsPennedBack)
                        {
                            MarkAsPennedBackCheckbox.Checked = true;
                        }
                    }
                    else
                    {
                        MarkAsPennedBackDiv.Visible = false;
                    }
                }

                IsNewResultFlow = eventRepository.IsEventHasNewResultFlow(EventId);

                if (IsNewResultFlow)
                {
                    ClientScript.RegisterHiddenField("IsNewResultFlowInputHidden", "true");
                }
                else
                {
                    ClientScript.RegisterHiddenField("IsNewResultFlowInputHidden", "false");
                }
            }

            var repository     = new TestResultRepository();
            var nextCustomerId = repository.GetNextCustomerPostAudit(EventId, CustomerId, IsNewResultFlow);

            ClientScript.RegisterStartupScript(Page.GetType(), "js_nextCustomer", "nextCustomerId = " + nextCustomerId + ";", true);
        }
        public EventCustomerResultStatusListModel Create(Event theEvent, Host eventHost, IEnumerable <EventTest> eventTests, EventCustomer eventCustomer, Customer customer,
                                                         IEnumerable <EventPackage> packages, IEnumerable <OrderedPair <long, long> > ecIdPackageIdpairs, IEnumerable <OrderedPair <long, long> > ecIdTestIdPairs,
                                                         IEnumerable <ResultArchiveLog> parsingResults, CustomerResultStatusViewModel customerResult, EventCustomerResult eventCustomerResult, bool isNewResultFlow, CorporateAccount account, QuestionnaireType questionnaireType)
        {
            var model = new EventCustomerResultStatusListModel
            {
                EventId    = theEvent.Id,
                EventDate  = theEvent.EventDate,
                Address    = Mapper.Map <Address, AddressViewModel>(eventHost.Address),
                Host       = eventHost.OrganizationName,
                EventTests = eventTests.Where(et => et.Test.IsRecordable).Select(et => et.Test).ToArray()
            };
            var orderPurchased     = "";
            var packageIdPurchased = ecIdPackageIdpairs.Where(p => p.FirstValue == eventCustomer.Id).Select(p => p.SecondValue).SingleOrDefault();

            var customerTests = new List <Test>();

            if (packageIdPurchased > 0)
            {
                var package = packages.Where(p => p.Id == packageIdPurchased).Select(p => p.Package).SingleOrDefault();
                orderPurchased = package.Name;
                customerTests.AddRange(package.Tests);
            }

            var testIdsPurchased = ecIdTestIdPairs.Where(p => p.FirstValue == eventCustomer.Id).Select(p => p.SecondValue).ToArray();

            if (testIdsPurchased.Count() > 0)
            {
                if (!string.IsNullOrEmpty(orderPurchased))
                {
                    orderPurchased += " + ";
                }
                var addOnTests = eventTests.Where(et => testIdsPurchased.Contains(et.Id)).Select(et => et.Test).ToArray();
                orderPurchased += string.Join(" + ", addOnTests.Select(t => t.Name));
                customerTests.AddRange(addOnTests);
            }

            var isHraQuestionnaire  = questionnaireType == QuestionnaireType.HraQuestionnaire;
            var isChatQuestionnaire = questionnaireType == QuestionnaireType.ChatQuestionnaire;

            var hasPurchasedEawvTest = isHraQuestionnaire && customerTests.Any(x => x.Id == (long)TestType.eAWV);

            var hasPurchasedQVTest = isChatQuestionnaire && customerTests.Any(x => x.Id == (long)TestType.Qv);

            var newCustomerResults = new List <CustomerResultStatusViewModel>();


            if (customerResult == null)
            {
                customerResult = new CustomerResultStatusViewModel {
                    CustomerId = eventCustomer.CustomerId
                };
            }
            newCustomerResults.Add(customerResult);

            customerResult.CustomerName      = customer.NameAsString;
            customerResult.CustomerFirstName = customer.Name.FirstName;
            customerResult.CustomerLastName  = customer.Name.LastName;
            customerResult.OrderPurchased    = orderPurchased;

            var eventTestResults = customerTests.Select(ct => new TestResultStatusViewModel
            {
                TestId      = ct.Id,
                Label       = ct.Name,
                Alias       = ct.Alias,
                ResultState = (isNewResultFlow ? (int)NewTestResultStateNumber.NoResults : (int)TestResultStateNumber.NoResults),
                State       = TestResultStateLabel.NoResults
            }).ToArray();

            bool isClinicalFormGenerated = false;
            bool isResultPdfGenerarted   = false;
            var  isChartSignedOff        = false;
            var  isIpResultGenerated     = false;

            if (isChatQuestionnaire)
            {
                isChartSignedOff = hasPurchasedQVTest || (eventCustomerResult != null && eventCustomerResult.SignedOffBy.HasValue);
            }
            else
            {
                isChartSignedOff = eventCustomerResult.SignedOffBy.HasValue || !hasPurchasedEawvTest;
            }

            if (eventCustomerResult != null)
            {
                isClinicalFormGenerated = eventCustomerResult.IsClinicalFormGenerated;
                isResultPdfGenerarted   = eventCustomerResult.IsResultPdfGenerated;
                //isChartSignedOff = isChatQuestionnaire ? eventCustomerResult.SignedOffBy.HasValue : eventCustomerResult.SignedOffBy.HasValue || !hasPurchasedEawvTest;
                isIpResultGenerated = eventCustomerResult.IsIpResultGenerated;
            }

            customerResult.HipaaStatus    = eventCustomer.HIPAAStatus;
            customerResult.PartnerRelease = eventCustomer.PartnerRelease;

            customerResult.IsPremiumVersionPdfGenerated = isResultPdfGenerarted;
            customerResult.IsClinicalFormGenerated      = isClinicalFormGenerated;
            customerResult.IsChartSigned       = isChartSignedOff;
            customerResult.IsIpResultGenerated = isIpResultGenerated;
            customerResult.IsCodingCompleted   = eventCustomerResult != null && eventCustomerResult.CodedBy.HasValue;
            customerResult.InvoicingDate       = eventCustomerResult != null ? eventCustomerResult.AcesApprovedOn : null;

            customerResult.TestResults = CompareEventTestResults(customerResult.TestResults, eventTestResults, parsingResults, isNewResultFlow, customerResult.IsChartSigned);

            model.Customers = newCustomerResults;
            return(model);
        }
예제 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var settings = IoC.Resolve <ISettings>();

            ISystemInformationRepository systemInformationRepository = new SystemInformationRepository();

            VersionNumber = systemInformationRepository.GetBuildNumber();

            if (!IsPostBack)
            {
                if (EventCustomerId > 0)
                {
                    var eventRepository = new EventCustomerResultRepository();
                    EventCustomerResult = eventRepository.GetById(EventCustomerId);
                    if (EventCustomerResult != null)
                    {
                        EventId    = EventCustomerResult.EventId;
                        CustomerId = EventCustomerResult.CustomerId;
                        SetEventBasicInfo(EventCustomerResult.EventId);
                        TestSection.CustomerId = EventCustomerResult.CustomerId;
                        TestSection.EventId    = EventCustomerResult.EventId;
                    }

                    var priorityInQueue = IoC.Resolve <IPriorityInQueueRepository>().GetByEventCustomerResultId(EventCustomerId);
                    if (priorityInQueue != null && priorityInQueue.InQueuePriority > 0 && priorityInQueue.NoteId != null)
                    {
                        var noteText = IoC.Resolve <INotesRepository>().Get(priorityInQueue.NoteId.Value);
                        if (noteText != null && !string.IsNullOrEmpty(noteText.Text))
                        {
                            PriorityInQueueMessage.ShowSuccessMessage("<b><u>Priority In Queue Reason:</u> </b>" +
                                                                      noteText.Text);
                            PriorityInQueueMessage.Visible = true;
                        }
                    }

                    var customerEventTestStateRepository = IoC.Resolve <ICustomerEventTestStateRepository>();
                    var isCriticalPatient = customerEventTestStateRepository.IsPatientCritical(EventCustomerId);

                    var eventCustomerCriticalQuestionRepository = IoC.Resolve <IEventCustomerCriticalQuestionRepository>();
                    var criticalData = eventCustomerCriticalQuestionRepository.GetByEventCustomerId(EventCustomerId);

                    if ((priorityInQueue != null && priorityInQueue.InQueuePriority > 0) || (isCriticalPatient && !criticalData.IsNullOrEmpty()))
                    {
                        ShowCriticalPatientData = true;
                    }
                }

                Page.Title = "Evaluation : " + CustomerId;

                var physicianId         = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole.OrganizationRoleUserId;
                var physicianRepository = IoC.Resolve <IPhysicianRepository>();
                var overReadPhysicianId = physicianRepository.GetOverreadPhysician(EventCustomerId);

                var physician = physicianRepository.GetPhysician(physicianId);
                CanPhysicianUpdateResultEntery = physician.UpdateResultEntry;
                if (physicianId == overReadPhysicianId)
                {
                    IsforOveread = true;
                }
                else
                {
                    IsforOveread = false;
                }

                string messageForPhysician = new CommunicationRepository().GetCommentsforPhysician(CustomerId, EventId, physicianId);
                if (!string.IsNullOrEmpty(messageForPhysician))
                {
                    FranchiseeCommentsMessage.ShowSuccessMessage("<b><u>Technician Comments:</u> </b>" + messageForPhysician);
                    FranchiseeCommentsMessage.Visible = true;
                }

                if (overReadPhysicianId > 0)
                {
                    headerifoverreaddiv.Visible   = true;
                    headerifoverreaddiv.InnerHtml = IsforOveread ? "<h2> This study is an Overread, and you are the Second Evaluator! </h2>" : "<h2> This study is an Overread, and you are the First Evaluator! </h2>";
                }

                ClientScript.RegisterClientScriptBlock(Page.GetType(), "js_OverRead", (overReadPhysicianId > 0 ? " var isOverReadAvailable = true; " : " var isOverReadAvailable = false; ") + (overReadPhysicianId == physicianId ? "var isCurrentViewforOverread = true;" : "var isCurrentViewforOverread = false;"), true);

                var mediaLocation = IoC.Resolve <IMediaRepository>().GetResultMediaFileLocation(CustomerId, EventId);
                ClientScript.RegisterClientScriptBlock(Page.GetType(), "js_Location_Url", "function getLocationPrefix() { return '" + mediaLocation.PhysicalPath.Replace("\\", "\\\\") + "'; } function getUrlPrefix() { return '" + mediaLocation.Url + "'; }", true);

                var basicBiometricCutOfDate = settings.BasicBiometricCutOfDate;
                var hideBasicBiometric      = (EventDate.Date >= basicBiometricCutOfDate);
                BasicBiometric.ShowByCutOffDate = !hideBasicBiometric;

                ShowHideFastingStatus = (EventDate.Date.Date >= settings.FastingStatusDate);

                TestSection.SetSectionShowHideEvaluation(EventId, CustomerId, hideBasicBiometric);

                StartEvaluation();
                GetConductedbyData();

                CreateIfjsArrays();
                CreateJsArrayforIfuCs();

                var hospitalPartnerRepository = IoC.Resolve <IHospitalPartnerRepository>();
                var eventHospitalPartner      = hospitalPartnerRepository.GetEventHospitalPartnersByEventId(EventId);
                if (eventHospitalPartner != null && eventHospitalPartner.RestrictEvaluation)
                {
                    var eventPhysicianTestRepository = IoC.Resolve <IEventPhysicianTestRepository>();
                    var eventPhysicianTests          = eventPhysicianTestRepository.GetByEventIdPhysicianId(EventId, physicianId);
                    if (eventPhysicianTests != null && eventPhysicianTests.Any())
                    {
                        foreach (var eventPhysicianTest in eventPhysicianTests)
                        {
                            ClientScript.RegisterArrayDeclaration("arr_permittedtest", "'" + eventPhysicianTest.TestId + "'");
                        }
                    }
                }
                else
                {
                    var testIds = physicianRepository.GetPermittedTestIdsForPhysician(physicianId);
                    foreach (var testId in testIds)
                    {
                        ClientScript.RegisterArrayDeclaration("arr_permittedtest", "'" + testId + "'");
                    }
                }
            }

            var accountRepository = IoC.Resolve <ICorporateAccountRepository>();
            var account           = accountRepository.GetbyEventId(EventId);

            CaptureHaf      = (account == null || account.CaptureHaf);
            IsNewResultFlow = EventDate >= settings.ResultFlowChangeDate;

            QuestionnaireType questionnaireType = QuestionnaireType.None;

            if (account != null && account.IsHealthPlan)
            {
                var accountHraChatQuestionnaireHistoryServices = IoC.Resolve <IAccountHraChatQuestionnaireHistoryServices>();
                questionnaireType = accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(account.Id, EventDate);
            }

            ShowHraLink  = "none";
            ShowChatLink = "none";

            if (EventCustomerResult == null && EventCustomerId > 0)
            {
                var eventRepository = new EventCustomerResultRepository();
                EventCustomerResult = eventRepository.GetById(EventCustomerId);
            }

            if (EventCustomerResult != null)
            {
                if (!IsforOveread)
                {
                    hfIsPdfVerified.Value = EventCustomerResult.ChatPdfReviewedByPhysicianId.HasValue &&
                                            EventCustomerResult.ChatPdfReviewedByPhysicianDate.HasValue ? "1" : "0";
                }
                else
                {
                    hfIsPdfVerified.Value = EventCustomerResult.ChatPdfReviewedByOverreadPhysicianId.HasValue &&
                                            EventCustomerResult.ChatPdfReviewedByOverreadPhysicianDate.HasValue ? "1" : "0";
                }
            }

            if (account != null && account.IsHealthPlan && (questionnaireType == QuestionnaireType.HraQuestionnaire) && EventCustomerId > 0)
            {
                var testResultService       = IoC.Resolve <ITestResultService>();
                var eventCustomerRepository = IoC.Resolve <IEventCustomerRepository>();
                var eventCustomer           = eventCustomerRepository.GetById(EventCustomerId);
                if (IsNewResultFlow)
                {
                    var isEawvPurchased = testResultService.IsTestPurchasedByCustomer(EventCustomerId, (long)TestType.eAWV);
                    if (isEawvPurchased)
                    {
                        var testResultRepository = new EAwvTestRepository();
                        var eawvTestResult       = testResultRepository.GetTestResult(eventCustomer.CustomerId, eventCustomer.EventId, (int)TestType.eAWV, IsNewResultFlow);

                        bool iseawvTestMarkedTestNotPerformed = eawvTestResult != null &&
                                                                eawvTestResult.TestNotPerformed != null &&
                                                                eawvTestResult.TestNotPerformed.TestNotPerformedReasonId >
                                                                0;

                        if (!iseawvTestMarkedTestNotPerformed)
                        {
                            if (eventCustomer.AwvVisitId != null)
                            {
                                MedicareVisitId = eventCustomer.AwvVisitId.Value;
                                Tag             = account.Tag;
                                var sessionContext = IoC.Resolve <ISessionContext>();
                                HraQuestionerAppUrl = settings.HraQuestionerAppUrl;
                                OrganizationNameForHraQuestioner = settings.OrganizationNameForHraQuestioner;
                                HraToken = (Session.SessionID + "_" + sessionContext.UserSession.UserId + "_" +
                                            sessionContext.UserSession.CurrentOrganizationRole.RoleId + "_" +
                                            sessionContext.UserSession.CurrentOrganizationRole.OrganizationId).Encrypt();
                                ShowHraLink = "block";
                            }
                        }
                    }
                }
                else
                {
                    if (eventCustomer.AwvVisitId != null)
                    {
                        MedicareVisitId = eventCustomer.AwvVisitId.Value;
                        Tag             = account.Tag;
                        var sessionContext = IoC.Resolve <ISessionContext>();
                        HraQuestionerAppUrl = settings.HraQuestionerAppUrl;
                        OrganizationNameForHraQuestioner = settings.OrganizationNameForHraQuestioner;
                        HraToken = (Session.SessionID + "_" + sessionContext.UserSession.UserId + "_" +
                                    sessionContext.UserSession.CurrentOrganizationRole.RoleId + "_" +
                                    sessionContext.UserSession.CurrentOrganizationRole.OrganizationId).Encrypt();
                        ShowHraLink = "block";
                    }
                }
            }
            else if (account != null && account.IsHealthPlan && (questionnaireType == QuestionnaireType.ChatQuestionnaire) && EventCustomerId > 0)
            {
                ChatQuestionerAppUrl  = settings.ChatQuestionerAppUrl;
                ShowChatLink          = "block";
                ShowChatAssesmentLink = true;
            }

            if (EventDate < settings.ChecklistChangeDate)
            {
                ShowCheckListForm = account != null && account.PrintCheckList;
            }

            if (IsNewResultFlow)
            {
                ClientScript.RegisterHiddenField("IsNewResultFlowInputHidden", "true");
            }
            else
            {
                ClientScript.RegisterHiddenField("IsNewResultFlowInputHidden", "false");
            }
        }
        public PreAssessmentCustomerContactViewModel GetByCustomerId(long customerId, long callId, long orgRoleUserId)
        {
            if (customerId <= 0)
            {
                return(null);
            }
            var       call          = _callCenterCallRepository.GetById(callId);
            var       eventCustomer = _eventCustomerRepository.Get(call.EventId, customerId);
            CallQueue callQueue     = null;

            if (call != null)
            {
                callQueue = _callQueueRepository.GetById((long)call.CallQueueId);
            }
            var customer = _customerRepository.GetCustomer(customerId);

            var memberIdLabel = string.Empty;
            CorporateAccount    corporateAccount    = null;
            CustomerEligibility customerEligibility = null;

            if (customer != null)
            {
                customerEligibility = _customerEligibilityRepository.GetByCustomerIdAndYear(customer.CustomerId, DateTime.Today.Year);
                if (!string.IsNullOrEmpty(customer.Tag))
                {
                    corporateAccount = _corporateAccountRepository.GetByTag(customer.Tag);
                    memberIdLabel    = corporateAccount != null ? corporateAccount.MemberIdLabel : string.Empty;
                }
            }

            var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId);
            CallQueuePatientInfomationViewModel patientInfo = null;

            if (customer != null)
            {
                Falcon.App.Core.Medical.Domain.ActivityType activityType = null;
                if (customer.ActivityId.HasValue)
                {
                    activityType = _activityTypeRepository.GetById(customer.ActivityId.Value);
                }

                patientInfo = _preAssessmentCallQueuePatientInfomationFactory.SetCustomerInfo(customer, customerEligibility, activityType);
            }
            else
            {
                patientInfo = _preAssessmentCallQueuePatientInfomationFactory.SetProspectCustomerInfo(prospectCustomer);
            }


            if (patientInfo.HealthPlanPhoneNumber == null)
            {
                patientInfo.HealthPlanPhoneNumber = corporateAccount != null ? corporateAccount.CheckoutPhoneNumber : null;
            }
            var additionalFileds = new List <OrderedPair <string, string> >();

            if (corporateAccount != null)
            {
                var accountAdditionalFields = _accountAdditionalFieldRepository.GetByAccountId(corporateAccount.Id);
                if (accountAdditionalFields.Any())
                {
                    additionalFileds.AddRange(accountAdditionalFields.Select(additionalField => new OrderedPair <string, string>(additionalField.DisplayName,
                                                                                                                                 GetCustomerAdditionalField(customer, additionalField.AdditionalFieldId))));
                }
                if (corporateAccount.ShowCallCenterScript && corporateAccount.CallCenterScriptFileId > 0)
                {
                    var callCenterScriptPdf = _fileRepository.GetById(corporateAccount.CallCenterScriptFileId);
                    var mediaLocation       = _mediaRepository.GetCallCenterScriptPdfFolderLocation();
                    patientInfo.CallCenterScriptUrl = mediaLocation.Url + callCenterScriptPdf.Path;
                }
                if (callQueue != null && callQueue.Category == HealthPlanCallQueueCategory.PreAssessmentCallQueue)
                {
                    if (corporateAccount.ShowCallCenterScript && corporateAccount.ConfirmationScriptFileId > 0)
                    {
                        var confirmationScriptPdf = _fileRepository.GetById(corporateAccount.ConfirmationScriptFileId);
                        var mediaLocation         = _mediaRepository.GetCallCenterScriptPdfFolderLocation();
                        patientInfo.CallCenterScriptUrl = mediaLocation.Url + confirmationScriptPdf.Path;
                    }
                }
            }
            var hasMammo = customer != null && _preApprovedTestRepository.CheckPreApprovedTestForCustomer(customer.CustomerId, TestGroup.BreastCancer);

            patientInfo.HasMammo = hasMammo;

            patientInfo.MammoTestAsPreApproved = hasMammo;

            patientInfo.CustomerId         = customerId;
            patientInfo.ProspectCustomerId = prospectCustomer != null ? prospectCustomer.Id : 0;

            patientInfo = _preAssessmentCallQueuePatientInfomationFactory.SetCustomerTagInfo(prospectCustomer, patientInfo);

            if (patientInfo != null && callQueue != null && callQueue.IsHealthPlan)
            {
                patientInfo.PrimaryCarePhysician = _primaryCarePhysicianHelper.GetPrimaryCarePhysicianViewModel(customerId);
            }

            if (customer != null)
            {
                var customerCustomTags = _corporateCustomerCustomTagRepository.GetByCustomerId(customer.CustomerId);
                if (!customerCustomTags.IsNullOrEmpty())
                {
                    var customTags = customerCustomTags.OrderByDescending(x => x.DataRecorderMetaData.DateCreated).Select(x => x.Tag).ToArray();
                    patientInfo.CustomCorporateTags = customTags.IsNullOrEmpty() ? string.Empty : string.Join(",", customTags);
                }
            }

            IEnumerable <string> preApprovedTests = null;
            var preApprovedTestsList = _preApprovedTestRepository.GetPreApprovedTests(customerId);

            if (preApprovedTestsList.Count() > 0)
            {
                preApprovedTests = preApprovedTestsList;
            }

            IEnumerable <Package> preApprovedPackages = null;
            var preApprovedPackageList = _preApprovedPackageRepository.GetByCustomerId(customerId);
            var packageIds             = preApprovedPackageList != null?preApprovedPackageList.Select(x => x.PackageId) : null;

            if (packageIds != null)
            {
                preApprovedPackages = _packageRepository.GetByIds(packageIds.ToList());
            }

            if (customer != null && customer.Address != null && customer.Address.StateId > 0 && corporateAccount != null)
            {
                patientInfo.HealthPlanPhoneNumber = _customerAccountGlocomNumberService.GetGlocomNumber(corporateAccount.Id, customer.Address.StateId, customer.CustomerId, callId);
            }

            if (patientInfo.HealthPlanPhoneNumber == null)
            {
                patientInfo.HealthPlanPhoneNumber = corporateAccount != null ? corporateAccount.CheckoutPhoneNumber : null;
            }

            if (patientInfo.HealthPlanPhoneNumber != null)
            {
                string dialerUrl;
                var    callCenterRepProfile = _callCenterRepProfileRepository.Get(orgRoleUserId);
                if (callCenterRepProfile != null && !string.IsNullOrEmpty(callCenterRepProfile.DialerUrl))
                {
                    dialerUrl = callCenterRepProfile.DialerUrl.ToLower().Replace(CallCenterAgentUrlKeywords.CallerId.ToLower(), (patientInfo.HealthPlanPhoneNumber.AreaCode + patientInfo.HealthPlanPhoneNumber.Number))
                                .Replace(CallCenterAgentUrlKeywords.PatientId.ToLower(), patientInfo.CustomerId.ToString());
                }
                else
                {
                    dialerUrl = "Glocom://*65*" + patientInfo.HealthPlanPhoneNumber.AreaCode + patientInfo.HealthPlanPhoneNumber.Number + "*1" + CallCenterAgentUrlKeywords.PatientContact.ToLower();
                }

                if (patientInfo.CallBackPhoneNumber != null)
                {
                    patientInfo.CallBackPhoneNumberUrl = dialerUrl.Replace(CallCenterAgentUrlKeywords.PatientContact.ToLower(), (patientInfo.CallBackPhoneNumber.AreaCode + patientInfo.CallBackPhoneNumber.Number));
                }

                if (patientInfo.OfficePhoneNumber != null)
                {
                    patientInfo.OfficePhoneNumberUrl = dialerUrl.Replace(CallCenterAgentUrlKeywords.PatientContact.ToLower(), (patientInfo.OfficePhoneNumber.AreaCode + patientInfo.OfficePhoneNumber.Number));
                }

                if (patientInfo.MobilePhoneNumber != null && !string.IsNullOrEmpty(patientInfo.MobilePhoneNumber.Number))
                {
                    patientInfo.MobilePhoneNumberUrl = dialerUrl.Replace(CallCenterAgentUrlKeywords.PatientContact.ToLower(), (patientInfo.MobilePhoneNumber.AreaCode + patientInfo.MobilePhoneNumber.Number));
                }
            }

            var preAssessmentCustomerCallQueueCallAttempt = _preAssessmentCustomerCallQueueCallAttemptRepository.GetByCallId(callId);

            RegisteredEventViewModel registeredEventModel = null;
            var isCancelled = false;

            if (callQueue != null && callQueue.Category == HealthPlanCallQueueCategory.PreAssessmentCallQueue && call.EventId > 0)
            {
                var         isEawvPurchased = _testResultService.IsTestPurchasedByCustomer(eventCustomer.Id, (long)TestType.eAWV);
                Appointment appointment     = null;
                if (eventCustomer.AppointmentId.HasValue)
                {
                    appointment = _appointmentRepository.GetById(eventCustomer.AppointmentId.Value);
                }
                else
                {
                    isCancelled = true;
                }

                var theEvent = _eventService.GetById(eventCustomer.EventId);

                var hostAddress = new AddressViewModel
                {
                    StreetAddressLine1 = theEvent.StreetAddressLine1,
                    StreetAddressLine2 = theEvent.StreetAddressLine2,
                    City    = theEvent.City,
                    State   = theEvent.State,
                    ZipCode = theEvent.Zip
                };

                QuestionnaireType questionnaireType = QuestionnaireType.None;
                if (corporateAccount != null && corporateAccount.IsHealthPlan && theEvent != null)
                {
                    questionnaireType = _accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(corporateAccount.Id, theEvent.EventDate);
                }

                registeredEventModel = new RegisteredEventViewModel
                {
                    EventId             = theEvent.EventId,
                    EventDate           = theEvent.EventDate,
                    AppointmentTime     = appointment != null ? appointment.StartTime : (DateTime?)null,
                    HostName            = theEvent.OrganizationName,
                    HostAddress         = hostAddress.ToString(),
                    EventNotes          = "",
                    EventCustomerId     = eventCustomer.Id,
                    TimeZone            = theEvent.EventTimeZone,
                    IsCanceled          = isCancelled,
                    HraQuestionerAppUrl = _settings.HraQuestionerAppUrl,
                    OrganizationNameForHraQuestioner = _settings.OrganizationNameForHraQuestioner,
                    CorporateAccountTag = corporateAccount.Tag,
                    MedicareVisitId     = eventCustomer.AwvVisitId.HasValue ? eventCustomer.AwvVisitId.Value : 0,
                    Pods = theEvent.Pods.IsNullOrEmpty() ? "" : theEvent.PodNames(),
                    ShowHraQuestionnaire = questionnaireType == QuestionnaireType.HraQuestionnaire ? true : false,
                    IsEawvPurchased      = isEawvPurchased,

                    ShowChatQuestionnaire = questionnaireType == QuestionnaireType.ChatQuestionnaire ? true : false,
                    ChatQuestionerAppUrl  = _settings.ChatQuestionerAppUrl,
                    AllowNonMammoPatients = theEvent.AllowNonMammoPatients,
                    CaptureHaf            = corporateAccount != null && corporateAccount.CaptureHaf,
                };

                preAssessmentCustomerCallQueueCallAttempt.IsNotesReadAndUnderstood = true;
            }
            if (corporateAccount != null)
            {
                var organization = _organizationRepository.GetOrganizationbyId(corporateAccount.Id);
                patientInfo.HealthPlan = organization.Name;
            }

            var warmTransfer = false;

            if (customer != null && corporateAccount != null && corporateAccount.WarmTransfer)
            {
                var customerWarmTransfer = _customerWarmTransferRepository.GetByCustomerIdAndYear(customer.CustomerId, DateTime.Today.Year);
                warmTransfer = customerWarmTransfer != null && customerWarmTransfer.IsWarmTransfer.HasValue && customerWarmTransfer.IsWarmTransfer.Value;
            }

            var model = new PreAssessmentCustomerContactViewModel
            {
                PatientInfomation = patientInfo,
                // CallHistory = callHistoryModel,
                PreApprovedTests = preApprovedTests,
                //    ReadAndUnderstood = currentCall != null && currentCall.ReadAndUnderstood.HasValue && currentCall.ReadAndUnderstood.Value,
                AdditionalFields = additionalFileds,
                MemberIdLabel    = memberIdLabel,
                //  IsCallEnded = currentCall != null && currentCall.Status == (long)CallStatus.CallSkipped && currentCall.EndTime.HasValue,
                PreApprovedPackages = !preApprovedPackages.IsNullOrEmpty() ? preApprovedPackages.Select(x => x.Name).ToList() : null,
                CallId                   = callId,
                HealthPlanId             = corporateAccount != null ? corporateAccount.Id : 0,
                CallQueueCustomerAttempt = preAssessmentCustomerCallQueueCallAttempt ?? new PreAssessmentCustomerCallQueueCallAttempt {
                    IsNotesReadAndUnderstood = true
                },
                EventInformation = registeredEventModel,
                WarmTransfer     = warmTransfer,
                // RequiredTests = requiredTests,
            };
            var isHealthPlanCallQueue = call != null;
            var patientInfoEditModel  = _preAssessmentCallQueuePatientInfomationFactory.GetCallQueueCustomerEditModel(model, isHealthPlanCallQueue);

            model.PatientInfoEditModel     = patientInfoEditModel;
            model.PatientInfoEditViewModel = patientInfoEditModel;
            return(model);
        }
예제 #21
0
        public IEnumerable <EventCustomerScreeningAggregate> Parse()
        {
            var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>();
            var mediaLocation           = _mediaRepository.GetEawvHraResultMediaLocation();
            var mediaArchiveLocation    = _mediaRepository.GetEawvHraResultArchiveMediaLocation();

            try
            {
                var xmlFilePaths = Directory.GetFiles(mediaLocation.PhysicalPath, "*.xml");

                foreach (var xmlfile in xmlFilePaths)
                {
                    _logger.Info("reading xml File: " + xmlfile);
                    HraResultTags eawvHraResult = null;
                    try
                    {
                        eawvHraResult = _eawvHraSerializer.Deserialize(xmlfile);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Some error occurred while reading xml. Message: " + ex.Message);
                        _logger.Error("Stack Trace: " + ex.StackTrace);
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                    }

                    if (eawvHraResult == null)
                    {
                        _logger.Info("Some error occurred while reading xml.");
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                    }

                    if (eawvHraResult.Events.IsNullOrEmpty())
                    {
                        _logger.Info("No Event Data found for Tag: " + eawvHraResult.Name);
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                        continue;
                    }

                    var eventid = eawvHraResult.Events.First().EventId;

                    var account = _corporateAccountRepository.GetbyEventId(eventid);

                    if (account == null)
                    {
                        _logger.Info("No Corporate Account For Event Id: " + eventid);
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                        continue;
                    }

                    _logger.Info("Running for corporate Account " + account.Tag);

                    var theEvent = _eventRepository.GetById(eventid);

                    QuestionnaireType questionnaireType = QuestionnaireType.None;
                    if (account != null && account.IsHealthPlan && theEvent != null)
                    {
                        questionnaireType = _accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(account.Id, theEvent.EventDate);
                    }

                    if (questionnaireType != QuestionnaireType.HraQuestionnaire)
                    {
                        _logger.Info("HRA Questionnaire is not started");
                        continue;
                    }

                    var eawvTestNotPurchsed = new HraResultTags
                    {
                        Name   = eawvHraResult.Name,
                        Events = new List <HraResultEvent>()
                    };

                    foreach (var hraResultEvent in eawvHraResult.Events)
                    {
                        var eventCustomers = _eventCustomerRepository.GetbyEventId(hraResultEvent.EventId);

                        if (eventCustomers.IsNullOrEmpty())
                        {
                            _logger.Info("No Event Cusotmer found");
                            continue;
                        }

                        var customeridNotToParse = eventCustomers.Where(x => x.NoShow || x.LeftWithoutScreeningReasonId.HasValue).Select(x => x.CustomerId);

                        var snapshotFolderPath     = Path.Combine(mediaLocation.PhysicalPath, eawvHraResult.Name, hraResultEvent.EventId.ToString(), HraFolderSnapshot);
                        var preventionFolderPlan   = Path.Combine(mediaLocation.PhysicalPath, eawvHraResult.Name, hraResultEvent.EventId.ToString(), HraFolderPreventionPlan);
                        var resultReportFolderPath = Path.Combine(mediaLocation.PhysicalPath, eawvHraResult.Name, hraResultEvent.EventId.ToString(), HraFolderResultReport);

                        var snapShotCustomerIds       = (hraResultEvent.Snapshot != null && !hraResultEvent.Snapshot.CustomerId.IsNullOrEmpty()) ? hraResultEvent.Snapshot.CustomerId.Where(c => !customeridNotToParse.Contains(c)).Select(c => c).Distinct() : new List <long>();
                        var preventionPlanCustomerIds = (hraResultEvent.PreventionPlan != null && !hraResultEvent.PreventionPlan.CustomerId.IsNullOrEmpty()) ? hraResultEvent.PreventionPlan.CustomerId.Where(c => !customeridNotToParse.Contains(c)).Select(c => c).Distinct() : new List <long>();
                        var resultReportCustomerIds   = (hraResultEvent.ResultReport != null && !hraResultEvent.ResultReport.CustomerId.IsNullOrEmpty()) ? hraResultEvent.ResultReport.CustomerId.Where(c => !customeridNotToParse.Contains(c)).Select(c => c).Distinct() : new List <long>();

                        _logger.Info(string.Format("============================Reading Snapshot for Tag:{0} EventId {1}=================================", eawvHraResult.Name, hraResultEvent.EventId));
                        _logger.Info(string.Format("snapshot folder Path: {0}", snapshotFolderPath));

                        var customerTestNotPurchased = new List <long>();
                        if (Directory.Exists(snapshotFolderPath))
                        {
                            _logger.Info("Count: " + snapShotCustomerIds.Count());
                            foreach (var customerId in snapShotCustomerIds)
                            {
                                var snapShotFilePath = Path.Combine(snapshotFolderPath, customerId + ".pdf");

                                if (!File.Exists(snapShotFilePath))
                                {
                                    _logger.Info("SnapShot File does not exist at following location: " + snapShotFilePath);
                                    continue;
                                }

                                _logger.Info("SnapShot File exists at location: " + snapShotFilePath);

                                var isEAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(hraResultEvent.EventId, customerId, (long)TestType.eAWV);

                                if (!isEAwvTestPurchasedByCustomer)
                                {
                                    customerTestNotPurchased.Add(customerId);
                                    _logger.Info("EAWV : EAWV tests is not availed by CustomerId [" + customerId + "].\n");
                                    continue;
                                }

                                try
                                {
                                    var mediaFiles = new List <ResultMedia>();

                                    string folderToSavePdf = _mediaRepository.GetResultMediaFileLocation(customerId, hraResultEvent.EventId).PhysicalPath;
                                    _logger.Info("Get Snapshot Media");
                                    var snapShotResultMedia = GetMediaFromPdfFile(snapShotFilePath, folderToSavePdf, TestType.eAWV, AwvFileTypes.SnapShot);

                                    if (snapShotResultMedia != null)
                                    {
                                        _logger.Info("Inside SpanShot Result Media");

                                        snapShotResultMedia.ReadingSource = ReadingSource.Automatic;

                                        mediaFiles.Add(snapShotResultMedia);

                                        if (preventionPlanCustomerIds.Any(c => c == customerId))
                                        {
                                            var preventionPlanFile = Path.Combine(preventionFolderPlan,
                                                                                  customerId + ".pdf");

                                            if (File.Exists(preventionPlanFile))
                                            {
                                                var preventionPlanMedia = GetMediaFromPdfFile(preventionPlanFile,
                                                                                              folderToSavePdf, TestType.eAWV, AwvFileTypes.PreventionPlan);
                                                if (preventionFolderPlan != null)
                                                {
                                                    preventionPlanMedia.ReadingSource = ReadingSource.Automatic;
                                                    mediaFiles.Add(preventionPlanMedia);
                                                    preventionPlanCustomerIds =
                                                        preventionPlanCustomerIds.Where(c => c != customerId).ToList();
                                                }
                                            }
                                            else
                                            {
                                                _logger.Info(
                                                    "Prevention Plan File does not exist at following location: " +
                                                    preventionPlanFile);
                                            }
                                        }

                                        if (resultReportCustomerIds.Any(c => c == customerId))
                                        {
                                            var resultReportFile = Path.Combine(resultReportFolderPath,
                                                                                customerId + ".pdf");

                                            if (File.Exists(resultReportFile))
                                            {
                                                var resultExportMedia = GetMediaFromPdfFile(resultReportFile,
                                                                                            folderToSavePdf, TestType.eAWV, AwvFileTypes.ResultExport);
                                                if (resultExportMedia != null)
                                                {
                                                    resultExportMedia.ReadingSource = ReadingSource.Automatic;
                                                    mediaFiles.Add(resultExportMedia);

                                                    resultReportCustomerIds =
                                                        resultReportCustomerIds.Where(c => c != customerId).ToList();
                                                }
                                            }
                                            else
                                            {
                                                _logger.Info(
                                                    "Result Report File does not exist at following location: " +
                                                    resultReportFile);
                                            }
                                        }
                                        var testResult = new EAwvTestResult {
                                            ResultImages = mediaFiles
                                        };

                                        _logger.Info("Inside SnapShot for adding Customer Aggregate");
                                        _resultParserHelper.AddTestResulttoEventCustomerAggregate(
                                            eventCustomerAggregates, hraResultEvent.EventId, customerId, testResult);
                                        _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.eAWV, customerId,
                                                                                MedicalEquipmentTag.HRA);
                                    }
                                    else
                                    {
                                        _logger.Info("SpanShot Result Media Not Found");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("EAwv HRA: System Failure! Message: " + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
                                    _resultParserHelper.AddResultArchiveLog(ex.Message, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                }
                            }
                        }
                        else
                        {
                            _logger.Info("Snapshot Directory does not exit for EventId " + hraResultEvent.EventId);
                            _logger.Info("Snapshot Directory Path " + hraResultEvent.EventId);
                        }

                        _logger.Info(string.Format("============================Reading Prevention Plan for Tag:{0} EventId {1}=================================", eawvHraResult.Name, hraResultEvent.EventId));
                        _logger.Info(string.Format("Prevention Plan folder Path: {0}", preventionFolderPlan));


                        if (Directory.Exists(preventionFolderPlan))
                        {
                            foreach (var customerId in preventionPlanCustomerIds)
                            {
                                var preventionFilePath = Path.Combine(preventionFolderPlan, customerId + ".pdf");

                                if (!File.Exists(preventionFilePath))
                                {
                                    _logger.Info("Prevention Plan File does not exist at following location: " + preventionFilePath);
                                    continue;
                                }

                                var isEAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(hraResultEvent.EventId, customerId, (long)TestType.eAWV);

                                if (!isEAwvTestPurchasedByCustomer)
                                {
                                    customerTestNotPurchased.Add(customerId);
                                    _logger.Info("EAWV : EAWV tests is not availed by CustomerId [" + customerId + "].\n");
                                    continue;
                                }
                                try
                                {
                                    var    mediaFiles                = new List <ResultMedia>();
                                    string folderToSavePdf           = _mediaRepository.GetResultMediaFileLocation(customerId, hraResultEvent.EventId).PhysicalPath;
                                    var    preventionPlanResultMedia = GetMediaFromPdfFile(preventionFilePath, folderToSavePdf, TestType.eAWV, AwvFileTypes.PreventionPlan);

                                    if (preventionPlanResultMedia != null)
                                    {
                                        preventionPlanResultMedia.ReadingSource = ReadingSource.Automatic;
                                        mediaFiles.Add(preventionPlanResultMedia);

                                        if (resultReportCustomerIds.Any(c => c == customerId))
                                        {
                                            var resultReportFile = Path.Combine(resultReportFolderPath, customerId + ".pdf");

                                            if (File.Exists(resultReportFile))
                                            {
                                                var resultExportaMedia = GetMediaFromPdfFile(resultReportFile, folderToSavePdf, TestType.eAWV, AwvFileTypes.ResultExport);
                                                if (resultExportaMedia != null)
                                                {
                                                    resultExportaMedia.ReadingSource = ReadingSource.Automatic;
                                                    mediaFiles.Add(resultExportaMedia);

                                                    resultReportCustomerIds = resultReportCustomerIds.Where(c => c != customerId).ToList();
                                                }
                                            }
                                            else
                                            {
                                                _logger.Info("Result Report File does not exist at following location: " + resultReportFile);
                                            }
                                        }
                                        var testResult = new EAwvTestResult {
                                            ResultImages = mediaFiles
                                        };
                                        _logger.Info("Inside PreventionPLan for adding Customer Aggregate");
                                        _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, hraResultEvent.EventId, customerId, testResult);
                                        _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("EAwv HRA: System Failure! Message: " + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
                                    _resultParserHelper.AddResultArchiveLog(ex.Message, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                }
                            }
                        }
                        else
                        {
                            _logger.Info("Prevention Plan Directory does not exit for EventId " + hraResultEvent.EventId);
                            _logger.Info("Prevention Plan Directory Path " + hraResultEvent.EventId);
                        }

                        _logger.Info(string.Format("============================Reading Result Report for Tag:{0} EventId {1}=================================", eawvHraResult.Name, hraResultEvent.EventId));
                        _logger.Info(string.Format("Result Report folder Path: {0}", resultReportFolderPath));


                        if (Directory.Exists(resultReportFolderPath))
                        {
                            foreach (var customerId in resultReportCustomerIds)
                            {
                                var resultReportFilePath = Path.Combine(resultReportFolderPath, customerId + ".pdf");

                                if (!File.Exists(resultReportFilePath))
                                {
                                    _logger.Info("Result Report File does not exist at following location: " + resultReportFilePath);
                                    continue;
                                }

                                var isEAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(hraResultEvent.EventId, customerId, (long)TestType.eAWV);

                                if (!isEAwvTestPurchasedByCustomer)
                                {
                                    customerTestNotPurchased.Add(customerId);
                                    _logger.Info("EAWV : EAWV tests is not availed by CustomerId [" + customerId + "].\n");
                                    continue;
                                }
                                try
                                {
                                    var    mediaFiles        = new List <ResultMedia>();
                                    string folderToSavePdf   = _mediaRepository.GetResultMediaFileLocation(customerId, hraResultEvent.EventId).PhysicalPath;
                                    var    resultExportMedia = GetMediaFromPdfFile(resultReportFilePath, folderToSavePdf, TestType.eAWV, AwvFileTypes.ResultExport);

                                    if (resultExportMedia != null)
                                    {
                                        resultExportMedia.ReadingSource = ReadingSource.Automatic;
                                        mediaFiles.Add(resultExportMedia);

                                        var testResult = new EAwvTestResult {
                                            ResultImages = mediaFiles
                                        };
                                        _logger.Info("Inside Result Report for adding Customer Aggregate");
                                        _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, hraResultEvent.EventId, customerId, testResult);
                                        _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("EAwv HRA: System Failure! Message: " + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
                                    _resultParserHelper.AddResultArchiveLog(ex.Message, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                }
                            }
                        }
                        else
                        {
                            _logger.Info("Result Report Directory does not exit for EventId " + hraResultEvent.EventId);
                            _logger.Info("Result Report Directory Path " + hraResultEvent.EventId);
                        }

                        if (!customerTestNotPurchased.IsNullOrEmpty())
                        {
                            eawvTestNotPurchsed.Events.Add(new HraResultEvent
                            {
                                EventId        = hraResultEvent.EventId,
                                PreventionPlan = new HraResultPreventionPlan {
                                    CustomerId = customerTestNotPurchased.ToList()
                                },
                                Snapshot = new HraResultSnapshot {
                                    CustomerId = customerTestNotPurchased.ToList()
                                },
                                ResultReport = new HraResultReport()
                                {
                                    CustomerId = customerTestNotPurchased.ToList()
                                }
                            });
                        }
                    }
                    if (!eawvTestNotPurchsed.Events.IsNullOrEmpty())
                    {
                        _eawvHraSerializer.SerializeandSave(Path.Combine(mediaLocation.PhysicalPath, "customerNotPurchaseTest_" + DateTime.Now.ToFileTime() + ".xml"), eawvTestNotPurchsed);
                    }

                    try
                    {
                        var archiveFileName = Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile));
                        if (File.Exists(archiveFileName))
                        {
                            File.Delete(archiveFileName);
                        }
                        File.Move(xmlfile, archiveFileName);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Error while moving XML File in Archive folder");
                        _logger.Info(string.Format("Message: {0}", ex.Message));
                        _logger.Info(string.Format("stackTrace: {0}", ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Some Error occurred while parsing Eawv Result");
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }

            _logger.Info("EAWVParser eventCustomerAggregates count " + eventCustomerAggregates.Count);
            return(eventCustomerAggregates);
        }
예제 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RegistrationFlow.CanSaveConsentInfo = false;
            SetTitle();
            bool defaultBasePackage = false;

            FillClinicialQuestionnaireDiv.Visible = false;
            ClinicalQuestionTemplateId            = 0;
            IsClinicalQuestionaireFilled          = false;


            if (EventId > 0)
            {
                if (EventData != null)
                {
                    EventType = EventData.EventType;

                    var configurationSettingRepository = IoC.Resolve <IConfigurationSettingRepository>();
                    EnableAlaCarte = Convert.ToBoolean(configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.EnableAlaCarte));
                    if (EnableAlaCarte)
                    {
                        EnableAlaCarte = EventData.EnableAlaCarteCallCenter;
                    }
                }

                if (AccountByEventId != null)
                {
                    if (AccountByEventId.AskClinicalQuestions && AccountByEventId.ClinicalQuestionTemplateId.HasValue)
                    {
                        FillClinicialQuestionnaireDiv.Visible = true;
                        ClinicalQuestionTemplateId            = AccountByEventId.ClinicalQuestionTemplateId.Value;
                        GetRecommendationText();
                    }
                    defaultBasePackage = AccountByEventId.DefaultSelectionBasePackage;

                    // for penguin integartion
                    var settings = IoC.Resolve <ISettings>();

                    QuestionnaireType questionnaireType = QuestionnaireType.None;
                    if (AccountByEventId != null && AccountByEventId.IsHealthPlan && EventData != null)
                    {
                        var accountHraChatQuestionnaireHistoryServices = IoC.Resolve <IAccountHraChatQuestionnaireHistoryServices>();
                        questionnaireType = accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(AccountByEventId.Id, EventData.EventDate);
                    }

                    if (questionnaireType == QuestionnaireType.HraQuestionnaire)
                    {
                        var userSession = IoC.Resolve <ISessionContext>().UserSession;
                        var token       =
                            (Session.SessionID + "_" + userSession.UserId + "_" +
                             userSession.CurrentOrganizationRole.RoleId + "_" +
                             userSession.CurrentOrganizationRole.OrganizationId).Encrypt();


                        HraQuestionerAppUrlWithoutVisit = settings.HraQuestionerAppUrl + "?userToken=" +
                                                          HttpUtility.UrlEncode(token) + "&customerId=" + CustomerId + "&orgName=" +
                                                          settings.OrganizationNameForHraQuestioner + "&tag=" + AccountByEventId.Tag;
                        HraQuestionerAppUrl = HraQuestionerAppUrlWithoutVisit + "&visitId=" + (RegistrationFlow.AwvVisitId.HasValue ? RegistrationFlow.AwvVisitId.Value : 0);

                        ChatQuestionerAppUrl = string.Empty;
                    }
                    else if (questionnaireType == QuestionnaireType.ChatQuestionnaire)
                    {
                        ChatQuestionerAppUrl = settings.HraQuestionerAppUrl;
                        HraQuestionerAppUrl  = string.Empty;
                    }
                }
            }


            if (!IsPostBack)
            {
                if (RegistrationFlow != null && RegistrationFlow.IsRetest)
                {
                    RetestNo.Checked  = false;
                    RetestYes.Checked = true;
                }
                else
                {
                    RetestNo.Checked  = true;
                    RetestYes.Checked = false;
                }

                if (RegistrationFlow != null && RegistrationFlow.SingleTestOverride)
                {
                    SingleTestOverrideYes.Checked = true;
                    SingleTestOverrideNo.Checked  = false;
                }
                else
                {
                    SingleTestOverrideYes.Checked = false;
                    SingleTestOverrideNo.Checked  = true;
                }

                if (EventId != 0)
                {
                    // Hack: This is  done if the user hits back button on payment page, to get back to select package page.
                    if (SourceCodeId > 0 && !string.IsNullOrEmpty(SourceCode))
                    {
                        txtCouponCode.Text = SourceCode;
                    }
                    else if (RegistrationFlow != null)
                    {
                        txtCouponCode.Text = RegistrationFlow.CallSourceCode;
                    }

                    hfEventID.Value = EventId.ToString();

                    var eventCustomerQuestionAnswerService = IoC.Resolve <IEventCustomerQuestionAnswerService>();
                    hfQuestionAnsTestId.Value = eventCustomerQuestionAnswerService.GetQuestionAnswerTestIdString(CustomerId, EventId);
                }
                else
                {
                    const string message = "Sorry, Event detail not found. <a href=\"RegCustomerSearchEvent.aspx\">Click here</a> to search event again ";
                    DisplayErrorMessage(message);
                }

                if (CurrentProspectCustomer != null && CurrentProspectCustomer.Id > 0 && CurrentProspectCustomer.SourceCodeId != null && CurrentProspectCustomer.SourceCodeId.Value > 0)
                {
                    ISourceCodeRepository sourceCodeRepository = new SourceCodeRepository();
                    var sourceCode = sourceCodeRepository.GetSourceCodeById(CurrentProspectCustomer.SourceCodeId.Value);
                    if (sourceCode != null)
                    {
                        txtCouponCode.Text = sourceCode.CouponCode;
                    }
                }
                IEventPackageRepository packageRepository = new EventPackageRepository();
                var preApprovedPackageRepository          = IoC.Resolve <IPreApprovedPackageRepository>();

                if (AccountByEventId != null && AccountByEventId.AllowPreQualifiedTestOnly)
                {
                    long preApprovedPackageId = preApprovedPackageRepository.CheckPreApprovedPackages(CustomerId);
                    if (PackageId == 0 && preApprovedPackageId > 0 && (RegistrationFlow == null || !RegistrationFlow.SingleTestOverride) && (RegistrationFlow == null || string.IsNullOrEmpty(RegistrationFlow.DisqualifiedTest)))
                    {
                        var eventPackages = packageRepository.GetPackagesForEventByRole(EventId, (long)Roles.CallCenterRep);

                        if (!eventPackages.IsNullOrEmpty())
                        {
                            var preApprovedPackage = eventPackages.FirstOrDefault(x => x.PackageId == preApprovedPackageId);
                            if (preApprovedPackage != null)
                            {
                                PackageId = preApprovedPackage.PackageId;
                                TestIds   = preApprovedPackage.Tests.Select(t => t.TestId).ToList();
                            }
                        }
                    }
                }


                if (defaultBasePackage && PackageId == 0 && (RegistrationFlow == null || !RegistrationFlow.SingleTestOverride) && (RegistrationFlow == null || string.IsNullOrEmpty(RegistrationFlow.DisqualifiedTest)))
                {
                    var eventPackages = packageRepository.GetPackagesForEventByRole(EventId, (long)Roles.CallCenterRep)
                                        .OrderBy(p => p.Price);
                    if (!eventPackages.IsNullOrEmpty())
                    {
                        var lowestPricePackage = eventPackages.First();
                        PackageId = lowestPricePackage.PackageId;
                        TestIds   = lowestPricePackage.Tests.Select(t => t.TestId).ToList();
                    }
                }

                if (RegistrationFlow != null && !string.IsNullOrWhiteSpace(RegistrationFlow.DisqualifiedTest) && string.IsNullOrWhiteSpace(hfDisqualifedTest.Value))
                {
                    hfDisqualifedTest.Value = RegistrationFlow.DisqualifiedTest;
                }

                if (RegistrationFlow != null && !string.IsNullOrWhiteSpace(RegistrationFlow.QuestionIdAnswerTestId) && string.IsNullOrWhiteSpace(hfQuestionAnsTestId.Value))
                {
                    hfQuestionAnsTestId.Value = RegistrationFlow.QuestionIdAnswerTestId;
                }

                /*if (!DisqualifiedTestIds.IsNullOrEmpty())
                 * {
                 *  TestIds = TestIds.Where(x => !DisqualifiedTestIds.Contains(x)).ToList();
                 * }*/

                ItemCartControl.EventId   = EventId;
                ItemCartControl.RoleId    = (long)Roles.CallCenterRep;
                ItemCartControl.PackageId = PackageId;
                ItemCartControl.TestIds   = TestIds;

                if (Request.QueryString["Call"] != null && Request.QueryString["Call"] == "No")
                {
                    divCall.Style.Add(HtmlTextWriterStyle.Display, "none");
                    divCall.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");
                }
                else
                {
                    var repository = new CallCenterCallRepository();
                    hfCallStartTime.Value = repository.GetCallStarttime(CallId);
                }

                if (Request.UrlReferrer != null)
                {
                    ViewState["UrlReferer"] = Request.UrlReferrer.PathAndQuery;
                }
            }
            if (Request.Params["__EVENTTARGET"] == "NextButton" && Request.Params["__EVENTARGUMENT"] == "Click")
            {
                NextButtonClick();
            }
        }