public static Patient CreatePatient(string mrn) { Patient patient = new Patient(); PatientProfile profile = new PatientProfile( new PatientIdentifier(mrn, new InformationAuthorityEnum("UHN", "UHN", "")), null, new HealthcardNumber("1111222333", new InsuranceAuthorityEnum("OHIP", "OHIP", ""), null, null), new PersonName("Roberts", "Bob", null, null, null, null), DateTime.Now - TimeSpan.FromDays(4000), Sex.M, new SpokenLanguageEnum("en", "English", null), new ReligionEnum("X", "unknown", null), false, null, null, null, null, null, null, null, patient ); patient.AddProfile(profile); return patient; }
public Patient GetPatient(string mrn, string assigningAuthority, bool createIfNotExist) { Platform.CheckForEmptyString(mrn, "mrn"); Platform.CheckForEmptyString(assigningAuthority, "assigningAuthority"); var infoAuth = _persistenceContext.GetBroker <IEnumBroker>().TryFind <InformationAuthorityEnum>(assigningAuthority); Patient patient = null; var criteria = new PatientProfileSearchCriteria(); criteria.Mrn.Id.EqualTo(mrn); criteria.Mrn.AssigningAuthority.EqualTo(infoAuth); try { var profile = _persistenceContext.GetBroker <IPatientProfileBroker>().FindOne(criteria); patient = profile.Patient; _patients.Add(new LockableEntity <Patient>(patient, DirtyState.Dirty)); } catch (EntityNotFoundException) { if (createIfNotExist) { patient = new Patient(); _patients.Add(new LockableEntity <Patient>(patient, DirtyState.New)); var profile = new PatientProfile { Mrn = { Id = mrn, AssigningAuthority = infoAuth } }; patient.AddProfile(profile); } } return(patient); }
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))); }
public static Patient CreatePatient(string mrn) { Patient patient = new Patient(); PatientProfile profile = new PatientProfile( new PatientIdentifier(mrn, new InformationAuthorityEnum("UHN", "UHN", "")), null, new HealthcardNumber("1111222333", new InsuranceAuthorityEnum("OHIP", "OHIP", ""), null, null), new PersonName("Roberts", "Bob", null, null, null, null), DateTime.Now - TimeSpan.FromDays(4000), Sex.M, new SpokenLanguageEnum("en", "English", null), new ReligionEnum("X", "unknown", null), false, null, null, null, null, null, null, null, patient ); patient.AddProfile(profile); return(patient); }
/// <summary> /// Reconciles the specified patient to this patient /// </summary> /// <param name="thisPatient"></param> /// <param name="otherPatient"></param> /// <param name="workflow"></param> private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow) { if (PatientIdentifierConflictsFound(thisPatient, otherPatient)) throw new PatientReconciliationException("assigning authority conflict - cannot reconcile"); // copy the collection to iterate var otherProfiles = new List<PatientProfile>(otherPatient.Profiles); foreach (var profile in otherProfiles) { thisPatient.AddProfile(profile); } // copy the collection to iterate var otherNotes = new List<PatientNote>(otherPatient.Notes); foreach (var note in otherNotes) { thisPatient.AddNote(note); } // copy the collection to iterate var otherAttachments = new List<PatientAttachment>(otherPatient.Attachments); foreach (var attachment in otherAttachments) { otherPatient.Attachments.Remove(attachment); thisPatient.Attachments.Add(attachment); } // copy the collection to iterate var otherAllergies = new List<Allergy>(otherPatient.Allergies); foreach (var allergy in otherAllergies) { otherPatient.Allergies.Remove(allergy); thisPatient.Allergies.Add(allergy); } var visitCriteria = new VisitSearchCriteria(); visitCriteria.Patient.EqualTo(otherPatient); var otherVisits = workflow.GetBroker<IVisitBroker>().Find(visitCriteria); foreach (var visit in otherVisits) { visit.Patient = thisPatient; } var orderCriteria = new OrderSearchCriteria(); orderCriteria.Patient.EqualTo(otherPatient); var otherOrders = workflow.GetBroker<IOrderBroker>().Find(orderCriteria); foreach (var order in otherOrders) { order.Patient = thisPatient; } }
static public void ReconcileBetweenInformationAuthorities(Patient thisPatient, Patient otherPatient, IPersistenceContext context) { if (Utility.PatientIdentifiersFromIdenticalInformationAuthority(thisPatient, otherPatient)) { throw new PatientReconciliationException("assigning authorities not identical conflict - cannot reconcile"); } // copy patient profiles over foreach (PatientProfile profile in otherPatient.Profiles) { thisPatient.AddProfile(profile); } ReconnectRelatedPatientInformation(thisPatient, otherPatient, context); }
/// <summary> /// Reconciles the specified patient to this patient /// </summary> /// <param name="thisPatient"></param> /// <param name="otherPatient"></param> /// <param name="workflow"></param> private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow) { if (PatientIdentifierConflictsFound(thisPatient, otherPatient)) { throw new PatientReconciliationException("assigning authority conflict - cannot reconcile"); } // copy the collection to iterate var otherProfiles = new List <PatientProfile>(otherPatient.Profiles); foreach (var profile in otherProfiles) { thisPatient.AddProfile(profile); } // copy the collection to iterate var otherNotes = new List <PatientNote>(otherPatient.Notes); foreach (var note in otherNotes) { thisPatient.AddNote(note); } // copy the collection to iterate var otherAttachments = new List <PatientAttachment>(otherPatient.Attachments); foreach (var attachment in otherAttachments) { otherPatient.Attachments.Remove(attachment); thisPatient.Attachments.Add(attachment); } // copy the collection to iterate var otherAllergies = new List <Allergy>(otherPatient.Allergies); foreach (var allergy in otherAllergies) { otherPatient.Allergies.Remove(allergy); thisPatient.Allergies.Add(allergy); } var visitCriteria = new VisitSearchCriteria(); visitCriteria.Patient.EqualTo(otherPatient); var otherVisits = workflow.GetBroker <IVisitBroker>().Find(visitCriteria); foreach (var visit in otherVisits) { visit.Patient = thisPatient; } var orderCriteria = new OrderSearchCriteria(); orderCriteria.Patient.EqualTo(otherPatient); var otherOrders = workflow.GetBroker <IOrderBroker>().Find(orderCriteria); foreach (var order in otherOrders) { order.Patient = thisPatient; } }