예제 #1
0
        /// <summary>
        /// Create an instance of the identified entity class from the specified person class
        /// </summary>
        internal MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity CreateIdentifiedEntity(RegistrationEvent verified, List <IResultDetail> dtls)
        {
            // Get localization service
            ILocalizationService locale = m_context.GetService(typeof(ILocalizationService)) as ILocalizationService;

            // Find the major components
            var person = verified.FindComponent(HealthServiceRecordSiteRoleType.SubjectOf) as Person;

            // Verify
            if (person == null)
            {
                dtls.Add(new NotImplementedResultDetail(ResultDetailType.Error, locale.GetString("DBCF0007"), null, null));
                return(new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity()
                {
                    NullFlavor = NullFlavor.NoInformation
                });
            }

            var mask = person.FindComponent(HealthServiceRecordSiteRoleType.FilterOf) as MaskingIndicator;

            // Return value
            var retVal = new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity(
                CreateIISet(person.AlternateIdentifiers, dtls),
                ConvertStatus(person.Status, dtls),
                CreateIVL(verified.EffectiveTime, dtls),
                mask == null ? null : CreateCV <String>(mask.MaskingCode, dtls),
                CreatePerson(person, dtls),
                new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.Subject()
            {
                NullFlavor = NullFlavor.NotApplicable
            }
                );

            // Return value
            return(retVal);
        }
예제 #2
0
        /// <summary>
        /// Create alternate registered role
        /// </summary>
        private MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity CreateRegisteredRoleAlt(Person person, List <IResultDetail> details)
        {
            ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;
            ITerminologyService         termService   = Context.GetService(typeof(ITerminologyService)) as ITerminologyService;

            var retVal = new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity();

            var relations         = person.FindAllComponents(HealthServiceRecordSiteRoleType.RepresentitiveOf);
            var maskingIndicators = person.FindComponent(HealthServiceRecordSiteRoleType.FilterOf) as MaskingIndicator;
            var queryParameter    = person.FindComponent(HealthServiceRecordSiteRoleType.CommentOn | HealthServiceRecordSiteRoleType.ComponentOf) as QueryParameters;

            // Masking indicators
            if (maskingIndicators != null)
            {
                retVal.ConfidentialityCode = CreateCV <String>(maskingIndicators.MaskingCode, details);
            }
            else
            {
                retVal.ConfidentialityCode = new CV <String>("N");
            }

            retVal.Id         = CreateIISet(person.AlternateIdentifiers, details);
            retVal.StatusCode = ConvertStatus(person.Status, details);

            // Query parameter (i.e. the match strength)
            if (queryParameter != null)
            {
                retVal.SubjectOf = new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.Subject(
                    new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.ObservationEvent(
                        (queryParameter.MatchingAlgorithm & MatchAlgorithm.Soundex) != 0 ? "PHON" : "PTNM",
                        new REAL(queryParameter.Confidence)
                {
                    Precision = 2
                }
                        )
                    );
            }

            object gend = new CV <AdministrativeGender>()
            {
                NullFlavor = NullFlavor.NoInformation
            };

            Util.TryFromWireFormat(person.GenderCode, typeof(CV <AdministrativeGender>), out gend);

            // Set the identified person
            retVal.IdentifiedPerson = new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.Person(
                null,
                null,
                gend as CV <AdministrativeGender>,
                CreateTS(person.BirthTime, details),
                person.DeceasedTime != null,
                CreateTS(person.DeceasedTime, details),
                person.BirthOrder.HasValue ? (BL)true : null,
                person.BirthOrder,
                null,
                null,
                null,
                null);

            // Create names
            retVal.IdentifiedPerson.Name = new LIST <PN>();
            if (person.Names != null)
            {
                foreach (var name in person.Names)
                {
                    retVal.IdentifiedPerson.Name.Add(CreatePN(name, details));
                }
            }
            else
            {
                retVal.IdentifiedPerson.Name.NullFlavor = NullFlavor.NoInformation;
            }

            // Create telecoms
            retVal.IdentifiedPerson.Telecom = new LIST <TEL>();
            if (person.TelecomAddresses != null)
            {
                foreach (var tel in person.TelecomAddresses)
                {
                    retVal.IdentifiedPerson.Telecom.Add(CreateTEL(tel, details));
                }
            }
            else
            {
                retVal.IdentifiedPerson.Telecom.NullFlavor = NullFlavor.NoInformation;
            }

            // Create addresses
            retVal.IdentifiedPerson.Addr = new LIST <AD>();
            if (person.Addresses != null)
            {
                foreach (var addr in person.Addresses)
                {
                    retVal.IdentifiedPerson.Addr.Add(CreateAD(addr, details));
                }
            }
            else
            {
                retVal.IdentifiedPerson.Addr.NullFlavor = NullFlavor.NoInformation;
            }

            // Create AsOtherIds
            retVal.IdentifiedPerson.AsOtherIDs = new List <MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.OtherIDs>();
            if (person.OtherIdentifiers != null)
            {
                foreach (var othId in person.OtherIdentifiers)
                {
                    var otherIdentifier = new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.OtherIDs(
                        CreateII(othId.Value, details),
                        CreateCV <String>(othId.Key, details),
                        null);
                    // Any extensions that apply to this?
                    var extId   = person.FindExtension(o => o.Name == "AssigningIdOrganizationId" && o.PropertyPath == String.Format("OtherIdentifiers[{0}{1}]", otherIdentifier.Id.Root, otherIdentifier.Id.Extension));
                    var extName = person.FindExtension(o => o.Name == "AssigningIdOrganizationName" && o.PropertyPath == String.Format("OtherIdentifiers[{0}{1}]", otherIdentifier.Id.Root, otherIdentifier.Id.Extension));
                    if (extId != null || extName != null)
                    {
                        otherIdentifier.AssigningIdOrganization = new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdOrganization(
                            extId != null ? CreateII(extId.Value as DomainIdentifier, details) : null,
                            extName != null ? extName.Value as String : null
                            );
                    }
                    retVal.IdentifiedPerson.AsOtherIDs.Add(otherIdentifier);
                }
            }

            // Languages
            if (person.Language != null)
            {
                foreach (var lang in person.Language)
                {
                    // Translate the code
                    var langCode = new CodeValue(lang.Language, configService.OidRegistrar.GetOid("ISO639-1").Oid);

                    if (termService != null)
                    {
                        langCode = termService.Translate(langCode, configService.OidRegistrar.GetOid("ISO639-3").Oid);
                    }

                    retVal.IdentifiedPerson.LanguageCommunication.Add(new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.LanguageCommunication(
                                                                          CreateCV <String>(langCode, details),
                                                                          (lang.Type & LanguageType.Preferred) != 0
                                                                          ));
                }
            }

            // Personal Relationships
            if (relations != null)
            {
                foreach (PersonalRelationship relation in relations)
                {
                    if (!String.IsNullOrEmpty(relation.RelationshipKind))
                    {
                        retVal.IdentifiedPerson.PersonalRelationship.Add(new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.PersonalRelationship(
                                                                             relation.RelationshipKind,
                                                                             new MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.ParentPerson(
                                                                                 CreateII(relation.AlternateIdentifiers[0], details),
                                                                                 CreatePN(relation.LegalName, details)
                                                                                 )
                                                                             ));
                    }
                }
            }

            return(retVal);
        }