示例#1
0
 public void UpdatePersonName(PersonNameDetail detail, PersonName personName)
 {
     personName.FamilyName = TrimDetail(detail.FamilyName);
     personName.GivenName = TrimDetail(detail.GivenName);
     personName.MiddleName = TrimDetail(detail.MiddleName);
     personName.Prefix = TrimDetail(detail.Prefix);
     personName.Suffix = TrimDetail(detail.Suffix);
     personName.Degree = TrimDetail(detail.Degree);
 }
		private static void TestName(PersonName name, ref List<string> reasons)
		{
			if (name == null)
			{
				reasons.Add(SR.AlertFamilyNameMissing);
				return;
			}

			if (string.IsNullOrEmpty(name.FamilyName))
				reasons.Add(SR.AlertFamilyNameMissing);

			if (string.IsNullOrEmpty(name.GivenName))
				reasons.Add(SR.AlertGivenNameMissing);
		}
示例#3
0
        public PersonNameDetail CreatePersonNameDetail(PersonName personName)
        {
            if (personName == null)
                return new PersonNameDetail();

            PersonNameDetail detail = new PersonNameDetail();
            detail.FamilyName = personName.FamilyName;
            detail.GivenName = personName.GivenName;
            detail.MiddleName = personName.MiddleName;
            detail.Prefix = personName.Prefix;
            detail.Suffix = personName.Suffix;
            detail.Degree = personName.Degree;
            return detail;
        }
示例#4
0
		public static PersonName[] ParsePersonNames(string query)
		{
			// define a term as anything starting with a letter, and followed by letters, hyphen (-) or apostrophe (')
			// we allow hyphens for hyphenated surnames (wyatt-jones)
			// allow apostrophe for names like O'Leary
			var termDefinition = new Regex(@"\b[A-Za-z][A-Za-z'\-]*\b");
			var terms = ParseTerms(query, termDefinition);

			var names = new List<PersonName>();
			for (var i = 0; i < terms.Length; i++)
			{
				var name = new PersonName {FamilyName = string.Join(" ", terms, 0, i + 1)};
				if (i < terms.Length - 1)
				{
					name.GivenName = string.Join(" ", terms, i + 1, terms.Length - i - 1);
				}
				names.Add(name);
			}
			return names.ToArray();
		}
示例#5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="note"></param>
 /// <param name="order"></param>
 /// <param name="patient"></param>
 /// <param name="patientProfile"></param>
 /// <param name="noteAuthor"></param>
 /// <param name="recipients"></param>
 /// <param name="diagnosticServiceName"></param>
 /// <param name="isAcknowledged"></param>
 public OrderNoteboxItem(Note note, Order order, Patient patient, PatientProfile patientProfile,
                         Staff noteAuthor, IList recipients,
                         string diagnosticServiceName, bool isAcknowledged)
 {
     _noteRef           = note.GetRef();
     _orderRef          = order.GetRef();
     _patientRef        = patient.GetRef();
     _patientProfileRef = patientProfile.GetRef();
     _mrn                   = patientProfile.Mrn;
     _patientName           = patientProfile.Name;
     _dateOfBirth           = patientProfile.DateOfBirth;
     _accessionNumber       = order.AccessionNumber;
     _diagnosticServiceName = diagnosticServiceName;
     _category              = note.Category;
     _urgent                = note.Urgent;
     _postTime              = note.PostTime;
     _author                = noteAuthor;
     _onBehalfOfGroup       = note.OnBehalfOfGroup;
     _isAcknowledged        = isAcknowledged;
     _recipients            = recipients;
 }
示例#6
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="note"></param>
		/// <param name="order"></param>
		/// <param name="patient"></param>
		/// <param name="patientProfile"></param>
		/// <param name="noteAuthor"></param>
		/// <param name="recipients"></param>
		/// <param name="diagnosticServiceName"></param>
		/// <param name="isAcknowledged"></param>
		public OrderNoteboxItem(Note note, Order order, Patient patient, PatientProfile patientProfile,
			Staff noteAuthor, IList recipients,
			string diagnosticServiceName, bool isAcknowledged)
		{
			_noteRef = note.GetRef();
			_orderRef = order.GetRef();
			_patientRef = patient.GetRef();
			_patientProfileRef = patientProfile.GetRef();
			_mrn = patientProfile.Mrn;
			_patientName = patientProfile.Name;
			_dateOfBirth = patientProfile.DateOfBirth;
			_accessionNumber = order.AccessionNumber;
			_diagnosticServiceName = diagnosticServiceName;
			_category = note.Category;
			_urgent = note.Urgent;
			_postTime = note.PostTime;
			_author = noteAuthor;
			_onBehalfOfGroup = note.OnBehalfOfGroup;
			_isAcknowledged = isAcknowledged;
			_recipients = recipients;
		}
示例#7
0
		public static PersonName[] ParsePersonNames(string query)
		{
			// define a person name as anything starting with a letter, and followed by letters or general punctuation
			// (apostrophe and hyphens in particular, but without prejudice to any other punctuation which may be used in native names of other languages)
			// examples:
			// * O'Leary
			// * Wyatt-Jones
			// * Pérez
			const string letter = @"\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Lm}\p{M}";
			var termDefinition = new Regex(@"\b[" + letter + @"][" + letter + @"\p{P}]*\b");
			var terms = ParseTerms(query, termDefinition);

			var names = new List<PersonName>();
			for (var i = 0; i < terms.Length; i++)
			{
				var name = new PersonName {FamilyName = string.Join(" ", terms, 0, i + 1)};
				if (i < terms.Length - 1)
				{
					name.GivenName = string.Join(" ", terms, i + 1, terms.Length - i - 1);
				}
				names.Add(name);
			}
			return names.ToArray();
		}
		/// <summary>
		/// Creates a new practitioner that is the result of merging the two specified practitioners.
		/// </summary>
		/// <param name="right"></param>
		/// <param name="left"></param>
		/// <param name="name"></param>
		/// <param name="licenseNumber"></param>
		/// <param name="billingNumber"></param>
		/// <param name="extendedProperties"></param>
		/// <param name="defaultContactPoint"></param>
		/// <param name="deactivatedContactPoints"></param>
		/// <param name="contactPointReplacements"></param>
		/// <returns></returns>
		public static ExternalPractitioner MergePractitioners(
			ExternalPractitioner right,
			ExternalPractitioner left,
			PersonName name,
			string licenseNumber,
			string billingNumber,
			IDictionary<string, string> extendedProperties,
			ExternalPractitionerContactPoint defaultContactPoint,
			ICollection<ExternalPractitionerContactPoint> deactivatedContactPoints,
			IDictionary<ExternalPractitionerContactPoint, ExternalPractitionerContactPoint> contactPointReplacements)
		{
			// sanity check
			if (Equals(right, left))
				throw new WorkflowException("Cannot merge a practitioner with itself.");
			if (right.Deactivated || left.Deactivated)
				throw new WorkflowException("Cannot merge a practitioner that is de-activated.");
			if (right.IsMerged || left.IsMerged)
				throw new WorkflowException("Cannot merge a practitioner that has already been merged.");
			if (defaultContactPoint != null && defaultContactPoint.IsMerged)
				throw new WorkflowException("Cannot assigned a merged contact point as default");

			// update properties on result record
			var result = new ExternalPractitioner { Name = name, LicenseNumber = licenseNumber, BillingNumber = billingNumber };

			ExtendedPropertyUtils.Update(result.ExtendedProperties, extendedProperties);

			// construct the set of retained contact points
			var retainedContactPoints = new HashedSet<ExternalPractitionerContactPoint>();
			retainedContactPoints.AddAll(contactPointReplacements.Values);

			// some of the replacement contact points are merged.  This should not be allowed.
			if (CollectionUtils.Contains(contactPointReplacements.Values, cp => cp.IsMerged))
				throw new WorkflowException("Cannot replace a contact point with another that has already been merged.");

			// add any existing contact point that was not in the replacement list (because it is implicitly being retained)
			foreach (var contactPoint in CollectionUtils.Concat(right.ContactPoints, left.ContactPoints))
			{
				// No need to retain a merged contact point.  Because its replacement would already be retained.
				if (!contactPointReplacements.ContainsKey(contactPoint) && !contactPoint.IsMerged)
					retainedContactPoints.Add(contactPoint);
			}

			// for all retained contact points, create a copy attached to the result practitioner,
			// and mark the original as having been merged into the copy
			foreach (var original in retainedContactPoints)
			{
				var copy = original.CreateCopy(result);
				result.ContactPoints.Add(copy);

				copy.IsDefaultContactPoint = original.Equals(defaultContactPoint);
				copy.MarkDeactivated(original.Deactivated || deactivatedContactPoints.Contains(original));
				original.SetMergedInto(copy);
			}

			// for all replaced contact points, mark the original as being merged into the 
			// copy of the replacement
			foreach (var kvp in contactPointReplacements)
			{
				kvp.Key.SetMergedInto(kvp.Value.MergedInto);
			}

			// mark both left and right as edited and merged
			foreach (var practitioner in new[] { right, left })
	{
				practitioner.MarkEdited();
				practitioner.SetMergedInto(result);
			}

			// mark the result as being edited
			result.MarkEdited();
			return result;
		}
        /// <summary>
        /// Creates a new practitioner that is the result of merging the two specified practitioners.
        /// </summary>
        /// <param name="right"></param>
        /// <param name="left"></param>
        /// <param name="name"></param>
        /// <param name="licenseNumber"></param>
        /// <param name="billingNumber"></param>
        /// <param name="extendedProperties"></param>
        /// <param name="defaultContactPoint"></param>
        /// <param name="deactivatedContactPoints"></param>
        /// <param name="contactPointReplacements"></param>
        /// <returns></returns>
        public static ExternalPractitioner MergePractitioners(
            ExternalPractitioner right,
            ExternalPractitioner left,
            PersonName name,
            string licenseNumber,
            string billingNumber,
            IDictionary <string, string> extendedProperties,
            ExternalPractitionerContactPoint defaultContactPoint,
            ICollection <ExternalPractitionerContactPoint> deactivatedContactPoints,
            IDictionary <ExternalPractitionerContactPoint, ExternalPractitionerContactPoint> contactPointReplacements)
        {
            // sanity check
            if (Equals(right, left))
            {
                throw new WorkflowException("Cannot merge a practitioner with itself.");
            }
            if (right.Deactivated || left.Deactivated)
            {
                throw new WorkflowException("Cannot merge a practitioner that is de-activated.");
            }
            if (right.IsMerged || left.IsMerged)
            {
                throw new WorkflowException("Cannot merge a practitioner that has already been merged.");
            }
            if (defaultContactPoint != null && defaultContactPoint.IsMerged)
            {
                throw new WorkflowException("Cannot assigned a merged contact point as default");
            }

            // update properties on result record
            var result = new ExternalPractitioner {
                Name = name, LicenseNumber = licenseNumber, BillingNumber = billingNumber
            };

            ExtendedPropertyUtils.Update(result.ExtendedProperties, extendedProperties);

            // construct the set of retained contact points
            var retainedContactPoints = new HashedSet <ExternalPractitionerContactPoint>();

            retainedContactPoints.AddAll(contactPointReplacements.Values);

            // some of the replacement contact points are merged.  This should not be allowed.
            if (CollectionUtils.Contains(contactPointReplacements.Values, cp => cp.IsMerged))
            {
                throw new WorkflowException("Cannot replace a contact point with another that has already been merged.");
            }

            // add any existing contact point that was not in the replacement list (because it is implicitly being retained)
            foreach (var contactPoint in CollectionUtils.Concat(right.ContactPoints, left.ContactPoints))
            {
                // No need to retain a merged contact point.  Because its replacement would already be retained.
                if (!contactPointReplacements.ContainsKey(contactPoint) && !contactPoint.IsMerged)
                {
                    retainedContactPoints.Add(contactPoint);
                }
            }

            // for all retained contact points, create a copy attached to the result practitioner,
            // and mark the original as having been merged into the copy
            foreach (var original in retainedContactPoints)
            {
                var copy = original.CreateCopy(result);
                result.ContactPoints.Add(copy);

                copy.IsDefaultContactPoint = original.Equals(defaultContactPoint);
                copy.MarkDeactivated(original.Deactivated || deactivatedContactPoints.Contains(original));
                original.SetMergedInto(copy);
            }

            // for all replaced contact points, mark the original as being merged into the
            // copy of the replacement
            foreach (var kvp in contactPointReplacements)
            {
                kvp.Key.SetMergedInto(kvp.Value.MergedInto);
            }

            // mark both left and right as edited and merged
            foreach (var practitioner in new[] { right, left })
            {
                practitioner.MarkEdited();
                practitioner.SetMergedInto(result);
            }

            // mark the result as being edited
            result.MarkEdited();
            return(result);
        }