예제 #1
0
        public void testMSH()
        {
            var __msh = new MSH(@"MSH |^ ~\&| ADT1 | MCM | LABADT | MCM | 198808181126 | SECURITY | ADT ^ A01 | MSG00001 | P | 2.4");
            var __ack = new ACK(__msh);

            Console.WriteLine("ACK: {0}", __ack.__ack_string);

            var __nak = new NAK(__msh, "AF");

            Console.WriteLine("NAK: {0}", __nak.__nak_string);

            __msh = new MSH(@"MSH|^~\&|FrameworkLTC|DELPHI|100|MAYQ|20110802115657||RDE^O11^RDE_O11|36652|P|2.5||||||ASCII|||");
            __ack = new ACK(__msh);
            Console.WriteLine("ACK: {0}", __ack.__ack_string);

            __nak = new NAK(__msh, "AF");
            Console.WriteLine("NAK: {0}", __nak.__nak_string);

            __msh = new MSH(@"MSH|^~\&|FrameworkLTC|DELPHI|100|MAYQ|20110802115657||RDE ^O11^ RDE_O11|36652|P|2.5||||||ASCII|||");
            __ack = new ACK(__msh);
            Console.WriteLine("ACK: {0}", __ack.__ack_string);

            __nak = new NAK(__msh, "AF");
            Console.WriteLine("NAK: {0}", __nak.__nak_string);
        }
예제 #2
0
        public virtual void Parse()
        {
            if (!string.IsNullOrEmpty(_message))
            {
                SegmentFactoryManager segmentBuilder = new SegmentFactoryManager();
                SegmentFactory        segmentFactory = segmentBuilder.GetFactory(_driverType);

                List <string> segments = new List <string>(_message.Replace("\r\n", "\r").Split('\r'));

                foreach (string segment in segments)
                {
                    Segment newSegment = segmentFactory.CreateSegmentInstance(
                        ((SegmentTypes)EnumUtils.enumValueOf(segment.Substring(0, 3), typeof(SegmentTypes))),
                        segment);

                    _segments.Add(newSegment);
                }

                if (_segments != null && _segments.Count > 0)
                {
                    MSH msh = (MSH)_segments.Find(s => s.SegmentType == SegmentTypes.MSH);
                    _delimiters.FieldSeparator        = msh.GetFieldSeparator();
                    _delimiters.ComponentSeparator    = msh.GetComponentSeparator();
                    _delimiters.FieldRepeatSeparator  = msh.GetFieldRepeatSeparator();
                    _delimiters.EscapeCharacter       = msh.GetEscapeCharacter();
                    _delimiters.SubComponentSeparator = msh.GetSubComponentSeparator();

                    _versioinId       = msh.GetVersionId();
                    _messageDate      = msh.GetMessageDateTime();
                    _type             = msh.GetMessageType();
                    _messageControlId = msh.GetMessageControlId();
                    _processingId     = msh.GetProcessingId();
                }
            }
        }
예제 #3
0
 public ACK(compositeType parent, string name) : base(parent, name)
 {
     data    = new abstractType[3];
     data[0] = new MSH(this, "ACK");
     data[1] = new MSA(this, "ACK");
     data[2] = new ERR(this, "ACK");
 }
예제 #4
0
        public void SerializeMSHQueue()
        {
            String filename = @"c:\temp\msh.bin";

            var prov = HCAssignmentDataProviderFactory.GetLiveProvider();

            List <MSH> mshList = prov.GetMSH();


            //mshList[0].ObrList[0].ObxList[0].HCAssignment = "Anthrax";


            MSH anotherOne = mshList[4].DeepCopy();

            anotherOne.MSH_ID                       = "1000";
            anotherOne.ObrList[0].OBR_ID            = "1001";
            anotherOne.ObrList[0].ObxList[0].OBX_ID = "1002";
            anotherOne.ObrList[0].ObxList           = null;

            mshList.Add(anotherOne);

            FileStream stream    = File.Create(filename);
            var        formatter = new BinaryFormatter();

            formatter.Serialize(stream, mshList);
            stream.Close();


            stream = File.OpenRead(filename);
            Console.WriteLine("Deserializing vector");
            var v1 = (List <MSH>)formatter.Deserialize(stream);

            stream.Close();
        }
예제 #5
0
        /// <summary>
        /// Updates a <see cref="MSH" /> segment.
        /// </summary>
        /// <param name="msh">The MSH segment to update.</param>
        /// <param name="patient">The patient.</param>
        /// <param name="targetConfiguration">The target configuration.</param>
        internal static void UpdateMSH(MSH msh, Patient patient, TargetConfiguration targetConfiguration)
        {
            // ensure authenticated
            EnsureAuthenticated();

            tracer.TraceEvent(TraceEventType.Verbose, 0, "Start updating MSH segment");

            msh.AcceptAcknowledgmentType.Value        = "AL";
            msh.DateTimeOfMessage.TimeOfAnEvent.Value = DateTime.Now.ToString("yyyyMMddHHmmss");
            msh.MessageControlID.Value          = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0).ToString();
            msh.ProcessingID.ProcessingID.Value = "P";

            if (targetConfiguration.DeviceId.Contains('|'))
            {
                msh.ReceivingApplication.NamespaceID.Value = targetConfiguration.DeviceId.Split('|')[0];
                msh.ReceivingFacility.NamespaceID.Value    = targetConfiguration.DeviceId.Split('|')[1];
            }
            else
            {
                msh.ReceivingApplication.NamespaceID.Value = targetConfiguration.DeviceId;
                msh.ReceivingFacility.NamespaceID.Value    = targetConfiguration.NotificationDomainConfigurations.FirstOrDefault()?.Domain;
            }

            var configuration = ApplicationContext.Current.Configuration;

            // set MSH-3 as the NSID of the patient identifier
            msh.SendingApplication.NamespaceID.Value = patient.Identifiers.FirstOrDefault()?.Authority?.DomainName ?? configuration.DeviceName;
            msh.SendingFacility.NamespaceID.Value    = configuration.JurisdictionData.Name;
            msh.VersionID.VersionID.Value            = "2.3.1";
        }
예제 #6
0
        public byte[] DataWritter()
        {
            byte[] mftEntryHeader = new byte[42 + ((StandardInformation)attributes.ElementAt(0)).RecordLength + ((FileName)attributes.ElementAt(1)).RecordLength];
            Array.Copy(MSH.DataWritter(), 0, mftEntryHeader, 0, 4);
            Array.Copy(BitConverter.GetBytes(FirstAttributeOffset), 0, mftEntryHeader, 4, 2);
            Array.Copy(BitConverter.GetBytes((ushort)Flags), 0, mftEntryHeader, 6, 2);
            Array.Copy(BitConverter.GetBytes(UsedEntrySize), 0, mftEntryHeader, 8, 4);
            Array.Copy(BitConverter.GetBytes(TotalEntrySize), 0, mftEntryHeader, 12, 4);
            Array.Copy(BitConverter.GetBytes(UsedFolderSize), 0, mftEntryHeader, 16, 4);
            Array.Copy(BitConverter.GetBytes(AllocatedFolderSize), 0, mftEntryHeader, 20, 4);

            Array.Copy(((StandardInformation)attributes.ElementAt(0)).DataWritter(), 0, mftEntryHeader, 24, ((StandardInformation)attributes.ElementAt(0)).RecordLength);
            Array.Copy(((FileName)attributes.ElementAt(1)).DataWritter(), 0, mftEntryHeader, 24, ((FileName)attributes.ElementAt(1)).RecordLength);

            if (attributes.ElementAt(2) is Data && ((Data)attributes.ElementAt(2)).DataBytes != null)
            {
                byte[] tmp = new byte[((Data)attributes.ElementAt(2)).DataBytes.Length];
                Array.Copy(((Data)attributes.ElementAt(2)).DataBytes, 0, tmp, 0, tmp.Length);

                var tmpRet = new byte[mftEntryHeader.Length + tmp.Length];
                mftEntryHeader.CopyTo(tmpRet, 0);
                tmp.CopyTo(tmpRet, mftEntryHeader.Length);
                return(tmpRet);
            }

            return(mftEntryHeader);
        }
예제 #7
0
        public void TestEmptyName()
        {
            options.Names.Clear();

            var actual = NHapiUtility.GenerateCandidateRegistry(options);

            Assert.IsInstanceOfType(actual.GetStructure("MSH"), typeof(MSH));

            MSH msh = (MSH)actual.GetStructure("MSH");

            Assert.AreEqual("CRTEST", msh.ReceivingApplication.NamespaceID.Value);
            Assert.AreEqual("Mohawk College of Applied Arts and Technology", msh.ReceivingFacility.NamespaceID.Value);
            Assert.AreEqual("SEEDER", msh.SendingApplication.NamespaceID.Value);
            Assert.AreEqual("SEEDING", msh.SendingFacility.NamespaceID.Value);

            Assert.IsInstanceOfType(actual.GetStructure("PID"), typeof(PID));

            PID pid = (PID)actual.GetStructure("PID");

            Assert.AreEqual("1.3.6.1.4.1.33349.3.1.2.99121.283", pid.GetPatientIdentifierList(0).AssigningAuthority.UniversalID.Value);

            var names = pid.GetPatientName();

            foreach (var item in names)
            {
                Assert.IsNull(item.GivenName.Value);
                Assert.IsNull(item.FamilyLastName.FamilyName.Value);
            }
        }
예제 #8
0
        public ORM(compositeType parent, string name) : base(parent, name)
        {
            data = new abstractType[19];

            data[0] = new MSH(this, "MSH");
            data[1] = new NTE(this, "NTE");
            //Patient
            data[2] = new PID(this, "PID");
            data[3] = new PD1(this, "PD1");
            //Patient_VISIT
            data[4] = new PV1(this, "PV1");
            data[5] = new PV2(this, "PV2");
            //INsurance
            data[6] = new IN1(this, "IN1");
            data[7] = new IN2(this, "IN2");
            data[8] = new IN3(this, "IN3");

            data[9]  = new GT1(this, "GT1");
            data[10] = new AL1(this, "AL1");
            //Order
            data[11] = new ORC(this, "ORC");
            //Order_Detail
            data[12] = new OBR(this, "OBR");
            data[13] = new NTE(this, "NTE");
            data[14] = new DG1(this, "DG1");
            //Observation
            data[15] = new OBX(this, "OBX");
            data[16] = new NTE(this, "NTE");
            data[17] = new CTI(this, "CTI");
            data[18] = new BLG(this, "BLG");
        }
예제 #9
0
            public void __parse_message(string __data)
            {
                // Clean delivery marks
                __data = __data.Remove(__data.IndexOf('\v'), 1);
                __data = __data.Remove(__data.IndexOf('\x1C'), 1);

                string[] __segments = __data.Split('|');

                try
                {
                    // Figure out what kind of message it is
                    MSH __resp = new MSH(__segments[0]);
                    switch (__resp.__msg_data["9.3"])
                    {
                    case "RDE_O11":
                        RDE_O11 __rde_o11 = new RDE_O11(__data);
                        break;

                    case "":

                    default:
                        break;
                    }

                    // Send Response Packet ACK
                }
                catch (Exception e)
                {
                    // Send Response Packet NAK
                }
            }
예제 #10
0
        /// <summary>
        /// The get msh.
        /// </summary>
        /// <param name="statement">
        /// The statement.
        /// </param>
        /// <param name="message">
        /// The message.
        /// </param>
        /// <returns>
        /// The <see cref="MSH"/>.
        /// </returns>
        private MSH GetMsh(Statement statement, Message message)
        {
            var msh = new MSH();

            // MSH.1
            msh.FieldDivider = Hl7Helper.BHS_Delimiter;

            // MSH.2
            msh.SpecialSymbol = Hl7Helper.BHS_CodeSymbols;

            var tfoms = statement.PointDistributionPolicy.Parent.Parent;

            // MSH.3
            msh.OriginApplicationName = new BHS3 {
                Application = "СРЗ " + tfoms.Code
            };

            // MSH.4
            msh.OriginOrganizationName = new BHS4 {
                CodeOfRegion = tfoms.Code, TableCode = Oid.Pvp, Iso = "ISO"
            };

            // MSH.5
            msh.ApplicationName = new BHS5 {
                Application = "ЦК ЕРП"
            };

            // MSH.6
            msh.OrganizationName = new BHS6 {
                FomsCode = "00", TableCode = Oid.Pvp, Iso = "ISO"
            };

            // MSH.7
            msh.DateTimeCreation = Hl7Helper.FormatCurrentDateTime();

            // MSH.9
            msh.MessageType = new MessageType {
                MessType = "ADT", TransactionCode = "A08", StructureType = "ADT_A01",
            };

            // MSH.10
            msh.Identificator = message.Id.ToString();

            // MSH.11
            msh.TypeWork = new TypeWork {
                Type = "P"
            };

            // MSH.12
            msh.VersionStandartId = new VersionStandartId();

            // MSH.15
            msh.ConfirmationTypeGateWay = "AL";

            // MSH.16
            msh.ConfirmationTypeFoms = "AL";

            return(msh);
        }
예제 #11
0
        public void MSHTest()
        {
            MSH    msh = new MSH(new ACK(null, "ack"), "msh");
            String str = @"MSH|^~\&|NES|NINTENDO|TESTSYSTEM|TESTFACILITY|20010101000000||ADT^A04|Q123456789T123456789X123456|P|2.3";

            msh.Value = str;
            Assert.AreEqual(msh.Value, str);
        }
예제 #12
0
            public Message processMessage(Message msg)
            {
                string encodedMessage = new NuGenPipeParser().encode(msg);

                MSH msh = (MSH)msg.get_Renamed("MSH");

                return(NuGenDefaultApplication.makeACK(msh));
            }
예제 #13
0
        public void MSHTest()
        {
            compositeMessage message = new compositeMessage(null, "ACK");
            MSH msh = new MSH(message, "MSH");

            msh.Value = "MSH|^~\\&|HIS|00001|LIS|1234|2004112754000||ACK^A01^ACK_A01|0200002|P|2.4\rMSA|AE|0200001|type error|||102\r";
            Assert.AreEqual("2004112754000", msh.DateTimeOfMessage.Time.Value);
        }
예제 #14
0
        private static void PopulateMSH(
            MSH msh,
            string type,
            string @event,
            string id,
            Identifier sendingApplication,
            Identifier sendingFacility,
            Identifier receivingAppliation,
            Identifier receivingFacility)
        {
            // MSH-1
            msh.FieldSeparator.Value = "|";

            // MSH-2
            msh.EncodingCharacters.Value = "^~\\&";

            // MSH-3
            HD hd = msh.SendingApplication;

            hd.NamespaceID.Value     = sendingApplication.NamespaceId;
            hd.UniversalID.Value     = sendingApplication.UniversalId;
            hd.UniversalIDType.Value = sendingApplication.UniversalIdType;

            // MSH-4
            hd = msh.SendingFacility;
            hd.NamespaceID.Value     = sendingFacility.NamespaceId;
            hd.UniversalID.Value     = sendingFacility.UniversalId;
            hd.UniversalIDType.Value = sendingFacility.UniversalIdType;

            // MSH-5
            hd = msh.ReceivingApplication;
            hd.NamespaceID.Value     = receivingAppliation.NamespaceId;
            hd.UniversalID.Value     = receivingAppliation.UniversalId;
            hd.UniversalIDType.Value = receivingAppliation.UniversalIdType;

            // MSH-6
            hd = msh.ReceivingFacility;
            hd.NamespaceID.Value     = receivingFacility.NamespaceId;
            hd.UniversalID.Value     = receivingFacility.UniversalId;
            hd.UniversalIDType.Value = receivingFacility.UniversalIdType;

            // MSH-7
            msh.DateTimeOfMessage.TimeOfAnEvent.SetShortDate(DateTime.Now);

            // MSH-9
            msh.MessageType.MessageType.Value  = type;
            msh.MessageType.TriggerEvent.Value = @event;

            // MSH-10
            msh.MessageControlID.Value = GenerateControlId();

            // MSH-11
            msh.ProcessingID.ProcessingID.Value = "P";

            // MSH-12
            msh.VersionID.VersionID.Value = "2.3.1";
        }
예제 #15
0
        public void ToStringTest()
        {
            compositeMessage message = new compositeMessage(null, "ACK");
            MSH msh = new MSH(message, "MSH");

            msh.FieldSeparator.Value = "|";
            msh.ReceivingApplication.NamespaceID.Value = "LIS";
            Assert.AreEqual("MSH||||LIS", msh.ToString());
        }
예제 #16
0
        public static TypeInfo TypeFactory(FHS fhs, BHS bhs, MSH msh)
        {
            if (msh.MessageType_09.MessageCode_01 == "RDS" && msh.MessageType_09.TriggerEvent_02 == "O13")
            {
                return(typeof(TSRDSO13).GetTypeInfo());
            }

            throw new Exception(string.Format("Transaction {0} for trigger {1} is not supported.",
                                              msh.MessageType_09.MessageCode_01, msh.MessageType_09.TriggerEvent_02));
        }
예제 #17
0
        public void WhenGeneratingMSHSegment_WithDefault()
        {
            var msh = new MSH();

            msh.BuildSegment();
            var result = msh.ConvertToHL7();

            Console.WriteLine(result);
            result.Should().Contain("MSH|^~&|||||||^^||T|2.5.1|||NE|AL|USA|ASCII||||");
        }
예제 #18
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);
            }
        }
예제 #19
0
        /// <summary>
        /// Parses the received HL7 message.
        /// </summary>
        /// <param name="messageForm">The raw message encoded in HL7 'pipes and hats' format.</param>
        /// <returns>The parsed HL7 message object</returns>
        /// <exception cref="HL7ParseException">Thrown when parsing fails</exception>
        public static HL7Message Parse(string messageForm)
        {
            // Determine the HL7 separators dynamically from the incoming message (usually "|^~\&")
            HL7Separators sep = new HL7Separators(messageForm);

            // Change CRLF or LF into the standard CR separators
            if (messageForm.Contains("\r\n"))
            {
                messageForm = messageForm.Replace("\r\n", "\r");
            }
            if (messageForm.Contains("\n"))
            {
                messageForm = messageForm.Replace("\n", "\r");
            }

            // Remove consecutive segment separators
            while (messageForm.Contains("\r\r"))
            {
                messageForm = messageForm.Replace("\r\r", "\r");
            }

            // Parse all the segments
            messageForm = messageForm.TrimEnd(new char[] { sep.SegmentSeparator });
            string[] segmentForm = messageForm.Split(sep.SegmentSeparator);
            for (int count = 0; count < segmentForm.Count(); count++)
            {
                segmentForm[count] = segmentForm[count].Replace("\n", string.Empty);
            }
            HL7Segment[] segments = new HL7Segment[segmentForm.Length];
            for (int i = 0; i < segmentForm.Length; i++)
            {
                segments[i] = HL7Segment.Parse(segmentForm[i], sep);
            }

            // Grab the MSH segment in order to determine which message structure to use
            MSH msh = segments[0] as MSH;

            if (msh == null)
            {
                throw new HL7ParseException(ConstantsResource.HL7NoMshSegment);
            }
            if (msh.MessageType == null)
            {
                throw new HL7ParseException(ConstantsResource.NoMessageType);
            }

            // Determine the structure for the indicated message identifier
            Type messageStructure = GetMessageStructure(msh.MessageType);

            // Create the message and populate all the matching segments into its structure
            int        segmentIndex = 0;
            HL7Message message      = BuildSegmentGroup(messageStructure, segments, ref segmentIndex) as HL7Message;

            return(message);
        }
예제 #20
0
        /// <summary>
        /// Notify the operation
        /// </summary>
        public void Notify(NotificationQueueWorkItem workItem)
        {
            // configuration service
            ISystemConfigurationService config = this.Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;
            ILocalizationService        locale = this.Context.GetService(typeof(ILocalizationService)) as ILocalizationService;

            // Common message bits we need to update
            IMessage notificationMessage = null;
            MSH      msh = null;
            PID      pid = null;
            EVN      evn = null;
            PV1      pv1 = null;


            // Identify the work item action
            switch (workItem.Action)
            {
            case MARC.HI.EHRS.CR.Notification.PixPdq.Configuration.ActionType.Create:
            case MARC.HI.EHRS.CR.Notification.PixPdq.Configuration.ActionType.DuplicatesResolved:
            case MARC.HI.EHRS.CR.Notification.PixPdq.Configuration.ActionType.Update:
            {
                ADT_A05 message = new ADT_A05();
                msh = message.MSH;
                pid = message.PID;
                evn = message.EVN;
                pv1 = message.PV1;
                notificationMessage = message;
                msh.MessageType.TriggerEvent.Value = "A31";
                break;
            }
            }

            // Populate the MSH header first
            this.UpdateMSH(msh, config);

            // Populate the EVN segment
            evn.EventTypeCode.Value         = workItem.Event.Mode.ToString();
            evn.RecordedDateTime.Time.Value = (TS)workItem.Event.Timestamp;

            // Populate the PID segment
            Person subject = workItem.Event.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person;

            this.UpdatePID(subject, pid, config);
            pv1.PatientClass.Value = "N";

            // Send
            var queueItem = new Hl7MessageQueue.MessageQueueWorkItem(this.Target, notificationMessage);

            if (!queueItem.TrySend())
            {
                Trace.TraceWarning(locale.GetString("NTFW005"));
                Hl7MessageQueue.Current.EnqueueMessageItem(queueItem);
            }
        }
예제 #21
0
        /// <summary>
        /// Update the MSH on the specified MSH segment
        /// </summary>
        /// <param name="msh">The message header to be updated</param>
        /// <param name="inbound">The inbound message</param>
        public static void SetDefault(this MSH msh, MSH inbound)
        {
            var config = ApplicationServiceContext.Current.GetService <IConfigurationManager>().GetSection <Hl7ConfigurationSection>();

            msh.MessageControlID.Value = Guid.NewGuid().ToString();
            msh.SendingApplication.NamespaceID.Value   = ApplicationServiceContext.Current.GetService <INetworkInformationService>()?.GetMachineName();
            msh.SendingFacility.NamespaceID.Value      = config.LocalFacility.ToString();
            msh.ReceivingApplication.NamespaceID.Value = inbound.SendingApplication.NamespaceID.Value;
            msh.ReceivingFacility.NamespaceID.Value    = inbound.SendingFacility.NamespaceID.Value;
            msh.DateTimeOfMessage.Time.Value           = DateTime.Now.ToString("yyyyMMddHHmmss");
        }
예제 #22
0
        private static void AddOBRAndOBXs(ref MSH msh, HL7.Reportable.Common.Business.HL7.LabReport report)
        {
            int        sequenceID = 1;
            List <OBR> OBRs       = new List <OBR>();

            foreach (var item in report.TestRequests)
            {
                OBRs.Add(GetObr(item, sequenceID++));
            }

            msh.ObrList = OBRs;
        }
예제 #23
0
        ///<summary>
        /// Returns  first repetition of MSH (Message Header) - creates it if necessary
        ///</summary>
        public MSH GetMSH()
        {
            MSH ret = null;

            try {
                ret = (MSH)this.GetStructure("MSH");
            } catch (HL7Exception e) {
                HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
                throw new System.Exception("An unexpected error ocurred", e);
            }
            return(ret);
        }
예제 #24
0
        void fillMshSegment(MSH msh, string fieldSeparator, string sendingAppNamespace, string sendingFacilityNamespace, string sendingFacilityId, string sendingFacilityIdType,
                            string receivingAppNamespace, string receivingFacilityNamespace, string receivingFacilityId, string receivingFacilityIdType, string dateTimeOfMessage,
                            string messageType, string triggerEvent, string messageStructure, string messageControlId, string processingId, string versionId)
        {
            msh.FieldSeparator.Value     = Convert.ToString(HL7Constants.FIELD_SEPARATOR);
            msh.EncodingCharacters.Value = HL7Constants.DEFAULT_DELIMITER;

            msh.SendingApplication.NamespaceID.Value  = "MHV EVAULT";
            msh.SendingFacility.NamespaceID.Value     = "200MH";
            msh.SendingFacility.UniversalID.Value     = "VAMHVWEB1.AAC.VA.GOV";
            msh.SendingFacility.UniversalIDType.Value = "DNS";

            msh.ReceivingApplication.NamespaceID.Value  = "MHV VISTA";
            msh.ReceivingFacility.UniversalIDType.Value = "DNS";
            //msh.DateTimeOfMessage.TimeOfAnEvent.Value = "20120417095000-0500";

            //msh.MessageType.MessageType.Value = "QBP";
            //msh.MessageType.TriggerEvent.Value = "Q13";
            //msh.MessageType.MessageStructure.Value = "QBP_Q13";
            //msh.MessageControlID.Value = String.Concat(_cxn.DataSource.SiteId.Id, Convert.ToString(DateTime.Now.Millisecond), new Random().Next());
            //msh.ProcessingID.ProcessingID.Value = "P";  // should this be a "T" ????
            //msh.VersionID.VersionID.Value = "2.4";

            //msh.SendingApplication.NamespaceID.Value = sendingAppNamespace;
            //msh.SendingFacility.NamespaceID.Value = sendingFacilityNamespace;
            //msh.SendingFacility.UniversalID.Value = sendingFacilityId;
            //msh.SendingFacility.UniversalIDType.Value = sendingFacilityIdType;

            //msh.ReceivingApplication.NamespaceID.Value = receivingAppNamespace;
            msh.ReceivingFacility.NamespaceID.Value = receivingFacilityNamespace; // site code
            msh.ReceivingFacility.UniversalID.Value = receivingFacilityId;
            //msh.ReceivingFacility.UniversalIDType.Value = receivingFacilityIdType;
            msh.DateTimeOfMessage.TimeOfAnEvent.Value = DateTime.Now.ToString("yyyyMMddHHmmsszzz").Replace(":", ""); // timezone offset comes with ':' via toString // dateTimeOfMessage;

            msh.MessageType.MessageType.Value      = messageType;
            msh.MessageType.TriggerEvent.Value     = triggerEvent;
            msh.MessageType.MessageStructure.Value = messageStructure;
            msh.MessageControlID.Value             = String.Concat(_cxn.DataSource.SiteId.Id, Convert.ToString(DateTime.Now.Millisecond), new Random().Next());

            // it doesn't appear that SiteTable has any code to set this to true if VhaSites.xml specifies the site as a test source - ok for production
            // but possibly could cause a headache if trying to run against a test site and IsTestSource is always false
            if (_cxn.DataSource.IsTestSource)
            {
                msh.ProcessingID.ProcessingID.Value = "T";
            }
            else
            {
                msh.ProcessingID.ProcessingID.Value = "P";
            }

            msh.VersionID.VersionID.Value = "2.4";
        }
예제 #25
0
        public void TestUnexpectedFieldReps()
        {
            // Arrange
            var factory = new DefaultModelClassFactory();
            var msh     = new MSH(new GenericMessage.V25(factory), new DefaultModelClassFactory());

            // Act
            msh.GetField(1, 0);
            msh.GetField(1, 1);

            // Assert
            Assert.AreEqual(2, msh.GetField(1).Length);
        }
예제 #26
0
        private void OpenMSH(string path)
        {
            bool success = false;

            try {
                msh     = MSH.LoadFromFile(path);
                success = true;
            }
            catch (FileNotFoundException) {
                MessageBox.Show(path + " could not be found!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (ArgumentException) {
                MessageBox.Show(path + " is not a valid File!", "Not Valid", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InsufficientPermissionsException) {
                MessageBox.Show("Insufficient permissions on File " + path, "Insufficient Permissions", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (IOException) {
                MessageBox.Show("Error while reading/writing File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (EndOfDataException) {
                MessageBox.Show("Unexpected end of Data!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidChunkException) {
                MessageBox.Show("Corrupted Chunk Data found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //takes way too long
            //foreach (string line in Log.GetLastLines(LogType.Info))
            //textBox1.AppendText(line + "\n");

            logBox.Lines = Log.GetAllLines(LogType.Info);

            if (success)
            {
                mshView.Enabled   = true;
                inspector.Enabled = true;
                checkToolStripMenuItem.Enabled    = true;
                materialToolStripMenuItem.Enabled = true;
                modelToolStripMenuItem.Enabled    = true;
                segmentToolStripMenuItem.Enabled  = true;

                mshFile = new FileInfo(path);

                CheckMSH(false);
                RefreshTreeView();

                glDraw.LoadTextures(BuildTextureList());
                glDraw.SegmentsToRender = GetSegmentsFromSelection();
            }
        }
예제 #27
0
 private static void ProduceMSH(MSH msh, string messageType, string triggerEvent, string controlId)
 {
     msh.FieldSeparator.Value     = "|";
     msh.EncodingCharacters.Value = "^~\\&";
     msh.DateTimeOfMessage.TimeOfAnEvent.Value = DateTime.Now.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture);
     msh.SendingApplication.NamespaceID.Value  = "Neusoft";
     msh.SendingApplication.UniversalID.Value  = "HL7System";
     //msh.SequenceNumber.Value = "123";
     msh.MessageType.MessageType.Value   = messageType;
     msh.MessageType.TriggerEvent.Value  = triggerEvent;
     msh.MessageControlID.Value          = controlId;
     msh.ProcessingID.ProcessingID.Value = "P";
     //msh.GetCharacterSet(0).Value = "8859/9";
 }
예제 #28
0
        private static void AddObrNodes(ref TreeViewNode mshNode, MSH mshInfo)
        {
            List <TreeViewNode> obrNodes = new List <TreeViewNode>();

            if (mshInfo.ObrList != null)
            {
                foreach (var item in mshInfo.ObrList)
                {
                    obrNodes.Add(GetSingleObrNode(mshInfo, item));
                }
            }

            mshNode.nodes = obrNodes;
        }
예제 #29
0
 /// <summary>
 /// Update the MSH header
 /// </summary>
 private void UpdateMSH(MSH header, String message, String structure, String trigger)
 {
     // Message header
     header.AcceptAcknowledgmentType.Value         = "AL";                                    // Always send response
     header.DateTimeOfMessage.Time.Value           = DateTime.Now.ToString("yyyyMMddHHmmss"); // Date/time of creation of message
     header.MessageControlID.Value                 = Guid.NewGuid().ToString();               // Unique id for message
     header.MessageType.MessageStructure.Value     = message;                                 // Message structure type (Query By Parameter Type 21)
     header.MessageType.MessageCode.Value          = structure;                               // Message Structure Code (Query By Parameter)
     header.MessageType.TriggerEvent.Value         = trigger;                                 // Trigger event (Event Query 22)
     header.ProcessingID.ProcessingID.Value        = "P";                                     // Production
     header.ReceivingApplication.NamespaceID.Value = this.ReceivingApplication;               // Client Registry
     header.ReceivingFacility.NamespaceID.Value    = this.ReceivingFacility;                  // SAMPLE
     header.SendingApplication.NamespaceID.Value   = this.SendingApplication;                 // What goes here?
     header.SendingFacility.NamespaceID.Value      = this.SendingFacility;                    // You're at the college ... right?
 }
예제 #30
0
 public virtual void SetMSH(MSH header, string messageCode, string triggerEvent)
 {
     // Populate the MSH Segment
     header.FieldSeparator.Value                   = ("|");
     header.EncodingCharacters.Value               = "^~\\&";
     header.MessageType.MessageCode.Value          = messageCode;
     header.MessageType.TriggerEvent.Value         = triggerEvent;
     header.SendingApplication.NamespaceID.Value   = _sendingApplication;
     header.SendingFacility.NamespaceID.Value      = _sendingFacility;
     header.ReceivingApplication.NamespaceID.Value = _receivingApplication;
     header.ReceivingFacility.NamespaceID.Value    = _receivingFacility;
     header.DateTimeOfMessage.Time.SetLongDate(Platform.Time);
     header.MessageControlID.Value          = DateTime.Now.ToString("yyyyMMddHHmmssffffff");
     header.ProcessingID.ProcessingID.Value = "P"; //production
 }