public override void Start()
        {
            // Create component for each tab
            _bannerComponent       = new BannerComponent();
            _orderHistoryComponent = new BiographyOrderHistoryComponent(_initialSelectedOrderRef)
            {
                PatientRef = _patientRef
            };
            _demographicComponent = new BiographyDemographicComponent {
                DefaultProfileRef = _profileRef, PatientRef = _patientRef
            };
            _documentComponent = new AttachedDocumentPreviewComponent(true, AttachmentSite.Patient);
            _noteComponent     = new BiographyNoteComponent();
            _allergyComponent  = new PatientAllergiesComponent();

            // Create tab and tab groups
            _pagesContainer = new TabComponentContainer();
            _pagesContainer.Pages.Add(new TabPage(SR.TitleOrders, _orderHistoryComponent));

            if (new WorkflowConfigurationReader().EnableVisitWorkflow)
            {
                _visitHistoryComponent = new BiographyVisitHistoryComponent {
                    PatientRef = _patientRef
                };
                _pagesContainer.Pages.Add(new TabPage(SR.TitleVisits, _visitHistoryComponent));
            }

            _pagesContainer.Pages.Add(new TabPage(SR.TitleDemographicProfiles, _demographicComponent));
            _pagesContainer.Pages.Add(new TabPage(SR.TitlePatientAttachments, _documentComponent));
            _pagesContainer.Pages.Add(new TabPage(SR.TitlePatientNotes, _noteComponent));
            //_pagesContainer.Pages.Add(new TabPage(SR.TitlePatientAllergies, _allergyComponent));

            var tabGroupContainer = new TabGroupComponentContainer(LayoutDirection.Horizontal);

            tabGroupContainer.AddTabGroup(new TabGroup(_pagesContainer, 1.0f));

            _contentComponentHost = new ChildComponentHost(this.Host, tabGroupContainer);
            _contentComponentHost.StartComponent();

            _bannerComponentHost = new ChildComponentHost(this.Host, _bannerComponent);
            _bannerComponentHost.StartComponent();

            _toolSet = new ToolSet(new PatientBiographyToolExtensionPoint(), new PatientBiographyToolContext(this));

            LoadPatientProfile();

            base.Start();
        }
        public override void Start()
        {
            _delaySelectionTimer = new Timer(state => SetSelectedOrder(state as EntityRef), _initialSelectedOrderRef, 250);

            _orderDetailComponent   = new BiographyOrderDetailViewComponent();
            _visitDetailComponent   = new BiographyVisitDetailViewComponent();
            _orderReportsComponent  = new BiographyOrderReportsComponent();
            _orderDocumentComponent = new AttachedDocumentPreviewComponent(true, AttachmentSite.Order);

            _rightHandComponentContainer = new TabComponentContainer();
            _rightHandComponentContainer.Pages.Add(new TabPage("Order Details", _orderDetailComponent));

            if (new WorkflowConfigurationReader().EnableVisitWorkflow)
            {
                _rightHandComponentContainer.Pages.Add(new TabPage("Visit Details", _visitDetailComponent));
            }

            _rightHandComponentContainer.Pages.Add(new TabPage("Reports", _orderReportsComponent));
            _rightHandComponentContainer.Pages.Add(new TabPage("Order Attachments", _orderDocumentComponent));

            // instantiate all extension pages
            _extensionPages = new List <IBiographyOrderHistoryPage>();
            foreach (IBiographyOrderHistoryPageProvider pageProvider in new BiographyOrderHistoryPageProviderExtensionPoint().CreateExtensions())
            {
                _extensionPages.AddRange(pageProvider.GetPages(new BiographyOrderHistoryContext(this)));
            }

            // add extension pages to container and set initial context
            // the container will start those components if the user goes to that page
            foreach (var page in _extensionPages)
            {
                _rightHandComponentContainer.Pages.Add(new TabPage(page.Path, page.GetComponent()));
            }

            _rightHandComponentContainerHost = new ChildComponentHost(this.Host, _rightHandComponentContainer);
            _rightHandComponentContainerHost.StartComponent();

            LoadOrders();

            base.Start();
        }
 internal AttachedDocumentToolContext(AttachedDocumentPreviewComponent component)
 {
     _component = component;
 }
        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();
        }