Exemple #1
0
        /// <summary>
        /// Create a list of ack details from the supplied list of details
        /// </summary>
        public static List <AcknowledgementDetail> CreateAckDetails(IEnumerable <IResultDetail> details)
        {
            List <AcknowledgementDetail> retVal = new List <AcknowledgementDetail>(10);

            foreach (IResultDetail dtl in details ?? new IResultDetail[0])
            {
                // Acknowledgement detail
                var ackDetail = new AcknowledgementDetail(
                    dtl.Type == ResultDetailType.Error ? AcknowledgementDetailType.Error :
                    dtl.Type == ResultDetailType.Warning ? AcknowledgementDetailType.Warning : AcknowledgementDetailType.Information);

                // Determine the type of acknowledgement
                if (dtl is InsufficientRepetitionsResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InsufficientRepetitions);
                }
                else if (dtl is MandatoryElementMissingResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.MandatoryElementWithNullValue);
                }
                else if (dtl is NotImplementedElementResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.SyntaxError);
                }
                else if (dtl is RequiredElementMissingResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.RequiredElementMissing);
                }
                else if (dtl is PersistenceResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.NoStorageSpaceForMessage);
                }
                else if (dtl is VocabularyIssueResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.TerminologyError);
                }
                else if (dtl is FixedValueMisMatchedResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.ValueDoesNotMatchFixedValue);
                }
                else if (dtl is UnsupportedProcessingModeResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingMode);
                }
                else if (dtl is UnsupportedResponseModeResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingId);
                }
                else if (dtl is UnsupportedVersionResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedVersionId);
                }
                else if (dtl.Exception is NotImplementedException)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedInteraction);
                }
                else if (dtl is UnrecognizedSenderResultDetail)
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnknownSender);
                }
                else if (dtl is DetectedIssueResultDetail) // Don't handle these
                {
                    continue;
                }
                else
                {
                    ackDetail.Code = Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InternalSystemError);
                }

                // Mesage
                ackDetail.Location = dtl.Location == null ? null : new SET <ST>((ST)dtl.Location, (a, b) => ST.Comparator(a, b));
                ackDetail.Text     = dtl.Message;
                if (dtl.Exception != null)
                {
                    ackDetail.Text += String.Format("({0})", dtl.Exception.Message);
                }

                retVal.Add(ackDetail);
            }

            return(retVal);
        }
        /// <summary>
        /// Create a list of ack details from the supplied list of details
        /// </summary>
        public static List <AcknowledgementDetail> CreateAckDetailsUv(IEnumerable <IResultDetail> details)
        {
            List <AcknowledgementDetail> retVal = new List <AcknowledgementDetail>(10);

            foreach (IResultDetail dtl in details ?? new IResultDetail[0])
            {
                // Acknowledgement detail
                var ackDetail = new AcknowledgementDetail()
                {
                    TypeCode =
                        dtl.Type == ResultDetailType.Error ? AcknowledgementDetailType.Error :
                        dtl.Type == ResultDetailType.Warning ? AcknowledgementDetailType.Warning : AcknowledgementDetailType.Information
                };

                // Determine the type of acknowledgement
                if (dtl is InsufficientRepetitionsResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InsufficientRepetitions), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is MandatoryElementMissingResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.MandatoryElementWithNullValue), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is NotImplementedElementResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.SyntaxError), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is RequiredElementMissingResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.RequiredElementMissing), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is PersistenceResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.NoStorageSpaceForMessage), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is VocabularyIssueResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.TerminologyError), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is FixedValueMisMatchedResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.ValueDoesNotMatchFixedValue), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnsupportedProcessingModeResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingMode), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnsupportedResponseModeResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedProcessingId), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnsupportedVersionResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedVersionId), "2.16.840.1.113883.5.1100");
                }
                else if (dtl.Exception is NotImplementedException)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnsupportedInteraction), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is UnrecognizedSenderResultDetail)
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.UnknownSender), "2.16.840.1.113883.5.1100");
                }
                else if (dtl is PatientNotFoundResultDetail || dtl is UnrecognizedTargetDomainResultDetail)
                {
                    ackDetail.Code = new CE <string>("204");
                }
                else if (dtl is DetectedIssueResultDetail) // Don't handle these
                {
                    continue;
                }
                else
                {
                    ackDetail.Code = new CE <string>(Util.ToWireFormat(MARC.Everest.RMIM.CA.R020402.Vocabulary.AcknowledgementDetailCode.InternalSystemError), "2.16.840.1.113883.5.1100");
                }

                // Correct the Xpath
                if (!String.IsNullOrEmpty(dtl.Location))
                {
                    dtl.Location += "/";
                    StringBuilder xPath = new StringBuilder();
                    Regex         regEx = new Regex(@"^(\/\/?)(.*?)#(.*?)(\[.*?])?/");
                    while (regEx.IsMatch(dtl.Location))
                    {
                        var match = regEx.Match(dtl.Location);
                        if (match.Groups.Count > 3)
                        {
                            xPath.AppendFormat("{0}*[namespace-uri() = '{1}' and local-name() = '{2}']", match.Groups[1].Value, match.Groups[2].Value, match.Groups[3].Value);
                        }
                        if (match.Groups.Count > 4)
                        {
                            xPath.Append(match.Groups[4].Value);
                        }
                        dtl.Location = regEx.Replace(dtl.Location, "/");
                    }
                    dtl.Location = xPath.ToString();
                }

                // Mesage
                ackDetail.Location = dtl.Location == null ? null : new SET <ST>((ST)dtl.Location, (a, b) => ST.Comparator(a, b));
                ackDetail.Text     = dtl.Message;
                if (dtl.Exception != null)
                {
                    if (ackDetail.Location == null)
                    {
                        ackDetail.Location = new SET <ST>();
                    }
                    ackDetail.Location.Add((ST)String.Format("({0})", dtl.Exception.StackTrace));
                }
                retVal.Add(ackDetail);
            }

            return(retVal);
        }