Example #1
0
        /// <summary>
        /// Validate the generic CDA message
        /// </summary>
        /// <param name="inputXml">generic CDA message in XML</param>
        /// <param name="templateSchemaName">optional template schema name, if not present it will use whatever template schema name present in the input XML</param>
        /// <param name="genericCdaSchemaName">optional CDA schema name, if not present if twill use whatever CDA schem name present in the input XML</param>
        /// <returns></returns>
        public Result Validate(string inputXml, string templateSchemaName = null, string genericCdaSchemaName = null)
        {
            try
            {
                InputSchema messageSchema = GetInputSchema(inputXml);

                if (!string.IsNullOrWhiteSpace(templateSchemaName))
                {
                    MakeSureSchemaMatches("generic CDA schema", templateSchemaName, messageSchema.TemplateSchema);
                }

                if (!string.IsNullOrEmpty(genericCdaSchemaName))
                {
                    MakeSureSchemaMatches("templated CDA schema", genericCdaSchemaName, messageSchema.CdaSchema);
                }

                Result result = ValidateGenericCda(inputXml, messageSchema.CdaSchema);
                if (!result.Status)
                {
                    return(result);
                }

                string templateXml = _transformer.Transform(StylesheetDocument.CdaToTemplated, inputXml);

                return(ValidateTemplate(templateXml, messageSchema.TemplateSchema));
            }
            catch (Exception ex)
            {
                return(Result.Exception(ex));
            }
        }
Example #2
0
        public void Transform_UsingClientStylesheet_Tests()
        {
            var transformer     = new StylesheetTransformer(_unitTestAssemblyResolver);
            var localStylesheet = _unitTestAssemblyResolver.GetResourceStream("CDALikeToTrueCDA.xsl").GetText();
            var templated       = transformer.Transform(localStylesheet, _unitTestAssemblyResolver.GetResourceStream("POCD_EX150001UK06_05.xml").GetText());

            Assert.NotNull(templated);
            Assert.True(Extensions.IsValidXml(templated));
        }
Example #3
0
        public void Transform_UsingLibraryStylesheet_Tests()
        {
            var transformer = new StylesheetTransformer();
            var cda         = _unitTestAssemblyResolver.GetResourceStream("POCD_EX150001UK06_05.xml").GetText();

            var templated = transformer.Transform(StylesheetDocument.CdaToTemplated, cda);


            Assert.NotNull(templated);
            Assert.True(Extensions.IsValidXml(templated));
        }