public void EnqueueEvents(PatientProfile patientProfile) { var queueItem = new WorkQueueItem(WorkQueueItemType); queueItem.ExtendedProperties.Add("EventType", this.EventType); queueItem.ExtendedProperties.Add("PatientOID", patientProfile.Patient.OID.ToString()); queueItem.ExtendedProperties.Add("PatientProfileOID", patientProfile.OID.ToString()); queueItem.ExtendedProperties.Add("Mrn", patientProfile.Mrn.ToString()); EnqueueWorkItem(queueItem); }
/// <summary> /// Adds a <see cref="PatientProfile"/> to this patient. /// </summary> /// <remarks> /// Use this method rather than adding to the <see cref="Profiles"/> /// collection directly. /// </remarks> /// <param name="profile"></param> public virtual void AddProfile(PatientProfile profile) { if (profile.Patient != null) { //NB: technically we should remove the profile from the other patient's collection, but there //seems to be a bug with NHibernate where it deletes the profile if we do this //profile.Patient.Profiles.Remove(profile); } profile.Patient = this; _profiles.Add(profile); }
public override AlertNotification Test(PatientProfile profile, IPersistenceContext context) { IPatientReconciliationStrategy strategy = (IPatientReconciliationStrategy)(new PatientReconciliationStrategyExtensionPoint()).CreateExtension(); IList<PatientProfileMatch> matches = strategy.FindReconciliationMatches(profile, context); if (matches.Count > 0) { return new AlertNotification(this.Id, new string[]{}); } return null; }
public override AlertNotification Test(PatientProfile profile, IPersistenceContext context) { AlertsSettings settings = new AlertsSettings(); List<string> defaultLanguages = string.IsNullOrEmpty(settings.CommonSpokenLanguages) ? new List<string>() : new List<string>(settings.CommonSpokenLanguages.Replace(" ", "").Split(',')); if (profile.PrimaryLanguage != null && !defaultLanguages.Contains(profile.PrimaryLanguage.Code)) { return new AlertNotification(this.Id, new string[] { profile.PrimaryLanguage.Value }); } return null; }
public IList<PatientProfileMatch> FindReconciliationMatches(PatientProfile targetProfile, IPersistenceContext context) { /* User needs to resort to manual linking of patient records from multiple HIS when automatic MPI fails. * * Allow user to to select 2 or more patient records from different hospitals and merge into an MPI. * * Display High-Probability match/search results from muliple HIS of patients with various Mrns when * field: healthcard # is matched/identical. * * Display Moderate-Probability match/search results from multiple HIS of patients with various Mrns when fields: surname, * given name, DOB, gender are matched/identical. * */ IPatientProfileBroker broker = context.GetBroker<IPatientProfileBroker>(); IList<PatientProfileMatch> matches = new List<PatientProfileMatch>(); IList<PatientProfileMatch> highMatches = new List<PatientProfileMatch>(); if (targetProfile.Healthcard != null && !string.IsNullOrEmpty(targetProfile.Healthcard.Id)) { PatientProfileSearchCriteria high = new PatientProfileSearchCriteria(); high.Healthcard.Id.EqualTo(targetProfile.Healthcard.Id); highMatches = PatientProfileMatch.CreateList(targetProfile, broker.Find(high), PatientProfileMatch.ScoreValue.High); } PatientProfileSearchCriteria moderateViaName = new PatientProfileSearchCriteria(); if (targetProfile.Name.FamilyName != null && !string.IsNullOrEmpty(targetProfile.Name.FamilyName)) moderateViaName.Name.FamilyName.EqualTo(targetProfile.Name.FamilyName); if (targetProfile.Name.GivenName != null && !string.IsNullOrEmpty(targetProfile.Name.GivenName)) moderateViaName.Name.GivenName.EqualTo(targetProfile.Name.GivenName); if (targetProfile.DateOfBirth != null) moderateViaName.DateOfBirth.EqualTo(targetProfile.DateOfBirth); moderateViaName.Sex.EqualTo(targetProfile.Sex); IList<PatientProfileMatch> moderateMatchesViaName = PatientProfileMatch.CreateList(targetProfile, broker.Find(moderateViaName), PatientProfileMatch.ScoreValue.Moderate); matches = PatientProfileMatch.Combine(highMatches, moderateMatchesViaName); RemoveConflicts(targetProfile.Patient, matches); return matches; }
public PatientProfileSummary CreatePatientProfileSummary(PatientProfile profile, IPersistenceContext context) { var nameAssembler = new PersonNameAssembler(); var healthcardAssembler = new HealthcardAssembler(); var summary = new PatientProfileSummary { Mrn = new MrnAssembler().CreateMrnDetail(profile.Mrn), DateOfBirth = profile.DateOfBirth, Healthcard = healthcardAssembler.CreateHealthcardDetail(profile.Healthcard), Name = nameAssembler.CreatePersonNameDetail(profile.Name), PatientRef = profile.Patient.GetRef(), PatientProfileRef = profile.GetRef(), Sex = EnumUtils.GetEnumValueInfo(profile.Sex, context) }; return summary; }
public PatientProfileDiff CreatePatientProfileDiff(PatientProfile left, PatientProfile right, IList<DiscrepancyTestResult> results) { var diff = new PatientProfileDiff(); diff.LeftProfileAssigningAuthority = left.Mrn.AssigningAuthority.Code; diff.RightProfileAssigningAuthority = right.Mrn.AssigningAuthority.Code; diff.DateOfBirth = CreatePropertyDiff(PatientProfileDiscrepancy.DateOfBirth, results); diff.FamilyName = CreatePropertyDiff(PatientProfileDiscrepancy.FamilyName, results); diff.GivenName = CreatePropertyDiff(PatientProfileDiscrepancy.GivenName, results); diff.Healthcard = CreatePropertyDiff(PatientProfileDiscrepancy.Healthcard, results); diff.HomeAddress = CreatePropertyDiff(PatientProfileDiscrepancy.HomeAddress, results); diff.HomePhone = CreatePropertyDiff(PatientProfileDiscrepancy.HomePhone, results); diff.MiddleName = CreatePropertyDiff(PatientProfileDiscrepancy.MiddleName, results); diff.Sex = CreatePropertyDiff(PatientProfileDiscrepancy.Sex, results); diff.WorkAddress = CreatePropertyDiff(PatientProfileDiscrepancy.WorkAddress, results); diff.WorkPhone = CreatePropertyDiff(PatientProfileDiscrepancy.WorkPhone, results); return diff; }
public override AlertNotification Test(PatientProfile profile, IPersistenceContext context) { var reasons = new List<string>(); TestName(profile.Name, ref reasons); TestAddresses(profile.Addresses, ref reasons); TestTelephoneNumbers(profile.TelephoneNumbers, ref reasons); var settings = new AlertsSettings(); if(settings.MissingHealthcardInfoTriggersIncompleteDemographicDataAlert) { TestHealthcard(profile.Healthcard, ref reasons); } if (reasons.Count > 0) return new AlertNotification(this.Id, reasons); return null; }
/// <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; }
public PatientProfileDetail CreatePatientProfileDetail(PatientProfile profile, IPersistenceContext context) { return CreatePatientProfileDetail(profile, context, true, true, true, true, true, true, true); }
public PatientProfileDetail CreatePatientProfileDetail(PatientProfile profile, IPersistenceContext context, bool includeAddresses, bool includeContactPersons, bool includeEmailAddresses, bool includeTelephoneNumbers, bool includeNotes, bool includeAttachments, bool includeAllergies) { var healthcardAssembler = new HealthcardAssembler(); var nameAssembler = new PersonNameAssembler(); var addressAssembler = new AddressAssembler(); var telephoneAssembler = new TelephoneNumberAssembler(); var detail = new PatientProfileDetail { PatientRef = profile.Patient.GetRef(), PatientProfileRef = profile.GetRef(), Mrn = new MrnAssembler().CreateMrnDetail(profile.Mrn), Healthcard = healthcardAssembler.CreateHealthcardDetail(profile.Healthcard), Name = nameAssembler.CreatePersonNameDetail(profile.Name), Sex = EnumUtils.GetEnumValueInfo(profile.Sex, context), DateOfBirth = profile.DateOfBirth, DeathIndicator = profile.DeathIndicator, TimeOfDeath = profile.TimeOfDeath, PrimaryLanguage = EnumUtils.GetEnumValueInfo(profile.PrimaryLanguage), Religion = EnumUtils.GetEnumValueInfo(profile.Religion), CurrentHomeAddress = addressAssembler.CreateAddressDetail(profile.CurrentHomeAddress, context), CurrentWorkAddress = addressAssembler.CreateAddressDetail(profile.CurrentWorkAddress, context), CurrentHomePhone = telephoneAssembler.CreateTelephoneDetail(profile.CurrentHomePhone, context), CurrentWorkPhone = telephoneAssembler.CreateTelephoneDetail(profile.CurrentWorkPhone, context), BillingInformation = profile.BillingInformation }; if (includeTelephoneNumbers) { detail.TelephoneNumbers = new List<TelephoneDetail>(); foreach (var t in profile.TelephoneNumbers) { detail.TelephoneNumbers.Add(telephoneAssembler.CreateTelephoneDetail(t, context)); } } if (includeAddresses) { detail.Addresses = new List<AddressDetail>(); foreach (var a in profile.Addresses) { detail.Addresses.Add(addressAssembler.CreateAddressDetail(a, context)); } } if (includeContactPersons) { var contactPersonAssembler = new ContactPersonAssembler(); detail.ContactPersons = new List<ContactPersonDetail>(); foreach (var cp in profile.ContactPersons) { detail.ContactPersons.Add(contactPersonAssembler.CreateContactPersonDetail(cp)); } } if (includeEmailAddresses) { var emailAssembler = new EmailAddressAssembler(); detail.EmailAddresses = new List<EmailAddressDetail>(); foreach (var e in profile.EmailAddresses) { detail.EmailAddresses.Add(emailAssembler.CreateEmailAddressDetail(e, context)); } } if (includeNotes) { var noteAssembler = new PatientNoteAssembler(); detail.Notes = new List<PatientNoteDetail>(); foreach (var n in profile.Patient.Notes) { detail.Notes.Add(noteAssembler.CreateNoteDetail(n, context)); } } if (includeAttachments) { var attachmentAssembler = new PatientAttachmentAssembler(); detail.Attachments = new List<AttachmentSummary>(); foreach (var a in profile.Patient.Attachments) { detail.Attachments.Add(attachmentAssembler.CreatePatientAttachmentSummary(a, context)); } } if (includeAllergies) { var allergyAssembler = new PatientAllergyAssembler(); detail.Allergies = new List<PatientAllergyDetail>(); foreach (var a in profile.Patient.Allergies) { detail.Allergies.Add(allergyAssembler.CreateAllergyDetail(a)); } } return detail; }
private static void IdentifyConflictsForSiteFromProposedMatches(PatientProfile existingReconciledProfile, IList<PatientProfileMatch> matches, IList<PatientProfileMatch> conflicts) { String existingMrn = existingReconciledProfile.Mrn.AssigningAuthority.Code; foreach (PatientProfileMatch proposedMatch in matches) { if (proposedMatch.PatientProfile.Mrn.AssigningAuthority.Code == existingMrn) { conflicts.Add(proposedMatch); RemoveAllProfilesRelatedToConflict(proposedMatch, matches, conflicts); } } }
public ReplaceOrderOperationData(string operation, PatientProfile patientProfile, Order cancelledOrder, Order newOrder) : base(operation, patientProfile) { this.CancelledOrder = new OrderData(cancelledOrder); this.NewOrder = new OrderData(newOrder); }
public MergeOrderOperationData(string operation, PatientProfile patientProfile, Order destOrder, IEnumerable<Order> mergedOrders) : base(operation, patientProfile) { this.MergedIntoOrder = new OrderData(destOrder); this.MergedOrders = mergedOrders.Select(x => new OrderData(x)).ToList(); }
public CancelOrderOperationData(string operation, PatientProfile patientProfile, Order order) : base(operation, patientProfile, order) { this.CancelReason = EnumUtils.GetEnumValueInfo(order.CancelInfo.Reason); }
public OperationData(string operation, PatientProfile patientProfile) { Operation = operation; Patient = new PatientData(patientProfile); }
public OperationData(string operation, PatientProfile patientProfile, Order order) { Operation = operation; Patient = new PatientData(patientProfile); Order = new OrderData(order); }
public OperationData(string operation, PatientProfile patientProfile, Order order, IEnumerable<Procedure> procedures) { Operation = operation; Patient = new PatientData(patientProfile); Order = new OrderData(order); Procedures = procedures.Select(rp => new ProcedureData(rp)).ToList(); }
public void AddNewPatient(PatientProfile patient) { throw new NotImplementedException(); }
public PatientData(PatientProfile patientProfile) { Mrn = patientProfile.Mrn.ToString(); Name = patientProfile.Name.ToString(); }
public void UpdatePatientProfile(PatientProfile patient) { throw new NotImplementedException(); }
public AddPatientResponse AddPatient(AddPatientRequest request) { var profile = new PatientProfile(); // check if we should auto-generate the MRN var workflowConfig = new WorkflowConfigurationReader(); if (workflowConfig.AutoGenerateMrn) { var authorities = PersistenceContext.GetBroker<IEnumBroker>().Load<InformationAuthorityEnum>(false); // just use the first Information Authority (there is typically only one in this case) profile.Mrn.AssigningAuthority = CollectionUtils.FirstElement(authorities); profile.Mrn.Id = PersistenceContext.GetBroker<IMrnBroker>().GetNext(); } var patient = new Patient(); patient.AddProfile(profile); UpdateHelper(profile, request.PatientDetail, true, true, !workflowConfig.AutoGenerateMrn); PersistenceContext.Lock(patient, DirtyState.New); LogicalHL7Event.PatientCreated.EnqueueEvents(profile); PersistenceContext.SynchState(); var assembler = new PatientProfileAssembler(); return new AddPatientResponse(assembler.CreatePatientProfileSummary(profile, PersistenceContext)); }
private void UpdateHelper(PatientProfile profile, PatientProfileDetail detail, bool updatePatient, bool updateProfile, bool updateMrn) { if (updatePatient) { var patient = profile.Patient; var noteAssembler = new PatientNoteAssembler(); noteAssembler.Synchronize(patient, detail.Notes, CurrentUserStaff, PersistenceContext); var attachmentAssembler = new PatientAttachmentAssembler(); attachmentAssembler.Synchronize(patient.Attachments, detail.Attachments, this.CurrentUserStaff, PersistenceContext); var allergyAssembler = new PatientAllergyAssembler(); allergyAssembler.Synchronize(patient.Allergies, detail.Allergies, PersistenceContext); } if (updateProfile) { var assembler = new PatientProfileAssembler(); assembler.UpdatePatientProfile(profile, detail, updateMrn, PersistenceContext); } }
public void UpdatePatientProfile(PatientProfile profile, PatientProfileDetail detail, bool updateMrn, IPersistenceContext context) { if(updateMrn) { profile.Mrn.Id = detail.Mrn.Id; profile.Mrn.AssigningAuthority = EnumUtils.GetEnumValue<InformationAuthorityEnum>(detail.Mrn.AssigningAuthority, context); } profile.Healthcard = new HealthcardNumber(); new HealthcardAssembler().UpdateHealthcard(profile.Healthcard, detail.Healthcard, context); var nameAssembler = new PersonNameAssembler(); nameAssembler.UpdatePersonName(detail.Name, profile.Name); profile.Sex = EnumUtils.GetEnumValue<Sex>(detail.Sex); profile.DateOfBirth = detail.DateOfBirth; profile.DeathIndicator = detail.DeathIndicator; profile.TimeOfDeath = detail.TimeOfDeath; profile.PrimaryLanguage = EnumUtils.GetEnumValue<SpokenLanguageEnum>(detail.PrimaryLanguage, context); profile.Religion = EnumUtils.GetEnumValue<ReligionEnum>(detail.Religion, context); profile.BillingInformation = detail.BillingInformation; var telephoneAssembler = new TelephoneNumberAssembler(); profile.TelephoneNumbers.Clear(); if (detail.TelephoneNumbers != null) { foreach (var phoneDetail in detail.TelephoneNumbers) { profile.TelephoneNumbers.Add(telephoneAssembler.CreateTelephoneNumber(phoneDetail)); } } var addressAssembler = new AddressAssembler(); profile.Addresses.Clear(); if (detail.Addresses != null) { foreach (var addressDetail in detail.Addresses) { profile.Addresses.Add(addressAssembler.CreateAddress(addressDetail)); } } var emailAssembler = new EmailAddressAssembler(); profile.EmailAddresses.Clear(); foreach (var e in detail.EmailAddresses) { profile.EmailAddresses.Add(emailAssembler.CreateEmailAddress(e)); } var contactAssembler = new ContactPersonAssembler(); profile.ContactPersons.Clear(); foreach (var cp in detail.ContactPersons) { profile.ContactPersons.Add(contactAssembler.CreateContactPerson(cp, context)); } }