public void ExportTemplatesModelTest2() { MockObjectRepository tdb = new MockObjectRepository(); tdb.InitializeCDARepository(); Organization org = tdb.FindOrAddOrganization("LCG Test"); ImplementationGuide ig = tdb.FindOrAddImplementationGuide(tdb.FindImplementationGuideType(MockObjectRepository.DEFAULT_CDA_IG_TYPE_NAME), "Test Implementation Guide"); IGSettingsManager igSettings = new IGSettingsManager(tdb, ig.Id); Template template = tdb.GenerateTemplate("1.2.3.4", "Document", "Test Template", ig, "observation", "Observation", "Test Description", "Test Notes"); ExportTemplate export = template.Export(tdb, igSettings); Assert.IsNotNull(export); Assert.AreEqual(template.Oid, export.identifier); Assert.AreEqual(template.Name, export.title); Assert.AreEqual(template.TemplateType.Name, export.templateType); Assert.AreEqual(template.PrimaryContext, export.context); Assert.AreEqual(template.PrimaryContextType, export.contextType); Assert.AreEqual(template.Description, export.Description); Assert.AreEqual(template.Notes, export.Notes); Assert.IsNull(export.organizationName); Assert.AreEqual(template.OwningImplementationGuide.Name, export.ImplementationGuide.name); }
public FileResult DownloadAll(int implementationGuideId) { if (!CheckPoint.Instance.GrantViewImplementationGuide(implementationGuideId)) { throw new AuthorizationException("You do not have access to view this implementation guide's files."); } ImplementationGuide ig = this.tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); string fileName = string.Format("{0}_{1}.zip", ig.NameWithVersion, DateTime.Now.ToString("yyyyMMdd")); using (ZipFile zip = new ZipFile()) { foreach (var file in ig.Files) { var latestVersionDate = file.Versions.Max(y => y.UpdatedDate); var latestVersion = file.Versions.Single(y => y.UpdatedDate == latestVersionDate); zip.AddEntry(file.FileName, latestVersion.Data); } using (MemoryStream ms = new MemoryStream()) { zip.Save(ms); return(File(ms.ToArray(), "application/x-gzip", fileName)); } } }
public JsonResult All(int implementationGuideId) { if (!CheckPoint.Instance.GrantEditImplementationGuide(implementationGuideId)) { throw new AuthorizationException("You do not have access to view this implementation guide's files."); } ImplementationGuide ig = this.tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); List <FileModel> files = new List <FileModel>(); foreach (var file in ig.Files) { var latestVersionDate = file.Versions.Max(y => y.UpdatedDate); var latestVersion = file.Versions.Single(y => y.UpdatedDate == latestVersionDate); FileModel newFileModel = new FileModel() { FileId = file.Id, VersionId = latestVersion.Id, Type = (FileModel.Types)Enum.Parse(typeof(FileModel.Types), file.ContentType, true), Name = file.FileName, Date = latestVersionDate.ToString("MM/dd/yyyy HH:mm:ss"), Note = latestVersion.Note, MimeType = file.MimeType, Description = file.Description, Url = file.Url }; files.Add(newFileModel); } return(Json(new { Files = files })); }
public IEnumerable <SchemaNode> GetSchemaNodes(int implementationGuideId, string parentType = null, bool includeAttributes = true) { if (!CheckPoint.Instance.GrantViewImplementationGuide(implementationGuideId)) { throw new AuthorizationException("You do not have permission to view this implementation guide"); } ImplementationGuide ig = this.tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); SimpleSchema schema = SimplifiedSchemaContext.GetSimplifiedSchema(HttpContext.Current.Application, ig.ImplementationGuideType); List <SimpleSchema.SchemaObject> children; if (!string.IsNullOrEmpty(parentType)) { schema = schema.GetSchemaFromContext(parentType); children = schema.Children; } else { children = schema.Children[0].Children; } var ret = (from s in children where includeAttributes || !s.IsAttribute select new SchemaNode() { Context = s.IsAttribute ? "@" + s.Name : s.Name, Conformance = s.Conformance, Cardinality = s.Cardinality, DataType = s.DataType, HasChildren = s.Children.Where(y => includeAttributes || !y.IsAttribute).Count() > 0 }); return(ret); }
public void Setup() { this.tdb.InitializeCDARepository(); this.ig = this.tdb.FindOrAddImplementationGuide(this.tdb.FindImplementationGuideType("CDA"), "Test IG"); this.mainSchema = this.tdb.FindImplementationGuideType("CDA").GetSimpleSchema(); }
public void Setup() { this.tdb.InitializeCDARepository(); this.ig = this.tdb.FindOrCreateImplementationGuide(this.tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA), "Test IG"); this.mainSchema = this.tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA).GetSimpleSchema(); }
private void UpdateVolume1(ImplementationGuide implementationGuide, IGSettingsManager igSettings, ImportImplementationGuide importImplementationGuide) { if (importImplementationGuide.Volume1 == null) { igSettings.SaveSetting(IGSettingsManager.SettingProperty.Volume1Html, string.Empty); this.RemoveVolume1Sections(implementationGuide); return; } if (importImplementationGuide.Volume1.Items.Count == 1 && importImplementationGuide.Volume1.Items.First() is string) { this.RemoveVolume1Sections(implementationGuide); igSettings.SaveSetting(IGSettingsManager.SettingProperty.Volume1Html, importImplementationGuide.Volume1.Items.First() as string); } else if (importImplementationGuide.Volume1.Items.Count > 0) { igSettings.SaveSetting(IGSettingsManager.SettingProperty.Volume1Html, string.Empty); foreach (ImportImplementationGuideSection importSection in importImplementationGuide.Volume1.Items) { if (importSection.Heading == null) { throw new ArgumentException("All implementation guide sections must have a heading"); } ImplementationGuideSection newSection = new ImplementationGuideSection() { Heading = importSection.Heading.Title, Level = importSection.Heading.Level, Order = implementationGuide.Sections.Count + 1 }; implementationGuide.Sections.Add(newSection); } } }
public void GetValueSetsTest_NoPublishDate() { ImplementationGuide ig = this.tdb.FindOrCreateImplementationGuide(this.tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA), "Test IG"); Template t1 = this.tdb.CreateTemplate("1.2.3.4", "Document", "Test Document Template", ig); this.tdb.AddConstraintToTemplate(t1, null, null, "code", "SHALL", "1..1", valueSet: this.vs1); Template t2 = this.tdb.CreateTemplate("1.2.3.4", "Document", "Test Document Template", ig); var tc2 = this.tdb.AddConstraintToTemplate(t2, null, null, "code", "SHALL", "1..1", valueSet: this.vs2); tc2.ValueSetDate = new DateTime(2012, 1, 12); DateTime dateNow = DateTime.Now; var valueSets = ig.GetValueSets(this.tdb, true); Assert.IsNotNull(valueSets); Assert.AreEqual(2, valueSets.Count); // Cannot get an exact match on DateTime.Now used by GetValueSets(), so using a 1 second range var valueSet1 = valueSets[0]; bool dateMatches = valueSet1.BindingDate > DateTime.Now.AddSeconds(-1) && valueSet1.BindingDate < DateTime.Now.AddSeconds(1); Assert.AreEqual(this.vs1, valueSet1.ValueSet); Assert.IsTrue(dateMatches); var valueSet2 = valueSets[1]; Assert.AreEqual(this.vs2, valueSet2.ValueSet); Assert.AreEqual(new DateTime(2012, 1, 12), valueSet2.BindingDate); }
protected VocabularySystems GetSystems(int implementationGuideId, int maxValueSetMembers, bool?onlyStatic = null) { try { ImplementationGuide ig = tdb.ImplementationGuides.SingleOrDefault(y => y.Id == implementationGuideId); if (ig == null) { throw new Exception("Could not find ImplementationGuide specified."); } IIGTypePlugin igTypePlugin = ig.ImplementationGuideType.GetPlugin(); List <ImplementationGuideValueSet> valueSets = ig.GetValueSets(tdb, onlyStatic); List <VocabularySystem> systems = new List <VocabularySystem>(); bool isCDA = ig.ImplementationGuideType.SchemaURI == "urn:hl7-org:v3"; foreach (ImplementationGuideValueSet cValueSet in valueSets) { VocabularySystem newSystem = this.GetSystem(igTypePlugin, tdb, cValueSet.ValueSet, cValueSet.BindingDate, isCDA); systems.Add(newSystem); } VocabularySystems schema = new VocabularySystems(); schema.Systems = systems.ToArray(); return(schema); } catch (Exception ex) { Log.For(this).Critical("Error occurred while retrieving vocabulary for an implementation guide.", ex); throw; } }
private XmlDocument CreateDocument(ExportSettings settings, string name, out XmlNamespaceManager nsManager) { var mockRepo = TestDataGenerator.GenerateMockDataset4(); IEnumerable <int> templateIds = (from t in mockRepo.Templates select t.Id); ImplementationGuide ig = mockRepo.ImplementationGuides.Single(y => y.Name == TestDataGenerator.DS1_IG_NAME); IIGTypePlugin igTypePlugin = ig.ImplementationGuideType.GetPlugin(); ImplementationGuideGenerator generator = new ImplementationGuideGenerator(mockRepo, 1, templateIds); generator.BuildImplementationGuide(settings, igTypePlugin); var docBytes = generator.GetDocument(); var docContents = GetWordDocumentContents(docBytes); XmlDocument doc = ReadWordDocXml(docContents, out nsManager); File.WriteAllText(Path.Combine(this.TestContext.TestDir, name + ".xml"), docContents); string outputLocation = Path.Combine(this.TestContext.TestDir, name + ".docx"); File.WriteAllBytes(outputLocation, docBytes); Console.WriteLine("Saved output to " + outputLocation); return(doc); }
public void GetValueSetsTest_Static() { ImplementationGuide ig = this.tdb.FindOrCreateImplementationGuide(this.tdb.FindImplementationGuideType(Constants.IGTypeNames.CDA), "Test IG"); Template t1 = this.tdb.CreateTemplate("1.2.3.4", "Document", "Test Document Template", ig); var tc1 = this.tdb.AddConstraintToTemplate(t1, null, null, "code", "SHALL", "1..1", valueSet: this.vs1); tc1.IsStatic = false; Template t2 = this.tdb.CreateTemplate("1.2.3.4", "Document", "Test Document Template", ig); var tc2 = this.tdb.AddConstraintToTemplate(t2, null, null, "code", "SHALL", "1..1", valueSet: this.vs2); tc2.ValueSetDate = new DateTime(2012, 1, 12); tc2.IsStatic = true; var tc3 = this.tdb.AddConstraintToTemplate(t2, null, null, "value", "SHALL", "1..1", valueSet: this.vs3); DateTime dateNow = DateTime.Now; var valueSets = ig.GetValueSets(this.tdb, true); Assert.IsNotNull(valueSets); Assert.AreEqual(2, valueSets.Count); var valueSet1 = valueSets[0]; Assert.AreEqual(this.vs2, valueSet1.ValueSet); Assert.AreEqual(new DateTime(2012, 1, 12), valueSet1.BindingDate); var valueSet2 = valueSets[1]; Assert.AreEqual(this.vs3, valueSet2.ValueSet); }
private void UpdateTemplateTypes(ImplementationGuide implementationGuide, ImportImplementationGuide importImplementationGuide) { foreach (var importTemplateType in importImplementationGuide.CustomTemplateType) { var foundTemplateType = implementationGuide.ImplementationGuideType.TemplateTypes.SingleOrDefault(y => y.Name.ToLower() == importTemplateType.templateTypeName.ToLower()); if (foundTemplateType == null) { throw new Exception("Could not find template type " + importTemplateType.templateTypeName + " associated with implementation guide type"); } var foundIgTemplateType = implementationGuide.TemplateTypes.SingleOrDefault(y => y.TemplateTypeId == foundTemplateType.Id); if (foundIgTemplateType == null) { foundIgTemplateType = new ImplementationGuideTemplateType(); foundIgTemplateType.TemplateType = foundTemplateType; foundIgTemplateType.TemplateTypeId = foundTemplateType.Id; foundIgTemplateType.ImplementationGuide = implementationGuide; implementationGuide.TemplateTypes.Add(foundIgTemplateType); } if (foundIgTemplateType.Name != importTemplateType.CustomName) { foundIgTemplateType.Name = importTemplateType.CustomName; } if (foundIgTemplateType.DetailsText != importTemplateType.Description) { foundIgTemplateType.DetailsText = importTemplateType.Description; } } }
protected override void ProcessRecord() { if (!string.IsNullOrEmpty(this.RootDirectory)) { var igDirectories = Directory.GetDirectories(this.RootDirectory); foreach (var igDirectory in igDirectories) { FileInfo igDirectoryInfo = new FileInfo(igDirectory); int implementationGuideId = Int32.Parse(igDirectoryInfo.Name); ImplementationGuide ig = this.tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); var sectionFiles = Directory.GetFiles(igDirectory, "*.txt"); foreach (var sectionFile in sectionFiles) { FileInfo sectionFileInfo = new FileInfo(sectionFile); string sectionName = sectionFileInfo.Name.Substring(0, sectionFileInfo.Name.Length - sectionFileInfo.Extension.Length); ImplementationGuideSection section = ig.Sections.Single(y => y.Heading.Trim().ToLower() == sectionName.Trim().ToLower()); section.Content = File.ReadAllText(sectionFile); this.WriteVerbose("Updating implementation guide " + ig.Id + " section " + section.Id + " (" + section.Heading + ")"); } } this.tdb.SaveChanges(); } }
public void ExportTemplatesModelTest1() { MockObjectRepository tdb = new MockObjectRepository(); tdb.InitializeCDARepository(); Organization org = tdb.FindOrAddOrganization("LCG Test"); ImplementationGuide ig = tdb.FindOrAddImplementationGuide(tdb.FindImplementationGuideType(MockObjectRepository.DEFAULT_CDA_IG_TYPE_NAME), "Test Implementation Guide"); IGSettingsManager igSettings = new IGSettingsManager(tdb, ig.Id); Template template = tdb.GenerateTemplate("1.2.3.4", "Document", "Test Template", ig, "observation", "Observation", "Test Description", "Test Notes", org); var tc1 = tdb.GenerateConstraint(template, null, null, "entryRelationship", "SHALL", "1..1"); var tc2 = tdb.GenerateConstraint(template, tc1, null, "observation", "SHOULD", "0..1"); var tc3 = tdb.GenerateConstraint(template, tc2, null, "value", "SHALL", "1..1", "CD", value: "4321", displayName: "Test"); tc3.Description = "Test description"; tc3.Label = "Test Label"; var tc4 = tdb.GeneratePrimitive(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.AreEqual(template.OrganizationName, export.organizationName); // 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)); }
public void GetValueSetsTest_Static() { ImplementationGuide ig = this.tdb.FindOrAddImplementationGuide(this.tdb.FindImplementationGuideType(MockObjectRepository.DEFAULT_CDA_IG_TYPE_NAME), "Test IG"); Template t1 = this.tdb.GenerateTemplate("1.2.3.4", "Document", "Test Document Template", ig); var tc1 = this.tdb.GenerateConstraint(t1, null, null, "code", "SHALL", "1..1", valueSet: this.vs1); tc1.IsStatic = false; Template t2 = this.tdb.GenerateTemplate("1.2.3.4", "Document", "Test Document Template", ig); var tc2 = this.tdb.GenerateConstraint(t2, null, null, "code", "SHALL", "1..1", valueSet: this.vs2); tc2.ValueSetDate = new DateTime(2012, 1, 12); tc2.IsStatic = true; var tc3 = this.tdb.GenerateConstraint(t2, null, null, "value", "SHALL", "1..1", valueSet: this.vs3); DateTime dateNow = DateTime.Now; var valueSets = ig.GetValueSets(this.tdb, true); Assert.IsNotNull(valueSets); Assert.AreEqual(2, valueSets.Count); var valueSet1 = valueSets[0]; Assert.AreEqual(this.vs2, valueSet1.ValueSet); Assert.AreEqual(new DateTime(2012, 1, 12), valueSet1.BindingDate); var valueSet2 = valueSets[1]; Assert.AreEqual(this.vs3, valueSet2.ValueSet); }
public void Setup() { this.tdb.InitializeCDARepository(); var cdaIgType = this.tdb.FindImplementationGuideType(MockObjectRepository.DEFAULT_CDA_IG_TYPE_NAME); var docType = this.tdb.FindTemplateType(MockObjectRepository.DEFAULT_CDA_IG_TYPE_NAME, "Document"); this.ig = this.tdb.FindOrAddImplementationGuide(cdaIgType, "Test IG"); var template = this.tdb.GenerateTemplate("urn:oid:1.2.3.4", docType, "Test Template", ig, "ClinicalDocument", "ClinicalDocument"); this.tdb.GenerateConstraint(template, null, null, "code", "SHALL", "1..1"); this.tdb.GenerateConstraint(template, null, null, "value", "SHOULD", "0..1", category: "CAT1"); this.tdb.GenerateConstraint(template, null, null, "value", "SHALL", "1..1", category: "CAT2"); var b1 = this.tdb.GenerateConstraint(template, null, null, "entryRelationship", "SHALL", "1..1", isBranch: true); this.tdb.GenerateConstraint(template, b1, null, "@typeCode", "SHALL", "1..1", value: "REFR", isBranchIdentifier: true); this.tdb.GenerateConstraint(template, b1, null, "observation", "SHALL", "1..1"); var b2 = this.tdb.GenerateConstraint(template, null, null, "entryRelationship", "SHALL", "1..1", isBranch: true, category: "CAT1"); this.tdb.GenerateConstraint(template, b2, null, "@typeCode", "SHALL", "1..1", value: "SUBJ", isBranchIdentifier: true); this.tdb.GenerateConstraint(template, b2, null, "observation", "SHALL", "1..1"); var b3 = this.tdb.GenerateConstraint(template, null, null, "entryRelationship", "SHALL", "1..1", isBranch: true, category: "CAT2"); this.tdb.GenerateConstraint(template, b3, null, "@typeCode", "SHALL", "1..1", value: "XXXX", isBranchIdentifier: true); this.tdb.GenerateConstraint(template, b3, null, "observation", "SHALL", "1..1"); // Category 1&2 constraint this.tdb.GenerateConstraint(template, null, null, "effectiveTime", "SHALL", "1..1", category: "CAT1,CAT2"); }
public void GetValueSetsTest_PublishDate() { ImplementationGuide ig = this.tdb.FindOrAddImplementationGuide(this.tdb.FindImplementationGuideType(MockObjectRepository.DEFAULT_CDA_IG_TYPE_NAME), "Test IG"); ig.PublishDate = new DateTime(2012, 5, 1); Template t1 = this.tdb.GenerateTemplate("1.2.3.4", "Document", "Test Document Template", ig); this.tdb.GenerateConstraint(t1, null, null, "code", "SHALL", "1..1", valueSet: this.vs1); Template t2 = this.tdb.GenerateTemplate("1.2.3.4", "Document", "Test Document Template", ig); var tc2 = this.tdb.GenerateConstraint(t2, null, null, "code", "SHALL", "1..1", valueSet: this.vs2); tc2.ValueSetDate = new DateTime(2012, 1, 12); DateTime dateNow = DateTime.Now; var valueSets = ig.GetValueSets(this.tdb, true); Assert.IsNotNull(valueSets); Assert.AreEqual(2, valueSets.Count); // Cannot get an exact match on DateTime.Now used by GetValueSets(), so using a 1 second range var valueSet1 = valueSets[0]; Assert.AreEqual(this.vs1, valueSet1.ValueSet); Assert.AreEqual(ig.PublishDate, valueSet1.BindingDate); var valueSet2 = valueSets[1]; Assert.AreEqual(this.vs2, valueSet2.ValueSet); Assert.AreEqual(new DateTime(2012, 1, 12), valueSet2.BindingDate); }
private ValidationDocument GetGeneratedValidationDocument(IObjectRepository tdb, int implementationGuideId) { ImplementationGuide ig = tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); ImplementationGuideFile vocFile = tdb.ImplementationGuideFiles.FirstOrDefault(y => y.ContentType == ImplementationGuideFile.ContentTypeVocabulary && y.ImplementationGuideId == ig.Id); string vocFilename = "voc.xml"; if (vocFile != null) { vocFilename = vocFile.FileName; } List <Template> templates = ig.GetRecursiveTemplates(tdb); SchematronGenerator schGenerator = new SchematronGenerator(tdb, ig, templates, true, vocFileName: vocFilename); string schContent = schGenerator.Generate(); string schName = Trifolia.Shared.Helper.NormalizeName(ig.Name) + ".sch"; ValidationDocument schDoc = new ValidationDocument() { Content = ASCIIEncoding.UTF8.GetBytes(schContent), ContentType = ImplementationGuideFile.ContentTypeSchematron, MimeType = "text/xml", Name = schName }; return(schDoc); }
private void UpdateCustomSchematron(ImplementationGuide implementationGuide, ImportImplementationGuide importImplementationGuide) { var allCustomSchematrons = implementationGuide.SchematronPatterns.ToList(); // Remove all first foreach (var customSchematron in allCustomSchematrons) { this.tdb.ImplementationGuideSchematronPatterns.DeleteObject(customSchematron); } // Add all in import as new foreach (var importCustomSchematron in importImplementationGuide.CustomSchematron) { var foundSchematronPattern = new ImplementationGuideSchematronPattern(); foundSchematronPattern.PatternId = importCustomSchematron.patternId; implementationGuide.SchematronPatterns.Add(foundSchematronPattern); if (foundSchematronPattern.Phase != importCustomSchematron.phase) { foundSchematronPattern.Phase = importCustomSchematron.phase; } if (foundSchematronPattern.PatternContent != importCustomSchematron.Rule) { foundSchematronPattern.PatternContent = importCustomSchematron.Rule; } } }
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)); }
public List <PublishStatus> GetPublishStatusesForTemplate(int?implementationGuideId) { if (implementationGuideId == null) { return(GetFilteredPublishStatuses(null)); } List <string> excludedStatuses = new List <string>(); using (TemplateDatabaseDataSource tdb = new TemplateDatabaseDataSource()) { ImplementationGuide ig = tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); var excludedStatusObjects = tdb.PublishStatuses.Where(y => y.Id != ig.PublishStatusId && y.Status != PublishStatus.DEPRECATED_STATUS && y.Status != PublishStatus.RETIRED_STATUS); foreach (PublishStatus current in excludedStatusObjects) { excludedStatuses.Add(current.Status); } } return(GetFilteredPublishStatuses(String.Join(",", excludedStatuses))); }
private void PopulateReadme(ZipFile zip, ImplementationGuide ig) { var categories = new Dictionary <string, string> { { "Fonts:", "fonts" }, { "Styles:", "css" }, { "Scripts:", "js" }, { "Images:", "images" } }; var sb = new StringBuilder(); sb.AppendLine(ig.WebReadmeOverview); sb.AppendLine(); sb.AppendLine("Structure of this package:"); sb.AppendLine(); sb.AppendLine("index.html"); foreach (var c in categories) { sb.AppendLine(); sb.AppendLine(c.Key); var fileNames = zip.EntryFileNames.Where(x => x.StartsWith(c.Value)); foreach (var s in fileNames) { sb.AppendLine(s); } } zip.AddEntry("README.txt", sb.ToString()); }
/// <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); }
public string GenerateDocumentLevelTemplateConstraints(ImplementationGuide aImplementationGuide, Phase aErrorPhase) { var firstTemplateType = aImplementationGuide.ImplementationGuideType.TemplateTypes.OrderBy(y => y.OutputOrder).FirstOrDefault(); if (firstTemplateType == null) { return(string.Empty); } var documentLevelTemplates = this.templates.Where(y => y.TemplateTypeId == firstTemplateType.Id); string lDeprecatedStatus = PublishStatuses.Deprecated.ToString(); documentLevelTemplates.ToList().RemoveAll(t => t.Status != null && t.Status.Status == lDeprecatedStatus); List <string> requiredTemplates = new List <string>(); foreach (var template in documentLevelTemplates) { string xpath = GenerateDocumentTemplateIdentifierXpath(template.Oid); requiredTemplates.Add(xpath); } return(string.Join(" or ", requiredTemplates)); }
/// <summary> /// Creates a new instance of SchematronGenerator. /// </summary> /// <param name="rep">The repository (object context) to get the data from.</param> /// <param name="ig">The implementation guide to export schematron for.</param> /// <param name="includeInferred">Indicates whether or not to include inferred templates, in addition to the templates directly owned by the implementation guide</param> public SchematronGenerator(IObjectRepository rep, ImplementationGuide ig, List <Template> templates, bool includeCustom, VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default, string vocFileName = "voc.xml", List <string> categories = null, string defaultSchematron = "not(.)") { this.rep = rep; this.ig = ig; this.templates = templates; this.vocabularyOutputType = vocabularyOutputType; this.includeCustom = includeCustom; this.vocFileName = vocFileName; this.igTypePlugin = ig.ImplementationGuideType.GetPlugin(); this.categories = categories; this.defaultSchematron = defaultSchematron; constraintNumbers = (from t in templates join tc in rep.TemplateConstraints on t.Id equals tc.TemplateId select new { tc.Id, tc.Template.OwningImplementationGuideId, tc.Number.Value }) .ToDictionary(y => y.Id, y => string.Format("{0}-{1}", y.OwningImplementationGuideId, y.Value)); this.schemaPrefix = ig.ImplementationGuideType.SchemaPrefix; if (!this.schemaPrefix.EndsWith(":")) { this.schemaPrefix += ":"; } }
public ImplementationGuideGenerator(IObjectRepository tdb, int implementationGuideId, IEnumerable <int> templateIds) { this._tdb = tdb; this.implementationGuide = tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); this.schema = this.implementationGuide.ImplementationGuideType.GetSimpleSchema(); this.igSettings = new IGSettingsManager(this._tdb, implementationGuideId); this.templates = (from tid in templateIds join t in tdb.Templates on tid equals t.Id select t).Distinct().ToList(); this.templateRelationships = (from tr in this._tdb.ViewTemplateRelationships join tid in templateIds on tr.ParentTemplateId equals tid where templateIds.Contains(tr.ChildTemplateId) select tr) .Union(from tr in this._tdb.ViewTemplateRelationships join tid in templateIds on tr.ChildTemplateId equals tid where templateIds.Contains(tr.ParentTemplateId) select tr) .ToList(); this.constraintReferences = (from t in this.templates join tc in this._tdb.TemplateConstraints on t.Id equals tc.TemplateId join tcr in this._tdb.TemplateConstraintReferences on tc.Id equals tcr.TemplateConstraintId join rt in this._tdb.Templates on tcr.ReferenceIdentifier equals rt.Oid select new ConstraintReference() { TemplateConstraintId = tc.Id, Name = rt.Name, Identifier = rt.Oid, Bookmark = rt.Bookmark, IncludedInIG = this.templates.Contains(rt) }).ToList(); this.retiredStatus = PublishStatus.GetRetiredStatus(this._tdb); }
public TemplateSchematronGenerator(IObjectRepository tdb, long implementationGuideId) { this.tdb = tdb; this.implementationGuide = tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); this.Initialize(); }
public static string GetViewUrl(this ImplementationGuide implementationGuide, bool absoluteUrl = false) { var request = System.Web.HttpContext.Current.Request; string baseAddress = absoluteUrl ? string.Format("{0}://{1}", request.Url.Scheme, request.Url.Authority) : string.Empty; return(string.Format("{0}/IGManagement/View/{1}", baseAddress, implementationGuide.Id)); }
public void Setup() { this.tdb = new MockObjectRepository(); this.tdb.InitializeFHIRRepository(); this.tdb.InitializeLCGAndLogin(); this.ig = this.tdb.FindOrAddImplementationGuide(MockObjectRepository.DEFAULT_FHIR_DSTU1_IG_TYPE_NAME, "Test IG"); }
public void Setup() { this.mockRepo = new MockObjectRepository(); cdaType = this.mockRepo.FindOrCreateImplementationGuideType(MockObjectRepository.DEFAULT_CDA_IG_TYPE_NAME, string.Empty, string.Empty, string.Empty); documentType = this.mockRepo.FindOrCreateTemplateType(cdaType, "Document Templates", "ClinicalDocument", "ClinicalDocument", 1); ig = this.mockRepo.FindOrAddImplementationGuide(cdaType, "Test"); }