Esempio n. 1
0
        /// <summary>
        /// Notifies a remote system.
        /// </summary>
        /// <param name="workItem">The work item of the notification.</param>
        public void Notify <T>(NotificationQueueWorkItem <T> workItem) where T : IdentifiedData
        {
            IMessage notificationMessage = null;

            var patient = workItem.Event as Patient;

            MSH msh = null;
            PID pid = null;
            EVN evn = null;
            PV1 pv1 = null;

            switch (workItem.ActionType)
            {
            case ActionType.Create:
            case ActionType.DuplicatesResolved:
            case ActionType.Update:
            {
                tracer.TraceEvent(TraceEventType.Information, 0, "Received update notification");

                ADT_A05 message = new ADT_A05();

                msh = message.MSH;
                msh.MessageType.TriggerEvent.Value = "A31";

                pid = message.PID;

                evn = message.EVN;
                evn.EventTypeCode.Value = "A31";

                pv1 = message.PV1;
                notificationMessage = message;

                break;
            }

            default:
                throw new ArgumentOutOfRangeException($"Invalid notification type {workItem.ActionType}");
            }

            NotifierBase.UpdateMSH(msh, patient, this.TargetConfiguration);

            evn.RecordedDateTime.TimeOfAnEvent.Value = (TS)patient.CreationTime.DateTime;

            NotifierBase.UpdatePID(patient, pid, this.TargetConfiguration);

            pv1.PatientClass.Value = "N";

            var queueItem = new MessageQueueWorkItem(notificationMessage, this.TargetConfiguration);

            if (!queueItem.TrySend())
            {
                tracer.TraceEvent(TraceEventType.Warning, 0, "Unable to send message to remote endpoint: {0}", this.TargetConfiguration.ConnectionString);
                Hl7MessageQueue.Current.Enqueue(queueItem);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Notifies a remote system.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="workItem">The work item of the notification.</param>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public void Notify <T>(NotificationQueueWorkItem <T> workItem) where T : IdentifiedData
        {
            IMessage notificationMessage;

            var patient = workItem.Event as Patient;

            MSH msh;
            PID pid;
            EVN evn;
            PV1 pv1;
            MRG mrg = null;

            switch (workItem.ActionType)
            {
            case ActionType.Create:
            {
                tracer.TraceEvent(TraceEventType.Information, 0, "Received create notification");

                var message = new ADT_A01();

                msh = message.MSH;
                msh.MessageType.MessageType.Value      = "ADT";
                msh.MessageType.MessageStructure.Value = "ADT_A01";
                msh.MessageType.TriggerEvent.Value     = "A01";

                pid = message.PID;

                evn = message.EVN;
                evn.EventTypeCode.Value = "A01";

                pv1 = message.PV1;
                notificationMessage = message;

                break;
            }

            case ActionType.DuplicatesResolved:
            {
                tracer.TraceEvent(TraceEventType.Information, 0, "Received duplicates resolved notification");

                var message = new ADT_A39();

                msh = message.MSH;
                msh.MessageType.MessageType.Value      = "ADT";
                msh.MessageType.MessageStructure.Value = "ADT_A40";
                msh.MessageType.TriggerEvent.Value     = "A40";

                pid = message.GetPATIENT(0).PID;

                evn = message.EVN;
                evn.EventTypeCode.Value = "A40";

                pv1 = message.GetPATIENT(0).PV1;
                mrg = message.GetPATIENT(0).MRG;
                notificationMessage = message;

                break;
            }

            case ActionType.Update:
            {
                tracer.TraceEvent(TraceEventType.Information, 0, "Received update notification");

                var message = new ADT_A01();

                msh = message.MSH;
                msh.MessageType.MessageType.Value      = "ADT";
                msh.MessageType.MessageStructure.Value = "ADT_A08";
                msh.MessageType.TriggerEvent.Value     = "A08";

                pid = message.PID;

                evn = message.EVN;
                evn.EventTypeCode.Value = "A08";

                pv1 = message.PV1;
                notificationMessage = message;

                break;
            }

            default:
                throw new ArgumentOutOfRangeException($"Invalid notification type {workItem.ActionType}");
            }

            NotifierBase.UpdateMSH(msh, patient, this.TargetConfiguration);

            evn.RecordedDateTime.TimeOfAnEvent.Value = (TS)patient.CreationTime.DateTime;

            NotifierBase.UpdatePID(patient, pid, this.TargetConfiguration);

            pv1.PatientClass.Value = "I";

            // TODO: populate the merge information
            if (mrg != null)
            {
            }

            var queueItem = new MessageQueueWorkItem(notificationMessage, this.TargetConfiguration);

            if (!queueItem.TrySend())
            {
                tracer.TraceEvent(TraceEventType.Warning, 0, "Unable to send message to remote endpoint: {0}", this.TargetConfiguration.ConnectionString);
                Hl7MessageQueue.Current.Enqueue(queueItem);
            }
        }