/// <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); } }
/// <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); } }
public void TestAdtA28MappingToHl7() { ADT_A05 a05 = new ADT_A05(); a05.MSH.MessageType.MessageCode.Value = "ADT"; a05.MSH.MessageType.TriggerEvent.Value = "A28"; a05.MSH.MessageType.MessageStructure.Value = "ADT_A05"; PipeParser parser = new PipeParser(); string msg = parser.Encode(a05); string[] data = msg.Split('|'); Assert.Equal("ADT^A28^ADT_A05", data[8]); }
public void TestAdtA28MappingToHl7() { var a05 = new ADT_A05(); a05.MSH.MessageType.MessageCode.Value = "ADT"; a05.MSH.MessageType.TriggerEvent.Value = "A28"; a05.MSH.MessageType.MessageStructure.Value = "ADT_A05"; var parser = new LegacyPipeParser(); var msg = parser.Encode(a05); var data = msg.Split('|'); Assert.AreEqual("ADT^A28^ADT_A05", data[8]); }
public void TestAdtA28MappingFromHl7() { string hl7Data = @"MSH|^~\&|CohieCentral|COHIE|Clinical Data Provider|TCH|20060228155525||ADT^A28^ADT_A05|1|P|2.5| EVN| PID|1|12345 PV1|1"; PipeParser parser = new PipeParser(); IMessage msg = parser.Parse(hl7Data); Assert.IsNotNull(msg, "Message should not be null"); ADT_A05 a05 = (ADT_A05)msg; Assert.AreEqual("A28", a05.MSH.MessageType.TriggerEvent.Value); Assert.AreEqual("1", a05.PID.SetIDPID.Value); }
static void Main(string[] args) { string ADTMessage = @"MSH|^~\&|Medway PAS V3|Christie|Christie Clinicals|Christie Dev|20180510130123||ADT^A31^ADT_A05|RBV_5533969|P|2.4|||AL|NE EVN|A31|20180510130123||||20180510130123 PID|||201800014^^^RBV^HOSP~3369628198^^^NHS^NHS~^^^RBV^DIST~^^^RBV^UNIT||Proton^Patient5^^^Sir||19671106|1|||18 Union Road^^^ASHTON-UNDER-LYNE^OL6 9JE^GB^HOME^Lancashire~^^^^^^TEMP||01618761029^^HOME~075402341423^^MOB|01617985342^^WORK||P|C13|||||C||||||||N||NSTS02 PD1|||Stamford House^^P89609|G3384167^Shah^PR^^^Dr^^^^^^^GP NK1|1|Grandmother Patient5|Grandmother|18 Union Road,ASHTON-UNDER-LYNE,Lancashire,OL6 9JE|10161876102|20754054637|NK NK1|2|""|Not Set||||EC"; //string hl7message = Convert.ToChar(11).ToString() + ADTMessage + Convert.ToChar(28).ToString() + Convert.ToChar(13).ToString(); //PipeParser parser = new PipeParser(); //IMessage mv23 = parser.Parse(firstMessage); //NHapi.Model.V23.Message.QRY_R02 qryR02 = mv23 as NHapi.Model.V23.Message.QRY_R02; //string EVNseg = "EVN|A31|20180510130123||||20180510130123"; //PipeParser parser = new PipeParser(); //IMessage evn = parser.Parse(EVNseg); //// NHapi.Model.V24.Message.ADT_A01 adtA01 = m as NHapi.Model.V24.Message.ADT_A01; //EVN mEVN = evn as EVN; //Console.WriteLine("EVN {0}", mEVN.RecordedDateTime); //Console.WriteLine("A HL7 message of the type {0} and version {1} is received.", hl7Message.GetStructureName(), hl7Message.Version); //if (!hl7Message.GetStructureName().StartsWith("ADT_")) //{ // errorMessage = "This message structure is not supported."; // return false; //} // switch (hl7Message.Version) PipeParser parser = new PipeParser(); IMessage mm = parser.Parse(ADTMessage); // NHapi.Model.V24.Message.ADT_A01 adtA01 = m as NHapi.Model.V24.Message.ADT_A01; ADT_A05 adtA05 = mm as ADT_A05; //adtA05 = EVNseg; //var setId = adtA05.PD1..Value; //var patientClass = adtA05.PV1.PatientClass.Value; //var AssignedPatientLocation = adtA05.PV1.AssignedPatientLocation.PointOfCare.Value; //var Admission_Type = adtA05.PV1.AdmissionType.Value; //var Pre_Admit_Number = adtA05.PV1.PreadmitNumber.ID.Value; //var Prior_Patient_Location = adtA05.PV1.PriorPatientLocation.PointOfCare.Value; //var Attending_Doctor_Id = adtA05.PV1.AttendingDoctor.IDNumber.Value; //var Attending_Doctor_Name = adtA05.PV1.AttendingDoctor.FamilyName.Value; //var Referring_Doctor_Id = adtA05.PV1.ReferringDoctor.IDNumber.Value; //var Referring_Doctor_Name = adtA05.PV1.ReferringDoctor.FamilyName.Value; Console.WriteLine("Hello ... Second Trying this:\n {0}", ADTMessage); //Console.WriteLine(adtA01.GetStructure("MSH")); if (adtA05 != null) { Console.WriteLine(adtA05); Console.WriteLine("--"); // adtA05.Message.Names.ToArray(); Console.WriteLine("--"); Console.WriteLine(adtA05.Version); Console.WriteLine(adtA05.ValidationContext); Console.WriteLine("ec: " + adtA05.MSH.EncodingCharacters); Console.WriteLine("Here"); Console.WriteLine(adtA05.GetStructureName().StartsWith("ADT_")); Console.WriteLine(adtA05.Version); Console.WriteLine("-------------------------------------------"); Console.WriteLine(adtA05.GetAll("NK1")); Console.WriteLine("-------------------------------------------"); } if (adtA05 is null) { Console.WriteLine(adtA05); Console.WriteLine("wHere"); } Console.WriteLine(adtA05.GetStructure("EVN")); Console.WriteLine(adtA05.GetStructure("PID")); Console.WriteLine("MSH:{0}", adtA05.MSH.NumFields()); Console.WriteLine("EVN:{0}", adtA05.EVN.NumFields()); Console.WriteLine("PID:{0}", adtA05.PID.NumFields()); //Console.WriteLine("PV1:{0}", adtA05.PV1.NumFields()); //Console.WriteLine("NK1:{0}", adtA05.GetNK1().NumFields()); Console.WriteLine("MSH length = " + adtA05.GetAll("MSH").Length); Console.WriteLine("EVN length = " + adtA05.GetAll("EVN").Length); Console.WriteLine("PID length = " + adtA05.GetAll("PID").Length); Console.WriteLine("MSH MessageType.MessageType {0}", adtA05.MSH.MessageType.MessageType.Value); Console.WriteLine("MSH MessageType.TriggerEvent {0}", adtA05.MSH.MessageType.TriggerEvent.Value); Console.WriteLine("MSH MessageControlID {0}", adtA05.MSH.MessageControlID.Value); Console.WriteLine("EVN adtA05.EVN.RecordedDateTime {0}", adtA05.EVN.RecordedDateTime.TimeOfAnEvent); Console.WriteLine("PID 1 - adtA05.PID.Patient ID {0}", adtA05.PID.DateTimeOfBirth.TimeOfAnEvent); //Console.WriteLine("QRD 2 - Query Format Code (ID) {0}", adtA01.PID.QueryFormatCode.Value); //Console.WriteLine("QRD 3 - Query Priority (ID) {0}", adtA01.PID.QueryPriority.Value); //Console.WriteLine("QRD 4 - What Department Data Code (CE) {0}", adtA01.PID.GetWhatDepartmentDataCode(0).Identifier.Value); //Console.WriteLine("QRD 5 - Query ID (ST) {0}", adtA01.PID.QueryID.Value); //Console.WriteLine("QRD 6 - Deferred Response Type (ID) {0}", adtA01.PID.DeferredResponseType.Value); //Console.WriteLine("QRD 7 - Deferred Response Date/Time (TS) {0}", adtA01.PID.DeferredResponseDateTime.TimeOfAnEvent.Value); //Console.WriteLine("QRD 8 - Quantity Limited Request (CQ) {0}", adtA01.PID.QuantityLimitedRequest.Quantity.Value); //Console.WriteLine("QRD 9 - Who Subject Filter (XCN) {0}", adtA01.PID.GetWhoSubjectFilter(0).IDNumber.Value); //Console.WriteLine("QRD 10- What Subject Filter (CE) {0}", adtA01.PID.GetWhatSubjectFilter(0).Identifier.Value); //Console.WriteLine("QRD 11- What Data Code Value Qualifier (CM_VR) {0}", adtA01.PID.GetWhatDataCodeValueQualifier(0).FirstDataCodeValue.Value); //Console.WriteLine("QRD 12- Query Results Level (ID) {0}", adtA01.PID.QueryResultsLevel.Value); }