bool ILanguangeExporter.AppendValueSetClose(ref StringBuilder sb, string sanitizedAlias, string sanitizedName, fhir.ValueSet valueSet)
        {
            // **** close our class ****

            sb.Append($"\t}};\n");
            return(true);
        }
Ejemplo n.º 2
0
        static bool ProcessPublishedJson(Options options)
        {
            string dir = Path.Combine(options.FhirDirectory, "publish");

            // **** check for this directory existing ****

            if (!Directory.Exists(dir))
            {
                Console.WriteLine("Publish directory not found!");
                return(false);
            }

            // **** get all canonical files in the publish directory ****

            string[] files = Directory.GetFiles(dir, "*.canonical.json", SearchOption.AllDirectories);

            // **** traverse the files ****

            foreach (string filename in files)
            {
                // **** read the contents ****

                string contents = File.ReadAllText(filename);

                // **** act depending on contents ****

                if (contents.Contains("\"resourceType\":\"StructureDefinition\""))
                {
                    // **** check for ignoring these ****

                    if (options.UseOnlyXmlSpreadsheets)
                    {
                        continue;
                    }

                    // **** parse into an object we can work with ****

                    fhir.StructureDefinition sd = JsonConvert.DeserializeObject <fhir.StructureDefinition>(contents);

                    // **** process this structure definition ****

                    ProcessStructureDefinition(sd, filename);

                    // **** done with this file ****

                    continue;
                }

                if (contents.Contains("\"resourceType\":\"CodeSystem\""))
                {
                    if (options.ExcludeCodeSystems)
                    {
                        continue;
                    }

                    // **** parse into an object we can work with ****

                    fhir.CodeSystem cs = JsonConvert.DeserializeObject <fhir.CodeSystem>(contents);

                    // **** process this code system ****

                    FhirTypeManager.LoadCodeSystem(cs);

                    // **** done with this file ****

                    continue;
                }

                if (contents.Contains("\"resourceType\":\"ValueSet\""))
                {
                    if (options.ExcludeValueSets)
                    {
                        continue;
                    }

                    // **** parse into an object we can work with ****

                    fhir.ValueSet vs = JsonConvert.DeserializeObject <fhir.ValueSet>(contents);

                    // **** process this value set ****

                    FhirTypeManager.LoadValueSet(vs, filename);

                    // **** done with this file ****

                    continue;
                }
            }


            // **** success *****

            return(true);
        }
        bool ILanguangeExporter.AppendValueSetOpen(ref StringBuilder sb, string sanitizedAlias, string sanitizedName, fhir.ValueSet valueSet)
        {
            // **** start with a comment ****

            if (!string.IsNullOrEmpty(valueSet.Description))
            {
                sb.Append($"\t///<summary>{FhirTypeManager.SanitizeComment(valueSet.Description, _lineComment, _indentChar, 1)}</summary>\n");
            }
            else
            {
                sb.Append($"\t///<summary>Expanded ValueSet from {valueSet.Url}</summary>\n");
            }

            // **** open our value set ****

            sb.Append($"\tpublic abstract class {sanitizedName}\n\t{{\n");

            return(true);
        }