コード例 #1
0
        /// <summary>
        /// Create the registration event
        /// </summary>
        internal MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object> CreateRegistrationEventDetail(Core.ComponentModel.RegistrationEvent res, List <MARC.Everest.Connectors.IResultDetail> details)
        {
            // Patient
            var patient = res.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person;

            if (patient == null)
            {
                return new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>()
                       {
                           NullFlavor = NullFlavor.NoInformation
                       }
            }
            ;

            var scoper = patient.FindComponent(HealthServiceRecordSiteRoleType.PlaceOfEntry | HealthServiceRecordSiteRoleType.InformantTo) as HealthcareParticipant;

            // Return status
            var retVal = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>(
                ActStatus.Active,
                new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject2 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient>(
                    new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient(
                        CreateIISet(patient.AlternateIdentifiers, details),
                        ConvertStatus(patient.Status, details),
                        null,
                        null
                        //CreateOrganization(scoper, details)
                        )
                    )
                );

            retVal.Subject1.registeredRole.SetPatientEntityChoiceSubject(CreatePerson(patient, details));
            return(retVal);
        }
コード例 #2
0
        /// <summary>
        /// Update the specified PID
        /// </summary>
        public void UpdatePID(Core.ComponentModel.RegistrationEvent registrationEvent, NHapi.Model.V25.Segment.PID pid, bool summaryOnly)
        {
            var subject = registrationEvent.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person;
            var aut     = registrationEvent.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.AuthorOf) as RepositoryDevice;

            // Update time
            pid.LastUpdateDateTime.Time.Value = ((TS)subject.Timestamp).Value;
            if (aut != null)
            {
                pid.LastUpdateFacility.NamespaceID.Value = aut.Jurisdiction;
            }

            // Alternate identifiers
            foreach (var altId in subject.AlternateIdentifiers)
            {
                var id = pid.GetPatientIdentifierList(pid.PatientIdentifierListRepetitionsUsed);
                UpdateCX(altId, id);
            }

            // Other identifiers
            foreach (var othId in subject.OtherIdentifiers)
            {
                var id = pid.GetPatientIdentifierList(pid.PatientIdentifierListRepetitionsUsed);
                UpdateCX(othId.Value, id);

                // Correct v3 codes
                if (othId.Key.CodeSystem == "1.3.6.1.4.1.33349.3.98.12")
                {
                    id.IdentifierTypeCode.Value = othId.Key.Code;
                }
                else if (othId.Key.CodeSystem == "2.16.840.1.113883.2.20.3.85")
                {
                    switch (othId.Key.Code)
                    {
                    case "SIN":
                        id.IdentifierTypeCode.Value = "SS";
                        break;

                    case "DL":
                        id.IdentifierTypeCode.Value = othId.Key.Code;
                        break;

                    default:
                        id.IdentifierTypeCode.Value = null;
                        break;
                    }
                }
                else
                {
                    id.IdentifierTypeCode.Value = null;
                }
            }

            // IHE: This first repetition should be null
            if (summaryOnly)
            {
                pid.GetPatientName(0);
                pid.GetPatientName(1).NameTypeCode.Value = "S";
                return;
            }

            // Populate Names
            if (subject.Names != null)
            {
                foreach (var name in subject.Names)
                {
                    var xpn = pid.GetPatientName(pid.PatientNameRepetitionsUsed);
                    UpdateXPN(name, xpn);
                }
            }

            // Birth time
            if (subject.BirthTime != null)
            {
                MARC.Everest.DataTypes.TS ts = new Everest.DataTypes.TS(subject.BirthTime.Value, ReverseLookup(ComponentUtility.TS_PREC_MAP, subject.BirthTime.Precision));
                pid.DateTimeOfBirth.Time.Value = MARC.Everest.Connectors.Util.ToWireFormat(ts);
            }

            // Admin Sex
            if (subject.GenderCode != null)
            {
                pid.AdministrativeSex.Value = subject.GenderCode;
            }

            // Address
            if (subject.Addresses != null)
            {
                foreach (var addr in subject.Addresses)
                {
                    var ad = pid.GetPatientAddress(pid.PatientAddressRepetitionsUsed);
                    UpdateAD(addr, ad);
                }
            }

            // Death
            if (subject.DeceasedTime != null)
            {
                pid.PatientDeathIndicator.Value = "Y";
                MARC.Everest.DataTypes.TS ts = new Everest.DataTypes.TS(subject.DeceasedTime.Value, ReverseLookup(ComponentUtility.TS_PREC_MAP, subject.DeceasedTime.Precision));
                pid.PatientDeathDateAndTime.Time.Value = MARC.Everest.Connectors.Util.ToWireFormat(ts);
            }

            // MB Order
            if (subject.BirthOrder.HasValue)
            {
                pid.MultipleBirthIndicator.Value = "Y";
                if (subject.BirthOrder.Value > 0)
                {
                    pid.BirthOrder.Value = subject.BirthOrder.ToString();
                }
            }

            // Citizenship
            if (subject.Citizenship != null)
            {
                foreach (var cit in subject.Citizenship)
                {
                    if (cit.Status == SVC.Core.ComponentModel.Components.StatusType.Active)
                    {
                        var c = pid.GetCitizenship(pid.CitizenshipRepetitionsUsed);
                        UpdateCE(new CodeValue(cit.CountryCode, this.m_config.OidRegistrar.GetOid("ISO3166-1").Oid), c);
                    }
                }
            }

            if (subject.MaritalStatus != null)
            {
                UpdateCE(subject.MaritalStatus, pid.MaritalStatus);
            }
            // Language
            if (subject.Language != null)
            {
                foreach (var lang in subject.Language)
                {
                    if (lang.Type == LanguageType.Preferred)
                    {
                        UpdateCE(new CodeValue(lang.Language, this.m_config.OidRegistrar.GetOid("ISO639-1").Oid), pid.PrimaryLanguage);
                        break;
                    }
                }
            }

            // Mothers name
            var relations = subject.FindAllComponents(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.RepresentitiveOf);

            foreach (var r in relations)
            {
                if (r is PersonalRelationship)
                {
                    var psn = r as PersonalRelationship;
                    if (psn.RelationshipKind != "MTH")
                    {
                        continue;
                    }

                    if (psn.AlternateIdentifiers != null)
                    {
                        foreach (var altid in psn.AlternateIdentifiers)
                        {
                            var id = pid.GetMotherSIdentifier(pid.MotherSIdentifierRepetitionsUsed);
                            UpdateCX(altid, id);
                        }
                    }
                    if (psn.LegalName != null)
                    {
                        UpdateXPN(psn.LegalName, pid.GetMotherSMaidenName(0));
                    }
                }
            }

            // Telecom addresses
            foreach (var tel in subject.TelecomAddresses)
            {
                if (tel.Use == "HP" && tel.Value.StartsWith("tel"))
                {
                    MessageUtil.XTNFromTel(new TEL()
                    {
                        Value        = tel.Value,
                        Use          = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationAddressUse> > >(tel.Use),
                        Capabilities = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationCabability> > >(tel.Capability)
                    }, pid.GetPhoneNumberHome(pid.PhoneNumberHomeRepetitionsUsed));
                }
                else if (tel.Use == "HP")
                {
                    pid.GetPhoneNumberHome(pid.PhoneNumberHomeRepetitionsUsed).EmailAddress.Value = tel.Value;
                }
                else if (tel.Use == "WP" && tel.Value.StartsWith("tel"))
                {
                    MessageUtil.XTNFromTel(new TEL()
                    {
                        Value        = tel.Value,
                        Use          = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationAddressUse> > >(tel.Use),
                        Capabilities = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationCabability> > >(tel.Capability)
                    }, pid.GetPhoneNumberBusiness(pid.PhoneNumberBusinessRepetitionsUsed));
                }
                else if (tel.Use == "WP")
                {
                    pid.GetPhoneNumberBusiness(pid.PhoneNumberBusinessRepetitionsUsed).EmailAddress.Value = tel.Value;
                }
            }

            // Race
            if (subject.Race != null)
            {
                foreach (var rc in subject.Race)
                {
                    this.UpdateCE(rc, pid.GetRace(pid.RaceRepetitionsUsed));
                }
            }

            // Ethnic code
            if (subject.EthnicGroup != null)
            {
                foreach (var e in subject.EthnicGroup)
                {
                    this.UpdateCE(e, pid.GetEthnicGroup(pid.EthnicGroupRepetitionsUsed));
                }
            }


            // Place of birth
            if (subject.BirthPlace != null)
            {
                pid.BirthPlace.Value = subject.BirthPlace.Name;
            }
        }
コード例 #3
0
        /// <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);
        }