Exemple #1
0
        private string GetJulianDate(EventCustomerResult eventCustomerResult)
        {
            var pdfGeneration = GetPdfGenerationDate(eventCustomerResult);
            var calendar      = new JulianCalendar();

            return(pdfGeneration.ToString("yy") + calendar.GetDayOfYear(pdfGeneration).ToString("000"));
        }
Exemple #2
0
        private static void SaveEventCustomerResult(long eventId, long customerId, long uploadedBy)
        {
            var eventCustomerResultRepository = new EventCustomerResultRepository();
            var eventCustomerResult           = eventCustomerResultRepository.GetByCustomerIdAndEventId(customerId, eventId);

            if (eventCustomerResult == null)
            {
                eventCustomerResult = new EventCustomerResult
                {
                    CustomerId           = customerId,
                    EventId              = eventId,
                    DataRecorderMetaData =
                        new DataRecorderMetaData(uploadedBy, DateTime.Now, null)
                };
                eventCustomerResultRepository.Save(eventCustomerResult);
            }
        }
        public CustomerEventCriticalTestDataEditModel Create(long eventId, long testId, Customer customer, CustomerCriticalData criticalData, EventCustomer eventCustomer, IEnumerable <OrderedPair <long, string> > physicians, PrimaryCarePhysician pcp,
                                                             EventCustomerResult eventCustomerResult)
        {
            var model = new CustomerEventCriticalTestDataEditModel
            {
                CustomerName             = customer.NameAsString,
                ContactNumber            = (customer.HomePhoneNumber ?? customer.OfficePhoneNumber) ?? customer.MobilePhoneNumber,
                EventId                  = eventId,
                TestId                   = testId,
                CustomerId               = customer.CustomerId,
                DateOfBirth              = customer.DateOfBirth,
                EventCustomerId          = eventCustomer.Id,
                Gender                   = customer.Gender,
                DateOfSubmission         = DateTime.Now,
                PrimaryPhysician         = physicians != null && physicians.Any() ? physicians.ElementAt(0).SecondValue : "",
                PrimaryCarePhysicianName = pcp != null?pcp.Name.ToString() : "",
                                               PrimaryCarePhysicianPhoneNumber = pcp != null ? pcp.Primary : null,
                                               ResultState = eventCustomerResult != null ? eventCustomerResult.ResultState : 1
            };

            if (criticalData != null)
            {
                model.CustomerEventScreeningTestId = criticalData.Id;
                model.DateOfSubmission             = criticalData.DateofSubmission;
                model.IsCustomerSigned             = criticalData.IsCustomerSigned;
                model.IsTechnicianSigned           = criticalData.IsTechnicianSigned;
                model.TechnicianNotes             = criticalData.TechnicianNotes;
                model.TechnicianNotesForPhysician = criticalData.TechnicianNotesforPhysician;
                model.ContactNumber          = criticalData.ContactNumber ?? model.ContactNumber;
                model.TechnicianId           = criticalData.TechnicianId;
                model.ValidatingTechnicianId = criticalData.ValidatingTechnicianId;
                model.PrimaryPhysician       = criticalData.Physician;
                model.HasPcp                  = !string.IsNullOrEmpty(model.PrimaryCarePhysicianName) ? true : criticalData.HasPcp;
                model.IsDefaultFollowup       = criticalData.IsDefaultFollowup;
                model.IsPatientReceivedImages = criticalData.IsPatientReceivedImages;
                model.Symptoms                = criticalData.Symptoms;
            }
            else
            {
                model.HasPcp            = !string.IsNullOrEmpty(model.PrimaryCarePhysicianName) ? true : false;
                model.IsDefaultFollowup = true;
            }

            return(model);
        }
Exemple #4
0
        public string GetFileName(List <CustomerInfo> resultPdfPostedCustomers, EventCustomerResult ecr, string fileName, long fileType, bool appendDateTime = true)
        {
            var fileSentCount = resultPdfPostedCustomers.Count(x => x.CustomerId == ecr.CustomerId && x.EventId == ecr.EventId && x.FileName.ToLower().Contains(fileName.ToLower()));

            if (appendDateTime)
            {
                if (fileSentCount > 0)
                {
                    fileName += string.Format("_{0}_{1}", fileSentCount, DateTime.Now.ToString("yyyyMMdd"));
                }
            }
            else
            {
                fileName += string.Format("_{0}", (fileSentCount + 1));
            }

            return(fileName);
        }
        private EventCustomerResult SaveEventCustomerResult(long eventId, long customerId, long uploadedBy, EventCustomerResult eventCustomerResult)
        {
            var eventCustomerResultRepository = new EventCustomerResultRepository();

            if (eventCustomerResult == null)
            {
                eventCustomerResult = new EventCustomerResult
                {
                    CustomerId           = customerId,
                    EventId              = eventId,
                    DataRecorderMetaData =
                        new DataRecorderMetaData(uploadedBy, DateTime.Now, null)
                };
                eventCustomerResult = eventCustomerResultRepository.Save(eventCustomerResult);
            }

            return(eventCustomerResult);
        }
Exemple #6
0
        public EventCustomerResultHistory CreateDomain(EventCustomerResult domain)
        {
            return(new EventCustomerResultHistory
            {
                EventCustomerResultId = domain.Id,
                CustomerId = domain.CustomerId,
                EventId = domain.EventId,
                IsClinicalFormGenerated = domain.IsClinicalFormGenerated,
                IsResultPdfGenerated = domain.IsResultPdfGenerated,
                IsPartial = domain.IsPartial,
                ResultState = domain.ResultState,
                ResultSummary = domain.ResultSummary,
                PathwayRecommendation = domain.PathwayRecommendation,
                RegenerationDate = domain.RegenerationDate,
                RegeneratedBy = domain.RegeneratedBy,
                IsFasting = domain.IsFasting,
                DataRecorderMetaData = domain.DataRecorderMetaData,

                IsRevertedToEvaluation = domain.IsRevertedToEvaluation,
                IsPennedBack = domain.IsPennedBack,

                SignedOffBy = domain.SignedOffBy,
                SignedOffOn = domain.SignedOffOn,

                VerifiedBy = domain.VerifiedBy,
                VerifiedOn = domain.VerifiedOn,

                CodedBy = domain.CodedBy,
                CodedOn = domain.CodedOn,

                AcesApprovedOn = domain.AcesApprovedOn,
                InvoiceDateUpdatedBy = domain.InvoiceDateUpdatedBy,
                IsIpResultGenerated = domain.IsIpResultGenerated,

                ChatPdfReviewedByPhysicianId = domain.ChatPdfReviewedByPhysicianId,
                ChatPdfReviewedByPhysicianDate = domain.ChatPdfReviewedByPhysicianDate,
                ChatPdfReviewedByOverreadPhysicianId = domain.ChatPdfReviewedByOverreadPhysicianId,
                ChatPdfReviewedByOverreadPhysicianDate = domain.ChatPdfReviewedByOverreadPhysicianDate
            });
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Initial Code just to hide left hand side panel for this page.
            var masterPage = (TecnicianManualEntry)Page.Master;

            if (masterPage != null)
            {
                masterPage.HideLeftContainer = true;
            }

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

            CaptureHaf = (account == null || account.CaptureHaf);

            CapturePcpConsent = (account != null && account.CapturePcpConsent);
            IsHealthPlanEvent = (account != null && account.IsHealthPlan);


            //var communicationRepository = IoC.Resolve<ICommunicationRepository>();
            EventCustomer eventCustomer = null;

            //var lastCommentAdded = communicationRepository.GetCommentsforPhysician(CustomerId, EventId);

            if (!IsPostBack)
            {
                var setting          = IoC.Resolve <ISettings>();
                var eventsRepository = IoC.Resolve <IEventRepository>();
                var eventData        = eventsRepository.GetById(EventId);
                eventCustomer = IoC.Resolve <IEventCustomerRepository>().Get(EventId, CustomerId);
                var eventCustomerId = eventCustomer.Id;

                var purchasedTest       = IoC.Resolve <ITestResultService>().TestPurchasedByCustomer(eventCustomerId);
                var iseawvTestPurchased = IsEawvTestPurchased = purchasedTest != null?purchasedTest.Any(x => x.Id == (long)TestType.eAWV) : false;

                IsNewResultFlow = eventData.EventDate >= setting.ResultFlowChangeDate;
                if (IsNewResultFlow)
                {
                    ClientScript.RegisterHiddenField("IsNewResultFlowInputHidden", "true");
                }
                else
                {
                    ClientScript.RegisterHiddenField("IsNewResultFlowInputHidden", "false");
                }

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

                var isShowHraQuestioner = questionnaireType == QuestionnaireType.HraQuestionnaire;

                if (eventData.EventDate < setting.ChecklistChangeDate)
                {
                    ShowCheckList = (account != null && account.PrintCheckList);
                }

                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);

                GetConductedbyData(eventData);
                FillStates();

                var currentSession = IoC.Resolve <ISessionContext>();

                ClientScript.RegisterHiddenField("hfTechnicianId", currentSession.UserSession.CurrentOrganizationRole.OrganizationRoleUserId.ToString());
                ClientScript.RegisterHiddenField("hfOrganizationId", currentSession.UserSession.CurrentOrganizationRole.OrganizationId.ToString());

                string pageHeading = "";

                var basicBiometricCutOfDate = setting.BasicBiometricCutOfDate;
                var hideBasicBiometric      = (eventData.EventDate.Date >= basicBiometricCutOfDate);
                ShowHideFastingStatus           = (eventData.EventDate.Date >= setting.FastingStatusDate);
                BasicBiometric.ShowByCutOffDate = !hideBasicBiometric;

                TestSection.SetSectionShowHide(hideBasicBiometric);

                if (currentSession != null && currentSession.UserSession != null && currentSession.UserSession.CurrentOrganizationRole != null)
                {
                    RoleId = currentSession.UserSession.CurrentOrganizationRole.GetSystemRoleId;
                }


                if (Mode == EditResultMode.ResultCorrection)
                {
                    var result = new CommunicationRepository().GetPhysicianandCommentsforFranchisee(CustomerId, EventId);
                    if (!string.IsNullOrEmpty(result.SecondValue))
                    {
                        PhysicianCommentsDiv.Visible = true;
                        PhysicianCommentsMessageBox.ShowErrorMessage("<b><u>Physician Comments:</u> </b>" + result.SecondValue);
                    }

                    updateWithCorrectionDivTop.Visible = true;
                    saveDivTop.Visible    = false;
                    approveDivtop.Visible = false;

                    updateWithCorrectionsDivbottom.Visible = true;
                    saveDivbottom.Visible    = false;
                    approveDivbottom.Visible = false;

                    var physicianService = IoC.Resolve <IPhysicianAssignmentService>();
                    var physicianIds     = physicianService.GetPhysicianIdsAssignedtoaCustomer(EventId, CustomerId);
                    if (physicianIds != null && result.FirstValue > 0 && physicianIds.Count() == 2 && physicianIds.ElementAt(1) == result.FirstValue)
                    {
                        SendToOvereadPhysician = true;
                    }

                    ClientScript.RegisterHiddenField("ResultStatusInputHidden", "4");

                    pageHeading = "Results Update/Correction";
                }


                if (Mode == EditResultMode.ResultPreAudit) // && isTechTeamConfigured == true)
                {
                    ClientScript.RegisterHiddenField("ResultStatusInputHidden", "4");
                    pageHeading = "Results Pre Audit";

                    saveDivTop.Visible    = false;
                    saveDivbottom.Visible = false;

                    if (TestSection.ContainsReviewableTests && !IsNewResultFlow)
                    {
                        skipevaluationdivbottom.Visible = true;
                    }

                    var customerHealthInfo = IoC.Resolve <IHealthAssessmentRepository>().Get(CustomerId, EventId);
                    if (!CaptureHaf || (customerHealthInfo != null && customerHealthInfo.Any()))
                    {
                        ClientScript.RegisterStartupScript(Page.GetType(), "js_setmedicalhistory", "setMedicalHistory();", true);
                    }

                    var defaultPhysician = IoC.Resolve <IPhysicianRepository>().GetDefaultPhysicianforEvent(EventId);
                    ClientScript.RegisterHiddenField("DefaultPhysician", defaultPhysician.ToString());

                    //var eventCustomerId = IoC.Resolve<IEventCustomerRepository>().Get(EventId, CustomerId).Id;
                    var isCustomerSkipped = IoC.Resolve <IPhysicianEvaluationRepository>().IsMarkedReviewSkip(eventCustomerId);
                    if (isCustomerSkipped)
                    {
                        ClientScript.RegisterStartupScript(Page.GetType(), "js_markcustomerskipped", "$('#skipevaluationcheckbox').attr('checked', true);", true);
                    }
                }
                else if (Mode == EditResultMode.ResultEntry)
                {
                    if (IsNewResultFlow)
                    {
                        ClientScript.RegisterHiddenField("ResultStatusInputHidden", "2");
                    }
                    else
                    {
                        ClientScript.RegisterHiddenField("ResultStatusInputHidden", "3");
                    }

                    pageHeading = "Results Edit/Entry";

                    approveDivtop.Visible    = false;
                    approveDivbottom.Visible = false;
                }

                HeadingSpan.InnerHtml = pageHeading;

                if (Request.UrlReferrer.AbsolutePath.ToLower().IndexOf("auditresultentry.aspx") < 0)
                {
                    Session["ReferredUrlFirstTimeOpen"] = Request.UrlReferrer;
                }

                CreateIFJSArrays();
                CreateJsArrayforIfuCs();

                //var eventCustomerRepository = IoC.Resolve<IEventCustomerRepository>();
                var goBackToResultEnteryPage = false;

                EventCustomerResult eventCustomerResult = IoC.Resolve <IEventCustomerResultRepository>().GetByCustomerIdAndEventId(CustomerId, EventId);;

                if ((Mode == EditResultMode.ResultEntry))
                {
                    if (IsCustomerNoShowOrLeftWithoutScreening(eventCustomer))
                    {
                        ClientScript.RegisterStartupScript(Page.GetType(), "js_NextCustomer", "customerMarkNoShow();", true);
                        goBackToResultEnteryPage = true;
                    }
                    else
                    {
                        var nextCustomerId = new TestResultRepository().GetNextCustomerEntryandAudit(EventId, CustomerId, IsNewResultFlow);
                        ClientScript.RegisterStartupScript(Page.GetType(), "js_NextCustomer", "setnextCustomerId(" + nextCustomerId + ");", true);
                    }
                }
                else
                {
                    var isChartSignedOff  = true;
                    var isQvTestPurchased = purchasedTest != null?purchasedTest.Any(x => x.Id == (long)TestType.Qv) : false;

                    var isHraQuestionnaire = questionnaireType == QuestionnaireType.HraQuestionnaire;

                    if (questionnaireType == QuestionnaireType.ChatQuestionnaire)
                    {
                        isChartSignedOff = isQvTestPurchased || (eventCustomerResult != null && eventCustomerResult.SignedOffBy.HasValue);
                    }
                    else
                    {
                        var isEawvTestNotPerformed = IoC.Resolve <ITestNotPerformedRepository>().IsTestNotPerformed(eventCustomer.Id, (long)TestType.eAWV);
                        isChartSignedOff = (eventCustomerResult != null && eventCustomerResult.SignedOffBy.HasValue) || !isShowHraQuestioner || !iseawvTestPurchased || isEawvTestNotPerformed;
                    }
                    IsChartSignedOff = (eventCustomerResult != null && eventCustomerResult.SignedOffBy.HasValue);
                    if (!IsNewResultFlow || isChartSignedOff)
                    {
                        if (IsCustomerNoShowOrLeftWithoutScreening(eventCustomer))
                        {
                            ClientScript.RegisterStartupScript(Page.GetType(), "js_NextCustomer", "customerMarkNoShow();", true);
                            goBackToResultEnteryPage = true;
                        }
                        else
                        {
                            long nextCustomerId = 0;
                            if (IsNewResultFlow && account != null && (questionnaireType != QuestionnaireType.None))
                            {
                                nextCustomerId = new TestResultRepository().GetNextCustomerForPreAudit(EventId, CustomerId, isHraQuestionnaire);
                            }
                            else
                            {
                                nextCustomerId = new TestResultRepository().GetNextCustomerEntryandAudit(EventId, CustomerId, IsNewResultFlow);
                            }

                            ClientScript.RegisterStartupScript(Page.GetType(), "js_NextCustomer", "setnextCustomerId(" + nextCustomerId + ");", true);
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(Page.GetType(), "js_NextCustomer", "customerChartIsUnsigned();", true);
                    }

                    //if (eventCustomerResult != null && IsNewResultFlow)
                    //{
                    //    var notes = communicationRepository.GetNotesForReversal(eventCustomerResult.Id);
                    //    if (!string.IsNullOrWhiteSpace(notes))
                    //    {
                    //        revertBackNotes.Visible = true;
                    //        ReasonToRevert.InnerText = notes;
                    //    }
                    //}
                }

                if (!goBackToResultEnteryPage)
                {
                    if (eventCustomerResult != null)
                    {
                        //LogAudit(ModelType.View, eventCustomerResult);
                        var priorityInQueue =
                            IoC.Resolve <IPriorityInQueueRepository>().GetByEventCustomerResultId(eventCustomerResult.Id);
                        if (priorityInQueue != null && priorityInQueue.InQueuePriority > 0)
                        {
                            if (!CurrentOrgUser.CheckRole((long)Roles.Technician))
                            {
                                PriorityInQueueCheckbox.Checked = true;
                            }

                            if (priorityInQueue.NoteId == null)
                            {
                                return;
                            }
                            var noteText = IoC.Resolve <INotesRepository>().Get(priorityInQueue.NoteId.Value);
                            if (noteText != null && !string.IsNullOrEmpty(noteText.Text))
                            {
                                PriorityInQueueText.InnerText = noteText.Text;
                                PriorityInQueueReasonDisplayDiv.Style.Add(HtmlTextWriterStyle.Display, "block");
                            }
                            else if (!CurrentOrgUser.CheckRole((long)Roles.Technician))
                            {
                                PriorityInQueueReasonDisplayDiv.Style.Add(HtmlTextWriterStyle.Display, "block");
                            }
                        }
                        else
                        {
                            PriorityInQueueCheckbox.Checked = false;
                            PriorityInQueueReasonDisplayDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
                        }
                    }
                    else
                    {
                        PriorityInQueueCheckbox.Checked = false;
                        PriorityInQueueReasonDisplayDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }
            }
        }
        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);
        }
        public ClinicalDocument Create(EventCustomerResult eventCustomerResult, Customer customer, PrimaryCarePhysician pcp, Event theEventData)
        {
            var patientIds = GetClinicalRoots(null, customer.CustomerId.ToString(), ClinicalDocumentRoots.PatinetMedicalRecordNumber);

            if (!string.IsNullOrWhiteSpace(customer.Hicn))
            {
                patientIds = GetClinicalRoots(patientIds, customer.Hicn.Trim(), ClinicalDocumentRoots.PatientAdditionalIds);
            }

            if (!string.IsNullOrWhiteSpace(customer.InsuranceId))
            {
                patientIds = GetClinicalRoots(patientIds, customer.InsuranceId.Trim(), ClinicalDocumentRoots.PatientAdditionalIds);
            }
            var telecom = new List <ClinicalTeleCom>();

            if (customer.HomePhoneNumber != null && !customer.HomePhoneNumber.IsEmpty())
            {
                telecom.Add(new ClinicalTeleCom(TelecomType.PrimaryHome, customer.HomePhoneNumber.GlobalPhoneNumberFormat));
            }

            if (customer.MobilePhoneNumber != null && !customer.MobilePhoneNumber.IsEmpty())
            {
                telecom.Add(new ClinicalTeleCom(TelecomType.MobileContact, customer.MobilePhoneNumber.GlobalPhoneNumberFormat));
            }


            if (customer.OfficePhoneNumber != null && !customer.OfficePhoneNumber.IsEmpty())
            {
                telecom.Add(new ClinicalTeleCom(TelecomType.Workplace, customer.OfficePhoneNumber.GlobalPhoneNumberFormat));
            }

            var orderId    = _orderRepository.GetOrderIdByEventIdCustomerId(theEventData.Id, customer.CustomerId);
            var package    = _eventPackageRepository.GetPackageForOrder(orderId);
            var eventTests = _eventTestRepository.GetTestsForOrder(orderId);

            if (package != null)
            {
                eventTests = eventTests.Concat(package.Tests.ToArray());
            }

            var tests = eventTests.Select(et => et.Test).ToArray();


            var structureBodySection = new List <StructuredBodyComponent>()
            {
                new StructuredBodyComponent()
                {
                    Section = _ccdVitalSectionFactory.GetVitalSection(customer, theEventData, tests, _settings)
                },
                GetResultSection(customer, theEventData, tests),
            };

            return(new ClinicalDocument
            {
                Realm = new RealmCode("US"),
                Title = "Summary of Patient Chart",
                EffectiveTime = new DocumentGenerationtime(DateTime.Now),
                // LanguageCode = new LanguageCode("en-US"),
                RecordTarget = new RecordTarget
                {
                    PatientRole = new PatientRole
                    {
                        PatientIds = patientIds,
                        PatinetAddress = GetClinicalAddress(customer.BillingAddress, AddressType.HomeAddress),
                        Patient = GetPatient(customer),
                        TeleCom = telecom.IsNullOrEmpty() ? null : telecom.ToArray(),
                        ProviderOrganization = GetProviderOrganization()
                    }
                },
                DocumentationOfCcd = GetDocumentationOf(pcp, theEventData),
                CdaBodyComponent = new CdaBodyComponent()
                {
                    StructuredBody = new StructuredBody {
                        VitalSigns = structureBodySection.ToArray()
                    }
                }
            });
        }
        private void SetReusltPdfNameing(EventCustomerResult ecr, CorporateAccount corporateAccount, string destinationFolderPdfPath, string sourcePath, ResultPdfPostedXml resultPosted, List <long> newCustomersWithNoMrn)
        {
            var eventDirectoryPdf   = destinationFolderPdfPath + "\\" + ecr.EventId;
            var destinationFilename = ecr.CustomerId.ToString();
            var customer            = _customerRepository.GetCustomer(ecr.CustomerId);
            var eventData           = _eventRepository.GetById(ecr.EventId);

            if (_optumAccountIds.Contains(corporateAccount.Id))
            {
                eventDirectoryPdf = destinationFolderPdfPath;
            }

            if (corporateAccount.Id == _settings.OptumNvAccountId || corporateAccount.Id == _settings.OptumNvMedicareAccountId)
            {
                if (!string.IsNullOrEmpty(customer.Mrn))
                {
                    destinationFilename = customer.Mrn + "_" + eventData.EventDate.ToString("yyyyMMdd");
                    var customerPcp = _primaryCarePhysicianRepository.Get(ecr.CustomerId);
                    destinationFilename += (customerPcp != null ? "_" + customerPcp.Name.LastName : "");
                }
                else
                {
                    newCustomersWithNoMrn.Add(ecr.CustomerId);
                    _logger.Info("MRN not available for Customer ID : " + ecr.CustomerId);
                    return;
                }
            }

            if (_monarchAccountIds.Contains(corporateAccount.Id))
            {
                destinationFilename = ResultFileName(customer);
            }

            if (corporateAccount.MarkPennedBack && ecr.IsPennedBack)
            {
                destinationFilename += "_" + corporateAccount.PennedBackText;
            }

            if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.PDF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both)
            {
                var fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.PDF);

                var resultPdfFile = eventDirectoryPdf + "/" + fileName + ".pdf";
                _resultPdfDownloadHelper.ExportResultInPdfFormat(fileName + ".pdf", sourcePath, eventDirectoryPdf);

                _logger.Info("source Url: " + sourcePath);
                _logger.Info("destination Url: " + eventDirectoryPdf + "/" + fileName + ".pdf");

                if (File.Exists(resultPdfFile))
                {
                    var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultPdfFile);

                    resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.PDF, customer, ecr.Id));
                }
                else
                {
                    _logger.Info("File Not Found : " + resultPdfFile);
                }
            }

            if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.TIF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both)
            {
                var fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.TIF);

                var resultTifFile = eventDirectoryPdf + "/" + fileName + ".tif";
                _resultPdfDownloadHelper.ExportResultInTiffFormat(fileName + ".tif", sourcePath, eventDirectoryPdf);

                _logger.Info("source Url: " + sourcePath);
                _logger.Info("destination Url: " + eventDirectoryPdf + "/" + fileName + ".tif");

                if (File.Exists(resultTifFile))
                {
                    var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultTifFile);
                    resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.TIF, customer, ecr.Id));
                }
                else
                {
                    _logger.Info(string.Format("File {0} not Exist for pgp Encryption ", resultTifFile));
                }
            }
        }
Exemple #11
0
        private long GetIdentificationNumber(EventCustomerResult eventCustomerResult)
        {
            var resultPosted = _customerResultPosedService.GetCusterResultPosted(eventCustomerResult.CustomerId);

            return(resultPosted.ResultPostId);
        }
Exemple #12
0
 private DateTime GetPdfGenerationDate(EventCustomerResult ecr)
 {
     return(ecr.RegenerationDate.HasValue ? ecr.RegenerationDate.Value : ecr.DataRecorderMetaData.DateModified.Value);
 }
        private string GetResultPdfFileName(ChaseOutbound chaseOutbound, Customer customer, EventCustomerResult ecr, CorporateAccount corporateAccount)
        {
            string fileName;

            if (!string.IsNullOrEmpty(chaseOutbound.ClientId))
            {
                fileName = string.Format("{0}_{1}.pdf", FileNamePrefix, chaseOutbound.ClientId);
            }

            else if (!string.IsNullOrEmpty(customer.InsuranceId))
            {
                fileName = string.Format("{0}_{1}.pdf", FileNamePrefix, customer.InsuranceId);
            }

            else
            {
                fileName = string.Format("{0}_NoMemberId_{1}.pdf", FileNamePrefix, customer.CustomerId);
            }

            if (corporateAccount.MarkPennedBack && ecr.IsPennedBack)
            {
                fileName += "_" + corporateAccount.PennedBackText;
            }

            return(fileName);
        }
Exemple #14
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");
            }
        }