Ejemplo n.º 1
0
        public override bool IsRequired(Business.Test.AccessionOrder accessionOrder)
        {
            bool result = false;

            YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest panelSetThinPrep = new YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(panelSetThinPrep.PanelSetId) == true)
            {
                YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology panelSetOrderCytology = (YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetThinPrep.PanelSetId);
                if (panelSetOrderCytology.Final == true)
                {
                    if (YellowstonePathology.Business.Cytology.Model.CytologyResultCode.IsDiagnosisAscusAgusLsilHsil(panelSetOrderCytology.ResultCode) == true)
                    {
                        if (accessionOrder.PBirthdate < DateTime.Today.AddYears(-20))
                        {
                            YellowstonePathology.Business.Domain.PatientHistory patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(accessionOrder.PatientId);
                            Nullable <DateTime> dateOfLastHPV = patientHistory.GetDateOfPreviousHpv(accessionOrder.AccessionDate.Value);

                            if (dateOfLastHPV.HasValue == true)
                            {
                                if (dateOfLastHPV < DateTime.Today.AddDays(-330))
                                {
                                    result = true;
                                }
                            }
                            else
                            {
                                result = true;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public override bool IsRequired(Business.Test.AccessionOrder accessionOrder)
        {
            bool result = false;

            if (accessionOrder.PanelSetOrderCollection.Exists(15) == true)
            {
                YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology panelSetOrderCytology = (YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(15);
                if (panelSetOrderCytology.Final == true)
                {
                    if (YellowstonePathology.Business.Cytology.Model.CytologyResultCode.IsDiagnosisAscusLsil(panelSetOrderCytology.ResultCode) == true)
                    {
                        result = true;
                        YellowstonePathology.Business.Domain.PatientHistory patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(accessionOrder.PatientId);
                        Nullable <DateTime> dateOfLastHPV = patientHistory.GetDateOfPreviousHpv(accessionOrder.AccessionDate.Value);

                        if (dateOfLastHPV.HasValue == true)
                        {
                            if (dateOfLastHPV >= DateTime.Today.AddDays(-330))
                            {
                                List <string> priorResults = patientHistory.GetPriorHPVResult(accessionOrder.MasterAccessionNo, DateTime.Today.AddDays(-330));
                                foreach (string hpvResult in priorResults)
                                {
                                    if (hpvResult == YellowstonePathology.Business.Test.HPV.HPVResult.OveralResultCodePositive)
                                    {
                                        result = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        private void SetPriorResults()
        {
            YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest panelSetThinPrepPap = new YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest();
            YellowstonePathology.Business.Test.HPV.HPVTest                 panelSetHPV         = new YellowstonePathology.Business.Test.HPV.HPVTest();
            YellowstonePathology.Business.Test.HPV1618.HPV1618Test         panelSetHPV1618     = new YellowstonePathology.Business.Test.HPV1618.HPV1618Test();
            YellowstonePathology.Business.Test.NGCT.NGCTTest               panelSetNGCT        = new YellowstonePathology.Business.Test.NGCT.NGCTTest();
            YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest panelSetTrichomonas = new YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest();

            DateTime cutoffDate = this.m_AccessionOrder.AccessionDate.Value.AddYears(-5);

            XmlNode mainTableNode  = this.m_ReportXml.SelectSingleNode("descendant::w:tbl[w:tr/w:tc/w:p/w:r/w:t='prior_report_no']", this.m_NameSpaceManager);
            XmlNode rowHistoryNode = mainTableNode.SelectSingleNode("descendant::w:tr[w:tc/w:p/w:r/w:t='prior_report_no']", this.m_NameSpaceManager);
            XmlNode insertAfterRow = rowHistoryNode;

            YellowstonePathology.Business.Domain.PatientHistory patientHistory = new YellowstonePathology.Business.Domain.PatientHistory();
            patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(this.m_AccessionOrder.PatientId);
            YellowstonePathology.Business.Domain.PatientHistory priorPapRelatedHistory = patientHistory.GetPriorPapRelatedHistory(this.m_AccessionOrder.MasterAccessionNo, cutoffDate);

            foreach (YellowstonePathology.Business.Domain.PatientHistoryResult patientHistoryResult in priorPapRelatedHistory)
            {
                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.GetAccessionOrderByMasterAccessionNo(patientHistoryResult.MasterAccessionNo);
                foreach (YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder in accessionOrder.PanelSetOrderCollection)
                {
                    string   reportNo  = null;
                    DateTime?finalDate = null;
                    string   result    = null;

                    if (panelSetOrder.PanelSetId == panelSetThinPrepPap.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetHPV.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetHPV1618.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetNGCT.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetTrichomonas.PanelSetId)
                    {
                        reportNo  = panelSetOrder.ReportNo;
                        finalDate = panelSetOrder.FinalDate;
                        result    = panelSetOrder.GetResultWithTestName();
                        XmlNode rowHistoryNodeClone = rowHistoryNode.Clone();
                        string  testFinaldate       = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(finalDate);

                        rowHistoryNodeClone.SelectSingleNode("descendant::w:r[w:t='prior_final_date']/w:t", this.m_NameSpaceManager).InnerText = testFinaldate;
                        rowHistoryNodeClone.SelectSingleNode("descendant::w:r[w:t='prior_report_no']/w:t", this.m_NameSpaceManager).InnerText  = reportNo;
                        rowHistoryNodeClone.SelectSingleNode("descendant::w:r[w:t='prior_result']/w:t", this.m_NameSpaceManager).InnerText     = result;
                        mainTableNode.InsertAfter(rowHistoryNodeClone, insertAfterRow);
                        insertAfterRow = rowHistoryNodeClone;
                    }
                }
            }

            if (patientHistory.Count > 0)
            {
                this.DeleteRow("prior_report_no");
            }
            else
            {
                rowHistoryNode.SelectSingleNode("descendant::w:r[w:t='prior_final_date']/w:t", this.m_NameSpaceManager).InnerText = "No prior tests performed";
                rowHistoryNode.SelectSingleNode("descendant::w:r[w:t='prior_report_no']/w:t", this.m_NameSpaceManager).InnerText  = string.Empty;
                rowHistoryNode.SelectSingleNode("descendant::w:r[w:t='prior_result']/w:t", this.m_NameSpaceManager).InnerText     = string.Empty;
            }
        }
Ejemplo n.º 4
0
 public void DataLoaded()
 {
     if (string.IsNullOrEmpty(this.m_AccessionOrder.PatientId) == false)
     {
         this.m_PatientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(this.m_AccessionOrder.PatientId);
     }
     this.NotifyPropertyChanged("");
     this.OnAccessionChanged(new EventArgs());
 }
        public WomensHealthProfilePage(YellowstonePathology.Business.Test.WomensHealthProfile.WomensHealthProfileTestOrder womensHealthProfileTestOrder,
                                       YellowstonePathology.Business.Test.AccessionOrder accessionOrder,
                                       YellowstonePathology.Business.ClientOrder.Model.ClientOrder clientOrder,
                                       System.Windows.Visibility backButtonVisibility) : base(womensHealthProfileTestOrder, accessionOrder)
        {
            this.m_AccessionOrder = accessionOrder;

            this.m_HPVReflexOrderCollection       = YellowstonePathology.Business.Client.Model.ReflexOrderCollection.GetHPVRequisitionReflexOrders();
            this.m_HPVStandingOrderCollection     = YellowstonePathology.Business.Client.Model.StandingOrderCollection.GetHPVStandingOrders();
            this.m_HPV1618ReflexOrderCollection   = YellowstonePathology.Business.Client.Model.ReflexOrderCollection.GetHPV1618ReflexOrders();
            this.m_HPV1618StandingOrderCollection = YellowstonePathology.Business.Client.Model.StandingOrderCollection.GetHPV1618StandingOrders();

            this.m_ClientOrder = clientOrder;
            this.m_WomensHealthProfileTestOrder = womensHealthProfileTestOrder;
            this.m_SystemIdentity       = Business.User.SystemIdentity.Instance;
            this.m_BackButtonVisibility = backButtonVisibility;

            this.m_Physician = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetPhysicianByPhysicianId(this.m_AccessionOrder.PhysicianId);

            this.m_PanelSetOrderCytology = (YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(15);

            this.m_AuditCollection = new Business.Audit.Model.IsWHPAllDoneAuditCollection(this.m_AccessionOrder);
            this.m_AuditCollection.Run();

            if (string.IsNullOrEmpty(accessionOrder.PatientId) == false)
            {
                YellowstonePathology.Business.Domain.PatientHistory patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(accessionOrder.PatientId);
                this.m_DateOfLastHPV = patientHistory.GetDateOfPreviousHpv(this.m_AccessionOrder.AccessionDate.Value);
            }

            YellowstonePathology.Business.Client.Model.StandingOrder standingOrder = YellowstonePathology.Business.Client.Model.StandingOrderCollection.GetByStandingOrderCode(this.m_WomensHealthProfileTestOrder.HPVStandingOrderCode);
            this.m_HPVStandingOrderDescription = standingOrder.ToString();

            InitializeComponent();

            this.DataContext = this;

            this.m_ParentWindow = Window.GetWindow(this);

            this.m_ControlsNotDisabledOnFinal.Add(this.ButtonClose);
            this.m_ControlsNotDisabledOnFinal.Add(this.ButtonBack);
            this.m_ControlsNotDisabledOnFinal.Add(this.TextBlockShowDocument);
            this.m_ControlsNotDisabledOnFinal.Add(this.TextBlockUnfinalize);
            this.m_ControlsNotDisabledOnFinal.Add(this.TextBlockNext);

            this.m_ControlsNotEnabledOnUnFinal.Add(this.CheckBoxAccepted);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.CheckBoxFinal);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.ComboBoxStandingOrderDescription);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBlockLastHPVDate);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBlockPatientAge);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBlockScreeningImpression);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBlockStandingOrderDescription);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBoxAcceptedBy);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBoxAcceptedTime);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBoxFinalTime);
            this.m_ControlsNotEnabledOnUnFinal.Add(this.TextBoxSignaure);
        }
Ejemplo n.º 6
0
        public override bool SatisfiesCondition(YellowstonePathology.Business.Test.AccessionOrder accessionOrder)
        {
            bool result = false;

            YellowstonePathology.Business.Domain.PatientHistory patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(accessionOrder.PatientId);
            Nullable <DateTime> dateOfLastHPV = patientHistory.GetDateOfPreviousHpv(accessionOrder.AccessionDate.Value);

            if (dateOfLastHPV.HasValue == true)
            {
                if (dateOfLastHPV < accessionOrder.AccessionDate.Value.AddDays(-330))
                {
                    result = true;
                }
            }
            else
            {
                result = true;
            }
            return(result);
        }
        public WomensHealthProfilePage(YellowstonePathology.Business.Test.AccessionOrder accessionOrder,
                                       YellowstonePathology.Business.ClientOrder.Model.ClientOrder clientOrder,
                                       System.Windows.Visibility backButtonVisibility)
        {
            this.m_AccessionOrder = accessionOrder;

            this.m_HPVReflexOrderCollection       = YellowstonePathology.Business.Client.Model.ReflexOrderCollection.GetHPVRequisitionReflexOrders();
            this.m_HPVStandingOrderCollection     = YellowstonePathology.Business.Client.Model.StandingOrderCollection.GetHPVStandingOrders();
            this.m_HPV1618ReflexOrderCollection   = YellowstonePathology.Business.Client.Model.ReflexOrderCollection.GetHPV1618ReflexOrders();
            this.m_HPV1618StandingOrderCollection = YellowstonePathology.Business.Client.Model.StandingOrderCollection.GetHPV1618StandingOrders();

            this.m_ClientOrder = clientOrder;
            this.m_WomensHealthProfileTestOrder = (YellowstonePathology.Business.Test.WomensHealthProfile.WomensHealthProfileTestOrder) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(116);
            this.m_SystemIdentity       = Business.User.SystemIdentity.Instance;
            this.m_BackButtonVisibility = backButtonVisibility;

            this.m_Physician = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetPhysicianByPhysicianId(this.m_AccessionOrder.PhysicianId);

            this.m_PanelSetOrderCytology = (YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(15);

            this.m_AuditCollection = new Business.Audit.Model.IsWHPAllDoneAuditCollection(this.m_AccessionOrder);
            this.m_AuditCollection.Run();

            if (string.IsNullOrEmpty(accessionOrder.PatientId) == false)
            {
                YellowstonePathology.Business.Domain.PatientHistory patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(accessionOrder.PatientId);
                this.m_DateOfLastHPV = patientHistory.GetDateOfPreviousHpv(this.m_AccessionOrder.AccessionDate.Value);
            }

            YellowstonePathology.Business.Client.Model.StandingOrder standingOrder = YellowstonePathology.Business.Client.Model.StandingOrderCollection.GetByStandingOrderCode(this.m_WomensHealthProfileTestOrder.HPVStandingOrderCode);
            this.m_HPVStandingOrderDescription = standingOrder.ToString();

            InitializeComponent();

            this.DataContext = this;

            this.m_ParentWindow = Window.GetWindow(this);
        }
        public override void ToXml(XElement document)
        {
            WomensHealthProfileTestOrder womensHealthProfileTestOrder = (WomensHealthProfileTestOrder)this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_ReportNo);
            WomensHealthProfileResult    womensHealthProfileResult    = new WomensHealthProfileResult(this.m_AccessionOrder);

            ThinPrepPap.ThinPrepPapTest thinPrepPapTest = new ThinPrepPap.ThinPrepPapTest();
            bool hasPap = this.m_AccessionOrder.PanelSetOrderCollection.Exists(thinPrepPapTest.PanelSetId);

            this.AddCompanyHeader(document);
            this.AddBlankNteElement(document);

            this.AddNextNteElement("Women's Health Profile", document);
            this.AddNextNteElement("Report #: " + womensHealthProfileTestOrder.ReportNo, document);
            this.AddBlankNteElement(document);

            if (hasPap == true)
            {
                this.AddNextNteElement("PAP TEST RESULT: ", document);

                YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology panelSetOrderCytology = (YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(15);
                if (string.IsNullOrEmpty(panelSetOrderCytology.ScreeningImpression) == false)
                {
                    this.AddNextNteElement("Epithelial Cell Description: ", document);
                    this.AddNextNteElement(panelSetOrderCytology.ScreeningImpression, document);
                    this.AddBlankNteElement(document);
                }

                this.AddNextNteElement("Specimen Adequacy:", document);
                this.AddNextNteElement(panelSetOrderCytology.SpecimenAdequacy, document);
                this.AddBlankNteElement(document);

                if (string.IsNullOrEmpty(panelSetOrderCytology.OtherConditions) == false)
                {
                    this.AddNextNteElement("Other Conditions:", document);
                    this.AddNextNteElement(panelSetOrderCytology.OtherConditions, document);
                    this.AddBlankNteElement(document);
                }

                if (string.IsNullOrEmpty(panelSetOrderCytology.ReportComment) == false)
                {
                    this.AddNextNteElement("Comment:", document);
                    this.AddNextNteElement(panelSetOrderCytology.ReportComment, document);
                    this.AddBlankNteElement(document);
                }

                YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology screeningPanelOrder = null;
                YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology reviewPanelOrder    = null;

                foreach (YellowstonePathology.Business.Interface.IPanelOrder panelOrder in panelSetOrderCytology.PanelOrders)
                {
                    Type objectType = panelOrder.GetType();
                    if (typeof(YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology).IsAssignableFrom(objectType) == true)
                    {
                        YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology cytologyPanelOrder = (YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology)panelOrder;
                        if (cytologyPanelOrder.PanelId == 38)
                        {
                            if (cytologyPanelOrder.ScreeningType == "Primary Screening")
                            {
                                screeningPanelOrder = cytologyPanelOrder;
                            }
                            else if (cytologyPanelOrder.ScreeningType == "Pathologist Review")
                            {
                                reviewPanelOrder = cytologyPanelOrder;
                            }
                            else if (cytologyPanelOrder.ScreeningType == "Cytotech Review")
                            {
                                if (reviewPanelOrder == null || reviewPanelOrder.ScreeningType != "Pathologist Review")
                                {
                                    reviewPanelOrder = cytologyPanelOrder;
                                }
                            }
                        }
                    }
                }

                YellowstonePathology.Business.User.SystemUser systemUser = YellowstonePathology.Business.User.SystemUserCollectionInstance.Instance.SystemUserCollection.GetSystemUserById(screeningPanelOrder.ScreenedById);
                if (string.IsNullOrEmpty(systemUser.Signature) == false)
                {
                    this.AddNextNteElement("Screened By: " + systemUser.Signature, document);
                }

                string cytoTechFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateAndTimeStringFromNullable(screeningPanelOrder.AcceptedTime);
                this.AddNextNteElement("*** E-Signed " + cytoTechFinal + " ***", document);
                this.AddBlankNteElement(document);

                if (reviewPanelOrder != null)
                {
                    string reviewedBy      = YellowstonePathology.Business.User.SystemUserCollectionInstance.Instance.SystemUserCollection.GetSystemUserById(reviewPanelOrder.ScreenedById).Signature;
                    string reviewedByFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(reviewPanelOrder.AcceptedDate);

                    if (reviewedBy.IndexOf("MD") >= 0)
                    {
                        this.AddNextNteElement("Interpreted By: " + reviewedBy + " " + reviewedByFinal, document);
                    }
                    else
                    {
                        this.AddNextNteElement("Reviewed By: " + reviewedBy + " " + reviewedByFinal, document);
                    }
                    this.AddBlankNteElement(document);
                }
            }

            this.AddAmendments(document, womensHealthProfileTestOrder, this.m_AccessionOrder);

            this.AddNextNteElement("CURRENT MOLECULAR TEST SUMMARY", document);

            YellowstonePathology.Business.Test.HPV.HPVTest                 panelSetHPV         = new YellowstonePathology.Business.Test.HPV.HPVTest();
            YellowstonePathology.Business.Test.HPV1618.HPV1618Test         panelSetHPV1618     = new YellowstonePathology.Business.Test.HPV1618.HPV1618Test();
            YellowstonePathology.Business.Test.NGCT.NGCTTest               panelSetNGCT        = new YellowstonePathology.Business.Test.NGCT.NGCTTest();
            YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest panelSetTrichomonas = new YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest();

            if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV.PanelSetId) == false &&
                this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV1618.PanelSetId) == false &&
                this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetNGCT.PanelSetId) == false &&
                this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetTrichomonas.PanelSetId) == false)
            {
                this.AddNextNteElement("No tests performed ", document);
                this.AddBlankNteElement(document);
            }
            else
            {
                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV.PanelSetId) == true)
                {
                    YellowstonePathology.Business.Test.HPV.HPVTestOrder hpvTestOrder = (YellowstonePathology.Business.Test.HPV.HPVTestOrder) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetHPV.PanelSetId);
                    this.AddNextNteElement("High Risk HPV: " + hpvTestOrder.Result, document);
                    this.AddNextNteElement("Reference: Negative", document);
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateAndTimeStringFromNullable(hpvTestOrder.FinalTime);
                    this.AddNextNteElement("Date Finalized: " + hpvFinal, document);
                    this.AddBlankNteElement(document);
                }

                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV1618.PanelSetId) == true)
                {
                    YellowstonePathology.Business.Test.HPV1618.PanelSetOrderHPV1618 panelSetOrderHPV1618 = (YellowstonePathology.Business.Test.HPV1618.PanelSetOrderHPV1618) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetHPV1618.PanelSetId);
                    this.AddNextNteElement("HPV type 16: " + panelSetOrderHPV1618.HPV16Result, document);
                    this.AddNextNteElement("Reference: Negative", document);

                    this.AddNextNteElement("HPV type 18: " + panelSetOrderHPV1618.HPV18Result, document);
                    this.AddNextNteElement("Reference: Negative", document);
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateAndTimeStringFromNullable(panelSetOrderHPV1618.FinalTime);
                    this.AddNextNteElement("Date Finalized: " + hpvFinal, document);
                    this.AddBlankNteElement(document);
                }

                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetNGCT.PanelSetId) == true)
                {
                    this.AddNextNteElement("Chlamydia Gonorrhea Screening ", document);
                    YellowstonePathology.Business.Test.NGCT.NGCTTestOrder panelSetOrderNGCT = (YellowstonePathology.Business.Test.NGCT.NGCTTestOrder) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetNGCT.PanelSetId);
                    this.AddNextNteElement("Chlamydia trachomatis: " + panelSetOrderNGCT.ChlamydiaTrachomatisResult, document);
                    this.AddNextNteElement("Reference: Negative", document);

                    this.AddNextNteElement("Neisseria gonorrhoeae: " + panelSetOrderNGCT.NeisseriaGonorrhoeaeResult, document);
                    this.AddNextNteElement("Reference: Negative", document);
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateAndTimeStringFromNullable(panelSetOrderNGCT.FinalTime);
                    this.AddNextNteElement("Date Finalized: " + hpvFinal, document);
                    this.AddBlankNteElement(document);
                }

                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetTrichomonas.PanelSetId) == true)
                {
                    this.AddNextNteElement("Trichomonas Screening ", document);
                    YellowstonePathology.Business.Test.Trichomonas.TrichomonasTestOrder reportOrderTrichomonas = (YellowstonePathology.Business.Test.Trichomonas.TrichomonasTestOrder) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetTrichomonas.PanelSetId);
                    this.AddNextNteElement("Trichomonas vaginalis: " + reportOrderTrichomonas.Result, document);
                    this.AddNextNteElement("Reference: Negative", document);
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateAndTimeStringFromNullable(reportOrderTrichomonas.FinalTime);
                    this.AddNextNteElement("Date Finalized: " + hpvFinal, document);
                    this.AddBlankNteElement(document);
                }
            }

            this.AddNextNteElement("Specimen Description: Thin Prep Fluid", document);
            this.AddNextNteElement("Specimen Source: " + this.m_AccessionOrder.SpecimenOrderCollection[0].SpecimenSource, document);
            string collectionDateTimeString = this.m_AccessionOrder.SpecimenOrderCollection[0].GetCollectionDateTimeString();

            this.AddNextNteElement("Collection Date/Time: " + collectionDateTimeString, document);
            this.AddBlankNteElement(document);

            this.AddNextNteElement("Clinical History: ", document);
            this.HandleLongString(this.m_AccessionOrder.ClinicalHistory, document);
            this.AddBlankNteElement(document);

            this.AddNextNteElement("Method: ", document);
            this.HandleLongString(womensHealthProfileResult.Method, document);
            this.AddBlankNteElement(document);

            this.AddNextNteElement("References: ", document);
            this.HandleLongString(womensHealthProfileResult.References, document);
            this.AddBlankNteElement(document);

            string locationPerformed = womensHealthProfileTestOrder.GetLocationPerformedComment();

            this.HandleLongString(locationPerformed, document);
            this.AddNextNteElement(string.Empty, document);

            this.AddNextNteElement("PRIOR PAP AND GYN MOLECULAR TESTS", document);
            YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest panelSetThinPrepPap = new YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest();
            DateTime cutoffDate = this.m_AccessionOrder.AccessionDate.Value.AddYears(-5);

            YellowstonePathology.Business.Domain.PatientHistory patientHistory         = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(this.m_AccessionOrder.PatientId);
            YellowstonePathology.Business.Domain.PatientHistory priorPapRelatedHistory = patientHistory.GetPriorPapRelatedHistory(this.m_AccessionOrder.MasterAccessionNo, cutoffDate);

            if (priorPapRelatedHistory.Count == 0)
            {
                this.AddNextNteElement("No prior tests performed ", document);
                this.AddBlankNteElement(document);
            }
            else
            {
                foreach (YellowstonePathology.Business.Domain.PatientHistoryResult patientHistoryResult in priorPapRelatedHistory)
                {
                    YellowstonePathology.Business.Test.AccessionOrder patientHistoryAccessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.GetAccessionOrderByMasterAccessionNo(patientHistoryResult.MasterAccessionNo);
                    foreach (YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder in patientHistoryAccessionOrder.PanelSetOrderCollection)
                    {
                        string reportNo = null;
                        string result   = null;

                        if (panelSetOrder.PanelSetId == panelSetThinPrepPap.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetHPV.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetHPV1618.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetNGCT.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetTrichomonas.PanelSetId)
                        {
                            reportNo = panelSetOrder.ReportNo;
                            string finaldate = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(panelSetOrder.FinalDate);
                            result = panelSetOrder.GetResultWithTestName();
                            this.AddNextNteElement("Test: " + panelSetOrder.PanelSetName + " Report No: " + reportNo + " Result: " + result + " Final Date: " + finaldate, document);
                            this.AddBlankNteElement(document);
                        }
                    }
                }
            }
            this.AddBlankNteElement(document);

            string disclaimer = "This Pap test is only a screening test. A negative result does not definitively rule out the presence of disease. Women should, therefore, in consultation with their physician, have this test performed at mutually agreed intervals.";

            this.AddNextNteElement(disclaimer, document);
            this.AddBlankNteElement(document);
        }
Ejemplo n.º 9
0
 public void DataLoaded()
 {
     if (string.IsNullOrEmpty(this.m_AccessionOrder.PatientId) == false)
     {
         this.m_PatientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(this.m_AccessionOrder.PatientId);
     }
     this.NotifyPropertyChanged("");
     this.OnAccessionChanged(new EventArgs());
 }
        public override void ToXml(XElement document)
        {
            WomensHealthProfileTestOrder womensHealthProfileTestOrder = (WomensHealthProfileTestOrder)this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_ReportNo);
            WomensHealthProfileResult    womensHealthProfileResult    = new WomensHealthProfileResult(this.m_AccessionOrder);

            YellowstonePathology.Business.Amendment.Model.AmendmentCollection amendmentCollection = this.m_AccessionOrder.AmendmentCollection.GetAmendmentsForReport(this.m_ReportNo);

            ThinPrepPap.ThinPrepPapTest thinPrepPapTest = new ThinPrepPap.ThinPrepPapTest();
            bool hasPap = this.m_AccessionOrder.PanelSetOrderCollection.Exists(thinPrepPapTest.PanelSetId);

            this.AddNextObxElementBeaker("Report No: ", this.m_ReportNo, document, "F");

            if (hasPap == true)
            {
                StringBuilder papTest = new StringBuilder();

                YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology panelSetOrderCytology = (YellowstonePathology.Business.Test.ThinPrepPap.PanelSetOrderCytology) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(15);
                if (string.IsNullOrEmpty(panelSetOrderCytology.ScreeningImpression) == false)
                {
                    papTest.AppendLine("Epithelial Cell Description: " + panelSetOrderCytology.ScreeningImpression);
                }

                papTest.AppendLine("Specimen Adequacy: " + panelSetOrderCytology.SpecimenAdequacy);

                if (string.IsNullOrEmpty(panelSetOrderCytology.OtherConditions) == false)
                {
                    papTest.AppendLine("Other Conditions: " + panelSetOrderCytology.OtherConditions);
                }

                if (string.IsNullOrEmpty(panelSetOrderCytology.ReportComment) == false)
                {
                    papTest.AppendLine("Comment: " + panelSetOrderCytology.ReportComment);
                }

                YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology screeningPanelOrder = null;
                YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology reviewPanelOrder    = null;

                foreach (YellowstonePathology.Business.Interface.IPanelOrder panelOrder in panelSetOrderCytology.PanelOrders)
                {
                    Type objectType = panelOrder.GetType();
                    if (typeof(YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology).IsAssignableFrom(objectType) == true)
                    {
                        YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology cytologyPanelOrder = (YellowstonePathology.Business.Test.ThinPrepPap.PanelOrderCytology)panelOrder;
                        if (cytologyPanelOrder.PanelId == 38)
                        {
                            if (cytologyPanelOrder.ScreeningType == "Primary Screening")
                            {
                                screeningPanelOrder = cytologyPanelOrder;
                            }
                            else if (cytologyPanelOrder.ScreeningType == "Pathologist Review")
                            {
                                reviewPanelOrder = cytologyPanelOrder;
                            }
                            else if (cytologyPanelOrder.ScreeningType == "Cytotech Review")
                            {
                                if (reviewPanelOrder == null || reviewPanelOrder.ScreeningType != "Pathologist Review")
                                {
                                    reviewPanelOrder = cytologyPanelOrder;
                                }
                            }
                        }
                    }
                }

                YellowstonePathology.Business.User.SystemUser systemUser = YellowstonePathology.Business.User.SystemUserCollectionInstance.Instance.SystemUserCollection.GetSystemUserById(screeningPanelOrder.ScreenedById);
                if (string.IsNullOrEmpty(systemUser.Signature) == false)
                {
                    papTest.AppendLine("Screened By: " + systemUser.Signature);
                }

                string cytoTechFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(screeningPanelOrder.AcceptedDate);
                papTest.AppendLine("E-Signed " + cytoTechFinal);

                if (reviewPanelOrder != null)
                {
                    string reviewedBy      = YellowstonePathology.Business.User.SystemUserCollectionInstance.Instance.SystemUserCollection.GetSystemUserById(reviewPanelOrder.ScreenedById).Signature;
                    string reviewedByFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(reviewPanelOrder.AcceptedDate);

                    if (reviewedBy.IndexOf("MD") >= 0)
                    {
                        papTest.AppendLine("Interpreted By: " + reviewedBy + " " + reviewedByFinal);
                    }
                    else
                    {
                        papTest.AppendLine("Reviewed By: " + reviewedBy + " " + reviewedByFinal);
                    }
                }
                this.AddNextObxElementBeaker("PAP TEST RESULT: ", papTest.ToString(), document, "F");
            }

            if (amendmentCollection.Count != 0)
            {
                StringBuilder amendments = new StringBuilder();
                foreach (YellowstonePathology.Business.Amendment.Model.Amendment amendment in amendmentCollection)
                {
                    if (amendment.Final == true)
                    {
                        amendments.AppendLine(amendment.AmendmentType + ": " + amendment.AmendmentDate.Value.ToString("MM/dd/yyyy"));
                        amendments.AppendLine(amendment.Text);
                        if (amendment.RequirePathologistSignature == true)
                        {
                            amendments.AppendLine("Signature: " + amendment.PathologistSignature);
                            amendments.AppendLine("E-signed " + amendment.FinalTime.Value.ToString("MM/dd/yyyy HH:mm"));
                        }
                    }
                }
                amendments.AppendLine();
                this.AddNextObxElementBeaker("Amendments", amendments.ToString(), document, "F");
            }

            StringBuilder testsPerformed = new StringBuilder();

            YellowstonePathology.Business.Test.HPV.HPVTest                 panelSetHPV         = new YellowstonePathology.Business.Test.HPV.HPVTest();
            YellowstonePathology.Business.Test.HPV1618.HPV1618Test         panelSetHPV1618     = new YellowstonePathology.Business.Test.HPV1618.HPV1618Test();
            YellowstonePathology.Business.Test.NGCT.NGCTTest               panelSetNGCT        = new YellowstonePathology.Business.Test.NGCT.NGCTTest();
            YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest panelSetTrichomonas = new YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest();

            if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV.PanelSetId) == false &&
                this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV1618.PanelSetId) == false &&
                this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetNGCT.PanelSetId) == false &&
                this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetTrichomonas.PanelSetId) == false)
            {
                testsPerformed.AppendLine("No tests performed");
            }
            else
            {
                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV.PanelSetId) == true)
                {
                    YellowstonePathology.Business.Test.HPV.HPVTestOrder hpvTestOrder = (YellowstonePathology.Business.Test.HPV.HPVTestOrder) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetHPV.PanelSetId);
                    testsPerformed.AppendLine("High Risk HPV: " + hpvTestOrder.Result);
                    testsPerformed.AppendLine("Reference: Negative");
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(hpvTestOrder.FinalDate);
                    testsPerformed.AppendLine("Date Finalized: " + hpvFinal);
                }

                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetHPV1618.PanelSetId) == true)
                {
                    YellowstonePathology.Business.Test.HPV1618.PanelSetOrderHPV1618 panelSetOrderHPV1618 = (YellowstonePathology.Business.Test.HPV1618.PanelSetOrderHPV1618) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetHPV1618.PanelSetId);
                    testsPerformed.AppendLine("HPV type 16: " + panelSetOrderHPV1618.HPV16Result);
                    testsPerformed.AppendLine("Reference: Negative");

                    testsPerformed.AppendLine("HPV type 18: " + panelSetOrderHPV1618.HPV18Result);
                    testsPerformed.AppendLine("Reference: Negative");
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(panelSetOrderHPV1618.FinalDate);
                    testsPerformed.AppendLine("Date Finalized: " + hpvFinal);
                }

                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetNGCT.PanelSetId) == true)
                {
                    //testsPerformed.AppendLine("Chlamydia Gonorrhea Screening");
                    YellowstonePathology.Business.Test.NGCT.NGCTTestOrder panelSetOrderNGCT = (YellowstonePathology.Business.Test.NGCT.NGCTTestOrder) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetNGCT.PanelSetId);
                    testsPerformed.AppendLine("Chlamydia trachomatis: " + panelSetOrderNGCT.ChlamydiaTrachomatisResult);
                    testsPerformed.AppendLine("Reference: Negative");

                    testsPerformed.AppendLine("Neisseria gonorrhoeae: " + panelSetOrderNGCT.NeisseriaGonorrhoeaeResult);
                    testsPerformed.AppendLine("Reference: Negative");
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(panelSetOrderNGCT.FinalDate);
                    testsPerformed.AppendLine("Date Finalized: " + hpvFinal);
                }

                if (this.m_AccessionOrder.PanelSetOrderCollection.Exists(panelSetTrichomonas.PanelSetId) == true)
                {
                    //testsPerformed.AppendLine("Trichomonas Screening");
                    YellowstonePathology.Business.Test.Trichomonas.TrichomonasTestOrder reportOrderTrichomonas = (YellowstonePathology.Business.Test.Trichomonas.TrichomonasTestOrder) this.m_AccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetTrichomonas.PanelSetId);
                    testsPerformed.AppendLine("Trichomonas vaginalis: " + reportOrderTrichomonas.Result);
                    testsPerformed.AppendLine("Reference: Negative");
                    string hpvFinal = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(reportOrderTrichomonas.FinalDate);
                    testsPerformed.AppendLine("Date Finalized: " + hpvFinal);
                }
            }
            this.AddNextObxElementBeaker("CURRENT MOLECULAR TEST SUMMARY", testsPerformed.ToString(), document, "F");

            this.AddNextObxElementBeaker("Specimen Description: ", "Thin Prep Fluid", document, "F");
            this.AddNextObxElementBeaker("Specimen Source: ", this.m_AccessionOrder.SpecimenOrderCollection[0].SpecimenSource, document, "F");
            string collectionDateTimeString = this.m_AccessionOrder.SpecimenOrderCollection[0].GetCollectionDateTimeString();

            this.AddNextObxElementBeaker("Collection Date/Time: ", collectionDateTimeString, document, "F");

            this.AddNextObxElementBeaker("Clinical History: ", this.m_AccessionOrder.ClinicalHistory, document, "F");

            this.AddNextObxElementBeaker("Method: ", womensHealthProfileResult.Method, document, "F");

            this.AddNextObxElementBeaker("References: ", womensHealthProfileResult.References, document, "F");

            string locationPerformed = womensHealthProfileTestOrder.GetLocationPerformedComment();

            this.AddNextObxElementBeaker("Location Performed: ", locationPerformed, document, "F");

            StringBuilder priorTests = new StringBuilder();

            YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest panelSetThinPrepPap = new YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest();
            DateTime cutoffDate = this.m_AccessionOrder.AccessionDate.Value.AddYears(-5);

            YellowstonePathology.Business.Domain.PatientHistory patientHistory         = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(this.m_AccessionOrder.PatientId);
            YellowstonePathology.Business.Domain.PatientHistory priorPapRelatedHistory = patientHistory.GetPriorPapRelatedHistory(this.m_AccessionOrder.MasterAccessionNo, cutoffDate);

            if (priorPapRelatedHistory.Count == 0)
            {
                priorTests.AppendLine("No prior tests performed");
            }
            else
            {
                foreach (YellowstonePathology.Business.Domain.PatientHistoryResult patientHistoryResult in priorPapRelatedHistory)
                {
                    YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.GetAccessionOrderByMasterAccessionNo(patientHistoryResult.MasterAccessionNo);
                    foreach (YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder in accessionOrder.PanelSetOrderCollection)
                    {
                        string reportNo = null;
                        string result   = null;

                        if (panelSetOrder.PanelSetId == panelSetThinPrepPap.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetHPV.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetHPV1618.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetNGCT.PanelSetId ||
                            panelSetOrder.PanelSetId == panelSetTrichomonas.PanelSetId)
                        {
                            reportNo = panelSetOrder.ReportNo;
                            string finaldate = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(panelSetOrder.FinalDate);
                            result = panelSetOrder.GetResultWithTestName();
                            priorTests.AppendLine("Test: " + panelSetOrder.PanelSetName + " Report No: " + reportNo + " Result: " + result + " Final Date: " + finaldate);
                        }
                    }
                }
            }
            this.AddNextObxElementBeaker("PRIOR PAP AND GYN MOLECULAR TESTS", priorTests.ToString(), document, "F");
        }
        private void SetPriorResults()
        {
            YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest panelSetThinPrepPap = new YellowstonePathology.Business.Test.ThinPrepPap.ThinPrepPapTest();
            YellowstonePathology.Business.Test.HPV.HPVTest panelSetHPV = new YellowstonePathology.Business.Test.HPV.HPVTest();
            YellowstonePathology.Business.Test.HPV1618.HPV1618Test panelSetHPV1618 = new YellowstonePathology.Business.Test.HPV1618.HPV1618Test();
            YellowstonePathology.Business.Test.NGCT.NGCTTest panelSetNGCT = new YellowstonePathology.Business.Test.NGCT.NGCTTest();
            YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest panelSetTrichomonas = new YellowstonePathology.Business.Test.Trichomonas.TrichomonasTest();

            DateTime cutoffDate = this.m_AccessionOrder.AccessionDate.Value.AddYears(-5);

            XmlNode mainTableNode = this.m_ReportXml.SelectSingleNode("descendant::w:tbl[w:tr/w:tc/w:p/w:r/w:t='prior_report_no']", this.m_NameSpaceManager);
            XmlNode rowHistoryNode = mainTableNode.SelectSingleNode("descendant::w:tr[w:tc/w:p/w:r/w:t='prior_report_no']", this.m_NameSpaceManager);
            XmlNode insertAfterRow = rowHistoryNode;

            YellowstonePathology.Business.Domain.PatientHistory patientHistory = new YellowstonePathology.Business.Domain.PatientHistory();
            patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(this.m_AccessionOrder.PatientId);
            YellowstonePathology.Business.Domain.PatientHistory priorPapRelatedHistory = patientHistory.GetPriorPapRelatedHistory(this.m_AccessionOrder.MasterAccessionNo, cutoffDate);

            foreach (YellowstonePathology.Business.Domain.PatientHistoryResult patientHistoryResult in priorPapRelatedHistory)
            {
                YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.GetAccessionOrderByMasterAccessionNo(patientHistoryResult.MasterAccessionNo);
                foreach (YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder in accessionOrder.PanelSetOrderCollection)
                {
                    string reportNo = null;
                    DateTime? finalDate = null;
                    string result = null;

                    if (panelSetOrder.PanelSetId == panelSetThinPrepPap.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetHPV.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetHPV1618.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetNGCT.PanelSetId ||
                        panelSetOrder.PanelSetId == panelSetTrichomonas.PanelSetId)
                    {
                        reportNo = panelSetOrder.ReportNo;
                        finalDate = panelSetOrder.FinalDate;
                        result = panelSetOrder.GetResultWithTestName();
                        XmlNode rowHistoryNodeClone = rowHistoryNode.Clone();
                        string testFinaldate = YellowstonePathology.Business.Helper.DateTimeExtensions.DateStringFromNullable(finalDate);

                        rowHistoryNodeClone.SelectSingleNode("descendant::w:r[w:t='prior_final_date']/w:t", this.m_NameSpaceManager).InnerText = testFinaldate;
                        rowHistoryNodeClone.SelectSingleNode("descendant::w:r[w:t='prior_report_no']/w:t", this.m_NameSpaceManager).InnerText = reportNo;
                        rowHistoryNodeClone.SelectSingleNode("descendant::w:r[w:t='prior_result']/w:t", this.m_NameSpaceManager).InnerText = result;
                        mainTableNode.InsertAfter(rowHistoryNodeClone, insertAfterRow);
                        insertAfterRow = rowHistoryNodeClone;
                    }
                }
            }

            if (patientHistory.Count > 0)
            {
                this.DeleteRow("prior_report_no");
            }
            else
            {
                rowHistoryNode.SelectSingleNode("descendant::w:r[w:t='prior_final_date']/w:t", this.m_NameSpaceManager).InnerText = "No prior tests performed";
                rowHistoryNode.SelectSingleNode("descendant::w:r[w:t='prior_report_no']/w:t", this.m_NameSpaceManager).InnerText = string.Empty;
                rowHistoryNode.SelectSingleNode("descendant::w:r[w:t='prior_result']/w:t", this.m_NameSpaceManager).InnerText = string.Empty;
            }
        }
        public ComprehensiveColonCancerProfileResult(YellowstonePathology.Business.Test.AccessionOrder accessionOrder,
                                                     ComprehensiveColonCancerProfile comprehensiveColonCancerProfile)
        {
            this.m_SpecimenOrder         = accessionOrder.SpecimenOrderCollection.GetSpecimenOrderByOrderTarget(comprehensiveColonCancerProfile.OrderedOnId);
            this.m_PanelSetOrderSurgical = (YellowstonePathology.Business.Test.Surgical.SurgicalTestOrder)accessionOrder.PanelSetOrderCollection.GetSurgical();
            this.m_SurgicalSpecimen      = this.m_PanelSetOrderSurgical.SurgicalSpecimenCollection.GetBySpecimenOrderId(this.m_SpecimenOrder.SpecimenOrderId);

            bool restrictToOrderedOn = !comprehensiveColonCancerProfile.IncludeTestsPerformedOnOtherBlocks;

            YellowstonePathology.Business.Test.LynchSyndrome.LynchSyndromeIHCPanelTest panelSetLynchSyndromeIHCPanel = new YellowstonePathology.Business.Test.LynchSyndrome.LynchSyndromeIHCPanelTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(panelSetLynchSyndromeIHCPanel.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_LSEIHCIsOrdered = true;
                this.m_PanelSetOrderLynchSyndromeIHC = (YellowstonePathology.Business.Test.LynchSyndrome.PanelSetOrderLynchSyndromeIHC)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetLynchSyndromeIHCPanel.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
                this.m_IHCResult = YellowstonePathology.Business.Test.LynchSyndrome.IHCResult.CreateResultFromResultCode(this.m_PanelSetOrderLynchSyndromeIHC.ResultCode);
            }
            else
            {
                YellowstonePathology.Business.Domain.PatientHistory patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(accessionOrder.PatientId);
                if (patientHistory.PanelSetIdExists(102) == true)
                {
                    YellowstonePathology.Business.Domain.PatientHistoryResult patientHistoryResult = patientHistory.GetByPanelSetId(102);
                    YellowstonePathology.Business.Test.AccessionOrder         lseIHCAccessionOrder = Business.Persistence.DocumentGateway.Instance.GetAccessionOrderByMasterAccessionNo(patientHistoryResult.MasterAccessionNo);
                    this.m_LSEIHCIsOrdered = true;

                    if (this.m_PanelSetOrderSurgical.MasterAccessionNo == patientHistoryResult.MasterAccessionNo)
                    {
                        this.m_PanelSetOrderLynchSyndromeIHC = (YellowstonePathology.Business.Test.LynchSyndrome.PanelSetOrderLynchSyndromeIHC)lseIHCAccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetLynchSyndromeIHCPanel.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
                    }
                    else
                    {
                        this.m_PanelSetOrderLynchSyndromeIHC = (YellowstonePathology.Business.Test.LynchSyndrome.PanelSetOrderLynchSyndromeIHC)lseIHCAccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(102);
                    }

                    this.m_IHCResult = YellowstonePathology.Business.Test.LynchSyndrome.IHCResult.CreateResultFromResultCode(this.m_PanelSetOrderLynchSyndromeIHC.ResultCode);
                }
            }

            YellowstonePathology.Business.Test.LynchSyndrome.MLH1MethylationAnalysisTest panelSetMLH1 = new YellowstonePathology.Business.Test.LynchSyndrome.MLH1MethylationAnalysisTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(panelSetMLH1.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_MLHIsOrdered = true;
                this.m_PanelSetOrderMLH1MethylationAnalysis = (YellowstonePathology.Business.Test.LynchSyndrome.PanelSetOrderMLH1MethylationAnalysis)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(panelSetMLH1.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
            }

            this.m_BRAFV600EKTest = new YellowstonePathology.Business.Test.BRAFV600EK.BRAFV600EKTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(this.m_BRAFV600EKTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_BRAFV600EKIsOrdered = true;
                this.m_BRAFV600EKTestOrder = (YellowstonePathology.Business.Test.BRAFV600EK.BRAFV600EKTestOrder)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_BRAFV600EKTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
            }

            this.m_KRASStandardTest = new YellowstonePathology.Business.Test.KRASStandard.KRASStandardTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(this.m_KRASStandardTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_KRASStandardIsOrdered = true;
                this.m_KRASStandardTestOrder = (YellowstonePathology.Business.Test.KRASStandard.KRASStandardTestOrder)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_KRASStandardTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
            }

            this.m_KRASExon23MutationTest = new KRASExon23Mutation.KRASExon23MutationTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(this.m_KRASExon23MutationTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_KRASExon23MutationIsOrdered = true;
                this.m_KRASExon23MutationTestOrder = (KRASExon23Mutation.KRASExon23MutationTestOrder)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_KRASExon23MutationTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
            }

            this.m_KRASExon4MutationTest = new KRASExon4Mutation.KRASExon4MutationTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(this.m_KRASExon4MutationTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_KRASExon4MutationIsOrdered = true;
                this.m_KRASExon4MutationTestOrder = (KRASExon4Mutation.KRASExon4MutationTestOrder)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_KRASExon4MutationTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
            }

            this.m_NRASMutationAnalysisTest = new NRASMutationAnalysis.NRASMutationAnalysisTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(this.m_NRASMutationAnalysisTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_NRASMutationAnalysisIsOrdered = true;
                this.m_NRASMutationAnalysisTestOrder = (NRASMutationAnalysis.NRASMutationAnalysisTestOrder)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_NRASMutationAnalysisTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
            }

            this.m_RASRAFPanelTest = new RASRAFPanel.RASRAFPanelTest();
            if (accessionOrder.PanelSetOrderCollection.Exists(this.m_RASRAFPanelTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == true)
            {
                this.m_RASRAFIsOrdered      = true;
                this.m_RASRAFPanelTestOrder = (RASRAFPanel.RASRAFPanelTestOrder)accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(this.m_RASRAFPanelTest.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn);
            }

            this.m_SurgicalSpecimenCollection = new YellowstonePathology.Business.Test.Surgical.SurgicalSpecimenCollection();
            foreach (YellowstonePathology.Business.Specimen.Model.SpecimenOrder specimenOrder in accessionOrder.SpecimenOrderCollection)
            {
                YellowstonePathology.Business.Test.Surgical.SurgicalSpecimen surgicalSpecimen = this.m_PanelSetOrderSurgical.SurgicalSpecimenCollection.GetBySpecimenOrderId(specimenOrder.SpecimenOrderId);
                if (surgicalSpecimen != null)
                {
                    this.m_SurgicalSpecimenCollection.Add(surgicalSpecimen);
                }
            }

            this.m_PanelSetOrderLynchSyndromeIHCCollection = new Collection <LynchSyndrome.PanelSetOrderLynchSyndromeIHC>();
            this.m_MolecularTestOrderCollection            = new PanelSetOrderCollection();
            foreach (YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder in accessionOrder.PanelSetOrderCollection)
            {
                if (panelSetOrder is YellowstonePathology.Business.Test.LynchSyndrome.PanelSetOrderLynchSyndromeIHC)
                {
                    this.m_PanelSetOrderLynchSyndromeIHCCollection.Add((YellowstonePathology.Business.Test.LynchSyndrome.PanelSetOrderLynchSyndromeIHC)panelSetOrder);
                }
                else
                {
                    if (panelSetOrder is LynchSyndrome.PanelSetOrderMLH1MethylationAnalysis ||
                        panelSetOrder is KRASStandard.KRASStandardTestOrder ||
                        panelSetOrder is KRASExon23Mutation.KRASExon23MutationTestOrder ||
                        panelSetOrder is KRASExon4Mutation.KRASExon4MutationTestOrder ||
                        panelSetOrder is BRAFV600EK.BRAFV600EKTestOrder ||
                        panelSetOrder is NRASMutationAnalysis.NRASMutationAnalysisTestOrder ||
                        panelSetOrder is RASRAFPanel.RASRAFPanelTestOrder)
                    {
                        this.m_MolecularTestOrderCollection.Add(panelSetOrder);
                    }
                }
            }

            if (accessionOrder.PanelSetOrderCollection.Exists(panelSetLynchSyndromeIHCPanel.PanelSetId, comprehensiveColonCancerProfile.OrderedOnId, restrictToOrderedOn) == false)
            {
                YellowstonePathology.Business.Domain.PatientHistory patientHistory = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetPatientHistory(accessionOrder.PatientId);
                if (patientHistory.PanelSetIdExists(102) == true)
                {
                    YellowstonePathology.Business.Domain.PatientHistoryResult patientHistoryResult = patientHistory.GetByPanelSetId(102);
                    YellowstonePathology.Business.Test.AccessionOrder         lseIHCAccessionOrder = Business.Persistence.DocumentGateway.Instance.GetAccessionOrderByMasterAccessionNo(patientHistoryResult.MasterAccessionNo);
                    this.m_PanelSetOrderLynchSyndromeIHC = (YellowstonePathology.Business.Test.LynchSyndrome.PanelSetOrderLynchSyndromeIHC)lseIHCAccessionOrder.PanelSetOrderCollection.GetPanelSetOrder(102);
                    this.m_PanelSetOrderLynchSyndromeIHCCollection.Add(m_PanelSetOrderLynchSyndromeIHC);
                }
            }
        }