public override void Start()
        {
            this.Pages.Add(new NavigatorPage("NodeContactPoint", _detailsEditor = new ExternalPractitionerContactPointDetailsEditorComponent(_contactPointDetail, _resultCommunicationModeChoices, _informationAuthorityChoices)));
            this.Pages.Add(new NavigatorPage("NodeContactPoint/NodeAddresses", _addressesSummary           = new AddressesSummaryComponent(_addressTypeChoices)));
            this.Pages.Add(new NavigatorPage("NodeContactPoint/NodePhoneNumbers", _phoneNumbersSummary     = new PhoneNumbersSummaryComponent(_phoneTypeChoices)));
            this.Pages.Add(new NavigatorPage("NodeContactPoint/NodeEmailAddresses", _emailAddressesSummary = new EmailAddressesSummaryComponent()));

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

            this.ValidationStrategy = new AllComponentsValidationStrategy();

            _addressesSummary.Subject      = _contactPointDetail.Addresses;
            _phoneNumbersSummary.Subject   = _contactPointDetail.TelephoneNumbers;
            _emailAddressesSummary.Subject = _contactPointDetail.EmailAddresses;

            base.Start();
        }
        public override void Start()
        {
            Platform.GetService <IStaffAdminService>(
                delegate(IStaffAdminService service)
            {
                LoadStaffEditorFormDataResponse formDataResponse = service.LoadStaffEditorFormData(new LoadStaffEditorFormDataRequest());

                this.ValidationStrategy = new AllComponentsValidationStrategy();

                if (_isNew)
                {
                    _staffDetail           = new StaffDetail();
                    _staffDetail.StaffType = CollectionUtils.FirstElement(formDataResponse.StaffTypeChoices);
                }
                else
                {
                    LoadStaffForEditResponse response = service.LoadStaffForEdit(new LoadStaffForEditRequest(_staffRef));
                    _staffRef    = response.StaffDetail.StaffRef;
                    _staffDetail = response.StaffDetail;
                }

                _originalStaffUserName = _staffDetail.UserName;

                _detailsEditor = new StaffDetailsEditorComponent(formDataResponse.StaffTypeChoices, formDataResponse.SexChoices)
                {
                    StaffDetail = _staffDetail
                };
                this.Pages.Add(new NavigatorPage("Staff", _detailsEditor));

                _phoneNumbersSummary = new PhoneNumbersSummaryComponent(formDataResponse.PhoneTypeChoices)
                {
                    ReadOnly = !CanModifyStaffProfile,
                    SetModifiedOnListChange = true,
                    Subject = _staffDetail.TelephoneNumbers
                };
                this.Pages.Add(new NavigatorPage("Staff/Phone Numbers", _phoneNumbersSummary));

                _addressesSummary = new AddressesSummaryComponent(formDataResponse.AddressTypeChoices)
                {
                    ReadOnly = !CanModifyStaffProfile,
                    SetModifiedOnListChange = true,
                    Subject = _staffDetail.Addresses
                };
                this.Pages.Add(new NavigatorPage("Staff/Addresses", _addressesSummary));

                _emailAddressesSummary = new EmailAddressesSummaryComponent
                {
                    ReadOnly = !CanModifyStaffProfile,
                    SetModifiedOnListChange = true,
                    Subject = _staffDetail.EmailAddresses
                };
                this.Pages.Add(new NavigatorPage("Staff/Email Addresses", _emailAddressesSummary));



                // allow modification of non-elective groups only iff the user has StaffGroup admin permissions
                this.Pages.Add(new NavigatorPage("Staff/Groups/Non-elective", _nonElectiveGroupsEditor = new StaffNonElectiveStaffGroupEditorComponent(_staffDetail.Groups, formDataResponse.StaffGroupChoices, !CanModifyNonElectiveGroups)));
                this.Pages.Add(new NavigatorPage("Staff/Groups/Elective", _electiveGroupsEditor        = new StaffElectiveStaffGroupEditorComponent(_staffDetail.Groups, formDataResponse.StaffGroupChoices, !CanModifyStaffProfile)));
            });

            // instantiate all extension pages
            _extensionPages = new List <IStaffEditorPage>();
            foreach (IStaffEditorPageProvider pageProvider in new StaffEditorPageProviderExtensionPoint().CreateExtensions())
            {
                _extensionPages.AddRange(pageProvider.GetPages(new EditorContext(this)));
            }

            // add extension pages to navigator
            // the navigator will start those components if the user goes to that page
            foreach (IStaffEditorPage page in _extensionPages)
            {
                this.Pages.Add(new NavigatorPage(page.Path, page.GetComponent()));
            }

            base.Start();
        }
        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();
        }