示例#1
0
 /// <summary>
 /// 按下删除按钮。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     NavigatorPage.MsgSystem.Show((s, r) => {
         if (r.CheckIndex == 0)
         {
             //执行删除操作并回退。
             var res = args.api[args.url][args.instance].Destroy();
             if (res.statuslike("204"))
             {
                 if (args.deleteaction == null)
                 {
                     if (NavigatorPage.Get().NavigationService.CanGoBack)
                     {
                         NavigatorPage.Get().NavigationService.GoBack();
                     }
                 }
                 else
                 {
                     args.deleteaction();
                 }
             }
             else
             {
                 NavigatorPage.MsgSystem.Show(null, "错误", res.content);
             }
         }
     }, "确认", "你确定要删除该条目吗?", buttonname: new string[] { "是", "否" });
 }
示例#2
0
 private void ShowBeforePage(NavigatorPage page, bool show, NavigatorPage insertBeforePage)
 {
     if (show)
     {
         if (this.Pages.Contains(page) == false)
         {
             if (insertBeforePage == null)
             {
                 this.Pages.Add(page);
             }
             else
             {
                 var index = this.Pages.IndexOf(insertBeforePage);
                 this.Pages.Insert(index, page);
             }
         }
     }
     else
     {
         if (this.Pages.Contains(page))
         {
             this.Pages.Remove(page);
         }
     }
 }
示例#3
0
        private void ShowPage(NavigatorPage page)
        {
            // get the control to show
            Control toShow = (Control)_component.GetPageView(page).GuiElement;

            // hide all others
            foreach (Control c in _contentPanel.Controls)
            {
                if (c != toShow)
                {
                    c.Visible = false;
                }
            }

            // if the control has not been added to the content panel, add it now
            if (!_contentPanel.Controls.Contains(toShow))
            {
                toShow.Dock = DockStyle.Fill;
                _contentPanel.Controls.Add(toShow);
            }

            toShow.Visible = true;

            // HACK: for some reason the error provider symbols don't show up the first time the control is shown
            // therefore we need to force it
            if (toShow is ApplicationComponentUserControl)
            {
                (toShow as ApplicationComponentUserControl).ErrorProvider.UpdateBinding();
            }

            // set the title and selected tree node
            _titleBar.Text         = page.Path.LastSegment.LocalizedText;
            _treeView.SelectedNode = _nodeMap[page];
        }
示例#4
0
 private void HyperlinkToStudent(JToken j)
 {
     NavigatorPage.NavigatorGoto("student-other-document", new Dictionary <string, object>()
     {
         { "id", j["id"].ToString() }
     });
 }
        public override void NavigatedToEvent(object sender, IDictionary <string, object> kwargs)
        {
            base.NavigatedToEvent(sender, kwargs);
            if (kwargs != null)
            {
                ID = kwargs["id"] as string;
            }
            if (ID != null)
            {
                template.Args.instance = ID;
                template.UpdateData();

                //修改按钮。
                template.Args.custombutton = new CustomButton[0];
                if (User.Get().HasAuthorityOrRoot(Authority.UserManage))
                {
                    template.Args.custombutton = template.Args.custombutton.append(new CustomButton("", () => {
                        NavigatorPage.NavigatorGoto("basic-manager-document", new Dictionary <string, object>()
                        {
                            { "id", ID }
                        });
                    }));
                }
                template.ConstructCustomButton();
            }
        }
        private void update_data(JArray datas)
        {
            var brush_white = new SolidColorBrush(Colors.White);
            var brush_gray  = new SolidColorBrush(Colors.LightGray);

            Items.Clear();
            int index = 0;

            foreach (var data in datas)
            {
                //构造每一个条目的记录。
                var row     = new ListTemplateItem();
                var objects = new UIElement[args.columns.Count];
                for (int i = 0; i < objects.Length; ++i)  //构造一条记录的每一个项。
                {
                    var c    = args.columns[i];
                    var item = new TextBlock();
                    item.HorizontalAlignment = HorizontalAlignment.Left;
                    item.VerticalAlignment   = VerticalAlignment.Center;
                    item.FontSize            = c.fontsize ?? args.fontsize;
                    item.Margin = c.margin ?? args.margin;
                    JToken jdata = data[c.name];
                    //按类型创建UI内容。
                    if (c.type == "text")
                    {
                        item.Text = jdata.ToString();
                    }
                    else if (c.type == "custom")
                    {
                        item.Text = (c.data as Func <JToken, string>)(jdata);
                    }
                    else if (c.type == "choice")
                    {
                        item.Text = (c.data as IDictionary <string, string>)[jdata.ToString()];
                    }
                    if (c.customaction != null)
                    {
                        item.PreviewMouseLeftButtonDown += (s, e) => {
                            c.customaction(data);
                        };
                    }
                    if (c.hyperlink != null)
                    {
                        var goal = c.hyperlink(data);                  //局部闭包
                        item.PreviewMouseLeftButtonDown += (s, e) => { //点击超链接事件。
                            NavigatorPage.NavigatorGoto(goal.Item1, goal.Item2);
                        };
                    }
                    objects[i] = item;
                }
                row.SetChildren(gridlength, objects);
                row.Background = index % 2 == 0 ? brush_gray : brush_white;
                //itemlist[index] = row;
                Items.Add(row);
                ++index;
            }
        }
示例#7
0
        private void RemoveTreeNode(NavigatorPage page)
        {
            // find node in map and remove it
            TreeNode node = _nodeMap[page];

            _nodeMap.Remove(page);

            // remove node from tree, recursively removing parent nodes if empty
            RemoveNode(node);
        }
示例#8
0
        public override void NavigatedToEvent(object sender, IDictionary <string, object> kwargs)
        {
            base.NavigatedToEvent(sender, kwargs);
            if (ID != null)
            {
                template.Args.instance = ID;
                template.UpdateData();
                //更新按钮。
                template.Args.custombutton = new CustomButton[0];
                if (User.Get().HasAuthorityOrRoot(Authority.CourseManage))
                {
                    template.Args.custombutton = template.Args.custombutton.append(new CustomButton("", () => {//[pencil]
                        NavigatorPage.NavigatorGoto("course-modify", new Dictionary <string, object>()
                        {
                            { "id", ID }
                        });
                    }, Tips: "修改"));
                }
                if (User.Get().BelongQuery("course", ID) == BelongRelation.Parent ||
                    User.Get().HasAuthorityOrRoot(Authority.CourseManage))
                {
                    template.Args.custombutton = template.Args.custombutton.append(new CustomButton("", () => {//[people]
                        NavigatorPage.NavigatorGoto("course-detail", new Dictionary <string, object>()
                        {
                            { "id", ID }
                        });
                    }, Tips: "出勤记录"));
                }
                template.ConstructCustomButton();

                //更新学生列表。
                var res = User.Api["api/courses/basic/"][ID].Retrieve();
                if (res.statuslike("2**"))
                {
                    var data = res.instance;
                    //构建有关学生的列表。
                    var datas   = new JArray();
                    var idset   = data["as_student_set"].map(j => j.ToString()) as string[];
                    var nameset = data["student_name_related"].map(j => j.ToString()) as string[];
                    for (int i = 0; i < idset.Length && i < nameset.Length; ++i)
                    {
                        var jo = new JObject();
                        jo["id"]   = new JValue(idset[i]);
                        jo["name"] = new JValue(nameset[i]);
                        datas.Add(jo);
                    }
                    list_temp.UpdateData(datas);
                }
            }
        }
        public override void NavigatedToEvent(object sender, IDictionary <string, object> kwargs)
        {
            base.NavigatedToEvent(sender, kwargs);
            if (kwargs != null)
            {
                ID = kwargs["id"] as string;
            }
            if (ID != null)
            {
                template.Args.instance = ID;
                template.UpdateData();
                template2.Args.instance = ID;
                template2.UpdateData();

                //修改按钮。
                template.Args.custombutton = new CustomButton[0];
                if (User.Get().HasAuthorityOrRoot(Authority.StudentManage))
                {
                    template.Args.custombutton = template.Args.custombutton.append(new CustomButton("", () => {
                        NavigatorPage.NavigatorGoto("student-manager-document", new Dictionary <string, object>()
                        {
                            { "id", ID }
                        });
                    }));
                }
                template.ConstructCustomButton();

                //列出学习的课程。
                var res = User.Api["api/auth/students/"][ID].Retrieve();
                if (res.statuslike("2**"))
                {
                    var idset   = res.instance["course_set"].map(j => j.ToString()) as string[];
                    var nameset = res.instance["course_name_related"].map(j => j.ToString()) as string[];
                    var jdata   = new JArray();
                    for (int i = 0; i < idset.Length && i < nameset.Length; ++i)
                    {
                        var jo = new JObject();
                        jo["id"]   = new JValue(idset[i]);
                        jo["name"] = new JValue(nameset[i]);
                        jdata.Add(jo);
                    }
                    list_temp.UpdateData(jdata);
                }
                else
                {
                    NavigatorPage.MsgSystem.Show(null, "错误", res.content);
                }
            }
        }
示例#10
0
        private void _treeView_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            NavigatorPage page = (NavigatorPage)e.Node.Tag;

            if (page == null)
            {
                // no page associated with this node, so cancel this selection
                e.Cancel = true;

                // attempt to select the next selectable node
                TreeNode nextNode = FindNextNode(e.Node, delegate(TreeNode n) { return(n.Tag != null); });
                if (nextNode != null)
                {
                    _treeView.SelectedNode = nextNode;
                }
            }
        }
示例#11
0
        public void Navigate(NavigatorPage page, object data = null)
        {
            CurrentPageData = data;
            tvRemote.Reset();
            switch (page)
            {
            case NavigatorPage.Login:
                pageFrame.Content = new Pages.Login(this, tvRemote);
                break;

            case NavigatorPage.Channels:
                pageFrame.Content = new Pages.TVChannels(this, tvRemote);
                break;

            case NavigatorPage.Player:
                pageFrame.Content = new Pages.Player(this, tvRemote);
                break;
            }
        }
示例#12
0
            private void InsertTreeNode(NavigatorPage page, TreeNodeCollection treeNodes, int depth, Dictionary <NavigatorPage, TreeNode> pageMap)
            {
                PathSegment segment = page.Path.Segments[depth];

                // see if node for this segment already exists
                TreeNode treeNode = CollectionUtils.FirstElement(treeNodes.Find(segment.LocalizedText, false));

                if (treeNode == null)
                {
                    // need to create the node, however, we can't just add it to the end of the child collection,
                    // we need to insert it at the appropriate place, which is just after the last "visited" node
                    // find first unvisited node, which indicates the insertion point
                    int i = 0;
                    for (; i < treeNodes.Count; i++)
                    {
                        if (!_visitedNodes.Contains(treeNodes[i]))
                        {
                            break;
                        }
                    }

                    // insert new node
                    treeNode = treeNodes.Insert(i, segment.LocalizedText, segment.LocalizedText);
                }

                if (depth < page.Path.Segments.Count - 1)
                {
                    // recur on next path segment
                    InsertTreeNode(page, treeNode.Nodes, depth + 1, pageMap);
                }
                else
                {
                    // this is the last path segment
                    treeNode.Tag = page;
                    pageMap.Add(page, treeNode);
                }

                // remember that this node has now been "visited"
                _visitedNodes.Add(treeNode);
            }
            private void InsertTreeNode(NavigatorPage page, TreeNodeCollection treeNodes, int depth, Dictionary<NavigatorPage, TreeNode> pageMap)
            {
                PathSegment segment = page.Path.Segments[depth];

                // see if node for this segment already exists
                TreeNode treeNode = CollectionUtils.FirstElement(treeNodes.Find(segment.LocalizedText, false));
                if (treeNode == null)
                {
                    // need to create the node, however, we can't just add it to the end of the child collection,
                    // we need to insert it at the appropriate place, which is just after the last "visited" node
                    // find first unvisited node, which indicates the insertion point
                    int i = 0;
                    for (; i < treeNodes.Count; i++)
                    {
                        if (!_visitedNodes.Contains(treeNodes[i]))
                            break;
                    }

                    // insert new node
                    treeNode = treeNodes.Insert(i, segment.LocalizedText, segment.LocalizedText);
                }

                if (depth < page.Path.Segments.Count - 1)
                {
                    // recur on next path segment
                    InsertTreeNode(page, treeNode.Nodes, depth + 1, pageMap);
                }
                else
                {
                    // this is the last path segment
                    treeNode.Tag = page;
                    pageMap.Add(page, treeNode);
                }

                // remember that this node has now been "visited"
                _visitedNodes.Add(treeNode);

            }
示例#14
0
 public override void NavigatedToEvent(object sender, IDictionary <string, object> kwargs)
 {
     base.NavigatedToEvent(sender, kwargs);
     if (kwargs != null)
     {
         ID = kwargs["id"] as string;
     }
     if (ID != null)
     {
         template.Args.instance = ID;
         template.UpdateData();
         //更新按钮。
         template.Args.custombutton = new CustomButton[0];
         if (User.Get().HasAuthorityOrRoot(Authority.ClassroomManage))
         {
             template.Args.custombutton = template.Args.custombutton.append(new CustomButton("", () => {//[pencil]
                 NavigatorPage.NavigatorGoto("classroom-modify", new Dictionary <string, object>()
                 {
                     { "id", ID }
                 });
             }, Tips: "修改"));
             list_temp.Args.filter("classroom_manage", ID);
             //如果是管理者,那么还可以查看到教室使用记录。
             list_temp.UpdateData();
             if (ListGrid.Children.Count <= 0)
             {
                 ListGrid.Children.Add(list_temp);
             }
         }
         else if (ListGrid.Children.Count > 0)
         {
             ListGrid.Children.Clear();
         }
         template.ConstructCustomButton();
     }
 }
        /// <summary>
        /// 链接生成最新内容,伴随查询参数。
        /// </summary>
        public void UpdateData()
        {
            itemlist = null;
            var search = SearchBox.Text;

            if (search == "")
            {
                search = null;
            }
            Task.Run(() => {
                var res = new Response[args.urls.Length];
                for (int i = 0; i < res.Length; ++i)
                {
                    res[i] = args.api[args.urls[i].url].List(args.getFilter(), getorderings(), search);
                }
                var flag = true;
                foreach (var i in res)
                {
                    if (!i.statuslike("2**"))
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    var datas = res.map(t => t.list) as JArray[];
                    Dispatcher.Invoke(() => {
                        //var Items = this.Items;
                        var brush_white = new SolidColorBrush(Colors.White);
                        var brush_gray  = new SolidColorBrush(Colors.LightGray);
                        Items.Clear();
                        int index = 0;
                        foreach (var data in datas[0])
                        {
                            //构造每一个条目的记录。
                            var row     = new ListTemplateItem();
                            var objects = new UIElement[args.columns.Count];
                            for (int i = 0; i < objects.Length; ++i) //构造一条记录的每一个项。
                            {
                                var c = args.columns[i];

                                var item = new TextBlock();
                                item.HorizontalAlignment = HorizontalAlignment.Left;
                                item.VerticalAlignment   = VerticalAlignment.Center;
                                item.FontSize            = c.fontsize ?? args.fontsize;
                                item.Margin = c.margin ?? args.margin;
                                //首先过滤名称,检查是主键内容还是副URL的内容。
                                JToken jdata = null;
                                if (c.name.Contains("/"))  //这表示使用斜线分割的url's name和json's name。
                                {
                                    var sp        = c.name.Split('/');
                                    var url_index = args.urls.firstAt(u => u.name == sp[0]);//得知这是第几条URL。
                                    if (url_index < 0)
                                    {
                                        throw new Exception("找不到对应的URL。Column的name书写错误。");
                                    }
                                    var second_url = args.urls[url_index];//获得副url的引用。

                                    foreach (var seconddata in datas[url_index])
                                    {
                                        if (seconddata[second_url.primarykey].ToString() == data[args.urls[0].primarykey].ToString())  //这个标志相当于二者对等。
                                        {
                                            jdata = seconddata[sp[1]];
                                            break;
                                        }
                                    }
                                }
                                else   //这表示是主键的内容。
                                {
                                    jdata = data[c.name];
                                }
                                //按类型创建UI内容。
                                if (c.type == "text")
                                {
                                    item.Text = jdata.ToString();
                                }
                                else if (c.type == "custom")
                                {
                                    item.Text = (c.data as Func <JToken, string>)(jdata);
                                }
                                else if (c.type == "choice")
                                {
                                    item.Text = (c.data as IDictionary <string, string>)[jdata.ToString()];
                                }
                                if (c.customaction != null)
                                {
                                    item.PreviewMouseLeftButtonDown += (s, e) => {
                                        c.customaction(data);
                                    };
                                }
                                if (c.hyperlink != null)
                                {
                                    var goal = c.hyperlink(data);                  //局部闭包
                                    item.PreviewMouseLeftButtonDown += (s, e) => { //点击超链接事件。
                                        NavigatorPage.NavigatorGoto(goal.Item1, goal.Item2);
                                    };
                                }
                                objects[i] = item;
                            }
                            row.SetChildren(gridlength, objects);
                            row.Background = index % 2 == 0 ? brush_gray : brush_white;
                            //itemlist[index] = row;
                            Items.Add(row);
                            ++index;
                        }
                    });
                }
                else   //抛出错误,存在不能正确连接的url。
                {
                    NavigatorPage.MsgSystem.Show(null, "错误", res[0].content);
                }
            });
        }
		private void RemoveTreeNode(NavigatorPage page)
		{
			// find node in map and remove it
			TreeNode node = _nodeMap[page];
			_nodeMap.Remove(page);

			// remove node from tree, recursively removing parent nodes if empty
			RemoveNode(node);
		}
        private void ShowPage(NavigatorPage page)
        {
            // get the control to show
            Control toShow = (Control)_component.GetPageView(page).GuiElement;

            // hide all others
            foreach (Control c in _contentPanel.Controls)
            {
                if (c != toShow)
                    c.Visible = false;
            }

            // if the control has not been added to the content panel, add it now
            if (!_contentPanel.Controls.Contains(toShow))
            {
                toShow.Dock = DockStyle.Fill;
                _contentPanel.Controls.Add(toShow);
            }

            toShow.Visible = true;

            // HACK: for some reason the error provider symbols don't show up the first time the control is shown
            // therefore we need to force it
            if (toShow is ApplicationComponentUserControl)
            {
                (toShow as ApplicationComponentUserControl).ErrorProvider.UpdateBinding();
            }

            // set the title and selected tree node
            _titleBar.Text = page.Path.LastSegment.LocalizedText;
            _treeView.SelectedNode = _nodeMap[page];
        }
        public override void Start()
        {
            Platform.GetService <IPatientAdminService>(
                service =>
            {
                var formData = service.LoadPatientProfileEditorFormData(new LoadPatientProfileEditorFormDataRequest());
                if (_isNew)
                {
                    _profile = new PatientProfileDetail();
                    _profile.Mrn.AssigningAuthority = formData.MrnAssigningAuthorityChoices.Count > 0
                                                        ? GetWorkingFacilityInformationAuthority(formData.MrnAssigningAuthorityChoices)
                                                        : null;
                    _profile.Healthcard.AssigningAuthority = formData.HealthcardAssigningAuthorityChoices.Count > 0
                                                        ? formData.HealthcardAssigningAuthorityChoices[0]
                                                        : null;
                    _profile.Sex         = formData.SexChoices[0];
                    _profile.DateOfBirth = Platform.Time.Date;
                }
                else
                {
                    var response = service.LoadPatientProfileForEdit(new LoadPatientProfileForEditRequest(_profileRef));

                    _profileRef = response.PatientProfileRef;
                    _profile    = response.PatientDetail;

                    this.Host.Title =
                        string.Format(SR.TitlePatientComponent, PersonNameFormat.Format(_profile.Name), MrnFormat.Format(_profile.Mrn));
                }

                if (_newAttachments.Count > 0)
                {
                    _profile.Attachments.AddRange(_newAttachments);
                    this.Modified      = true;
                    this.AcceptEnabled = true;
                }

                // if the user has permission to either a) create a new patient, or b) update the patient profile, then
                // these pages should be displayed
                if (Thread.CurrentPrincipal.IsInRole(
                        ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.PatientProfile.Update) ||
                    Thread.CurrentPrincipal.IsInRole(ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.Patient.Create))
                {
                    this.Pages.Add(
                        new NavigatorPage("NodePatient",
                                          _patientEditor =
                                              new PatientProfileDetailsEditorComponent(
                                                  _isNew,
                                                  formData.MrnAutoGenerated,
                                                  formData.SexChoices,
                                                  formData.MrnAssigningAuthorityChoices,
                                                  formData.HealthcardAssigningAuthorityChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeAddresses",
                                          _addressesSummary = new AddressesSummaryComponent(formData.AddressTypeChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodePhoneNumbers",
                                          _phoneNumbersSummary = new PhoneNumbersSummaryComponent(formData.PhoneTypeChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeEmailAddresses",
                                          _emailAddressesSummary = new EmailAddressesSummaryComponent()));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeContactPersons",
                                          _contactPersonsSummary =
                                              new ContactPersonsSummaryComponent(formData.ContactPersonTypeChoices, formData.ContactPersonRelationshipChoices)));
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeCulture",
                                          _additionalPatientInfoSummary =
                                              new PatientProfileAdditionalInfoEditorComponent(formData.ReligionChoices, formData.PrimaryLanguageChoices)));

                    _addressesSummary.SetModifiedOnListChange      = true;
                    _phoneNumbersSummary.SetModifiedOnListChange   = true;
                    _emailAddressesSummary.SetModifiedOnListChange = true;
                    _contactPersonsSummary.SetModifiedOnListChange = true;

                    _patientEditor.Subject                = _profile;
                    _addressesSummary.Subject             = _profile.Addresses;
                    _phoneNumbersSummary.Subject          = _profile.TelephoneNumbers;
                    _emailAddressesSummary.Subject        = _profile.EmailAddresses;
                    _contactPersonsSummary.Subject        = _profile.ContactPersons;
                    _additionalPatientInfoSummary.Subject = _profile;
                }

                // if the user has permission to either a) create a new patient, or b) update a patient, then
                // these pages should be displayed
                if (Thread.CurrentPrincipal.IsInRole(ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.Patient.Create) ||
                    Thread.CurrentPrincipal.IsInRole(ClearCanvas.Ris.Application.Common.AuthorityTokens.Workflow.Patient.Update))
                {
                    this.Pages.Add(
                        new NavigatorPage("NodePatient/NodeNotes",
                                          _notesSummary   = new PatientNoteSummaryComponent(_profile.Notes, formData.NoteCategoryChoices)));
                    _notesSummary.SetModifiedOnListChange = true;

                    var patientDocumentsPage = new NavigatorPage("NodePatient/NodeAttachments",
                                                                 _documentSummary =
                                                                     new AttachedDocumentPreviewComponent(false, AttachmentSite.Patient));
                    this.Pages.Add(patientDocumentsPage);
                    _documentSummary.Attachments = _profile.Attachments;

                    if (_newAttachments.Count > 0)
                    {
                        this.MoveTo(this.Pages.IndexOf(patientDocumentsPage));
                        _documentSummary.SetInitialSelection(_newAttachments[0]);
                    }
                }

                this.ValidationStrategy = new AllComponentsValidationStrategy();
            });


            base.Start();
        }
示例#19
0
        public override void Start()
        {
            Platform.GetService(
                delegate(IWorklistAdminService service)
            {
                var request = new GetWorklistEditFormDataRequest
                {
                    GetWorklistEditFormChoicesRequest = new GetWorklistEditFormChoicesRequest(!_adminMode)
                };
                _formDataResponse = service.GetWorklistEditFormData(request).GetWorklistEditFormChoicesResponse;

                // initialize _worklistDetail depending on add vs edit vs duplicate mode
                var procedureTypeGroups = new List <ProcedureTypeGroupSummary>();
                if (_mode == WorklistEditorMode.Add)
                {
                    _worklistDetail = new WorklistAdminDetail
                    {
                        FilterByWorkingFacility = true,
                        // establish initial class name
                        WorklistClass = CollectionUtils.SelectFirst(_formDataResponse.WorklistClasses, wc => wc.ClassName == _initialClassName)
                    };
                }
                else
                {
                    // load the existing worklist
                    var response = service.LoadWorklistForEdit(new LoadWorklistForEditRequest(_worklistRef));

                    _worklistDetail = response.Detail;
                    _worklistRef    = response.Detail.EntityRef;

                    // determine initial set of proc type groups, since worklist class already known
                    var groupsResponse  = service.ListProcedureTypeGroups(new ListProcedureTypeGroupsRequest(_worklistDetail.WorklistClass.ProcedureTypeGroupClassName));
                    procedureTypeGroups = groupsResponse.ProcedureTypeGroups;
                }

                // limit class choices if filter specified
                if (_worklistClassChoices != null)
                {
                    _formDataResponse.WorklistClasses =
                        CollectionUtils.Select(_formDataResponse.WorklistClasses, wc => _worklistClassChoices.Contains(wc.ClassName));
                }

                // sort worklist classes so they appear alphabetically in editor
                _formDataResponse.WorklistClasses = CollectionUtils.Sort(_formDataResponse.WorklistClasses, (x, y) => x.DisplayName.CompareTo(y.DisplayName));

                // determine which main page to show (multi or single)
                if (_mode == WorklistEditorMode.Add && _adminMode)
                {
                    _detailComponent = new WorklistMultiDetailEditorComponent(_formDataResponse.WorklistClasses,
                                                                              _formDataResponse.OwnerGroupChoices);
                }
                else
                {
                    _detailComponent = new WorklistDetailEditorComponent(
                        _worklistDetail,
                        _formDataResponse.WorklistClasses,
                        _formDataResponse.OwnerGroupChoices,
                        _mode,
                        _adminMode,
                        false);
                }
                _detailComponent.ProcedureTypeGroupClassChanged += ProcedureTypeGroupClassChangedEventHandler;
                _detailComponent.WorklistClassChanged           += OnWorklistClassChanged;
                _detailComponent.WorklistCategoryChanged        += OnWorklistCategoryChanged;

                // create all other pages
                _filterComponent = new WorklistFilterEditorComponent(_worklistDetail,
                                                                     _formDataResponse.FacilityChoices, _formDataResponse.OrderPriorityChoices,
                                                                     _formDataResponse.PatientClassChoices);

                _procedureTypeFilterComponent = new SelectorEditorComponent <ProcedureTypeSummary, ProcedureTypeTable>(
                    _formDataResponse.ProcedureTypeChoices, _worklistDetail.ProcedureTypes, s => s.ProcedureTypeRef);

                _procedureTypeGroupFilterComponent = new SelectorEditorComponent <ProcedureTypeGroupSummary, ProcedureTypeGroupTable>(
                    procedureTypeGroups, _worklistDetail.ProcedureTypeGroups, s => s.ProcedureTypeGroupRef);

                _departmentFilterComponent = new SelectorEditorComponent <DepartmentSummary, DepartmentTable>(
                    _formDataResponse.DepartmentChoices, _worklistDetail.Departments, s => s.DepartmentRef);

                _locationFilterComponent = new SelectorEditorComponent <LocationSummary, LocationTable>(
                    _formDataResponse.PatientLocationChoices, _worklistDetail.PatientLocations, s => s.LocationRef);

                var maxSpanDays      = _formDataResponse.CurrentServerConfigurationRequiresTimeFilter ? _formDataResponse.CurrentServerConfigurationMaxSpanDays : 0;
                _timeWindowComponent = new WorklistTimeWindowEditorComponent(
                    _worklistDetail,
                    _mode == WorklistEditorMode.Add && _formDataResponse.CurrentServerConfigurationRequiresTimeFilter,
                    maxSpanDays);

                _interpretedByFilterComponent = new StaffSelectorEditorComponent(
                    _formDataResponse.StaffChoices, _worklistDetail.InterpretedByStaff.Staff, _worklistDetail.InterpretedByStaff.IncludeCurrentUser);

                _transcribedByFilterComponent = new StaffSelectorEditorComponent(
                    _formDataResponse.StaffChoices, _worklistDetail.TranscribedByStaff.Staff, _worklistDetail.TranscribedByStaff.IncludeCurrentUser);

                _verifiedByFilterComponent = new StaffSelectorEditorComponent(
                    _formDataResponse.StaffChoices, _worklistDetail.VerifiedByStaff.Staff, _worklistDetail.VerifiedByStaff.IncludeCurrentUser);
                _supervisedByFilterComponent = new StaffSelectorEditorComponent(
                    _formDataResponse.StaffChoices, _worklistDetail.SupervisedByStaff.Staff, _worklistDetail.SupervisedByStaff.IncludeCurrentUser);

                if (ShowSubscriptionPages)
                {
                    _staffSubscribersComponent = new SelectorEditorComponent <StaffSummary, StaffSelectorTable>(
                        _formDataResponse.StaffChoices,
                        _worklistDetail.StaffSubscribers,
                        s => s.StaffRef,
                        SubscriptionPagesReadOnly);
                    _groupSubscribersComponent = new SelectorEditorComponent <StaffGroupSummary, StaffGroupTable>(
                        _formDataResponse.GroupSubscriberChoices,
                        _worklistDetail.GroupSubscribers,
                        s => s.StaffGroupRef,
                        SubscriptionPagesReadOnly);
                }
            });

            // add pages
            this.Pages.Add(new NavigatorPage("NodeWorklist", _detailComponent));
            this.Pages.Add(new NavigatorPage("NodeWorklist/NodeFilters", _filterComponent));
            this.Pages.Add(new NavigatorPage("NodeWorklist/NodeFilters/FilterProcedureType", _procedureTypeFilterComponent));
            this.Pages.Add(new NavigatorPage("NodeWorklist/NodeFilters/FilterProcedureTypeGroup", _procedureTypeGroupFilterComponent));

            if (new WorkflowConfigurationReader().EnableVisitWorkflow)
            {
                this.Pages.Add(new NavigatorPage("NodeWorklist/NodeFilters/FilterPatientLocation", _locationFilterComponent));
            }
            this.Pages.Add(_departmentComponentPage = new NavigatorPage("NodeWorklist/NodeFilters/FilterDepartment", _departmentFilterComponent));

            _procedureTypeFilterComponent.ItemsAdded      += OnProcedureTypeAdded;
            _procedureTypeGroupFilterComponent.ItemsAdded += OnProcedureTypeGroupAdded;

            _interpretedByFilterComponentPage = new NavigatorPage("NodeWorklist/NodeFilters/NodeStaff/FilterInterpretedBy", _interpretedByFilterComponent);

            if (WorklistEditorComponentSettings.Default.ShowTranscribedByPage)
            {
                _transcribedByFilterComponentPage = new NavigatorPage("NodeWorklist/NodeFilters/NodeStaff/FilterTranscribedBy", _transcribedByFilterComponent);
            }

            _verifiedByFilterComponentPage   = new NavigatorPage("NodeWorklist/NodeFilters/NodeStaff/FilterVerifiedBy", _verifiedByFilterComponent);
            _supervisedByFilterComponentPage = new NavigatorPage("NodeWorklist/NodeFilters/NodeStaff/FilterSupervisedBy", _supervisedByFilterComponent);

            _timeWindowComponentPage = new NavigatorPage("NodeWorklist/FilterTimeWindow", _timeWindowComponent);

            ShowWorklistCategoryDependantPages();

            if (ShowSubscriptionPages)
            {
                this.Pages.Add(new NavigatorPage("NodeWorklist/NodeSubscribers/NodeGroupSubscribers", _groupSubscribersComponent));
                this.Pages.Add(new NavigatorPage("NodeWorklist/NodeSubscribers/NodeStaffSubscribers", _staffSubscribersComponent));
            }
            this.Pages.Add(_summaryComponentPage = new NavigatorPage("NodeWorklist/NodeWorklistSummary", _summaryComponent = new WorklistSummaryComponent(_worklistDetail, _adminMode)));

            this.CurrentPageChanged += WorklistEditorComponent_CurrentPageChanged;

            this.ValidationStrategy = new AllComponentsValidationStrategy();

            base.Start();

            // Modify EntityRef and add the word "copy" to the worklist name.
            // This is done after the Start() call, so changing the worklist name will trigger a component modify changed.
            if (_mode == WorklistEditorMode.Duplicate)
            {
                _worklistDetail.EntityRef = null;
                ((WorklistDetailEditorComponent)_detailComponent).Name = _worklistDetail.Name + " copy";
            }
        }