/// <summary> /// Create a patient registry record added message /// </summary> private Everest.Interfaces.IInteraction CreatePatientRegistryRecordAddedMessage(Core.ComponentModel.RegistrationEvent registrationEvent, TargetConfiguration configuration) { // Construct the return value PRPA_IN201301UV02 retVal = new PRPA_IN201301UV02( Guid.NewGuid(), DateTime.Now, PRPA_IN201301UV02.GetInteractionId(), ProcessingID.Production, "T", AcknowledgementCondition.Always); // Construct the sending node retVal.VersionCode = HL7StandardVersionCode.Version3_Prerelease1; retVal.Sender = CreateSenderNode(); retVal.Receiver.Add(CreateReceiverNode(configuration)); // Construct the control act process retVal.controlActProcess = new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.ControlActProcess <Everest.RMIM.UV.NE2008.PRPA_MT201301UV02.Patient, object>("EVN"); var subject = new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Subject1 <Everest.RMIM.UV.NE2008.PRPA_MT201301UV02.Patient, object>(false, new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.RegistrationEvent <Everest.RMIM.UV.NE2008.PRPA_MT201301UV02.Patient, object>( ConvertActStatusCode(registrationEvent.Status), CreatePatient(registrationEvent, configuration) ) ); retVal.controlActProcess.Subject.Add(subject); // Custodian? subject.RegistrationEvent.Custodian = CreateCustodian(registrationEvent, configuration); return(retVal); }
/// <summary> /// Create a patient registry duplicates resolved message /// </summary> private Everest.Interfaces.IInteraction CreatePatientRegistryDuplicatesResolvedMessage(Core.ComponentModel.RegistrationEvent registrationEvent, TargetConfiguration configuration) { // Construct the return value PRPA_IN201304UV02 retVal = new PRPA_IN201304UV02( Guid.NewGuid(), DateTime.Now, PRPA_IN201304UV02.GetInteractionId(), ProcessingID.Production, "T", AcknowledgementCondition.Always); // Construct the sending node retVal.VersionCode = HL7StandardVersionCode.Version3_Prerelease1; retVal.Sender = CreateSenderNode(); retVal.Receiver.Add(CreateReceiverNode(configuration)); // Construct the control act process retVal.controlActProcess = new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.ControlActProcess <Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Patient, object>("EVN"); // Get the subjects and components var subject = registrationEvent.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person; var providerOrg = subject.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.PlaceOfEntry | SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.InformantTo) as HealthcareParticipant; var custodian = registrationEvent.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.PlaceOfRecord | SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.ResponsibleFor); var replacements = subject.FindAllComponents(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.ReplacementOf); // Create the person List <DomainIdentifier> identifiers = new List <DomainIdentifier>(subject.AlternateIdentifiers.FindAll(o => configuration.NotificationDomain.Exists(d => d.Domain.Equals(o.Domain)))); var eventRegistration = new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Subject1 <Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Patient, object>(false, new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.RegistrationEvent <Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Patient, object>( ActStatus.Active, new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Subject2 <Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Patient>( new Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Patient( CreateIISet(identifiers), RoleStatus.Active, CreatePerson(subject, new TargetConfiguration(String.Empty, null, configuration.Notifier.GetType().Name, null)), providerOrg == null ? null : CreateProviderOrganization(providerOrg) ) ) ) ); // Get person data var personData = eventRegistration.RegistrationEvent.Subject1.registeredRole.PatientEntityChoiceSubject as Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Person; personData.AsOtherIDs.Clear(); retVal.controlActProcess.Subject.Add(eventRegistration); // TODO: Replacement of compatibility mode for other XDS registries // Replacement var registration = this.Context.GetService(typeof(IDataRegistrationService)) as IDataRegistrationService; var persistence = this.Context.GetService(typeof(IDataPersistenceService)) as IDataPersistenceService; foreach (PersonRegistrationRef rplc in replacements) { // First, need to de-persist the identifiers QueryParameters qp = new QueryParameters() { Confidence = 1.0f, MatchingAlgorithm = MatchAlgorithm.Exact, MatchStrength = MatchStrength.Exact }; var patientQuery = new QueryEvent(); RegistrationEvent regEvent = new RegistrationEvent() { }; patientQuery.Add(regEvent, "SUBJ", SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf, null); patientQuery.Add(qp, "FLT", SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.FilterOf, null); regEvent.Add(new Person() { AlternateIdentifiers = rplc.AlternateIdentifiers }, "SUBJ", SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf, null); // Perform the query var pid = registration.QueryRecord(patientQuery); if (pid.Length == 0) { throw new InvalidOperationException(); } var replacedPerson = (persistence.GetContainer(pid[0], true) as RegistrationEvent).FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person; var ids = CreateIISet(replacedPerson.AlternateIdentifiers.FindAll(o => configuration.NotificationDomain.Exists(d => d.Domain == o.Domain))); if (ids.Count == 0) { ; // TODO: Trace log } else { eventRegistration.RegistrationEvent.ReplacementOf.Add(new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.ReplacementOf( new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.PriorRegistration( null, ActStatus.Obsolete, new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.Subject3( new Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.PriorRegisteredRole( ids ) ), null ) )); } } if (eventRegistration.RegistrationEvent.ReplacementOf.Count == 0) { throw new InvalidOperationException("Nothing to do"); } // Custodian? eventRegistration.RegistrationEvent.Custodian = CreateCustodian(registrationEvent, configuration); return(retVal); }