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); }
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)); }