Esempio n. 1
0
 /// <summary>
 /// The create logic error.
 /// </summary>
 /// <param name="errorTypeCode">
 /// The error type code.
 /// </param>
 /// <param name="code">
 /// The code.
 /// </param>
 /// <param name="message">
 /// The message.
 /// </param>
 /// <param name="codeHL7">
 /// The code h l 7.
 /// </param>
 /// <param name="messageHL7">
 /// The message h l 7.
 /// </param>
 /// <param name="severityHL7">
 /// The severity h l 7.
 /// </param>
 /// <param name="reference">
 /// The reference.
 /// </param>
 /// <param name="xpath">
 /// The xpath.
 /// </param>
 /// <param name="nodeNumber">
 /// The node number.
 /// </param>
 /// <returns>
 /// The <see cref="XElement"/>.
 /// </returns>
 internal static XElement CreateLogicError(
     string errorTypeCode,
     string code,
     string message,
     string codeHL7,
     string messageHL7,
     string severityHL7,
     string reference,
     string xpath,
     string nodeNumber)
 {
     return(new XElement(
                XName.Get("ERR", "urn:hl7-org:v2xml"),
                new object[]
     {
         new XElement(
             XName.Get("ERR.2", "urn:hl7-org:v2xml"),
             new object[]
         {
             new XElement(
                 XName.Get("ERL.1", "urn:hl7-org:v2xml"),
                 xpath.ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false)),
             new XElement(
                 XName.Get("ERL.2", "urn:hl7-org:v2xml"),
                 nodeNumber.ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false))
         }),
         new XElement(
             XName.Get("ERR.3", "urn:hl7-org:v2xml"),
             new object[]
         {
             new XElement(
                 XName.Get("CWE.1", "urn:hl7-org:v2xml"),
                 codeHL7.ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false)),
             new XElement(
                 XName.Get("CWE.2", "urn:hl7-org:v2xml"),
                 messageHL7.ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false)),
             new XElement(XName.Get("CWE.3", "urn:hl7-org:v2xml"), "1.2.643.2.40.5.100.357")
         }),
         new XElement(
             XName.Get("ERR.4", "urn:hl7-org:v2xml"),
             severityHL7.ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false)),
         new XElement(
             XName.Get("ERR.5", "urn:hl7-org:v2xml"),
             new object[]
         {
             new XElement(
                 XName.Get("CWE.1", "urn:hl7-org:v2xml"),
                 code.ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false)),
             new XElement(
                 XName.Get("CWE.2", "urn:hl7-org:v2xml"),
                 HL7Helper.AddMessageReference(message, reference)
                 .ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false)),
             new XElement(
                 XName.Get("CWE.3", "urn:hl7-org:v2xml"),
                 errorTypeCode.ReplaceInvalidXmlCharacters(XmlVersion.Version_1_0, " ", false))
         })
     }));
 }
Esempio n. 2
0
 /// <summary>
 /// The create msh.
 /// </summary>
 /// <param name="parameters">
 /// The parameters.
 /// </param>
 /// <returns>
 /// The <see cref="XElement"/>.
 /// </returns>
 internal static XElement CreateMsh(Parameters parameters)
 {
     return(new XElement(
                XName.Get("MSH", "urn:hl7-org:v2xml"),
                new object[]
     {
         new XElement(XName.Get("MSH.1", "urn:hl7-org:v2xml"), HL7Helper.BHS_Delimiter),
         new XElement(XName.Get("MSH.2", "urn:hl7-org:v2xml"), HL7Helper.BHS_CodeSymbols),
         new XElement(
             XName.Get("MSH.3", "urn:hl7-org:v2xml"),
             new XElement(XName.Get("HD.1", "urn:hl7-org:v2xml"), parameters.Constants.ApplicationName)),
         new XElement(
             XName.Get("MSH.4", "urn:hl7-org:v2xml"),
             new object[]
         {
             new XElement(XName.Get("HD.1", "urn:hl7-org:v2xml"), parameters.Constants.OrganizationName),
             new XElement(XName.Get("HD.2", "urn:hl7-org:v2xml"), HL7Helper.TypeCode_Region2Code),
             new XElement(XName.Get("HD.3", "urn:hl7-org:v2xml"), "ISO")
         }),
         new XElement(
             XName.Get("MSH.5", "urn:hl7-org:v2xml"),
             new XElement(XName.Get("HD.1", "urn:hl7-org:v2xml"), parameters.OriginApplicationName)),
         new XElement(
             XName.Get("MSH.6", "urn:hl7-org:v2xml"),
             new object[]
         {
             new XElement(XName.Get("HD.1", "urn:hl7-org:v2xml"), parameters.OriginOrganizationName),
             new XElement(XName.Get("HD.2", "urn:hl7-org:v2xml"), HL7Helper.TypeCode_Region2Code),
             new XElement(XName.Get("HD.3", "urn:hl7-org:v2xml"), "ISO")
         }),
         new XElement(XName.Get("MSH.7", "urn:hl7-org:v2xml"), HL7Helper.FormatCurrentDateTime()),
         new XElement(
             XName.Get("MSH.9", "urn:hl7-org:v2xml"),
             new object[]
         {
             new XElement(
                 XName.Get("MSG.1", "urn:hl7-org:v2xml"),
                 DataEventTypes.RetrieveReplyCode(parameters.InputDataEventType)),
             new XElement(
                 XName.Get("MSG.2", "urn:hl7-org:v2xml"),
                 DataEventTypes.RetrieveTransactionReply(parameters.InputDataEventType)),
             new XElement(
                 XName.Get("MSG.3", "urn:hl7-org:v2xml"),
                 DataEventTypes.RetrieveReplyStruct(parameters.InputDataEventType))
         }),
         new XElement(XName.Get("MSH.10", "urn:hl7-org:v2xml"), Guid.NewGuid().ToString()),
         new XElement(
             XName.Get("MSH.11", "urn:hl7-org:v2xml"),
             new XElement(XName.Get("PT.1", "urn:hl7-org:v2xml"), parameters.ProcessingMode)),
         new XElement(
             XName.Get("MSH.12", "urn:hl7-org:v2xml"),
             new XElement(XName.Get("VID.1", "urn:hl7-org:v2xml"), "2.6")),
         new XElement(XName.Get("MSH.15", "urn:hl7-org:v2xml"), "AL"),
         new XElement(XName.Get("MSH.16", "urn:hl7-org:v2xml"), "AL")
     }));
 }
Esempio n. 3
0
        public void Message_Parse_Success_1()
        {
            var error = string.Empty;
            var test  = HL7Helper.AnalyzeResponse(@"PUB|OK|||1|
RSP | 1 | TotalPayValue | float | 580.00 |

".Replace("\r\n", "\r"), out error);

            Assert.Equal(test.Name, "");
        }
Esempio n. 4
0
        /// <summary>
        /// The add error reference.
        /// </summary>
        /// <param name="error">
        /// The error.
        /// </param>
        /// <param name="reference">
        /// The reference.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        internal static bool AddErrorReference(XElement error, string reference)
        {
            if ((error != null) && !string.IsNullOrEmpty(reference))
            {
                foreach (var element in error.SelectByLocalName("ERR.5"))
                {
                    foreach (var element2 in element.SelectByLocalName("CWE.2"))
                    {
                        element2.SetValue(HL7Helper.AddMessageReference(element2.Value, reference));
                        return(true);
                    }
                }
            }

            return(false);
        }
        internal Medication buildMedication(RDT rdt)
        {
            Medication med = new Medication();

            med.OrderId    = HL7Helper.getString(rdt, 13, 0);
            med.Refills    = HL7Helper.getString(rdt, 11, 0);
            med.Quantity   = HL7Helper.getString(rdt, 9, 0);
            med.DaysSupply = HL7Helper.getString(rdt, 10, 0);

            med.IssueDate      = HL7Helper.getString(rdt, 4, 0);
            med.LastFillDate   = HL7Helper.getString(rdt, 5, 0);
            med.StartDate      = HL7Helper.getString(rdt, 6, 0);
            med.ExpirationDate = HL7Helper.getString(rdt, 7, 0);

            med.RxNumber = HL7Helper.getString(rdt, 1, 0);
            med.Id       = HL7Helper.getString(rdt, 2, 0);

            med.Provider = new Author();
            NHapi.Base.Model.IType provider = ((Varies)rdt.GetField(12, 0)).Data;
            if (provider is GenericComposite)
            {
                GenericComposite         gc         = (GenericComposite)provider;
                NHapi.Base.Model.IType[] components = gc.Components;
                med.Provider.Id   = ((Varies)components[0]).Data.ToString();
                med.Provider.Name = ((Varies)components[1]).Data.ToString() + ", " + ((Varies)components[2]).Data.ToString();
            }
            else
            {
                med.Provider.Id = provider.ToString();
            }

            med.Name   = HL7Helper.getString(rdt, 3, 0);
            med.Sig    = HL7Helper.getString(rdt, 20, 0);
            med.Detail = HL7Helper.getString(rdt, 19, 0);
            med.Status = HL7Helper.getString(rdt, 8, 0);

            return(med);
        }
        private void SendRequest(RequestMode query)
        {
            string receivedMessage = null;

            ResultList = null;

            try
            {
                switch (query)
                {
                case RequestMode.registry:
                    receivedMessage = HL7Helper.GenerateTeamRegistry(TeamName, RegistryIP, RegistryPort);
                    break;

                case RequestMode.service:
                    receivedMessage = HL7Helper.GenerateQueryService(TeamName, TeamID, RegistryIP, RegistryPort, ServiceTag);
                    break;

                case RequestMode.request:
                    receivedMessage = HL7Helper.SendRequest(SelectedService);
                    break;
                }
            }
            catch (Exception e)
            {
                Logger.Error("Failed to send HL7 request", e);
                _dialogService.ShowMessageBox("Failed to send HL7 request.");

                IsLoading = false;
                return;
            }

            LoadingMessage = "Analyzing";

            string error = string.Empty;

            ResponseHolder serviceResult = null;
            IWebService    queryResult   = null;

            switch (query)
            {
            case RequestMode.registry:
                break;

            case RequestMode.service:
                queryResult = HL7Helper.AnalyzeQueryResponse(receivedMessage, out error);
                break;

            case RequestMode.request:
                serviceResult = HL7Helper.AnalyzeResponse(receivedMessage, out error);
                break;
            }

            if (!string.IsNullOrWhiteSpace(error))
            {
                _dialogService.ShowMessageBox(string.Format("Bad response: {0}", error));
                Logger.Error(error, new Exception(receivedMessage));
            }
            else
            {
                switch (query)
                {
                case RequestMode.registry:
                    break;

                case RequestMode.service:
                    Teams = new List <ITeam>()
                    {
                        new Team(TeamName, new List <IWebService>()
                        {
                            queryResult
                        })
                    };
                    break;

                case RequestMode.request:
                    ResultList = new List <ResponseHolder>()
                    {
                        serviceResult
                    };
                    break;
                }
            }

            IsLoading = false;
            return;
        }
Esempio n. 7
0
        public void Service_1_Message_Success()
        {
            var test = HL7Helper.GenerateServiceMessage(SERVICE_1);

            Assert.Equal(test, "");
        }