public void TestSetup() { this.tdb = new MockObjectRepository(); this.tdb.InitializeCDARepository(); CodeSystem cs = tdb.FindOrCreateCodeSystem("LOINC", "1.2.3.4.5"); this.vs1 = tdb.FindOrCreateValueSet("Test Valueset 1", "1.2.3.4"); this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "1", "One", "active", "1/1/2000"); this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "2", "Two", "active", "1/1/2000"); this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "1", "One", "inactive", "1/1/2001"); this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "3", "Three", "active", "1/1/2001"); this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "1", "One", "active", "1/1/2002"); this.vs2 = tdb.FindOrCreateValueSet("Test Valueset 2", "4.3.2.1"); this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "1", "One"); this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "2", "Two"); this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "3", "Three", "inactive", "1/1/2000"); this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "4", "Four", "active", "1/1/2000"); this.vs3 = tdb.FindOrCreateValueSet("Test Valueset 3", "1.4.2.3"); this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "1", "One"); this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "2", "Two"); this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "3", "Three", valueSetStatus: "inactive", dateOfValueSetStatus: "08/05/2013"); this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "4", "Four", valueSetStatus: "active"); this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "5", "Five"); this.ig = this.tdb.FindOrCreateImplementationGuide(Constants.IGTypeNames.CDA, "Test IG"); }
/// <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); }
/// <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("CDA", "CDA.xsd", "cda", "urn:hl7-org:v3"); TemplateType docType = mockRepo.FindOrCreateTemplateType(igType, "Document", "ClinicalDocument", "ClinicalDocument", 1); TemplateType sectionType = mockRepo.FindOrCreateTemplateType(igType, "Section", "section", "Section", 2); mockRepo.GenerateDataType(igType, "II"); mockRepo.GenerateDataType(igType, "INT"); mockRepo.GenerateDataType(igType, "TS"); mockRepo.GenerateDataType(igType, "CE"); ImplementationGuide ig1 = mockRepo.FindOrAddImplementationGuide(igType, "Test IG 1"); Template t1 = mockRepo.GenerateTemplate("urn:oid:1.2.3.4", docType, "Test Template 1", ig1, null, null, null); TemplateConstraint tc1 = mockRepo.GenerateConstraint(t1, null, null, "code", "SHALL", "1..1", "CE"); TemplateConstraint tc1_1 = mockRepo.GenerateConstraint(t1, tc1, null, "@code", "SHALL", "1..1", null, "SHALL", "1234-x", "Test Doc Code", null, null); TemplateConstraint tc1_2 = mockRepo.GenerateConstraint(t1, tc1, null, "@codeSystem", "SHALL", "1..1", null, "SHALL", "1.5.4.2.3", "Test Code System OID", null, null); TemplateConstraint tc2 = mockRepo.GenerateConstraint(t1, null, null, "setId", "SHALL", "1..1", "II"); TemplateConstraint tc3 = mockRepo.GenerateConstraint(t1, null, null, "versionNumber", "SHALL", "1..1", "INT"); TemplateConstraint tc4 = mockRepo.GenerateConstraint(t1, null, null, "recordTarget", "SHALL", "1..*", null); TemplateConstraint tc4_1 = mockRepo.GenerateConstraint(t1, tc4, null, "patientRole", "SHALL", "1..1", null); TemplateConstraint tc4_1_1 = mockRepo.GenerateConstraint(t1, tc4_1, null, "id", "SHALL", "1..1", "II"); TemplateConstraint tc4_1_2 = mockRepo.GenerateConstraint(t1, tc4_1, null, "patient", "SHALL", "1..1", null); TemplateConstraint tc4_1_2_1 = mockRepo.GenerateConstraint(t1, tc4_1_2, null, "birthTime", "SHALL", "1..1", "TS"); TemplateConstraint tc4_1_2_2 = mockRepo.GenerateConstraint(t1, tc4_1_2, null, "administrativeGenderCode", "SHALL", "1..1", "CE"); // Green Info GreenTemplate gt1 = new GreenTemplate() { Id = 1, Template = t1, TemplateId = t1.Id, Name = "Test Green Template 1" }; mockRepo.GreenTemplates.AddObject(gt1); t1.GreenTemplates.Add(gt1); GreenConstraint gc1 = mockRepo.GenerateGreenConstraint(gt1, tc2, null, 1, "VersionSet", true); GreenConstraint gc2 = mockRepo.GenerateGreenConstraint(gt1, tc3, null, 2, "VersionNumber", true); GreenConstraint gc3 = mockRepo.GenerateGreenConstraint(gt1, tc4, null, 3, "Patient", false); GreenConstraint gc4 = mockRepo.GenerateGreenConstraint(gt1, tc4_1_1, gc3, 1, "Id", true); GreenConstraint gc5 = mockRepo.GenerateGreenConstraint(gt1, tc4_1_2_1, gc3, 2, "BirthDate", true); GreenConstraint gc6 = mockRepo.GenerateGreenConstraint(gt1, tc4_1_2_2, gc3, 3, "Gender", true); return(mockRepo); }
/// <summary> /// Used to test different narrative constraint generation combinations. /// </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("CDA", "CDA.xsd", "cda", "urn:hl7-org:v3"); ImplementationGuide ig = mockRepo.FindOrAddImplementationGuide(igType, "The IG"); TemplateType docType = mockRepo.FindOrCreateTemplateType(igType, "Document", "ClinicalDocument", "ClinicalDocument", 1); Template template1 = mockRepo.GenerateTemplate("1.2.3.4.5.6", docType, "Test Template 1", ig, null, null, "Test Description 1", "Test Notes 1"); Template template2 = mockRepo.GenerateTemplate("1.2.3.4.5.6.5", docType, "Test Template 2", ig, null, null, "Test Description 2", "Test Notes 2"); mockRepo.GenerateConstraint(template1, null, null, "value", "SHALL", "1..1", null, null, null, null, null, null); mockRepo.GenerateConstraint(template1, null, null, "@classCode", "SHALL", "1..1", null, null, "OBS", "Observation", null, mockRepo.CodeSystems.Single(y => y.Id == 2)); mockRepo.GenerateConstraint(template1, null, null, "templateId/@root", "SHALL", "1..1", null, null, "22.4.47", null, null, null); mockRepo.GenerateConstraint(template1, null, null, "code", "SHALL", "1..1", "CD", null, null, null, null, null); mockRepo.GenerateConstraint(template1, null, template2, null, "MAY", "0..1", null, null, null, null, null, null); mockRepo.GenerateConstraint(template1, null, null, "administrativeGenderCode/@code", "SHALL", "1..1", null, "MAY", null, null, mockRepo.ValueSets.Single(y => y.Id == 1), null); mockRepo.GenerateConstraint(template1, null, null, "statusCode", "SHALL", "1..1", null, null, "completed", "Completed", null, mockRepo.CodeSystems.Single(y => y.Id == 2)); mockRepo.GenerateConstraint(template1, null, null, "code/@code", "SHALL", "1..1", "CD", "SHALL", "1234-X", "Test Disp", null, mockRepo.CodeSystems.Single(y => y.Id == 1)); mockRepo.GenerateConstraint(template1, null, null, "code", "SHALL", "1..1", "CD", "SHALL", "1234-X", "Test Disp", null, mockRepo.CodeSystems.Single(y => y.Id == 1)); Template template3 = mockRepo.GenerateTemplate("1.2.3.4.5.6.7", docType, "Test Template 3", ig, null, null, "Test Description 3", ""); TemplateConstraint template3_c1 = mockRepo.GenerateConstraint(template3, null, null, "code", "SHALL", "1..1"); template3_c1.Category = "TestCategory"; return(mockRepo); }
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); }
public void TestImportExcel() { MockObjectRepository tdb = new MockObjectRepository(); var data = Helper.GetSampleContentBytes("Trifolia.Test.DocSamples.ExampleTerminologyImport.xlsx"); TerminologyController controller = new TerminologyController(tdb); ImportCheckRequest request = new ImportCheckRequest() { Data = data, FirstRowIsHeader = true }; var response = controller.CheckExcelImport(request); Assert.AreEqual(response.Errors.Count, 1, "Expected an error related to code system not being found"); // Code system is found, first valueset is not found, to be added var codesystem = tdb.FindOrCreateCodeSystem("Test Code System", "urn:oid:4.3.2.1"); response = controller.CheckExcelImport(request); Assert.AreEqual(response.Errors.Count, 0); Assert.AreEqual(response.ValueSets.Count, 2); Assert.IsNull(response.ValueSets[0].Id); Assert.AreEqual(response.ValueSets[0].ChangeType, ImportValueSetChange.ChangeTypes.Add); // First valueset is found, name to be updated var valueset = tdb.FindOrCreateValueSet("Value Set", "urn:oid:1.2.3.4"); response = controller.CheckExcelImport(request); Assert.AreEqual(response.Errors.Count, 0); Assert.AreEqual(response.ValueSets.Count, 2); Assert.IsNotNull(response.ValueSets[0].Id); Assert.AreEqual(response.ValueSets[0].ChangeType, ImportValueSetChange.ChangeTypes.Update); // First valueset is found, nothing to update valueset.Name = "Test Valueset 1"; response = controller.CheckExcelImport(request); Assert.AreEqual(response.Errors.Count, 0); Assert.AreEqual(response.ValueSets.Count, 2); Assert.IsNotNull(response.ValueSets[0].Id); Assert.AreEqual(response.ValueSets[0].ChangeType, ImportValueSetChange.ChangeTypes.None); // Concepts to be added Assert.AreEqual(response.ValueSets[0].Concepts.Count, 1); Assert.IsNull(response.ValueSets[0].Concepts[0].Id); Assert.AreEqual(response.ValueSets[0].Concepts[0].ChangeType, ImportValueSetChange.ChangeTypes.Add); // Found exact concept, but nothing to update var concept = tdb.FindOrCreateValueSetMember(valueset, codesystem, "asdf", "TEST", "active", "5/15/2014"); response = controller.CheckExcelImport(request); Assert.AreEqual(response.Errors.Count, 0); Assert.IsNotNull(response.ValueSets[0].Concepts[0].Id); Assert.AreEqual(response.ValueSets[0].Concepts[0].ChangeType, ImportValueSetChange.ChangeTypes.None); // Found exact concept, but update the display concept.DisplayName = "invalid display"; response = controller.CheckExcelImport(request); Assert.AreEqual(response.Errors.Count, 0); Assert.IsNotNull(response.ValueSets[0].Concepts[0].Id); Assert.AreEqual(response.ValueSets[0].Concepts[0].ChangeType, ImportValueSetChange.ChangeTypes.Update); Assert.AreEqual(response.ValueSets[0].Concepts[0].Code, "asdf"); Assert.AreEqual(response.ValueSets[0].Concepts[0].DisplayName, "TEST"); concept.Status = null; concept.StatusDate = null; response = controller.CheckExcelImport(request); Assert.AreEqual(response.Errors.Count, 0); Assert.AreEqual(response.ValueSets[0].Concepts[0].ChangeType, ImportValueSetChange.ChangeTypes.Add); Assert.AreEqual(response.ValueSets[0].Concepts[0].Code, "asdf"); Assert.AreEqual(response.ValueSets[0].Concepts[0].DisplayName, "TEST"); Assert.AreEqual(response.ValueSets[0].Concepts[0].CodeSystemOid, codesystem.Oid); Assert.AreEqual(response.ValueSets[0].Concepts[0].CodeSystemName, codesystem.Name); Assert.AreEqual(response.ValueSets[0].Concepts[0].Status, "active"); Assert.AreEqual(response.ValueSets[0].Concepts[0].StatusDate, DateTime.Parse("5/15/2014")); }
public void MyTestInitialize() { tdb = new MockObjectRepository(); // IG Type ImplementationGuideType cdaType = tdb.FindOrCreateImplementationGuideType("CDA", "cda.xsd", "cda", "urn:hl7-org:v3"); // Template Type TemplateType docType = tdb.FindOrCreateTemplateType(cdaType, "document", "ClinicalDocument", "ClinicalDocument", 1); TemplateType secType = tdb.FindOrCreateTemplateType(cdaType, "section", "section", "Section", 2); TemplateType entType = tdb.FindOrCreateTemplateType(cdaType, "entry", "entry", "Entry", 3); // Code System CodeSystem cs1 = tdb.FindOrCreateCodeSystem("SNOMED CT", "6.36"); // Value Set ValueSet vs1 = tdb.FindOrCreateValueSet("Test Value Set 1", "1.2.3.4"); tdb.FindOrCreateValueSetMember(vs1, cs1, "1234", "Test Member 1"); tdb.FindOrCreateValueSetMember(vs1, cs1, "4321", "Test Member 2"); // Implementation Guide ImplementationGuide ig1 = tdb.FindOrAddImplementationGuide(cdaType, "Test Implementation Guide 1", publishDate: new DateTime(2012, 1, 1)); // IG Files byte[] testSchBytes = Helper.GetSampleContentBytes("Trifolia.Test.DocSamples.test.sch"); ImplementationGuideFile testSchFile = tdb.GenerateImplementationGuideFile(ig1, "test.sch", ImplementationGuideFile.ContentTypeSchematron, "text/xml", content: testSchBytes); this.testSchFileId = testSchFile.Id; tdb.GenerateImplementationGuideFile(ig1, "voc.xml", ImplementationGuideFile.ContentTypeVocabulary, "text/xml", content: testSchBytes); tdb.GenerateImplementationGuideFile(ig1, "test1_template1.ent", ImplementationGuideFile.ContentTypeSchematronHelper, "text/xml", content: testSchBytes); ImplementationGuide ig2 = tdb.FindOrAddImplementationGuide(cdaType, "Test Implementation Guide 2"); // Template 1 Template t1 = tdb.GenerateTemplate("urn:oid:1.2.3.4", docType, "Test Template", ig1, null, null, null); tdb.GenerateConstraint(t1, null, null, "title", "SHALL", "1..1"); // Template 2 Template t2 = tdb.GenerateTemplate("urn:oid:1.2.3.4.1", docType, "Test Template", ig1, null, null, null); TemplateConstraint t2_tc1 = tdb.GenerateConstraint(t2, null, null, "title", "SHALL", "1..1"); t2_tc1.Schematron = "count(cda:title)"; TemplateConstraint t2_tc2 = tdb.GeneratePrimitive(t2, null, "SHALL", "This is a test primitive"); tdb.GeneratePrimitive(t2, null, "SHALL", "This is test primitive #2", "count(cda:title) > 0"); // Template 3 Template t3 = tdb.GenerateTemplate("urn:oid:1.2.3.4.2", docType, "Test Template", ig2, null, null, null); tdb.GenerateConstraint(t1, null, null, "title", "SHOULD", "1..1"); // Template 4 Template t4 = tdb.GenerateTemplate("urn:oid:1.2.3.4.3", docType, "Test Template", ig2, null, null, null); TemplateConstraint t4_p1 = tdb.GenerateConstraint(t4, null, null, "entryRelationship", "SHALL", "1..1", null, null, null, null, null, null, null, true); TemplateConstraint t4_p2 = tdb.GenerateConstraint(t4, t4_p1, null, "@typeCode", "SHALL", "1..1", null, null, "DRIV"); TemplateConstraint t4_p3 = tdb.GenerateConstraint(t4, t4_p1, null, "observation", "SHALL", "1..1", null, null, "DRIV", null, null, null, null, true); }
/// <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.FindOrAddOrganization("Lantana"); Organization testOrg = mockRepo.FindOrAddOrganization("Test Organization"); ImplementationGuideType igType = mockRepo.FindOrCreateImplementationGuideType("CDA", "CDA.xsd", "cda", "urn:hl7-org:v3"); 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.FindOrAddImplementationGuide(igType, "Test Implementation Guide", internalOrg); mockRepo.FindOrAddImplementationGuide(igType, "Test IG 2", testOrg); mockRepo.FindOrAddImplementationGuide(igType, "Test IG 3", internalOrg); Template template1 = mockRepo.GenerateTemplate("1.2.3.4.5", docType, "Test Template 1", ig, null, null, "Test Description 2", "Test Note 1"); template1.Notes = "This is a test note"; // Basic constraint, nothing special TemplateConstraint t1tc1 = mockRepo.GenerateConstraint(template1, null, null, "templateId", "SHALL", "1..1"); t1tc1.Notes = "This is a test constraint comment"; // Constraint with a child TemplateConstraint t1tc2 = mockRepo.GenerateConstraint(template1, null, null, "code", "SHALL", "1..1"); TemplateConstraint t1tc2_2 = mockRepo.GenerateConstraint(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.GenerateConstraint(template1, null, null, "code", "SHALL", "1..1"); TemplateConstraint t1tc3_1 = mockRepo.GenerateConstraint(template1, t1tc3, null, "@code", "SHALL", "1..1", "CE", "SHALL", null, null, t1tc3_vs); t1tc3_1.IsStatic = true; Template template2 = mockRepo.GenerateTemplate("1.2.3.4.5.6", docType, "Test Template 2", ig, null, null, "Test Description 1", "Test Note 2"); template2.ImpliedTemplate = template1; // Constraint with a child TemplateConstraint t2tc1 = mockRepo.GenerateConstraint(template2, null, null, "code", "SHALL", "1..1"); Template template3 = mockRepo.GenerateTemplate("1.2.3.4.5.6.7", docType, "Test Template 3", ig, null, null, "Test Description 3", "Test Note 3"); TemplateConstraint t3tc1 = mockRepo.GenerateConstraint(template3, null, template2, null, "SHALL", "1..1"); TemplateConstraint t3tc2 = mockRepo.GenerateConstraint(template3, null, null, "entry", "SHALL", "1..1"); TemplateConstraint t3tc2_1 = mockRepo.GenerateConstraint(template3, t3tc2, template2, "observation", "SHALL", "1..1"); Template template4 = mockRepo.GenerateTemplate("8.2234.19.234.11", docType, "Test Constraint Description Template", ig, null, null, null, null); mockRepo.GenerateConstraint(template4, null, null, "code", "SHALL", "1..1", "CD", null, null, null, null, null, "Test constraint description"); return(mockRepo); }
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); }
/// <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); }