Beispiel #1
0
        public static string GetIdentifier(this ValueSet valueSet, IIGTypePlugin igTypePlugin)
        {
            if (igTypePlugin != null)
            {
                return(valueSet.GetIdentifier(igTypePlugin.DefaultIdentifierType));
            }

            return(valueSet.GetIdentifier());
        }
Beispiel #2
0
        private string GetValueSetDisplay(IConstraint constraint)
        {
            if (constraint.ValueSetId != null)
            {
                ValueSet valueSet = null;

                if (constraint is TemplateConstraint)
                {
                    valueSet = ((TemplateConstraint)constraint).ValueSet;
                }
                else
                {
                    valueSet = this.tdb.ValueSets.Single(y => y.Id == constraint.ValueSetId);
                }

                return(string.Format("{0} ({1})", valueSet.Name, valueSet.GetIdentifier(this.igTypePlugin)));
            }

            return(string.Empty);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        private void AddValueSetDetailTable(ValueSet valueSet, DateTime bindingDate)
        {
            string valueSetIdentifier     = valueSet.GetIdentifier(this.igTypePlugin);
            string bookmarkId             = this.GetValueSetBookmark(valueSet);
            List <ValueSetMember> members = valueSet.GetActiveMembers(bindingDate);

            if (members == null || members.Count == 0)
            {
                return;
            }

            TableCell headingCell = new TableCell(
                new TableCellProperties()
            {
                GridSpan = new GridSpan()
                {
                    Val = 4
                }
            },
                new Paragraph(
                    new ParagraphProperties(new ParagraphStyleId()
            {
                Val = Properties.Settings.Default.TableContentStyle
            }),
                    DocHelper.CreateRun(
                        string.Format("Value Set: {0} {1}", valueSet.Name, valueSet.GetIdentifier(igTypePlugin)))));

            if (!string.IsNullOrEmpty(valueSet.Description))
            {
                headingCell.Append(
                    new Paragraph(
                        new ParagraphProperties(new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }),
                        DocHelper.CreateRun(valueSet.Description)));
            }

            if (!string.IsNullOrEmpty(valueSet.Source))
            {
                headingCell.Append(
                    new Paragraph(
                        new ParagraphProperties(new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }),
                        DocHelper.CreateRun("Value Set Source: "),
                        this.hyperlinkTracker.CreateUrlHyperlink(this.mainPart, valueSet.Source, valueSet.Source, Properties.Settings.Default.LinkStyle)));
            }

            TableRow         headerRow   = DocHelper.CreateTableHeader("Code", "Code System", "Code System OID", "Print Name");
            List <TableCell> headerCells = headerRow.ChildElements.OfType <TableCell>().ToList();

            headerCells[0].ChildElements.OfType <TableCellProperties>().First().TableCellWidth = new TableCellWidth()
            {
                Width = "1560"
            };
            headerCells[1].ChildElements.OfType <TableCellProperties>().First().TableCellWidth = new TableCellWidth()
            {
                Width = "3000"
            };
            headerCells[2].ChildElements.OfType <TableCellProperties>().First().TableCellWidth = new TableCellWidth()
            {
                Width = "3000"
            };
            headerCells[3].ChildElements.OfType <TableCellProperties>().First().TableCellWidth = new TableCellWidth()
            {
                Width = "2520"
            };
            Table t = DocHelper.CreateTable(
                new TableRow(headingCell),
                headerRow);

            int maximumMembers = this.defaultMaxMembers;

            if (this.valueSetMaximumMembers != null && this.valueSetMaximumMembers.ContainsKey(valueSetIdentifier))
            {
                maximumMembers = this.valueSetMaximumMembers[valueSetIdentifier];
            }

            int count = 0;

            foreach (ValueSetMember currentMember in members)
            {
                if (count >= maximumMembers)
                {
                    break;
                }

                TableRow memberRow = new TableRow(
                    new TableCell(
                        new TableCellProperties()
                {
                    TableCellWidth = new TableCellWidth()
                    {
                        Width = "1170"
                    }
                },
                        new Paragraph(
                            new ParagraphProperties(
                                new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }),
                            DocHelper.CreateRun(currentMember.Code))),
                    new TableCell(
                        new TableCellProperties()
                {
                    TableCellWidth = new TableCellWidth()
                    {
                        Width = "3195"
                    }
                },
                        new Paragraph(
                            new ParagraphProperties(
                                new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }),
                            DocHelper.CreateRun(currentMember.CodeSystem.Name))),
                    new TableCell(
                        new TableCellProperties()
                {
                    TableCellWidth = new TableCellWidth()
                    {
                        Width = "3195"
                    }
                },
                        new Paragraph(
                            new ParagraphProperties(
                                new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }),
                            DocHelper.CreateRun(currentMember.CodeSystem.Oid))),
                    new TableCell(
                        new TableCellProperties()
                {
                    TableCellWidth = new TableCellWidth()
                    {
                        Width = "2520"
                    }
                },
                        new Paragraph(
                            new ParagraphProperties(
                                new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }),
                            DocHelper.CreateRun(currentMember.DisplayName)))
                    );

                t.Append(memberRow);
                count++;
            }

            if (count <= members.Count - 1 || valueSet.IsIncomplete)
            {
                TableRow moreMembersRow = new TableRow(
                    new TableCell(
                        new TableCellProperties()
                {
                    GridSpan = new GridSpan()
                    {
                        Val = 4
                    }
                },
                        new Paragraph(
                            new ParagraphProperties(
                                new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TableContentStyle
                }),
                            DocHelper.CreateRun("..."))));
                t.Append(moreMembersRow);
            }

            this.tables.AddTable(valueSet.Name, t, bookmarkId);
        }
        public void ParseConstraint(IIGTypePlugin igTypePlugin, IConstraint constraint, ValueSet valueSet = null, CodeSystem codeSystem = null)
        {
            this.childCount = constraint.Children != null?constraint.Children.Count() : 0;

            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;
            this.IsChoice           = constraint.IsChoice;
            this.Conformance        = constraint.Conformance;
            this.Cardinality        = constraint.Cardinality;
            this.DataType           = constraint.DataType;

            if (constraint.Parent != null)
            {
                var parent = constraint.Parent;

                // Ignore the fact that the parent is a choice if this is the only constraint within the parent...
                // The parent is ignored in this case, and this constraint should be treated as a normal constraint
                if (parent.IsChoice && parent.Children.Count() == 1)
                {
                    this.Conformance = parent.Conformance;
                    this.Cardinality = parent.Cardinality;

                    if (parent.Parent != null)
                    {
                        parent = constraint.Parent.Parent;
                    }
                }

                this.ParentIsBranch    = parent.IsBranch == true;
                this.ParentContext     = parent.Context;
                this.ParentCardinality = parent.Cardinality;
                this.ParentIsChoice    = parent.IsChoice;

                this.indexInSiblings = parent.Children.OrderBy(y => y.Order).ToList().IndexOf(constraint);
            }

            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;
        }