Ejemplo n.º 1
0
        void BuildCodeSystem(CSInfo ci)
        {
            CodeBlockNested csFields = ci.ClassCode.Blocks.Find("Fields");

            csFields
            .AppendCode($"const string System = \"{ci.CodeSystem.Url}\";");
            ;

            if (ci.CodeSystem.Filter.Count > 0)
            {
                throw new NotImplementedException("Have not implemented CodeSystem.Filter");
            }

            foreach (CodeSystem.ConceptDefinitionComponent component in ci.CodeSystem.Concept)
            {
                String display = component.Display?.Replace("\"", "'");
                String code    = component.Code;

                csFields
                .BlankLine()
                .AppendLine("/// <summary>")
                ;
                if (component.Definition != null)
                {
                    foreach (String line in component.Definition.Split('\n'))
                    {
                        String s = line
                                   .Trim()
                                   .Replace("\r", "")
                                   .Replace("%", "\\%")
                        ;
                        s = WebUtility.HtmlEncode(s);
                        csFields.AppendLine($"/// {s}");
                    }
                }

                csFields
                .AppendLine("/// </summary>")
                .AppendCode($"public static Coding {CSMisc.CodeName(component.Code)} = new Coding(System, \"{code}\", \"{display}\");")
                ;
            }
        }
Ejemplo n.º 2
0
        public static bool BindingClassName(ElementDefinition elementDefinition,
                                            out String bindingClassName,
                                            out ElementDefinition.ElementDefinitionBindingComponent binding)
        {
            bindingClassName = null;
            binding          = elementDefinition.Binding;
            if (binding == null)
            {
                return(false);
            }

            ElementDefinition.ElementDefinitionBindingComponent bindingComp = elementDefinition.Binding;
            String valueSet = bindingComp.ValueSet;

            // currently we only do local value sets.
            if (valueSet.StartsWith(Global.LocalValueSetUrl) == false)
            {
                return(false);
            }
            String vsClassName = CSMisc.MachineName(valueSet.LastUriPart());

            bindingClassName = $"{vsClassName}.TCoding";
            return(true);
        }
Ejemplo n.º 3
0
        public override void Build()
        {
            const String fcn = "Build";

            this.CSBuilder.ConversionInfo(this.GetType().Name,
                                          fcn,
                                          $"Building {this.fragBase.StructDef.Url.LastUriPart()}");

            base.Build();

            //{
            //    if (this.fragBase.SnapNodes.TryGetElementNode("Extension.extension", out ElementTreeNode extensionNode) == false)
            //        throw new Exception($"Extension.extension node is missing");
            //    BuildItemExtension bmv = new BuildItemExtension(this, this.fragBase.CodeBlocks);
            //    bmv.Build(CSMisc.ClassName(this.fragBase), extensionNode);
            //}
            {
                BuildMembers.BuildMemberExtension bm = new BuildMembers.BuildMemberExtension(this,
                                                                                             this.fragBase.CodeBlocks,
                                                                                             this.fragBase.SnapNodes.DefaultSlice,
                                                                                             CSMisc.ClassName(this.fragBase));
                bm.Build();
            }
        }
Ejemplo n.º 4
0
 public static String LocalClassNameSpace(String name) => $"BreastRadLib.{CSMisc.ClassName(name)}Local;";
Ejemplo n.º 5
0
 public static String LocalClassNameSpace(SDInfo fi) => $"BreastRadLib.{CSMisc.ClassName(fi)}Local;";
Ejemplo n.º 6
0
        void SaveAll()
        {
            this.resourceFactoryEditor.Save();
            this.fc.Mark(this.resourceFactoryEditor.SavePath);
            foreach (SDInfo fi in this.SDFragments.Values)
            {
                this.Save(fi.InterfaceEditor, Path.Combine(this.OutputDir, "Generated", "Interfaces", $"{CSMisc.InterfaceName(fi)}.cs"));
                if (fi.ClassEditor != null)
                {
                    if (
                        (fi.IsFragment() == true) ||
                        (fi.StructDef.BaseDefinition == Global.ExtensionUrl)
                        )
                    {
                        this.Save(fi.ClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}.txt"));
                    }
                    else
                    {
                        this.Save(fi.ClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}.cs"));
                    }
                }
                if (fi.SubClassEditor != null)
                {
                    this.Save(fi.SubClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}Local.cs"));
                }
            }

            foreach (CSInfo ci in this.CodeSystems.Values)
            {
                this.Save(ci.ClassCode, Path.Combine(this.OutputDir, "Generated", "CodeSystems", $"{CSMisc.CodeSystemName(ci)}.cs"));
            }

            foreach (VSInfo vi in this.ValueSets.Values)
            {
                this.Save(vi.ClassCode, Path.Combine(this.OutputDir, "Generated", "ValueSets", $"{CSMisc.ValueSetName(vi)}.cs"));
            }
        }
Ejemplo n.º 7
0
        void BuildFragment(SDInfo fi)
        {
            const String fcn = "BuildFragment";

            String fhirType = fi.BaseDefinitionName;

            this.ConversionInfo(this.GetType().Name,
                                fcn,
                                $"Processing fragment {fi.StructDef.Name}");

            if (String.Compare(CSMisc.ClassName(fi), this.BreakOnClass, StringComparison.OrdinalIgnoreCase) == 0)
            {
                Debugger.Break();
            }

            if (
                (fi.IsFragment() == false) &&
                (fi.StructDef.BaseDefinition != Global.ExtensionUrl)
                )
            {
                String url = fi.StructDef.Url.Trim().ToLower();
                this.resourceFactoryProfileBlock
                .AppendCode($"case \"{url}\":")
                .AppendCode($"    return new {CSMisc.ClassName(fi)}(doc, ({fhirType}) resource);")
                ;
            }

            this.DefineInterfaces(fi);
            DefineBase csDef = null;

            switch (fi.StructDef.BaseDefinition)
            {
            case Global.ExtensionUrl:
                csDef = new DefineExtension(this, fi);
                break;

            case Global.ResourceUrl:
                break;

            case Global.ObservationUrl:
                csDef = new DefineObservation(this, fi);
                break;

            case Global.DiagnosticReportUrl:
                csDef = new DefineDiagnosticReport(this, fi);
                break;

            case Global.CompositionUrl:
                csDef = new DefineComposition(this, fi);
                break;

            case Global.ServiceRequestUrl:
                csDef = new DefineServiceRequest(this, fi);
                break;

            default:
                this.ConversionError(this.GetType().Name,
                                     fcn,
                                     $"No builder defined for class {fi.StructDef.BaseDefinition}");
                break;
            }

            if (csDef != null)
            {
                csDef.Clear();
                csDef.DefBase();
                csDef.Build();
            }
        }