Example #1
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));
        }
Example #2
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));
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
0
        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);
        }
        public void TemplateValidationSuccess()
        {
            Template newTemplate = tdb.CreateTemplate("1.2.3.4", tdb.FindTemplateType(Constants.IGTypeNames.CDA, "Document"), "Test 1", this.ig, "section", "Section");
            var      tc1         = tdb.AddConstraintToTemplate(newTemplate, null, null, "code", "SHALL", "1..1");

            tdb.AddConstraintToTemplate(newTemplate, tc1, null, "@code", "SHALL", "1..1", value: "TEST", displayName: "TESTDISPLAY");
            tdb.AddConstraintToTemplate(newTemplate, null, null, "title", "SHALL", "1..1");
            tdb.AddConstraintToTemplate(newTemplate, null, null, "text", "SHALL", "1..1");
            var tc2 = tdb.AddConstraintToTemplate(newTemplate, null, null, "entry", "SHALL", "1..1");

            /* TODO: Schema Choice support temporarily removed from non-FHIR schemas
             * var tc2Choice = tdb.AddConstraintToTemplate(newTemplate, tc2, null, "choice", "SHALL", "1..1");
             * tdb.AddConstraintToTemplate(newTemplate, tc2Choice, null, "observation", "SHALL", "1..1");
             */

            tdb.AddConstraintToTemplate(newTemplate, tc2, null, "observation", "SHALL", "1..1");

            RIMValidator validator = new RIMValidator(tdb);
            var          errors    = validator.ValidateTemplate(newTemplate, null);

            Assert.IsNotNull(errors, "Errors list should not be null.");
            Assert.AreEqual(0, errors.Count, "Shouldn't have found any errors.");
        }
Example #7
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);
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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);
        }