예제 #1
0
        private void ValidateMessage(Hl7Message hl7RequestMessage, Hl7MessageDelimiters messageDelimiters)
        {
            try
            {
                // validate the HL7 message
                System.String facility = hl7RequestMessage.SendingFacility;
                System.String version  = hl7RequestMessage.VersionId;
                if (_hl7ProfileStore != null)
                {
                    // get the validation profile - keyed off the facility, version and messageType
                    System.String messageType = hl7RequestMessage.MessageType;
                    if (hl7RequestMessage.MessageSubType != System.String.Empty)
                    {
                        messageType += ("^" + hl7RequestMessage.MessageSubType);
                    }

                    System.String xmlProfile = _hl7ProfileStore.GetXmlHl7Profile(new Hl7ProfileId(facility, version, messageType));

                    if (_hl7ValidationContext != null)
                    {
                        // get the validation context
                        System.String xmlValidationContext = _hl7ValidationContext.XmlValidationContext;

                        if ((xmlProfile != System.String.Empty) &&
                            (xmlValidationContext != System.String.Empty) &&
                            (_nistWebServiceClient != null))
                        {
                            System.String errorDescription    = System.String.Empty;
                            System.String xmlValidationResult = _nistWebServiceClient.Validate(xmlProfile, xmlValidationContext, hl7RequestMessage.ToString(messageDelimiters), false, out errorDescription);
                            if (errorDescription != System.String.Empty)
                            {
                                _hl7ThreadForHl7Server.LogError(errorDescription);
                            }

                            NistXmlResultsParser xmlParser = new NistXmlResultsParser(xmlValidationResult);
                            _hl7ThreadForHl7Server.UpdateValidationErrorCount(xmlParser.ErrorCount);
                            _hl7ThreadForHl7Server.UpdateValidationWarningCount(xmlParser.WarningCount);
                            _hl7ThreadForHl7Server.WriteXmlStringToResults(xmlParser.RemoveHeader(xmlValidationResult));
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                System.String message = System.String.Format("NIST Validation Exception: {0} - {1}",
                                                             e.Message, e.StackTrace);
                Console.WriteLine(message);
                _hl7ThreadForHl7Server.LogInformation(message);
            }
        }
예제 #2
0
파일: Hl7Client.cs 프로젝트: ewcasas/DVTK
        private void ValidateMessage(Hl7Message hl7ResponseMessage, Hl7MessageDelimiters messageDelimiters)
        {
            try
            {
                // validate the HL7 message
                System.String facility = hl7ResponseMessage.SendingFacility;
                System.String version = hl7ResponseMessage.VersionId;
                if (_hl7ProfileStore != null)
                {
                    // get the validation profile - keyed off the facility, version and messageType
                    System.String messageType = hl7ResponseMessage.MessageType;
                    if (hl7ResponseMessage.MessageSubType != System.String.Empty)
                    {
                        messageType += ("^" + hl7ResponseMessage.MessageSubType);
                    }

                    System.String xmlProfile = _hl7ProfileStore.GetXmlHl7Profile(new Hl7ProfileId(facility, version, messageType));

                    if (_hl7ValidationContext != null)
                    {
                        // get the validation context
                        System.String xmlValidationContext = _hl7ValidationContext.XmlValidationContext;

                        if ((xmlProfile != System.String.Empty) &&
                            (xmlValidationContext != System.String.Empty) &&
                            (_nistWebServiceClient != null))
                        {
                            System.String errorDescription = System.String.Empty;
                            System.String xmlValidationResult = _nistWebServiceClient.Validate(xmlProfile, xmlValidationContext, hl7ResponseMessage.ToString(messageDelimiters), false, out errorDescription);
                            if (errorDescription != System.String.Empty)
                            {
                                _hl7ThreadForHl7Client.LogError(errorDescription);
                            }
                            NistXmlResultsParser xmlParser = new NistXmlResultsParser(xmlValidationResult);
                            _hl7ThreadForHl7Client.UpdateValidationErrorCount(xmlParser.ErrorCount);
                            _hl7ThreadForHl7Client.UpdateValidationWarningCount(xmlParser.WarningCount);
                            _hl7ThreadForHl7Client.WriteXmlStringToResults(xmlParser.RemoveHeader(xmlValidationResult));
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                System.String message = System.String.Format("NIST Validation Exception: {0} - {1}",
                    e.Message, e.StackTrace);
                Console.WriteLine(message);
                _hl7ThreadForHl7Client.LogInformation(message);
            }
        }