public ExternalPractitionerDetail CreateExternalPractitionerDetail(ExternalPractitioner prac, IPersistenceContext context)
		{
			var assembler = new PersonNameAssembler();

			var sortedContactPoints = CollectionUtils.Sort(prac.ContactPoints, (x, y) =>
				{
					if (ReferenceEquals(x, y)) return 0;
					if (x.IsDefaultContactPoint) return -1;
					if (y.IsDefaultContactPoint) return 1;
					return string.Compare(x.Name, y.Name);
				});

			var contactPointDetails = CollectionUtils.Map(
				sortedContactPoints,
				(ExternalPractitionerContactPoint cp) => CreateExternalPractitionerContactPointDetail(cp, context));

			var detail = new ExternalPractitionerDetail(
				prac.GetRef(),
				assembler.CreatePersonNameDetail(prac.Name),
				prac.LicenseNumber,
				prac.BillingNumber,
				prac.IsVerified,
				prac.LastVerifiedTime,
				prac.LastEditedTime,
				contactPointDetails,
				ExtendedPropertyUtils.Copy(prac.ExtendedProperties),
				CreateExternalPractitionerSummary(prac.GetUltimateMergeDestination(), context),
				prac.IsMerged,
				prac.Deactivated);

			return detail;
		}
		public void UpdateExternalPractitioner(ExternalPractitionerDetail detail, ExternalPractitioner prac, IPersistenceContext context)
		{
			// validate that only one contact point is specified as default
			var defaultPoints = CollectionUtils.Select(detail.ContactPoints, cp => cp.IsDefaultContactPoint);
			if(defaultPoints.Count > 1)
				throw new RequestValidationException(SR.ExceptionOneDefaultContactPoint);

			var assembler = new PersonNameAssembler();
			assembler.UpdatePersonName(detail.Name, prac.Name);

			prac.LicenseNumber = detail.LicenseNumber;
			prac.BillingNumber = detail.BillingNumber;
			prac.MarkDeactivated(detail.Deactivated);

			// update contact points collection
			var syncHelper = new CollectionSynchronizeHelper<ExternalPractitionerContactPoint, ExternalPractitionerContactPointDetail>(
					delegate (ExternalPractitionerContactPoint cp, ExternalPractitionerContactPointDetail cpDetail)
					{
						// ignore version in this comparison - deal with this issue in the update delegate
						return cp.GetRef().Equals(cpDetail.ContactPointRef, true);
					},
					delegate (ExternalPractitionerContactPointDetail cpDetail, ICollection<ExternalPractitionerContactPoint> cps)
					{
						// create a new contact point
						var cp = new ExternalPractitionerContactPoint(prac);
						UpdateExternalPractitionerContactPoint(cpDetail, cp, context);
						cps.Add(cp);
					},
					(cp, cpDetail, cps) => UpdateExternalPractitionerContactPoint(cpDetail, cp, context),
					(cp, cps) => cps.Remove(cp));

			syncHelper.Synchronize(prac.ContactPoints, detail.ContactPoints);

			ExtendedPropertyUtils.Update(prac.ExtendedProperties, detail.ExtendedProperties);
		}
Exemple #3
0
        bool ILookupHandler.Resolve(string query, bool interactive, out object result)
        {
            result = null;

            ExternalPractitionerDetail practitionerDetail = null;

            Platform.GetService <IExternalPractitionerAdminService>(
                service =>
            {
                var response       = service.LoadExternalPractitionerForEdit(new LoadExternalPractitionerForEditRequest(_practitionerRef));
                practitionerDetail = response.PractitionerDetail;
            });

            var component = new ExternalPractitionerContactPointSummaryComponent(_practitionerRef);

            practitionerDetail.ContactPoints.ForEach(p => component.Subject.Add(p));

            var exitCode = ApplicationComponent.LaunchAsDialog(
                _desktopWindow, component, SR.TitleContactPoints);

            if (exitCode == ApplicationComponentExitCode.Accepted)
            {
                result = component.SummarySelection.Item;
            }

            return(result != null);
        }
        public void Save(ExternalPractitionerDetail practitioner)
        {
            practitioner.ContactPoints.Clear();

            // Add the originally deactivated contact points
            practitioner.ContactPoints.AddRange(_deactivatedContactPointNotShown);

            // Add the items in the table.
            practitioner.ContactPoints.AddRange(_table.Items);
        }
        private void OnMovedForward()
        {
            var currentComponent = this.CurrentPage.Component;

            if (currentComponent == _selectedDuplicateComponent)
            {
                _originalPractitioner = LoadPractitionerDetail(_originalPractitionerRef);
                _selectedDuplicateComponent.OriginalPractitioner   = _originalPractitioner;
                _mergePropertiesComponent.OriginalPractitioner     = _originalPractitioner;
                _selectContactPointsComponent.OriginalPractitioner = _originalPractitioner;
            }
            else if (currentComponent == _mergePropertiesComponent)
            {
                // If selection change, load detail of the selected duplicate practitioner.
                if (_selectedDuplicateComponent.SelectedPractitioner == null)
                {
                    _selectedDuplicate = null;
                }
                else if (_selectedDuplicate == null)
                {
                    _selectedDuplicate = LoadPractitionerDetail(_selectedDuplicateComponent.SelectedPractitioner.PractitionerRef);
                }
                else if (!_selectedDuplicate.PractitionerRef.Equals(_selectedDuplicateComponent.SelectedPractitioner.PractitionerRef, true))
                {
                    _selectedDuplicate = LoadPractitionerDetail(_selectedDuplicateComponent.SelectedPractitioner.PractitionerRef);
                }

                _mergePropertiesComponent.DuplicatePractitioner = _selectedDuplicate;
            }
            else if (currentComponent == _selectContactPointsComponent)
            {
                _selectContactPointsComponent.DuplicatePractitioner = _selectedDuplicate;
            }
            else if (currentComponent == _replaceContactPointsComponent)
            {
                _replaceContactPointsComponent.ActiveContactPoints      = _selectContactPointsComponent.ActiveContactPoints;
                _replaceContactPointsComponent.DeactivatedContactPoints = _selectContactPointsComponent.DeactivatedContactPoints;

                if (_replaceContactPointsComponent.DeactivatedContactPoints.Count == 0)
                {
                    Forward();
                }
            }
            else if (currentComponent == _confirmationComponent)
            {
                _mergedPractitioner.PractitionerRef = _originalPractitionerRef;
                _mergePropertiesComponent.Save(_mergedPractitioner);
                _selectContactPointsComponent.Save(_mergedPractitioner);
                _replaceContactPointsComponent.Save();
                _confirmationComponent.PractitionerDetail = _mergedPractitioner;

                // The accept is enabled only on the very last page.
                this.AcceptEnabled = true;
            }
        }
Exemple #6
0
        private ExternalPractitionerDetail GetSelectedExternalPractitionerDetail()
        {
            ExternalPractitionerDetail detail = null;
            var selectedPractitioner          = CollectionUtils.FirstElement(this.SelectedItems);

            Platform.GetService <IExternalPractitionerAdminService>(service =>
            {
                var forEditResponse = service.LoadExternalPractitionerForEdit(new LoadExternalPractitionerForEditRequest(selectedPractitioner.PractitionerRef));
                detail = forEditResponse.PractitionerDetail;
            });
            return(detail);
        }
        private static ExternalPractitionerDetail LoadPractitionerDetail(EntityRef practitionerRef)
        {
            ExternalPractitionerDetail detail = null;

            if (practitionerRef != null)
            {
                Platform.GetService(
                    delegate(IExternalPractitionerAdminService service)
                {
                    var request  = new LoadExternalPractitionerForEditRequest(practitionerRef);
                    var response = service.LoadExternalPractitionerForEdit(request);
                    detail       = response.PractitionerDetail;
                });
            }

            return(detail);
        }
Exemple #8
0
        public void Save(ExternalPractitionerDetail practitioner)
        {
            // Ask all responsible party to update the merged property
            EventsHelper.Fire(_saveRequested, this, EventArgs.Empty);

            // Clone all properties
            practitioner.Name          = (PersonNameDetail)_mergedPractitioner.Name.Clone();
            practitioner.LicenseNumber = _mergedPractitioner.LicenseNumber;
            practitioner.BillingNumber = _mergedPractitioner.BillingNumber;
            practitioner.ExtendedProperties.Clear();
            foreach (var kvp in _mergedPractitioner.ExtendedProperties)
            {
                // Only keep properties that have value
                if (!string.IsNullOrEmpty(kvp.Value))
                {
                    practitioner.ExtendedProperties.Add(kvp.Key, kvp.Value);
                }
            }
        }
        public ExternalPractitionerDetail CreateExternalPractitionerDetail(ExternalPractitioner prac, IPersistenceContext context)
        {
            var assembler = new PersonNameAssembler();

            var sortedContactPoints = CollectionUtils.Sort(prac.ContactPoints, (x, y) =>
            {
                if (ReferenceEquals(x, y))
                {
                    return(0);
                }
                if (x.IsDefaultContactPoint)
                {
                    return(-1);
                }
                if (y.IsDefaultContactPoint)
                {
                    return(1);
                }
                return(string.Compare(x.Name, y.Name));
            });

            var contactPointDetails = CollectionUtils.Map(
                sortedContactPoints,
                (ExternalPractitionerContactPoint cp) => CreateExternalPractitionerContactPointDetail(cp, context));

            var detail = new ExternalPractitionerDetail(
                prac.GetRef(),
                assembler.CreatePersonNameDetail(prac.Name),
                prac.LicenseNumber,
                prac.BillingNumber,
                prac.IsVerified,
                prac.LastVerifiedTime,
                prac.LastEditedTime,
                contactPointDetails,
                ExtendedPropertyUtils.Copy(prac.ExtendedProperties),
                CreateExternalPractitionerSummary(prac.GetUltimateMergeDestination(), context),
                prac.IsMerged,
                prac.Deactivated);

            return(detail);
        }
        public void UpdateExternalPractitioner(ExternalPractitionerDetail detail, ExternalPractitioner prac, IPersistenceContext context)
        {
            // validate that only one contact point is specified as default
            var defaultPoints = CollectionUtils.Select(detail.ContactPoints, cp => cp.IsDefaultContactPoint);

            if (defaultPoints.Count > 1)
            {
                throw new RequestValidationException(SR.ExceptionOneDefaultContactPoint);
            }

            var assembler = new PersonNameAssembler();

            assembler.UpdatePersonName(detail.Name, prac.Name);

            prac.LicenseNumber = detail.LicenseNumber;
            prac.BillingNumber = detail.BillingNumber;
            prac.MarkDeactivated(detail.Deactivated);

            // update contact points collection
            var syncHelper = new CollectionSynchronizeHelper <ExternalPractitionerContactPoint, ExternalPractitionerContactPointDetail>(
                delegate(ExternalPractitionerContactPoint cp, ExternalPractitionerContactPointDetail cpDetail)
            {
                // ignore version in this comparison - deal with this issue in the update delegate
                return(cp.GetRef().Equals(cpDetail.ContactPointRef, true));
            },
                delegate(ExternalPractitionerContactPointDetail cpDetail, ICollection <ExternalPractitionerContactPoint> cps)
            {
                // create a new contact point
                var cp = new ExternalPractitionerContactPoint(prac);
                UpdateExternalPractitionerContactPoint(cpDetail, cp, context);
                cps.Add(cp);
            },
                (cp, cpDetail, cps) => UpdateExternalPractitionerContactPoint(cpDetail, cp, context),
                (cp, cps) => cps.Remove(cp));

            syncHelper.Synchronize(prac.ContactPoints, detail.ContactPoints);

            ExtendedPropertyUtils.Update(prac.ExtendedProperties, detail.ExtendedProperties);
        }
Exemple #11
0
 public UpdateExternalPractitionerRequest(ExternalPractitionerDetail pracDetail, bool markVerified)
 {
     this.PractitionerDetail = pracDetail;
     this.MarkVerified       = markVerified;
 }
		public AddExternalPractitionerRequest(ExternalPractitionerDetail pracDetail, bool markVerified)
		{
			this.PractitionerDetail = pracDetail;
			this.MarkVerified = markVerified;
		}
Exemple #13
0
        public override void Start()
        {
            LoadExternalPractitionerEditorFormDataResponse formDataResponse = null;

            Platform.GetService <IExternalPractitionerAdminService>(service =>
            {
                formDataResponse = service.LoadExternalPractitionerEditorFormData(new LoadExternalPractitionerEditorFormDataRequest());

                if (_isNew)
                {
                    _practitionerDetail = new ExternalPractitionerDetail();
                }
                else
                {
                    var response        = service.LoadExternalPractitionerForEdit(new LoadExternalPractitionerForEditRequest(_practitionerRef));
                    _practitionerRef    = response.PractitionerDetail.PractitionerRef;
                    _practitionerDetail = response.PractitionerDetail;
                }
            });

            _contactPointSummaryComponent = new ExternalPractitionerContactPointSummaryComponent(_practitionerRef,
                                                                                                 formDataResponse.AddressTypeChoices,
                                                                                                 formDataResponse.PhoneTypeChoices,
                                                                                                 formDataResponse.ResultCommunicationModeChoices,
                                                                                                 formDataResponse.InformationAuthorityChoices,
                                                                                                 Formatting.PersonNameFormat.Format(_practitionerDetail.Name));
            _contactPointSummaryComponent.SetModifiedOnListChange = true;

            var rootPath = SR.TitleExternalPractitioner;

            this.Pages.Add(new NavigatorPage("NodeExternalPractitioner", _detailsEditor = new ExternalPractitionerDetailsEditorComponent(_isNew)));
            this.Pages.Add(new NavigatorPage("NodeExternalPractitioner/NodeContactPoints", _contactPointSummaryComponent));

            this.ValidationStrategy = new AllComponentsValidationStrategy();

            _detailsEditor.ExternalPractitionerDetail = _practitionerDetail;

            // Hide the merged contact points from user.
            CollectionUtils.ForEach(_practitionerDetail.ContactPoints,
                                    delegate(ExternalPractitionerContactPointDetail cp)
            {
                if (cp.IsMerged)
                {
                    _hiddenMergedContactPoints.Add(cp);
                }
                else
                {
                    _contactPointSummaryComponent.Subject.Add(cp);
                }
            });

            // instantiate all extension pages
            _extensionPages = new List <IExternalPractitionerEditorPage>();
            foreach (IExternalPractitionerEditorPageProvider pageProvider in new ExternalPractitionerEditorPageProviderExtensionPoint().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 (var page in _extensionPages)
            {
                this.Pages.Add(new NavigatorPage(page.Path, page.GetComponent()));
            }

            base.Start();
        }
 /// <summary>
 /// Constructor for selecting two practitioners to merge.
 /// </summary>
 public ExternalPractitionerMergeNavigatorComponent(EntityRef practitionerRef, EntityRef duplicatePractitionerRef)
 {
     _originalPractitionerRef           = practitionerRef;
     _specifiedDuplicatePractitionerRef = duplicatePractitionerRef;
     _mergedPractitioner = new ExternalPractitionerDetail();
 }
Exemple #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ExternalPractitionerDetailsEditorComponent(bool isNew)
 {
     _practitionerDetail = new ExternalPractitionerDetail();
     _isNew = isNew;
 }