Пример #1
0
        /// <summary>
        /// Create Get Patient details
        /// </summary>
        internal MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.RegistrationEvent <MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity> CreateRegistrationEventDetailEx(RegistrationEvent res, List <IResultDetail> details)
        {
            var retVal = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.RegistrationEvent <MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity>();

            var person          = res.FindComponent(HealthServiceRecordSiteRoleType.SubjectOf) as Person;
            var custodialDevice = res.FindComponent(HealthServiceRecordSiteRoleType.PlaceOfRecord | HealthServiceRecordSiteRoleType.ResponsibleFor) as RepositoryDevice;
            var replacement     = res.FindAllComponents(HealthServiceRecordSiteRoleType.ReplacementOf);

            // person
            if (person == null)
            {
                retVal.Subject = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject4 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity>()
                {
                    NullFlavor = NullFlavor.NoInformation
                }
            }
            ;
            else
            {
                retVal.Subject = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject4 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101102CA.IdentifiedEntity>(CreateRegisteredRoleAlt(person, details));
            }

            // custodial device
            if (custodialDevice == null)
            {
                retVal.Custodian = new MARC.Everest.RMIM.CA.R020403.REPC_MT000007CA.Custodian()
                {
                    NullFlavor = NullFlavor.NoInformation
                }
            }
            ;
            else
            {
                retVal.Custodian = CreateCustodialDevice(custodialDevice, details);
            }

            // Replacement
            foreach (RegistrationEvent replc in replacement)
            {
                retVal.ReplacementOf.Add(new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.ReplacementOf(
                                             new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.PriorRegistration(
                                                 new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.Subject5(
                                                     new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.PriorRegisteredRole()
                {
                    Id = CreateII(replc.AlternateIdentifier, details)
                }
                                                     )
                                                 )
                                             ));
            }

            return(retVal);
        }
Пример #2
0
        /// <summary>
        /// Create audit data
        /// </summary>
        internal AuditData CreateAuditData(string itiName, ActionType action, OutcomeIndicator outcome, Hl7MessageReceivedEventArgs msgEvent, List <VersionedDomainIdentifier> identifiers)
        {
            // Audit data
            AuditData retVal = null;

            AuditableObjectLifecycle lifecycle = AuditableObjectLifecycle.Access;

            // Get the config service
            ISystemConfigurationService config = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;

            Terser terser = new Terser(msgEvent.Message);

            // Source and dest
            string sourceData = String.Format("{0}|{1}", terser.Get("/MSH-3"), terser.Get("/MSH-4")),
                   destData   = String.Format("{0}|{1}", terser.Get("/MSH-5"), terser.Get("/MSH-6"));


            switch (itiName)
            {
            case "ITI-21":
            {
                retVal = new AuditData(DateTime.Now, action, outcome, EventIdentifierType.Query, new CodeValue(itiName, "IHE Transactions")
                    {
                        DisplayName = "Patient Demographics Query"
                    });

                // Audit actor for Patient Identity Source
                retVal.Actors.Add(new AuditActorData()
                    {
                        UserIsRequestor = true,
                        UserIdentifier  = sourceData,
                        ActorRoleCode   = new List <CodeValue>()
                        {
                            new  CodeValue("110153", "DCM")
                            {
                                DisplayName = "Source"
                            }
                        },
                        NetworkAccessPointId   = msgEvent.SolicitorEndpoint.Host,
                        NetworkAccessPointType = msgEvent.SolicitorEndpoint.HostNameType == UriHostNameType.Dns ? NetworkAccessPointType.MachineName : NetworkAccessPointType.IPAddress
                    });


                // Add query parameters
                retVal.AuditableObjects.Add(
                    new AuditableObject()
                    {
                        IDTypeCode       = AuditableObjectIdType.Custom,
                        CustomIdTypeCode = new CodeValue(itiName, "IHE Transactions")
                        {
                            DisplayName = "Patient Demographics Query"
                        },
                        QueryData  = Convert.ToBase64String(CreateMessageSerialized(msgEvent.Message)),
                        Type       = AuditableObjectType.SystemObject,
                        Role       = AuditableObjectRole.Query,
                        ObjectId   = terser.Get("/QPD-2"),
                        ObjectData = new Dictionary <string, byte[]>()
                        {
                            { "MSH-10", System.Text.Encoding.ASCII.GetBytes(terser.Get("/MSH-10")) }
                        }
                    }
                    );

                // Audit actor for PDQ
                retVal.Actors.Add(new AuditActorData()
                    {
                        UserIdentifier  = destData,
                        UserIsRequestor = false,
                        ActorRoleCode   = new List <CodeValue>()
                        {
                            new CodeValue("110152", "DCM")
                            {
                                DisplayName = "Destination"
                            }
                        },
                        NetworkAccessPointType = NetworkAccessPointType.MachineName,
                        NetworkAccessPointId   = Dns.GetHostName(),
                        AlternativeUserId      = Process.GetCurrentProcess().Id.ToString()
                    });
                break;
            }

            case "ITI-8":
            {
                retVal = new AuditData(DateTime.Now, action, outcome, EventIdentifierType.PatientRecord, new CodeValue(itiName, "IHE Transactions")
                    {
                        DisplayName = "Patient Identity Feed"
                    });

                // Audit actor for Patient Identity Source
                retVal.Actors.Add(new AuditActorData()
                    {
                        UserIsRequestor = true,
                        UserIdentifier  = sourceData,
                        ActorRoleCode   = new List <CodeValue>()
                        {
                            new  CodeValue("110153", "DCM")
                            {
                                DisplayName = "Source"
                            }
                        },
                        NetworkAccessPointId   = msgEvent.SolicitorEndpoint.Host,
                        NetworkAccessPointType = msgEvent.SolicitorEndpoint.HostNameType == UriHostNameType.Dns ? NetworkAccessPointType.MachineName : NetworkAccessPointType.IPAddress
                    });

                // Audit actor for PDQ
                retVal.Actors.Add(new AuditActorData()
                    {
                        UserIdentifier  = destData,
                        UserIsRequestor = false,
                        ActorRoleCode   = new List <CodeValue>()
                        {
                            new CodeValue("110152", "DCM")
                            {
                                DisplayName = "Destination"
                            }
                        },
                        NetworkAccessPointType = NetworkAccessPointType.MachineName,
                        NetworkAccessPointId   = Dns.GetHostName(),
                        AlternativeUserId      = Process.GetCurrentProcess().Id.ToString()
                    });
                break;
            }

            case "ITI-9":
            {
                retVal = new AuditData(DateTime.Now, action, outcome, EventIdentifierType.Query, new CodeValue(itiName, "IHE Transactions")
                    {
                        DisplayName = "PIX Query"
                    });

                // Audit actor for Patient Identity Source
                retVal.Actors.Add(new AuditActorData()
                    {
                        UserIsRequestor = true,
                        UserIdentifier  = sourceData,
                        ActorRoleCode   = new List <CodeValue>()
                        {
                            new  CodeValue("110153", "DCM")
                            {
                                DisplayName = "Source"
                            }
                        },
                        NetworkAccessPointId   = msgEvent.SolicitorEndpoint.Host,
                        NetworkAccessPointType = msgEvent.SolicitorEndpoint.HostNameType == UriHostNameType.Dns ? NetworkAccessPointType.MachineName : NetworkAccessPointType.IPAddress
                    });

                // Add query parameters
                retVal.AuditableObjects.Add(
                    new AuditableObject()
                    {
                        IDTypeCode       = AuditableObjectIdType.Custom,
                        CustomIdTypeCode = new CodeValue("ITI-9", "IHE Transactions")
                        {
                            DisplayName = "PIX Query"
                        },
                        QueryData  = Convert.ToBase64String(CreateMessageSerialized(msgEvent.Message)),
                        Type       = AuditableObjectType.SystemObject,
                        Role       = AuditableObjectRole.Query,
                        ObjectId   = terser.Get("/QPD-2"),
                        ObjectData = new Dictionary <string, byte[]>()
                        {
                            { "MSH-10", System.Text.Encoding.ASCII.GetBytes(terser.Get("/MSH-10")) }
                        }
                    }
                    );

                // Audit actor for PDQ
                retVal.Actors.Add(new AuditActorData()
                    {
                        UserIdentifier  = destData,
                        UserIsRequestor = false,
                        ActorRoleCode   = new List <CodeValue>()
                        {
                            new CodeValue("110152", "DCM")
                            {
                                DisplayName = "Destination"
                            }
                        },
                        NetworkAccessPointType = NetworkAccessPointType.MachineName,
                        NetworkAccessPointId   = Dns.GetHostName(),
                        AlternativeUserId      = Process.GetCurrentProcess().Id.ToString()
                    });
                break;
            }
            }

            var expDatOid = config.OidRegistrar.GetOid("CR_CID");

            // HACK: Use only patient identifiers in the output
            foreach (var id in identifiers.Where(o => o.Domain != expDatOid.Oid).ToArray())
            {
                RegistrationEvent evt = this.m_dataPersistence.GetContainer(id, true) as RegistrationEvent;
                if (evt != null)
                {
                    identifiers.Remove(id);
                    foreach (Person subj in evt.FindAllComponents(HealthServiceRecordSiteRoleType.SubjectOf))
                    {
                        identifiers.Add(new VersionedDomainIdentifier()
                        {
                            Identifier = subj.Id.ToString(),
                            Domain     = expDatOid.Oid
                        });
                    }
                }
            }

            // Audit patients
            foreach (var id in identifiers)
            {
                // If the id is not a patient then
                // Construct the audit object
                AuditableObject aud = new AuditableObject()
                {
                    IDTypeCode = AuditableObjectIdType.PatientNumber,
                    Role       = AuditableObjectRole.Patient,
                    Type       = AuditableObjectType.Person
                };

                // Lifecycle
                switch (action)
                {
                case ActionType.Create:
                    aud.LifecycleType = AuditableObjectLifecycle.Creation;
                    break;

                case ActionType.Delete:
                    aud.LifecycleType = AuditableObjectLifecycle.LogicalDeletion;
                    break;

                case ActionType.Execute:
                    aud.LifecycleType = AuditableObjectLifecycle.Access;
                    break;

                case ActionType.Read:
                    aud.LifecycleType = AuditableObjectLifecycle.Disclosure;
                    break;

                case ActionType.Update:
                    aud.LifecycleType = AuditableObjectLifecycle.Amendment;
                    break;
                }

                aud.ObjectData.Add("MSH-10", System.Text.Encoding.ASCII.GetBytes(terser.Get("/MSH-10")));
                aud.ObjectId = String.Format("{1}^^^{2}&{0}&ISO", expDatOid.Oid, id.Identifier, expDatOid.Attributes.Find(o => o.Key == "AssigningAuthorityName").Value);
                retVal.AuditableObjects.Add(aud);
            }


            return(retVal);
        }
Пример #3
0
        /// <summary>
        /// Create the response registration event
        /// </summary>
        internal MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.RegistrationEvent <MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.IdentifiedEntity> CreateRegistrationEventDetail(RegistrationEvent res, List <IResultDetail> details)
        {
            var retVal = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.RegistrationEvent <MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.IdentifiedEntity>();

            var person          = res.FindComponent(HealthServiceRecordSiteRoleType.SubjectOf) as Person;
            var custodialDevice = res.FindComponent(HealthServiceRecordSiteRoleType.PlaceOfRecord | HealthServiceRecordSiteRoleType.ResponsibleFor) as RepositoryDevice;
            var replacement     = res.FindAllComponents(HealthServiceRecordSiteRoleType.ReplacementOf);

            // person
            if (person == null)
            {
                retVal.Subject = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject4 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.IdentifiedEntity>()
                {
                    NullFlavor = NullFlavor.NoInformation
                }
            }
            ;
            else
            {
                var regRole = CreateRegisteredRole(person, details);
                retVal.Subject = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject4 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.IdentifiedEntity>(
                    new MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.IdentifiedEntity(
                        regRole.Id,
                        regRole.StatusCode,
                        regRole.EffectiveTime,
                        regRole.ConfidentialityCode,
                        new MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.Person(),
                        regRole.SubjectOf
                        ));
                if (regRole.IdentifiedPerson != null && regRole.IdentifiedPerson.NullFlavor == null)
                {
                    foreach (var othId in regRole.IdentifiedPerson.AsOtherIDs)
                    {
                        retVal.Subject.registeredRole.IdentifiedPerson.AsOtherIDs.Add(
                            new MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.OtherIDs(
                                othId.Id,
                                othId.Code,
                                new MARC.Everest.RMIM.CA.R020403.PRPA_MT101106CA.IdOrganization(
                                    othId.AssigningIdOrganization.Id,
                                    othId.AssigningIdOrganization.Name)
                                ));
                    }
                }
            }

            // custodial device
            if (custodialDevice == null)
            {
                retVal.Custodian = new MARC.Everest.RMIM.CA.R020403.REPC_MT000007CA.Custodian()
                {
                    NullFlavor = NullFlavor.NoInformation
                }
            }
            ;
            else
            {
                retVal.Custodian = CreateCustodialDevice(custodialDevice, details);
            }

            // Replacement
            foreach (RegistrationEvent replc in replacement)
            {
                retVal.ReplacementOf.Add(new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.ReplacementOf(
                                             new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.PriorRegistration(
                                                 new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.Subject5(
                                                     new MARC.Everest.RMIM.CA.R020403.MFMI_MT700726CA.PriorRegisteredRole()
                {
                    Id = CreateII(replc.AlternateIdentifier, details)
                }
                                                     )
                                                 )
                                             ));
            }

            return(retVal);
        }