public void MyTestInitialize() { this.cdaSchema = SimpleSchema.CreateSimpleSchema(Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = Constants.IGTypeNames.CDA, SchemaLocation = Constants.IGTypeSchemaLocations.CDA })); this.eMeasureSchema = SimpleSchema.CreateSimpleSchema(Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = Constants.IGTypeNames.EMEASURE, SchemaLocation = "schemas/EMeasure.xsd" })); this.hqmfSchema = SimpleSchema.CreateSimpleSchema(Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = Constants.IGTypeNames.HQMF, SchemaLocation = "schemas/EMeasure.xsd" })); Assert.IsNotNull(this.eMeasureSchema); Assert.IsNotNull(this.cdaSchema); Assert.IsNotNull(this.hqmfSchema); }
public void MyTestInitialize() { this.cdaSchema = SimpleSchema.CreateSimpleSchema(Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = "CDA", SchemaLocation = "CDA.xsd" })); this.eMeasureSchema = SimpleSchema.CreateSimpleSchema(Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = "eMeasure", SchemaLocation = "schemas/EMeasure.xsd" })); this.fhirSchema = SimpleSchema.CreateSimpleSchema(Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = MockObjectRepository.DEFAULT_FHIR_DSTU1_IG_TYPE_NAME, SchemaLocation = "fhir-all.xsd" })); Assert.IsNotNull(this.eMeasureSchema); Assert.IsNotNull(this.cdaSchema); Assert.IsNotNull(this.fhirSchema); }
public void TestSimplifiedSchema_eMeasure() { SimpleSchema cdaSchema = SimpleSchema.CreateSimpleSchema( Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = "CDA", SchemaLocation = "CDA.xsd" })); cdaSchema = cdaSchema.GetSchemaFromContext("Observation"); var foundClassCodeAttr = cdaSchema.Children.SingleOrDefault(y => y.Name == "classCode" && y.IsAttribute); Assert.IsNotNull(foundClassCodeAttr); var foundCode = cdaSchema.Children.SingleOrDefault(y => y.Name == "code" && !y.IsAttribute); Assert.IsNotNull(foundCode); var foundValue = cdaSchema.Children.SingleOrDefault(y => y.Name == "value" && !y.IsAttribute); Assert.IsNotNull(foundValue); var foundEntryRelationship = cdaSchema.Children.SingleOrDefault(y => y.Name == "entryRelationship" && !y.IsAttribute); Assert.IsNotNull(foundEntryRelationship); var foundObservation = foundEntryRelationship.Children.SingleOrDefault(y => y.Name == "observation" && !y.IsAttribute); Assert.IsNotNull(foundObservation); Assert.IsNotNull(cdaSchema); }
public GreenTransformGenerator(IObjectRepository tdb, Dictionary <int, int> greenTemplates, long templateId) : this(tdb) { this.rootTemplate = tdb.Templates.Single(y => y.Id == templateId); this.greenTemplates = greenTemplates; this.schemaNamespace = this.rootTemplate.ImplementationGuideType.SchemaURI; this.simpleSchema = SimpleSchema.CreateSimpleSchema( Helper.GetIGSimplifiedSchemaLocation(this.rootTemplate.ImplementationGuideType)); TransformHelper.InitializeTransform(this.transformDoc, this.schemaNamespace); }
public static SimpleSchema GetSimplifiedSchema(HttpApplicationState application, ImplementationGuideType igType) { if (application != null && application[igType.Name] != null) { return((SimpleSchema)application[igType.Name]); } SimpleSchema newSimplifiedSchema = SimpleSchema.CreateSimpleSchema(Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation(igType)); if (application != null) { application.Add(igType.Name, newSimplifiedSchema); } return(newSimplifiedSchema); }
public void DSTU2_TestConvertExtension() { StructureDefinitionExporter exporter = new StructureDefinitionExporter(StructureDefinitionControllerTest.mockRepo1, "http", "test.com"); SimpleSchema schema = SimpleSchema.CreateSimpleSchema( Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = Constants.IGTypeNames.FHIR_DSTU2, SchemaLocation = "fhir-all.xsd" })); StructureDefinition strucDef = exporter.Convert(StructureDefinitionControllerTest.profile1, 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"); }
public void TestSimplifiedSchema_eMeasure() { SimpleSchema cdaSchema = SimpleSchema.CreateSimpleSchema( Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = Constants.IGTypeNames.CDA, SchemaLocation = Constants.IGTypeSchemaLocations.CDA })); cdaSchema = cdaSchema.GetSchemaFromContext("Observation"); var foundClassCodeAttr = cdaSchema.Children.SingleOrDefault(y => y.Name == "classCode" && y.IsAttribute); Assert.IsNotNull(foundClassCodeAttr); var foundCode = cdaSchema.Children.SingleOrDefault(y => y.Name == "code" && !y.IsAttribute); Assert.IsNotNull(foundCode); var foundValue = cdaSchema.Children.SingleOrDefault(y => y.Name == "value" && !y.IsAttribute); Assert.IsNotNull(foundValue); var foundEntryRelationship = cdaSchema.Children.SingleOrDefault(y => y.Name == "entryRelationship" && !y.IsAttribute); Assert.IsNotNull(foundEntryRelationship); /* TODO: Schema Choice support temporarily removed from non-FHIR schemas * var foundChoice = foundEntryRelationship.Children.SingleOrDefault(y => y.Name == "choice" && !y.IsAttribute); * Assert.IsNotNull(foundChoice); * * var foundObservation = foundChoice.Children.SingleOrDefault(y => y.Name == "observation" && !y.IsAttribute); * Assert.IsNotNull(foundObservation); */ var foundObservation = foundEntryRelationship.Children.SingleOrDefault(y => y.Name == "observation" && !y.IsAttribute); Assert.IsNotNull(foundObservation); Assert.IsNotNull(cdaSchema); }
private DefaultSampleGenerator(IObjectRepository tdb, Template template) { this.tdb = tdb; this.template = template; this.simpleSchema = SimpleSchema.CreateSimpleSchema( Helper.GetIGSimplifiedSchemaLocation(template.ImplementationGuideType)); if (string.IsNullOrEmpty(this.template.PrimaryContextType)) { this.simpleSchema = this.simpleSchema.GetSchemaFromContext(template.TemplateType.RootContextType); } else { this.simpleSchema = this.simpleSchema.GetSchemaFromContext(template.PrimaryContextType); } this.igType = template.ImplementationGuideType; this.igTypePlugin = this.igType.GetPlugin(); }
public static void SetupData(TestContext context) { STU3Tests.tdb = new MockObjectRepository(); STU3Tests.tdb.InitializeFHIR3Repository(); var fhirIgType = STU3Tests.tdb.FindImplementationGuideType(Constants.IGTypeNames.FHIR_STU3); STU3Tests.fhirIg = STU3Tests.tdb.FindOrCreateImplementationGuide(fhirIgType, "Test IG"); string schemaLocation = Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation(fhirIgType); schema = SimpleSchema.CreateSimpleSchema(schemaLocation); var templateType = tdb.FindTemplateType(Constants.IGTypeNames.FHIR_STU3, RESOURCE_TYPE_OBS); STU3Tests.template1 = STU3Tests.tdb.CreateTemplate("http://test.com/StructureDefinition/1", templateType, "Test Observation", fhirIg, RESOURCE_TYPE_OBS, RESOURCE_TYPE_OBS, DESCRIPTION); var c1_1 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template1, null, null, "extension"); var c1_2 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template1, c1_1, null, "value[x]", isChoice: true); var c1_3 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template1, c1_2, null, "valueCodeableConcept", value: "1234-x", displayName: "test single-value binding"); STU3Tests.template2 = STU3Tests.tdb.CreateTemplate("http://test.com/StructureDefinition/2", templateType, "Test Observation", fhirIg, RESOURCE_TYPE_OBS, RESOURCE_TYPE_OBS, DESCRIPTION); var c2_1 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template2, null, null, "extension"); var c2_2 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template2, c2_1, null, "value[x]", isChoice: true, cardinality: "1..1"); var c2_3 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template2, c2_2, null, "valueCodeableConcept", value: "1234-x", displayName: "test single-value binding"); var c2_4 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template2, c2_2, null, "valuePeriod"); var c2_5 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template2, c2_4, null, "start", cardinality: "1..1"); STU3Tests.template3 = STU3Tests.tdb.CreateTemplate("http://test.com/StructureDefinition/3", templateType, "Test Observation", fhirIg, RESOURCE_TYPE_OBS, RESOURCE_TYPE_OBS, DESCRIPTION); var c3_1 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template3, null, null, "comment", cardinality: "1..1", value: "Test"); STU3Tests.template4 = STU3Tests.tdb.CreateTemplate("http://test.com/StructureDefinition/4", templateType, "Test Observation", fhirIg, RESOURCE_TYPE_OBS, RESOURCE_TYPE_OBS, DESCRIPTION); var c4_1 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template4, null, null, "referenceRange", cardinality: "1..1", isBranch: true); var c4_2 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template4, c4_1, null, "low", cardinality: "1..1"); var c4_3 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template4, c4_1, null, "appliesTo", cardinality: "1..1", value: "at1", displayName: "appliesTo1", isBranchIdentifier: true); var c4_4 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template4, null, null, "referenceRange", cardinality: "1..1", isBranch: true); var c4_5 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template4, c4_4, null, "high", cardinality: "1..1"); var c4_6 = STU3Tests.tdb.AddConstraintToTemplate(STU3Tests.template4, c4_4, null, "appliesTo", cardinality: "1..1", value: "at2", displayName: "appliesTo2", isBranchIdentifier: true); }
public void TestConvertExtension() { MockObjectRepository mockRepo = new MockObjectRepository(); mockRepo.InitializeFHIR3Repository(); mockRepo.InitializeLCG(); var ig = mockRepo.FindOrAddImplementationGuide(MockObjectRepository.DEFAULT_FHIR_STU3_IG_TYPE_NAME, "Test IG"); var template = mockRepo.GenerateTemplate("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 = MockObjectRepository.DEFAULT_FHIR_STU3_IG_TYPE_NAME, 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"); }
public void TestSimplifiedSchema_CDA() { SimpleSchema cdaSchema = SimpleSchema.CreateSimpleSchema( Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation( new ImplementationGuideType() { Name = Constants.IGTypeNames.CDA, SchemaLocation = Constants.IGTypeSchemaLocations.CDA })); Assert.IsNotNull(cdaSchema.ComplexTypes); Assert.AreEqual(232, cdaSchema.ComplexTypes.Count); // This number may change if the schema changes Assert.IsNotNull(cdaSchema.Children); Assert.AreEqual(1, cdaSchema.Children.Count); // Test root document level SimpleSchema.SchemaObject clinicalDocument = cdaSchema.Children.SingleOrDefault(y => y.Name == "ClinicalDocument"); Assert.IsNotNull(clinicalDocument); Assert.AreEqual("ClinicalDocument", clinicalDocument.DataType); Assert.AreEqual(false, clinicalDocument.Mixed); Assert.AreEqual(31, clinicalDocument.Children.Count); var clinicalDocumentInvalidChildNames = clinicalDocument.Children.Where(y => string.IsNullOrEmpty(y.Name) || y.Name.Length <= 1); Assert.IsTrue(clinicalDocumentInvalidChildNames.Count() == 0); Assert.AreEqual(SimpleSchema.ObjectTypes.Element, clinicalDocument.Type); // Test datatype SimpleSchema.SchemaObject typeId = clinicalDocument.Children.SingleOrDefault(y => y.Name == "typeId"); Assert.IsNotNull(typeId); Assert.AreEqual("typeId[typeId]", typeId.ToString()); Assert.AreEqual("typeId", typeId.DataType); Assert.AreEqual("1..1", typeId.Cardinality); Assert.AreEqual("SHALL", typeId.Conformance); Assert.AreEqual(false, typeId.Mixed); Assert.AreEqual(5, typeId.Children.Count); var typeIdInvalidNames = typeId.Children.Where(y => string.IsNullOrEmpty(y.Name) || y.Name.Length <= 1); Assert.IsTrue(typeIdInvalidNames.Count() == 0); Assert.AreEqual(SimpleSchema.ObjectTypes.Element, typeId.Type); // Test attribute SimpleSchema.SchemaObject typeIdRoot = typeId.Children.SingleOrDefault(y => y.Name == "root"); Assert.IsNotNull(typeId); Assert.AreEqual("uid", typeIdRoot.DataType); Assert.AreEqual("1..1", typeIdRoot.Cardinality); Assert.AreEqual("SHALL", typeIdRoot.Conformance); Assert.AreEqual(false, typeIdRoot.Mixed); Assert.AreEqual(0, typeIdRoot.Children.Count); Assert.AreEqual(SimpleSchema.ObjectTypes.Attribute, typeIdRoot.Type); // Test many cardinality SimpleSchema.SchemaObject recordTarget = clinicalDocument.Children.SingleOrDefault(y => y.Name == "recordTarget"); Assert.IsNotNull(recordTarget); Assert.AreEqual("RecordTarget", recordTarget.DataType); Assert.AreEqual("1..*", recordTarget.Cardinality); Assert.AreEqual("SHALL", recordTarget.Conformance); Assert.AreEqual(false, recordTarget.Mixed); Assert.AreEqual(7, recordTarget.Children.Count); var recordTargetInvalidNames = recordTarget.Children.Where(y => string.IsNullOrEmpty(y.Name) || y.Name.Length <= 1); Assert.IsTrue(recordTargetInvalidNames.Count() == 0); Assert.AreEqual(SimpleSchema.ObjectTypes.Element, recordTarget.Type); // Test patientRole SimpleSchema.SchemaObject patientRole = recordTarget.Children.SingleOrDefault(y => y.Name == "patientRole"); Assert.IsNotNull(patientRole); Assert.AreEqual("PatientRole", patientRole.DataType); Assert.AreEqual("1..1", patientRole.Cardinality); Assert.AreEqual("SHALL", patientRole.Conformance); Assert.AreEqual(false, patientRole.Mixed); Assert.AreEqual(10, patientRole.Children.Count); Assert.AreEqual(SimpleSchema.ObjectTypes.Element, patientRole.Type); // Test conformance SimpleSchema.SchemaObject patient = patientRole.Children.SingleOrDefault(y => y.Name == "patient"); Assert.IsNotNull(patient); Assert.AreEqual("Patient", patient.DataType); Assert.AreEqual("0..1", patient.Cardinality); Assert.AreEqual("MAY", patient.Conformance); Assert.AreEqual(false, patient.Mixed); Assert.AreEqual(24, patient.Children.Count); Assert.IsNotNull(patient.Children.SingleOrDefault(y => y.Name == "sdtc:raceCode")); var patientInvalidNames = patient.Children.Where(y => string.IsNullOrEmpty(y.Name) || y.Name.Length <= 1); Assert.IsTrue(patientInvalidNames.Count() == 0); Assert.AreEqual(SimpleSchema.ObjectTypes.Element, patientRole.Type); SimpleSchema.SchemaObject sdtcRaceCode = patient.Children.Single(y => y.Name == "sdtc:raceCode"); var sdtcRaceCodeInvalidNames = sdtcRaceCode.Children.Where(y => string.IsNullOrEmpty(y.Name) || y.Name.Length <= 1); Assert.IsTrue(sdtcRaceCodeInvalidNames.Count() == 0); // Test mixed SimpleSchema.SchemaObject patientName = patient.Children.SingleOrDefault(y => y.Name == "name"); Assert.IsNotNull(patientName); Assert.AreEqual("PN", patientName.DataType); Assert.AreEqual("0..*", patientName.Cardinality); Assert.AreEqual("MAY", patientName.Conformance); Assert.AreEqual(true, patientName.Mixed); Assert.AreEqual(8, patientName.Children.Count, "Expected patient to have 8 children"); // TODO: Schema Choice support temporarily removed from non-FHIR schemas Assert.IsTrue(patientName.Children.Count(y => string.IsNullOrEmpty(y.Name) || y.Name.Length <= 1) == 0); Assert.AreEqual(SimpleSchema.ObjectTypes.Element, patientRole.Type); }