Exemplo n.º 1
0
        public void AddFiles(params String[] inputDirs)
        {
            foreach (String inputDir in inputDirs)
            {
                foreach (String file in Directory.GetFiles(inputDir))
                {
                    FSHFile f = new FSHFile(file);
                    files.Add(f);
                    foreach (String line in f.Lines)
                    {
                        String s = line.Trim();

                        String Name()
                        {
                            int    i      = s.IndexOf(':');
                            String retVal = s.Substring(i + 1).Trim();

                            i = retVal.IndexOf(' ');
                            if (i > 0)
                            {
                                retVal = retVal.Substring(0, i).Trim();
                            }
                            return(retVal);
                        }

                        if (s.StartsWith("CodeSystem"))
                        {
                            codeSystems.Add(Name(), f);
                        }
                        else if (s.StartsWith("ValueSet"))
                        {
                            valueSets.Add(Name(), f);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        void Process(String codeSystemName,
                     CodeSystem.ConceptDefinitionComponent concept,
                     FSHFile f)
        {
            if (String.IsNullOrEmpty(concept.Definition) == true)
            {
                return;
            }

            String code = concept.Code;

            switch (code)
            {
            case "mgBreastDensityObservation":
                break;

            case "mgFindingObservationObservation":
                code = "mgFindingObservation";
                break;

            case "mgDensity":
                code = "mgBreastDensity";
                break;

            case "EqualDensity":
                code = "HeterogeneouslyDense";
                break;

            case "FatContaining":
                code = "AlmostEntirelyFat";
                break;

            case "HighDensity":
                code = "ExtremelyDense";
                break;

            case "LowDensity":
                code = "ScatteredAreasOfFibroglandularDensity";
                break;

            case "mgCalcificationDistribution":
            case "CentralLucent":
                return;

            default:
                code = code.Replace("Quadrent", "Quadrant");
                if (code.StartsWith("sectionCode"))
                {
                    code = code.Substring(11);
                }
                if (code.StartsWith("section"))
                {
                    code = code.Substring(7);
                }
                if (code.StartsWith("mg"))
                {
                    code = code.Substring(2);
                }
                break;
            }
            Int32 i = f.FindConcept(codeSystemName, code);

            if (i < 0)
            {
                Console.WriteLine($"Error finding concept '{codeSystemName}#{code}' in FSH file {Path.GetFileName(f.Path)}");
                return;
            }
            void InsertLine(String s)
            {
                i += 1;
                f.Lines.Insert(i, s);
            }

            void RemoveBlanks()
            {
                Int32 j = i + 1;

                while (j < f.Lines.Count)
                {
                    if (String.IsNullOrEmpty(f.Lines[j].Trim()) == false)
                    {
                        return;
                    }
                    f.Lines.RemoveAt(j);
                }
            }

            bool HasMLComment()
            {
                if (i >= f.Lines.Count)
                {
                    return(false);
                }
                return(f.Lines[i + 1].Trim().StartsWith("\"\"\""));
            }

            if (HasMLComment())
            {
                return;
            }

            InsertLine("    \"\"\"");
            bool blankLineFlag = false;

            foreach (String s in concept.Definition.Split('\n'))
            {
                String line = s.Trim()
                              .Replace("\r", "")
                              .Replace("\"", "'")
                ;
                bool thisBlanksLine = String.IsNullOrEmpty(line);
                if ((blankLineFlag == false) || (thisBlanksLine == false))
                {
                    InsertLine($"    {line}");
                }
                blankLineFlag = thisBlanksLine;
            }

            InsertLine("    \"\"\"");
            InsertLine("");
            RemoveBlanks();
        }
Exemplo n.º 3
0
 public bool TryGetCodeSystem(String name, out FSHFile f) => this.codeSystems.TryGetValue(name, out f);