예제 #1
0
        private XElement GenerateCodeTable(ValueSetCode[] codes, uri codeSystem, bool isExternal)
        {
            bool showDefinition = (!isExternal) && (!codes.All(t => string.IsNullOrWhiteSpace(t.Definition)));

            return(BootstrapHtml.Table(Styles.TableLayoutFixedClassName, new object[]
            {
                Html.THead(new object[]
                {
                    Html.Th(Styles.TableColumn20pcClassName, "Code"),
                    Html.Th(Styles.TableColumn20pcClassName, "Display"),
                    Html.Th(showDefinition ? "Definition" : string.Empty)
                }),
                Html.TBody
                (
                    codes.Select(t => Html.Tr(new object[]
                {
                    Html.Td(GetCodeWithHyperlink(t.Code, codeSystem.WhenNotNull(s => s.value))),
                    Html.Td(t.DisplayName ?? (isExternal ? "(see external code system)" : string.Empty)),
                    Html.Td(showDefinition ? t.Definition : string.Empty)
                }))
                )
            }));
        }
예제 #2
0
        private XElement GenerateCodeExpansion(ValueSet valueset)
        {
            ValueSetCode[] expansion = new ValueSetCode[] { };

            bool showCodeSystem = true;

            // has already defined expansion
            if (valueset.expansion.WhenNotNull(t => t.contains.WhenNotNull(s => s.Length > 0)))
            {
                expansion = valueset
                            .expansion
                            .contains
                            .Select(t => new ValueSetCode()
                {
                    Code        = t.code.WhenNotNull(s => s.value),
                    DisplayName = t.display.WhenNotNull(s => s.value),
                    Definition  = t.system.WhenNotNull(s => s.value)
                })
                            .ToArray();

                showCodeSystem = (valueset
                                  .expansion
                                  .contains
                                  .DistinctBy(t => t.system.WhenNotNull(s => s.value)).Count() > 1);
            }

            if (valueset.compose != null)
            {
                if (valueset.compose.import != null)
                {
                    foreach (uri uri in valueset.compose.import)
                    {
                        // process valueset imports
                    }
                }

                if (valueset.compose.include != null)
                {
                    foreach (ValueSetInclude include in valueset.compose.include)
                    {
                        if (include.concept.WhenNotNull(t => t.Length > 0))
                        {
                            continue;
                        }

                        if (include.filter.WhenNotNull(t => t.Length > 0))
                        {
                            foreach (ValueSetFilter filter in include.filter)
                            {
                                // process filters
                            }
                        }
                        else
                        {
                            // process all
                        }
                    }
                }
            }

            object tableRows = Html.Tr(Html.Td(Html.I("(not available)")));

            if (expansion.Length > 0)
            {
                tableRows = expansion
                            .Select(t => Html.Tr(new object[]
                {
                    Html.Td(t.Code),
                    Html.Td(t.DisplayName),
                    Html.Td(showCodeSystem ? t.Definition : string.Empty)
                }))
                            .ToArray();
            }

            return(BootstrapHtml.Table(Styles.TableLayoutFixedClassName, new object[]
            {
                Html.THead(new object[]
                {
                    Html.Th(Styles.TableColumn20pcClassName, "Code"),
                    Html.Th(Styles.TableColumn20pcClassName, "Display"),
                    Html.Th(showCodeSystem ? "Code system" : string.Empty)
                }),
                Html.TBody
                (
                    tableRows
                )
            }));
        }