public ConstraintParser(IObjectRepository tdb, IConstraint constraint, ImplementationGuideType igType, SimpleSchema igTypeSchema, IEnumerable <Template> allTemplates, string valueSetFile = "voc.xml", VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default) { this.tdb = tdb; this.constraint = constraint; this.valueSetFile = valueSetFile; this.igType = igType; this.igTypeSchema = igTypeSchema; this.allTemplates = allTemplates; this.igTypePlugin = igType.GetPlugin(); if (!string.IsNullOrEmpty(this.constraint.Cardinality)) { this.constraintCardinalityType = CardinalityParser.Parse(this.constraint.Cardinality); } if (!string.IsNullOrEmpty(this.constraint.Conformance)) { this.constraintConformanceType = ConformanceParser.Parse(this.constraint.Conformance); } this.prefix = igType.SchemaPrefix; this.vocabularyOutputType = vocabularyOutputType; }
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); }
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; } }
/// <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 PublishModel MapEntityToViewModel(DB.Template aTemplate) { PublishModel lModel = new PublishModel(); lModel.TemplateId = aTemplate.Id; lModel.TemplateName = aTemplate.Name; lModel.TemplateOid = aTemplate.Oid; foreach (DB.TemplateSample lSample in aTemplate.TemplateSamples) { XmlSample lViewSample = new XmlSample() { Id = lSample.Id, Name = lSample.Name, SampleText = lSample.XmlSample, TemplateId = aTemplate.Id }; lModel.XmlSamples.Add(lViewSample); } IGSettingsManager igManager = new IGSettingsManager(_tdb, aTemplate.OwningImplementationGuideId); IIGTypePlugin igTypePlugin = aTemplate.OwningImplementationGuide.ImplementationGuideType.GetPlugin(); string baseLink = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path) + "?Id="; int constraintCount = 0; foreach (DB.TemplateConstraint cDbConstraint in aTemplate.ChildConstraints.Where(y => y.Parent == null).OrderBy(y => y.Order)) { PublishConstraint lConstraintView = this.BuildConstraint(_tdb, baseLink, igManager, igTypePlugin, cDbConstraint, constraintCount); lModel.Constraints.Add(lConstraintView); } return(lModel); }
public static IFormattedConstraint NewFormattedConstraint( IObjectRepository tdb, IGSettingsManager igSettings, IIGTypePlugin igTypePlugin, IConstraint constraint, List <ConstraintReference> references, string templateLinkBase = null, string valueSetLinkBase = null, bool linkContainedTemplate = false, bool linkIsBookmark = false, bool createLinksForValueSets = false, bool includeCategory = true, ValueSet valueSet = null, CodeSystem codeSystem = null) { Type selectedType = null; if (igSettings == null || !igSettings.IsPublished) { var latestVersion = versions.Keys.OrderByDescending(y => y).First(); selectedType = versions[latestVersion]; } else { foreach (var versionDate in versions.Keys.OrderByDescending(y => y)) { if (igSettings.PublishDate > versionDate) { selectedType = versions[versionDate]; break; } } if (selectedType == null) { var latestVersion = versions.Keys.OrderByDescending(y => y).Last(); selectedType = versions[latestVersion]; } } IFormattedConstraint formattedConstraint = (IFormattedConstraint)Activator.CreateInstance(selectedType); formattedConstraint.Tdb = tdb; formattedConstraint.IgSettings = igSettings; formattedConstraint.IncludeCategory = includeCategory; formattedConstraint.TemplateLinkBase = templateLinkBase; formattedConstraint.ValueSetLinkBase = valueSetLinkBase; formattedConstraint.LinkContainedTemplate = linkContainedTemplate; formattedConstraint.LinkIsBookmark = linkIsBookmark; formattedConstraint.CreateLinkForValueSets = createLinksForValueSets; formattedConstraint.ConstraintReferences = references; // Set the properties in the FormattedConstraint based on the IConstraint formattedConstraint.ParseConstraint(igTypePlugin, constraint, valueSet, codeSystem); // Pre-process the constraint so that calls to GetHtml(), GetPlainText(), etc. returns something formattedConstraint.ParseFormattedConstraint(); return(formattedConstraint); }
public ConstraintExporter(XmlDocument dom, Template template, IGSettingsManager igSettings, IIGTypePlugin igTypePlugin, IObjectRepository tdb) { this.dom = dom; this.template = template; this.igSettings = igSettings; this.igTypePlugin = igTypePlugin; this.tdb = tdb; }
public StructureDefinitionExporter(IObjectRepository tdb, string scheme, string authority) { this.tdb = tdb; this.scheme = scheme; this.authority = authority; this.implementationGuideType = STU3Helper.GetImplementationGuideType(this.tdb, true); this.igTypePlugin = this.implementationGuideType.GetPlugin(); }
private void CreateConstraints(IGSettingsManager igManager, IIGTypePlugin igTypePlugin, IEnumerable <TemplateConstraint> constraints, List <ViewDataModel.Constraint> parentList, SimpleSchema templateSchema, SimpleSchema.SchemaObject schemaObject = null) { foreach (var constraint in constraints.OrderBy(y => y.Order)) { var theConstraint = constraint; // TODO: Possible bug? Should schemaObject always be re-set? Remove schemaObject == null from if() if (templateSchema != null && schemaObject == null) { schemaObject = templateSchema.Children.SingleOrDefault(y => y.Name == constraint.Context); } IFormattedConstraint fc = FormattedConstraintFactory.NewFormattedConstraint(this.tdb, igManager, igTypePlugin, theConstraint, this.constraintReferences.Cast <ConstraintReference>().ToList(), "#/volume2/", "#/valuesets/#", true, true, true, false); var newConstraintModel = new ViewDataModel.Constraint() { Number = string.Format("{0}-{1}", theConstraint.Template.OwningImplementationGuideId, theConstraint.Number), Narrative = fc.GetHtml(string.Empty, 1, true), Conformance = theConstraint.Conformance, Cardinality = theConstraint.Cardinality, Context = theConstraint.Context, DataType = theConstraint.DataType, Value = theConstraint.Value, ValueSetIdentifier = theConstraint.ValueSet != null?theConstraint.ValueSet.GetIdentifier(igTypePlugin) : null, ValueSetDate = theConstraint.ValueSetDate != null?theConstraint.ValueSetDate.Value.ToShortDateString() : null, IsChoice = theConstraint.IsChoice }; newConstraintModel.ContainedTemplates = (from cr in this.constraintReferences where cr.TemplateConstraintId == theConstraint.Id select new ViewDataModel.TemplateReference() { Identifier = cr.Identifier, Bookmark = cr.Bookmark, ImplementationGuide = cr.ImplementationGuide, PublishDate = cr.PublishDate, Name = cr.Name }).ToList(); var isFhir = constraint.Template.ImplementationGuideType.SchemaURI == ImplementationGuideType.FHIR_NS; // Check if we're dealing with a FHIR constraint if (isFhir && schemaObject != null) { newConstraintModel.DataType = schemaObject.DataType; } parentList.Add(newConstraintModel); var nextSchemaObject = schemaObject != null? schemaObject.Children.SingleOrDefault(y => y.Name == constraint.Context) : null; // Recursively add child constraints CreateConstraints(igManager, igTypePlugin, theConstraint.ChildConstraints, newConstraintModel.Constraints, null, nextSchemaObject); } }
public static string GetIdentifier(this ValueSet valueSet, IIGTypePlugin igTypePlugin) { if (igTypePlugin != null) { return(valueSet.GetIdentifier(igTypePlugin.DefaultIdentifierType)); } return(valueSet.GetIdentifier()); }
/// <summary> /// Creates a new instance of VersionComparer /// </summary> public static VersionComparer CreateComparer(IObjectRepository tdb, IIGTypePlugin igTypePlugin, IGSettingsManager igSettings) { VersionComparer comparer = new VersionComparer(); comparer.tdb = tdb; comparer.igTypePlugin = igTypePlugin; comparer.igSettings = igSettings; return(comparer); }
public TemplateExporter(IEnumerable <Template> templates, IObjectRepository tdb, int implementationGuideId) { this.templates = templates; this.tdb = tdb; this.igSettings = new IGSettingsManager(tdb, implementationGuideId); this.ig = this.tdb.ImplementationGuides.Single(y => y.Id == implementationGuideId); this.igTypePlugin = this.ig.ImplementationGuideType.GetPlugin(); this.publishedStatus = PublishStatus.GetPublishedStatus(tdb); this.retiredStatus = PublishStatus.GetRetiredStatus(tdb); }
public ValueSetsExport(IIGTypePlugin igTypePlugin, MainDocumentPart mainPart, HyperlinkTracker hyperlinkTracker, TableCollection tables, bool generateAsAppendix, int defaultMaxMembers, Dictionary <string, int> valueSetMaximumMembers) { this.igTypePlugin = igTypePlugin; this.mainPart = mainPart; this.hyperlinkTracker = hyperlinkTracker; this.tables = tables; this.generateAsAppendix = generateAsAppendix; this.defaultMaxMembers = defaultMaxMembers; this.valueSetMaximumMembers = valueSetMaximumMembers; }
public void MyTestInitialize() { this.mockRepo = TestDataGenerator.GenerateMockDataset2(); ImplementationGuide ig = this.mockRepo.ImplementationGuides.SingleOrDefault(y => y.Name == TestDataGenerator.DS2_IG_NAME); this.igSettings = new IGSettingsManager(this.mockRepo, ig.Id); this.igTypePlugin = ig.ImplementationGuideType.GetPlugin(); this.linkContainedTemplate = false; }
public TemplateConstraintTable(IObjectRepository tdb, List <ConstraintReference> references, IGSettingsManager igSettings, IIGTypePlugin igTypePlugin, List <Template> templates, TableCollection tables, List <string> selectedCategories, HyperlinkTracker hyperlinkTracker) { this.tdb = tdb; this.references = references; this.igSettings = igSettings; this.igTypePlugin = igTypePlugin; this.templates = templates; this.tables = tables; this.selectedCategories = selectedCategories; this.hyperlinkTracker = hyperlinkTracker; }
public void Setup() { this.tdb = new MockObjectRepository(); this.tdb.InitializeCDARepository(); this.tdb.InitializeFHIR3Repository(); var fhirIgType = this.tdb.FindImplementationGuideType(Constants.IGTypeNames.FHIR_STU3); this.fhirIg = this.tdb.FindOrCreateImplementationGuide(fhirIgType, "Test FHIR IG"); this.fhirIgSettings = new IGSettingsManager(this.tdb, this.fhirIg.Id); this.fhirIgTypePlugin = fhirIgType.GetPlugin(); }
public void TestFormattedConstraint_ContainedTemplate2() { TemplateConstraint ctConstraint = this.mockRepo.TemplateConstraints.Last(y => y.References.Any(x => x.ReferenceType == ConstraintReferenceTypes.Template)); IGSettingsManager igSettings = new IGSettingsManager(this.mockRepo, ctConstraint.Template.OwningImplementationGuideId); IIGTypePlugin igTypePlugin = ctConstraint.Template.OwningImplementationGuide.ImplementationGuideType.GetPlugin(); IFormattedConstraint fc = FormattedConstraintFactory.NewFormattedConstraint(mockRepo, igSettings, igTypePlugin, ctConstraint); string constraintText = fc.GetPlainText(); Assert.IsNotNull(constraintText); Assert.AreEqual("This entry SHALL contain exactly one [1..1] Test Template 2 (identifier: 1.2.3.4.5.6) (CONF:1-13).", constraintText); }
static public void AddCodeSystemToElement(IObjectRepository aTdb, IIGTypePlugin igTypePlugin, DocumentTemplateElement aElement, IConstraint aTemplateConstraint) { if (aTemplateConstraint.ValueCodeSystemId.HasValue && (aElement.ElementName == "value" || aElement.ElementName == "code")) { var codeSystem = aTdb.CodeSystems.Single(y => y.Id == aTemplateConstraint.ValueCodeSystemId); if (codeSystem != null) { var codeSystemIdentifier = igTypePlugin.ParseIdentifier(codeSystem.Oid); aElement.AddAttribute(new DocumentTemplateElementAttribute("codeSystem", codeSystemIdentifier, true)); //TODO: this is cda specific, need to update it } } }
public TemplateContextBuilder(IObjectRepository tdb, ImplementationGuideType igType, SimpleSchema igTypeSchema, string prefix = null) { this.tdb = tdb; this.igType = igType; this.plugin = this.igType.GetPlugin(); this.igTypeSchema = igTypeSchema; this.prefix = !string.IsNullOrEmpty(prefix) ? prefix : igType.SchemaPrefix; if (!string.IsNullOrEmpty(this.prefix) && this.prefix.EndsWith(":")) { this.prefix = this.prefix.Substring(0, this.prefix.Length - 1); } }
public ActionResult ViewIgChanges(int id) { if (!CheckPoint.Instance.GrantViewImplementationGuide(id)) { throw new AuthorizationException("You do not have access to view this implementation guide's changes."); } ImplementationGuide lGuide = this.tdb.ImplementationGuides.Single(ig => ig.Id == id); ViewChangesModel lModel = new ViewChangesModel(); IGSettingsManager igSettings = new IGSettingsManager(this.tdb, lGuide.Id); IIGTypePlugin igTypePlugin = lGuide.ImplementationGuideType.GetPlugin(); VersionComparer lComparer = VersionComparer.CreateComparer(tdb, igTypePlugin, igSettings); lModel.IgName = lGuide.Name; // Modified templates foreach (Template lNewTemplate in lGuide.ChildTemplates.Where(t => t.PreviousVersionTemplateId.HasValue)) { Template lPreviousVersion = this.tdb.Templates.Single(t => t.Id == lNewTemplate.PreviousVersionTemplateId.Value); ComparisonResult lResult = lComparer.Compare(lPreviousVersion, lNewTemplate); lModel.TemplateDifferences.Add( new DifferenceModel(lResult) { Id = lNewTemplate.Id, IsAdded = false, TemplateName = lNewTemplate.Name, PreviousTemplateName = string.Format("{0} ({1})", lPreviousVersion.Name, lPreviousVersion.Oid), PreviousTemplateId = lPreviousVersion.Id, Difference = lResult, InlineConstraints = GetInlineConstraintChanges(lResult) }); } // Added templates foreach (Template lNewTemplate in lGuide.ChildTemplates.Where(t => !t.PreviousVersionTemplateId.HasValue)) { ComparisonResult lResult = lComparer.Compare(new Template(), lNewTemplate); lModel.TemplateDifferences.Add( new DifferenceModel(lResult) { Id = lNewTemplate.Id, IsAdded = true, TemplateName = lNewTemplate.Name }); } return(View(lModel)); }
public BuildExporter(IObjectRepository tdb, int implementationGuideId, IEnumerable <Template> templates = null, bool jsonFormat = false) { this.tdb = tdb; this.ig = this.tdb.ImplementationGuides.SingleOrDefault(y => y.Id == implementationGuideId); this.igTypePlugin = this.ig.ImplementationGuideType.GetPlugin(); this.templates = templates ?? this.ig.GetRecursiveTemplates(this.tdb); this.schema = this.ig.ImplementationGuideType.GetSimpleSchema(); this.igName = this.ig.Name.Replace(" ", "_"); this.controlFileName = "ig.json"; this.JsonFormat = jsonFormat; this.dataExamples = new DataExamples(); }
private IEnumerable <ConstraintModel> GetConstraints(IObjectRepository tdb, Template template) { IGSettingsManager igSettings = new IGSettingsManager(tdb, template.OwningImplementationGuideId); IIGTypePlugin igTypePlugin = template.OwningImplementationGuide.ImplementationGuideType.GetPlugin(); var constraints = template.ChildConstraints.Where(y => y.ParentConstraintId == null); List <ConstraintModel> constraintModels = new List <ConstraintModel>(); foreach (TemplateConstraint rootConstraint in constraints.OrderBy(y => y.Order)) { var newConstraintModel = CreateConstraintModel(rootConstraint, igSettings, igTypePlugin); constraintModels.Add(newConstraintModel); } return(constraintModels); }
public static IFormattedConstraint NewFormattedConstraint( IObjectRepository tdb, IGSettingsManager igSettings, IIGTypePlugin igTypePlugin, TemplateConstraint constraint, List <ConstraintReference> references = null, string templateLinkBase = null, string valueSetLinkBase = null, bool linkContainedTemplate = false, bool linkIsBookmark = false, bool createLinksForValueSets = false, bool includeCategory = true) { if (references == null) { references = (from tcr in tdb.TemplateConstraintReferences join t in tdb.Templates on tcr.ReferenceIdentifier equals t.Oid where tcr.TemplateConstraintId == constraint.Id select new ConstraintReference() { Bookmark = t.Bookmark, Identifier = t.Oid, Name = t.Name, TemplateConstraintId = tcr.TemplateConstraintId }).ToList(); } else { references = references.Where(y => y.TemplateConstraintId == constraint.Id).ToList(); } return(NewFormattedConstraint( tdb, igSettings, igTypePlugin, (IConstraint)constraint, references, templateLinkBase, valueSetLinkBase, linkContainedTemplate, linkIsBookmark, createLinksForValueSets, includeCategory, constraint.ValueSet, constraint.CodeSystem)); }
private PublishConstraint BuildConstraint( DB.IObjectRepository tdb, string baseLink, IGSettingsManager igSettings, IIGTypePlugin igTypePlugin, DB.TemplateConstraint dbConstraint, int constraintCount, int?aParentConstraintId = null) { IFormattedConstraint fc = FormattedConstraintFactory.NewFormattedConstraint(tdb, igSettings, igTypePlugin, dbConstraint); PublishConstraint newConstraint = new PublishConstraint(dbConstraint, fc); foreach (DB.TemplateConstraintSample lSample in dbConstraint.Samples) { ConstraintSample lSampleView = new ConstraintSample() { Id = lSample.Id, Name = lSample.Name, SampleText = lSample.SampleText, ConstraintId = dbConstraint.Id }; newConstraint.Samples.Add(lSampleView); } if (aParentConstraintId.HasValue) { newConstraint.ParentConstraintId = aParentConstraintId.Value; } int nextConstraintCount = 0; foreach (DB.TemplateConstraint cDbConstraint in dbConstraint.ChildConstraints.OrderBy(y => y.Order)) { PublishConstraint nextNewConstraint = BuildConstraint(tdb, baseLink, igSettings, igTypePlugin, cDbConstraint, ++nextConstraintCount, dbConstraint.Id); newConstraint.ChildConstraints.Add(nextNewConstraint); } return(newConstraint); }
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 GreenTemplateViewModel MapEntityToViewModel(DB.Template aTemplate) { DB.GreenTemplate lGreenTemplate = aTemplate.GreenTemplates.DefaultIfEmpty(null).FirstOrDefault(); GreenTemplateViewModel lViewModel = new GreenTemplateViewModel(); if (lGreenTemplate == null) { lViewModel.Name = this.GetCamelCaseTemplateName(aTemplate.Name); lViewModel.IsNew = true; } else { lViewModel.Id = lGreenTemplate.Id; lViewModel.Name = lGreenTemplate.Name; } lViewModel.TemplateId = aTemplate.Id; lViewModel.TemplateName = aTemplate.Name; lViewModel.TemplateOid = aTemplate.Oid; IGSettingsManager igManager = new IGSettingsManager(_tdb, aTemplate.OwningImplementationGuideId); IIGTypePlugin igTypePlugin = aTemplate.OwningImplementationGuide.ImplementationGuideType.GetPlugin(); string baseLink = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path) + "?Id="; int constraintCount = 0; foreach (DB.TemplateConstraint cDbConstraint in aTemplate.ChildConstraints .Where(y => y.Parent == null) .Where(c => c.IsPrimitive == false) .Where(c => string.IsNullOrEmpty(c.Value)).OrderBy(y => y.Order)) { ConstraintViewModel lConstraintView = this.BuildConstraint(_tdb, baseLink, igManager, igTypePlugin, cDbConstraint, constraintCount); this.CreateIfRequiredGreenTemplateTree(lConstraintView); lViewModel.childConstraints.Add(lConstraintView); } return(lViewModel); }
private VocabularySystem GetSystem(IIGTypePlugin igTypePlugin, IObjectRepository tdb, ValueSet valueSet, DateTime?bindingDate, bool isCDA) { if (valueSet == null) { throw new Exception("Could not find ValueSet specified."); } VocabularySystems schema = new VocabularySystems(); VocabularySystem schemaValueSet = new VocabularySystem() { ValueSetOid = valueSet.GetIdentifier(igTypePlugin), ValueSetName = valueSet.Name }; if (isCDA && schemaValueSet.ValueSetOid.StartsWith("urn:oid:")) { schemaValueSet.ValueSetOid = schemaValueSet.ValueSetOid.Substring(8); } schemaValueSet.Codes = GetCodes(valueSet, bindingDate, isCDA); return(schemaValueSet); }
public ConstraintParser(IObjectRepository tdb, IConstraint constraint, ImplementationGuideType igType, string valueSetFile = "voc.xml", VocabularyOutputType vocabularyOutputType = VocabularyOutputType.Default) { this.tdb = tdb; this.constraint = constraint; this.valueSetFile = valueSetFile; this.igTypePlugin = igType.GetPlugin(); if (this.constraint.ValueSetId != null) { this.constraintValueSet = this.tdb.ValueSets.Single(y => y.Id == constraint.ValueSetId); } if (this.constraint.ValueCodeSystemId != null) { this.constraintCodeSystem = this.tdb.CodeSystems.Single(y => y.Id == constraint.ValueCodeSystemId); } if (!string.IsNullOrEmpty(this.constraint.Cardinality)) { this.constraintCardinalityType = CardinalityParser.Parse(this.constraint.Cardinality); } if (!string.IsNullOrEmpty(this.constraint.Conformance)) { this.constraintConformanceType = ConformanceParser.Parse(this.constraint.Conformance); } if (this.constraint.ContainedTemplateId != null) { this.containedTemplate = this.tdb.Templates.Single(y => y.Id == this.constraint.ContainedTemplateId.Value); } this.prefix = igType.SchemaPrefix; this.vocabularyOutputType = vocabularyOutputType; }
public void Setup() { this.mockRepo = TestDataGenerator.GenerateMockDataset4(); IEnumerable <int> templateIds = (from t in this.mockRepo.Templates select t.Id); ImplementationGuide ig = this.mockRepo.ImplementationGuides.Single(y => y.Name == TestDataGenerator.DS1_IG_NAME); IIGTypePlugin igTypePlugin = ig.ImplementationGuideType.GetPlugin(); ImplementationGuideGenerator generator = new ImplementationGuideGenerator(this.mockRepo, 1, templateIds); ExportSettings lSettings = new ExportSettings(); lSettings.Use(s => { s.GenerateTemplateConstraintTable = true; s.GenerateTemplateContextTable = true; s.GenerateDocTemplateListTable = true; s.GenerateDocContainmentTable = true; s.AlphaHierarchicalOrder = false; s.DefaultValueSetMaxMembers = 10; s.GenerateValueSetAppendix = true; s.IncludeXmlSamples = true; s.IncludeChangeList = false; s.IncludeTemplateStatus = true; s.IncludeNotes = true; }); generator.BuildImplementationGuide(lSettings, igTypePlugin); this.docBytes = generator.GetDocument(); this.docContents = GetWordDocumentContents(docBytes); this.docComments = GetWordCommentContents(docBytes); this.doc = ReadWordDocXml(this.docContents, out this.docNsMgr); this.comments = ReadWordDocXml(this.docComments, out this.commentsNsMgr); GenerateIGFileTest(); }
public void ParseConstraint(IIGTypePlugin igTypePlugin, IConstraint constraint, ValueSet valueSet = null, CodeSystem codeSystem = null) { this.Category = constraint.Category; this.Number = constraint.GetFormattedNumber(this.igSettings == null ? null : this.igSettings.PublishDate); this.Context = constraint.Context; this.IsPrimitive = constraint.IsPrimitive == true; this.IsBranch = constraint.IsBranch == true; this.HasChildren = constraint.Children != null && constraint.Children.Count() > 0; this.Narrative = constraint.PrimitiveText; this.Description = constraint.Description; this.Label = constraint.Label; this.IsHeading = constraint.IsHeading; this.HeadingDescription = constraint.HeadingDescription; if (constraint.Parent != null) { this.ParentIsBranch = constraint.Parent.IsBranch == true; this.ParentContext = constraint.Parent.Context; this.ParentCardinality = constraint.Parent.Cardinality; } this.Conformance = constraint.Conformance; this.Cardinality = constraint.Cardinality; this.DataType = constraint.DataType; this.ValueConformance = constraint.ValueConformance; if (constraint.IsStatic == true) { this.StaticDynamic = "STATIC"; } else if (constraint.IsStatic == false) { this.StaticDynamic = "DYNAMIC"; } if (constraint.ValueSetId != null) { // If the caller didn't pass in the ValueSet, get it from the db if (valueSet == null && constraint is TemplateConstraint) { valueSet = ((TemplateConstraint)constraint).ValueSet; } else if (valueSet == null || valueSet.Id != constraint.ValueSetId) { valueSet = this.tdb.ValueSets.Single(y => y.Id == constraint.ValueSetId); } this.ValueSetName = valueSet.Name; this.ValueSetOid = valueSet.GetIdentifier(igTypePlugin); this.ValueSetVersion = constraint.ValueSetDate; } if (constraint.ValueCodeSystemId != null) { // If the caller didn't pass in the CodeSystem, get it from the db if (codeSystem == null && constraint is TemplateConstraint) { codeSystem = ((TemplateConstraint)constraint).CodeSystem; } else if (codeSystem == null || codeSystem.Id != constraint.ValueCodeSystemId) { codeSystem = this.tdb.CodeSystems.Single(y => y.Id == constraint.ValueCodeSystemId); } this.CodeSystemName = codeSystem.Name; this.CodeSystemOid = codeSystem.Oid; } this.Value = constraint.Value; this.DisplayName = constraint.ValueDisplayName; }