Пример #1
0
        /// <summary>
        /// Returns the Pathology(key) AND (ProstatectomyPathology OR BiopsyProstatePathology)(value) used for calulating gleason score.
        /// </summary>
        /// <param name="patientProtocolId"></param>
        /// <returns></returns>
        public static KeyValuePair <Pathology, BusinessObject>?GetGleasonPathologyRecord(int patientProtocolId)
        {
            Pathology path = PatientProtocolController.GetPatientRelatedRecords <Pathology>(patientProtocolId).FirstOrDefault();

            if (path != null && !path.IsEmpty)
            {
                int    pathologyId = (int)path[Pathology.PathologyId];
                string pathType    = path[Pathology.PathSpecimenType].ToString();
                // manuall set child records
                if (pathType.Equals("Prostatectomy"))
                {
                    var prostatectomy = BusinessObject.GetByParent <ProstatectomyPathology>(pathologyId).FirstOrDefault();
                    if (prostatectomy != null)
                    {
                        return(new KeyValuePair <Pathology, BusinessObject>(path, prostatectomy));
                    }
                }
                else if (pathType == "Biopsy")
                {
                    var biopsy = BusinessObject.GetByParent <BiopsyProstatePathology>(pathologyId).FirstOrDefault();
                    if (biopsy != null)
                    {
                        return(new KeyValuePair <Pathology, BusinessObject>(path, biopsy));
                    }
                }
            }
            return(null);
        }
Пример #2
0
 // delete patient off schema (only admin's can perform action)
 private void DeletePatient(int patientSchemaId)
 {
     if (base.UserType == ProtocolMgmtUsers.ProtocolAdmin)
     {
         PatientProtocolController.DeletePatientFromSchema(patientSchemaId);
     }
 }
Пример #3
0
        /// <summary>
        /// Build list of statuses
        /// </summary>
        private void BindStatus()
        {
            if (ptProtocol != null)
            {
                int      patProtocolId       = (int)ptProtocol[PatientProtocol.PatientProtocolId];
                bool?    isEligible          = PatientProtocolController.IsPatientEligible(patProtocolId);
                string   ptEligibilityStatus = PatientProtocolController.PatientEligiblityString(isEligible);
                string[] eligibilityStatuses = new string[] { PatientProtocolController.Eligible, PatientProtocolController.Ineligible };
                // get all statuses for patient
                IEnumerable <PatientProtocolStatus> patientStatuses = BusinessObject.GetByParent <PatientProtocolStatus>(patProtocolId);
                // explicitly sort statuses by date then weight, (get status weight by location in list)
                string[] statusSequence        = PatientProtocolController.PatientStatusSequence;
                var      sortedPatientStatuses = from biz in patientStatuses
                                                 let status = biz[PatientProtocolStatus.PtProtocolStatus].ToString()
                                                              let weight                       = Array.IndexOf(statusSequence, status)
                                                                                      let date = biz.IsNull(PatientProtocolStatus.PtProtocolStatusDate) ? DateTime.MinValue : (DateTime)biz[PatientProtocolStatus.PtProtocolStatusDate]
                                                                                                 orderby weight ascending, date ascending
                let ptProtocolStatus = string.Format("{0}", biz[PatientProtocolStatus.PtProtocolStatus])
                                       select new
                {
                    PatientProtocolStatusId = string.Format("{0}", biz[PatientProtocolStatus.PatientProtocolStatusId]),
                    PtProtocolStatusDate    = string.Format("{0:d}", biz[PatientProtocolStatus.PtProtocolStatusDate]),
                    PtProtocolStatus        = eligibilityStatuses.Contains(ptProtocolStatus) ? ptProtocolStatus + " (" + ptEligibilityStatus + ")" : ptProtocolStatus,
                    PtProtocolStatusReason  = string.Format("{0}", biz[PatientProtocolStatus.PtProtocolStatusReason])
                };

                // build list
                PatientProtocolStatusRptr.DataSource = sortedPatientStatuses;
                PatientProtocolStatusRptr.DataBind();
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected string GetNextParticipantId()
        {
            int    protocolId             = int.Parse(BaseProtocolId);
            string generatedParticipantId = PatientProtocolController.GenerateParticipantId(protocolId);

            return(generatedParticipantId);
        }
Пример #5
0
        /// <summary>
        /// Update Patient's Study Id and/or warn if already exits.
        /// </summary>
        /// <param name="e"></param>
        protected void UpdateStudyId(CaisisAjaxEventArgs e)
        {
            string newStudyId = e.ClientParam;

            if (PatientPage != null && !string.IsNullOrEmpty(newStudyId) && !string.IsNullOrEmpty(PatientPage.PatientProtocolId))
            {
                // ok to update when study id doesn't exits
                if (!ProtocolMgmtDa.StudyIdExists(newStudyId, int.Parse(PatientPage.BaseProtocolId)))
                {
                    int             ptProtocolId = int.Parse(PatientPage.PatientProtocolId);
                    PatientProtocol biz          = new PatientProtocol();
                    biz.Get(ptProtocolId);
                    biz[PatientProtocol.PtProtocolStudyId] = newStudyId;
                    biz.Save();

                    // CREATE STUDY ID IDENTIFIER
                    PatientProtocolController.CreateStudyIdIdentifier(biz);

                    // echo back value to client
                    e.ReturnValue = newStudyId;
                }
                // otherwise exists, and warn
                else
                {
                    // echo back to client study id exits
                    e.ReturnValue = "The StudyId entered already exits in the system.";
                }
            }
            else
            {
                // echo to client there were issues
                e.ReturnValue = "Please Enter a valid StudyId.";
            }
        }
Пример #6
0
        private DateTime?GetOnStudyDate()
        {
            int ptProtocolId = int.Parse(PatientProtocolId);
            PatientProtocolController ppc = new PatientProtocolController(ptProtocolId);

            return(ppc.GetStatusDate(PatientProtocolController.OnStudy));
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UpdateStatusClick(object sender, EventArgs e)
        {
            foreach (int dirtyRow in dirtyVisits)
            {
                GridViewRow   row               = PatientVisitsGrid.Rows[dirtyRow];
                CaisisHidden  pItemStatus       = row.FindControl(PatientItem.Status) as CaisisHidden;
                CaisisTextBox pItemSDate        = row.FindControl(PatientItem.ScheduledDate) as CaisisTextBox;
                CaisisHidden  deviationId       = row.FindControl(PatientDeviation.PatientDeviationId) as CaisisHidden;
                int           patientItemId     = int.Parse(PatientVisitsGrid.DataKeys[dirtyRow][PatientItem.PatientItemId].ToString());
                string        patientItemStatus = pItemStatus.Value;
                string        scheduledDate     = pItemSDate.Value;

                PatientItem biz = new PatientItem();
                biz.Get(patientItemId);
                biz[PatientItem.Status]        = patientItemStatus;
                biz[PatientItem.ScheduledDate] = scheduledDate;
                // needs deviation ???


                if (patientItemStatus == "Missed")
                {
                    // do not create deviation

                    /*
                     * PatientDeviation deviation = new PatientDeviation();
                     * if (!string.IsNullOrEmpty(deviationId.Value))
                     * {
                     *  deviation.Get(int.Parse(deviationId.Value));
                     * }
                     * // otherwise set required foreign key
                     * else
                     * {
                     *  deviation[PatientDeviation.PatientItemId] = patientItemId.ToString();
                     * }
                     * deviation[PatientDeviation.DeviationType] = "Missed Visit";
                     * deviation.Save();
                     *
                     * // update hidden deviation field
                     * deviationId.Value = deviation[PatientDeviation.PatientDeviationId].ToString();
                     */
                }
                // if status isn't missed, remove deviation if exists
                else if (!string.IsNullOrEmpty(deviationId.Value))
                {
                    PatientDeviation deviation = new PatientDeviation();
                    deviation.Delete(int.Parse(deviationId.Value));
                    deviationId.Value = string.Empty;
                }
                biz.Save();

                // trigger scheduling for dependent items
                PatientProtocolController.ScheduleDependentItemsByItemStatus(patientItemId, patientItemStatus);
            }
            dirtyVisits.Clear();

            SetVisit(sender, e);

            RegisterReloadPatientLists();
        }
Пример #8
0
        private void SaveForm(bool registerUpdateScript)
        {
            // only update dirty record
            if (isToxicityRecordDirty)
            {
                int patientId = int.Parse(BaseDecryptedPatientId);
                // save toxicity
                Toxicity tox        = new Toxicity();
                int      toxicityId = SaveRecord(ToxicityFields, tox, ToxicityIdField, patientId);

                // PatientItem Record
                PatientItem item = new PatientItem();
                int         patientItemId;
                if (!string.IsNullOrEmpty(PatientItemId.Value))
                {
                    item.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
                }
                else
                {
                    item[PatientItem.PatientSchemaId] = PatientSchemaId;
                    item[PatientItem.Status]          = "Unplanned";
                }
                item[PatientItem.ScheduledDate] = ToxDate.Value;
                item.Save();
                patientItemId       = (int)item[item.PrimaryKeyName];
                PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

                // Related Record
                int relatedRecordId = PatientProtocolController.CreateUnplannedVisitRelatedRecord(patientItemId, tox.TableName, toxicityId);
                RelatedRecordId.Value = relatedRecordId.ToString();

                // if visible to user and record dirty
                if (isSAERecordDirty)
                {
                    // SAE Record
                    SeriousAdverseEvent sae = new SeriousAdverseEvent();
                    SaveRecord(SAEFields, sae, ToxicityIdField, toxicityId);
                }
            }
            // no need to update parent Toxicity, update child record if needed
            else if (isSAERecordDirty && !string.IsNullOrEmpty(ToxicityIdField.Value))
            {
                int toxicityId          = int.Parse(ToxicityIdField.Value);
                SeriousAdverseEvent sae = new SeriousAdverseEvent();
                SaveRecord(SAEFields, sae, ToxicityIdField, toxicityId);
            }
            // save attributions
            if (!string.IsNullOrEmpty(ToxicityIdField.Value) && ToxAttributionGrid.DirtyRows.Count > 0)
            {
                int toxicityId = int.Parse(ToxicityIdField.Value);
                ToxAttributionGrid.Save(toxicityId);
            }
            // register client update script (close form from popup)
            if (registerUpdateScript)
            {
                RegisterUpdateScript(false);
            }
        }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
            // save survey
            Survey biz = new Survey();

            if (!string.IsNullOrEmpty(SurveyIdField.Value))
            {
                biz.Get(int.Parse(SurveyIdField.Value));
            }
            // if save was NOT triggerd from plugin, then save with form fields
            if (string.IsNullOrEmpty(SaveFromPlugin.Value))
            {
                CICHelper.SetBOValues(this.Controls, biz, int.Parse(BaseDecryptedPatientId));
                biz.Save();
                int surveyId = (int)biz[Survey.SurveyId];
                SurveyIdField.Value = surveyId.ToString();

                // save survey items
                SurveyItemsGrid.Save(surveyId);
            }

            SurveyPluginControl.SetSurveyIdField(SurveyIdField.Value);

            // create patient item if needed
            PatientItem item = new PatientItem();
            int         patientItemId;

            if (!string.IsNullOrEmpty(PatientItemId.Value))
            {
                item.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
            }
            else
            {
                item[PatientItem.PatientSchemaId] = PatientSchemaId;
                item[PatientItem.Status]          = "Unplanned";
            }
            item[PatientItem.ScheduledDate] = FieldSurveyDate.Value;
            item.Save();
            patientItemId       = (int)item[item.PrimaryKeyName];
            PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

            // now create association via related records
            int relatedRecordId = PatientProtocolController.CreateUnplannedVisitRelatedRecord(patientItemId, biz.TableName, int.Parse(SurveyIdField.Value));

            RelatedRecordId.Value = relatedRecordId.ToString();

            // don't register update script if triggered from add new row
            if (sender != AddNewRowBtn)
            {
                // register update script
                RegisterUpdateScript(false);
            }
            // otherwise repopulate form
            else
            {
                PopulateForm();
            }
        }
Пример #10
0
        /// <summary>
        /// Save the data entry form and close
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
            var biz = BusinessObjectFactory.BuildBusinessObject(QueryTableName);

            if (!string.IsNullOrEmpty(PriKeyField.Value))
            {
                biz.Get(int.Parse(PriKeyField.Value));
            }
            int patientId = (int)Session[Patient.PatientId];//int.Parse(BaseDecryptedPatientId)
            int parentKey = biz.HasField(Patient.PatientId) ? patientId : -1;

            CICHelper.SetBOValues(DataEntryLayout.Controls, biz, parentKey);
            biz.Save();
            // update hidden field
            int priKey = (int)biz[biz.PrimaryKeyName];

            PriKeyField.Value = priKey.ToString();

            // create patient item if needed
            PatientItem item = new PatientItem();
            int         patientItemId;

            if (!string.IsNullOrEmpty(PatientItemId.Value))
            {
                item.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
            }
            else
            {
                item[PatientItem.PatientSchemaId] = PatientSchemaId;
                item[PatientItem.Status]          = "Unplanned";
            }
            // determine schedule date
            var dateFields = from field in biz.FieldNames
                             where field.EndsWith("Date")
                             select field;

            if (dateFields.Count() > 0)
            {
                item[PatientItem.ScheduledDate] = biz[dateFields.First()].ToString();
            }
            item.Save();
            patientItemId       = (int)item[item.PrimaryKeyName];
            PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

            // now create association via related records
            if (string.IsNullOrEmpty(RelatedRecordId.Value))
            {
                int relatedRecordId = PatientProtocolController.CreateUnplannedVisitRelatedRecord(patientItemId, biz.TableName, priKey);
                RelatedRecordId.Value = relatedRecordId.ToString();
            }

            RegisterUpdateScript(false);

            // re populate
            BuildUnplannedEvent();
        }
Пример #11
0
        /// <summary>
        /// Sets the computed participant id
        /// </summary>
        /// <param name="epid"></param>
        private void SetParticipantId(string epid)
        {
            string participantId = string.Empty;

            if (!string.IsNullOrEmpty(epid))
            {
                int patientId  = int.Parse(DecrypyValue(epid));
                int protocolId = int.Parse(BaseProtocolId);
                participantId = PatientProtocolController.GetParticipantId(protocolId, patientId);
            }
            ParticipantId.Value = participantId;
        }
Пример #12
0
        /// <summary>
        /// Gets a start and end date filter for Diagnostics
        /// </summary>
        /// <returns></returns>
        private KeyValuePair <DateTime?, DateTime?> GetDiagnosticDateRange()
        {
            PatientProtocolController ppc = new PatientProtocolController(int.Parse(PatientProtocolId));
            DateTime?startDate            = ppc.GetStatusDate(PatientProtocolController.OnStudy);

            // 90 days before on study
            if (startDate.HasValue)
            {
                startDate = startDate.Value.AddDays(-90);
            }
            DateTime?endDate = ppc.GetStatusDate(PatientProtocolController.OffStudy);

            return(new KeyValuePair <DateTime?, DateTime?>(startDate, endDate));;
        }
Пример #13
0
        public static float?GetPatientPSADoublingTime(int patientProtocolId)
        {
            float parseResult = 0;
            var   labs        = PatientProtocolController.GetPatientRelatedRecords <LabTest>(patientProtocolId);
            var   psaByDate   = from lab in labs
                                where lab[LabTest.LabTest_Field].ToString() == "PSA"
                                where !lab.IsNull(LabTest.LabDate) && !lab.IsNull(LabTest.LabResult)
                                let labResult = lab[LabTest.LabResult].ToString()
                                                let labDate = (DateTime)lab[LabTest.LabDate]
                                                              where float.TryParse(labResult, out parseResult)
                                                              select new KeyValuePair <float, DateTime>(parseResult, labDate);

            return(GetPSADoublingTime(psaByDate));
        }
Пример #14
0
        /// <summary>
        /// Updates the PatientItem record including status and status date.
        /// Also triggers scheduling of dependent events on this item.
        /// </summary>
        private void UpdatePatientItem()
        {
            if (!string.IsNullOrEmpty(PatientItemId))
            {
                // Load Item record and update fields
                int         priKey = int.Parse(PatientItemId);
                PatientItem biz    = new PatientItem();
                biz.Get(priKey);
                biz[PatientItem.Status] = StatusField.Value;
                // ScheduledDate is read only, so values aren't persisted by rumtime, but in Form
                biz[PatientItem.ScheduledDate] = Request.Form[ScheduledDate.UniqueID];
                biz.Save();

                // trigger scheduling for dependent items
                PatientProtocolController.ScheduleDependentItemsByItemStatus(priKey, StatusField.Value);
            }
        }
Пример #15
0
        private void BuildLabTestsInterface()
        {
            int patientProtocolId = int.Parse(PatientProtocolId);
            var labs       = PatientProtocolController.GetPatientRelatedRecords <LabTest>(patientProtocolId);
            var sortedLabs = from lab in labs
                             where lab[LabTest.LabTest_Field].ToString() == "PSA"
                             orderby(lab.IsNull(LabTest.LabTestId) ? int.MaxValue : (int)lab[LabTest.LabTestId]) ascending
                             orderby(lab.IsNull(LabTest.LabDate)?DateTime.MaxValue : (DateTime)lab[LabTest.LabDate]) ascending
                             select lab;

            var labsView = sortedLabs.AsDataView <LabTest>();

            LabTestsGrid.BlankRows        = 15;
            LabTestsGrid.VisibleBlankRows = labsView.Count > 2 ? 2 : 4;
            LabTestsGrid.DataSource       = labsView;
            LabTestsGrid.DataBind();

            // run inital calculation
            CalculatePSADoublingTime();
        }
Пример #16
0
        private void BuildPatientList()
        {
            string dataset         = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            int    protocolId      = int.Parse(BaseProtocolId);
            bool   showIdentifiers = base.ShowPatientIdentifiers();

            // get list
            bool      canViewIdentifiers = base.ShowPatientIdentifiers();
            DataTable patientsList       = ProtocolMgmtDa.GetPatientsByProtocol(protocolId, dataset, showIdentifiers, true);
            DataView  sortedPatients     = PatientProtocolController.SortPatientsByStudyId(patientsList, "ASC");
            var       patients           = from patient in sortedPatients.ToTable().AsEnumerable()
                                           let name = patient["Name"].ToString()
                                                      select new
            {
                PatientDisplayName = patient[PatientProtocol.PtProtocolStudyId].ToString() + (canViewIdentifiers && !string.IsNullOrEmpty(name) ? " : " + name : ""),
                PatientProtocolId  = patient[PatientProtocol.PatientProtocolId].ToString()
            };

            PatientList.DataSource = patients;
            PatientList.DataBind();
        }
Пример #17
0
        protected void BuildIdentifiers(string type)
        {
            int    protocolId = int.Parse(BaseProtocolId);
            string datasetSQL = base.GetSpecimenPatientsDatasetSQL();

            DataTable patientIdentifiers = ProtocolMgmtDa.GetProtocolPatientIdentifiers(protocolId, datasetSQL);
            DataView  patientView        = PatientProtocolController.SortPatientsByStudyId(patientIdentifiers, "ASC");

            // set column visibility
            ProtocolPatientIdentifiers.Columns[1].Visible = type == ID_TYPES[0];
            ProtocolPatientIdentifiers.Columns[2].Visible = type == ID_TYPES[1];
            ProtocolPatientIdentifiers.Columns[3].Visible = type == ID_TYPES[2];
            // delete column
            ProtocolPatientIdentifiers.Columns[4].Visible = false;// todo: UserType == ProtocolMgmtUsers.ProtocolAdmin;

            ProtocolPatientIdentifiers.DataSource = patientView;
            ProtocolPatientIdentifiers.DataBind();

            UpdateBtn.Visible = patientView.Count > 0;
            ProtocolPatientIdentifiers.Visible = true;
        }
Пример #18
0
        /// <summary>
        /// Builds the patient questionnaire
        /// </summary>
        private void BuildPatientEligibility()
        {
            int  ptProtocolId = int.Parse(PatientProtocolId);
            bool canEnterData = true;

            if (registrationId.HasValue)
            {
                if (!metaSurveyId.HasValue && !registrationId.HasValue)
                {
                    canEnterData = false;
                }
                else
                {
                    DataView questionsView = ProtocolMgmtDa.GetPatientQuestionnaire(metaSurveyId, registrationId).DefaultView;
                    PatientEligibilityGrid.DataSource = questionsView;
                    PatientEligibilityGrid.DataBind();

                    canEnterData = questionsView.Count > 0;
                }
            }

            // Update UI elements based on user being able to enter data
            CoverLayer.Visible = !canEnterData;
            UpdateBtn.Visible  = canEnterData;

            // display Eligibility status
            EligibilityStatus.Visible = true;

            // determine eligibility
            if (metaSurveyId.HasValue && registrationId.HasValue)
            {
                bool?  eligible       = PatientProtocolController.IsPatientEligible(ptProtocolId, metaSurveyId.Value, registrationId.Value);
                string eligibleString = PatientProtocolController.PatientEligiblityString(eligible);
                EligibilityStatus.Text = eligibleString;
            }
            else
            {
                EligibilityStatus.Text = "Not Completed";
            }
        }
Пример #19
0
        /// <summary>
        /// Populates the patient's baseline form
        /// </summary>
        private void PopulateBaselineForm()
        {
            int patientId         = int.Parse(BaseDecryptedPatientId);
            int ptProtocolId      = int.Parse(PatientProtocolId);
            var dataEntryControls = PageUtil.GetControls <BaseDataEntryControl>(BaselineFormPanel);
            // load patient
            Patient patient = new Patient();

            patient.Get(patientId);
            // load patient protocol
            PatientProtocol ptProtocol = new PatientProtocol();

            ptProtocol.Get(ptProtocolId);
            PatientProtocolController ptProtocolController = new PatientProtocolController(ptProtocolId);
            DateTime?onStudyDate         = ptProtocolController.GetStatusDate(PatientProtocolController.OnStudy);
            DateTime?screeningFailedDate = ptProtocolController.GetStatusDate(PatientProtocolController.ScreeningFailed);
            DateTime?screeningPassedDate = ptProtocolController.GetStatusDate(PatientProtocolController.ScreeningPassed);
            // determine date ranges
            DateTime?baselineFromDate = null;
            DateTime?baselineToDate   = onStudyDate ?? screeningFailedDate ?? screeningPassedDate;

            List <ICaisisInputControl> inputs = new List <ICaisisInputControl>();

            // populate components
            foreach (BaseDataEntryControl control in dataEntryControls)
            {
                // set date ranges
                control.BaselineFromDate = baselineFromDate;
                // todo???
                control.BaselineToDate = baselineToDate;
                control.Populate();
                inputs.AddRange(CICHelper.GetCaisisInputControls(control));
            }
            // add required field
            foreach (var control in inputs.Where(i => i.Required).OfType <WebControl>())
            {
                control.Attributes["data-required"] = "true";
            }
        }
Пример #20
0
        private void BuildInventory(DataView inventoryView)
        {
            selectedColumns = GetSpecimenColumns();

            // build header
            HeaderRptr.DataSource = selectedColumns;
            HeaderRptr.DataBind();

            // build data
            string sortColumn    = SortColumn.Value;
            string sortDirection = SortDirection.Value;

            if (!string.IsNullOrEmpty(sortColumn))
            {
                // special case
                if (sortColumn == "PtProtocolStudyId" && inventoryView.Count > 0)
                {
                    inventoryView = PatientProtocolController.SortPatientsByStudyId(inventoryView.ToTable(), sortDirection);
                }
                else
                {
                    inventoryView.Sort = sortColumn + " " + sortDirection;
                }
            }
            // do not show NULL statuses
            inventoryView.RowFilter = Specimen.SpecimenStatus + " IS NOT NULL";
            bool hideBankedSpeicmens = BankedSpecimensPreference.Checked && BankedSpecimensPreference.Visible;

            if (hideBankedSpeicmens)
            {
                inventoryView.RowFilter += " AND SpecimenSubType NOT IN ('Serum', 'Plasma', 'PAXGen')";
            }
            SpecimenInventoryRows.DataSource = inventoryView;
            SpecimenInventoryRows.DataBind();

            RecordCount.Text = inventoryView.Count + " Record(s)";
        }
Пример #21
0
        private void BuildChronList()
        {
            int patientId = int.Parse(BaseDecryptedPatientId);
            //ChronoDa da = new ChronoDa();
            //DataView dv = da.GetChronoList(patientId, CHRON_NAME, User.Identity.Name).Tables[0].DefaultView;
            PatientProtocolResponseDa da = new PatientProtocolResponseDa();
            // all dx types
            //DataView dv = da.GetImagingAndResponseChronList(patientId).DefaultView;
            // only specific dx types
            DataTable imagingTable = da.GetImagingAndResponseChronList(patientId, DxImagingTypes);
            DataView  imagingView  = imagingTable.DefaultView;

            // filter > 90 days before screened date
            if (!string.IsNullOrEmpty(PatientProtocolId) && DiagFilter.Checked)
            {
                PatientProtocolController ppc = new PatientProtocolController(int.Parse(PatientProtocolId));
                DateTime?     onStudyDate     = ppc.GetStatusDate(PatientProtocolController.OnStudy);
                DateTime?     offStudyDate    = ppc.GetStatusDate(PatientProtocolController.OffStudy);
                List <string> filters         = new List <string>();
                // within 90 days of on study
                if (onStudyDate.HasValue)
                {
                    filters.Add(string.Format("SortDate >= #{0:d}#", onStudyDate.Value.AddDays(-90)));
                }
                // after off study
                if (offStudyDate.HasValue)
                {
                    filters.Add(string.Format("SortDate <= #{0:d}#", offStudyDate.Value));
                }
                if (filters.Count > 0)
                {
                    imagingView.RowFilter = string.Join(" AND ", filters.ToArray());
                }
            }
            ImagingChronListRptr.DataSource = imagingView;
            ImagingChronListRptr.DataBind();
        }
Пример #22
0
        private DataView LoadPatients(String SortString)
        {
            string   dataset = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            DataView patientsList;
            int      protocolId      = int.Parse(BaseProtocolId);
            bool     showIdentifiers = base.ShowPatientIdentifiers();

            // call main method for filtering values
            patientsList = ProtocolMgmtDa.GetPatientsByProtocol(protocolId, dataset, QueryTreatmentArms, QueryStatuses, showIdentifiers, IncludeDeceasedPatients).DefaultView;

            // special case for StudyId: strip last x ids from end to sort
            if (SortString.StartsWith(PatientProtocol.PtProtocolStudyId) && patientsList.Count > 0)
            {
                string sort = SortString.EndsWith("DESC", StringComparison.OrdinalIgnoreCase) ? "DESC" : "ASC";
                patientsList = PatientProtocolController.SortPatientsByStudyId(patientsList.Table, sort);
            }
            else
            {
                // Force default sort to earliest records first
                patientsList.Sort = SortString;
            }

            return(patientsList);
        }
Пример #23
0
 private void DeletePatientSchema(int patientSchemaId)
 {
     PatientProtocolController.DeletePatientFromSchema(patientSchemaId);
 }
Пример #24
0
        /// <summary>
        /// Inserts/Updates the relevent labs and gleason calculations
        /// </summary>
        private void SaveDetails()
        {
            // validation
            int             patientId         = int.Parse(BaseDecryptedPatientId);
            int             patientProtocolId = int.Parse(PatientProtocolId);
            PatientProtocol patientProtocol   = new PatientProtocol();

            patientProtocol.Get(patientProtocolId);

            var relatedLabTestIds = GetRelatedLabTestIds(patientProtocolId);

            // LABS (PSA)
            List <KeyValuePair <float, DateTime> > labResults = new List <KeyValuePair <float, DateTime> >();

            foreach (GridViewRow row in LabTestsGrid.Rows)
            {
                LabTest lab = new LabTest();
                // load???
                string currentRowId = LabTestsGrid.DataKeys[row.RowIndex][LabTest.LabTestId].ToString();
                if (!string.IsNullOrEmpty(currentRowId))
                {
                    lab.Get(int.Parse(currentRowId));
                }
                CICHelper.SetBOValues(row.Controls, lab, patientId);
                if (!lab.IsEmpty)
                {
                    lab[LabTest.LabTest_Field] = "PSA";
                    lab.Save();
                    int labTestId = (int)lab[LabTest.LabTestId];

                    string labTest        = lab[LabTest.LabTest_Field].ToString();
                    string labResult      = lab[LabTest.LabResult].ToString();
                    float  labResultValue = 0;
                    if (labTest.Equals("PSA") && float.TryParse(labResult, out labResultValue) && !lab.IsNull(LabTest.LabDate))
                    {
                        DateTime labDate = (DateTime)lab[LabTest.LabDate];
                        labResults.Add(new KeyValuePair <float, DateTime>(labResultValue, labDate));
                    }

                    // RELATED RECORD
                    if (!relatedLabTestIds.Contains(labTestId))
                    {
                        BOL.RelatedRecord relatedRecord = RelatedRecordController.CreateRelatedRecord(lab, patientProtocol);
                    }
                }
            }

            // calculate doubling time
            float?dbl = ProtocolMgmtUtil.GetPatientPSADoublingTime(patientProtocolId);

            if (dbl.HasValue)
            {
                PSADoublingTime.Text = dbl + " Months";
            }
            else
            {
                PSADoublingTime.Text = "N/A";
            }

            // GLEASON SCORE
            Pathology pathology = PatientProtocolController.GetPatientRelatedRecords <Pathology>(patientProtocolId).FirstOrDefault();

            // create new patholgy if needed
            if (!string.IsNullOrEmpty(PathSpecimenType.Value))
            {
                bool   isNewPathology = pathology == null;
                string pathType       = PathSpecimenType.Value;
                if (isNewPathology)
                {
                    pathology = new Pathology();
                    pathology[Pathology.PatientId] = patientId;
                }
                pathology[Pathology.PathSpecimenType] = pathType;
                pathology[Pathology.PathDateText]     = PathDateText.Value;
                pathology[Pathology.PathDate]         = PathDate.Value;
                pathology.Save();
                if (!pathology.IsEmpty)
                {
                    int pathologyId = (int)pathology[Pathology.PathologyId];
                    // create child record
                    if (pathType.Equals("Prostatectomy"))
                    {
                        var prostatectomy = BusinessObject.GetByParent <ProstatectomyPathology>(pathologyId).FirstOrDefault();
                        if (prostatectomy == null)
                        {
                            prostatectomy = new ProstatectomyPathology();
                            prostatectomy[ProstatectomyPathology.PathologyId] = pathologyId;
                        }
                        prostatectomy[ProstatectomyPathology.PathGG1] = GleasonField1.Text;
                        prostatectomy[ProstatectomyPathology.PathGG2] = GleasonField2.Text;
                        prostatectomy[ProstatectomyPathology.PathGGS] = GleasonFieldSum.Text;
                        prostatectomy.Save();
                    }
                    else if (pathType == "Biopsy")
                    {
                        var biopsy = BusinessObject.GetByParent <BiopsyProstatePathology>(pathologyId).FirstOrDefault();
                        if (biopsy == null)
                        {
                            biopsy = new BiopsyProstatePathology();
                            biopsy[BiopsyProstatePathology.PathologyId] = pathologyId;
                        }
                        biopsy[BiopsyProstatePathology.PathGG1] = GleasonField1.Text;
                        biopsy[BiopsyProstatePathology.PathGG2] = GleasonField2.Text;
                        biopsy[BiopsyProstatePathology.PathGGS] = GleasonFieldSum.Text;
                        biopsy.Save();
                    }
                    // create related record if needed
                    if (isNewPathology)
                    {
                        BOL.RelatedRecord relatedPathology = RelatedRecordController.CreateRelatedRecord(pathology, patientProtocol);
                    }
                }
            }

            // rebuild UI
            BuildInterfaces();
        }
Пример #25
0
        /// <summary>
        /// Return a list of LabTest Ids related to the current PatientProtocol
        /// </summary>
        /// <param name="patientProtocolId"></param>
        /// <returns></returns>
        private IEnumerable <int> GetRelatedLabTestIds(int patientProtocolId)
        {
            var relatedLabs = PatientProtocolController.GetPatientRelatedRecords(patientProtocolId, "LabTests");

            return(relatedLabs.Select(b => int.Parse(b[RelatedRecord.SrcPrimaryKey].ToString())));
        }
Пример #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="patientId"></param>
        /// <returns></returns>
        protected string GetParticipantId(int patientId)
        {
            int protocolId = int.Parse(BaseProtocolId);

            return(PatientProtocolController.GetParticipantId(protocolId, patientId));
        }
Пример #27
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            // set dataset message
            if (!hasInstitutionDataset)
            {
                NewPatientInstitution.Visible = true;
            }

            if (!Page.IsPostBack)
            {
                int protocolId = int.Parse(BaseProtocolId);
                // Get an auto-generate screening id
                ScreeningID.Value = PatientProtocolController.GenerateScreeningId().ToString();
                // study id
                string autoStudyId = PatientProtocolController.GenerateStudyId(protocolId);
                StudyID.Value = autoStudyId;
                bool calculateStudyIdBySite = ProtocolMgmtUtil.GenerateStudyIdByOrganization();
                // custom auto-generation
                if (calculateStudyIdBySite)
                {
                    OrganizationStudyIds.Visible = true;

                    StudyIdTooltip.Attributes["title"] = "An Id created to identify a patient on a study in the form: Site Id (2 digits) + Protocol Id (3 digits) + Incremental Patient Id (3 digits)";

                    // get associated Project (to select organizations)
                    Protocol protocol = new Protocol();
                    protocol.Get(protocolId);
                    string protocolNum = protocol[Protocol.ProtocolNum].ToString();

                    // get a list of associated organizations
                    if (!protocol.IsNull(Protocol.ProjectId) && !string.IsNullOrEmpty(protocolNum))
                    {
                        ProjectManagementDa da = new ProjectManagementDa();
                        int projectId          = (int)protocol[Protocol.ProjectId];

                        // get a list of organizations associated with project
                        var projectOrganizations = BusinessObject.GetByFields <Project_ProjectOrganization>(new Dictionary <string, object> {
                            { Project_ProjectOrganization.ProjectId, projectId }
                        });

                        // get a list of user's organizations
                        int       userId              = new UserController().GetUserId();
                        DataTable userOrganizations   = new UserDa().GetUserOrganizations(userId);
                        var       userOrganizationIds = userOrganizations.AsEnumerable().Select(r => (int)r["OrganizationId"]);

                        // get the intersect of user's sites and lead sites
                        var userLeadSites = from po in projectOrganizations
                                            let organizationType = po["OrganizationType"].ToString()
                                                                   let organizationId = (int)po[Project_ProjectOrganization.OrganizationId]
                                                                                        where organizationType.Contains("Lead Site")
                                                                                        join userOrgId in userOrganizationIds on organizationId equals userOrgId
                                                                                        select userOrgId;
                        // if user is part of a lead site, allow to select organization
                        if (userLeadSites.Count() > 0)
                        {
                            // TODO: centralize call to get project organizations
                            var organizations = da.GetAllOrganizationsByProjectId(projectId);
                            // get a list of organizations and calculate study id per organization
                            var organizationToStudyId = from row in organizations.AsEnumerable()
                                                        let orgName                         = row["Name"].ToString()
                                                                                  let orgId = (int)row["OrganizationId"]
                                                                                              let isAssociated = userOrganizationIds.Contains(orgId) ? 0 : 1
                                                                                                                 orderby
                                                                                                                 //isAssociated ascending,
                                                                                                                 orgName ascending
                                                                                                                 select new
                            {
                                OrganizationName    = orgName,
                                OrganizationId      = orgId,
                                OrganizationStudyId = GenerateStudyIdByOrganization(protocolId, protocolNum, orgId)
                            };

                            OrganizationStudyIds.DataSource = organizationToStudyId;
                            OrganizationStudyIds.DataBind();

                            // a list of insitutions where institution = organization in project
                            var allInstitutions = from inst in BOL.BusinessObject.GetAll <Institution>()
                                                  let institutionId = (int)inst[BOL.Institution.InstitutionId]
                                                                      let institutionName = inst[BOL.Institution.Institution_Field].ToString()
                                                                                            select new
                            {
                                InstitutionId = institutionId,
                                Institution   = institutionName
                            };
                            var orgs = from org in userOrganizations.AsEnumerable()
                                       select new
                            {
                                Name      = org["Name"].ToString(),
                                ShortName = org["ShortName"].ToString()
                            };
                            // get institution where name matches an organization's name or short name
                            var institutions = from inst in allInstitutions
                                               let institutionName = inst.Institution
                                                                     let organization = orgs.Where(org => org.Name == institutionName || org.ShortName == institutionName).FirstOrDefault()
                                                                                        where organization != null
                                                                                        select new
                            {
                                Text  = organization.Name,
                                Value = inst.InstitutionId
                            };

                            // build institutions
                            NewPatientInstitutionSelect.DataSource = institutions;
                            NewPatientInstitutionSelect.DataBind();

                            // set default study id: user's organization
                            // get user's site
                            int userLeadSiteId = userLeadSites.First();
                            // get study id for user's site
                            var userSites = organizationToStudyId.Where(o => o.OrganizationId == userLeadSiteId);
                            autoStudyId = userSites.Count() == 1 ? userSites.First().OrganizationStudyId : "";

                            // update field and select
                            OrganizationStudyIds.Value = autoStudyId;
                            StudyID.Value = autoStudyId;
                        }
                        // show a list of all user's organizations
                        else
                        {
                            if (userOrganizations.Rows.Count > 0)
                            {
                                string organizationName = userOrganizations.Rows[0]["Name"].ToString();
                                int    organizationId   = (int)userOrganizations.Rows[0]["OrganizationId"];

                                // a list of orgaizations associated with the project
                                var organizations = from o in userOrganizations.AsEnumerable()
                                                    let orgId = (int)o["OrganizationId"]
                                                                select
                                                                new
                                {
                                    OrganizationName    = o["Name"].ToString(),
                                    OrganizationId      = orgId,
                                    OrganizationStudyId = GenerateStudyIdByOrganization(protocolId, protocolNum, orgId)
                                };

                                // a list of insitutions where institution = organization in project
                                var allInstitutions = from inst in BOL.BusinessObject.GetAll <Institution>()
                                                      let institutionId = (int)inst[BOL.Institution.InstitutionId]
                                                                          let institutionName = inst[BOL.Institution.Institution_Field].ToString()
                                                                                                select new
                                {
                                    InstitutionId = institutionId,
                                    Institution   = institutionName
                                };
                                var orgs = from org in userOrganizations.AsEnumerable()
                                           select new
                                {
                                    Name      = org["Name"].ToString(),
                                    ShortName = org["ShortName"].ToString()
                                };
                                // get institution where name matches an organization's name or short name
                                var institutions = from inst in allInstitutions
                                                   let institutionName = inst.Institution
                                                                         let organization = orgs.Where(org => org.Name == institutionName || org.ShortName == institutionName).FirstOrDefault()
                                                                                            where organization != null
                                                                                            select new
                                {
                                    Text  = organization.Name,
                                    Value = inst.InstitutionId
                                };

                                // build organizations
                                OrganizationStudyIds.DataSource = organizations;
                                OrganizationStudyIds.DataBind();


                                // build institutions
                                NewPatientInstitutionSelect.DataSource = institutions;
                                NewPatientInstitutionSelect.DataBind();


                                autoStudyId = organizations.Count() == 1? organizations.First().OrganizationStudyId : "";

                                OrganizationStudyIds.Value = autoStudyId;

                                //OrganizationStudyIds.Enabled = false;
                                StudyID.Value = autoStudyId;
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(autoStudyId))
                    {
                        StudyIdError.Visible = true;
                    }
                }

                // default screeing date
                //ScreeningDate.Value = DateTime.Today.ToShortDateString();

                PopulatePhysicians();

                // set search by particpant id type
                SeachTypeParticipantID.Text = PROTOCOL_PARTICIPANT_ID_CODE;

                // default participant id field
                ParticipantIdField.Text = GetNextParticipantId();

                // default radios and panel which can be seen by user
                DetermineUserSearchAccess();
            }
        }
Пример #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DoSave(object sender, EventArgs e)
        {
            try
            {
                if (ValidateForm())
                {
                    // REQUIRED
                    int protocolId = int.Parse(BaseProtocolId);

                    // STEP 1: Get PatientId
                    Patient patient = new Patient();
                    int     ptId    = -1;
                    if (CanViewPatientInfo)
                    {
                        if (AddNewPatient.Checked)
                        {
                            patient[Patient.PtFirstName] = NewFirstName.Value;
                            patient[Patient.PtLastName]  = NewLastName.Value;
                            patient[Patient.PtMRN]       = NewMRN.Value;
                            // If no name or mrn, enter notes to save record
                            patient[Patient.PtNotes] = "Protocol-Patient";
                            // insert records using controller
                            PatientController ct = new PatientController();
                            try
                            {
                                // insert new patient
                                InsertNewPatientRecord(patient);
                            }
                            catch (InvalidScreeningException ex)
                            {
                                throw ex;
                            }
                            // if cannot insert patient, already exits, warn user
                            catch (Exception ex)
                            {
                                throw new InvalidScreeningException("Select a new MRN, another patient with the same MRN already exists in the system.");
                            }
                            //if (patient.RecordCount > 0)
                            if (!patient.IsEmpty)
                            {
                                ptId = int.Parse(patient[Patient.PatientId].ToString());
                            }
                        }
                        // if using existing patient
                        else if (FindExistingPatient.Checked)
                        {
                            if (!string.IsNullOrEmpty(epid.Value))
                            {
                                ptId = int.Parse(DecrypyValue(epid.Value));
                            }
                        }
                    }
                    // if cannnot view PatientInfo, insert blinded info
                    else
                    {
                        patient[Patient.PtFirstName] = string.Empty;
                        patient[Patient.PtLastName]  = string.Empty;
                        patient[Patient.PtMRN]       = string.Empty;
                        patient[Patient.PtNotes]     = "Blinded-Protocol-Patient";

                        // insert new patient
                        InsertNewPatientRecord(patient);

                        //if (patient.RecordCount > 0)
                        if (!patient.IsEmpty)
                        {
                            ptId = int.Parse(patient[Patient.PatientId].ToString());
                        }
                    }

                    // STEP 2: Create ParticipantID (if needed)
                    if (ptId != -1)
                    {
                        if (!PatientProtocolController.HasParticipantId(protocolId, ptId))
                        {
                            PatientProtocolController.CreateParticipantIdIdentifier(protocolId, ptId);
                        }
                    }

                    // VALIDATION: ensure non-duplicate PatientProtocol, via insert new patient
                    int?ptProtocolId = null;
                    var pp           = BusinessObject.GetByFields <PatientProtocol>(
                        new Dictionary <string, object>
                    {
                        { PatientProtocol.ProtocolId, protocolId },
                        { PatientProtocol.PatientId, ptId }
                    }
                        );
                    if (pp.Count() > 0)
                    {
                        ptProtocolId = (int)pp.First()[PatientProtocol.PatientProtocolId];
                    }

                    // STEP 3: Determine Pass or Fail, and create relevent records

                    // If screening failed, create empty PatientProtocol record to track screening
                    if (ScreeningFailed.Checked)
                    {
                        PatientProtocol ptProtocol = new PatientProtocol();
                        if (ptProtocolId.HasValue)
                        {
                            ptProtocol.Get(ptProtocolId.Value);
                        }
                        else
                        {
                            ptProtocol[PatientProtocol.PatientId]             = ptId;
                            ptProtocol[PatientProtocol.ProtocolId]            = protocolId;
                            ptProtocol[PatientProtocol.PtProtocolScreeningId] = PatientProtocolController.GenerateScreeningId();
                            ptProtocol.Save();
                        }
                        PatientProtocolStatus status = new PatientProtocolStatus();
                        status[PatientProtocolStatus.PatientProtocolId] = ptProtocol[PatientProtocol.PatientProtocolId];
                        status[PatientProtocolStatus.PtProtocolStatus]  = PatientProtocolController.ScreeningFailed;

                        DateTime statusDate = DateTime.Today;
                        if (!string.IsNullOrEmpty(ScreeningDate.Value) && DateTime.TryParse(ScreeningDate.Value, out statusDate))
                        {
                            status[PatientProtocolStatus.PtProtocolStatusDate]     = statusDate;
                            status[PatientProtocolStatus.PtProtocolStatusDateText] = statusDate.ToShortDateString();
                        }
                        else
                        {
                            status[PatientProtocolStatus.PtProtocolStatusDate]     = DateTime.Today;
                            status[PatientProtocolStatus.PtProtocolStatusDateText] = DateTime.Today.ToShortDateString();
                        }
                        status[PatientProtocolStatus.PtProtocolStatusReason] = ReasonFailed.Value;
                        status[PatientProtocolStatus.PtProtocolStatusNotes]  = ReasonFailedNotes.Value;
                        status.Save();
                    }
                    // If screening passed, create necessary records
                    else if (ScreeningPassed.Checked)
                    {
                        // Create PatientProtocol for Patient
                        PatientProtocol ptProtocol = new PatientProtocol();
                        if (ptProtocolId.HasValue)
                        {
                            ptProtocol.Get(ptProtocolId.Value);
                            bool doUpdate = false;
                            // update/ insert fields
                            if (ptProtocol.IsNull(PatientProtocol.PtProtocolStudyId))
                            {
                                ptProtocol[PatientProtocol.PtProtocolStudyId] = StudyID.Value;
                                doUpdate = true;
                            }
                            if (ptProtocol.IsNull(PatientProtocol.PtProtocolScreeningId))
                            {
                                ptProtocol[PatientProtocol.PtProtocolScreeningId] = PatientProtocolController.GenerateScreeningId();
                                doUpdate = true;
                            }
                            if (doUpdate)
                            {
                                ptProtocol.Save();
                            }
                        }
                        else
                        {
                            ptProtocol[PatientProtocol.ProtocolId]            = protocolId;
                            ptProtocol[PatientProtocol.PatientId]             = ptId;
                            ptProtocol[PatientProtocol.PtProtocolScreeningId] = PatientProtocolController.GenerateScreeningId();
                            ptProtocol[PatientProtocol.PtProtocolStudyId]     = StudyID.Value;
                            ptProtocol.Save();
                        }

                        // CREATE STUDY ID IDENTIFIER
                        PatientProtocolController.CreateStudyIdIdentifier((int)ptProtocol[ptProtocol.PrimaryKeyName]);

                        // Create Registration Record
                        PatientProtocolRegistration registrationRecord = new PatientProtocolRegistration();
                        registrationRecord[PatientProtocolRegistration.PatientProtocolId] = ptProtocol[PatientProtocol.PatientProtocolId];
                        registrationRecord[PatientProtocolRegistration.ConsentedTo]       = " ";
                        registrationRecord.Save();

                        PatientProtocolStatus status = new PatientProtocolStatus();
                        status[PatientProtocolStatus.PatientProtocolId] = ptProtocol[PatientProtocol.PatientProtocolId];
                        status[PatientProtocolStatus.PtProtocolStatus]  = PatientProtocolController.ScreeningPassed;
                        DateTime statusDate = DateTime.Today;
                        if (!string.IsNullOrEmpty(ScreeningDate.Value) && DateTime.TryParse(ScreeningDate.Value, out statusDate))
                        {
                            status[PatientProtocolStatus.PtProtocolStatusDate]     = statusDate;
                            status[PatientProtocolStatus.PtProtocolStatusDateText] = statusDate.ToShortDateString();
                        }
                        else
                        {
                            status[PatientProtocolStatus.PtProtocolStatusDate]     = DateTime.Today;
                            status[PatientProtocolStatus.PtProtocolStatusDateText] = DateTime.Today.ToShortDateString();
                        }
                        status[PatientProtocolStatus.PtProtocolStatusNotes] = StudyNodes.Value;
                        status.Save();
                    }

                    // STEP 4: Register Client Script events

                    // Save and Close
                    if (sender == SaveBtn)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "saveAndClose", "saveAndClose();", true);
                    }
                    // Save and Load Registration Interface
                    else if (sender == ContinueBtn)
                    {
                        string script = "if(parent.patientAssigned) { parent.patientAssigned('" + protocolId + "','','" + EncryptValue(ptId.ToString()) + "'); }";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "OnPatientAssigned", script, true);
                    }
                    ErrorMessage.Text = "";
                }
            }
            catch (InvalidScreeningException invalidFormException)
            {
                ErrorMessage.Text = "Error:&nbsp;&nbsp;" + invalidFormException.Message;
            }
        }