Пример #1
0
        private static object GetCodeWithHyperlink(string code, string codeSystem)
        {
            object result = code;

            if (SnomedHelper.IsSnomedSystemUri(codeSystem))
            {
                result = Html.A(SnomedHelper.GetBrowserUrl(code), code);
            }

            return(result);
        }
Пример #2
0
        private object[] GenerateDefinition(ConceptMap conceptMap)
        {
            List <object> result = new List <object>();
            List <object> table  = new List <object>();


            table.Add(Html.Tr(new object[]
            {
                Html.Td(Html.B("Source")),
                Html.Td(""),
                Html.Td(Html.B("Target")),
                Html.Td("")
            }
                              ));
            ValueSet sourceValueSet = null;
            ValueSet targetValueSet = null;


            if (conceptMap.Item != null && conceptMap.Item.GetType() == typeof(Reference))
            {
                // Cheating a little here at the mo. Not safe
                Reference source = (Reference)conceptMap.Item;
                Reference target = (Reference)conceptMap.Item1;

                Link sourceValuesetLink = _profileSet.GetValueSetLink(source.reference.GetValueAsString());
                Link targetValuesetLink = _profileSet.GetValueSetLink(target.reference.GetValueAsString());
                sourceValueSet = _profileSet.GetValueSet(source.reference.GetValueAsString());
                targetValueSet = _profileSet.GetValueSet(target.reference.GetValueAsString());

                table.Add(Html.Tr(new object[]
                {
                    Html.Td(Html.P(GetLabelAndValue("Valueset", new object[]
                    {
                        Html.A(sourceValuesetLink.Url, sourceValuesetLink.Display)
                    }))),
                    Html.Td(""),
                    Html.Td(Html.P(GetLabelAndValue("Valueset", new object[]
                    {
                        Html.A(targetValuesetLink.Url, targetValuesetLink.Display)
                    }))),
                    Html.Td("")
                }
                                  ));
            }

            if (conceptMap.element != null && sourceValueSet != null && targetValueSet != null)
            {
                foreach (ConceptMapElement element in conceptMap.element)
                {
                    string sourceCode = element.code.GetValueAsString();     // GetExtensionValueAsString(FhirConstants.ValueSetSystemNameExtensionUrl);
                    string sourceName = "";
                    foreach (ValueSetInclude include in sourceValueSet.compose.include)
                    {
                        foreach (ValueSetConcept1 concept in include.concept)
                        {
                            if (concept.code.value.Equals(sourceCode))
                            {
                                sourceName = concept.display.GetValueAsString();
                            }
                        }
                    }
                    if (element.code.WhenNotNull(t => t.ToString().Length) > 0)
                    {
                        if (element.target != null)
                        {
                            bool isFirstTarget = true;

                            foreach (ConceptMapTarget target in element.target)
                            {
                                if (!isFirstTarget)
                                {
                                    sourceCode = "";
                                }
                                isFirstTarget = true;
                                string targetCode = target.code.GetValueAsString();
                                string targetName = "";
                                foreach (ValueSetInclude include in targetValueSet.compose.include)
                                {
                                    foreach (ValueSetConcept1 concept in include.concept)
                                    {
                                        if (concept.code.value.Equals(targetCode))
                                        {
                                            targetName = concept.display.GetValueAsString();
                                        }
                                    }
                                }
                                // Need to check codeSystem is SNOMED
                                if (float.Parse(targetCode) > 0 && targetCode.Length > 7)
                                {
                                    table.Add(Html.Tr(new object[]
                                    {
                                        Html.Td(sourceCode),
                                        Html.Td(sourceName),
                                        Html.Td(Html.A(SnomedHelper.GetBrowserUrl(targetCode), targetCode)),
                                        Html.Td(targetName)
                                    }
                                                      ));
                                }
                                else
                                {
                                    table.Add(Html.Tr(new object[]
                                    {
                                        Html.Td(sourceCode),
                                        Html.Td(sourceName),
                                        Html.Td(targetCode),
                                        Html.Td(targetName)
                                    }
                                                      ));
                                }
                            }
                        }
                        else
                        {
                            table.Add(Html.Tr(new object[]
                            {
                                Html.Td(sourceCode),
                                Html.Td(""),
                                Html.Td(""),
                                Html.Td("")
                            }
                                              )
                                      );
                        }
                    }
                }
            }
            result.Add(Html.Table(new object[] { table, Html.Class(Styles.ValueSetReferenceTableClassName) }));

            return(result.ToArray());
        }