/// <summary>
        /// Get a list of field filters for export
        /// </summary>
        private void BuildExportTableFilters()
        {
            int    protocolId  = int.Parse(QueryProtocolId);
            string datasetSQL  = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            bool   unmaskDates = UnmaskedCheck.Checked;
            // get a list of tables and filters
            Dictionary <string, List <string> > filtersByTable = ProtocolMgmtServices.GetDataExportFilters(datasetSQL, protocolId, unmaskDates);
            IEnumerable <CaisisCheckBoxList>    inputs         = PageUtil.GetControls <CaisisCheckBoxList>(PatientPanel_Filters);

            // data bind checkbox lists to values
            foreach (CaisisCheckBoxList input in inputs)
            {
                if (filtersByTable.ContainsKey(input.Table))
                {
                    // tmp fix
                    input.PreRender += new CaisisEventHandler(input_PreRender);
                    input.DataSource = filtersByTable[input.Table];
                    input.DataBind();
                }
            }
            // static binding for Encounters filter
            string encountersTable = new BOL.Encounter().TableName;
            var    encounterFields = from field in service.GetFieldNames(encountersTable)
                                     let name                         = field.Key
                                                            let label = pdec.GetFieldLabel(encountersTable, name)
                                                                        orderby label ascending
                                                                        select new
            {
                FieldName  = name,
                FieldLabel = label
            };

            Encounters_Filter.DataSource = encounterFields;
            Encounters_Filter.DataBind();
        }
Exemplo n.º 2
0
        public override void Populate()
        {
            // determine lab at diagnosis
            LabTest diagnosisPSA = ProtocolMgmtServices.GetBaselinePSA(base.patientId);

            // populate
            if (diagnosisPSA != null)
            {
                // set key
                LabTestIdField.Value = diagnosisPSA[BOL.LabTest.LabTestId] + "";
                // populate fields
                CICHelper.SetFieldValues(this.Controls, diagnosisPSA);
            }
        }
Exemplo n.º 3
0
        private Procedure GetBaselineBiopsy()
        {
            // 1st pass: first baseline Biopsy procedure
            Procedure baselineBiopsy = ProtocolMgmtServices.GetBaselineBiopsy(base.patientId);

            if (baselineBiopsy != null)
            {
                return(baselineBiopsy);
            }
            // 2nd pass: if no biopsy found, use diagnostic biopsy
            else
            {
                Procedure diagnosticProcedure = BOL.ProtocolMgmtServices.GetDiagnosticBiopsy(patientId);
                return(diagnosticProcedure);
            }
        }
        private Dictionary <string, List <Dictionary <string, object> > > GetExportTableRestrictions(IEnumerable <string> tables)
        {
            int    protocolId  = int.Parse(QueryProtocolId);
            string datasetSQL  = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            bool   unmaskDates = UnmaskedCheck.Checked;
            // get a list of tables and filters
            Dictionary <string, List <string> > filtersByTable = ProtocolMgmtServices.GetDataExportFilters(datasetSQL, protocolId, unmaskDates);
            Dictionary <string, List <Dictionary <string, object> > > tableToListOfRestrictions = new Dictionary <string, List <Dictionary <string, object> > >();
            IEnumerable <CaisisCheckBoxList> inputs   = PageUtil.GetControls <CaisisCheckBoxList>(PatientPanel_Filters);
            IEnumerable <string>             formKeys = Request.Form.Keys.Cast <string>();

            foreach (CaisisCheckBoxList input in inputs)
            {
                string   formInputName    = input.Table + "_Filter";
                string[] formExcludeNames = new string[] { input.Table + "_FilterCheckBox", input.Table + "_FilterTextBoxKey" };
                // check for values POSTed
                int  selectedCount  = formKeys.Where(k => k.StartsWith(formInputName)).Except(formExcludeNames).Count();
                bool addRestriction = filtersByTable.ContainsKey(input.Table) && selectedCount > 0 ? filtersByTable[input.Table].Count() != selectedCount : false;
                // manually add each restriction if 1-(n-1) items selected
                if (addRestriction)
                {
                    string   table         = input.Table;
                    string   field         = input.Field;
                    string[] field_filters = input.ValueList;
                    if (field_filters.Length > 0)
                    {
                        if (tables.Contains(table))
                        {
                            var filterList = new List <Dictionary <string, object> >();
                            foreach (string field_filter in field_filters)
                            {
                                filterList.Add(new Dictionary <string, object> {
                                    { field, field_filter }
                                });
                            }
                            tableToListOfRestrictions.Add(table, filterList);
                        }
                    }
                }
            }
            return(tableToListOfRestrictions);
        }
Exemplo n.º 5
0
        protected void SetFieldValues(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                // get Status and Bizo (optional)
                string status = DataBinder.Eval(e.Item.DataItem, "Status").ToString();
                Status biz    = DataBinder.Eval(e.Item.DataItem, "Bizo") as Status;

                var                 inputs              = CICHelper.GetCaisisInputControls(e.Item);
                HiddenField         statusIdField       = e.Item.FindControl("StatusId_Field") as HiddenField;
                ICaisisInputControl statusDateTextField = e.Item.FindControl("StatusDateText") as ICaisisInputControl;
                ICaisisInputControl statusDateField     = e.Item.FindControl("StatusDate") as ICaisisInputControl;
                ICaisisInputControl statusField         = e.Item.FindControl("Status") as ICaisisInputControl;
                HtmlTableRow        rowElement          = e.Item.FindControl("DataRecordRow") as HtmlTableRow;
                Control             clearBtn            = e.Item.FindControl("ClearBtn");
                Control             lockImg             = e.Item.FindControl("LockImage");
                clearBtn.Visible = false;
                lockImg.Visible  = false;

                // populate
                statusField.Value = status;

                if (biz != null)
                {
                    // populate fields
                    CICHelper.SetFieldValues(inputs, biz);
                    // set key field
                    statusIdField.Value = biz[Status.StatusId] + "";

                    bool lockedByRecord = (biz[Status.LockedBy] + "") != "";
                    if (lockedByRecord)
                    {
                        CICHelper.EnableFields(e.Item.Controls, false);
                    }
                    lockImg.Visible  = lockedByRecord;
                    clearBtn.Visible = false;
                }
                // new records
                else
                {
                    statusIdField.Value = "";
                    lockImg.Visible     = false;
                    clearBtn.Visible    = true;

                    // SPECIAL CASE: if calculated diagnosis date, lock status
                    if (status == "Diagnosis Date")
                    {
                        DateTime?diagnosisDate = ProtocolMgmtServices.GetDateOfDiagnosis(patientId);
                        if (diagnosisDate.HasValue)
                        {
                            CICHelper.EnableFields(e.Item.Controls, false);
                            string displayDate = string.Format("{0:d}", diagnosisDate);
                            statusDateField.Value     = displayDate;
                            statusDateTextField.Value = displayDate;

                            lockImg.Visible  = true;
                            clearBtn.Visible = false;
                        }
                    }
                }
            }
        }
        private void PreviewExportProtocolPatients(int protocolId)
        {
            string datasetSQL         = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]);
            bool   canViewIdentifiers = new Caisis.Controller.UserController().CanViewPatientIdentifiers();
            bool   includeDeceased    = ExportProtocolIncludeDeceased.Checked;
            bool   unmaskedDates      = UnmaskedCheck.Checked;

            // get all patients on protocol
            var allPatients      = Caisis.DataAccess.ProtocolMgmtDa.GetPatientsByProtocol(protocolId, datasetSQL, canViewIdentifiers, includeDeceased);
            var eligiblePatients = ProtocolMgmtServices.GetEligibleProtocolExportPatients(datasetSQL, protocolId, unmaskedDates);
            // create view of data, validating exportable patients
            var exportPatientsView = from record in allPatients.AsEnumerable()
                                     let ptProtocolId = (int)record[PatientProtocol.PatientProtocolId]
                                                        let patientId                                                     = (int)record["PatientId"]
                                                                                             let name                     = record["Name"].ToString()
                                                                                                                  let mrn = record["PtMRN"].ToString()
                                                                                                                            let screeningId = record["PtProtocolScreeningId"].ToString()
                                                                                                                                              let studyId = record["PtProtocolStudyId"].ToString()
                                                                                                                                                            let schemaId = record["ProtocolSchemaId"].ToString()
                                                                                                                                                                           let schema = GetSchemaName(schemaId)
                                                                                                                                                                                        let eligibleRecord = eligiblePatients.Select(PatientProtocol.PatientProtocolId + " = " + ptProtocolId).FirstOrDefault()
                                                                                                                                                                                                             let isExportable                         = eligibleRecord != null
                                                                                                                                                                                                                                            let ptAge = isExportable ? eligibleRecord[PatientProtocolRegistration.PtRegistrationAge].ToString() : ""
                                                                                                                                                                                                                                                        let passedScreeningDate = isExportable ? (DateTime?)eligibleRecord["PassedScreeningDate"] : null
                                                                                                                                                                                                                                                                                  orderby name ascending// isExportable ? 0 : 1 ascending, studyId ascending
                                                                                                                                                                                                                                                                                  select new
            {
                Exportable          = isExportable ? "Yes" : "No",
                PatientId           = patientId,
                Arm                 = schema,
                Name                = name,
                MRN                 = mrn,
                RegistrationAge     = ptAge,
                ScreeningId         = screeningId,
                StudyId             = studyId,
                PassedScreeningDate = string.Format("{0:d}", passedScreeningDate)
            };

            ExportProtocolPatientsControls.Visible = true;
            ExportProtocolPatientsBtns.Visible     = true;

            // set count
            int totalPatientsCount    = exportPatientsView.Count();
            int eligiblePatientsCount = exportPatientsView.Where(p => p.Exportable == "Yes").Count();

            ExportPatientCount.Text = string.Format("<b>{0}</b> of <b>{1}</b> patients eligible for export.", eligiblePatientsCount, totalPatientsCount);

            // build patient export preview
            DataPreview.DataKeyNames = new string[] { Patient.PatientId };
            DataPreview.DataSource   = exportPatientsView;
            DataPreview.DataBind();
            DataPreview.Columns[0].Visible = true;

            // build patient export tables
            var exportTableNames = from table in ProtocolMgmtServices.GetPatientTableNames()
                                   let label = pdec.GetTableLabel(table)
                                               orderby table == "Patients" ? 0 : 1 ascending, label ascending
                select new
            {
                TableName  = table,
                TableLabel = string.Format("{0} [{1}]", label, table)
            };

            ExportTableNames.DataSource = exportTableNames;
            ExportTableNames.DataBind();

            // set header
            SetProtocolTitle(protocolId);

            // set dataset
            var dataset = new BOL.Dataset();

            dataset.Get(int.Parse(Session[SessionKey.DatasetId].ToString()));
            string datasetName = dataset[BOL.Dataset.DatasetName].ToString();

            CurrentDataset.Text = datasetName;

            // set filter text
            MaskedDatesPanel.Visible   = !unmaskedDates;
            UnmaskedDatesPanel.Visible = unmaskedDates;
        }