public ExternalPractitionerSummary CreateExternalPractitionerSummary(ExternalPractitioner prac, IPersistenceContext context)
        {
            var summary = new ExternalPractitionerSummary(
                prac.GetRef(),
                new PersonNameAssembler().CreatePersonNameDetail(prac.Name),
                prac.LicenseNumber,
                prac.BillingNumber,
                prac.IsVerified,
                prac.LastVerifiedTime,
                prac.LastEditedTime,
                prac.IsMerged,
                prac.Deactivated);

            return(summary);
        }
        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);
        }