Exemple #1
0
        public void TestBuildContextStringForDocument()
        {
            var docTemplateType = tdb.FindOrCreateTemplateType(this.igType, MockObjectRepository.DEFAULT_CDA_DOC_TYPE);
            var ig = tdb.FindOrCreateImplementationGuide(this.igType, "Test IG");
            TemplateContextBuilder tcb = new TemplateContextBuilder(tdb, this.igType, this.igTypeSchema);

            Template template      = tdb.CreateTemplate("urn:oid:1.2.3.4", docTemplateType, "Test Template", ig, "ClinicalDocument", "ClinicalDocument");
            var      contextString = tcb.BuildContextString(template);

            Assert.AreEqual("cda:ClinicalDocument[cda:templateId[@root='1.2.3.4']]", contextString);
        }
Exemple #2
0
        public void GenerateXMLTest()
        {
            MockObjectRepository mockTdb = new MockObjectRepository();

            mockTdb.InitializeCDARepository();

            ImplementationGuide ig       = mockTdb.FindOrCreateImplementationGuide(Constants.IGTypeNames.CDA, "Test IG", null, DateTime.Now);
            Template            template = mockTdb.CreateTemplate("urn:oid:2.16.22.22.11", "Document", "Test Doc Type", ig, "ClinicalDocument", "ClinicalDocument", "Test Description");
            var tca1 = mockTdb.AddConstraintToTemplate(template, null, null, "@classCode", "SHALL", "1..1", value: "test1");
            var tca2 = mockTdb.AddConstraintToTemplate(template, null, null, "@moodCode", "SHALL", "1..1", value: "test2");
            var tc1  = mockTdb.AddConstraintToTemplate(template, null, null, "entryRelationship", "SHALL", "1..1");
            var tc2  = mockTdb.AddConstraintToTemplate(template, tc1, null, "observation", "SHOULD", "0..1");
            var tc3  = mockTdb.AddConstraintToTemplate(template, tc2, null, "value", "SHALL", "1..1", "CD", value: "4321", displayName: "Test");

            template.TemplateSamples = new System.Data.Entity.Core.Objects.DataClasses.EntityCollection <TemplateSample>();
            template.TemplateSamples.Add(new TemplateSample()
            {
                XmlSample = "<test><example>VALUE</example></test>"
            });

            List <Template> templates = new List <Template>();

            templates.Add(template);

            IGSettingsManager igSettings = new IGSettingsManager(mockTdb, ig.Id);
            TemplateExporter  exporter   = new TemplateExporter(templates, mockTdb, ig.Id);
            string            export     = exporter.GenerateXML();

            Assert.IsFalse(string.IsNullOrEmpty(export));
        }
Exemple #3
0
        public void TestBuildContextStringForAddress_ContainedByMultiple()
        {
            MockObjectRepository tdb = new MockObjectRepository();

            tdb.InitializeCDARepository();

            var igType = tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA);
            var unspecifiedTemplateType = tdb.FindOrCreateTemplateType(igType, MockObjectRepository.DEFAULT_CDA_UNSPECIFIED_TYPE);
            var docTemplateType         = tdb.FindOrCreateTemplateType(igType, Constants.IGTypeNames.CDA);
            var entryTemplateType       = tdb.FindOrCreateTemplateType(igType, MockObjectRepository.DEFAULT_CDA_ENTRY_TYPE);
            var ig = tdb.FindOrCreateImplementationGuide(igType, "Test IG");
            TemplateContextBuilder tcb = new TemplateContextBuilder(tdb, igType, igType.GetSimpleSchema());

            Template addrTemplate = tdb.CreateTemplate("urn:oid:1.2.3.4", unspecifiedTemplateType, "Test Address Template", ig, "addr", "AD");

            Template containingTemplate1 = tdb.CreateTemplate("urn:oid:4.3.2.1", docTemplateType, "Test Doc Template", ig, "ClinicalDocument", "ClinicalDocument");
            var      c1_1 = tdb.AddConstraintToTemplate(containingTemplate1, null, null, "recordTarget", "SHALL", "1..1");
            var      c1_2 = tdb.AddConstraintToTemplate(containingTemplate1, c1_1, null, "patientRole", "SHALL", "1..1");

            tdb.AddConstraintToTemplate(containingTemplate1, c1_2, addrTemplate, "addr", "SHALL", "1..1");

            Template containingTemplate2 = tdb.CreateTemplate("urn:oid:3.2.1.4", entryTemplateType, "Test Entry Template", ig, "observation", "Observation");
            var      c2_1 = tdb.AddConstraintToTemplate(containingTemplate2, null, null, "participant", "SHALL", "1..1");
            var      c2_2 = tdb.AddConstraintToTemplate(containingTemplate2, c2_1, null, "participantRole", "SHALL", "1..1");

            tdb.AddConstraintToTemplate(containingTemplate2, c2_2, addrTemplate, "addr", "SHALL", "1..1");

            var contextString = tcb.BuildContextString(addrTemplate);

            Assert.AreEqual("cda:ClinicalDocument[cda:templateId[@root='4.3.2.1']]/cda:recordTarget/cda:patientRole/cda:addr | cda:observation[cda:templateId[@root='3.2.1.4']]/cda:participant/cda:participantRole/cda:addr", contextString);
        }
        public void STU3_TestGetTemplates()
        {
            MockObjectRepository mockRepo = new MockObjectRepository();

            mockRepo.InitializeFHIR3Repository();
            mockRepo.InitializeLCGAndLogin();

            var ig       = mockRepo.FindOrCreateImplementationGuide(Constants.IGTypeNames.FHIR_STU3, "Test IG");
            var template = mockRepo.CreateTemplate("http://test.com/profile1", "Composition", "Test Composition", ig);

            HttpRequestMessage request = new HttpRequestMessage()
            {
                RequestUri = new Uri("http://localhost:8080/api/FHIR3/StructureDefinition")
            };
            HttpRequest  contextRequest  = new HttpRequest(null, "http://localhost:8080/api/FHIR3/StructureDefinition", null);
            HttpResponse contextResponse = new HttpResponse(new StringWriter());

            HttpContext.Current = new HttpContext(contextRequest, contextResponse);

            FHIR3StructureDefinitionController controller = new FHIR3StructureDefinitionController(mockRepo, request);
            var response = controller.GetTemplates();
            var result   = AssertHelper.IsType <NegotiatedContentResult <Bundle> >(response);

            Assert.IsNotNull(result.Content);
            Assert.AreEqual(1, result.Content.Entry.Count);

            var firstEntry = result.Content.Entry.First();

            Assert.AreEqual("http://localhost:8080/api/FHIR3/StructureDefinition/1", firstEntry.FullUrl);
            Assert.IsNotNull(firstEntry.Resource);

            var firstStrucDef = AssertHelper.IsType <StructureDefinition>(firstEntry.Resource);

            Assert.AreEqual("Test_Composition", firstStrucDef.Id);
        }
Exemple #5
0
        /// <summary>
        /// Used to test green artifact generation.
        /// </summary>
        /// <returns></returns>
        public static MockObjectRepository GenerateGreenMockDataset1()
        {
            MockObjectRepository mockRepo = new MockObjectRepository();

            mockRepo.FindOrCreateCodeSystem("SNOMED CT", "6.96");
            mockRepo.FindOrCreateCodeSystem("HL7ActStatus", "113883.5.14");
            mockRepo.FindOrCreateValueSet("GenderCode", "11.1");

            ImplementationGuideType igType      = mockRepo.FindOrCreateImplementationGuideType(Constants.IGTypeNames.CDA, Constants.IGTypeSchemaLocations.CDA, Constants.IGTypePrefixes.CDA, Constants.IGTypeNamespaces.CDA);
            TemplateType            docType     = mockRepo.FindOrCreateTemplateType(igType, "Document", "ClinicalDocument", "ClinicalDocument", 1);
            TemplateType            sectionType = mockRepo.FindOrCreateTemplateType(igType, "Section", "section", "Section", 2);

            mockRepo.FindOrCreateDataType(igType, "II");
            mockRepo.FindOrCreateDataType(igType, "INT");
            mockRepo.FindOrCreateDataType(igType, "TS");
            mockRepo.FindOrCreateDataType(igType, "CE");

            ImplementationGuide ig1 = mockRepo.FindOrCreateImplementationGuide(igType, "Test IG 1");
            Template            t1  = mockRepo.CreateTemplate("urn:oid:1.2.3.4", docType, "Test Template 1", ig1, null, null, null);

            TemplateConstraint tc1       = mockRepo.AddConstraintToTemplate(t1, null, null, "code", "SHALL", "1..1", "CE");
            TemplateConstraint tc1_1     = mockRepo.AddConstraintToTemplate(t1, tc1, null, "@code", "SHALL", "1..1", null, "SHALL", "1234-x", "Test Doc Code", null, null);
            TemplateConstraint tc1_2     = mockRepo.AddConstraintToTemplate(t1, tc1, null, "@codeSystem", "SHALL", "1..1", null, "SHALL", "1.5.4.2.3", "Test Code System OID", null, null);
            TemplateConstraint tc2       = mockRepo.AddConstraintToTemplate(t1, null, null, "setId", "SHALL", "1..1", "II");
            TemplateConstraint tc3       = mockRepo.AddConstraintToTemplate(t1, null, null, "versionNumber", "SHALL", "1..1", "INT");
            TemplateConstraint tc4       = mockRepo.AddConstraintToTemplate(t1, null, null, "recordTarget", "SHALL", "1..*", null);
            TemplateConstraint tc4_1     = mockRepo.AddConstraintToTemplate(t1, tc4, null, "patientRole", "SHALL", "1..1", null);
            TemplateConstraint tc4_1_1   = mockRepo.AddConstraintToTemplate(t1, tc4_1, null, "id", "SHALL", "1..1", "II");
            TemplateConstraint tc4_1_2   = mockRepo.AddConstraintToTemplate(t1, tc4_1, null, "patient", "SHALL", "1..1", null);
            TemplateConstraint tc4_1_2_1 = mockRepo.AddConstraintToTemplate(t1, tc4_1_2, null, "birthTime", "SHALL", "1..1", "TS");
            TemplateConstraint tc4_1_2_2 = mockRepo.AddConstraintToTemplate(t1, tc4_1_2, null, "administrativeGenderCode", "SHALL", "1..1", "CE");

            return(mockRepo);
        }
Exemple #6
0
        public void ExportTemplatesModelTest1()
        {
            MockObjectRepository tdb = new MockObjectRepository();

            tdb.InitializeCDARepository();

            Organization        org        = tdb.FindOrCreateOrganization("LCG Test");
            ImplementationGuide ig         = tdb.FindOrCreateImplementationGuide(tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA), "Test Implementation Guide");
            IGSettingsManager   igSettings = new IGSettingsManager(tdb, ig.Id);

            Template template = tdb.CreateTemplate("1.2.3.4", "Document", "Test Template", ig, "observation", "Observation", "Test Description", "Test Notes", org);
            var      tc1      = tdb.AddConstraintToTemplate(template, null, null, "entryRelationship", "SHALL", "1..1");
            var      tc2      = tdb.AddConstraintToTemplate(template, tc1, null, "observation", "SHOULD", "0..1");
            var      tc3      = tdb.AddConstraintToTemplate(template, tc2, null, "value", "SHALL", "1..1", "CD", value: "4321", displayName: "Test");

            tc3.Description = "Test description";
            tc3.Label       = "Test Label";
            var tc4 = tdb.AddPrimitiveToTemplate(template, null, "SHALL", "This is a test");

            ExportTemplate export = template.Export(tdb, igSettings);

            Assert.IsNotNull(export);
            Assert.AreEqual(template.Oid, export.identifier);
            Assert.AreEqual(template.Name, export.title);
            Assert.AreEqual(template.TemplateType.Name, export.templateType);
            Assert.AreEqual(template.PrimaryContext, export.context);
            Assert.AreEqual(template.PrimaryContextType, export.contextType);
            Assert.AreEqual(template.Description, export.Description);
            Assert.AreEqual(template.Notes, export.Notes);

            // Assert constraints
            Assert.IsNotNull(export.Constraint);
            Assert.AreEqual(2, export.Constraint.Count);

            // tc1
            Assert.AreEqual(tc1.Context, export.Constraint[0].context);
            Assert.AreEqual(ExportConformanceTypes.SHALL, export.Constraint[0].conformance);
            Assert.AreEqual(tc1.Cardinality, export.Constraint[0].cardinality);

            // tc4
            Assert.IsNull(export.Constraint[1].context);
            Assert.AreEqual(true, export.Constraint[1].isPrimitive);
            Assert.AreEqual(tc4.PrimitiveText, export.Constraint[1].NarrativeText);

            // tc2
            Assert.AreEqual(1, export.Constraint[0].Constraint.Count);
            Assert.AreEqual(tc2.Context, export.Constraint[0].Constraint[0].context);
            Assert.AreEqual(ExportConformanceTypes.SHOULD, export.Constraint[0].Constraint[0].conformance);
            Assert.AreEqual(tc2.Cardinality, export.Constraint[0].Constraint[0].cardinality);

            // tc3
            Assert.AreEqual(1, export.Constraint[0].Constraint[0].Constraint.Count);
            Assert.AreEqual(tc3.Context, export.Constraint[0].Constraint[0].Constraint[0].context);
            Assert.AreEqual(ExportConformanceTypes.SHALL, export.Constraint[0].Constraint[0].Constraint[0].conformance);
            Assert.AreEqual(tc3.Cardinality, export.Constraint[0].Constraint[0].Constraint[0].cardinality);
            Assert.AreEqual(tc3.Description, export.Constraint[0].Constraint[0].Constraint[0].Description);
            Assert.AreEqual(tc3.Label, export.Constraint[0].Constraint[0].Constraint[0].Label);
            Assert.IsFalse(string.IsNullOrEmpty(export.Constraint[0].Constraint[0].Constraint[0].Description));
        }
Exemple #7
0
        public void TestBuildContextStringForAddress_NotContained()
        {
            MockObjectRepository tdb = new MockObjectRepository();

            tdb.InitializeCDARepository();

            var igType = tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA);
            var unspecifiedTemplateType = tdb.FindOrCreateTemplateType(igType, MockObjectRepository.DEFAULT_CDA_UNSPECIFIED_TYPE);
            var ig = tdb.FindOrCreateImplementationGuide(igType, "Test IG");
            TemplateContextBuilder tcb = new TemplateContextBuilder(tdb, igType, igType.GetSimpleSchema());

            Template template      = tdb.CreateTemplate("urn:oid:1.2.3.4", unspecifiedTemplateType, "Test Template", ig, "addr", "AD");
            var      contextString = tcb.BuildContextString(template);

            Assert.AreEqual("cda:addr", contextString);
        }
        public void TestCloneTemplate()
        {
            MockObjectRepository mockDb = new MockObjectRepository();

            mockDb.InitializeCDARepository();
            var ig = mockDb.FindOrCreateImplementationGuide(Constants.IGTypeNames.CDA, "My Test IG");

            var template1 = mockDb.CreateTemplate("1.2.3.4.1", "Document", "My Test Template", ig);

            template1.AuthorId = 2;

            mockDb.AddConstraintToTemplate(template1, null, null, "recordTarget", "SHALL", "1..1");

            template1.TemplateSamples.Add(new TemplateSample()
            {
                Name      = "My Test Sample",
                XmlSample = "<test></test>"
            });

            // Test 1
            var clone1 = template1.CloneTemplate(mockDb, null);

            Assert.IsNotNull(clone1);
            Assert.AreEqual("D_My_Test_Template (Copy)", clone1.Bookmark);
            Assert.AreEqual("My Test Template (Copy)", clone1.Name);
            Assert.AreEqual("1.2.3.4.1.1", clone1.Oid);
            Assert.AreEqual(2, clone1.AuthorId);
            Assert.AreEqual(1, clone1.Constraints.Count);

            // Test the sample for clone1
            Assert.AreEqual(1, clone1.TemplateSamples.Count);
            Assert.AreEqual("My Test Sample", clone1.TemplateSamples.First().Name);
            Assert.AreEqual("<test></test>", clone1.TemplateSamples.First().XmlSample);

            mockDb.Templates.Add(clone1);

            // Test 2
            var clone2 = template1.CloneTemplate(mockDb, 1);

            Assert.IsNotNull(clone2);
            Assert.AreEqual("D_My_Test_Template (Copy 2)", clone2.Bookmark);
            Assert.AreEqual("My Test Template (Copy 2)", clone2.Name);
            Assert.AreEqual("1.2.3.4.1.2", clone2.Oid);
            Assert.AreEqual(1, clone2.AuthorId);
            Assert.AreEqual(1, clone2.Constraints.Count);
        }
Exemple #9
0
        /// <summary>
        /// Used to test different narrative constraint generation combinations.
        /// Populates the mock repository with CDA implementation guide and some basic templates
        /// </summary>
        /// <returns></returns>
        public static MockObjectRepository GenerateMockDataset2()
        {
            MockObjectRepository mockRepo = new MockObjectRepository();

            mockRepo.FindOrCreateCodeSystem("SNOMED CT", "6.96");
            mockRepo.FindOrCreateCodeSystem("HL7ActStatus", "113883.5.14");
            CodeSystem hl7CodeSystem = mockRepo.FindOrCreateCodeSystem("HL7", "1.2.3");

            ValueSet genderCodeValueSet = mockRepo.FindOrCreateValueSet("GenderCode", "11.1");

            mockRepo.FindOrCreateValueSetMember(genderCodeValueSet, hl7CodeSystem, "M", "Male", "active", "01/02/2012");
            mockRepo.FindOrCreateValueSetMember(genderCodeValueSet, hl7CodeSystem, "F", "Female", "active", "01/02/2012");
            mockRepo.FindOrCreateValueSetMember(genderCodeValueSet, hl7CodeSystem, "U", "Undetermined", "active", "01/02/2012");

            ImplementationGuideType igType = mockRepo.FindOrCreateImplementationGuideType(Constants.IGTypeNames.CDA, Constants.IGTypeSchemaLocations.CDA, Constants.IGTypePrefixes.CDA, Constants.IGTypeNamespaces.CDA);

            ImplementationGuide ig = mockRepo.FindOrCreateImplementationGuide(igType, DS2_IG_NAME);

            TemplateType docType = mockRepo.FindOrCreateTemplateType(igType, "Document", "ClinicalDocument", "ClinicalDocument", 1);

            Template template1 = mockRepo.CreateTemplate("1.2.3.4.5.6", docType, "Test Template 1", ig, null, null, "Test Description 1", "Test Notes 1");
            Template template2 = mockRepo.CreateTemplate("1.2.3.4.5.6.5", docType, "Test Template 2", ig, null, null, "Test Description 2", "Test Notes 2");

            mockRepo.AddConstraintToTemplate(template1, null, null, "value", "SHALL", "1..1", null, null, null, null, null, null);
            mockRepo.AddConstraintToTemplate(template1, null, null, "@classCode", "SHALL", "1..1", null, null, "OBS", "Observation", null, mockRepo.CodeSystems.Single(y => y.Id == 2));
            mockRepo.AddConstraintToTemplate(template1, null, null, "templateId/@root", "SHALL", "1..1", null, null, "22.4.47", null, null, null);
            mockRepo.AddConstraintToTemplate(template1, null, null, "code", "SHALL", "1..1", "CD", null, null, null, null, null);
            mockRepo.AddConstraintToTemplate(template1, null, template2, null, "MAY", "0..1", null, null, null, null, null, null);
            mockRepo.AddConstraintToTemplate(template1, null, null, "administrativeGenderCode/@code", "SHALL", "1..1", null, "MAY", null, null, mockRepo.ValueSets.Single(y => y.Id == 1), null);
            mockRepo.AddConstraintToTemplate(template1, null, null, "statusCode", "SHALL", "1..1", null, null, "completed", "Completed", null, mockRepo.CodeSystems.Single(y => y.Id == 2));
            mockRepo.AddConstraintToTemplate(template1, null, null, "code/@code", "SHALL", "1..1", "CD", "SHALL", "1234-X", "Test Disp", null, mockRepo.CodeSystems.Single(y => y.Id == 1));
            mockRepo.AddConstraintToTemplate(template1, null, null, "code", "SHALL", "1..1", "CD", "SHALL", "1234-X", "Test Disp", null, mockRepo.CodeSystems.Single(y => y.Id == 1));

            Template template3 = mockRepo.CreateTemplate("1.2.3.4.5.6.7", docType, "Test Template 3", ig, null, null, "Test Description 3", "");

            TemplateConstraint template3_c1 = mockRepo.AddConstraintToTemplate(template3, null, null, "code", "SHALL", "1..1");

            template3_c1.Category = "TestCategory";

            return(mockRepo);
        }
Exemple #10
0
        public void ExportTemplatesModelTest2()
        {
            MockObjectRepository tdb = new MockObjectRepository();

            tdb.InitializeCDARepository();

            Organization        org        = tdb.FindOrCreateOrganization("LCG Test");
            ImplementationGuide ig         = tdb.FindOrCreateImplementationGuide(tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA), "Test Implementation Guide");
            IGSettingsManager   igSettings = new IGSettingsManager(tdb, ig.Id);

            Template template = tdb.CreateTemplate("1.2.3.4", "Document", "Test Template", ig, "observation", "Observation", "Test Description", "Test Notes");

            ExportTemplate export = template.Export(tdb, igSettings);

            Assert.IsNotNull(export);
            Assert.AreEqual(template.Oid, export.identifier);
            Assert.AreEqual(template.Name, export.title);
            Assert.AreEqual(template.TemplateType.Name, export.templateType);
            Assert.AreEqual(template.PrimaryContext, export.context);
            Assert.AreEqual(template.PrimaryContextType, export.contextType);
            Assert.AreEqual(template.Description, export.Description);
            Assert.AreEqual(template.Notes, export.Notes);
            Assert.AreEqual(template.OwningImplementationGuide.Name, export.ImplementationGuide.name);
        }
        public void STU3_TestConvertExtension()
        {
            MockObjectRepository mockRepo = new MockObjectRepository();

            mockRepo.InitializeFHIR3Repository();
            mockRepo.InitializeLCG();

            var ig       = mockRepo.FindOrCreateImplementationGuide(Constants.IGTypeNames.FHIR_STU3, "Test IG");
            var template = mockRepo.CreateTemplate("http://test.com/fhir/test", "Composition", "Test Composition", ig, "Composition", "Composition");

            template.Extensions.Add(new Trifolia.DB.TemplateExtension()
            {
                Identifier = "http://test.com/extension",
                Type       = "String",
                Value      = "Test string extension value"
            });
            template.Extensions.Add(new Trifolia.DB.TemplateExtension()
            {
                Identifier = "http://test2.com/extension",
                Type       = "Date",
                Value      = "2016234234234" // Invalid date format, but should still be parsed by FHIR library
            });
            template.Extensions.Add(new Trifolia.DB.TemplateExtension()
            {
                Identifier = "http://test3.com/extension",
                Type       = "Coding",
                Value      = "xyz-123|display|urn:oid:2.16.113"
            });
            template.Extensions.Add(new Trifolia.DB.TemplateExtension()
            {
                Identifier = "http://test4.com/extension",
                Type       = "CodeableConcept",
                Value      = "xyz-123|display|urn:oid:2.16.113"
            });
            template.Extensions.Add(new Trifolia.DB.TemplateExtension()         // Extension has invalid value... It is skipped
            {
                Identifier = "http://test5.com/extension",
                Type       = "CodeableConcept",
                Value      = "test"
            });
            template.Extensions.Add(new Trifolia.DB.TemplateExtension()         // Extension has invalid value... It is skipped
            {
                Identifier = "http://test6.com/extension",
                Type       = "Boolean",
                Value      = "test"
            });
            template.Extensions.Add(new Trifolia.DB.TemplateExtension()         // Extension has invalid value... It is skipped
            {
                Identifier = "http://test7.com/extension",
                Type       = "Integer",
                Value      = "test"
            });

            StructureDefinitionExporter exporter = new StructureDefinitionExporter(mockRepo, "http", "test.com");
            SimpleSchema schema = SimpleSchema.CreateSimpleSchema(
                Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation(
                    new ImplementationGuideType()
            {
                Name           = Constants.IGTypeNames.FHIR_STU3,
                SchemaLocation = "fhir-all.xsd"
            }));

            StructureDefinition strucDef = exporter.Convert(template, schema);

            Assert.IsNotNull(strucDef);
            Assert.IsNotNull(strucDef.Extension);
            Assert.AreEqual(strucDef.Extension.Count, 4);

            // Extension 1
            Assert.AreEqual(strucDef.Extension[0].Url, "http://test.com/extension");
            Assert.IsInstanceOfType(strucDef.Extension[0].Value, typeof(FhirString));
            Assert.AreEqual(((FhirString)strucDef.Extension[0].Value).Value, "Test string extension value");

            // Extension 2
            Assert.AreEqual(strucDef.Extension[1].Url, "http://test2.com/extension");
            Assert.IsInstanceOfType(strucDef.Extension[1].Value, typeof(Date));
            Assert.AreEqual(((Date)strucDef.Extension[1].Value).Value, "2016234234234");

            // Extension 3
            Assert.AreEqual(strucDef.Extension[2].Url, "http://test3.com/extension");
            Assert.IsInstanceOfType(strucDef.Extension[2].Value, typeof(Coding));
            Assert.AreEqual(((Coding)strucDef.Extension[2].Value).Code, "xyz-123");
            Assert.AreEqual(((Coding)strucDef.Extension[2].Value).Display, "display");
            Assert.AreEqual(((Coding)strucDef.Extension[2].Value).System, "urn:oid:2.16.113");

            // Extension 4
            Assert.AreEqual(strucDef.Extension[3].Url, "http://test4.com/extension");
            Assert.IsInstanceOfType(strucDef.Extension[3].Value, typeof(CodeableConcept));
            Assert.AreEqual(((CodeableConcept)strucDef.Extension[3].Value).Coding.Count, 1);
            Assert.AreEqual(((CodeableConcept)strucDef.Extension[3].Value).Coding[0].Code, "xyz-123");
            Assert.AreEqual(((CodeableConcept)strucDef.Extension[3].Value).Coding[0].Display, "display");
            Assert.AreEqual(((CodeableConcept)strucDef.Extension[3].Value).Coding[0].System, "urn:oid:2.16.113");
        }
Exemple #12
0
        public static void SetupData(TestContext context)
        {
            tdb = new MockObjectRepository();
            tdb.InitializeFHIR3Repository();
            igType          = tdb.ImplementationGuideTypes.Single(y => y.Name == Constants.IGTypeNames.FHIR_STU3);
            compositionType = tdb.TemplateTypes.Single(y => y.ImplementationGuideType == igType && y.Name == "Composition");
            extensionType   = tdb.TemplateTypes.Single(y => y.ImplementationGuideType == igType && y.Name == "Extension");

            ig                   = tdb.FindOrCreateImplementationGuide(igType, "STU3 IG Publisher Build Package");
            ig.Identifier        = "http://test.com/ig";
            ig.WebDescription    = "This Implementation Guide (IG) defines a series of FHIR profiles on the Composition resource to represent the various document types in C - CDA.This release does not directly map every C - CDA template to FHIR profiles, rather tries to accomplish the C - CDA use case using Composition resource profiles created under this project(the equivalent of Level 2 CDA documents), and begins by linking to the profiles created under the US Core project for any coded entries that would normally be included in C - CDA sections.To have a simpler, more streamlined standard that reuses existing work and focuses on the 80 % that implementers actually need in production systems, the resources of US Core represents a portion of the 80 % needed for coded entries for coded entries of CCD, Care Plan and Discharge Summary).";
            ig.WebReadmeOverview = "We encourage feedback on these Composition profiles, and the general approach to the project as a whole. We also encourage implementers who wish to see more of the coded data from C - CDA mapped to FHIR to comment on the US Core project and make their requests known there.  Once US Core creates new profiles, this project can reference them.";

            tdb.CreateImplementationGuideSection(ig, "Test Heading", "Test Content", 1, level: 3);

            var CCDAonFHIRParticipantProfile = tdb.CreateTemplate(
                "http://test.com/ig/StructureDefinition/CCDA-on-FHIR-Participant",
                extensionType,
                "C-CDAonFHIRParticipant",
                ig,
                "Extension",
                "Extension",
                "C-CDA on FHIR Participant Extension");

            CCDAonFHIRParticipantProfile.Bookmark = "CCDA-on-FHIR-Participant";

            var CCDAonFHIRAuthorizationProfile = tdb.CreateTemplate(
                "http://test.com/ig/StructureDefinition/CCDA-on-FHIR-Authorization",
                extensionType,
                "C-CDAonFHIRAuthorization",
                ig,
                "Extension",
                "Extension",
                "C-CDA on FHIR Authorization Extension");

            CCDAonFHIRAuthorizationProfile.Bookmark = "CCDA-on-FHIR-Authorization";

            var USCorePatientProfile = tdb.CreateTemplate(
                "http://test.com/ig/StructureDefinition/us-core-patient",
                compositionType,
                "U.S.CorePatient",
                ig,
                "Composition",
                "Composition",
                "Defines basic constraints and extensions on the Patient resource for use with other US Core resources.");

            USCorePatientProfile.Bookmark = "us-core-patient";

            USCorePatientProfile.Author           = new User();
            USCorePatientProfile.Author.FirstName = "Sarah";
            USCorePatientProfile.Author.LastName  = "Gaunt";
            USCorePatientProfile.Author.Email     = "*****@*****.**";

            var USCorePractitionerProfile = tdb.CreateTemplate(
                "http://test.com/ig/StructureDefinition/us-core-practitioner",
                compositionType,
                "U.S.CorePractitioner",
                ig,
                "Composition",
                "Composition",
                "Defines basic constraints and extensions on the Practitioner resource for use with other US Core resources.");

            USCorePractitionerProfile.Bookmark = "us-core-practitioner";

            USCorePractitionerProfile.Author           = new User();
            USCorePractitionerProfile.Author.FirstName = "Eric";
            USCorePractitionerProfile.Author.LastName  = "Parapini";
            USCorePractitionerProfile.Author.Email     = "*****@*****.**";

            var USCoreOrganizationProfile = tdb.CreateTemplate(
                "http://test.com/ig/StructureDefinition/us-core-organization",
                compositionType,
                "U.S.CoreOrganization",
                ig,
                "Composition",
                "Composition",
                "Defines basic constraints and extensions on the Organization resource for use with other US Core resources.");

            USCoreOrganizationProfile.Bookmark = "us-core-organization";

            USCoreOrganizationProfile.Author           = new User();
            USCoreOrganizationProfile.Author.FirstName = "Meenaxi";
            USCoreOrganizationProfile.Author.LastName  = "Gosai";
            USCoreOrganizationProfile.Author.Email     = "*****@*****.**";

            var USRealmHeaderProfile = tdb.CreateTemplate(
                "http://test.com/ig/StructureDefinition/CCDA-on-FHIR-US-Realm-Header",
                compositionType,
                "US.RealmHeader",
                ig,
                "Composition",
                "Composition",
                "This profile defines constraints that represent common administrative and demographic concepts for US Realm clinical documents. Further specification, such as type, are provided in document profiles that conform to this profile.");

            USRealmHeaderProfile.Bookmark = "CCDA-on-FHIR-US-Realm-Header";                // This translates to the StructureDefinition.id, which is important

            USRealmHeaderProfile.Author           = new User();
            USRealmHeaderProfile.Author.FirstName = "Sean";
            USRealmHeaderProfile.Author.LastName  = "McIlvenna";
            USRealmHeaderProfile.Author.Email     = "*****@*****.**";

            // Add basic constraints to the  profile
            tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "identifier", "SHALL", "1..1");
            tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "date", "SHALL", "1..1");
            tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "type", "SHALL", "1..1");
            tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "title", "SHALL", "1..1");
            tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "status", "SHALL", "1..1");
            tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "language", "SHALL", "1..1");


            // Add a reference constraint to a contained profile
            TemplateConstraint t3tc1 = tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, USCorePatientProfile, "subject", "SHALL", "1..1");

            // Add a reference constraint to a contained profile
            TemplateConstraint t3tc2 = tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, USCorePractitionerProfile, "author", "SHALL", "1..1");

            // Add a reference constraint to a contained profile
            TemplateConstraint t3tc3 = tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, USCoreOrganizationProfile, "custodian", "SHALL", "1..1");

            // Constraint with a child (child has code system)
            CodeSystem         t1tc4_cs = tdb.FindOrCreateCodeSystem("FHIR CompositionAttestationMode", "http://hl7.org/fhir/composition-attestation-mode");
            TemplateConstraint t1tc4    = tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "attester", "SHOULD", "0..1");
            TemplateConstraint t1tc4_2  = tdb.AddConstraintToTemplate(USRealmHeaderProfile, t1tc4, null, "mode", "SHALL", "1..1", "CE", "SHALL", "legal", null, codeSystem: t1tc4_cs);

            // Add an extension constraint with a contained profile
            TemplateConstraint t5tc1 = tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, CCDAonFHIRAuthorizationProfile, "extension", "SHALL", "1..1", "Extension");

            // Add a Constraint with a child (child has valueset)
            ValueSet           t1tc6_vs = tdb.FindOrCreateValueSet("v3-ConfidentialityClassification", "http://hl7.org/fhir/ValueSet/v3-ConfidentialityClassification");
            TemplateConstraint t1tc6    = tdb.AddConstraintToTemplate(USRealmHeaderProfile, null, null, "confidentiality", "SHALL", "1..1", "CE", "SHALL", null, null, valueSet: t1tc6_vs);

            extractDirectory = Path.Combine(context.TestDeploymentDir, dstu2ExtractFolder);
        }
Exemple #13
0
        public void ImportTemplatesTest()
        {
            MockObjectRepository tdb = new MockObjectRepository();

            tdb.InitializeCDARepository();

            var implementationGuide = tdb.FindOrCreateImplementationGuide(Constants.IGTypeNames.CDA, "Test IG");

            string importXml =
                "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
                "<Trifolia xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.lantanagroup.com\">" +
                "  <Template identifier=\"urn:oid:1.2.3.4.5\" implementationGuideType=\"CDA\" templateType=\"Document\" title=\"Test Template 1\" bookmark=\"D_Test_Template_1\" context=\"ClinicalDocument\">" +
                "    <ImplementationGuide name=\"Test IG\" />" +
                "    <Description>Test Description 2</Description>" +
                "    <Notes>Test Note 1</Notes>" +
                "    <Constraint isVerbose=\"false\" number=\"1000\" context=\"templateId\" conformance=\"SHALL\" cardinality=\"1..1\" />" +
                "    <Constraint isVerbose=\"false\" number=\"1001\" context=\"code\" conformance=\"SHALL\" cardinality=\"1..1\">" +
                "      <Constraint isVerbose=\"false\" number=\"1002\" context=\"@code\" conformance=\"SHALL\" cardinality=\"1..1\">" +
                "        <SingleValueCode code=\"12345X\" displayName=\"Test Static Value\" />" +
                "      </Constraint>" +
                "    </Constraint>" +
                "    <Constraint isVerbose=\"false\" number=\"1003\" context=\"code\" conformance=\"SHALL\" cardinality=\"1..1\">" +
                "      <Constraint isVerbose=\"false\" number=\"1004\" context=\"@code\" conformance=\"SHALL\" cardinality=\"1..1\" dataType=\"CE\">" +
                "        <ValueSet identifier=\"urn:oid:9.8.7.6.5.4.3.2.1\" isStatic=\"true\" />" +
                "      </Constraint>" +
                "    </Constraint>" +
                "  </Template>" +
                "  <Template identifier=\"urn:oid:1.2.3.4.5.6\" implementationGuideType=\"CDA\" templateType=\"Document\" title=\"Test Template 2\" bookmark=\"D_Test_Template_2\" impliedTemplateOid=\"urn:oid:1.2.3.4.5\" context=\"Document\">" +
                "    <ImplementationGuide name=\"Test IG\" />" +
                "    <Description>Test Description 1</Description>" +
                "    <Notes>Test Note 2</Notes>" +
                "    <Constraint isVerbose=\"false\" number=\"1005\" context=\"code\" conformance=\"SHALL\" cardinality=\"1..1\" />" +
                "  </Template>" +
                "  <Template identifier=\"urn:oid:1.2.3.4.5.6.7\" implementationGuideType=\"CDA\" templateType=\"Document\" title=\"Test Template 3\" bookmark=\"D_Test_Template_3\" context=\"Document\">" +
                "    <ImplementationGuide name=\"Test IG\" />" +
                "    <Description>Test Description 3</Description>" +
                "    <Notes>Test Note 3</Notes>" +
                "    <Constraint isVerbose=\"false\" number=\"1006\" conformance=\"SHALL\" cardinality=\"1..1\" containedTemplateOid=\"urn:oid:1.2.3.4.5.6\" />" +
                "    <Constraint isVerbose=\"false\" number=\"1007\" context=\"entry\" conformance=\"SHALL\" cardinality=\"1..1\">" +
                "      <Constraint isVerbose=\"false\" number=\"1008\" context=\"observation\" conformance=\"SHALL\" cardinality=\"1..1\" containedTemplateOid=\"urn:oid:1.2.3.4.5.6\" />" +
                "    </Constraint>" +
                "  </Template>" +
                "</Trifolia>";
            TemplateImporter importer  = new TemplateImporter(tdb);
            List <Template>  templates = importer.Import(importXml);

            Assert.AreEqual(0, importer.Errors.Count, "Should not have errors");

            Assert.IsNotNull(templates, "Did not expect import to return null list of templates");
            Assert.AreEqual(3, templates.Count, "Expected to find 3 imported templates");

            Template firstTemplate = templates[0];

            Assert.AreEqual("urn:oid:1.2.3.4.5", firstTemplate.Oid, "First template's oid was not correct.");
            Assert.AreEqual("Test Template 1", firstTemplate.Name, "First template's title was not set correctly.");
            Assert.AreEqual("D_Test_Template_1", firstTemplate.Bookmark, "First template's bookmark was not set correctly.");

            Assert.IsNotNull(firstTemplate.ImplementationGuideType, "First template's implementation guide type was not set.");
            Assert.AreEqual(Constants.IGTypeNames.CDA, firstTemplate.ImplementationGuideType.Name, "First template's implementation guide was not correct.");

            Assert.IsNotNull(firstTemplate.TemplateType, "First template's type was not set.");
            Assert.AreEqual("Document", firstTemplate.TemplateType.Name, "First template's type was not correct.");

            Assert.IsNotNull(firstTemplate.PrimaryContext, "First template's context was not set.");
            Assert.AreEqual("ClinicalDocument", firstTemplate.PrimaryContext, "First template's context was not correct.");

            Assert.AreEqual(5, firstTemplate.ChildConstraints.Count, "Expected to find 5 constraints in the first template.");

            TemplateConstraint constraint = firstTemplate.ChildConstraints.ToList()[0];

            Assert.IsNotNull(constraint.Context, "First constraint of first template does not have a context.");
            Assert.AreEqual(constraint.Context, "templateId", "First constraint of first template does not have the correct context.");

            Assert.AreEqual(constraint.Cardinality, "1..1", "First constraint of first template does not have the correct cardinality.");

            Assert.IsNotNull(constraint.Conformance, "First constraint of first template does does not have a conformance.");
            Assert.AreEqual(constraint.Conformance, "SHALL", "First constraint of first template does does not have the correct conformance.");

            TemplateConstraint secondConstraint = firstTemplate.ChildConstraints.ToList()[2];

            Assert.IsNotNull(secondConstraint.ParentConstraint, "Third constraint of the first template does not have a parent constraint.");
        }
Exemple #14
0
        public static MockObjectRepository GenerateMockDataset4()
        {
            MockObjectRepository mockRepo = new MockObjectRepository();

            Organization internalOrg = mockRepo.FindOrCreateOrganization("Lantana");
            Organization testOrg     = mockRepo.FindOrCreateOrganization("Test Organization");

            ImplementationGuideType igType = mockRepo.FindOrCreateImplementationGuideType(Constants.IGTypeNames.CDA, Constants.IGTypeSchemaLocations.CDA, Constants.IGTypePrefixes.CDA, Constants.IGTypeNamespaces.CDA);

            TemplateType docType      = mockRepo.FindOrCreateTemplateType(igType, "Document", "ClinicalDocument", "ClinicalDocument", 1);
            TemplateType sectionType  = mockRepo.FindOrCreateTemplateType(igType, "Section", "Section", "Section", 2);
            TemplateType entryType    = mockRepo.FindOrCreateTemplateType(igType, "Entry", "entry", "Entry", 3);
            TemplateType subEntryType = mockRepo.FindOrCreateTemplateType(igType, "Sub-Entry", "entry", "Entry", 4);
            TemplateType otherType    = mockRepo.FindOrCreateTemplateType(igType, "Other", string.Empty, string.Empty, 5);



            mockRepo.FindOrCreateCodeSystem("SNOMED CT", "urn:oid:2.16.840.1.113883.6.96");
            mockRepo.FindOrCreateCodeSystem("LOINC", "urn:oid:2.16.840.1.113883.6.1");
            mockRepo.FindOrCreateCodeSystem("HL7ParticipationType", "urn:oid:2.16.840.1.113883.5.90");
            mockRepo.FindOrCreateCodeSystem("HL7ActStatus", "urn:oid:113883.5.14");
            CodeSystem hl7CodeSystem = mockRepo.FindOrCreateCodeSystem("SNOMED CT", "urn:oid:2.16.840.1.113883.6.96");

            var valueSet = mockRepo.FindOrCreateValueSet("Treatment status", "urn:oid:2.16.840.1.114222.4.11.3203");

            mockRepo.FindOrCreateValueSetMember(valueSet, hl7CodeSystem, "5561003", "Active");
            mockRepo.FindOrCreateValueSetMember(valueSet, hl7CodeSystem, "73425007", "Inactive");
            mockRepo.FindOrCreateValueSetMember(valueSet, hl7CodeSystem, "14321245", "On hold");
            mockRepo.FindOrCreateValueSetMember(valueSet, hl7CodeSystem, "5382145", "Requested");
            mockRepo.FindOrCreateValueSetMember(valueSet, hl7CodeSystem, "7789215", "Cancelled");

            ImplementationGuide ig = mockRepo.FindOrCreateImplementationGuide(igType, DS1_IG_NAME, internalOrg);

            mockRepo.FindOrCreateImplementationGuide(igType, "Test IG 2", testOrg);
            mockRepo.FindOrCreateImplementationGuide(igType, "Test IG 3", internalOrg);

            Template template1 = mockRepo.CreateTemplate("1.2.3.4.5", docType, "Test Template 1", ig, null, null, "Test Description 2", "Template Level Note for Test Template 1");

            template1.Notes = "Template Level Note for Test Template 1";


            mockRepo.AddConstraintToTemplate(template1, null, null, "code", "SHALL", "1..1", "CD", "SHALL", "51897-7", "Test Disp", null, mockRepo.CodeSystems.Single(y => y.Id == 2));

            TemplateConstraint t1 = mockRepo.AddConstraintToTemplate(template1, null, null, "participant", "SHALL", "1..1", "CD", "SHALL", null, null, null, null, null, true, true);

            mockRepo.AddConstraintToTemplate(template1, t1, null, "@typeCode", "SHALL", "1..1", null, "SHALL", "LOC", "Location", null, mockRepo.CodeSystems.Single(y => y.Id == 3));

            // Primitive constraint
            mockRepo.AddPrimitiveToTemplate(template1, null, "SHALL", "A templateId element SHALL be present representing conformance to this release of the Implementation Guide");


            template1.TemplateSamples.Add(new TemplateSample()
            {
                XmlSample = @"<observation/>",
                Name      = "Test_Template_1_Example"
            });

            // Basic constraint
            TemplateConstraint t1tc1 = mockRepo.AddConstraintToTemplate(template1, null, null, "templateId", "SHALL", "1..1", "CD", null, null, null, null, null, null, null, null);

            t1tc1.Notes = "Constraint *TemplateId* Note for Test Template 1";

            // Basic Constraint with a child
            TemplateConstraint t1tc2   = mockRepo.AddConstraintToTemplate(template1, null, null, "code", "SHALL", "1..1");
            TemplateConstraint t1tc2_2 = mockRepo.AddConstraintToTemplate(template1, t1tc2, null, "@value", "SHALL", "1..1", null, null, "236435004", "Test Static Value", null, mockRepo.CodeSystems.Single(y => y.Id == 1));

            // Constraint with a child (child has valueset)
            ValueSet           t1tc3_vs = mockRepo.FindOrCreateValueSet("Test Valueset", "9.8.7.6.5.4.3.2.1");
            TemplateConstraint t1tc3    = mockRepo.AddConstraintToTemplate(template1, null, null, "code", "SHALL", "1..1");
            //TemplateConstraint t1tc3_1 = mockRepo.AddConstraintToTemplate(template1, t1tc3, null, "@code", "SHALL", "1..1", "CE", "SHALL", null, null, t1tc3_vs);
            TemplateConstraint t1tc3_1 = mockRepo.AddConstraintToTemplate(template1, t1tc3, null, "@code", "SHALL", "1..1", "CE", "SHALL", "55561003", "Active", mockRepo.ValueSets.Single(y => y.Id == 1));

            t1tc3.Notes      = "Child *code* constraint with Value Set Notes";
            t1tc3_1.IsStatic = true;

            Template template2 = mockRepo.CreateTemplate("1.2.3.4.5.6", docType, "Test Template 2", ig, null, null, "Test Description 1", "Template Level Note for Test Template 2");

            template2.ImpliedTemplate = template1;

            // Constraint with a child
            TemplateConstraint t2tc1 = mockRepo.AddConstraintToTemplate(template2, null, null, "code", "SHALL", "1..1");

            Template template3 = mockRepo.CreateTemplate("1.2.3.4.5.6.7", docType, "Test Template 3", ig, null, null, "Test Description 3", "Template Level Note for Test Template 3");

            TemplateConstraint t3tc1   = mockRepo.AddConstraintToTemplate(template3, null, template2, null, "SHALL", "1..1");
            TemplateConstraint t3tc2   = mockRepo.AddConstraintToTemplate(template3, null, null, "entry", "SHALL", "1..1");
            TemplateConstraint t3tc2_1 = mockRepo.AddConstraintToTemplate(template3, t3tc2, template2, "observation", "SHALL", "1..1");

            Template template4 = mockRepo.CreateTemplate("8.2234.19.234.11", docType, "Test Constraint Description Template", ig, null, null, null, null);

            mockRepo.AddConstraintToTemplate(template4, null, null, "code", "SHALL", "1..1", "CD", null, null, null, null, null, "Test constraint description");

            // Create a new version of the implementation guide
            ImplementationGuide igVersion = mockRepo.FindOrCreateImplementationGuide(igType, DS1_IG_NAME + " Version 2");

            igVersion.SetPreviousVersion(ig);
            igVersion.Version = 2;

            // Create a new version of template 3 within the new version of the IG
            Template template3Version = mockRepo.CreateTemplate("urn:hl7ii:1.2.3.4.5.6.7:20180117", docType, "Test Template 3", igVersion, null, null, "Test Description 3 with changes", "Test Note 3 with changes");

            template3Version.SetPreviousVersion(template3);

            // Create an entirely new template for the new version of the IG
            Template template4Version = mockRepo.CreateTemplate("urn:oid:1.2.3.4.1.2.3.4", sectionType, "Test Template 4", igVersion);
            var      t4tc1            = mockRepo.AddConstraintToTemplate(template4Version, null, null, "component", "SHALL", "1..1");

            mockRepo.AddConstraintToTemplate(template4Version, t4tc1, null, "section", "SHALL", "1..1");

            return(mockRepo);
        }
Exemple #15
0
        /// <summary>
        /// Data set is used to test implementation guide generation (the MS Word document export) and to test importing/exporting
        /// implementation guides in the legacy trifolia format.
        /// </summary>
        public static MockObjectRepository GenerateMockDataset1()
        {
            MockObjectRepository mockRepo = new MockObjectRepository();

            Organization internalOrg = mockRepo.FindOrCreateOrganization("Lantana");
            Organization testOrg     = mockRepo.FindOrCreateOrganization("Test Organization");

            ImplementationGuideType igType = mockRepo.FindOrCreateImplementationGuideType(Constants.IGTypeNames.CDA, Constants.IGTypeSchemaLocations.CDA, Constants.IGTypePrefixes.CDA, Constants.IGTypeNamespaces.CDA);

            TemplateType docType      = mockRepo.FindOrCreateTemplateType(igType, "Document", "ClinicalDocument", "ClinicalDocument", 1);
            TemplateType sectionType  = mockRepo.FindOrCreateTemplateType(igType, "Section", "Section", "Section", 2);
            TemplateType entryType    = mockRepo.FindOrCreateTemplateType(igType, "Entry", "entry", "Entry", 3);
            TemplateType subEntryType = mockRepo.FindOrCreateTemplateType(igType, "Sub-Entry", "entry", "Entry", 4);
            TemplateType otherType    = mockRepo.FindOrCreateTemplateType(igType, "Other", string.Empty, string.Empty, 5);

            mockRepo.FindOrCreateValueSet("Test Value Set", "9.8.7.6.5.4.3.2.1");

            ImplementationGuide ig = mockRepo.FindOrCreateImplementationGuide(igType, DS1_IG_NAME, internalOrg);

            mockRepo.FindOrCreateImplementationGuide(igType, "Test IG 2", testOrg);
            mockRepo.FindOrCreateImplementationGuide(igType, "Test IG 3", internalOrg);

            Template template1 = mockRepo.CreateTemplate("1.2.3.4.5", docType, "Test Template 1", ig, null, null, "Test Description 2", "Template Level Note for Test Template 1");

            template1.Notes = "Template 1 Note";

            template1.TemplateSamples.Add(new TemplateSample()
            {
                XmlSample = @"<observation/>",
                Name      = "Test_Template_1_Example"
            });

            // Basic constraint, nothing special
            TemplateConstraint t1tc1 = mockRepo.AddConstraintToTemplate(template1, null, null, "templateId", "SHALL", "1..1");

            t1tc1.Notes = "Constraint TemplateId comment for Test Template 1";

            // Constraint with a child
            TemplateConstraint t1tc2   = mockRepo.AddConstraintToTemplate(template1, null, null, "code", "SHALL", "1..1");
            TemplateConstraint t1tc2_2 = mockRepo.AddConstraintToTemplate(template1, t1tc2, null, "@code", "SHALL", "1..1", null, null, "12345X", "Test Static Value");

            // Constraint with a child (child has valueset)
            ValueSet           t1tc3_vs = mockRepo.FindOrCreateValueSet("Test Valueset", "9.8.7.6.5.4.3.2.1");
            TemplateConstraint t1tc3    = mockRepo.AddConstraintToTemplate(template1, null, null, "code", "SHALL", "1..1");
            TemplateConstraint t1tc3_1  = mockRepo.AddConstraintToTemplate(template1, t1tc3, null, "@code", "SHALL", "1..1", "CE", "SHALL", null, null, t1tc3_vs);

            t1tc3_1.IsStatic = true;

            Template template2 = mockRepo.CreateTemplate("1.2.3.4.5.6", docType, "Test Template 2", ig, null, null, "Test Description 1", "Template Level Note for Test Template 2");

            template2.ImpliedTemplate = template1;

            // Constraint with a child
            TemplateConstraint t2tc1 = mockRepo.AddConstraintToTemplate(template2, null, null, "code", "SHALL", "1..1");

            Template template3 = mockRepo.CreateTemplate("1.2.3.4.5.6.7", docType, "Test Template 3", ig, null, null, "Test Description 3", "Template Level Note for Test Template 3");

            TemplateConstraint t3tc1   = mockRepo.AddConstraintToTemplate(template3, null, template2, null, "SHALL", "1..1");
            TemplateConstraint t3tc2   = mockRepo.AddConstraintToTemplate(template3, null, null, "entry", "SHALL", "1..1");
            TemplateConstraint t3tc2_1 = mockRepo.AddConstraintToTemplate(template3, t3tc2, template2, "observation", "SHALL", "1..1");

            Template template4 = mockRepo.CreateTemplate("8.2234.19.234.11", docType, "Test Constraint Description Template", ig, null, null, null, null);

            mockRepo.AddConstraintToTemplate(template4, null, null, "code", "SHALL", "1..1", "CD", null, null, null, null, null, "Test constraint description");

            return(mockRepo);
        }