/// <summary>
        ///
        /// </summary>
        /// <param name="biz"></param>
        /// <returns></returns>
        protected string GetItemStatus(PatientItem biz)
        {
            string defaultStatus = "Anticipated";
            string status        = biz[PatientItem.Status].ToString();

            return(!string.IsNullOrEmpty(status) ? status : defaultStatus);
        }
示例#2
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();
        }
 public ExamPage(PatientItem PatientSelected)
 {
     examViewModel = new ExamViewModel();
     InitializeComponent();
     BindingContext            = examViewModel;
     examViewModel.PatientItem = PatientSelected;
     startExam();
 }
        /// <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();
            }
        }
        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);
            }
        }
        public ReviewTestHomePage(PatientItem patientItem)
        {
            currentPatient = patientItem;

            InitializeComponent();
            title.Text  = "Exam Review: " + currentPatient.FirstName + " " + currentPatient.LastName;
            testResults = getResults();
            ReviewTestList.ItemsSource = testResults;
        }
示例#7
0
 public PatientDashboardPage(PatientItem patientItem)
 {
     InitializeComponent();
     BindingContext    = patientItem;
     currentPatient    = patientItem;
     MyLineChart.Chart = new LineChart {
         Entries = GetResults()
     };
 }
        /// <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();
        }
 protected void UpdateItemClick(object sender, EventArgs e)
 {
     if (PatientItemId.HasValue)
     {
         PatientItem patientItem = new PatientItem();
         patientItem.Get(PatientItemId.Value);
         CICHelper.SetBOValues(PatientItemFields.Controls, patientItem, -1);
         patientItem.Save();
         RegisterUpdateScript(true);
     }
 }
 public UpdatePatient(PatientItem patient = null)
 {
     InitializeComponent();
     if (patient != null)
     {
         patientId              = patient.Id;
         tbName.Text            = patient.Name;
         tbAddress.Text         = patient.Address;
         tbPhone.Text           = patient.Phone;
         cbGender.SelectedIndex = patient.Gender == "♂" ? 0 : 1;
     }
 }
        private void BuildPatientItem(int patientItemId)
        {
            PatientItem patientItem = new PatientItem();

            patientItem.Get(patientItemId);
            var inputs = CICHelper.GetCaisisInputControls(PatientItemFields);

            foreach (var input in inputs)
            {
                input.Value = string.Format(input.Field.EndsWith("Date") ? "{0:d}" : "{0}", patientItem[input.Field]);
            }
        }
示例#12
0
        private void PatientsList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            SelectedPatientGrid.Children.Clear();
            PatientSelected = e.SelectedItem as PatientItem;

            PatientsList.ItemsSource = null;
            SelectedLabel.Text       = "Selected Patient: ";
            var selectedPatient = e.SelectedItem as PatientItem;

            Label firstName = new Label {
                Text = "First Name: ", FontAttributes = FontAttributes.Bold
            };
            Label PatientFirstName = new Label {
                Text = selectedPatient.FirstName
            };

            SelectedPatientGrid.Children.Add(firstName, 0, 0);
            SelectedPatientGrid.Children.Add(PatientFirstName, 1, 0);

            Label lastName = new Label {
                Text = "Last Name: ", FontAttributes = FontAttributes.Bold
            };
            Label PatientLastName = new Label {
                Text = selectedPatient.LastName
            };

            SelectedPatientGrid.Children.Add(lastName, 0, 1);
            SelectedPatientGrid.Children.Add(PatientLastName, 1, 1);

            Label Dob = new Label {
                Text = "Date of Birth: ", FontAttributes = FontAttributes.Bold
            };
            Label PatientDob = new Label {
                Text = selectedPatient.PatientDOB.Date.ToString()
            };

            SelectedPatientGrid.Children.Add(Dob, 0, 2);
            SelectedPatientGrid.Children.Add(PatientDob, 1, 2);

            Label lastExam = new Label {
                Text = "Last Exam Date: ", FontAttributes = FontAttributes.Bold
            };
            Label PatientLastExam = new Label {
                Text = selectedPatient.LastTestDate.Date.ToString()
            };

            SelectedPatientGrid.Children.Add(lastExam, 0, 3);
            SelectedPatientGrid.Children.Add(PatientLastExam, 1, 3);
        }
示例#13
0
        /// <summary>
        /// Saves/Updates the current PatientDeviation record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
            // Update/Insert PatientItem
            PatientItem patientItem = new PatientItem();

            // update
            if (!string.IsNullOrEmpty(PatientItemId.Value))
            {
                patientItem.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
            }
            // inserting
            else
            {
                patientItem[PatientItem.PatientSchemaId] = PatientSchemaId;
            }
            patientItem[PatientItem.ScheduledDate] = ScheduledDate.Value;
            patientItem[PatientItem.Status]        = "Unplanned";
            patientItem.Save();
            int patientItemId = (int)patientItem[PatientItem.PatientItemId];

            PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

            // Update/insert deviation
            PatientDeviation deviation = new PatientDeviation();

            // update
            if (!string.IsNullOrEmpty(PatientDeviationId.Value))
            {
                deviation.Get(int.Parse(PatientDeviationId.Value));
            }
            // insert
            else
            {
                deviation[PatientDeviation.PatientItemId] = patientItemId;
            }
            // set biz object values, update and reload form
            CICHelper.SetBOValues(this.Controls, deviation, patientItemId);
            deviation[PatientDeviation.PatientItemId] = patientItemId;
            deviation.Save();
            PatientDeviationId.Value = deviation[PatientDeviation.PatientDeviationId].ToString();

            // update fields
            PopulateForm();

            // notify client scripts
            RegisterUpdateScript(false);
        }
示例#14
0
        /// <summary>
        /// Populates the PatienItem
        /// </summary>
        /// <param name="pItemId"></param>
        private void PopulatePatientItem(int pItemId)
        {
            PatientItem biz = new PatientItem();

            biz.Get(pItemId);

            // ScheduledDate.Text = ((DateTime)biz[PatientItem.ScheduledDate]).ToShortDateString();
            object dt = biz[PatientItem.ScheduledDate];

            if (dt != null && !String.IsNullOrEmpty(dt.ToString()))
            {
                ScheduledDate.Text = ((DateTime)dt).ToShortDateString();
            }

            StatusField.Value = biz[PatientItem.Status].ToString();
            ItemStatus        = GetItemStatus(biz);

            // register client buffer dates
            string clientDateFormatString = "new Date('{0}')";
            object firstDate = biz[PatientItem.FirstAnticipatedDate];
            object lastDate  = biz[PatientItem.LastAnticipatedDate];

            if (firstDate != null && !string.IsNullOrEmpty(firstDate.ToString()))
            {
                DateTime date      = (DateTime)firstDate;
                string   shortDate = date.ToShortDateString();
                FirstAnticipatedClientDate    = string.Format(clientDateFormatString, shortDate);
                FirstAnticipatedDateText.Text = shortDate;
            }
            else
            {
                FirstAnticipatedClientDate    = "null";
                FirstAnticipatedDateText.Text = string.Empty;
            }
            if (lastDate != null && !string.IsNullOrEmpty(lastDate.ToString()))
            {
                DateTime date      = (DateTime)lastDate;
                string   shortDate = date.ToShortDateString();
                LastAnticipatedClientDate    = string.Format(clientDateFormatString, shortDate);
                LastAnticipatedDateText.Text = shortDate;
            }
            else
            {
                LastAnticipatedClientDate    = "null";
                LastAnticipatedDateText.Text = string.Empty;
            }
        }
示例#15
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);
            }
        }
示例#16
0
        /// <summary>
        /// Populates the fiels on this form with a PatientDevaition record
        /// </summary>
        private void PopulateForm()
        {
            if (!string.IsNullOrEmpty(PatientItemId.Value))
            {
                // Populate patient item scheduled field
                int         patientItemId = int.Parse(base.DecrypyValue(PatientItemId.Value));
                PatientItem item          = new PatientItem();
                item.Get(patientItemId);
                if (item[PatientItem.ScheduledDate] != null && item[PatientItem.ScheduledDate].ToString() != "")
                {
                    string sDate = ((DateTime)item[PatientItem.ScheduledDate]).ToShortDateString();
                    ScheduledDate.Value     = sDate;
                    ScheduledDateText.Value = sDate;
                }

                // populate deviation
                if (!string.IsNullOrEmpty(PatientDeviationId.Value))
                {
                    int pdi = int.Parse(PatientDeviationId.Value);
                    PatientDeviation deviation = new PatientDeviation();
                    deviation.Get(pdi);
                    base.PopulateForm(deviation);
                    // cleanup date field display
                    var inputs = PageUtil.GetCaisisInputControlsInContainer(this);
                    foreach (var input in inputs)
                    {
                        if (input.Table == "ProtocolMgr_PatientDeviations" && input.Field.Contains("DeviationDate"))
                        {
                            if (!deviation.IsNull(input.Field))
                            {
                                input.Value = string.Format("{0:d}", deviation[input.Field]);
                            }
                        }
                    }
                }
            }
        }
示例#17
0
        public async Task QueryTest()
        {
            var testNumber = 123456;

            // Create a test workspace
            _workspaceItemOne = await TestHelper.CreateWorkspaceAsync(_testClassName, testNumber);

            // Create a test patient
            _patientOne = await TestHelper.CreatePatientAsync(_testClassName, testNumber, Path.Combine("Becker^Matthew", "RD.dcm"));

            await TestHelper.DeleteWorkspacesAsync(_workspaceItemOne.Name);

            var json = await _proKnow.Requestor.GetAsync($"/user");

            var userItem = JsonSerializer.Deserialize <UserItem>(json);

            FilterParameters filterParams = new FilterParameters();

            filterParams.PageSize    = 1;
            filterParams.Types       = new string[] { "patient_read", "workspace_deleted" };
            filterParams.WorkspaceId = _workspaceItemOne.Id;
            var auditPage = await _proKnow.Audit.Query(filterParams);

            Assert.AreEqual(auditPage.Total, (uint)2);

            var patientItem = auditPage.Items[0];

            Assert.AreEqual(patientItem.Classification, "HTTP");
            Assert.AreEqual(patientItem.Method, "DELETE");
            Assert.AreEqual(patientItem.PatientId, null);
            Assert.AreEqual(patientItem.PatientMrn, null);
            Assert.AreEqual(patientItem.PatientName, null);
            Assert.AreEqual(patientItem.ResourceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(patientItem.ResourceName, _workspaceItemOne.Name);
            Assert.AreEqual(patientItem.StatusCode, "200");
            Assert.AreEqual(patientItem.Uri, $"/workspaces/{_workspaceItemOne.Id}");
            Assert.AreEqual(patientItem.UserName, userItem.Name);
            Assert.AreEqual(patientItem.WorkspaceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(patientItem.WorkspaceName, null);

            var audit2Page = await auditPage.Next();

            Assert.AreEqual(audit2Page.Total, (uint)2);

            var nextPatientItem = audit2Page.Items[0];

            Assert.AreEqual(nextPatientItem.Classification, "HTTP");
            Assert.AreEqual(nextPatientItem.Method, "GET");
            Assert.AreEqual(nextPatientItem.PatientId, $"{_patientOne.Id}");
            Assert.AreEqual(nextPatientItem.PatientMrn, "123456-Mrn");
            Assert.AreEqual(nextPatientItem.PatientName, "123456-Name");
            Assert.AreEqual(nextPatientItem.ResourceId, $"{_patientOne.Id}");
            Assert.AreEqual(nextPatientItem.ResourceName, "123456-Name");
            Assert.AreEqual(nextPatientItem.StatusCode, "200");
            Assert.AreEqual(nextPatientItem.Uri, $"/workspaces/{_workspaceItemOne.Id}/patients/{_patientOne.Id}");
            Assert.AreEqual(nextPatientItem.UserName, userItem.Name);
            Assert.AreEqual(nextPatientItem.WorkspaceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(nextPatientItem.WorkspaceName, $"{_workspaceItemOne.Name}");

            //Call Next() on auditPage to verify it still retrieves Page 2 data
            var audit2PageAgain = await auditPage.Next();

            Assert.AreEqual(audit2PageAgain.Total, (uint)2);

            var lastPatientItem = audit2PageAgain.Items[0];

            Assert.AreEqual(lastPatientItem.Classification, "HTTP");
            Assert.AreEqual(lastPatientItem.Method, "GET");
            Assert.AreEqual(lastPatientItem.PatientId, $"{_patientOne.Id}");
            Assert.AreEqual(lastPatientItem.PatientMrn, "123456-Mrn");
            Assert.AreEqual(lastPatientItem.PatientName, "123456-Name");
            Assert.AreEqual(lastPatientItem.ResourceId, $"{_patientOne.Id}");
            Assert.AreEqual(lastPatientItem.ResourceName, "123456-Name");
            Assert.AreEqual(lastPatientItem.StatusCode, "200");
            Assert.AreEqual(lastPatientItem.Uri, $"/workspaces/{_workspaceItemOne.Id}/patients/{_patientOne.Id}");
            Assert.AreEqual(lastPatientItem.UserName, userItem.Name);
            Assert.AreEqual(lastPatientItem.WorkspaceId, $"{_workspaceItemOne.Id}");
            Assert.AreEqual(lastPatientItem.WorkspaceName, $"{_workspaceItemOne.Name}");
        }
示例#18
0
        private void PatientGallery_SelectionChanged(object sender, EventArgs e)
        {
            PatientItem item = (PatientItem)_gvPatients.Selection.Item;

            this.SelectedPatient = item;
        }
示例#19
0
            protected override DragDropOption PerformDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
            {
                PatientItem    patient = (PatientItem)targetItem;
                DragDropOption action  = DragDropOption.None;

                foreach (IGalleryItem droppingItem in droppingItems)
                {
                    if (droppingItem is StudyItem)
                    {
                        StudyItem study = (StudyItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            if (!patient.Studies.Contains(study))
                            {
                                patient.Studies.Add(study.Copy());
                                action = DragDropOption.Move;
                            }
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            patient.Studies.Add(study.Copy());
                            action = DragDropOption.Copy;
                        }
                    }
                    else if (droppingItem is SeriesItem)
                    {
                        SeriesItem series = (SeriesItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            StudyNode   studyNode   = (StudyNode)GetNodeAncestor(series.Node, 1);
                            PatientNode patientNode = (PatientNode)GetNodeAncestor(studyNode, 1);
                            if (patient.Node != patientNode)
                            {
                                StudyItem study = new StudyItem(studyNode.Copy(false));
                                study.Series.Add(series.Copy());
                                study.UpdateIcon();
                                patient.Studies.Add(study);
                                action = DragDropOption.Move;
                            }
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            StudyNode studyNode = (StudyNode)GetNodeAncestor(series.Node, 1);
                            StudyItem study     = new StudyItem(studyNode.Copy(false));
                            study.Series.Add(series.Copy());
                            study.UpdateIcon();
                            patient.Studies.Add(study);
                            action = DragDropOption.Copy;
                        }
                    }
                    else if (droppingItem is ImageItem)
                    {
                        ImageItem image = (ImageItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            SeriesNode  seriesNode  = (SeriesNode)GetNodeAncestor(image.Node, 1);
                            StudyNode   studyNode   = (StudyNode)GetNodeAncestor(seriesNode, 1);
                            PatientNode patientNode = (PatientNode)GetNodeAncestor(studyNode, 1);
                            if (patient.Node != patientNode)
                            {
                                SeriesItem series = new SeriesItem(seriesNode.Copy(false));
                                StudyItem  study  = new StudyItem(studyNode.Copy(false));
                                series.Images.Add(image.Copy());
                                series.UpdateIcon();
                                study.Series.Add(series);
                                study.UpdateIcon();
                                patient.Studies.Add(study);
                                action = DragDropOption.Move;
                            }
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            SeriesNode seriesNode = (SeriesNode)GetNodeAncestor(image.Node, 1);
                            StudyNode  studyNode  = (StudyNode)GetNodeAncestor(seriesNode, 1);
                            SeriesItem series     = new SeriesItem(seriesNode.Copy(false));
                            StudyItem  study      = new StudyItem(studyNode.Copy(false));
                            series.Images.Add(image.Copy());
                            series.UpdateIcon();
                            study.Series.Add(series);
                            study.UpdateIcon();
                            patient.Studies.Add(study);
                            action = DragDropOption.Copy;
                        }
                    }
                }
                return(action);
            }
示例#20
0
            protected override DragDropOption CheckDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
            {
                PatientItem patient = (PatientItem)targetItem;
                bool        allowed = true;

                foreach (IGalleryItem droppingItem in droppingItems)
                {
                    if (droppingItem is StudyItem)
                    {
                        StudyItem study = (StudyItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            allowed &= !(patient.Studies.Contains(study));                             // disallow moves where the item is already in the target tree
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            allowed &= true;
                        }
                    }
                    else if (droppingItem is SeriesItem)
                    {
                        SeriesItem series = (SeriesItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            allowed &= (patient.Node != GetNodeAncestor(series.Node, 2));                             // disallow moves where the item is already in the target tree
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            allowed &= true;
                        }
                    }
                    else if (droppingItem is ImageItem)
                    {
                        ImageItem image = (ImageItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            allowed &= (patient.Node != GetNodeAncestor(image.Node, 3));                             // disallow moves where the item is already in the target tree
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            allowed &= true;
                        }
                    }
                    else
                    {
                        allowed &= false;
                    }
                }

                if (allowed)
                {
                    if (modifiers == ModifierFlags.None)
                    {
                        return(DragDropOption.Move);
                    }
                    else if (modifiers == ModifierFlags.Shift)
                    {
                        return(DragDropOption.Copy);
                    }
                }
                return(DragDropOption.None);
            }